<?php
include("../connect.php"); 
$response = array();
if(isset($_POST['transaction_id']) && isset($_POST['policy_no']) && isset($_POST['manager_id']))
{
	$ver = $_POST['manager_id'];
	$policy_no=$_POST['policy_no'];
	$unique_id=$_POST['unique_id'];
	$transaction_id=$_POST['transaction_id'];
	$status=$_POST['status'];
	$reason=$_POST['reason'];
	date_default_timezone_set('Asia/Calcutta');
	$cdate  = date("Y-m-d");
	$ctime=date('h:i:sa');
	$res_product_stock = mysqli_query($con,"SELECT transaction_id FROM  tbl_customer_premium where manager_id='$ver' and policy_no='$policy_no' and status='Pending' and transaction_id='$transaction_id'");

	if(mysqli_num_rows($res_product_stock)>0)
	{	
		$uq2=mysqli_query($con,"update tbl_customer_premium set status='$status',complete_date='$cdate',complete_time='$ctime' where transaction_id='$transaction_id'"); 
		
		$uq4=mysqli_query($con,"update tbl_policy_master set rejection_reason='$reason' where unique_id='$unique_id' and status ='Pending'"); 
		
		$uq3=mysqli_query($con,"update tbl_policy_master set status='Expired',update_datetime='$cdate' where unique_id='$unique_id' and status in('Renewal Pending','Pending')"); 
	


		$response['success']='1';
		$response['details']="Insert Successful";			
	}
	else
	{
		$response['success']='0';
		$response['details']="Policy No Not exists";
	}
}
else
{
	$response['success']='0';
	$response['details']="Required field missing";
}	
echo json_encode($response);
?>