<?php
/*
  $Id: product_listing.php,v 1.44 2003/06/09 22:49:59 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/
//echo "sql===".$listing_sql;
  $listing_split = new splitPageResults($listing_sql, 32, 'p.products_id');
  $listing_query = tep_db_query($listing_split->sql_query);


  if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
?>
<table border="0" width="607" cellspacing="0" cellpadding="2"  align="center">
  <tr>
    <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
    <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>
  </tr>
</table>
<?
$lines=7;
$lines=ceil(tep_db_num_rows($listing_query)/4);

	for($i = 1; $i <= $lines; $i++)
	{
?>
	<table width="607" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
<?
		for($j = 1; $j <= 4; $j++)
		{
			$listing = tep_db_fetch_array($listing_query);
			if (isset($listing['products_name'])) {

			$isspecial=0;
			if ($new_price = tep_get_products_special_price($listing['products_id'])) {
			$isspecial=1;
			  $products_price = '<s>' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s> <span class="productSpecialPrice_r">' . $currencies->display_price($new_price, tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>';
			  $products_price2 = '<s>' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>';
			} else {
			  $products_price = $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id']));
			  $products_price2=$products_price;
			}


if(strlen($listing['products_name'])>50){
	$pos=strpos($listing['products_name']," ",strlen($listing['products_name'])-20);
	$str_product_name=substr_replace($listing['products_name']," ...",$pos);
}
else{
	$str_product_name=$listing['products_name'];
}


?>
            <td width="25%" height="165" >
					<table width="146"  border="0" cellspacing="1" cellpadding="1" class="infoBoxContents_td">
						<tr  height="91">
						  <td width="146" bgcolor="#FFFFFF">
							<table width="142"  border="0" cellspacing="1" cellpadding="1">
							  <tr>
									<td width="137" height="91">
										<table width="90" height="90" border="0" align="center" cellpadding="0" cellspacing="0">
												<tr>
												  <td><a href="<? echo tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']);?>"><img src="images/products_images/<?=$listing['products_image']?>" width="90" height="90" border="0"  alt="<? echo $listing[products_name];?>"></a></td>
												</tr>
										</table>
									</td>
							  </tr>
							  <tr>
								<td height="45" class="ad_s" align="center" ><a class="ad_s" href="<? echo tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']);?>"  title="<?=$listing[products_name]?>"><?=$str_product_name?></a></td>
							  </tr>
							  <tr>
								<td>
									<table width="100%"  border="0" cellspacing="0" cellpadding="0">
										<tr>
<?php if ($isspecial==0){?>
											  <td ><div align="center" class="top_selp"><?php echo $products_price2; ?></div></td>
<? }else{?>
											  <td ><div align="center" class="cat_bssss"><?php echo $products_price2; ?></div></td>
<? }?>
										</tr>
									</table>
								</td>
							  </tr>
						  </table>
						</td>
						</tr>
					</table>
					<table  border="0" cellpadding="0" cellspacing="0">
						  <tr>
							<td ><a href="<? echo tep_href_link(FILENAME_DEFAULT, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'sort=2a&action=buy_now&products_id=' . $listing['products_id']);?>"><img src="<?=DIR_WS_LANGUAGES.$language?>/images/buttons/button_list_01.gif"  border="0"></a></td>
							<td ><a href="<? echo tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']);?>"><img src="<?=DIR_WS_LANGUAGES.$language?>/images/buttons/view_button.gif"  border="0"></a></td>
						  </tr>
					</table>
			</td>
<?
}else{
?>
<td width="25%" height="165" >&nbsp;</td>
<?
}
}
?>
          </tr>
        </table>
        <table width="607"  border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td height="12"></td>
          </tr>
        </table>
<?
}
?>
<?
}else {

    $list_box_contents = array();

    $list_box_contents[0] = array('params' => 'class="productListing-odd"');
    $list_box_contents[0][] = array('params' => 'class="productListing-data"',
                                   'text' => TEXT_NO_PRODUCTS);

    new productListingBox($list_box_contents);

  }

  if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
?>
<table border="0" width="607" cellspacing="0" cellpadding="2" align="center">
  <tr>
    <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
    <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>
  </tr>
</table>
<?php
  }
?>
