<?php
session_start(); 
ob_start();
include("../../pidbco/pidbjoin.php");

if(!isset($_SESSION['jay_proj_mngmnt']) && empty($_SESSION['jay_proj_mngmnt']))
{
    echo '<script type="text/javascript">alert("You Want To Login Now.."); window.location.href="../Login";</script>';
}


/*------------------- Add New Customer -----------  */

$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
    $custreg = $request->custreg;
	if($custreg != ''){
		
    $ccompany = $request->ccompany;
    $ccontact = $request->ccontact;
    $cmob = $request->cmob;
	$cemail = $request->cemail;
	$ccountry = $request->ccountry;
	$cstate = $request->cstate;
	$cdistrict = $request->cdistrict;
	$cststaus = $request->cststaus;
	$dat = date('Y-m-d');
	
	$sq = mysqli_query($con,"SELECT MAX(`cid`) AS mxidntty FROM `p_customers` ");
    $row = mysqli_fetch_assoc($sq);
    $cust_no = $row['mxidntty']+1;
	
		
	$custinsert = mysqli_query($con, "INSERT INTO `p_customers` (`cidentity` ,`cname` ,`ccontact` ,`cmob` ,`cemail` ,`ccountry` ,`cstate` ,
`cdistrict` ,`cstatus` ,`cdate`)
VALUES ('$cust_no', '$ccompany', '$ccontact', '$cmob', '$cemail', '$ccountry', '$cstate', '$cdistrict', '$cststaus', '$dat')");

}




$output = array();  
 $sq2 = mysqli_query($con,"SELECT id,country_name FROM `countries` ");  
 while($row = mysqli_fetch_array($sq2))  
 {  
      $output[] = $row;  
 }  
 echo json_encode($output); 
?>

