<?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_SERVICES); ?></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)) {

      $services_contents = array();

      for ($col=0, $n=sizeof($column_services_list); $col<$n; $col++) {
        $lc_align = '';
        switch ($column_services_list[$col]) {
          case 'SERVICES_LIST_NAME':
              $lc_align = '';
              $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 'SERVICES_LIST_COSTS':
	  //if($service_info['include_resource']=='Y' && $service_info['include_resource_price']=='N' || $service_info['include_resource']=='N'){	
             $lc_align = 'right';
	    		 $lc_text ="";	
	   		if($listing['include_resource']=='Y' && $listing['include_resource_price']=='N' || $listing['include_resource']=='N'){	
            	$lc_text = '&nbsp;' . $currencies->display_price($listing['service_costs'], tep_get_tax_rate($listing['service_tax_class_id'])) . '&nbsp;';
            }   
	 break;
          case 'SERVICES_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_image(DIR_WS_IMAGES . $listing['service_image'], $listing['service_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>&nbsp;';
            break;
          case 'SERVICES_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&service_id=' . $listing['service_id']) . '">' . tep_template_image_button('button_select.gif', IMAGE_BUTTON_BUY_NOW) . '</a>&nbsp;';
				$lc_text="";
          break;
        }
        if ($column_services_list[$col]!='SERVICES_LIST_PERIOD') $services_contents[] = $lc_text;

      }
      $lc_text = implode('<br>', $services_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_SERVICES);

    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_SERVICES); ?></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
  }
?>
