<?php
/*
  $Id: upcoming_products.php,v 1.1.1.1 2003/09/18 19:04:53 wilt Exp $

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

  Copyright (c) 2003 osCommerce

	Freeway eCommerce
	http://www.openfreeway.org
	Copyright (c) 2007 ZacWare
	
  Released under the GNU General Public License
*/

// Check to ensure this file is included in Freeway!
defined('_FEXEC') or die();



?>
<?php 

  //$expected_query = tep_db_query("select p.products_id, pd.products_name, products_date_available as date_expected from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where to_days(products_date_available) >= to_days(now()) and p.products_id = pd.products_id and pd.language_id = '" . (int)$FSESSION->languages_id . "' order by " . EXPECTED_PRODUCTS_FIELD . " " . EXPECTED_PRODUCTS_SORT . " limit " . MAX_DISPLAY_UPCOMING_PRODUCTS);
  //if (tep_db_num_rows($expected_query) > 0) {
?>
<?php
// BOF: Lango Added for template MOD
//if (MAIN_TABLE_BORDER == 'yes'){
//table_image_border_top(false, false, TABLE_HEADING_UPCOMING_PRODUCTS);
//}

// EOF: Lango Added for template MOD
?>
		<table border="0" width="100%" cellspacing="0" cellpadding="2">
		<tr>
			<td class="headerNavigation1" colspan="3" width="25%" align="left" height="34">
			<table cellpadding="0" cellspacing="5" border="0" width="100%">
				<tr><td class="infoBoxNavigationContent" valign="middle"><?php echo '<b>'.TABLE_HEADING_UPCOMING_PRODUCTS.'</b>';?></td></tr>
			</table>
			</td>	
		</tr>	
		<?php
			if (!isset($upcoming_products_array)){	
				  $upcoming_products_query_raw = "select p.products_id, pd.products_description, pd.products_name, p.products_image_1, p.products_title_1, p.products_price, p.products_tax_class_id, p.products_date_added,  p.products_date_available as date_expected from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where products_date_available >'" . getServerDate() ."' and p.products_status=1 and p.products_id = pd.products_id  and pd.language_id = '" . (int)$FSESSION->languages_id . "' order by " . EXPECTED_PRODUCTS_FIELD . " " . EXPECTED_PRODUCTS_SORT . " limit " . MAX_DISPLAY_UPCOMING_PRODUCTS;
				 
				  $upcoming_products_query = tep_db_query($upcoming_products_query_raw);
				  while ($upcoming_products = tep_db_fetch_array($upcoming_products_query)) {
					$upcoming_products_array[] = array('id' => $upcoming_products['products_id'],
												  'name' => $upcoming_products['products_name'],
												  'image' => $upcoming_products['products_image_1'],
												  'title'=>$upcoming_products['products_title_1'],
												  'price' => $upcoming_products['products_price'],
												  'tax_class_id' => $upcoming_products['products_tax_class_id'],
												  'products_description' => $upcoming_products['products_description'],
												  'date_added' => tep_date_long($upcoming_products['products_date_added']));
												  //'manufacturer' => $upcoming_products['manufacturers_name']);
				  }
			}
		  if (sizeof($upcoming_products_array) == '0') {
		?>
		  <tr>
			<td class="main" align="center"><b><?php echo TEXT_NO_UPCOMING_PRODUCTS; ?></b></td>
		  </tr>
		  
		<?php
		  } else {
			for($i=0; $i<sizeof($upcoming_products_array); $i++) {
				$products_price = $currencies->display_price($upcoming_products_array[$i]['price'], tep_get_tax_rate($upcoming_products_array[$i]['tax_class_id']),1,true);
			  if(strlen(strip_tags($upcoming_products_array[$i]['products_description']))>150)
			  		$description=substr(strip_tags($upcoming_products_array[$i]['products_description']),0,150)."...";
				else 
					$description=strip_tags($upcoming_products_array[$i]['products_description'],'<br>');
		?>
		  <tr class="infoContentPage" >
		  	<td align="left" width="15%" valign="top">
				<table cellpadding="2" cellspacing="2" border="0" width="100%"><tr>
					<td width="<?php echo SMALL_IMAGE_WIDTH + 10; ?>" valign="top" class="main" align="left"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $upcoming_products_array[$i]['id'], 'NONSSL') . '">' . tep_product_small_image($upcoming_products_array[$i]['image'], $upcoming_products_array[$i]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>' ; ?></td>
				</tr>
				<tr><td class="main" align="center"><?php echo TEXT_PRICE . ' ' . $products_price;?></td></tr>
				</table>
			</td>
			<td align="left" valign="top" width="60%">
				<table cellpadding="2" cellspacing="2" border="0" width="100%">
				  <tr><td valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $upcoming_products_array[$i]['id'], 'NONSSL') . '" ><font  class="mainText"><b>' . $upcoming_products_array[$i]['name'] . '</b></font></a>';?></td></tr>
				  <tr><td valign="top" height="40" class="main"><?php echo $description;?></td></tr>
				  <?php if(HIDE_FEATURED_PRODUCT_ID=="Yes"){?>
					<tr><td class="infoboxContentDetails" valign="top"><?php echo '<b>'.TEXT_ID . '#' . $upcoming_products_array[$i]['id'].'</b>' ; ?></td></tr>
				<?php }?>
					<tr><td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $upcoming_products_array[$i]['id'], 'NONSSL') . '">' . tep_template_image_button('button_details.gif', IMAGE_BUTTON_DETAILS) . '</a>'; ?></td></tr> 
				</table>
			</td>
			<?php $category_query=tep_db_query("select pc.categories_id from ".TABLE_PRODUCTS_TO_CATEGORIES." pc, ".TABLE_PRODUCTS." p where p.products_id=pc.products_id and p.products_id='".(int)$upcoming_products_array[$i]['id']."'");
				  $category_array=tep_db_fetch_array($category_query);
				  $similar_products_query=tep_db_query("select pd.products_name,pd.products_id from ".TABLE_PRODUCTS_DESCRIPTION ." pd, ".TABLE_PRODUCTS ." p, ".TABLE_PRODUCTS_TO_CATEGORIES." pc where p.products_id=pc.products_id and pc.products_id=pd.products_id and pc.categories_id='".(int)$category_array["categories_id"]."' and pd.products_id!='".(int)$upcoming_products_array[$i]['id']."' and pd.language_id='".(int)$FSESSION->languages_id."'group by pd.products_id limit 5");
			?>		
			<td align="left" class="main" valign="top" width="25%">
				<table cellpadding="0" cellspacing="2" border="0">
					<?php if(tep_db_num_rows($similar_products_query)){?>
					<tr><td class="infoBoxNavigation"><?php echo '<b>'.TEXT_HEADING_SIMILAR_PRODUCTS.'</b>';?></td></tr><tr><td></td></tr>
					<?php while($similar_products_array=tep_db_fetch_array($similar_products_query)){?>
						<tr><td class="infoboxSimilar"><?php echo '- <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'products_id=' . $similar_products_array['products_id'], 'NONSSL') . '">'.$similar_products_array["products_name"].'</a>';?></td></tr>
			<?php } 
				} //echo '<a href="' . tep_href_link(FILENAME_FEATURED_PRODUCTS, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products_array[$i]['id'], 'NONSSL') . '">' . tep_template_image_button('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</a>'; 
			 ?>
		 	 </table>
			 </td>
			 </tr>
		<?php 
			//  if (($i+1) != sizeof($upcoming_products_array)) {
		?>
		 <!-- <tr>
			<td colspan="3" class="main">&nbsp;</td>
		  </tr>-->
		<?php
			//  }
			} ?>
			
	<?php	  }
		?>

<?php
// BOF: Lango Added for template MOD
//if (MAIN_TABLE_BORDER == 'yes'){
//table_image_border_bottom();
//}
// EOF: Lango Added for template MOD
?>
