<?php
include("DB.php");
$bdd = new DB();
if($_POST['type']=="viewCustomerDetail"){
	$chassisNo=substr($_POST['chassisNo'],-5);
	$row = $bdd->getOne("SELECT name,contact_no,AllotmentNo FROM `customer` WHERE RIGHT(chassis_no,5) ='$chassisNo'");
	$response = array();

	if(!empty($row)){
		echo "<b>Name : </b>".$row['name'];
		echo "<br><b>Contact No : </b>".$row['contact_no'];
		echo "<br><b>Allotment No : </b>".$row['AllotmentNo'];
		/*$response['customer']=$row;
		$response['response'] = "success";
		$response['message'] = "Found.";*/
	}else{
		echo "No customer No found";
		/*$response['response'] = "fail.";
		$response['message'] = "No customer No found";*/
	}
	//echo json_encode($response);
}

if($_POST['type']=="revertSelectStatus"){
	$chassisNo=substr($_POST['ChassisNo'],-8);
	$crow=$bdd->getOne("SELECT customer_id FROM customer WHERE chassis_no='$chassisNo'");
	$bdd->execute("UPDATE customer SET status = 'Allotment' WHERE customer_id=".$crow['customer_id']);
}
$bdd->disconnect();