<?php  

  session_start();
   error_reporting(0);
		include("../db.php");
		include("../all_query.php");
		

 if(isset($_SESSION['loan_crm_username']) && isset($_SESSION['loan_crm_password']))
{
	
	
		   $phone = $_REQUEST['phone'];
		   $phone_label = $_REQUEST['phone_label'];
		   $account_holder_id = $_REQUEST['account_holder_id'];
	   
	   $customerQ = mysqli_query($conn,"select *from `customer` where account_holder_id = '$account_holder_id' ");
	   $customerData = mysqli_fetch_assoc($customerQ);
	   
	   
			$phone_cibil = $customerData['phone_cibil'];
		   $phoneArray = explode(' || ',$phone_cibil);
		   
		   $phoneArray[] = $phone;
		   
		   $phone_cibil = implode(' || ',$phoneArray);
		   
		   
		   $extra_phone_json = $customerData['extra_phone_json'];
		   
		   $extra_phone_jsonArray = array();
		   if($extra_phone_json!='')
		   {
			   $extra_phone_jsonArray = json_decode($extra_phone_json,TRUE);
		   }
		   
		   $phonelabelArray = array();
		   $phonelabelArray['label'] = $phone_label;
		   $phonelabelArray['phone'] = $phone;
		   
		   $extra_phone_jsonArray[] = $phonelabelArray;
		   
		   $extra_phone_json = json_encode($extra_phone_jsonArray);
		   
		   
		   
		   
		   
		   
		   
		   
		   mysqli_query($conn,"update customer set phone_cibil = '$phone_cibil' , extra_phone_json = '$extra_phone_json'  where account_holder_id = '$account_holder_id'  ");
		   
		   
	   
	
	
	    echo "Phone Added Successfully";
	
	
	
}


?>