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


//echo $listing_event_sql;
  $listing_split = new splitPageResults($listing_event_sql, MAX_DISPLAY_SEARCH_RESULTS,'e.events_id');
  $event_rows_count=$listing_split->number_of_rows;
  if(!$event_rows_count) return;
  $list_box_contents = array();

  for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
    switch ($column_list[$col]) {
      case 'EVENT_LIST_NAME':
        $lc_text = TABLE_HEADING_EVENTS;
        $lc_align = '';
        break;
      case 'EVENT_LIST_FEES':
        $lc_text = TABLE_HEADING_PRICE;
        $lc_align = 'right';
        break;
      case 'EVENT_LIST_MAX_REGT':
        $lc_text = TABLE_HEADING_REGT;
        $lc_align = 'right';
        break;
      case 'EVENT_LIST_MAX_RES':
        $lc_text = TABLE_HEADING_MAXIMUM;
        $lc_align = 'right';
        break;
      case 'EVENT_LIST_SESSIONS':
        $lc_text = TABLE_HEADING_SESSIONS;
        $lc_align = 'center';
        break;
      case 'EVENT_LIST_BUY_NOW':
        $lc_text = TABLE_HEADING_BUY_NOW;
        $lc_align = 'center';
        break;
	  case 'EVENT_LIST_IMAGE':
        $lc_text = TABLE_HEADING_IMAGE;
        $lc_align = 'center';
        break;
    }
    if(($column_list[$col] != 'EVENT_LIST_BUY_NOW') && ($column_list[$col] != 'EVENT_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++) {
        switch ($column_list[$col]) {
          case 'EVENT_LIST_NAME':
            $lc_align = 'left';
            $lc_text = '&nbsp;<a href="' . tep_href_link(FILENAME_SESSION_DETAILS, ($ecPath ? 'ecPath=' . $ecPath . '&' : '') . 'events_id=' . $listing['events_id']) . '">' . $listing['events_name'] . '</a><br>';
            break;
		  case 'EVENT_LIST_FEES':
            $lc_align = 'right';
            $lc_text = '&nbsp;<a href="' . tep_href_link(FILENAME_SESSION_DETAILS, ($ecPath ? 'ecPath=' . $ecPath . '&' : '') . 'events_id=' . $listing['events_id']) . '">' . $currencies->display_price($listing['events_fees'], tep_get_tax_rate($listing['events_tax_class_id'])) . '</a><br>';
            break;	    
           case 'EVENT_LIST_IMAGE':
            $lc_align = 'center';
            $lc_text = '&nbsp;<a href="' . tep_href_link(FILENAME_SESSION_DETAILS, ($ecPath ? 'ecPath=' . $ecPath . '&' : '') . 'events_id=' . $listing['events_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['events_image'], $listing['events_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';
            break;
		   case 'EVENT_LIST_BUY_NOW':
            $lc_align = 'center';
            $lc_text = '<a href="' . tep_href_link(FILENAME_SESSION_DETAILS, ($ecPath ? 'ecPath=' . $ecPath . '&' : '') . 'events_id=' . $listing['events_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_EVENTS);
    new productListingBox($list_box_contents);
  }
?>