<?php
include("../connect.php"); 
$response = array();
if(isset($_POST['manager_id']) && isset($_POST['manager_name']) && isset($_POST['manager_phone']) && isset($_POST['manager_email']) && isset($_POST['address']))
{
	$ver = $_POST['manager_id'];
	$manager_name=$_POST['manager_name'];
	$manager_phone=$_POST['manager_phone'];
	$manager_email=$_POST['manager_email'];
	$address=$_POST['address'];
	date_default_timezone_set('Asia/Calcutta');
	$cdate11  = date("Y-m-d")." ".date("H:i:s");
	$rs1=mysqli_query($con,"select * from tbl_manager where manager_id!='$ver' and manager_phone='$manager_phone'");
	if(mysqli_num_rows($rs1)<=0)
	{
		$rs11=mysqli_query($con,"select * from tbl_manager where manager_id='$ver'");
		while($fetch_dis_check=mysqli_fetch_assoc($rs11))
		{
			$pname1=$fetch_dis_check['manager_name'];
			$distri_email1=$fetch_dis_check['manager_email'];
			$dist_address=$fetch_dis_check['address'];
			$dis_phone=$fetch_dis_check['manager_phone'];
			$managetype=$fetch_dis_check['manage_type'];
			$adminid=$fetch_dis_check['admin_id'];
			$query = mysqli_query($con,"INSERT INTO `tbl_manager_history`(`manager_id`, `admin_id`, `manager_name`, `manager_phone`, `manager_email`, `address`, `manage_type`, `insert_datetime`, `remark`, `update_by`) VALUES ('$ver','$adminid','$pname1','$dis_phone','$distri_email1','$dist_address','$managetype','$cdate11','Profile Updation','$ver')");
			$uq2=mysqli_query($con,"update tbl_manager set manager_name='$manager_name',manager_phone='$manager_phone',manager_email='$manager_email',address='$address',update_datetime='$cdate11' where manager_id='$ver'"); 
			$response['success']='1';
			$response['details']="Profile Detail Successfully Updated";
		}
	}
	else
	{
		$response['success']='0';
		$response['details']="Number is not valid";
	}
}
else
{
	$response['success']='0';
	$response['details']="Required field missing";
}	
echo json_encode($response);

?>