<?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();


if ($HTTP_GET_VARS['subscription_id']) { 
//xsell_products forced//
$subscriptions_id_list=$cart->get_product_id_list();
if ($subscriptions_id_list=="") $subscriptions_id_list="0";

$xsell_query = tep_db_query("select distinct s.subscription_id, s.subscription_image, sd.subscription_name, s.subscription_tax_class_id,xp.xsell_id, subscription_costs from " . TABLE_PRODUCTS_XSELL . " xp, " . TABLE_SUBSCRIPTIONS . " s, " . TABLE_SUBSCRIPTIONS_DESCRIPTION . " sd where xp.xsell_type='F' and xp.item_type='S' and xp.products_id = '" . tep_db_input(tep_db_prepare_input($HTTP_GET_VARS['subscription_id'])) . "' and xp.xsell_id=s.subscription_id and s.subscription_id = sd.subscription_id and sd.language_id = '" . $languages_id . "' and s.subscription_status = '1' and xp.xsell_id not in ('" .$subscriptions_id_list . "') order by xp.products_id asc ");
$num_subscriptions_xsell = tep_db_num_rows($xsell_query); 
if ($num_subscriptions_xsell >= MIN_DISPLAY_XSELL) { 

      $info_box_contents = array();
      $info_box_contents[] = array('align' => 'left', 'text' => TEXT_XSELL_FORCED_SUBSCRIPTIONS);
      new contentBoxHeading($info_box_contents, false, false);

    $info_box_contents = array();
	$info_box_contents[0][0]=array('align'=>'right','params'=>' colspan=3 class="smallText" valign="middle"','text'=>tep_draw_selection_field('xsell_forced_item','checkbox',$xsell['xsell_id'],'','valign=top') . TEXT_SELECT_FORCED_ITEMS);
	$info_box_contents[0][1]=array('text'=>'');
	$info_box_contents[0][2]=array('text'=>'');

      $row = 1;
      $col = 0;

      while ($xsell = tep_db_fetch_array($xsell_query)) {
      $xsell_price =  $currencies->display_price($xsell['subscription_costs'], tep_get_tax_rate($xsell['subscription_tax_class_id'])); 
    		$products_text="";
			
			$products_text='<tr><td class=smalltext ><a href="' . tep_href_link(FILENAME_SUBSCRIPTION_INFO, 'subscription_id=' . $xsell['subscription_id']) . '">' .tep_image(DIR_WS_IMAGES . $xsell['subscription_image'],$xsell['subscription_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>' .
											   '<td align=left class=smalltext valign="top"><a href="' . tep_href_link(FILENAME_SUBSCRIPTION_INFO, 'subscription_id=' . $xsell['subscription_id']) . '">' . $xsell['subscription_name'] .'</a><br>' . $xsell_price. '</td></tr>';
		
        $info_box_contents[$row][$col] = array('align' => 'left',
                                               'params' => 'class="smallText" width="33%" valign="top"',
                                               'text' => '<table cellpadding=3>' .  $products_text . '</table>');
	    $xsell_forced_ids .=($xsell_forced_ids!=''?',':'');
		$xsell_forced_ids .=$xsell['xsell_id'];
		echo '<input type="hidden" name="xsell_forced_id[]" value="' .$xsell["xsell_id"] . '">';
        $col ++;
        if ($col > 2) {
          $col = 0;
          $row ++;
        }
      }

      new contentBox($info_box_contents);
if (MAIN_TABLE_BORDER == 'yes'){
$info_box_contents = array();
$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);
}
}
?>
<!-- xsell_products_eof forced//-->
<!-- xsell_products //-->
<?php
$xsell_query = tep_db_query("select distinct s.subscription_id, s.subscription_image, sd.subscription_name, s.subscription_tax_class_id, subscription_costs from " . TABLE_PRODUCTS_XSELL . " xp, " . TABLE_SUBSCRIPTIONS . " s, " . TABLE_SUBSCRIPTIONS_DESCRIPTION . " sd where xp.xsell_type='G' and xp.item_type='S' and xp.products_id = '" . tep_db_input(tep_db_prepare_input($HTTP_GET_VARS['subscription_id'])) . "' and xp.xsell_id = s.subscription_id and s.subscription_id = sd.subscription_id and sd.language_id = '" . $languages_id . "' and s.subscription_status = '1' order by xp.products_id asc limit " . MAX_DISPLAY_ALSO_PURCHASED); 
$num_subscriptions_xsell = tep_db_num_rows($xsell_query); 
if ($num_subscriptions_xsell >= MIN_DISPLAY_XSELL) { 
      $info_box_contents = array();
      $info_box_contents[] = array('align' => 'left', 'text' =>TEXT_XSELL_SUBSCRIPTIONS);
      new contentBoxHeading($info_box_contents, false, false);

      $row = 0;
      $col = 0;
      $info_box_contents = array();
      while ($xsell = tep_db_fetch_array($xsell_query)) {
       
      $xsell_price =  $currencies->display_price($xsell['subscription_costs'], tep_get_tax_rate($xsell['subscription_tax_class_id']),1,true); 
      $info_box_contents[$row][$col] = array('align' => 'center',
                                               'params' => 'class="smallText" width="33%" valign="top"',
                                               'text' => '<table cellpadding=3><tr><td width=10></td><td><a href="' . tep_href_link(FILENAME_SUBSCRIPTION_INFO, 'subscription_id=' . $xsell['subscription_id']) . '">' . tep_image(DIR_WS_IMAGES . $xsell['subscription_image'], $xsell['subscription_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td></tr>' .
											   '<tr><td></td><td class=smalltext><a href="' . tep_href_link(FILENAME_SUBSCRIPTION_INFO, 'subscription_id=' . $xsell['subscription_id']) . '">' . stripslashes($xsell['subscription_name']) .'</a><br><div align=center>' .  $xsell_price . '</div></td></tr></table>');
        $col ++;
        if ($col > 2) {
          $col = 0;
          $row ++;
        }
      }
      new contentBox($info_box_contents);
if (MAIN_TABLE_BORDER == 'yes'){
$info_box_contents = array();
$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);
}
}
?>
<!-- xsell_products_eof //-->
<?php
  }
?>