????
| Current Path : /home2/morganrand/www/store/includes/modules/ |
| Current File : /home2/morganrand/www/store/includes/modules/product_listing.php1 |
<?php
/*
$Id$
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2010 osCommerce
Released under the GNU General Public License
*/
///// BOF CONFIGURATION OPTIONS FOR LIST -OR- GRID LISTING STYLE /////
///// BOF LIST VIEW OPTIONS /////
//default configuration of stock osCommerce install
//if this is set to true $define_grid_view below must be set to false
//change to false to use grid view
$define_list_view = false;
///// EOF LIST VIEW OPTIONS /////
///// BOF GRID VIEW OPTIONS /////
//new configuration to use grid product listing style
//if this is set to true $define_list_view above must be set to false
//change to true to use grid view
$define_grid_view = true;
//how many items per row in the grid?
$items_per_row = '3';
///// EOF GRID VIEW OPTIONS /////
///// NO NEED TO EDIT PAST THIS POINT /////
if ( $define_list_view == true ) { $define_grid_view = false; }
if ( $define_list_view == false && $define_grid_view == false ) { $define_list_view = true; }
$items_per_row = $items_per_row-1;
///// EOF CONFIGURATION OPTIONS FOR LIST -OR- GRID LISTING STYLE /////
$listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id');
?>
<div class="contentText">
<?php
if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
?>
<div>
<span style="float: right;"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></span>
<span><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></span>
</div>
<br />
<?php
}
if ( $define_list_view == true && $define_grid_view == false ) {//BOF list view
$prod_list_contents = '<div class="ui-widget infoBoxContainer">' .
' <div class="ui-widget-header ui-corner-top infoBoxHeading">' .
' <table border="0" width="100%" cellspacing="0" cellpadding="2" class="productListingHeader">' .
' <tr>';
for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
$lc_align = '';
switch ($column_list[$col]) {
case 'PRODUCT_LIST_MODEL':
$lc_text = TABLE_HEADING_MODEL;
$lc_align = '';
break;
case 'PRODUCT_LIST_NAME':
$lc_text = TABLE_HEADING_PRODUCTS;
$lc_align = '';
break;
case 'PRODUCT_LIST_MANUFACTURER':
$lc_text = TABLE_HEADING_MANUFACTURER;
$lc_align = '';
break;
case 'PRODUCT_LIST_PRICE':
$lc_text = TABLE_HEADING_PRICE;
$lc_align = 'right';
break;
case 'PRODUCT_LIST_QUANTITY':
$lc_text = TABLE_HEADING_QUANTITY;
$lc_align = 'right';
break;
case 'PRODUCT_LIST_WEIGHT':
$lc_text = TABLE_HEADING_WEIGHT;
$lc_align = 'right';
break;
case 'PRODUCT_LIST_IMAGE':
$lc_text = TABLE_HEADING_IMAGE;
$lc_align = 'center';
break;
case 'PRODUCT_LIST_BUY_NOW':
$lc_text = TABLE_HEADING_BUY_NOW;
$lc_align = 'center';
break;
}
if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) {
$lc_text = tep_create_sort_heading($HTTP_GET_VARS['sort'], $col+1, $lc_text);
}
$prod_list_contents .= ' <td' . (tep_not_null($lc_align) ? ' align="' . $lc_align . '"' : '') . '>' . $lc_text . '</td>';
}
$prod_list_contents .= ' </tr>' .
' </table>' .
' </div>';
if ($listing_split->number_of_rows > 0) {
$rows = 0;
$listing_query = tep_db_query($listing_split->sql_query);
$prod_list_contents .= ' <div class="ui-widget-content ui-corner-bottom productListTable">' .
' <table border="0" width="100%" cellspacing="0" cellpadding="2" class="productListingData">';
while ($listing = tep_db_fetch_array($listing_query)) {
$rows++;
$prod_list_contents .= ' <tr>';
for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
switch ($column_list[$col]) {
case 'PRODUCT_LIST_MODEL':
$prod_list_contents .= ' <td>' . $listing['products_model'] . '</td>';
break;
case 'PRODUCT_LIST_NAME':
if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
$prod_list_contents .= ' <td><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a></td>';
} else {
$prod_list_contents .= ' <td><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a></td>';
}
break;
case 'PRODUCT_LIST_MANUFACTURER':
$prod_list_contents .= ' <td><a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a></td>';
break;
case 'PRODUCT_LIST_PRICE':
if (tep_not_null($listing['specials_new_products_price'])) {
$prod_list_contents .= ' <td align="right"><del>' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</del> <span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span></td>';
} else {
$prod_list_contents .= ' <td align="right">' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</td>';
}
break;
case 'PRODUCT_LIST_QUANTITY':
$prod_list_contents .= ' <td align="right">' . $listing['products_quantity'] . '</td>';
break;
case 'PRODUCT_LIST_WEIGHT':
$prod_list_contents .= ' <td align="right">' . $listing['products_weight'] . '</td>';
break;
case 'PRODUCT_LIST_IMAGE':
if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
$prod_list_contents .= ' <td align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>';
} else {
$prod_list_contents .= ' <td align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>';
}
break;
case 'PRODUCT_LIST_BUY_NOW':
$prod_list_contents .= ' <td align="center">' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id'])) . '</td>';
break;
}
}
$prod_list_contents .= ' </tr>';
}
$prod_list_contents .= ' </table>' .
' </div>' .
'</div>';
echo $prod_list_contents;
} else {
?>
<p><?php echo TEXT_NO_PRODUCTS; ?></p>
<?php
}
}//EOF list view
if ( $define_grid_view == true && $define_list_view == false ) {//BOF grid view
if ($listing_split->number_of_rows > 0) {
$rows = 0;
$true_row = 0;
$one_cell = 0;
$listing_query = tep_db_query($listing_split->sql_query);
$sort_options[0] = array('id' => ' ', 'text' => 'Alphabetically');
$sort_options[1] = array('id' => '3a', 'text' => 'Price Low to High');
$sort_options[2] = array('id' => '3d', 'text' => 'Price High to Low');
$prod_list_contents .= '<div>' . tep_draw_form('filter_by', FILENAME_DEFAULT, 'get') . '<p align="right"><strong>' . TEXT_SORT_PRODUCTS . TEXT_BY . ' </strong>' . tep_draw_hidden_field('cPath', $cPath) . tep_draw_pull_down_menu('sort', $sort_options, '', 'onchange="this.form.submit()"') . tep_hide_session_id() . '</p></form></div>' . "\n";
$prod_list_contents .= ' <div class="ui-widget-content ui-corner-bottom">' .
' <table border="0" width="100%" cellspacing="0" cellpadding="2" class="productListingData">';
while ($listing = tep_db_fetch_array($listing_query)) {
$rows++;
if ( $rows == '1' ) {
$prod_list_contents .= '<tr>';
}
if ( $true_row == '1' && $one_cell == '0') {
$prod_list_contents .= '<td style="text-align:center; padding:0 5px;" rowspan="2" colspan="2">';
$one_cell = '1';
} else {
$prod_list_contents .= '<td style="text-align:center; padding:0 5px;">';
}
for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
switch ($column_list[$col]) {
case 'PRODUCT_LIST_MODEL':
$prod_list_contents .= '<br />' . $listing['products_model'];
break;
case 'PRODUCT_LIST_NAME':
if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
$prod_list_contents .= '<br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>';
} else {
$prod_list_contents .= '<br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>';
}
break;
case 'PRODUCT_LIST_MANUFACTURER':
$prod_list_contents .= '<br /><a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a>';
break;
case 'PRODUCT_LIST_PRICE':
if (tep_not_null($listing['specials_new_products_price'])) {
$prod_list_contents .= '<br /><del>' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</del> <span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>';
} else {
//$prod_list_contents .= '<br />' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id']));
$prod_list_contents .= '<br /> $27.00 - $49.00';
}
break;
case 'PRODUCT_LIST_QUANTITY':
$prod_list_contents .= '<br />' . $listing['products_quantity'];
break;
case 'PRODUCT_LIST_WEIGHT':
$prod_list_contents .= '<br />' . $listing['products_weight'];
break;
case 'PRODUCT_LIST_IMAGE':
if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
$prod_list_contents .= '<br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';
} else {
if ($true_row == '1' && $one_cell == '1') {
$pi_query = tep_db_query("select image from " . TABLE_PRODUCTS_IMAGES . " where products_id = '" . (int)$listing['products_id'] . "' order by sort_order limit 1");
$product_bimage = tep_db_fetch_array($pi_query);
if (tep_db_num_rows($pi_query) > 0 && $product_bimage['image'] !='') {
$listing['products_image'] = $product_bimage['image'];
}
$prod_list_contents .= '<br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], 460, 460) . '</a>';
$one_cell = 2;
} else {
$prod_list_contents .= '<br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';
}
}
break;
case 'PRODUCT_LIST_BUY_NOW':
$prod_list_contents .= '<br />' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']));
break;
}
}
$prod_list_contents .= '</td>';
if ( ($rows > $items_per_row) || (($true_row == '1') && ($rows >= $items_per_row)) || ($true_row == '2')) {
$prod_list_contents .= '</tr>';
$rows = 0;
$true_row++;
}
}
$prod_list_contents .= ' </table>' .
' </div>';
echo $prod_list_contents;
} else {
?>
<p><?php echo TEXT_NO_PRODUCTS; ?></p>
<?php
}
}//EOF grid view
if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
?>
<br />
<div>
<span style="float: right;"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></span>
<span><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></span>
</div>
<?php
}
?>
</div>