<?php
include("../connect.php"); 
$response = array();
if(isset($_POST['policy_name']) && isset($_POST['policy_id']) && isset($_POST['admin_id']))
{
	$ver = $_POST['admin_id'];
	$policy_id = $_POST['policy_id'];
	$c_name=$_POST['policy_name'];
	date_default_timezone_set('Asia/Calcutta');
	$cdate  = date("Y-m-d")." ".date('h:i:sa');
	$res_product_stock = mysqli_query($con,"SELECT policy_name FROM  tbl_policy_type where policy_name='$c_name' and admin_id='$ver'");
	if(mysqli_num_rows($res_product_stock)<=0)
	{	
		$res_customer = mysqli_query($con,"SELECT * FROM  tbl_policy_type where policy_id='$policy_id'");
		while($fetch_detail=mysqli_fetch_assoc($res_customer))
		{
			// $query = mysqli_query($con,"INSERT INTO `tbl_insurance_company_history`(`vehicle_id`, `admin_id`, `status`, `company_name`, `insert_datetime`, `update_by`) VALUES ('$vehicle_id','$ver','".$fetch_detail['status']."','".$fetch_detail['company_name']."','$cdate','$manager_id')");	
			
			$uq2=mysqli_query($con,"update tbl_policy_type set policy_name='$c_name',update_datetime='$cdate' where policy_id='$policy_id'"); 
		
			$response['success']='1';
			$response['details']="Update Successful";
		}			
	}
	else
	{
		$response['success']='0';
		$response['details']="Policy Category already exists";
	}
}
else
{
	$response['success']='0';
	$response['details']="Required field missing";
}	
echo json_encode($response);
?>