<?php require_once('../auth/auth.php');
if (isset($_GET["term"])) {
$term = trim($_GET["term"]);
$pro_r= mysqli_query($conn,"SELECT item.pro_id,item.item_name,item.item_details,item.item_code,item.item_qty,pro_unit.unit_convart,pro_unit.unit_symble,item_brand.pbrand_name 
FROM item
LEFT JOIN pro_unit ON (item.pro_unit=pro_unit.puid)
LEFT JOIN item_brand ON (item.pbid=item_brand.pbid)

WHERE item.coid='$coid' AND item.bid='$bid' AND item.brid='$brid' AND (item.item_name LIKE '%$term%' || item.item_details LIKE '%$term%' || item.item_code LIKE '%$term%') AND item.pro_type='P' AND item.active=1 ORDER BY item.pro_id ASC LIMIT 10") or die (mysqli_error($conn));
$items = [];
while ($rowp= mysqli_fetch_assoc($pro_r)) {
$items[]= ['value'=>$rowp['pro_id'] , 'label'=>$rowp['pbrand_name']."  ".$rowp['item_name']." ".$rowp['item_details'].", ".$rowp['item_code']." - ".number_format($rowp['item_qty'],$item_decimel)." Pcs"];
}
echo json_encode( $items );
}
?>