[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/templates/fallback/content/ -> specials.tpl.php (source)

   1      <table border="0" width="100%" cellspacing="0" cellpadding="0">
   2        <tr>
   3          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
   4            <tr>
   5              <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
   6              <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_specials.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
   7            </tr>
   8          </table></td>
   9        </tr>
  10        <tr>
  11          <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  12        </tr>
  13  <?php
  14  // BOF Separate Price Per Customer
  15  //  global variable (session): $sppc_customers_group_id -> local variable $customer_group_id
  16  
  17    if(!tep_session_is_registered('sppc_customer_group_id')) { 
  18    $customer_group_id = '0';
  19    } else {
  20     $customer_group_id = $sppc_customer_group_id;
  21    }
  22  
  23  /*   $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"; */
  24    $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";
  25    $specials_split = new splitPageResults($specials_query_raw, MAX_DISPLAY_SPECIAL_PRODUCTS);
  26  // EOF Separate Price Per Customer
  27    $specials_split = new splitPageResults($specials_query_raw, MAX_DISPLAY_SPECIAL_PRODUCTS);
  28  
  29    if (($specials_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3'))) {
  30  ?>
  31        <tr>
  32          <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
  33            <tr>
  34              <td class="smallText"><?php echo $specials_split->display_count(TEXT_DISPLAY_NUMBER_OF_SPECIALS); ?></td>
  35              <td align="right" class="smallText"><?php echo TEXT_RESULT_PAGE . ' ' . $specials_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
  36            </tr>
  37          </table></td>
  38        </tr>
  39        <tr>
  40          <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  41        </tr>
  42  <?php
  43    }
  44  ?>
  45        <tr>
  46          <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
  47            <tr>
  48  <?php
  49   // BOF Separate Price Per Customer
  50      $row = 0;
  51      $specials_query = tep_db_query($specials_split->sql_query);
  52      $no_of_specials = tep_db_num_rows($specials_query);
  53  // get all product prices from the table products_groups in one query
  54  // traverse specials_query for products_id's, store the query result in a numbered array
  55     while ($_specials = tep_db_fetch_array($specials_query)) {
  56      $specials[] = $_specials;
  57      $list_of_prdct_ids[] = $_specials['products_id'];
  58     } // end while ($_specials = tep_db_fetch_array($specials_query))
  59  // a line needed for the selection of the products_id's
  60    $pg_list_of_prdct_ids = "products_id = '".$list_of_prdct_ids[0]."' ";
  61    if ($no_of_specials > 1) {
  62     for ($n = 1 ; $n < count($list_of_prdct_ids) ; $n++) {
  63     $pg_list_of_prdct_ids .= "or products_id = '".$list_of_prdct_ids[$n]."' ";  
  64     }
  65  }
  66  // now get all the customers_group_price's
  67  $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 . "'");
  68  // put all the info in an array called new_prices
  69      while ($pg_array = tep_db_fetch_array($pg_query)) {
  70      $new_prices[] = array ('products_id' => $pg_array['products_id'], 'products_price' => $pg_array['customers_group_price']);
  71      }
  72  // we already got the results from the query and put them into an array, can't use while now
  73  //    while ($specials = tep_db_fetch_array($specials_query)) {
  74      for ($x = 0; $x < $no_of_specials; $x++) {    
  75        $row++;
  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  
  85        echo '            <td align="center" width="33%" class="smallText"><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'])) . '</span></td>' . "\n";
  86   // EOF Separate Price per Customer, specials code
  87        if ((($row / 3) == floor($row / 3))) {
  88  ?>
  89            </tr>
  90            <tr>
  91              <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  92            </tr>
  93            <tr>
  94  <?php
  95        }
  96      }
  97  ?>
  98            </tr>
  99          </table></td>
 100        </tr>
 101  <?php
 102    if (($specials_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3'))) {
 103  ?>
 104        <tr>
 105          <td><br><table border="0" width="100%" cellspacing="0" cellpadding="2">
 106            <tr>
 107              <td class="smallText"><?php echo $specials_split->display_count(TEXT_DISPLAY_NUMBER_OF_SPECIALS); ?></td>
 108              <td align="right" class="smallText"><?php echo TEXT_RESULT_PAGE . ' ' . $specials_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
 109            </tr>
 110          </table></td>
 111        </tr>
 112  <?php
 113    }
 114  ?>
 115      </table>
 116  


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7