PageRenderTime 46ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/includes/modules/pages/best_deal/header_php.php

https://github.com/happyxlq/lt_svn
PHP | 193 lines | 154 code | 23 blank | 16 comment | 28 complexity | 6e3f940a20d2c67266c84342e7b909e9 MD5 | raw file
Possible License(s): AGPL-1.0, BSD-3-Clause, LGPL-2.1
  1. <?php
  2. /**
  3. * beat_deal header_php.php
  4. *
  5. * @package page
  6. * @copyright Copyright 2003-2007 Zen Cart Development Team
  7. * @copyright Portions Copyright 2003 osCommerce
  8. * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  9. * @version $Id: header_php.php 6912 2007-09-02 02:23:45Z drbyte $
  10. */
  11. require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
  12. $breadcrumb->add(NAVBAR_TITLE);
  13. // display order dropdown
  14. $productsort = array();
  15. $nsort = array('Bestselling','Item Name','Price(Low to high)','Price(High to low)','New Arrival');
  16. for ($i=1; $i<6; $i++) {
  17. $productsort[] = array('id' => sprintf('%2d', $i), 'text' =>$nsort[$i-1] );
  18. }
  19. $pagesize = array();
  20. $pagesize[] = array('id'=>24,'text'=>24);
  21. $pagesize[] = array('id'=>36,'text'=>36);
  22. $pagesize[] = array('id'=>48,'text'=>48);
  23. if(isset($_GET['productsort']) && (int)$_GET['productsort'] > 0){
  24. switch ($_GET['productsort']){
  25. case 2:
  26. $product_sort = " order by pd.products_name ";
  27. break;
  28. case 3:
  29. $product_sort = " order by p.products_price";
  30. break;
  31. case 4:
  32. $product_sort = " order by p.products_price DESC";
  33. break;
  34. case 5:
  35. $product_sort = " order by p.products_date_added DESC";
  36. break;
  37. default:
  38. $product_sort = " order by p.products_ordered DESC";
  39. }
  40. }
  41. //print_r($_SERVER['QUERY_STRING']);
  42. $display = isset($_GET['display'])? $_GET['display']: '1';
  43. if(isset($_GET['display'])){
  44. $display = $_GET['display'];
  45. }else{
  46. $display = 1;
  47. }
  48. if(isset($_GET['listtypes'])){
  49. $listTypes = $_GET['listtypes'];
  50. }else{
  51. $listTypes = 1;
  52. }
  53. if(isset($_GET['display'])){
  54. //addBy showq@qq.com
  55. $displayTypes = substr($_GET['display'],0,strlen($_GET['display']) - (is_numeric(substr($_GET['display'],-1,1)) ? 2 : 0));
  56. switch ($display){
  57. case '2':
  58. $displayOrder = ' and p.`product_is_wholesale` = 1';
  59. break;
  60. case '3':
  61. $displayOrder = ' and p.`product_is_always_free_shipping` = 1';
  62. break;
  63. default:
  64. $displayOrder = '';
  65. }
  66. }
  67. if (isset($_GET['min_price']) && isset($_GET['max_price'])){
  68. $pricefilter = "and p.`products_price` >= ".$_GET['min_price'] ." and p.`products_price` <= " . $_GET['max_price'];
  69. }
  70. $beat_deal_array = array();
  71. // display limits
  72. // $display_limit = zen_get_beat_deal_timelimit();
  73. $display_limit = zen_get_new_date_range();
  74. $best_deal_query_raw = "SELECT p.products_id, p.products_type, pd.products_name, p.products_image, p.products_price,
  75. p.products_tax_class_id, p.products_date_added, m.manufacturers_name, p.products_model,
  76. p.products_quantity, p.products_weight, p.product_is_call,
  77. p.product_is_always_free_shipping, p.products_qty_box_status,
  78. p.master_categories_id,p.product_is_wholesale,p.product_wholesale_min,p.products_price_sample,
  79. p.products_price_retail,p.products_quantity,p.products_quantity_order_min,p.products_status
  80. FROM " . TABLE_PRODUCTS . " p
  81. LEFT JOIN " . TABLE_MANUFACTURERS . " m
  82. ON (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s
  83. WHERE p.products_status = 1
  84. AND s.products_id = p.products_id
  85. AND s.status = 1
  86. AND p.products_id = pd.products_id
  87. AND pd.language_id = :languageID " .$displayOrder. $display_limit . $product_sort .$pricefilter ;
  88. $best_deal_query_raw = $db->bindVars($best_deal_query_raw, ':languageID', $_SESSION['languages_id'], 'integer');
  89. $best_deal_split = new splitPageResults($best_deal_query_raw, (isset($_GET['pagesize']) ? $_GET['pagesize'] : 24));
  90. //check to see if we are in normal mode ... not showcase, not maintenance, etc
  91. $show_submit = zen_run_normal();
  92. $best_deal = $db->Execute($best_deal_split->sql_query);
  93. if($best_deal->RecordCount()>0){
  94. $row = 0;
  95. while (!$best_deal->EOF) {
  96. if ($best_deal->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) {
  97. $list_box_contents[$row]['products_image'] = '';
  98. } else {
  99. $list_box_contents[$row]['products_image'] = $best_deal->fields['products_image'] ;
  100. }
  101. $list_box_contents[$row]['products_name'] = $best_deal->fields['products_name'];
  102. $list_box_contents[$row]['products_description'] = zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($best_deal->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION);
  103. $list_box_contents[$row]['products_price'] = zen_get_products_base_price($best_deal->fields['products_id']);
  104. $list_box_contents[$row]['actual_price'] = $currencies->display_price(zen_get_products_actual_price($best_deal->fields['products_id']),zen_get_tax_rate($product_check->fields['products_tax_class_id']));
  105. $list_box_contents[$row]['products_status']=$best_deal->fields['products_status'];
  106. if ($best_deal->fields['product_is_always_free_shipping'] == 0) {
  107. $list_box_contents[$row]['product_is_always_free_shipping'] = '';
  108. } else {
  109. $list_box_contents[$row]['product_is_always_free_shipping'] = '<span class="free_shipping"></span>';
  110. }
  111. $list_box_contents[$row]['products_quantity_order_min'] = $best_deal->fields['products_quantity_order_min'];
  112. $list_box_contents[$row]['products_id'] = $best_deal->fields['products_id'];
  113. $list_box_contents[$row]['products_quantity'] = $best_deal->fields['products_quantity'];
  114. $list_box_contents[$row]['products_price_retail'] = $currencies->display_price($best_deal->fields['products_price_retail'],zen_get_tax_rate($product_check->fields['products_tax_class_id']));
  115. $list_box_contents[$row]['products_price_sample'] = $currencies->display_price($best_deal->fields['products_price_sample'],zen_get_tax_rate($product_check->fields['products_tax_class_id']));
  116. $list_box_contents[$row]['product_is_wholesale'] = $best_deal->fields['product_is_wholesale'];
  117. $list_box_contents[$row]['product_wholesale_min'] = $best_deal->fields['product_wholesale_min'];
  118. $best_deal->MoveNext();
  119. $row++;
  120. }
  121. }
  122. $best_deal_query_raw2 = "SELECT p.products_id, p.products_type, pd.products_name, p.products_image, p.products_price,
  123. p.products_tax_class_id, p.products_date_added, m.manufacturers_name, p.products_model,
  124. p.products_quantity, p.products_weight, p.product_is_call,
  125. p.product_is_always_free_shipping, p.products_qty_box_status,
  126. p.master_categories_id,p.product_is_wholesale,p.product_wholesale_min,p.products_price_sample,
  127. p.products_price_retail,p.products_quantity,p.products_quantity_order_min,p.products_status
  128. FROM " . TABLE_PRODUCTS . " p
  129. LEFT JOIN " . TABLE_MANUFACTURERS . " m
  130. ON (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s
  131. WHERE p.products_status = 1
  132. AND s.products_id = p.products_id
  133. AND s.status = 1
  134. AND p.products_id = pd.products_id
  135. AND pd.language_id = :languageID " .$displayOrder. $display_limit . $product_sort ;
  136. $best_deal_query_raw2 = $db->bindVars($best_deal_query_raw2, ':languageID', $_SESSION['languages_id'], 'integer');
  137. $best_deal_split2 = new splitPageResults($best_deal_query_raw2, (isset($_GET['pagesize']) ? $_GET['pagesize'] : 24));
  138. //check to see if we are in normal mode ... not showcase, not maintenance, etc
  139. $show_submit = zen_run_normal();
  140. $best_deal2 = $db->Execute($best_deal_split2->sql_query);
  141. if($best_deal2->RecordCount()>0){
  142. $row = 0;
  143. while (!$best_deal2->EOF) {
  144. if ($best_deal2->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) {
  145. $list_box_contents2[$row]['products_image'] = '';
  146. } else {
  147. $list_box_contents2[$row]['products_image'] = $best_deal2->fields['products_image'] ;
  148. }
  149. $list_box_contents2[$row]['products_name'] = $best_deal2->fields['products_name'];
  150. $list_box_contents2[$row]['products_description'] = zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($best_deal2->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION);
  151. $list_box_contents2[$row]['products_price'] = zen_get_products_base_price($best_deal2->fields['products_id']);
  152. $list_box_contents2[$row]['actual_price'] = $currencies->display_price(zen_get_products_actual_price($best_deal2->fields['products_id']),zen_get_tax_rate($product_check->fields['products_tax_class_id']));
  153. $list_box_contents2[$row]['products_status']=$best_deal2->fields['products_status'];
  154. if ($best_deal2->fields['product_is_always_free_shipping'] == 0) {
  155. $list_box_contents2[$row]['product_is_always_free_shipping'] = '';
  156. } else {
  157. $list_box_contents2[$row]['product_is_always_free_shipping'] = '<span class="free_shipping"></span>';
  158. }
  159. $list_box_contents2[$row]['products_quantity_order_min'] = $best_deal2->fields['products_quantity_order_min'];
  160. $list_box_contents2[$row]['products_id'] = $best_deal2->fields['products_id'];
  161. $list_box_contents2[$row]['products_quantity'] = $best_deal2->fields['products_quantity'];
  162. $list_box_contents2[$row]['products_price_retail'] = $currencies->display_price($best_deal2->fields['products_price_retail'],zen_get_tax_rate($product_check->fields['products_tax_class_id']));
  163. $list_box_contents2[$row]['products_price_sample'] = $currencies->display_price($best_deal2->fields['products_price_sample'],zen_get_tax_rate($product_check->fields['products_tax_class_id']));
  164. $list_box_contents2[$row]['product_is_wholesale'] = $best_deal2->fields['product_is_wholesale'];
  165. $list_box_contents2[$row]['product_wholesale_min'] = $best_deal2->fields['product_wholesale_min'];
  166. $best_deal2->MoveNext();
  167. $row++;
  168. }
  169. }
  170. ?>