<?php
/*
  osCommRes, Services Oline 
http://www.oscommres.com 
Copyright (c) 2005 osCommRes 

Freeway eCommerce 
http://www.zac-ware.com/freeway 
Copyright (c) 2007 ZacWare 

Released under the GNU General Public License 
*/
// Check to ensure this file is included in Freeway!
defined('_FEXEC') or die();
?>
<!-- specials //-->
<?php 
	$customer_exists = '';
	if(tep_session_is_registered('customer_id'))
	$customer_exists = "OR(p.restrict_to_customers like '%," . $customer_id . ",%' OR p.restrict_to_groups like '%," . $customers_groups_id . ",%')";
	$random_sql = "select p.products_id, pd.products_name, p.products_image_1,p.products_title_1, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id  left join " . TABLE_FEATURED . " f on p.products_id = f.products_id and pd.language_id = '" . $languages_id . "'  where p.products_status = '1' and f.status = '1' " . 
				" and (" . 
						"(p.restrict_to_customers = '' OR ISNULL(p.restrict_to_customers))" . 
						"and(p.restrict_to_groups = '' OR ISNULL(p.restrict_to_groups))" . $customer_exists . 
				") order by f.featured_date_added DESC limit " . MAX_RANDOM_SELECT_SPECIALS;
  if ($random_product = tep_random_select($random_sql)) {

?>
          <tr>
            <td>
<?php
$special_price=tep_get_products_special_price($random_product["products_id"]);
if ($special_price) {
      $whats_new_price =  '<s>' . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id']),1,true) . '</s><br>';
      $whats_new_price .= $currencies->display_price($special_price, tep_get_tax_rate($random_product['products_tax_class_id'])) . '</span>';
    } else {
      $whats_new_price =  $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id']),1,true);
    }


	if(!defined('BOX_HEADING_FEATURED'))define('BOX_HEADING_FEATURED', 'featured');
    $info_box_contents = array();
    $info_box_contents[] = array('align' => 'left',
                                 'text'  =>  BOX_HEADING_FEATURED
                                );
   // new infoBoxHeading($info_box_contents,  true, true, tep_href_link(FILENAME_FEATURED_PRODUCTS, '', 'NONSSL'));
		 new infoBoxHeading($info_box_contents,  true, true);
    $info_box_contents = array();
    $info_box_contents[] = array('align' => 'center',
						'text'  => '<table cellpadding="0" cellspacing="0"><tr><td class="infoBoxNavigationContent" align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . tep_product_small_image($random_product['products_image_1'], $random_product['products_title_1']) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id'], 'NONSSL') . '">' . $random_product['products_name'] . '</a><br><font class="productSpecialPrice">' . $whats_new_price . '</font></td></tr></table>'
                                );



   new infoBox($info_box_contents);
  
$info_box_contents = array();
  $info_box_contents[] = array('align' => 'left',
                                'text'  => tep_draw_separator('pixel_trans.gif', '100%', '1')
                              );
  new infoboxFooter($info_box_contents, true, true);
?>
            </td>
          </tr>
<?php
  }
?>
<!-- specials_eof //-->
