<?php

/*

osCommerce, Open Source E-Commerce Solutions 
http://www.oscommerce.com 

Copyright (c) 2003 osCommerce 

osCommRes, Services Oline 
http://www.oscommres.com 
Copyright (c) 2005 osCommRes 

Freeway eCommerce 
http://www.zac-ware.com/freeway 
Copyright (c) 2007 ZacWare

Released under the GNU General Public License
*/
// Set flag that this is a parent file
	define( '_FEXEC', 1 );

include('includes/application_top.php');

?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title>Quick Products Listing</title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">

<script>
<!--
function selectAll(formObj, isInverse)
{
   for (var i=0;i < formObj.length;i++)
   {
      fldObj = formObj.elements[i];
      if (fldObj.type == 'checkbox')
      {
         if(isInverse)
            fldObj.checked = (fldObj.checked) ? false : true;
         else fldObj.checked = true;
       }
   }
}
-->
</script>

<?php /* BOF: WebMakers.com Added: PopUp Window */ ?>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function NewWindow3(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
//  End -->
</script>
<?php /* EOF: WebMakers.com Added: PopUp Window */ ?>

</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onLoad="SetFocus();">
<table style="border:none" border="0" align="center" class="none">
  <tr><td class="smallText">
<?php

?>
<br><form method="post" action="products_quick_popup.php">
<?php

   // first select all categories that have 0 as parent:
      $sql = tep_db_query("SELECT c.categories_id, cd.categories_name from categories c, categories_description cd WHERE c.parent_id = 0 AND c.categories_id = cd.categories_id AND cd.language_id = 1");
        echo '<center><b>Quick Product Locator</b>'. tep_draw_separator('pixel_trans.gif', '100%', '3') . '</center>' . "\n";
        echo '<table border="1" align="center">' . "\n" . ' ' . ' <tr class="smallText">' . "\n";
        $count_it=0;
        while ($parents = tep_db_fetch_array($sql)) {
          // check if the parent has products
          $check = tep_db_query("SELECT products_id FROM products_to_categories WHERE categories_id = '" . $parents['categories_id'] . "'");
    	    if (tep_db_num_rows($check) > 0) {
            $tree = tep_get_category_tree();
            $dropdown= tep_draw_pull_down_menu('cat_id', $tree, '', 'onChange="this.form.submit();"'); //single
            $all_list = "\n" . '<form method="post" action="products_quick_popup.php"> ' . "\n" . ' ' . ' <td class="smallText" align="left" valign="top" width="115"><FONT COLOR="FF0000"><B>All categories:</B></FONT><br>' . $dropdown . '</form></td>' . "\n";
          } else {
            // get the tree for that parent
            $tree = tep_get_category_tree($parents['categories_id']);
            // draw a dropdown with it:
            $dropdown = tep_draw_pull_down_menu('cat_id', $tree, '', 'onChange="this.form.submit();"');
            $list .= "\n" . '<form method="post" action="products_quick_popup.php"> '  . "\n" . ' ' . ' <td class="smallText" align="left" valign="top" width="115">' . $parents['categories_name'] . ':<br>' . $dropdown . '</form></td>' . "\n";
          }
            $count_it++;
            if ($count_it > 4) {
              $count_it=0;
              $list .= '</tr>' . "\n" . '<tr class="smallText">';
            }
        }
//       echo $list . $all_list . '</tr></table><p>';
        echo $all_list . $list;

   // see if there is a category ID:

  if ($HTTP_POST_VARS['cat_id']) {

      // start the table
      echo "\n" . '<form method="post" action="products_quick_popup.php"><table border="1" width="100%"><tr>' . "\n";
       $i = 0;

      // get all active prods in that specific category

       $sql2 = tep_db_query("SELECT p.products_id, p.products_status, p.products_image_1,p.products_title_1,pd.products_name from products p, products_description pd, products_to_categories ptc where p.products_id = ptc.products_id and p.products_id = pd.products_id and p.products_status=1 and pd.language_id = '" . $languages_id . "' and ptc.categories_id = '" . $HTTP_POST_VARS['cat_id'] . "'");

     while ($results = tep_db_fetch_array($sql2)) {
           $i++;
             echo '<td valign="top" class="smallText" align="center">' . tep_product_small_image($results['products_image_1'], $results['products_title_1']);
             echo '<FONT size="3px">&nbsp;#' . $results['products_id'] . '</font><br clear="all">' . $results['products_title_1'];
             $show_attributes='<FONT COLOR="FF0000">Click to:<br><a href="' . 'products_attributes_quick_popup.php?look_it_up=' . $results['products_id'] . '&my_languages_id=' . $languages_id . '" onclick="NewWindow3(this.href,\'name3\',\'700\',\'400\',\'yes\');return false;">Show Attributes</a></font>';
             echo '<P>' . $show_attributes . '</td>' . "\n";
          if ($i == 5) {
               echo '</tr><tr>' . "\n";
               $i =0;
         }
    }
  echo '<input type="hidden" name="cat_id" value="' . $HTTP_POST_VARS['cat_id'] . '">' . "\n";
  echo '</tr>' . "\n";
  } //if
?>
    </tr></table>
  </td></tr>
</table>

<BR><BR>
<center>
<table align="center" border="1" cellpadding="6" cellspacing="3"><tr><td class="main">
<a href="javascript:window.close()"> Close Window </a>
</td></tr></table>
</center>
<BR><BR>

</body>
</html>
