<?php 
include_once('DB.php');
require_once 'web_constant.php';
if($_POST['action']=='searchChassiNo'){
	if(isset($_POST['search']))
	{
		$search = $_POST['search'];
		
		/*//$sql = "SELECT customer_id,name FROM customer WHERE name like '$search%'";
		$sql="SELECT customer_id,name,contact_no FROM customer WHERE name like '$search%' UNION SELECT customer_id,name,contact_no as name FROM customer WHERE contact_no like '$search%'";

		$bdd=new DB();
		$rows=$bdd->getAll($sql);
		$bdd->disconnect();
		foreach ($rows as $row) {
			$response[] = array("label"=>$row['name']."-".$row['contact_no'],"id"=>$row['customer_id']);	
		}*/
		$url= web_constant::$ip_ticl."api.php";
		//echo $url;
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL,$url);
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query(array('type' => 'getChassisNo','ChassisNo'=>$_POST['search'])));
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		$output = curl_exec($ch);
		curl_close($ch);
		$chassisJson=json_decode($output);
		foreach($chassisJson->result as $row){
		//for($cnt=0;sizeof($chassisJson->result);$cnt++){
			//echo "<option value='$row'>$row</option>";
			$response[] = array("label"=>$row,"id"=>$row);
		}
		
		echo json_encode($response);
	}
}

exit;
?>
