<?php 
/*
	Freeway eCommerce
	http://www.openfreeway.org
	Copyright (c) 2007 ZacWare

	Released under the GNU General Public License 
*/	
// Check to ensure this file is included in Freeway!
defined('_FEXEC') or die();
?>
    <table width="100%">
<?php
// BOF: Lango Added for template MOD
if (SHOW_HEADING_TITLE_ORIGINAL == 'yes') {
$header_text = '&nbsp;'
//EOF: Lango Added for template MOD
?>
      <tr>
        <td><h3><?php echo HEADING_TITLE; ?></h3></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
<?php
}else{
$header_text = HEADING_TITLE_2;
}
?>

          <tr>
            <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
          </tr>
      <tr>
                <td >
		<Div id="navtext"></Div>
        </td>
      </tr>
<tr><td>
<?php if($include_event)
{
   // $define_list = array('EVENT_LIST_IMAGE' => PRODUCT_LIST_IMAGE,
						// 'EVENT_LIST_NAME' => PRODUCT_LIST_NAME,
						// 'EVENT_LIST_FEES'=>PRODUCT_LIST_PRICE,
						// 'EVENT_LIST_MAX_REGT' => '0',
						// 'EVENT_LIST_MAX_RES' => '0',
						// 'EVENT_LIST_SESSIONS' =>'0',
						// 'EVENT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW);
  // asort($define_list);
  // $column_list = array();
  // //reset($define_list);
  // while (list($key, $value) = each($define_list)) {
    // if ($value > 0) $column_list[] = $key;
  // }
  // $select_column_list = get_select_fields($column_list);
  // $select_str = "SELECT distinct " . $select_column_list . " e.events_id,ed.events_name,e.events_fees,e.events_tax_class_id "; //
  // if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {
    // $select_str .= ", SUM(tr.tax_rate) as tax_rate ";
  // }
  // $from_str="from " . TABLE_EVENTS . " e " ;
  // if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {
		// if (!$FSESSION->is_registered('customer_country_id')) {
   				// $FSESSION->set('customer_country_id',STORE_COUNTRY);
				// $FSESSION->set('customer_zone_id',STORE_ZONE);
  // }
  	// $from_str .= " left join " . TABLE_TAX_RATES . " tr on e.events_tax_class_id = tr.tax_class_id left join " . TABLE_ZONES_TO_GEO_ZONES . " gz on tr.tax_zone_id = gz.geo_zone_id and (gz.zone_country_id is null or gz.zone_country_id = '0' or gz.zone_country_id = '" . (int)$FSESSION->customer_country_id . "') and (gz.zone_id is null or gz.zone_id = '0' or gz.zone_id = '" . (int)$FSESSION->customer_zone_id . "')";
// }
// $from_str .= ", " . TABLE_EVENTS_DESCRIPTION . " ed, " . TABLE_EVENTS_TO_EVENTS_CATEGORIES . " e2c," .TABLE_EVENTS_CATEGORIES . " ec ";
// $where_str=" where e.events_status = '1' and  e.events_id = ed.events_id and ed.language_id = '" . (int)$FSESSION->languages_id . "' and e.events_id = e2c.events_id and e2c.events_categories_id = ec.events_categories_id ";
// // and e2c.events_categories_id = '" . (int)$default_category . "'";
// if(tep_not_null($event_category_id)){
	// if(tep_not_null($event_subcat)){
      // $subcategories_array = array();
   	  // tep_get_events_subcategories($subcategories_array, $event_category_id);
      // $where_str .= " and e2c.events_id = e.events_id and e2c.events_id = ed.events_id and (e2c.events_categories_id = '" . (int)$event_category_id . "'";
      // for ($i=0, $n=sizeof($subcategories_array); $i<$n; $i++ ) {
        // $where_str .= " or e2c.events_categories_id = '" . (int)$subcategories_array[$i] . "'";
      // }
      // $where_str .= ")";
	// }else {
      // $where_str .= " and e2c.events_id = e.events_id and e2c.events_id = ed.events_id and ed.language_id = '" . (int)$FSESSION->languages_id . "' and e2c.events_categories_id = '" . (int)$event_category_id . "'";
    // }
// }
  // if (isset($search_keywords) && (sizeof($search_keywords) > 0)) {
    // $where_str .= " and (";
    // $where_str .=build_keyword_where_clause($search_keywords,'E');
    // $where_str .= " )";
  // }
 
  // if (tep_not_null($dfrom)) {
    // $where_str .= " and e.events_date_added >= '" . tep_db_input(tep_date_raw($dfrom)) . "'";
  // }

  // if (tep_not_null($dto)) {
    // $where_str .= " and e.events_date_added <= '" . tep_db_input(tep_date_raw($dto)) . "'";
  // }

  // if (tep_not_null($pfrom)) {
    // if ($currencies->is_set($currency)) {
      // $rate = $currencies->get_value($currency);
      // $pfrom = $pfrom / $rate;
    // }
  // }
  // if (tep_not_null($pto)) {
    // if (isset($rate)) {
      // $pto = $pto / $rate;
    // }
  // }

  // if (DISPLAY_PRICE_WITH_TAX == 'true') {
    // if ($pfrom > 0) $where_str .= " and (e.events_fees * if(gz.geo_zone_id is null, 1, 1 + (tr.tax_rate / 100) ) >= " . (float)$pfrom . ")";
    // if ($pto > 0) $where_str .= " and (e.events_fees * if(gz.geo_zone_id is null, 1, 1 + (tr.tax_rate / 100) ) <= " . (float)$pto . ")";
  // } else {
    // if ($pfrom > 0) $where_str .= " and ( e.events_fees>= " . (float)$pfrom . ")";
    // if ($pto > 0) $where_str .= " and (e.events_fees <= " . (float)$pto . ")";
  // }

  // if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {
    // $where_str .= " group by e.events_id, tr.tax_priority";
  // }
  // if ( ($FREQUEST->getvalue('sort')=="") || (!ereg('[1-8][ad]', $FREQUEST->getvalue('sort'))) || (substr($FREQUEST->getvalue('sort'), 0, 1) > sizeof($column_list)) ) {
    // for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {

      // if ($column_list[$i] == 'EVENT_LIST_NAME') {
        // $FREQUEST->setvalue('sort',$i+1 . 'a','GET');
        // $order_str = ' order by ed.events_name';
        // break;
      // }
    // }
  // } else {
    // $sort_col = substr($FREQUEST->getvalue('sort'), 0 , 1);
    // $sort_order = substr($FREQUEST->getvalue('sort'), 1);
	// $order_str=get_sort_order($column_list,$sort_col,$sort_order,'ed.events_name');
  // }
  // $listing_event_sql = $select_str . $from_str . $where_str . $order_str;
  // require(DIR_WS_MODULES . FILENAME_EVENT_LISTING);
  // $select_str="";
  // $from_str="";
  // $where_str="";
  // $order_str="";

}
?>
</td></tr>
<tr><td>
<?php if($include_subscription)
{
	// $define_list = array('SUBSCRIPTION_LIST_IMAGE' => PRODUCT_LIST_IMAGE,
						// 'SUBSCRIPTION_LIST_NAME' => PRODUCT_LIST_NAME,
						// 'SUBSCRIPTION_LIST_COSTS'=>PRODUCT_LIST_PRICE,
						// 'SUBSCRIPTION_LIST_PERIOD' => '0',
						// 'SUBSCRIPTION_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW);
						
  // asort($define_list);
  // $column_list = array();
  // reset($define_list);
  // while (list($key, $value) = each($define_list)) {
    // if ($value > 0) $column_list[] = $key;
  // }
  // $select_column_list = get_select_fields($column_list);
  // $select_str = "select distinct " . $select_column_list . " s.subscription_tax_class_id,s.subscription_id,sd.subscription_name, s.subscription_costs ";
  // if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {
    // $select_str .= ", SUM(tr.tax_rate) as tax_rate ";
  // }
  // $from_str="from " . TABLE_SUBSCRIPTIONS . " s " ;
  // if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {
		// if (!$FSESSION->is_registered('customer_country_id')) {
   				// $FSESSION->set('customer_country_id',STORE_COUNTRY);
				// $FSESSION->set('customer_zone_id',STORE_ZONE);
  // }
  	// $from_str .= " left join " . TABLE_TAX_RATES . " tr on s.subscription_tax_class_id = tr.tax_class_id left join " . TABLE_ZONES_TO_GEO_ZONES . " gz on tr.tax_zone_id = gz.geo_zone_id and (gz.zone_country_id is null or gz.zone_country_id = '0' or gz.zone_country_id = '" . (int)$FSESSION->customer_country_id . "') and (gz.zone_id is null or gz.zone_id = '0' or gz.zone_id = '" . (int)$FSESSION->customer_zone_id . "')";
// }
// $from_str .= ", " . TABLE_SUBSCRIPTIONS_DESCRIPTION . " sd, " . TABLE_SUBSCRIPTION_TO_SUBSCRIPTION_CATEGORIES . " s2c," .TABLE_SUBSCRIPTION_CATEGORIES . " sc ";
// $where_str=" where s.subscription_status=1 and s.subscription_id = sd.subscription_id and sd.language_id = '" . (int)$FSESSION->languages_id . "' and s.subscription_id = s2c.subscription_id and s2c.subscription_categories_id = sc.subscription_categories_id and s.subscription_type!='M'";
// // and e2c.events_categories_id = '" . (int)$default_category . "'";
// if(tep_not_null($subscription_category_id)){
	// if(tep_not_null($subscription_subcat)){
      // $subcategories_array = array();
   	  // tep_get_subscription_subcategories($subcategories_array, $subscription_category_id);
      // $where_str .= " and s2c.subscription_id = s.subscription_id and s2c.subscription_id = sd.subscription_id and (s2c.subscription_categories_id = '" . (int)$subscription_category_id . "'";
      // for ($i=0, $n=sizeof($subcategories_array); $i<$n; $i++ ) {
        // $where_str .= " or s2c.subscription_categories_id = '" . (int)$subcategories_array[$i] . "'";
      // }
      // $where_str .= ")";
	// }else {
      // $where_str .= " and s2c.subscription_id = s.subscription_id and s2c.subscription_id = sd.subscription_id and sd.language_id = '" . (int)$FSESSION->languages_id . "' and s2c.subscription_categories_id = '" . (int)$subscription_category_id . "'";
    // }
// }
  // if (isset($search_keywords) && (sizeof($search_keywords) > 0)) {
    // $where_str .= " and (";
    // $where_str .=build_keyword_where_clause($search_keywords,'S');
    // $where_str .= " )";
  // }
  // if (tep_not_null($dfrom)) {
    // $where_str .= " and s.subscription_date_added >= '" . tep_db_input(tep_date_raw($dfrom)) . "'";
  // }

  // if (tep_not_null($dto)) {
    // $where_str .= " and s.subscription_date_added <= '" . tep_db_input(tep_date_raw($dto)) . "'";
  // }

  // if (tep_not_null($pfrom)) {
    // if ($currencies->is_set($currency)) {
      // $rate = $currencies->get_value($currency);
      // $pfrom = $pfrom / $rate;
    // }
  // }
  // if (tep_not_null($pto)) {
    // if (isset($rate)) {
      // $pto = $pto / $rate;
    // }
  // }

  // if (DISPLAY_PRICE_WITH_TAX == 'true') {
    // if ($pfrom > 0) $where_str .= " and (s.subscription_costs * if(gz.geo_zone_id is null, 1, 1 + (tr.tax_rate / 100) ) >= " . (float)$pfrom . ")";
    // if ($pto > 0) $where_str .= " and (s.subscription_costs * if(gz.geo_zone_id is null, 1, 1 + (tr.tax_rate / 100) ) <= " . (float)$pto . ")";
  // } else {
    // if ($pfrom > 0) $where_str .= " and ( s.subscription_costs>= " . (float)$pfrom . ")";
    // if ($pto > 0) $where_str .= " and (s.subscription_costs <= " . (float)$pto . ")";
  // }

  // if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {
    // $where_str .= " group by s.subscription_id, tr.tax_priority";
  // }

  // if ( ($FREQUEST->getvalue('sort')=="") || (!ereg('[1-4][ad]', $FREQUEST->getvalue('sort'))) || (substr($FREQUEST->getvalue('sort'), 0, 1) > sizeof($column_list)) ) {
    // for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
      // if ($column_list[$i] == 'SUBSCRIPTION_LIST_NAME') {
        // $FREQUEST->setvalue('sort',$i+1 . 'a','GET');
        // $order_str = ' order by sd.subscription_name';
        // break;
      // }
    // }
  // } else {
    // $sort_col = substr($FREQUEST->getvalue('sort'), 0 , 1);
    // $sort_order = substr($FREQUEST->getvalue('sort'), 1);
	// $order_str=get_sort_order($column_list,$sort_col,$sort_order,'sd.subscription_name');
  // }
  // $listing_subscription_sql = $select_str . $from_str . $where_str . $order_str;
  // require(DIR_WS_MODULES . FILENAME_SUBSCRIPTION_LISTING);
  // $select_str="";
  // $from_str="";
  // $where_str="";
  // $order_str="";

}
?>
</td></tr>
<tr><td>
<?php 
//SERVICE START
if($include_service)
{					
  // $define_list = array('SERVICE_LIST_IMAGE' => PRODUCT_LIST_IMAGE,
						// 'SERVICE_LIST_NAME' => PRODUCT_LIST_NAME,
						// 'SERVICE_LIST_COSTS'=>PRODUCT_LIST_PRICE,
						// 'SERVICE_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW);
						
  // asort($define_list);
  // $column_list = array();
  // reset($define_list);
  // while (list($key, $value) = each($define_list)) {
    // if ($value > 0) $column_list[] = $key;
  // }
  // $select_column_list = get_select_fields($column_list);
  // $select_str = "select distinct " . $select_column_list . " s.service_tax_class_id,s.service_id,sd.service_name, s.service_costs ";
   // if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {
    // $select_str .= ", SUM(tr.tax_rate) as tax_rate ";
  // }
  // $from_str="from " . TABLE_SERVICES. " s " ;
  // if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {
		// if (!$FSESSION->is_registered('customer_country_id')) {
   				// $FSESSION->set('customer_country_id',STORE_COUNTRY);
				// $FSESSION->set('customer_zone_id',STORE_ZONE);
  // }
  	// $from_str .= " left join " . TABLE_TAX_RATES . " tr on s.service_tax_class_id = tr.tax_class_id left join " . TABLE_ZONES_TO_GEO_ZONES . " gz on tr.tax_zone_id = gz.geo_zone_id and (gz.zone_country_id is null or gz.zone_country_id = '0' or gz.zone_country_id = '" . (int)$FSESSION->customer_country_id . "') and (gz.zone_id is null or gz.zone_id = '0' or gz.zone_id = '" . (int)$FSESSION->customer_zone_id . "')";
// }
  // $from_str .= ", " . TABLE_SERVICES_DESCRIPTION . " sd, " . TABLE_SERVICES_TO_SERVICES_CATEGORIES . " s2c," .TABLE_SERVICES_CATEGORIES . " sc ";
  // $where_str=" where s.service_status=1 and s.service_id = sd.service_id and sd.language_id = '" . (int)$FSESSION->languages_id . "' and s.service_id = s2c.service_id and s2c.services_categories_id = sc.services_categories_id ";
  // // and e2c.events_categories_id = '" . (int)$default_category . "'";
  // if(tep_not_null($service_category_id)){
	// if(tep_not_null($service_subcat)){
      // $subcategories_array = array();
   	  // //tep_get_subscription_subcategories($subcategories_array, $subscription_category_id);
      // $where_str .= " and s2c.service_id = s.service_id and s2c.service_id = sd.service_id and (s2c.services_categories_id = '" . (int)$service_category_id . "'";
	  // for ($i=0, $n=sizeof($subcategories_array); $i<$n; $i++ ) {
        // $where_str .= " or s2c.services_categories_id = '" . (int)$service_array[$i] . "'";
      // }
      // $where_str .= ")";
	// }else {
      // $where_str .= " and s2c.service_id = s.service_id and s2c.service_id = sd.service_id and sd.language_id = '" . (int)$FSESSION->languages_id . "' and s2c.services_categories_id = '" . (int)$service_category_id . "'";
    // }
  // }
  // if (isset($search_keywords) && (sizeof($search_keywords) > 0)) {
    // $where_str .= " and (";
    // $where_str .=build_keyword_where_clause($search_keywords,'V');
    // $where_str .= " )";
  // }
  // if (tep_not_null($dfrom)) {
    // $where_str .= " and s.service_date_added >= '" . tep_db_input(tep_date_raw($dfrom)) . "'";
  // }

  // if (tep_not_null($dto)) {
    // $where_str .= " and s.service_date_added <= '" . tep_db_input(tep_date_raw($dto)) . "'";
  // }

  // if (tep_not_null($pfrom)) {
    // if ($currencies->is_set($currency)) {
      // $rate = $currencies->get_value($currency);
      // $pfrom = $pfrom / $rate;
    // }
  // }
  // if (tep_not_null($pto)) {
    // if (isset($rate)) {
      // $pto = $pto / $rate;
    // }
  // }

  // if (DISPLAY_PRICE_WITH_TAX == 'true') {
    // if ($pfrom > 0) $where_str .= " and (s.service_costs * if(gz.geo_zone_id is null, 1, 1 + (tr.tax_rate / 100) ) >= " . (float)$pfrom . ")";
    // if ($pto > 0) $where_str .= " and (s.service_costs * if(gz.geo_zone_id is null, 1, 1 + (tr.tax_rate / 100) ) <= " . (float)$pto . ")";
  // } else {
    // if ($pfrom > 0) $where_str .= " and (s.service_costs>= " . (float)$pfrom . ")";
    // if ($pto > 0) $where_str .= " and (s.service_costs <= " . (float)$pto . ")";
  // }

  // if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {
    // $where_str .= " group by s.service_id, tr.tax_priority";
  // }
  // if ( ($FREQUEST->getvalue('sort')=="") || (!ereg('[1-4][ad]', $FREQUEST->getvalue('sort'))) || (substr($FREQUEST->getvalue('sort'), 0, 1) > sizeof($column_list)) ) {
    // for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
      // if ($column_list[$i] == 'SERVICE_LIST_NAME') {
        // $FREQUEST->setvalue('sort',$i+1 . 'a','GET');
        // $order_str = ' order by sd.service_name';
        // break;
      // }
    // }
  // } else {
    // $sort_col = substr($FREQUEST->getvalue('sort'), 0 , 1);
    // $sort_order = substr($FREQUEST->getvalue('sort'), 1);
	// $order_str=get_sort_order($column_list,$sort_col,$sort_order,'sd.service_name');
  // }
  // $listing_service_sql = $select_str . $from_str . $where_str . $order_str;
  // require(DIR_WS_MODULES . FILENAME_SERVICE_LISTING);
  // $select_str="";
  // $from_str="";
  // $where_str="";
  // $order_str="";

// }
// //SERVICE END
// // create column list
// if($include_product)
// {
  // $define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL,
                       // 'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME,
                       // 'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER,
                       // 'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE,
                       // 'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY,
                       // 'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT,
                       // 'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE,
                       // 'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW);

  // asort($define_list);

  // $column_list = array();
  // reset($define_list);
  // while (list($key, $value) = each($define_list)) {
    // if ($value > 0) $column_list[] = $key;
  // }

  // $select_column_list = get_select_fields($column_list);

  // $select_str = "select distinct " . $select_column_list . " m.manufacturers_id, p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price ";

  // if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {
    // $select_str .= ", SUM(tr.tax_rate) as tax_rate ";
  // }

  
  // $from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id";
  
  // if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {
		// if (!$FSESSION->is_registered('customer_country_id')) {
   				// $FSESSION->set('customer_country_id',STORE_COUNTRY);
				// $FSESSION->set('customer_zone_id',STORE_ZONE);
  // }
  	// $from_str .= " left join " . TABLE_TAX_RATES . " tr on p.products_tax_class_id = tr.tax_class_id left join " . TABLE_ZONES_TO_GEO_ZONES . " gz on tr.tax_zone_id = gz.geo_zone_id and (gz.zone_country_id is null or gz.zone_country_id = '0' or gz.zone_country_id = '" . (int)$FSESSION->customer_country_id . "') and (gz.zone_id is null or gz.zone_id = '0' or gz.zone_id = '" . (int)$FSESSION->customer_zone_id . "')";
// }

// $from_str .= ", " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c";
// $where_str = " where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$FSESSION->languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id ";


// if(tep_not_null($product_category_id)){
	// if(tep_not_null($product_subcat)){
      // $subcategories_array = array();
   	  // tep_get_subcategories($subcategories_array, $product_category_id);
      // $where_str .= " and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and (p2c.categories_id = '" . (int)$product_category_id . "'";

      // for ($i=0, $n=sizeof($subcategories_array); $i<$n; $i++ ) {
        // $where_str .= " or p2c.categories_id = '" . (int)$subcategories_array[$i] . "'";
      // }

      // $where_str .= ")";
    // } else {
      // $where_str .= " and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and pd.language_id = '" . (int)$FSESSION->languages_id . "' and p2c.categories_id = '" . (int)$product_category_id . "'";
    // }
  // }

  // if (isset($search_keywords) && (sizeof($search_keywords) > 0)) {
    // $where_str .= " and (";
    // $where_str .=build_keyword_where_clause($search_keywords,'P');
    // $where_str .= " )";
	// }
  // if (tep_not_null($dfrom)) {
    // $where_str .= " and p.products_date_added >= '" . tep_db_input(tep_date_raw($dfrom)) . "'";
  // }

  // if (tep_not_null($dto)) {
    // $where_str .= " and p.products_date_added <= '" . tep_db_input(tep_date_raw($dto)) . "'";
  // }

  // if (tep_not_null($pfrom)) {
    // if ($currencies->is_set($currency)) {
      // $rate = $currencies->get_value($currency);

      // $pfrom = $pfrom / $rate;
    // }
  // }

  // if (tep_not_null($pto)) {
    // if (isset($rate)) {
      // $pto = $pto / $rate;
    // }
  // }

  // if (DISPLAY_PRICE_WITH_TAX == 'true') {
    // if ($pfrom > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) * if(gz.geo_zone_id is null, 1, 1 + (tr.tax_rate / 100) ) >= " . (float)$pfrom . ")";
    // if ($pto > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) * if(gz.geo_zone_id is null, 1, 1 + (tr.tax_rate / 100) ) <= " . (float)$pto . ")";
  // } else {
    // if ($pfrom > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) >= " . (float)$pfrom . ")";
    // if ($pto > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) <= " . (float)$pto . ")";
  // }
	// $customer_exists = '';
	// $customers_groups_id=(int)tep_get_customers_groups_id();
	// if($FSESSION->is_registered('customer_id'))
	// $customer_exists = "OR(p.restrict_to_customers like '%," . (int)$FSESSION->customer_id . ",%' OR p.restrict_to_groups like '%," . $customers_groups_id . ",%')";
	// $where_str .= " and (" . 
					// "(p.restrict_to_customers = '' OR ISNULL(p.restrict_to_customers))" . 
					// "and(p.restrict_to_groups = '' OR ISNULL(p.restrict_to_groups))" . $customer_exists . ") ";

  // if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {
    // $where_str .= " group by p.products_id, tr.tax_priority";
  // }

  // if ( ($FREQUEST->getvalue('sort')=="") || (!ereg('[1-8][ad]', $FREQUEST->getvalue('sort'))) || (substr($FREQUEST->getvalue('sort'), 0, 1) > sizeof($column_list)) ) {
    // for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
      // if ($column_list[$i] == 'PRODUCT_LIST_NAME') {
        // $FREQUEST->setvalue('sort',$i+1 . 'a','GET');
        // $order_str = ' order by pd.products_name';
        // break;
      // }
    // }
  // } else {
    // $sort_col = substr($FREQUEST->getvalue('sort'), 0 , 1);
    // $sort_order = substr($FREQUEST->getvalue('sort'), 1);
		// $order_str=get_sort_order($column_list,$sort_col,$sort_order,'pd.products_name');
  // }
  // $listing_product_sql = $select_str . $from_str . $where_str . $order_str;
  
  // require(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING);
  // $select_str="";
  // $from_str="";
  // $where_str="";
  // $order_str="";
}?>
</td></tr>
<?php 
if($product_rows_count > 0 ) {
	if($product_rows_count>$event_rows_count && $product_rows_count>$subscription_rows_count)
    	$listing_split = new splitPageResults($listing_product_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id');
	// elseif($event_rows_count>$subscription_rows_count)
	    // $listing_split = new splitPageResults($listing_event_sql, MAX_DISPLAY_SEARCH_RESULTS,'e.events_id');
	// else if($subscription_rows_count>$service_rows_count)
 		// $listing_split = new splitPageResults($listing_subscription_sql, MAX_DISPLAY_SEARCH_RESULTS,'s.subscription_id');
  	// else
		// $listing_split = new splitPageResults($listing_service_sql, MAX_DISPLAY_SEARCH_RESULTS,'s.service_id');
  $nav_display='<table cellpadding="2" width="100%">';
  $nav_display.='<tr><td class="smallText" width="50%">';  
      $to_num = ($listing_split->number_of_rows_per_page * $listing_split->current_page_number);
      if ($to_num > $listing_split->number_of_rows) $to_num = $listing_split->number_of_rows;
      
	  $from_num = ($listing_split->number_of_rows_per_page * ($listing_split->current_page_number - 1));
      if ($to_num == 0) {
        $from_num = 0;
      } else {
        $from_num++;
      }
	  $disp_text="";
	  $disp_text=($event_rows_count>0)?$event_rows_count . ' ' . TEXT_EVENTS :'';
	  if($subscription_rows_count>0)
	  {
	  	$disp_text.=($disp_text!=""?",":'');	
	  	$disp_text.=$subscription_rows_count . ' ' . TEXT_SUBSCRIPTIONS ;
	  }
	  if($service_rows_count>0)
	  {
	  	$disp_text.=($disp_text!=""?",":'');	
	  	$disp_text.=$service_rows_count . ' ' . TEXT_SERVICES ;
	  }
	  if($product_rows_count>0)
	  {
	  	$disp_text.=($disp_text!=""?",":'');	
	  	$disp_text.=$product_rows_count . ' ' . TEXT_PRODUCTS_1 ;
	  }
	   $to_num1=$subscription_rows_count+$event_rows_count+$product_rows_count+$service_rows_count ;
   $nav_display.=sprintf(TEXT_DISPLAY_ITEMS, $from_num, $to_num1, $disp_text);
   $nav_display.=' </td>';
   $nav_display.='<td class="smallText" align="right" width="35%">'. TEXT_RESULT_PAGE . '</td><td class="pageNavigation" align="center" width="15%"> ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))) . '</td>';
   $nav_display.='</tr>';
   $nav_display.='</table>';
  } else {
  	echo "<Tr><td class='smallText' align=center>";
	echo TEXT_NO_ITEMS ;
	echo "</td></tr>";
 }
  if((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3')) 
  {
  	echo "<script>";
	echo "document.all.navtext.innerHTML='" . $nav_display . "'" ;
	echo "</script>";
  }
  if((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) 
  {
  	echo "<Tr><td>";
	echo $nav_display ;
	echo "</td></tr>";
    echo "<tr><td>";
    echo tep_draw_separator('pixel_trans.gif', '100%', '10');
    echo "<td></tr>";
  }
?>

      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
      <tr>
        <td class="main"><?php echo '&nbsp;&nbsp;&nbsp;&nbsp;<div style="float:right"><a href="' . tep_href_link(FILENAME_ADVANCED_SEARCH, tep_get_all_get_params(array('sort', 'page')), 'NONSSL', true, false) . '">' . tep_template_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a></div>'; ?></td>
      </tr>
    </table>
<?php
function get_select_fields($column_list)
{
  for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
    switch ($column_list[$i]) {
      case 'PRODUCT_LIST_MODEL':
        $select_column_list .= 'p.products_model, ';
        break;
      case 'PRODUCT_LIST_MANUFACTURER':
        $select_column_list .= 'm.manufacturers_name, ';
        break;
      case 'PRODUCT_LIST_QUANTITY':
        $select_column_list .= 'p.products_quantity, ';
        break;
      case 'PRODUCT_LIST_IMAGE':
        $select_column_list .= 'p.products_image_1,p.products_title_1, ';
        break;
      case 'PRODUCT_LIST_WEIGHT':
        $select_column_list .= 'p.products_weight, ';
        break;
	  case 'EVENT_LIST_NAME':
        $select_column_list .= 'ed.events_name, ';
        break;
	  case 'EVENT_LIST_FEES':
        $select_column_list .= 'e.events_fees, ';
        break;
      case 'EVENT_LIST_IMAGE':
        $select_column_list .= 'e.events_image, ';
        break;
	  case 'EVENT_LIST_MAX_RES':
        $select_column_list .= 'e.events_max_reserve, ';
        break;
	  case 'SUBSCRIPTION_LIST_NAME':
        $select_column_list .= 'sd.subscription_name, ';
		break;
	  case 'SUBSCRIPTION_LIST_COSTS':
        $select_column_list .= 's.subscription_costs, ';
		break;
	  case 'SUBSCRIPTION_LIST_IMAGE':
        $select_column_list .= 's.subscription_image, ';
		break;
     case 'SUBSCRIPTION_LIST_PERIOD':
	 	$select_column_list .= 's.subscription_period, ';
		break;
  	 case 'SERVICE_LIST_NAME':
        $select_column_list .= 'sd.service_name, ';
		break;
	  case 'SERVICE_LIST_COSTS':
        $select_column_list .= 's.service_costs, ';
		break;
	  case 'SERVICE_LIST_IMAGE':
        $select_column_list .= 's.service_image, ';
		break;
    }
  }
  return $select_column_list;
}
function get_sort_order($column_list,$sort_col,$sort_order,$default_order)
{

    $order_str = ' order by ';
    switch ($column_list[$sort_col-1]) {
      case 'PRODUCT_LIST_MODEL':
        $order_str .= "p.products_model " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";
        break;
      case 'PRODUCT_LIST_NAME':
        $order_str .= "pd.products_name " . ($sort_order == 'd' ? "desc" : "");
        break;
      case 'PRODUCT_LIST_MANUFACTURER':
        $order_str .= "m.manufacturers_name " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";
        break;
      case 'PRODUCT_LIST_QUANTITY':
        $order_str .= "p.products_quantity " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";
        break;
      case 'PRODUCT_LIST_IMAGE':
        $order_str .= "pd.products_name ";
        break;
      case 'PRODUCT_LIST_WEIGHT':
        $order_str .= "p.products_weight " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";
        break;
      case 'PRODUCT_LIST_PRICE':
        $order_str .= "final_price " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";
        break;
	  case 'EVENT_LIST_NAME':
	  case 'EVENT_LIST_IMAGE':
        $order_str .= "ed.events_name " . ($sort_order == 'd' ? "desc" : "");
        break;
	  case 'EVENT_LIST_FEES':
        $order_str .= "e.events_fees " . ($sort_order == 'd' ? "desc" : "") . ", ed.events_name";
        break;
	  case 'EVENT_LIST_MAX_RES':
        $order_str .= "e.events_max_reserve " . ($sort_order == 'd' ? "desc" : "") . ", ed.events_name";
        break;
	  case 'SUBSCRIPTION_LIST_NAME':
	  case 'SUBSCRIPTION_LIST_IMAGE':
        $order_str .= "sd.subscription_name " . ($sort_order == 'd' ? "desc" : "") ;
		break;
	  case 'SUBSCRIPTION_LIST_COSTS':
        $order_str .= "s.subscription_costs " . ($sort_order == 'd' ? "desc" : "") . ", sd.subscription_name";
		break;
     case 'SUBSCRIPTION_LIST_PERIOD':
        $order_str .= "s.subscription_period " . ($sort_order == 'd' ? "desc" : "") . ", sd.subscription_name";
		break;
  	  case 'SERVICE_LIST_NAME':
	  case 'SERVICE_LIST_IMAGE':
        $order_str .= "sd.service_name " . ($sort_order == 'd' ? "desc" : "") ;
		break;
	  case 'SERVICE_LIST_COSTS':
        $order_str .= "s.service_costs " . ($sort_order == 'd' ? "desc" : "") . ", sd.service_name";
		break;
     default:
        $order_str .= 	$default_order . ($sort_order == 'd' ? " desc" : "") ;
		break;
    }
	return $order_str;
}
function build_keyword_where_clause($search_keywords,$type)
{
  global $FREQUEST;
  for ($i=0, $n=sizeof($search_keywords); $i<$n; $i++ ) {
      switch ($search_keywords[$i]) {
        case '(':
        case ')':
        case 'and':
        case 'or':
          $where_str .= " " . $search_keywords[$i] . " ";
          break;
        default:
          $keyword = tep_db_prepare_input($search_keywords[$i]);
		   if($type=='P'){
	          $where_str .= "(pd.products_name like '%" . tep_db_input($keyword) . "%' or p.products_model like '%" . tep_db_input($keyword) . "%' or m.manufacturers_name like '%" . tep_db_input($keyword) . "%'";
    	      if (($FREQUEST->getvalue('search_in_description') == '1')) $where_str .= " or pd.products_description like '%" . tep_db_input($keyword) . "%'";
		   }elseif($type=='E'){
	          $where_str .= "(ed.events_name like '%" . tep_db_input($keyword) . "%' ";
    	      if (($FREQUEST->getvalue('search_in_description') == '1')) $where_str .= " or ed.events_description like '%" . tep_db_input($keyword) . "%'";
		   }elseif($type=='S'){
	          $where_str .= "(sd.subscription_name like '%" . tep_db_input($keyword) . "%' ";
    	      if ( ($FREQUEST->getvalue('search_in_description') == '1')) $where_str .= " or sd.subscription_description like '%" . tep_db_input($keyword) . "%'";
		   }elseif($type=='V'){
		  		$where_str .= "(sd.service_name like '%" . tep_db_input($keyword) . "%' ";
    	      if ( ($FREQUEST->getvalue('search_in_description') == '1')) $where_str .= " or sd.service_description like '%" . tep_db_input($keyword) . "%'"; 
		   }
           $where_str .= ')';
          break;
      }
	
    }
	return $where_str;

  }
 ?>