<?php
require "racs.php";
require "vtshowsBBB.php";
session_start();
if(!isset($_SESSION['titles']) || !isset($_SESSION['positions'])|| !isset($_SESSION['usernames'])){
header("location:index.php");
}
?>

<html>
<title>DB-Paymode</title>
<head>
<style type="text/css">
.form-style-9{
	max-width: 450px;
	background: #FAFAFA;
	padding: 30px;
	margin: 50px auto;
	box-shadow: 1px 1px 25px rgba(0, 0, 0, 0.35);
	border-radius: 10px;
	border: 6px solid #305A72;
}
.form-style-9 ul{
	padding:0;
	margin:0;
	list-style:none;
}
.form-style-9 ul li{
	display: block;
	margin-bottom: 10px;
	min-height: 35px;
}
.form-style-9 ul li  .field-style{
	box-sizing: border-box; 
	-webkit-box-sizing: border-box;
	-moz-box-sizing: border-box; 
	padding: 8px;
	outline: none;
	border: 1px solid #B0CFE0;
	-webkit-transition: all 0.30s ease-in-out;
	-moz-transition: all 0.30s ease-in-out;
	-ms-transition: all 0.30s ease-in-out;
	-o-transition: all 0.30s ease-in-out;

}.form-style-9 ul li  .field-style:focus{
	box-shadow: 0 0 5px #B0CFE0;
	border:1px solid #B0CFE0;

}
.form-style-9 ul li .field-split{
	width: 49%;
}
.form-style-9 ul li .field-full{
	width: 100%;
}
.form-style-9 ul li input.align-left{
	float:left;
}
.form-style-9 ul li input.align-right{
	float:right;
}
.form-style-9 ul li textarea{
	width: 100%;
	height: 100px;
}
.form-style-9 ul li input[type="button"], 
.form-style-9 ul li input[type="submit"] {
	-moz-box-shadow: inset 0px 1px 0px 0px #3985B1;
	-webkit-box-shadow: inset 0px 1px 0px 0px #3985B1;
	box-shadow: inset 0px 1px 0px 0px #3985B1;
	background-color: #216288;
	border: 1px solid #17445E;
	display: inline-block;
	cursor: pointer;
	color: #FFFFFF;
	padding: 8px 18px;
	text-decoration: none;
	font: 12px Arial, Helvetica, sans-serif;
}
.form-style-9 ul li input[type="button"]:hover, 
.form-style-9 ul li input[type="submit"]:hover {
	background: linear-gradient(to bottom, #2D77A2 5%, #337DA8 100%);
	background-color: #28739E;
}
</style>    
<link rel="stylesheet" type="text/css" media="all" href="jsDatePick_ltr.min.css" />
<link rel="stylesheet" type="text/css" media="all" href="jsDatePick_ltr.css" />
<script type="text/javascript" src="jsDatePick.min.1.3.js"></script>
<script src="datesps.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

<link rel="stylesheet" type="text/css" href="vtxstyles.css">
</head>
<body style='font-family:calibri;font-size:small;'>
<div style='width=30%;height:100%%;'>

<?php
$flt=racs(1);

if($flt=="access failed"){
printf("<div style='font-color:red;'>>Access failed\nContact Sales and Marketing division</div>");
}
else{
$conn=mysqli_connect("localhost","primarysales","S5L7lF01EQZvQrGK","primarysales_diana");

if(isset($_REQUEST['starts'])){
$starts=$_REQUEST['starts'];}
else{
$starts=date('Y-m-01');}

if(isset($_REQUEST['ends'])){
$ends=$_REQUEST['ends'];}
else{
$ends=date('Y-m-t');}

if(isset($_REQUEST['zones'])){
$zones=$_REQUEST['zones'];}
else{
$zones='all';}

if(isset($_REQUEST['regions'])){
$regions=$_REQUEST['regions'];}
else{
$regions='all';}

if(isset($_REQUEST['agents'])){
$agents=$_REQUEST['agents'];}
else{
$agents='all';}

if(isset($_REQUEST['terrys'])){
$terrys=$_REQUEST['terrys'];}
else{
$terrys='all';}

if(isset($_REQUEST['subregions'])){
$subregions=$_REQUEST['subregions'];}
else{
$subregions='all';}

if(isset($_REQUEST['agenttypes'])){
$agenttypes=$_REQUEST['agenttypes'];}
else{
$agenttypes='all';}

if(isset($_REQUEST['chqnum'])){
$chqnum=$_REQUEST['chqnum'];}
else{
$chqnum='all';}

if(isset($_REQUEST['ranges'])){
$ranges=$_REQUEST['ranges'];}
else{
$ranges='all';}

if(isset($_REQUEST['subranges'])){
$subranges=$_REQUEST['subranges'];}
else{
$subranges='all';}

if(isset($_REQUEST['invnum'])){
$invnum=$_REQUEST['invnum'];}
else{
$invnum='all';}

if(isset($_REQUEST['chqdt'])){
$chqdt=$_REQUEST['chqdt'];}
else{
$chqdt='all';}

if(isset($_REQUEST['dlvdates'])){
$dlvd=$_REQUEST['dlvdates'];}
else{
$dlvd='all';}

if(isset($_REQUEST['claims'])){
$claims=$_REQUEST['claims'];}
else{
$claims='all';}

if(isset($_REQUEST['charges'])){
$charges=$_REQUEST['charges'];}
else{
$charges='all';}

if(isset($_REQUEST['srtnvl'])){
$srtnvl=$_REQUEST['srtnvl'];}
else{
$srtnvl='all';}

if(isset($_REQUEST['undnvl'])){
$undnvl=$_REQUEST['undnvl'];}
else{
$undnvl='all';}

if(isset($_REQUEST['mrtnvl'])){
$mrtnvl=$_REQUEST['mrtnvl'];}
else{
$mrtnvl='all';}

if(isset($_REQUEST['duamt'])){
$duamt=$_REQUEST['duamt'];}
else{
$duamt='all';}

if(isset($_REQUEST['cldate'])){
$cldate=$_REQUEST['cldate'];}
else{
$cldate='all';    
}

if(isset($_REQUEST['chqamount'])){
$chqamount=$_REQUEST['chqamount'];}
else{
$chqamount='all';    
}

if(isset($_REQUEST['clinter'])){
$clinter=$_REQUEST['clinter'];}
else{
$clinter='all';    
}

if($clinter==''){
$clinter='0';    
}

if(isset($_REQUEST['fisue'])){
$fisue=$_REQUEST['fisue'];}
else{
$fisue='all';    
}

if($fisue==''){
$fisue='0';    
}

if(isset($_REQUEST['salwage'])){
$salwage=$_REQUEST['salwage'];}
else{
$salwage='all';    
}

if($salwage==''){
$salwage='0';    
}

if($chqamount==''){
$chqamount='0';    
}

if($charges==''){
$charges='0';    
}

if($claims==''){
$claims='0';    
}

if($srtnvl==''){
$srtnvl='0';    
}

if($mrtnvl==''){
$mrtnvl='0';    
}

if($undnvl==''){
$undnvl='0';    
}

if($duamt=='0'){
$duamt='0';    
}


#$flt=racs(1);

if(strtolower($zones)!='all'){
$flt=$flt." and zones='".$zones."' ";}
if(strtolower($regions)!='all'){
$flt=$flt." and regions='".$regions."' ";}
if(strtolower($subregions)!='all'){
$flt=$flt." and sub_regions='".$subregions."' ";}
if(strtolower($agents)!='all'){
$flt=$flt." and agent_names='".$agents."' ";}
if(strtolower($agenttypes)!='all'){
$flt=$flt." and agent_types='".$agenttypes."' ";}
if(strtolower($terrys)!='all'){
$flt=$flt." and territory_names='".$terrys."' ";}
if(strtolower($items)!='all'){
$flt=$flt." and item_names='".$items."' ";}
if(strtolower($ranges)!='all'){
$flt=$flt." and item_ranges='".$ranges."' ";}
if(strtolower($subranges)!='all'){
$flt=$flt." and sub_ranges='".$subranges."' ";}
if(strtolower($invnum)!='all'){
$flt=$flt." and invoice_number='".$invnum."' ";}
}

stps(1);
printf("<div class='sds'>");
sacnew(1);
printf("</div>");

$qq="select sum(box_qty*box_price) as invvalue,sum(dv_box_qty*box_price) as dlvvalue,sum(box_qty*box_price)*discount_rates as disrate,dlv_dates as dlvdt from rc_invoices ".$flt." ";
$qryy=mysqli_query($conn,$qq);
while($rst=mysqli_fetch_row($qryy)){
$invvalue=$rst[0]+$rst[2];
$dlvalue=$rst[1]+$rst[2];
$dlvdates=$rst[3];
}
?>

<form class="form-style-9" name="form_name" method="post" action="dbledpayup.php">
<ul>
<li>
<input type="text" name="dbname" id="dbn" class="field-style field-split align-left" disabled="true" value="<?php if(isset($agents)) echo $agents ?>" />
<input type="hidden" name="agentname" value="<?php if(isset($agents)) echo $agents ?>" />

<input type="text" name="terinames" id="terinum" class="field-style field-split align-right" disabled="true" value="<?php if(isset($terrys)) echo $terrys ?>" />
<input type="hidden" name="terriname" value="<?php if(isset($terrys)) echo $terrys ?>"/ >
</li>

<li>
<input type="text" class="field-style field-split align-left" placeholder="Monthly Claims"disabled="true"/>
<input type="text" name="addclaim" class="field-style field-split align-right" value="" id="mclaim" autocomplete="off" onkeyup="btnclm(event)" onkeydown="bncld(event)"/>
<input type="text" name="climdate" class="field-style field-split align-right" value="" id="claimdate" placeholder="Remarks - Claim" autocomplete="off" onkeyup="btnclmdet(event)" onkeydown="bncldd(event)" />
</li>
<br><br>
<li>
<input type="text" class="field-style field-split align-left" placeholder="Charges-Reverse"disabled="true"/>
<input type="text" name="addcharges" class="field-style field-split align-right" title="Charges" value="" id="otherch" onkeyup="btncharg(event)" onkeydown="bnchg(event)"/>
<input type="text" name="chargeremark" background-color: '#3CBC8D' class="field-style field-split align-right" value="" id="chrgrem" placeholder="Remarks - Charges" autocomplete="off" onkeyup="btnchgrem(event)" onkeydown="bnremchg(event)" />
</li>

<br><br>
<li>
<input type="text" class="field-style field-split align-left" placeholder="Staff Salary"disabled="true"/>
<input type="text" name="addsalary" class="field-style field-split align-right" title="Salary" value="" id="salamt" onkeyup="btnsal(event)" onkeydown="bnsal(event)"/>
<input type="text" name="salremarker" background-color: '#3CBC8D' class="field-style field-split align-right" value="" id="salrem" placeholder="Remarks - Salary" autocomplete="off" onkeyup="btnsalrem(event)" onkeydown="bnsalrem(event)" />
</li>

<br><br>
<li>
<input type="text" class="field-style field-split align-left" placeholder="Free Issue"disabled="true"/>
<input type="text" name="fissus" class="field-style field-split align-right" title="Free" value="" id="fisue" onkeyup="btnfisue(event)" onkeydown="bnfisue(event)"/>
<input type="text" name="fisueremarker" background-color: '#3CBC8D' class="field-style field-split align-right" value="" id="fisuerem" placeholder="Remarks - Free issue" autocomplete="off" onkeyup="btnfisuerem(event)" onkeydown="bnfisurem(event)" />
</li>

<br><br>
<li>
<input type="text" class="field-style field-split align-left" placeholder="Interest-Claim Hold"disabled="true"/>
<input type="text" name="clhldinterest" class="field-style field-split align-right" title="Ineterest" value="" id="interestt" onkeyup="btninst(event)" onkeydown="bnclhldinst(event)"/>
<input type="text" name="clminter" background-color: '#3CBC8D' class="field-style field-split align-right" value="" id="clminterr" placeholder="Remarks - Claim Hold" autocomplete="off" onkeyup="btnclmints(event)" onkeydown="bnclmints(event)" />
</li>

<br><br>
<li>
    
<input type="text" name="dedsrtns" class="field-style field-split align-left" placeholder="Sales Returns" disabled="true"/>
<input type="text" name="dedsrtn" class="field-style field-split align-right" title="S-Returns" value=""  id="srtnvl" onkeyup="btnsrtn(event)" onkeydown="bnsr(event)"/>
<input type="text" name="srtnremark" class="field-style field-split align-right" value="" id="srtnremk" placeholder="Remarks - Srtns" autocomplete="off" onkeyup="btnsrtnrem(event)" onkeydown="bnsrtnremks(event)" />
</li>
<br><br>

<li>
<input type="text" name="undl" class="field-style field-split align-left" placeholder="Undelivery" disabled="true"/>
<input type="text" name="undlvsr" class="field-style field-split align-right" title="Undelivery" value=""  id="undlvl" onkeyup="btnundlv(event)" onkeydown="bnunlv(event)"/>
<input type="text" name="undlvremark" class="field-style field-split align-right" value="" id="undlvremk" placeholder="Remarks - Undelivery" autocomplete="off" onkeyup="btnundlvrem(event)" onkeydown="bnsundlvremks(event)" />
</li>
<br><br>

<li>
<input type="text" class="field-style field-split align-left" placeholder="Market Returns" disabled="true"/>
<input type="text" name="dedmrtn" class="field-style field-split align-right" title="M-Returns" value="" id="mrtnvl" onkeyup="btnmrtn(event)" onkeydown="bnmr(event)"/>
<input type="text" name="mrtnremark" class="field-style field-split align-right" value="" id="mrtnremk" placeholder="Remarks - Mrtn" autocomplete="off" onkeyup="btnmrtnrem(event)" onkeydown="bnsmrtnremks(event)" />
</li>
<br><br>

<li>
<input type="text" name="cashpay" class="field-style field-split align-left" title="Cash Payment" value="0.00" id="cashpay" onkeyup="btncash(event)" onkeydown="bncash(event)"/>&nbsp&nbsp
<select name="cashbank" id="cashb" class="field-style field-split align-right" onkeydown="bncashbn(event)">
<option>CASHIER</option>    
<option>SAMPATH</option>
<option>COMMERCIAL</option>
<option>HNB</option>
<option>NTB</option>
<option>NDB</option>
<option>BOC</option>
<option>PB</option>
<option>DFCC</option>
<option>PAB</option>
<option>UBC</option>
<option>SDB</option>
<option>SEYLAN</option>
</select>   
<br>
<input type="text" name="cashbnkdate" class="field-style field-split align-right" placeholder="Deposit Date" id="inputField" onkeydown="bncashdt(event)"/>
</li>
<br><br><br>
<li>
<input type="text" name="chqpay1" class="field-style field-split align-left" title="cheque Payment" value="0.00" id="chq1pay" onkeyup="btnchqp(event)" onkeydown="bnchqp(event)"/>
<input type="text" name="chq1chqdate" class="field-style field-split align-right" placeholder="Cheque Recived Date" id="inputField2"/>
<select name="chqbank1" class="field-style field-split align-right">
<option>SAMPATH</option>
<option>COMMERCIAL</option>
<option>HNB</option>
<option>NTB</option>
<option>NDB</option>
<option>BOC</option>
<option>PB</option>
<option>DFCC</option>
<option>PAB</option>
<option>UBC</option>
<option>SDB</option>
<option>SEYLAN</option>
</select>
<input type="text" name="chqnum" class="field-style field-split align-right" placeholder="Cheque Number" id="cqnum" />
<input type="text" name="chq1bnkdate" class="field-style field-split align-right" placeholder="Realized Date" id="inputField3" />
</li>
<br><br>
<li>
<select name="paysts" class="field-style field-split align-right" required>
<option></option>    
<option>BALANCE SETLEMENT</option>
</select>
</li>
<li>
<input type="submit" name="save" id="btnac" onclick="submit_by_name()"/>    
</li>
</ul>
</form>
</div>
</div>
<?php

$srmrcl=($claims+$srtnvl+$mrtnvl+$undnvl+$charges+$salwage+$clinter+$fisue);
?>

<script>

$(function(){
       $("#datepicker").datepicker({ dateFormat: "yy-mm-dd"}).val()
       });
     

function btncash(event){
var num11 = document.getElementById('dueamount').value;
//var num111 = document.getElementById('billamount').value;
var num12 = document.getElementById('cashpay').value;
var num13 = document.getElementById('chq1pay').value;
var num14 = document.getElementById('otherch').value;
var num15 = document.getElementById('srtnvl').value;
var num16 = document.getElementById('mrtnvl').value;
var num17 = document.getElementById('mclaim').value;
var num18 = document.getElementById('undlvl').value;
var num19 = document.getElementById('salamt').value;
var num20 = document.getElementById('fisue').value;
var num21 = document.getElementById('interestt').value;
var result = parseInt(num11) - parseInt(num12) - parseInt(num13) - parseInt(num14) - parseInt(num15) - parseInt(num16) - parseInt(num17) - parseInt(num18) - parseInt(num19) - parseInt(num20) - parseInt(num21);
if (!isNaN(result)) {
document.getElementById('invdues').value = result + <?php echo number_format($srmrcl,2,'.',',') ?>;
}
}

function btninst(event){
var num11g = document.getElementById('dueamount').value;
//var num111 = document.getElementById('billamount').value;
var num12g = document.getElementById('cashpay').value;
var num13g = document.getElementById('chq1pay').value;
var num14g = document.getElementById('otherch').value;
var num15g = document.getElementById('srtnvl').value;
var num16g = document.getElementById('mrtnvl').value;
var num17g = document.getElementById('mclaim').value;
var num18g = document.getElementById('undlvl').value;
var num19g = document.getElementById('salamt').value;
var num20g = document.getElementById('fisue').value;
var num22g = document.getElementById('interestt').value;
var result = parseInt(num11g) - parseInt(num12g) - parseInt(num13g) - parseInt(num14g) - parseInt(num15g) - parseInt(num16g) - parseInt(num17g) - parseInt(num18g) - parseInt(num19g) - parseInt(num20g) - parseInt(num22g);
if (!isNaN(result)) {
document.getElementById('invdues').value = result + <?php echo number_format($srmrcl,2,'.',',') ?>;
}
}



function btnsal(event){
var num11h = document.getElementById('dueamount').value;
//var num111 = document.getElementById('billamount').value;
var num12h = document.getElementById('cashpay').value;
var num13h = document.getElementById('chq1pay').value;
var num14h = document.getElementById('otherch').value;
var num15h = document.getElementById('srtnvl').value;
var num16h = document.getElementById('mrtnvl').value;
var num17h = document.getElementById('mclaim').value;
var num18h = document.getElementById('undlvl').value;
var num20h = document.getElementById('salamt').value;
var num21h = document.getElementById('fisue').value;
var num22h = document.getElementById('interestt').value;
var result = parseInt(num11h) - parseInt(num12h) - parseInt(num13h) - parseInt(num14h) - parseInt(num15h) - parseInt(num16h) - parseInt(num17h) - parseInt(num18h) - parseInt(num20h) - parseInt(num21h) - parseInt(num22h);
if (!isNaN(result)) {
document.getElementById('invdues').value = result + <?php echo number_format($srmrcl,2,'.',',') ?>;
}
}

function btnclm(event){
var num1p = document.getElementById('dueamount').value;
//var numdf = document.getElementById('billamount').value;
var num2p = document.getElementById('cashpay').value;
var num3p = document.getElementById('chq1pay').value;
var num4p = document.getElementById('otherch').value;
var num5p = document.getElementById('srtnvl').value;
var num6p = document.getElementById('mrtnvl').value;
var num7p = document.getElementById('mclaim').value;
var num88p = document.getElementById('undlvl').value;
var num89p = document.getElementById('salamt').value;
var num90p = document.getElementById('interestt').value;
var result = parseInt(num1p) - parseInt(num2p) - parseInt(num3p) - parseInt(num4p) - parseInt(num5p) - parseInt(num6p) - parseInt(num7p) - parseInt(num88p) - parseInt(num89p) - parseInt(num90p);
if (!isNaN(result)) {
document.getElementById('invdues').value = result + <?php echo number_format($srmrcl,2,'.',',') ?>;
}
}

function btncharg(event){
var num1a = document.getElementById('dueamount').value;
//var numsdf = document.getElementById('billamount').value;
var num2b = document.getElementById('cashpay').value;
var num3c = document.getElementById('chq1pay').value;
var num4d = document.getElementById('otherch').value;
var num5e = document.getElementById('srtnvl').value;
var num6f = document.getElementById('mrtnvl').value;
var num7g = document.getElementById('mclaim').value;
var undchrg = document.getElementById('undlvl').value;
var numsalamt = document.getElementById('salamt').value;
var numsalamtu = document.getElementById('interestt').value;
var result = parseInt(num1a) - parseInt(num2b) - parseInt(num3c) - parseInt(num4d) - parseInt(num5e) - parseInt(num6f) - parseInt(num7g)  - parseInt(numsalamt) - parseInt(numsalamtu);
if (!isNaN(result)) {
document.getElementById('invdues').value = result + <?php echo number_format($srmrcl,2,'.',',') ?>;
}
}

function btnfisue(event){
var num11t = document.getElementById('dueamount').value;
//var num111 = document.getElementById('billamount').value;
var num12t = document.getElementById('cashpay').value;
var num13t = document.getElementById('chq1pay').value;
var num14t = document.getElementById('otherch').value;
var num15t = document.getElementById('srtnvl').value;
var num16t = document.getElementById('mrtnvl').value;
var num17t = document.getElementById('mclaim').value;
var num18t = document.getElementById('undlvl').value;
var num19t = document.getElementById('salamt').value;
var num20t = document.getElementById('fisue').value;
var num21t = document.getElementById('interestt').value;
var result = parseInt(num11t) - parseInt(num12t) - parseInt(num13t) - parseInt(num14t) - parseInt(num15t) - parseInt(num16t) - parseInt(num17t) - parseInt(num18t) - parseInt(num19t) - parseInt(num20t) - parseInt(num21t);
if (!isNaN(result)) {
document.getElementById('invdues').value = result + <?php echo number_format($srmrcl,2,'.',',') ?>;
}
}

function btnsrtn(event){
var num1a1 = document.getElementById('dueamount').value;
//var numhbo = document.getElementById('billamount').value;
var num2b2 = document.getElementById('cashpay').value;
var num3c3 = document.getElementById('chq1pay').value;
var num4d4 = document.getElementById('otherch').value;
var num5e5 = document.getElementById('srtnvl').value;
var num6f6 = document.getElementById('mrtnvl').value;
var num7g7 = document.getElementById('mclaim').value;
var und7sd = document.getElementById('undlvl').value;
var und8sd = document.getElementById('salamt').value;
var num20tm = document.getElementById('fisue').value;
var und9sd = document.getElementById('interestt').value;
var result = parseInt(num1a1) - parseInt(num2b2) - parseInt(num3c3) - parseInt(num4d4) - parseInt(num5e5) - parseInt(num6f6) - parseInt(num7g7) - parseInt(und7sd) - parseInt(und8sd) - parseInt(und9sd) - parseInt(num20tm);
if (!isNaN(result)) {
document.getElementById('invdues').value = result + <?php echo number_format($srmrcl,2,'.',',') ?>;
}
}

function btnundlv(event){
var ab = document.getElementById('dueamount').value;
var ab1 = document.getElementById('cashpay').value;
var ab2 = document.getElementById('chq1pay').value;
var ab3 = document.getElementById('otherch').value;
var ab4 = document.getElementById('srtnvl').value;
var ab5 = document.getElementById('mrtnvl').value;
var ab6 = document.getElementById('mclaim').value;
var ab7 = document.getElementById('undlvl').value;
var ab8 = document.getElementById('salamt').value;
var num20tmn = document.getElementById('fisue').value;
var ab9 = document.getElementById('interestt').value;
var result = parseInt(ab) - parseInt(ab1) - parseInt(ab2) - parseInt(ab3) - parseInt(ab4) - parseInt(ab5) - parseInt(ab6) - parseInt(ab7) - parseInt(ab8) - parseInt(ab9) - parseInt(num20tmn);
if (!isNaN(result)) {
document.getElementById('invdues').value = result + <?php echo number_format($srmrcl,2,'.',',') ?>;
}
}

function btnmrtn(event){
var num1a1a = document.getElementById('dueamount').value;
//var numdvc = document.getElementById('billamount').value;
var num2b2b = document.getElementById('cashpay').value;
var num3c3c = document.getElementById('chq1pay').value;
var num4d4d = document.getElementById('otherch').value;
var num5e5e = document.getElementById('srtnvl').value;
var num6f6f = document.getElementById('mrtnvl').value;
var num7g7g = document.getElementById('mclaim').value;
var undn = document.getElementById('undlvl').value;
var unsalamt = document.getElementById('salamt').value;
var num20tmnc = document.getElementById('fisue').value;
var numbg = document.getElementById('interestt').value;
var result = parseInt(num1a1a) - parseInt(num2b2b) - parseInt(num3c3c) - parseInt(num4d4d) - parseInt(num5e5e) - parseInt(num6f6f) - parseInt(num7g7g) - parseInt(undn) - parseInt(unsalamt) - parseInt(numbg) - parseInt(num20tmnc);
if (!isNaN(result)) {
document.getElementById('invdues').value = result + <?php echo number_format($srmrcl,2,'.',',') ?>;
}
}

function btnchqp(event){
var num1a1ap = document.getElementById('dueamount').value;
//var numvdo = document.getElementById('billamount').value;
var num2b2bp = document.getElementById('cashpay').value;
var num3c3cp = document.getElementById('chq1pay').value;
var num4d4dp = document.getElementById('otherch').value;
var num5e5ep = document.getElementById('srtnvl').value;
var num6f6fp = document.getElementById('mrtnvl').value;
var num7g7gp = document.getElementById('mclaim').value;
var num8re = document.getElementById('undlvl').value;
var num9re = document.getElementById('salamt').value;
var nnnuv8 = document.getElementById('fisue').value;
var num10re = document.getElementById('interestt').value;
var result = parseInt(num1a1ap) - parseInt(num2b2bp) - parseInt(num3c3cp) - parseInt(num4d4dp) - parseInt(num5e5ep) - parseInt(num6f6fp) - parseInt(num7g7gp) - parseInt(num8re) - parseInt(num9re) - parseInt(num10re) - parseInt(nnnuv8);
if (!isNaN(result)) {
document.getElementById('invdues').value = result + <?php echo number_format($srmrcl,2,'.',',') ?>;
}
}


function bncld(event){
var x = event.keyCode;    
if (x == 13 || x == 40) {
document.getElementById("otherch").focus();
}
}

function bnchg(event){
var x = event.keyCode;
if (x == 13 || x == 40){
document.getElementById("srtnvl").focus();    
}
if (x == 38){
document.getElementById("mclaim").focus();    
}
}

function bnsr(event){
var x = event.keyCode;    
if (x == 13 || x == 40) {
document.getElementById("undlvl").focus();
}
if (x == 38){
document.getElementById("otherch").focus();    
}
}

function bnunlv(event){
var x = event.keyCode;    
if (x == 13 || x == 40) {
document.getElementById("mrtnvl").focus();
}
if (x == 38){
document.getElementById("srtnvl").focus();    
}
}

function bnmr(event){
var x = event.keyCode;
if (x == 13 || x == 40){
document.getElementById("cashpay").focus();    
}
if (x == 38){
document.getElementById("undlvl").focus();    
}    
}

function bncash(event){
var x = event.keyCode;
if (x == 13 || x == 40){
document.getElementById("cashb").focus();    
}
if (x == 38){
document.getElementById("mrtnvl").focus();    
}    
}

function bnchqp(event){
var x = event.keyCode;  
if (x == 38){
document.getElementById("cashpay").focus();
}
if (x == 13) {
document.getElementById("textar").focus();    
}
}

function bncashbn(event){
var x = event.keyCode;  
if (x == 13){
document.getElementById("inputField").focus();
}
}

function bncashdt(event){
var x = event.keyCode;  
if (x == 13){
document.getElementById("chq1pay").focus();
}
}

// Submit form with name function.
function submit_by_name() {
var name = document.getElementById("inputField4").value;
if (validation()) // Calling validation function
{
var x = document.getElementsByName('form_name');
x[0].submit(); //form submission
alert(" Name : " + name + " n Form Name : " + document.getElementById("form_id").getAttribute("name") + "nn Form Submitted Successfully......");
}
}

// Name and Email validation Function.
function validation() {
var name = document.getElementById("inputField4").value;
if (name === '') {
alert("Please fill Delivery date fields...!!!!!!");
return false;
}
}

//function btnac(event){
//var x = event.keyCode;
//if (x == 13){
//var netball=document.getElementById("invdues").value;
//if (x==13 && netball>=0) {
//document.getElementById("btnac").disabled=false;
//document.getElementById("btnac").focus();
//}
//}    
//}


</script>
</body>
</html>