<?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_sql, MAX_DISPLAY_SEARCH_RESULTS);

  if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
  <tr>
    <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_SUBSCRIPTIONS); ?></td>
    <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
  </tr>
</table>
<?php
  }
  $list_box_contents = array();

  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)) {

      $subscription_contents = array();

      for ($col=0, $n=sizeof($column_subscription_list); $col<$n; $col++) {
        $lc_align = '';
        switch ($column_subscription_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(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&subscription_id=' . $listing['subscription_id']) . '">' . tep_template_image_button('button_select.gif', IMAGE_BUTTON_BUY_NOW) . '</a>&nbsp;';
			$lc_text="";
            break;
        }
        if ($column_subscription_list[$col]!='SUBSCRIPTION_LIST_PERIOD') $subscription_contents[] = $lc_text;

      }
      $lc_text = implode('<br>', $subscription_contents);
      $list_box_contents[$row][$column] = array('align' => 'center',
                                                'params' => 'class="productListing-data"',
                                                'text'  => $lc_text);
      $column ++;
      if ($column >= 3) {
        $row ++;
        $column = 0;
      }
    }

    new productListingBox($list_box_contents);
  } else {
    $list_box_contents = array();

    $list_box_contents[0] = array('params' => 'class="productListing-odd"');
    $list_box_contents[0][] = array('params' => 'class="productListing-data"',
                                   'text' => TEXT_NO_SUBSCRIPTIONS);

    new productListingBox($list_box_contents);
  }

  if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
  <tr>
    <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_SUBSCRIPTIONS); ?></td>
    <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
  </tr>
</table>
<?php
  }
?>