[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/templates/fallback/content/ -> products_new.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_products_new.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    $products_new_array = array();
  15  
  16    $products_new_query_raw = "select p.products_id, p.products_model, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and month(p.products_date_added) = month(now()) order by p.products_date_added DESC, pd.products_name";
  17    $products_new_split = new splitPageResults($products_new_query_raw, MAX_DISPLAY_PRODUCTS_NEW);
  18  
  19    if (($products_new_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3'))) {
  20  ?>
  21        <tr>
  22          <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
  23            <tr>
  24              <td class="smallText"><?php echo $products_new_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS_NEW); ?></td>
  25              <td align="right" class="smallText"><?php echo TEXT_RESULT_PAGE . ' ' . $products_new_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
  26            </tr>
  27          </table></td>
  28        </tr>
  29        <tr>
  30          <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  31        </tr>
  32  <?php
  33    }
  34  ?>
  35        <tr>
  36          <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
  37  <?php
  38    if ($products_new_split->number_of_rows > 0) {
  39  // BOF Separate Price Per Customer
  40  //  global variable (session): $sppc_customers_group_id -> local variable $customer_group_id
  41  
  42    if(!tep_session_is_registered('sppc_customer_group_id')) { 
  43    $customer_group_id = '0';
  44    } else {
  45     $customer_group_id = $sppc_customer_group_id;
  46    }
  47      $products_new_query = tep_db_query($products_new_split->sql_query);
  48      $no_of_products_new = tep_db_num_rows($products_new_query);
  49      while ($_products_new = tep_db_fetch_array($products_new_query)) {
  50        $products_new[] = $_products_new;
  51      $list_of_prdct_ids[] = $_products_new['products_id'];  
  52      }
  53      
  54    $select_list_of_prdct_ids = "products_id = '".$list_of_prdct_ids[0]."' ";
  55     if ($no_of_products_new > 1) {
  56        for ($n = 1 ; $n < count($list_of_prdct_ids) ; $n++) {
  57        $select_list_of_prdct_ids .= "or products_id = '".$list_of_prdct_ids[$n]."' ";   
  58        }
  59     }
  60  
  61  // get all customers_group_prices for products with the particular customer_group_id
  62  // however not necessary for customer_group_id
  63  if ($customer_group_id != '0') {
  64    $pg_query = tep_db_query("select pg.products_id, customers_group_price as price from " . TABLE_PRODUCTS_GROUPS . " pg where (".$select_list_of_prdct_ids.") and pg.customers_group_id = '".$customer_group_id."'");
  65      while ($pg_array = tep_db_fetch_array($pg_query)) {
  66      $new_prices[] = array ('products_id' => $pg_array['products_id'], 'products_price' => $pg_array['price'], 'specials_new_products_price' => '');
  67      }
  68  
  69     for ($x = 0; $x < $no_of_products_new; $x++) {
  70  // replace products prices with those from customers_group table
  71  // originally they would be obtained with an extra query for every new product:
  72  //   if ($new_price = tep_get_products_special_price($products_new['products_id'])) {
  73        
  74          if(!empty($new_prices)) {
  75          for ($i = 0; $i < count($new_prices); $i++) {
  76              if( $products_new[$x]['products_id'] == $new_prices[$i]['products_id'] ) {
  77              $products_new[$x]['products_price'] = $new_prices[$i]['products_price'];
  78              }
  79          }
  80      } // end if(!empty($new_prices)
  81     } // end for ($x = 0; $x < $no_of_products_new; $x++)
  82  } // end if ($customer_group_id != '0')
  83  
  84  // an extra query is needed for all the specials
  85  
  86      $specials_query = tep_db_query("select s.products_id, specials_new_products_price from " . TABLE_SPECIALS . " s  where (".$select_list_of_prdct_ids.") and status = '1' and s.customers_group_id = '" .$customer_group_id. "'");
  87      while ($specials_array = tep_db_fetch_array($specials_query)) {
  88      $new_prices[] = array ('products_id' => $specials_array['products_id'], 'products_price' => '', 'specials_new_products_price' => $specials_array['specials_new_products_price']);
  89      }
  90  
  91  // replace specials_new_products_price with those those for the customers_group_id
  92      for ($x = 0; $x < $no_of_products_new; $x++) {
  93        
  94          if(!empty($new_prices)) {
  95          for ($i = 0; $i < count($new_prices); $i++) {
  96              if( $products_new[$x]['products_id'] == $new_prices[$i]['products_id'] ) {
  97              $products_new[$x]['specials_new_products_price'] = $new_prices[$i]['specials_new_products_price'];
  98              }
  99             }
 100         } // end if(!empty($new_prices)
 101  //    } // end for ($x = 0; $x < $no_of_products_new; $x++)
 102          
 103      if (tep_not_null($products_new[$x]['specials_new_products_price'])) {
 104              $products_price = '<span style="text-decoration:line-through">' . $currencies->display_price($products_new[$x]['products_price'], tep_get_tax_rate($products_new[$x]['products_tax_class_id'])) . '</span> <span class="productSpecialPrice">' . $currencies->display_price($products_new[$x]['specials_new_products_price'], tep_get_tax_rate($products_new[$x]['products_tax_class_id'])) . '</span>';
 105      } else {
 106          $products_price = $currencies->display_price($products_new[$x]['products_price'], tep_get_tax_rate($products_new[$x]['products_tax_class_id']));
 107      }
 108  ?>
 109            <tr>
 110              <td width="<?php echo SMALL_IMAGE_WIDTH + 10; ?>" valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $products_new[$x]['products_image'], $products_new[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>'; ?></td>
 111              <td valign="top" class="main"><?php 
 112      $display_manufacturer = '';
 113      if (PRODUCT_LIST_MANUFACTURER)$display_manufacturer = '<br>' . TEXT_MANUFACTURER . ' ' . $products_new[$x]['manufacturers_name'] ;
 114              
 115              echo '<a href="' 
 116              . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new[$x]['products_id']) . '"><strong><u>' . $products_new[$x]['products_name'] . '</u></strong></a><br>Model:'. $products_new[$x]['products_model'] . '<br>' . TEXT_DATE_ADDED . ' ' . tep_date_long($products_new[$x]['products_date_added']) 
 117              . $display_manufacturer
 118              . '<br><br>' . TEXT_PRICE . ' ' . $products_price; ?></td>
 119              <td align="right" valign="middle" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_NEW, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $products_new[$x]['products_id']) . '">' . tep_image_button('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</a>'; ?></td>
 120            </tr>
 121            <tr>
 122              <td colspan="3"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
 123            </tr>
 124  <?php // EOF Separate Pricing Per Customer
 125     } // end for ($x = 0; $x < $products_new_split->number_of_rows; $x++)
 126   }  else { 
 127  ?>
 128            <tr>
 129              <td class="main"><?php echo TEXT_NO_NEW_PRODUCTS; ?></td>
 130            </tr>
 131            <tr>
 132              <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
 133            </tr>
 134  <?php
 135    }
 136  ?>
 137          </table></td>
 138        </tr>
 139  <?php
 140    if (($products_new_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3'))) {
 141  ?>
 142        <tr>
 143          <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
 144            <tr>
 145              <td class="smallText"><?php echo $products_new_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS_NEW); ?></td>
 146              <td align="right" class="smallText"><?php echo TEXT_RESULT_PAGE . ' ' . $products_new_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
 147            </tr>
 148          </table></td>
 149        </tr>
 150  <?php
 151    }
 152  ?>
 153      </table>
 154  


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