<?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 (isset($HTTP_GET_VARS['subscription_id'])) {
    $orders_query = tep_db_query("select s.subscription_id, s.subscription_image from " . TABLE_ORDERS_PRODUCTS . " opa, " . TABLE_ORDERS_PRODUCTS . " opb, " . TABLE_ORDERS . " o, " . TABLE_SUBSCRIPTIONS . " s where opa.products_id = '" . (int)$HTTP_GET_VARS['subscription_id'] . "' and opa.orders_id = opb.orders_id and opb.products_id != '" . (int)$HTTP_GET_VARS['subscription_id'] . "' and opb.products_id = s.subscription_id and opb.orders_id = o.orders_id and s.subscription_status = '1' group by s.subscription_id order by o.date_purchased desc limit " . MAX_DISPLAY_ALSO_PURCHASED);
    $num_subscription_ordered = tep_db_num_rows($orders_query);
    if ($num_subscription_ordered >= MIN_DISPLAY_ALSO_PURCHASED) {
?>
<!-- also_purchased_products //-->

<?php
      $info_box_contents = array();
      $info_box_contents[] = array('text' => TEXT_ALSO_PURCHASED_SUBSCRIPTIONS);

      new infoBoxHeading($info_box_contents,false, false);

      $row = 0;
      $col = 0;
      $info_box_contents = array();
      while ($orders = tep_db_fetch_array($orders_query)) {
        $orders['subscription_name'] = tep_get_subscription_name($orders['subscription_id']);
        $info_box_contents[$row][$col] = array('align' => 'center',
                                               'params' => 'class="smallText" width="33%" valign="top"',
                                               'text' => '<a href="' . tep_href_link(FILENAME_SUBSCRIPTION_INFO, 'subscription_id=' . $orders['subscription_id']) . '">' . tep_image(DIR_WS_IMAGES . $orders['subscription_image'], $orders['subscription_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_SUBSCRIPTION_INFO, 'subscription_id=' . $orders['subscription_id']) . '">' . $orders['subscription_name'] . '</a>');
        $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);
}
?>
<!-- also_purchased_products_eof //-->
<?php
    }
  }
?>
