if(!isset($c_id) || !is_numeric($c_id) || (false === ($cat_data = $db->selectObject( "select c.* ". "from {$tblPref}Category c ". "inner join {$tblPref}SubCategory sb ". "using (Cat_ID) ". "inner join {$tblPref}Tours t ". "using (SubCat_ID) ". "where c.Cat_ID =".$c_id." ". "group by c.Cat_ID ". "having count(t.Tour_ID) > 1 " , __CFG_MOST_FREQUENT_CACHE_LIFETIME )))) { Object::raiseError("Invalid request parameters", __FILE__, __LINE__, E_USER_WARNING); $sid->assign("error", "strErrorInvalidRequestParameters"); Http::localRedirect("error"); } $tpl->assign("Cat_ID", $c_id); $tpl->assign("notice", $sid->assigned("notice") ? $sid->fetch("notice") : array()); if($sid->assigned("notice")) $sid->unassign("notice"); $cat_types = $db->selectObjects( "select * from {$tblPref}SubCategory ". "where Cat_ID =".$cat_data->Cat_ID." order by ToolbarPosition asc", "SubCat_ID", __CFG_MOST_FREQUENT_CACHE_LIFETIME ); if ($c_id == 7) { foreach($cat_types as $c_types_id => $c_data) { $cat_types[$c_types_id]->Photo = $db->selectValue("SELECT Img FROM {$tblPref}FlyDrivesImg WHERE SubCat_ID = ".$c_types_id, __CFG_MOST_FREQUENT_CACHE_LIFETIME); } } $c_types = $cat_types; $c_types2 = array(); foreach($c_types as $c_types_id => $c_data) { if ($c_id == 7) { $c_types2[$c_types_id]->Photo = $c_data->Photo; } $c_types2[$c_types_id]->Tours = $db->selectObjects( "select t.*, min(p.Single) as Price ". "from {$tblPref}Tours t ". "inner join {$tblPref}SubCategory sb ". "using (SubCat_ID) ". "inner join {$tblPref}Category c ". "on (sb.Cat_ID = c.Cat_ID) ". "left outer join {$tblPref}ToursPrices p ". "on (t.Tour_ID = p.Tour_ID) ". "where t.SubCat_ID =".$c_data->SubCat_ID." ". "and t.Activated > 0 ". "group by t.Tour_ID", "Tour_ID", __CFG_MOST_FREQUENT_CACHE_LIFETIME); if ($c_types2[$c_types_id]->Tours !== false) { foreach ($c_types2[$c_types_id]->Tours as $tid=>$t) { $year = date('y'); $valid_date = $year.'-04-01'; $query = "SELECT Single FROM {$tblPref}ToursPrices WHERE Tour_ID = ".$tid." AND ValidFrom >= '".$valid_date."' ORDER BY ValidFrom LIMIT 1"; $price = $db->selectObject($query, __CFG_MOST_FREQUENT_CACHE_LIFETIME); if ($price !== false) { $c_types2[$c_types_id]->Tours[$tid]->Price = $price->Single; } } } foreach ($c_types2[$c_types_id]->Tours as $t_index=>$t_data) { $picID = $db->selectObject( "SELECT PicInfo_ID ". "FROM {$tblPref}ToursPicInfo ". "WHERE Tour_ID = ".$t_index." AND ". "PicNum = ".$t_data->PrimaryPic, __CFG_MOST_FREQUENT_CACHE_LIFETIME); if ($picID === false) { $pic_ID = 0; } else { $pic_ID = $picID->PicInfo_ID; } $c_types2[$c_types_id]->Tours[$t_index]->PicID = $pic_ID; } } $tpl->assign('c_types2', $c_types2); $tpl->assign("cat_types", $cat_types); $tpl->assign("category", $cat_data); ?> AmeTours.com Self Drives

EN |  RU