[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

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

   1  <?php
   2  /*

   3  $Id: product_listing.php 3 2006-05-27 04:59:07Z user $

   4  

   5    osCMax Power E-Commerce

   6    http://oscdox.com

   7  

   8    Copyright 2006 osCMax

   9  

  10    Released under the GNU General Public License

  11  */
  12  
  13    $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id');
  14  
  15    if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
  16  ?>
  17  <table border="0" width="100%" cellspacing="0" cellpadding="2">
  18    <tr>
  19      <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
  20      <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>
  21    </tr>
  22  </table>
  23  <?php
  24    }
  25  
  26    $list_box_contents = array();
  27  
  28    for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
  29      switch ($column_list[$col]) {
  30        case 'PRODUCT_LIST_MODEL':
  31          $lc_text = TABLE_HEADING_MODEL;
  32          $lc_align = '';
  33  // LINE ADDED

  34          $lc_class = 'class="headerNavigation"';
  35          break;
  36        case 'PRODUCT_LIST_NAME':
  37          $lc_text = TABLE_HEADING_PRODUCTS;
  38          $lc_align = '';
  39  // LINE ADDED

  40          $lc_class = 'class="headerNavigation"';
  41          break;
  42        case 'PRODUCT_LIST_MANUFACTURER':
  43          $lc_text = TABLE_HEADING_MANUFACTURER;
  44          $lc_align = '';
  45  // LINE ADDED

  46          $lc_class = 'class="headerNavigation"';
  47          break;
  48        case 'PRODUCT_LIST_PRICE':
  49          $lc_text = TABLE_HEADING_PRICE;
  50          $lc_align = 'right';
  51  // LINE ADDED

  52          $lc_class = 'class="headerNavigation"';
  53          break;
  54        case 'PRODUCT_LIST_QUANTITY':
  55          $lc_text = TABLE_HEADING_QUANTITY;
  56          $lc_align = 'right';
  57  // LINE ADDED

  58          $lc_class = 'class="headerNavigation"';
  59          break;
  60        case 'PRODUCT_LIST_WEIGHT':
  61          $lc_text = TABLE_HEADING_WEIGHT;
  62          $lc_align = 'right';
  63  // LINE ADDED

  64          $lc_class = 'class="headerNavigation"';
  65          break;
  66        case 'PRODUCT_LIST_IMAGE':
  67          $lc_text = TABLE_HEADING_IMAGE;
  68          $lc_align = 'center';
  69  // LINE ADDED

  70          $lc_class = 'class="headerNavigation"';
  71          break;
  72        case 'PRODUCT_LIST_BUY_NOW':
  73  // Bugfix 0000069        

  74  //      $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'pName')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';

  75          $lc_text = TABLE_HEADING_BUY_NOW;
  76  // LINE ADDED

  77          $lc_align = 'center';
  78          break;
  79      }
  80  
  81      if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) {
  82        $lc_text = tep_create_sort_heading($HTTP_GET_VARS['sort'], $col+1, $lc_text);
  83      }
  84  
  85      $list_box_contents[0][] = array('align' => $lc_align,
  86  // OLD                              'params' => 'class="productListing-heading"',

  87                                      'params' => $lc_class,
  88                                      'text' => '&nbsp;' . $lc_text . '&nbsp;');
  89    }
  90  
  91    if ($listing_split->number_of_rows > 0) {
  92      $rows = 0;
  93      $listing_query = tep_db_query($listing_split->sql_query);
  94  // BOF: MOD - Separate Pricing per Customer

  95      $no_of_listings = tep_db_num_rows($listing_query);
  96  // global variable (session) $sppc_customer_group_id -> local variable customer_group_id

  97  
  98    if(!tep_session_is_registered('sppc_customer_group_id')) {
  99    $customer_group_id = '0';
 100    } else {
 101     $customer_group_id = $sppc_customer_group_id;
 102    }
 103    while ($_listing = tep_db_fetch_array($listing_query)) {
 104      $listing[] = $_listing;
 105      $list_of_prdct_ids[] = $_listing['products_id'];
 106    }
 107  // next part is a debug feature, when uncommented it will print the info that this module receives

 108   /*

 109     echo '<pre>';

 110     print_r($listing);

 111     echo '</pre>';

 112   */
 113    $select_list_of_prdct_ids = "products_id = '".$list_of_prdct_ids[0]."' ";
 114    if ($no_of_listings > 1) {
 115      for ($n = 1 ; $n < count($list_of_prdct_ids) ; $n++) {
 116        $select_list_of_prdct_ids .= "or products_id = '".$list_of_prdct_ids[$n]."' ";
 117      }
 118    }
 119  
 120  // get all product prices for products with the particular customer_group_id

 121  // however not necessary for customer_group_id = 0

 122    if ($customer_group_id != '0') {
 123      $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."' ");
 124  //  $no_of_pg_products = tep_db_num_rows($pg_query) ;

 125      while ($pg_array = tep_db_fetch_array($pg_query)) {
 126        $new_prices[] = array ('products_id' => $pg_array['products_id'], 'products_price' => $pg_array['price'], 'specials_new_products_price' => '', 'final_price' => $pg_array['price']);
 127      }
 128      for ($x = 0; $x < $no_of_listings; $x++) {
 129  // replace products prices with those from customers_group table

 130        if(!empty($new_prices)) {
 131          for ($i = 0; $i < count($new_prices); $i++) {
 132            if( $listing[$x]['products_id'] == $new_prices[$i]['products_id'] ) {
 133              $listing[$x]['products_price'] = $new_prices[$i]['products_price'];
 134              $listing[$x]['final_price'] = $new_prices[$i]['final_price'];
 135            }
 136          }
 137        } // end if(!empty($new_prices)

 138        $listing[$x]['specials_new_products_price'] = ''; // makes sure that a retail specials price doesn't carry over to another customer group

 139        $listing[$x]['final_price'] = $listing[$x]['products_price']; // final price should not be the retail special price

 140      } // end for ($x = 0; $x < $no_of_listings; $x++)

 141    } // end if ($customer_group_id != '0')

 142  
 143  // an extra query is needed for all the specials

 144  
 145    $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. "'");
 146    while ($specials_array = tep_db_fetch_array($specials_query)) {
 147    $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']);
 148    }
 149  
 150  // add the correct specials_new_products_price and replace final_price

 151    for ($x = 0; $x < $no_of_listings; $x++) {
 152  
 153          if(!empty($new_s_prices)) {
 154        for ($i = 0; $i < count($new_s_prices); $i++) {
 155       if( $listing[$x]['products_id'] == $new_s_prices[$i]['products_id'] ) {
 156         $listing[$x]['specials_new_products_price'] = $new_s_prices[$i]['specials_new_products_price'];
 157         $listing[$x]['final_price'] = $new_s_prices[$i]['final_price'];
 158       }
 159           }
 160       } // end if(!empty($new_s_prices)

 161    } // end for ($x = 0; $x < $no_of_listings; $x++)

 162  
 163  //    while ($listing = tep_db_fetch_array($listing_query)) { (was original code)

 164      for ($x = 0; $x < $no_of_listings; $x++) {
 165  // EOF: MOD - Separate Pricing per Customer

 166  
 167        $rows++;
 168  
 169        if (($rows/2) == floor($rows/2)) {
 170          $list_box_contents[] = array('params' => 'class="productListing-even"');
 171        } else {
 172          $list_box_contents[] = array('params' => 'class="productListing-odd"');
 173        }
 174  
 175        $cur_row = sizeof($list_box_contents) - 1;
 176  
 177        for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
 178          $lc_align = '';
 179  
 180  // BOF: MOD - Separate Pricing per Customer - Added on may lines [$x]

 181          switch ($column_list[$col]) {
 182            case 'PRODUCT_LIST_MODEL':
 183              $lc_align = '';
 184              $lc_text = '&nbsp;' . $listing[$x]['products_model'] . '&nbsp;';
 185              break;
 186            case 'PRODUCT_LIST_NAME':
 187              $lc_align = '';
 188              if (isset($HTTP_GET_VARS['manufacturers_id'])) {
 189                $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>';
 190              } else {
 191                $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;';
 192              }
 193              break;
 194            case 'PRODUCT_LIST_MANUFACTURER':
 195              $lc_align = '';
 196              $lc_text = '&nbsp;<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing[$x]['manufacturers_id']) . '">' . $listing[$x]['manufacturers_name'] . '</a>&nbsp;';
 197              break;
 198            case 'PRODUCT_LIST_PRICE':
 199              $lc_align = 'right';
 200  
 201              if (tep_not_null($listing[$x]['specials_new_products_price'])) {
 202                $lc_text = '&nbsp;<s>' .  $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</s>&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;';
 203              } else {
 204                $lc_text = '&nbsp;' . $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '&nbsp;';
 205              }
 206              break;
 207            case 'PRODUCT_LIST_QUANTITY':
 208              $lc_align = 'right';
 209              $lc_text = '&nbsp;' . $listing[$x]['products_quantity'] . '&nbsp;';
 210              break;
 211            case 'PRODUCT_LIST_WEIGHT':
 212              $lc_align = 'right';
 213              $lc_text = '&nbsp;' . $listing[$x]['products_weight'] . '&nbsp;';
 214              break;
 215            case 'PRODUCT_LIST_IMAGE':
 216              $lc_align = 'center';
 217              if (isset($HTTP_GET_VARS['manufacturers_id'])) {
 218                $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>';
 219              } else {
 220                $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;';
 221              }
 222              break;
 223            case 'PRODUCT_LIST_BUY_NOW':
 224              $lc_align = 'center';
 225              $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing[$x]['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a>&nbsp;';
 226              break;
 227  // EOF: MOD - Separate Pricing per Customer - Added on may lines [$x]

 228          }
 229  
 230          $list_box_contents[$cur_row][] = array('align' => $lc_align,
 231                                                 'params' => 'class="productListing-data"',
 232                                                 'text'  => $lc_text);
 233        }
 234      }
 235  
 236      new productListingBox($list_box_contents);
 237    } else {
 238      $list_box_contents = array();
 239  
 240      $list_box_contents[0] = array('params' => 'class="productListing-odd"');
 241      $list_box_contents[0][] = array('params' => 'class="productListing-data"',
 242                                     'text' => TEXT_NO_PRODUCTS);
 243  
 244      new productListingBox($list_box_contents);
 245    }
 246  
 247    if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
 248  ?>
 249  <table border="0" width="100%" cellspacing="0" cellpadding="2">
 250    <tr>
 251      <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
 252      <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>
 253    </tr>
 254  </table>
 255  <?php
 256    }
 257  ?>


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