<?php
$conn=mysqli_connect("localhost","primarysales","S5L7lF01EQZvQrGK","primarysales_diana");
if(isset($_POST["save"])){
$pay=$_POST["paydates"];
$zones=$_POST["zones"];
$dlvdate=$_POST["dlvdates"];
$agenttypes=$_POST["agtype"];
$subrgn=$_POST["subrgn"];
$terrys=$_POST["terriname"];
$invdate=$_POST["invdate"];
$executivenames=$_POST["exname"];
$rsmnames=$_POST["rsmname"];
$regions=$_POST["region"];
$chqnum=$_POST["chqnum"];
$chqsts=$_POST["chqsts"];
$invoice=$_POST["invnumberr"];
$zoneorders=$_POST["zoneorder"];
$agnt=$_POST["agentname"];
$chqamount=$_POST["chqamount"];
$chqbnkdetail=$_POST["chqbank"];
$chqbnkdate=$_POST["depsitdt"];
$chqcharges=$_POST["rtnchqcharges"];

if($chqsts=='Cheque-Rtn'){
$resultin = mysqli_query($conn,"insert into st_paymode (dates,invoice_number,	pay_types,zone_orders,zones,regions,sub_regions,agent_types,agent_names,territory_names,rsm_names,executive_names,cheq_amount,bank_name,chq_number,payrcv_date,deposit_date,coment_area,dlv_dates,tot_amounts,chq_pass,setl_types,chq_rtn_num) values ('".$chqbnkdate."','".$invoice."','Cheque-Rtn','".$zoneorders."','".$zones."','".$regions."','".$subrgn."','".$agenttypes."','".$agnt."','".$terrys."','".$rsmnames."','".$executivenames."','".$chqamount."','".$chqbnkdetail."','".$chqnum."','".$pay."','".$chqbnkdate."','Cheque-Rtn:".$chqnum."','".$dlvdate."','".$chqamount."','".$chqsts."','Rtn','".$chqnum."')");
}
if($chqsts=='Cheque-Rtn' && $chqcharges>'0'){
$resultin = mysqli_query($conn,"insert into st_paymode (dates,invoice_number,	pay_types,zone_orders,zones,regions,sub_regions,agent_types,agent_names,territory_names,rsm_names,executive_names,chq_number,deposit_date,coment_area,tot_amounts,setl_types,chq_rtn_num,charges_amount) values ('".$chqbnkdate."','".$invoice."','Charges-Rtnchq','".$zoneorders."','".$zones."','".$regions."','".$subrgn."','".$agenttypes."','".$agnt."','".$terrys."','".$rsmnames."','".$executivenames."','".$chqnum."','".$chqbnkdate."','Charge-Rtnchq:".$chqnum."','".$chqcharges."','Rtn','".$chqnum."','".$chqcharges."')");
}
if($chqsts=='Cheque-Rtn' || $chqcharges>'0'){
$qq=mysqli_query ($conn,"update st_paymode set chq_pass='Return' where chq_number='".$chqnum."' and agent_names='".$agnt."' and invoice_number='".$invoice."'");
}
if($chqsts=='Realized'){
$qq=mysqli_query ($conn,"update st_paymode set chq_pass='Realized' where chq_number='".$chqnum."' and agent_names='".$agnt."' and invoice_number='".$invoice."'");
}
header("Location: chqrealize.php");
}
?>



	


