<?php
include("../connect.php"); 
$response = array();
if(isset($_POST['vehicle_type']) && isset($_POST['admin_id']) && isset($_POST['vehicle_id']))
{
	$ver = $_POST['admin_id'];
	$vehicle_id = $_POST['vehicle_id'];
	$c_name=$_POST['vehicle_type'];
	date_default_timezone_set('Asia/Calcutta');
	$cdate  = date("Y-m-d")." ".date('h:i:sa');
	$res_product_stock = mysqli_query($con,"SELECT vehicle_type FROM  tbl_vehicle_master where vehicle_type='$c_name' and admin_id='$ver'");
	if(mysqli_num_rows($res_product_stock)<=0)
	{	
		$res_customer = mysqli_query($con,"SELECT * FROM  tbl_vehicle_master where vehicle_id='$vehicle_id'");
		while($fetch_detail=mysqli_fetch_assoc($res_customer))
		{
			
			$uq2=mysqli_query($con,"update tbl_vehicle_master set vehicle_type='$c_name',update_datetime='$cdate' where vehicle_id='$vehicle_id'"); 
		
			$response['success']='1';
			$response['details']="Update Successful";
		}			
	}
	else
	{
		$response['success']='0';
		$response['details']="Vehicle already exists";
	}
}
else
{
	$response['success']='0';
	$response['details']="Required field missing";
}	
echo json_encode($response);
?>