<?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.1.0
  @date  18/12/10, 21:29
  @author oscim <mail aurelien@oscim.fr> <www http://www.oscim.fr>
  @encode UTF-8
  @brief this content for best seller products
*/
 $best_sellers_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_quantity, p.products_tax_class_id, m.manufacturers_name, m.manufacturers_id, p.products_model, p.products_weight, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id) left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on (p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'),  " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1'  and p.products_id = p2c.products_id and c.categories_id=p2c.categories_id and  categories_status = 1 and p.products_ordered > 0 order by p.products_ordered desc, pd.products_name ";
?>
<div id="bestSellers">
  <?php if (tep_db_num_rows(tep_db_query($best_sellers_query_raw)) < $page->_conf_value('MIN_DISPLAY_BESTSELLERS')) : ?>
      <p class="infoText"><?php echo TEXT_INFORMATION; ?></p>
  <?php else :
      $listing_split = new splitPageResults($best_sellers_query_raw, $page->_conf_value('MAX_DISPLAY_BESTSELLERS')); ?>
      <?php $page->oscss_modules->_add(FILENAME_PRODUCT_LISTING,'center',array('title'=>HEADING_TITLE,'listing_split'=>$listing_split,'listing_query'=>$best_sellers_query_raw)); ?>
  <?php endif; ?>
</div>