<?php
/*
  $Id: best_sellers.php,v 1.21 2003/06/09 22:07:52 hpdl Exp $

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

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

?>
<!-- center_output //-->
<link href="../../stylesheet.css" rel="stylesheet" type="text/css">

		<table width="609" border="0" align="center" cellpadding="0" cellspacing="0">
			<tr>
				  <td><img src="<?=DIR_WS_LANGUAGES.$language?>/images/ad_s_1.jpg" alt="<?=BOX_CENTER_TOP?>" ></td>
			</tr>
		</table>
        <table width="609" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td width="203" height="160">
					<table width="198"  border="0" cellpadding="0" cellspacing="0">
						  <tr>
								<td width="8"><img src="images/ad_left.gif" width="8" ></td>
								<td  bgcolor="#4866A4"><span class="ad_top"><strong><?=BOX_CENTER_01?></strong></span></td>
								<td width="9"><img src="images/ad_right.gif" width="8" ></td>
						  </tr>
					</table>
					<table width="198" border="0" cellspacing="0" cellpadding="0">
						<tr>
						  <td height="141" bgcolor="D9DFED"><a href="<?php echo tep_href_link(FILENAME_DEFAULT, 'cPath=111_103_140');?>" ><img src="<?=DIR_WS_LANGUAGES.$language?>/images/ad_top_1.jpg" alt="<?=BOX_CENTER_01?>" width="198" height="141" border="0"></a></td>
						</tr>
					</table>
			</td>
            <td width="203">
				<table width="198" border="0" cellspacing="0" cellpadding="0">
				  <tr>
					<td width="8"><img src="images/ad_left.gif" width="8"></td>
					<td  bgcolor="#4866A4"><span class="ad_top"><strong><?=BOX_CENTER_02?></strong></span></td>
					<td width="8"><img src="images/ad_right.gif" width="8" ></td>
				  </tr>
				</table>
				  <table width="198" border="0" cellspacing="0" cellpadding="0">
					<tr>
					  <td width="33%" height="141" bgcolor="D9DFED"><a href="<?php echo tep_href_link(FILENAME_DEFAULT, 'cPath=111_70_180');?>"><img src="<?=DIR_WS_LANGUAGES.$language?>/images/ad_top_2.jpg" alt="<?=BOX_CENTER_02?>" width="198" height="141" border="0"></a></td>
					</tr>
				</table>
			</td>
            <td width="198">
				<table width="198" border="0" cellspacing="0" cellpadding="0">
				  <tr>
						<td width="8"><img src="images/ad_left.gif" width="8" ></td>
						<td  bgcolor="#4866A4"><span class="ad_top"><strong><?=BOX_CENTER_03?></strong></span></td>
						<td width="8"><img src="images/ad_right.gif" width="8" ></td>
				  </tr>
				  </table>			  
				<table width="198" border="0" cellspacing="0" cellpadding="0">
					<tr>
					  <td height="141" bgcolor="D9DFED"><a href="<? echo tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=128');?>"><img src="<?=DIR_WS_LANGUAGES.$language?>/images/ad_top_3.jpg" alt="<?=BOX_CENTER_03?>" width="198" height="141" border="0"></a></td>
					</tr>
				</table>
			</td>
          </tr>
        </table>

        <table width="609" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td height="12"></td>
          </tr>
        </table>
        <table width="609" height="19" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td height="19"><img src="<?=DIR_WS_LANGUAGES.$language?>/images/ban_new_a.jpg"   border="0" usemap="#Map1" height="23"></td>
          </tr>
        </table>
        <table width="609" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td height="8"></td>
          </tr>
        </table>
        <table width="609" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
<?php
$listing_sql = "select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image from products p, products_description pd where p.products_id = pd.products_id  and p.products_status=1 and pd.language_id=".(int)$languages_id." and p.products_quantity>0 order by p.products_date_added desc limit 4";
$products_query=tep_db_query($listing_sql);

	for($j = 1; $j <= 4; $j++)
	{
		$row = tep_db_fetch_array($products_query);

if(strlen($row['products_name'])>55){
	$pos=strpos($row['products_name']," ",strlen($row['products_name'])-20);
	$str_product_name=substr_replace($row['products_name']," ...",$pos);
}
else{
	$str_product_name=$row['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" align="center">
                    <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=' . $row['products_id']);?>"><img src="images/products_images/<? echo $row[products_image];?>" width="90" height="90" border="0"  alt="<? echo $row[products_name];?>"></a></td>
							</tr>
                        </table>
					</td>
                    </tr>
                    <tr>
                      <td height="45" class="ad_s" align="center" valign="top" ><a class="ad_s" href="<? echo tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $row['products_id']);?>"  title="<?=$row[products_name]?>"><?=$str_product_name?></a></td>
                    </tr>
                    <tr>
                          <td><div align="center" class="pric_b"><?php echo $currencies->display_price($row['products_price'], tep_get_tax_rate($row['products_tax_class_id']));?></div></td>
                    </tr>
                  </table></td>
                </tr>
              </table>
              <table  border="0" cellpadding="0" cellspacing="0">
                <tr>
                      <td width="101"><div align="right"><a href="<? echo tep_href_link(FILENAME_DEFAULT, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'sort=2a&action=buy_now&products_id=' . $row['products_id']);?>"><img src="<?=DIR_WS_LANGUAGES.$language?>/images/buttons/add_button_1.gif"  border="0"></a></div></td>
                      <td width="50"><div align="right"><a href="<? echo tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $row['products_id']);?>"><img src="<?=DIR_WS_LANGUAGES.$language?>/images/buttons/view_button.gif"  border="0"></a></div></td>
                </tr>
              </table>
		</td>

<?
}
?>

          </tr>
        </table>
        <table width="609" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td height="18"></td>
          </tr>
        </table>
        <table width="609" height="19" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td height="19"><img src="<?=DIR_WS_LANGUAGES.$language?>/images/ban_new_f.jpg"  border="0" usemap="#Map2" ></td>
          </tr>
        </table>

<?php
$listing_sql = "select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' order by s.specials_date_added DESC limit 20";
$products_query=tep_db_query($listing_sql);

	for($i = 1; $i <= 5; $i++)
	{
?>
        <table width="609" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td height="8"></td>
          </tr>
        </table>      
        <table width="609" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
<?
		for($j = 1; $j <= 4; $j++)
		{
			$row = tep_db_fetch_array($products_query);

if(strlen($row['products_name'])>55){
	$pos=strpos($row['products_name']," ",strlen($row['products_name'])-20);
	$str_product_name=substr_replace($row['products_name']," ...",$pos);
}
else{
	$str_product_name=$row['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" align="center">
									<tr>
												<td align="center"><a href="<? echo tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $row['products_id']);?>"><img src="images/products_images/<? echo $row[products_image];?>" width="90" height="90" border="0" alt="<? echo $row[products_name];?>"></a></td>
									</tr>
									<tr>
									  <td height="45" class="ad_s" align="center"  valign="top" ><a class="ad_s" href="<? echo tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $row['products_id']);?>"  title="<?=$row[products_name]?>"><?=$str_product_name?></a></td>
									</tr>
									<tr>
										  <td height="50">
												<table width="100%"  border="0" cellspacing="0" cellpadding="0">
													<tr>
													  <td><div align="center" class="cat_b_s"><?=BOX_SPECIALS_RRP?>:<?php echo $currencies->display_price($row['products_price'], tep_get_tax_rate($row['products_tax_class_id']));?></div></td>
													</tr>
													<tr>
													  <td><div align="center" class="pric_b"><?php echo $currencies->display_price($row['specials_new_products_price'], tep_get_tax_rate($row['products_tax_class_id']));?></div></td>
													</tr>
													<tr>
													  <td><div align="center" class="cat_b"><?=BOX_SPECIALS_SAVE_F?><?php echo $currencies->display_price($row[products_price]-$row['specials_new_products_price'], tep_get_tax_rate($row['products_tax_class_id']));?>&nbsp;<?=BOX_SPECIALS_SAVE_B?></div></td>
													</tr>
											  </table>
										 </td>
									</tr>
								</table>
						</td>
					  </tr>
					</table>
					<table  border="0" cellpadding="0" cellspacing="0">
					  <tr>
							<td width="101"><a href="<? echo tep_href_link(FILENAME_DEFAULT, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'sort=2a&action=buy_now&products_id=' . $row['products_id']);?>"><img src="<?=DIR_WS_LANGUAGES.$language?>/images/buttons/add_button_3.gif"  border="0"></a></td>
							<td width="50"><a href="<? echo tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $row['products_id']);?>"><img src="<?=DIR_WS_LANGUAGES.$language?>/images/buttons/view_button.gif"  border="0"></a></td>
					  </tr>
					</table>			  
		</td>
<?
}
?>
          </tr>
        </table>
<?
}
?>
<map name="Map1" id="Map1">
  <area shape="rect" coords="482,1,603,18" href="products_new.php">
</map>
<map name="Map2" id="Map2">
  <area shape="rect" coords="488,3,604,20" href="specials.php">
</map>
