$tpl = new TemplatePower("template/search.htm");
$tpl->prepare();
$config_path = "http://".$CONFIG["http_host"].$CONFIG["dir_path"];
$tpl->assignGlobal("config_path",$config_path);
$txtsearch = $_REQUEST['txtsearch'];
$catpd = intval($_REQUEST['catpd']);
$id_catpj = intval($_REQUEST['id_catpj']);
$price = $_REQUEST['price'];
$link = $config_path."/tim-kiem.html/txt-$txtsearch";
$dksearch = "p.active = 1";
if($txtsearch){
if($txtsearch != "Nhập tên sản phẩm..." && $txtsearch != "Nhập tên sản phẩm"){
$dksearch .= " AND (p.name LIKE '%".$txtsearch."%'";
$dksearch .= " OR p.gioi_thieu LIKE '%".$txtsearch."%'";
$dksearch .= " OR p.noi_dung LIKE '%".$txtsearch."%')";
}
}
if($catpd){
$dksearch .=" AND p.id_catpd =$catpd";
}
if($id_catpj){
$dksearch .=" AND p.id_project =$id_catpj";
}
if($price){
if($price==1) $dksearch .=" AND p.price <= 500000";
elseif($price == 2) $dksearch .=" AND p.price > 500000 AND p.price<=1000000";
elseif($price == 3) $dksearch .=" AND p.price > 1000000 AND p.price<=2000000";
elseif($price == 4) $dksearch .=" AND p.price > 2000000 AND p.price<=3000000";
elseif($price == 5) $dksearch .=" AND p.price > 3000000 AND p.price<=4000000";
else $dksearch .=" AND p.price > 20000000";
}
//tieu de
$tpl->assign("name_cat",_tim_kiem);
$sql = "SELECT p.*, mau.image AS img_mau FROM product AS p"
." LEFT JOIN loaibds AS mau ON p.id_bds = mau.id"
." WHERE ".$dksearch." ORDER BY p.thu_tu ASC,p.id_product DESC";
$count = mysql_num_rows($DB->query($sql));
//$link="?act=search&txtsearch=".$txtsearch."&price=".$price;
$maxp=10;
include('lib/pagination-seo.php');
if($kgPagerOBJ -> total_pages > 1){
$tpl->newBlock("phan_trang");
$tpl->assign("cac_trang", $str);
}
if(!$count){
$tpl->newBlock("notnews");
$tpl->assign("text","Không có sản phẩm");
}
else{
$tpl->newBlock("lists");
while($r=mysql_fetch_array($rs_list)){
$tpl->newBlock("row-list");
if($r['xuat_xu'])
$tpl->assign("xuat_xu",$r['xuat_xu']);
else
$tpl->assign("xuat_xu","Lắp ráp trong nước");
$tpl->assign("link","?act=productdetail&pid=".$r['id_catpd']."&id=".$r['id_product']."");
$namecat = hangsx($r['id_catpd']);
$tpl->assign("hangsx",$namecat['name']);
$tpl->assign("dong_xe",$r['dong_xe']);
$img = '';
if($r['image']){
$imgs = explode(", ", $r['image']);
$link = $config_path."/productdetail-00/".remove_marks($r['name'])."-".$r['id_catpd']."-".$r['id_product'].".html";
// $tpl->assign("link","?act=productdetail&pid=".$_r['id_catpd']."&id=".$_r['id_product']."");
$img = "
";
}
elseif($r['img_mau']){
$imgs = explode(", ", $r['img_mau']);
$link=$config_path."/productdetail-00/".remove_marks($r['name'])."-".$r['id_catpd']."-".$r['id_product'].".html";
// $tpl->assign("link","?act=productdetail&pid=".$_r['id_catpd']."&id=".$_r['id_product']."");
$img = "
";
}
$tpl->assign("image",$img);
$tpl->assign("mau",$r['mau']);
$tpl->assign("link",$link);
$tpl->assign("price",format_price($r['price']).' vnđ');
}
}
function hangsx($id,&$r=array()){
global $DB;
$sql="SELECT id_catpd,name,parentid FROM catpd WHERE id_catpd = ".$id;
$rs = $DB->query($sql);
$r = $DB->fetch_row($rs);
if ($r['parentid'] != 0){
hangsx($r['parentid'],$r);
}
return $r;
}
$tpl->printToScreen();
?>