<?php
/**
  @licence GPL 2005-2010  The osCSS developers - osCSS Open Source E-commerce
  @portion code Copyright (c) 2002 osCommerce
  @package osCSS-2 <www http://www.oscss.org>
  @version 2.0.9
  @date  14/11/10, 14:40
  @author oscim <mail aurelien@oscim.fr> <www http://www.oscim.fr>
  @encode UTF-8
*/
?>
<!-- body //-->
<h4><?php echo HEADING_TITLE; ?></h4>
<!-- body_text //-->
        <table style="width:100%" class="dataTable">
                <thead>
                <tr>
                        <th><?php echo TABLE_HEADING_NUMBER; ?></th>
                        <th><?php echo TABLE_HEADING_PRODUCTS; ?></th>
                        <th><?php echo TABLE_HEADING_PURCHASED; ?></th>
                </tr>
                </thead>
                <tbody>
<?php
  if (isset($_GET['page']) && ($_GET['page'] > 1)) $rows = $_GET['page'] * MAX_DISPLAY_SEARCH_RESULTS - MAX_DISPLAY_SEARCH_RESULTS;
  $products_query_raw = "select p.products_id, p.products_ordered, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . $languages_id. "' and p.products_ordered > 0 group by pd.products_id order by p.products_ordered DESC, pd.products_name";
  $db_query_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS, $products_query_raw, $db_query_numrows);

  $rows = 0;
  $products_query = tep_db_query($products_query_raw);
  while ($products = tep_db_fetch_array($products_query)) {
    $rows++;

    if (strlen($rows) < 2) {
      $rows = '0' . $rows;
    }
?>
                <tr class="dataTableRow">
                        <td><?php echo $rows; ?>.</td>
                        <td><?php echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'action=new_product_preview&amp;read=only&amp;pID=' . $products['products_id'] . '&amp;origin=' . FILENAME_STATS_PRODUCTS_PURCHASED . '&amp;page=' . $_GET['page'], 'NONSSL') . '">' . $products['products_name'] . '</a>'; ?></td>
                        <td><?php echo $products['products_ordered']; ?></td>
                </tr>
<?php
}
?>
</tbody>
        </table>
<!-- body_text_eof //-->
<!-- body_eof //-->