<?php session_start();
include ('../inc/dbcon.php');
include ('../inc/functions.php');
include ('../inc/repfunctions.php');
if(isset($_SESSION["axeslogin"]) && $_SESSION["axeslogin"] == true){    
$aid=$_SESSION['uid'];
$brid=$_SESSION['abrid'];    
}else{
header('Location:../index.php');
exit;    
}

$output=''; 

if(isset($_POST['catid'])){
$catid=intval($_POST['catid']);
if($catid>0){
$sql = "SELECT * FROM tbl_item WHERE catid='$catid' AND status='1' ORDER BY name ASC";    
}else{
$sql = "SELECT * FROM tbl_item WHERE status='1' ORDER BY name ASC";    
}        
}elseif(isset($_POST['subcatid'])){
$scatid=intval($_POST['subcatid']);
$sql = "SELECT * FROM tbl_item WHERE scatid='$scatid' AND status='1' ORDER BY name ASC";     
}elseif(isset($_POST['brandid'])){    
$brid=intval($_POST['brandid']);
if($brid>0){
$sql = "SELECT * FROM tbl_item WHERE brid='$brid' AND status='1' ORDER BY name ASC";     
}else{
$sql = "SELECT * FROM tbl_item WHERE status='1' ORDER BY name ASC";    
}    
}else{
$sql = "SELECT * FROM tbl_item WHERE status='1' ORDER BY name ASC";
}
$result = mysqli_query($con, $sql);
while ($row=mysqli_fetch_array($result)){

$output.='<div class="product-content product-select puritem" id="AX_'.$row['id'].'" title="'.$row['name'].'"><img src="../img/product/';
if(empty($row['image'])){$output.='no_image.png';}else{$output.=$row['image'];} 
$output.='" class="product-image"><div class="info"><h3>'.get_proval($row['id'],'P').'</h3><p>Welcome</p></div><div class="product-detail"><b class="name">'.$row['name'].'</b></div><div class="product-code"><b class="sku">'.$row['code'].'</b><b class="indexg" style="display:none;">'.strtoupper(substr($row['name'],0,1)).'</b></div></div>';	
}   
echo $output;
exit;