<?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_service_sql, MAX_DISPLAY_SEARCH_RESULTS,'s.service_id');
  $service_rows_count=$listing_split->number_of_rows;
  if(!$service_rows_count)return;
  $list_box_contents=array();
  for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
    switch ($column_list[$col]) {
      case 'SERVICE_LIST_NAME':
      	$lc_align = 'left';
         $lc_text = TEXT_SERVICES;
         break;
      case 'SERVICE_LIST_COSTS':
        $lc_text = TABLE_HEADING_PRICE;
        $lc_align = 'right';
        break;
      case 'SERVICE_LIST_BUY_NOW':
        $lc_text = TABLE_HEADING_BUY_NOW;
        $lc_align = 'center';
        break;
	  case 'SERVICE_LIST_IMAGE':
        $lc_text = TABLE_HEADING_IMAGE;
        $lc_align = 'center';
        break;
    }
    if ( ($column_list[$col] != 'SERVICE_LIST_BUY_NOW') && ($column_list[$col] != 'SERVICE_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 'SERVICE_LIST_NAME':
            $lc_align = 'left';
            $lc_text = '&nbsp;<a href="' . tep_href_link(FILENAME_SERVICES_INFO, ($secPath ? 'secPath=' . $secPath . '&' : '') . 'service_id=' . $listing['service_id']) . '">' . $listing['service_name'] . '</a>&nbsp;';
            break;
          case 'SERVICE_LIST_COSTS':
            $lc_align = 'right';
            $lc_text = '&nbsp;' . $currencies->display_price($listing['service_costs'], tep_get_tax_rate($listing['service_tax_class_id'])) . '&nbsp;';
            break;
          case 'SERVICE_LIST_IMAGE':
            $lc_align = 'center';
            $lc_text = '&nbsp;<a href="' . tep_href_link(FILENAME_SERVICES_INFO, ($secPath ? 'secPath=' . $secPath . '&' : '') . 'service_id=' . $listing['service_id']) . '">' . tep_product_small_image($listing['service_image'], $listing['service_name']) . '</a>&nbsp;';
            break;
          case 'SERVICE_LIST_BUY_NOW':
            $lc_align = 'center';
            $lc_text = '<br><a href="' . tep_href_link(FILENAME_SERVICES_INFO, ($secPath ? 'secPath=' . $secPath . '&' : '') . 'service_id=' . $listing['service_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[1] = array('params' => 'class="productListing-odd"');
    $list_box_contents[1][] = array('align' => 'center',
									'params' => ' colspan=5 class="productListing-data"',
                                   'text' => TEXT_NO_SERVICES);
    new productListingBox($list_box_contents);
  }
?>