<?php
include('config.php');

$q 		= strtolower($_GET["q"]);
$zona 	= $_REQUEST['zona'];
if (!$q) return;

$sqlprod = "SELECT * FROM mst_product where (pm_name LIKE '%$q%' or pm_code LIKE '%$q%') LIMIT 0,25";
$prod_conn = $conn->query($sqlprod);
while($prod = $prod_conn->fetch_assoc()){
	
		$name 				= ($prod['pm_name']." - ".$prod['pm_code']);
		$product_id 		= ($prod['pm_autoid']);
		$product_name 		= ($prod['pm_name']);
		$avg_price			= ($prod['pm_avg_price']);
		
		$pm_convert			= $prod['pm_ums_convert'];
		if(!$pm_convert){$pm_convert = 1;}
		
		$avg_price = $avg_price / $pm_convert;
		
		$avg_price = toDecimal($avg_price);
		
		$stok = get_stok_info($product_id,0,$conn);
		
		echo "$name|$product_id|$product_name|$avg_price|$stok \n";
}
?>