[ Index ] |
PHP Cross Reference of osCMax 2.0.4 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 $Id: default_specials.php 3 2006-05-27 04:59:07Z user $ 4 5 osCMax Power E-Commerce 6 http://oscdox.com 7 8 Copyright 2006 osCMax2005 osCMax 9 10 Released under the GNU General Public License 11 */ 12 ?> 13 14 <!-- default_specials //--> 15 16 <?php 17 $info_box_contents = array(); 18 // $info_box_contents[] = array('align' => 'left', 'text' => sprintf(TABLE_HEADING_DEFAULT_SPECIALS, strftime('%B'))); 19 $info_box_contents[] = array('align' => 'left', 'text' => '<a href="' . tep_href_link(FILENAME_SPECIALS) . '" class="headerNavigation">' . sprintf(TABLE_HEADING_DEFAULT_SPECIALS, strftime('%B') . '</a>')); 20 new infoBoxHeading($info_box_contents, false, false, tep_href_link(FILENAME_SPECIALS)); 21 22 // BOF Separate Price Per Customer 23 // global variable (session): $sppc_customers_group_id -> local variable $customer_group_id 24 if(!tep_session_is_registered('sppc_customer_group_id')) { 25 $customer_group_id = '0'; 26 } else { 27 $customer_group_id = $sppc_customer_group_id; 28 } 29 30 /* $specials_query_raw = "select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' order by s.specials_date_added DESC"; */ 31 32 // BOF: Bugfix 0000061 33 // $specials_query_raw = "select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' and s.customers_group_id = ". (int)$customer_group_id." order by s.specials_date_added DESC"; 34 if ($customer_group_id == '0') { 35 $specials_query_raw = "select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' and s.customers_group_id = ". (int)$customer_group_id." order by s.specials_date_added DESC"; 36 } else { 37 $specials_query_raw = "select p.products_id, pd.products_name, IF(pg.customers_group_price IS NOT NULL,pg.customers_group_price, p.products_price) as products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s LEFT JOIN " . TABLE_PRODUCTS_GROUPS . " pg using (products_id, customers_group_id) where p.products_status = '1' and p.products_id = s.products_id and pd.products_id = s.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' and s.customers_group_id= '".$customer_group_id."' order by s.specials_date_added desc"; 38 } 39 // EOF: Bugfix 0000061 40 $specials_split = new splitPageResults($specials_query_raw, MAX_DISPLAY_SPECIAL_PRODUCTS); 41 $row = 0; 42 $col = 0; 43 $specials_query = tep_db_query($specials_split->sql_query); 44 $no_of_specials = tep_db_num_rows($specials_query); 45 // get all product prices from the table products_groups in one query 46 // traverse specials_query for products_id's, store the query result in a numbered array 47 while ($_specials = tep_db_fetch_array($specials_query)) { 48 $specials[] = $_specials; 49 $list_of_prdct_ids[] = $_specials['products_id']; 50 } // end while ($_specials = tep_db_fetch_array($specials_query)) 51 // a line needed for the selection of the products_id's 52 $pg_list_of_prdct_ids = "products_id = '".$list_of_prdct_ids[0]."' "; 53 if ($no_of_specials > 1) { 54 for ($n = 1 ; $n < count($list_of_prdct_ids) ; $n++) { 55 $pg_list_of_prdct_ids .= "or products_id = '".$list_of_prdct_ids[$n]."' "; 56 } 57 } 58 // now get all the customers_group_price's 59 $pg_query = tep_db_query("select products_id, customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where (".$pg_list_of_prdct_ids.") and customers_group_id = '" . $customer_group_id . "'"); 60 // put all the info in an array called new_prices 61 while ($pg_array = tep_db_fetch_array($pg_query)) { 62 $new_prices[] = array ('products_id' => $pg_array['products_id'], 'products_price' => $pg_array['customers_group_price']); 63 } 64 // we already got the results from the query and put them into an array, can't use while now 65 // while ($specials = tep_db_fetch_array($specials_query)) { 66 for ($x = 0; $x < $no_of_specials; $x++) { 67 $info_box_contents[$row][$col] = array ('align' => 'center', 68 'params' =>'class="smallText"', 69 // 'text' => '<td><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $specials[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . DYNAMIC_MOPICS_THUMBS_DIR . $specials[$x]['products_image'], $specials[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $specials[$x]['products_id']) . '">' . $specials[$x]['products_name'] . '</a><br><span style="text-decoration:line-through">' . $currencies->display_price($specials[$x]['products_price'], tep_get_tax_rate($specials[$x]['products_tax_class_id'])) . '</span><br><span class="productSpecialPrice">' . $currencies->display_price($specials[$x]['specials_new_products_price'], tep_get_tax_rate($specials[$x]['products_tax_class_id'])) . '</td>'); 70 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $specials[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . DYNAMIC_MOPICS_THUMBS_DIR . $specials[$x]['products_image'], $specials[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $specials[$x]['products_id']) . '">' . $specials[$x]['products_name'] . '</a><br><span style="text-decoration:line-through">' . $currencies->display_price($specials[$x]['products_price'], tep_get_tax_rate($specials[$x]['products_tax_class_id'])) . '</span><br><span class="productSpecialPrice">' . $currencies->display_price($specials[$x]['specials_new_products_price'], tep_get_tax_rate($specials[$x]['products_tax_class_id']))); 71 $col ++; 72 if ($col >= 3) { 73 $col = 0; 74 $row ++; 75 } 76 // replace products prices with those from customers_group table 77 if(!empty($new_prices)) { 78 for ($i = 0; $i < count($new_prices); $i++) { 79 if( $specials[$x]['products_id'] == $new_prices[$i]['products_id'] ) { 80 $specials[$x]['products_price'] = $new_prices[$i]['products_price']; 81 } 82 } 83 } // end if(!empty($new_prices) 84 // EOF Separate Price per Customer, specials code 85 } 86 new contentBox($info_box_contents); 87 ?> 88 <!-- default_specials_eof //-->
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Jan 1 13:43:16 2010 | Cross-referenced by PHPXref 0.7 |