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


  $listing_split = new splitPageResults($listing_subscription_sql, MAX_DISPLAY_SEARCH_RESULTS,'s.subscription_id');
  $subscription_rows_count=$listing_split->number_of_rows;
  if(!$subscription_rows_count)return;
  $list_box_contents = array();
  for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
    switch ($column_list[$col]) {
      case 'SUBSCRIPTION_LIST_NAME':
        $lc_text = TEXT_SUBSCRIPTIONS;
        $lc_align = '';
        break;
      case 'SUBSCRIPTION_LIST_COSTS':
        $lc_text = TABLE_HEADING_PRICE;
        $lc_align = 'right';
        break;
      case 'SUBSCRIPTION_LIST_MAX_REGT':
        $lc_text = TABLE_HEADING_REGT;
        $lc_align = 'right';
        break;
      case 'SUBSCRIPTION_LIST_MAX_RES':
        $lc_text = TABLE_HEADING_MAXIMUM;
        $lc_align = 'right';
        break;
      case 'SUBSCRIPTION_LIST_SESSIONS':
        $lc_text = TABLE_HEADING_SESSIONS;
        $lc_align = 'center';
        break;
      case 'SUBSCRIPTION_LIST_BUY_NOW':
        $lc_text = TABLE_HEADING_BUY_NOW;
        $lc_align = 'center';
        break;
	  case 'SUBSCRIPTION_LIST_IMAGE':
        $lc_text = TABLE_HEADING_IMAGE;
        $lc_align = 'center';
        break;
    }
    if ( ($column_list[$col] != 'SUBSCRIPTION_LIST_BUY_NOW') && ($column_list[$col] != 'SUBSCRIPTION_LIST_IMAGE') ) {
       $lc_text = tep_create_sort_heading(tep_db_prepare_input($HTTP_GET_VARS['sort']), $col+1,$lc_text);
    }
    $list_box_contents[0][] = array('align' => $lc_align,
                                    'params' => 'class="productListing-heading"',
                                    'text' => '&nbsp;' . $lc_text . '&nbsp;');
  }

  if ($listing_split->number_of_rows > 0) {
    $listing_query = tep_db_query($listing_split->sql_query);

    $row = 0;
    $column = 0;
    while ($listing = tep_db_fetch_array($listing_query)) {
      $rows++;
      if (($rows/2) == floor($rows/2)) {
        $list_box_contents[] = array('params' => 'class="productListing-even"');
      } else {
        $list_box_contents[] = array('params' => 'class="productListing-odd"');
      }
       $cur_row = sizeof($list_box_contents) - 1;
      for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
        $lc_align = '';
        switch ($column_list[$col]) {
          case 'SUBSCRIPTION_LIST_NAME':
            $lc_align = '';
              $lc_text = '&nbsp;<a href="' . tep_href_link(FILENAME_SUBSCRIPTIONS_INFO, ($suPath ? 'suPath=' . $suPath . '&' : '') . 'subscription_id=' . $listing['subscription_id']) . '">' . $listing['subscription_name'] . '</a>&nbsp;';
            break;
          case 'SUBSCRIPTION_LIST_COSTS':
            $lc_align = 'right';
              $lc_text = '&nbsp;' . $currencies->display_price($listing['subscription_costs'], tep_get_tax_rate($listing['subscription_tax_class_id'])) . '&nbsp;';
            break;
          case 'SUBSCRIPTION_LIST_IMAGE':
            $lc_align = 'center';
              $lc_text = '&nbsp;<a href="' . tep_href_link(FILENAME_SUBSCRIPTIONS_INFO, ($sucPath ? 'sucPath=' . $sucPath . '&' : '') . 'subscription_id=' . $listing['subscription_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['subscription_image'], $listing['subscription_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>&nbsp;';
            break;
          case 'SUBSCRIPTION_LIST_BUY_NOW':
            $lc_align = 'center';
            $lc_text = '<br><a href="' . tep_href_link(FILENAME_SUBSCRIPTIONS_INFO, ($suPath ? 'suPath=' . $suPath . '&' : '') . 'subscription_id=' . $listing['subscription_id']) . '">' . tep_template_image_button('button_select.gif', IMAGE_BUTTON_BUY_NOW) . '</a>&nbsp;';
            break;
        }
        $list_box_contents[$cur_row][] = array('align' => $lc_align,
                                               'params' => 'class="productListing-data" width="100"',
                                               'text'  => $lc_text);
      }
    }

    new productListingBox($list_box_contents);
  } elseif(isset($HTTP_GET_VARS['page']) && (int)$HTTP_GET_VARS['page']<=1) {
   // $list_box_contents = array();
    $list_box_contents[1] = array('params' => 'class="productListing-odd"');
    $list_box_contents[1][] = array('align' => 'center',
									'params' => ' colspan=5 class="productListing-data"',
                                   'text' => TEXT_NO_SUBSCRIPTIONS);
    new productListingBox($list_box_contents);
  }
?>