[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/includes/modules/ -> product_listing_col.php (source)

   1  <?php
   2  /*
   3  $Id: product_listing_col.php 14 2006-07-28 17:42:07Z user $
   4  */
   5  
   6    $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id');
   7  
   8    if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
   9  ?>
  10  <table border="0" width="100%" cellspacing="0" cellpadding="2">
  11    <tr>
  12      <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
  13      <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
  14    </tr>
  15  </table>
  16  <?php
  17    }
  18  
  19    $list_box_contents = array();
  20  
  21    if ($listing_split->number_of_rows > 0) {
  22  $row = 0;
  23    $rows = 0;
  24     $column = 0;
  25     $listing_query = tep_db_query($listing_split->sql_query);
  26  // BOF Separate Pricing per Customer
  27     $no_of_listings = tep_db_num_rows($listing_query);
  28  // global variable (session) $sppc_customer_group_id -> local variable customer_group_id
  29  
  30   if(!tep_session_is_registered('sppc_customer_group_id')) {
  31   $customer_group_id = '0';
  32   } else {
  33    $customer_group_id = $sppc_customer_group_id;
  34   }
  35  
  36  while ($_listing = tep_db_fetch_array($listing_query)) {
  37  $listing[] = $_listing;
  38  $list_of_prdct_ids[] = $_listing['products_id'];
  39  }
  40  // next part is a debug feature, when uncommented it will print the info that this module receives
  41  /*
  42    echo '<pre>';
  43    print_r($listing);
  44    echo '</pre>';
  45  */
  46   $select_list_of_prdct_ids = "products_id = '".$list_of_prdct_ids[0]."' ";
  47   if ($no_of_listings > 1) {
  48    for ($n = 1; $n < count($list_of_prdct_ids); $n++) {
  49    $select_list_of_prdct_ids .= "or products_id = '".$list_of_prdct_ids[$n]."' ";
  50    }
  51  }
  52  
  53  // get all product prices for products with the particular customer_group_id
  54  // however not necessary for customer_group_id = 0
  55  if ($customer_group_id != '0') {
  56   $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."' ");
  57  //   $no_of_pg_products = tep_db_num_rows($pg_query);
  58  while ($pg_array = tep_db_fetch_array($pg_query)) {
  59  $new_prices[] = array ('products_id' => $pg_array['products_id'], 'products_price' => $pg_array['price'], 'specials_new_products_price' => '', 'final_price' => $pg_array['price']);
  60  }
  61    for ($x = 0; $x < $no_of_listings; $x++) {
  62  // replace products prices with those from customers_group table
  63       if(!empty($new_prices)) {
  64          for ($i = 0; $i < count($new_prices); $i++) {
  65      if( $listing[$x]['products_id'] == $new_prices[$i]['products_id'] ) {
  66   $listing[$x]['products_price'] = $new_prices[$i]['products_price'];
  67   $listing[$x]['specials_new_products_price'] = $new_prices[$i]['specials_new_products_price'];
  68   $listing[$x]['final_price'] = $new_prices[$i]['final_price'];
  69   }
  70      }
  71  } // end if(!empty($new_prices)
  72  $listing[$x]['specials_new_products_price'] = ''; // makes sure that a retail specials price doesn't carry over to another customer group
  73  $listing[$x]['final_price'] = $listing[$x]['products_price']; // final price should not be the retail special price
  74   } // end for ($x = 0; $x < $no_of_listings; $x++)
  75  } // end if ($customer_group_id != '0')
  76  // an extra query is needed for all the specials
  77  
  78  $specials_query = tep_db_query("select products_id, specials_new_products_price from " . TABLE_SPECIALS . " where (".$select_list_of_prdct_ids.") and status = '1' and customers_group_id = '" .$customer_group_id. "'");
  79  while ($specials_array = tep_db_fetch_array($specials_query)) {
  80  $new_s_prices[] = array ('products_id' => $specials_array['products_id'], 'products_price' => '', 'specials_new_products_price' => $specials_array['specials_new_products_price'] , 'final_price' => $specials_array['specials_new_products_price']);
  81  }
  82  
  83  // add the correct specials_new_products_price and replace final_price
  84  for ($x = 0; $x < $no_of_listings; $x++) {
  85  
  86         if(!empty($new_s_prices)) {
  87      for ($i = 0; $i < count($new_s_prices); $i++) {
  88    if( $listing[$x]['products_id'] == $new_s_prices[$i]['products_id'] ) {
  89      $listing[$x]['specials_new_products_price'] = $new_s_prices[$i]['specials_new_products_price'];
  90      $listing[$x]['final_price'] = $new_s_prices[$i]['final_price'];
  91    }
  92         }
  93     } // end if(!empty($new_s_prices)
  94  } // end for ($x = 0; $x < $no_of_listings; $x++)
  95  
  96  //    while ($listing = tep_db_fetch_array($listing_query)) { (was original code)
  97  // WARNING the code assumes there are three products per row. To use a different number change the number
  98  // at line 195: if ($column >= 3) and the code to fill up the table row below that accordingly
  99    $counter = $row;
 100    $class_for_buy_now = 'class="productListing-odd"';
 101    $list_box_contents[$row] = array('params' => 'class="productListing-odd"');
 102  for ($x = 0; $x < $no_of_listings; $x++) {
 103  
 104       $rows++;
 105  
 106      if (($rows/2) == floor($rows/2) && ($row > $counter)) {
 107        $list_box_contents[$row] = array('params' => 'class="productListing-even"');
 108        $class_for_buy_now = 'class="productListing-even"';
 109        $counter = $row;
 110      } else {
 111       if ($row > $counter) {
 112        $list_box_contents[$row] = array('params' => 'class="productListing-odd"');
 113        $class_for_buy_now = 'class="productListing-odd"';
 114        $counter = $row;
 115       }
 116      }
 117        $product_contents = array();
 118  
 119        for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
 120          $lc_align = '';
 121  
 122          switch ($column_list[$col]) {
 123            case 'PRODUCT_LIST_MODEL':
 124              $lc_align = '';
 125             $lc_text = '&nbsp;' . $listing[$x]['products_model'] . '&nbsp;';
 126              break;
 127            case 'PRODUCT_LIST_NAME':
 128              $lc_align = '';
 129              if (isset($HTTP_GET_VARS['manufacturers_id'])) {
 130               $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a>';
 131              } else {
 132               $lc_text = '&nbsp;<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a>&nbsp;';
 133              }
 134              break;
 135            case 'PRODUCT_LIST_MANUFACTURER':
 136              $lc_align = '';
 137             $lc_text = '&nbsp;<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing[$x]['manufacturers_id']) . '">' . $listing[$x]['manufacturers_name'] . '</a>&nbsp;';
 138              break;
 139            case 'PRODUCT_LIST_PRICE':
 140              $lc_align = 'right';
 141  
 142  
 143             if (tep_not_null($listing[$x]['specials_new_products_price'])) {
 144               $lc_text = '&nbsp;<span style="text-decoration:line-through">' .  $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</span><br>&nbsp;&nbsp;<span class="productSpecialPrice">' . $currencies->display_price($listing[$x]['specials_new_products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</span>&nbsp;';
 145              } else {
 146               $lc_text = '&nbsp;' . $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '&nbsp;';
 147              }
 148              break;
 149            case 'PRODUCT_LIST_QUANTITY':
 150              $lc_align = 'right';
 151             $lc_text = '&nbsp;' . $listing[$x]['products_quantity'] . '&nbsp;';
 152              break;
 153            case 'PRODUCT_LIST_WEIGHT':
 154              $lc_align = 'right';
 155             $lc_text = '&nbsp;' . $listing[$x]['products_weight'] . '&nbsp;';
 156              break;
 157            case 'PRODUCT_LIST_IMAGE':
 158              $lc_align = 'center';
 159              if (isset($HTTP_GET_VARS['manufacturers_id'])) {
 160               $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . DYNAMIC_MOPICS_THUMBS_DIR . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';
 161              } else {
 162               $lc_text = '&nbsp;<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . DYNAMIC_MOPICS_THUMBS_DIR . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>&nbsp;';
 163              }
 164             break; // EOF Separate Pricing per Customer
 165            case 'PRODUCT_LIST_BUY_NOW':
 166             $lc_align = 'center';
 167             $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'pName')) . 'action=buy_now&products_id=' . $listing[$x]['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';
 168             break;
 169          }
 170          $product_contents[] = $lc_text;
 171  
 172        }
 173        $lc_text = implode('<br>', $product_contents);
 174        $list_box_contents[$row][$column] = array('align' => 'center',
 175                                                  'params' => 'class="productListing-data"',
 176                                                  'text'  => $lc_text);
 177        $column ++;
 178  
 179              if ($column >= PRODUCT_LIST_NUM_COLUMNS) {
 180          $row ++;
 181          $column = 0;
 182              }
 183  
 184      } // line 102 (N of listing per current page)
 185      if ($column > 0){
 186          for ($x = $column; $x < PRODUCT_LIST_NUM_COLUMNS; $x++){
 187              
 188              $list_box_contents[$row][$column] = array('align' => 'center',
 189                                                'params' => 'class="productListing-data" ',
 190                                                'text'  => "&nbsp;");
 191                   $column++;
 192              
 193          }
 194      }
 195      
 196      
 197  
 198      new productListingBox($list_box_contents);
 199    } else { // from line 21
 200      $list_box_contents = array();
 201  
 202      $list_box_contents[0] = array('params' => 'class="productListing-odd"');
 203      $list_box_contents[0][] = array('params' => 'class="productListing-data" yyyyyy',
 204                                     'text' => TEXT_NO_PRODUCTS);
 205  
 206      new productListingBox($list_box_contents);
 207    }
 208  
 209    if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
 210  ?>
 211  <table border="0" width="100%" cellspacing="0" cellpadding="2">
 212    <tr>
 213      <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
 214      <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
 215    </tr>
 216  </table>
 217  <?php
 218    }
 219  ?>


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