<?php
ob_start();
include("../connect.php");
$response = array();
if(isset($_POST['customer_id']) && isset($_POST['distributor_id']) && isset($_POST['status']))
{  
   $c_id=$_POST['customer_id'];
   $d_id=$_POST['distributor_id'];
   $status=$_POST['status'];
   
   $res=mysqli_query($con,"Select * from tbl_master_customer where customer_id='$c_id'");
   $row=mysqli_fetch_assoc($res);
   if(mysqli_num_rows($res)>0)
   {
	 if($status=='Active')
	 {
	  $update_status = mysqli_query($con,"update tbl_master_customer set status='Deactive' where customer_id='$c_id'");
	 }
	 else
	 {
	  $update_status = mysqli_query($con,"update tbl_master_customer set status='Active' where customer_id='$c_id'");	
	 }
	
	 if($update_status)
	 {
	   $response['success']=1;	
	   $response['details']="Customer Status Successfully updated";
	 }
	 else
	 {
	  $response['success']=0;	
	  $response['details']="Customer Status Not updated"; 	
	 }
	}
   else
   {
	 $response['success']=0;	
	 $response['details']="Data Fail"; 
   }	   
}	
else
{	
	$response['success']=0;
	$response['details']="Required fields missing";
}
echo json_encode($response);
?>
