bank issue-bala

This commit is contained in:
venbatechnologies@gmail.com 2018-09-26 15:42:31 +05:30
parent b1ca9e36ed
commit 23f042a909
4 changed files with 1327 additions and 1230 deletions

View File

@ -345,41 +345,195 @@ function clearedcreditbalance(){
}
function debitbankstatemet($Supplierid,$fdate,$tdate){
$sql="select im.IGRNO as igrn,pm.POType as potype,im.PONO as PONO,im.IGRNO,id.IGRItemNo,id.CreatedDate,br.Balancetopay,br.Amountpaid,sd.SupplierName as SupplierName,
round(ifnull(if(POType = 'REVENUE',
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.SGST/100)),
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.SGST /100))),0),2) as sgst,
round(ifnull(if(POType = 'REVENUE',
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.CGST/100)),
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.CGST /100))),0),2) as cgst,
round(ifnull(if(POType = 'REVENUE',
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.IGST/100)),
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.IGST /100))),0),2) as igst,
round(ifnull(if(POType = 'REVENUE',
(id.QuantityAsPerInvoice * pl.Rate)- (rt.AfterDiscount),
(id.QuantityAsPerInvoice * pl.Rate)- (st.Afterdiscountval)),0),2) as discount,
round(ifnull(if(POType = 'REVENUE',
(id.QuantityAsPerInvoice * pl.Rate) + (rt.AfterFreightValue),
(id.QuantityAsPerInvoice * pl.Rate) + (st.AfterFreightValue)),0),2) as freight,
round(ifnull(if(POType = 'REVENUE',
(id.QuantityAsPerInvoice * pl.Rate) +(rt.AfterPackagingValue),0),0),2) as Package,
round((
if(POType = 'IMPORT',(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)),
if(POType = 'CAPITAL' && CapitalRange = 0,(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)),
ifnull((id.QuantityAsPerInvoice * pl.Rate),0)))
+ round(ifnull(if(POType = 'REVENUE',
(id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity),
(id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2)
+ round(ifnull(if(POType = 'REVENUE',
(id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity),
(id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2)
+ round(ifnull(if(POType = 'REVENUE',
(id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity),
(id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2)
+ round(ifnull(if(POType = 'REVENUE',
(id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity),
(id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2)
+ round(ifnull(if(POType = 'REVENUE',
(id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2)
- round(ifnull(if(POType = 'REVENUE',
(id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity),
(id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)),2) as total
from T_IGR_Master im
left join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO
join T_IGR_Details id on id.IGRNO = im.IGRNO and id.MaterialCode = pl.MaterialCode
join T_PurchaseOrder_Master pm on pm.PONO = pl.PONO
left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID
left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo
left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo
left join T_Bankporeport br on br.IGRLineItemNo=id.IGRItemNo
where im.IGRStatus = 'ST027' and id.BankStatus!='ST070' ";
if ($Supplierid!= ''){
$sql.="and sd.SupplierID = '".$Supplierid."'";
}
if ($fdate and $tdate != ''){
$fromd= date("Y-m-d",strtotime($fdate));
$tod=date("Y-m-d",strtotime($tdate));
$sql.="and date(im.CreatedDate) >= '".$fromd."'
and date(im.CreatedDate) <= '".$tod."'";
}
$sql.="group by id.IGRItemNo";
//echo $sql;
$query = $this->db->query($sql);
return $query->result();
}
function debitbankstatemet($Supplierid,$fdate,$tdate)
{
$status='ST057';
//echo $tdate;
//die();
// +rt.SGST/100+rt.IGST/100))
//$Supplierid;
$this->db->distinct();
$this->db->select('igr.PONO,igrli.IGRItemNo,igr.IGRNO,supp.SupplierName,igrli.CreatedDate,BR.Balancetopay,BR.Amountpaid,pom.Status,igrli.QuantityAsPerInvoice ,poli.Rate,(igrli.QuantityAsPerInvoice * poli.Rate) as total,(igrli.QuantityAsPerInvoice * poli.Rate)+(igrli.QuantityAsPerInvoice * poli.Rate)*(rt.CGST/100)+(igrli.QuantityAsPerInvoice * poli.Rate)*(rt.SGST/100)+(igrli.QuantityAsPerInvoice * poli.Rate)*(rt.IGST/100) as finalamount');
$this->db->from ('T_IGR_Details igrli');
$this->db->join('T_IGR_Master igr','igrli.IGRNO = igr.IGRNO','left');
$this->db->join('T_PurchaseOrder_LineItem poli','igr.PONO= poli.PONO and igrli.MaterialCode=poli.MaterialCode');
$this->db->join('T_PurchaseOrder_Master pom','poli.PONO =pom.PONO');
$this->db->join('T_SupplierDetailsN supp','pom.SupplierID =supp.SupplierID');
$this->db->join('T_Revenue_Tax rt','poli.LineItemNo=rt.LineItemNo');
$this->db->join ('T_Bankporeport BR','igrli.IGRItemNo = BR.IGRLineItemNo','left');
if ($fdate and $tdate != ''){
$fromdate= date("Y-m-d",strtotime($fdate));
$todate=date("Y-m-d",strtotime($tdate));
$date = "date(igr.CreatedDate) >= '".$fromdate."'
and date(igr.CreatedDate) <= '".$todate."'";
$this->db->where($date);
}
if ($Supplierid != ''){
$this->db->where('supp.SupplierID',$Supplierid);
}
$this->db->where_in('igr.IGRStatus','ST027');
//$this->db->where_in('pom.Status',[ST044,ST056]);
$this->db->where('igrli.BankStatus','ST072');
$query = $this->db->get();
return $query->result();
// function debitbankstatemet($Supplierid,$fdate,$tdate)
// {
// echo $Supplierid;
// $status='ST057';
// //echo $tdate;
// //die();
// // +rt.SGST/100+rt.IGST/100))
// //$Supplierid;
// $this->db->distinct();
// $this->db->select('igr.PONO,igrli.IGRItemNo,igr.IGRNO,supp.SupplierName,igrli.CreatedDate,BR.Balancetopay,BR.Amountpaid,pom.Status,igrli.QuantityAsPerInvoice ,poli.Rate,(igrli.QuantityAsPerInvoice * poli.Rate) as total,((igrli.QuantityAsPerInvoice * poli.Rate)+(rt.FreightValue)-(rt.DiscountValue))+((igrli.QuantityAsPerInvoice * poli.Rate)*(rt.CGST/100))+((igrli.QuantityAsPerInvoice * poli.Rate)*(rt.SGST as rtsgst/100))+((igrli.QuantityAsPerInvoice * poli.Rate)*(rt.IGST as rtigst/100))+((igrli.QuantityAsPerInvoice * poli.Rate)*(st.IGST as stigst/100))+((igrli.QuantityAsPerInvoice * poli.Rate)*(st.SGST as stsgst/100))+((igrli.QuantityAsPerInvoice * poli.Rate)*(st.CGST /100)) as finalamount');
// $this->db->from ('T_IGR_Details igrli');
// $this->db->join('T_IGR_Master igr','igrli.IGRNO = igr.IGRNO','left');
// $this->db->join('T_PurchaseOrder_LineItem poli','igr.PONO= poli.PONO and igrli.MaterialCode=poli.MaterialCode');
// $this->db->join('T_PurchaseOrder_Master pom','poli.PONO =pom.PONO');
// $this->db->join('T_SupplierDetailsN supp','pom.SupplierID =supp.SupplierID');
// $this->db->join('T_Revenue_Tax rt','poli.LineItemNo=rt.LineItemNo','left');
// $this->db->join('T_Service_Tax st','poli.LineItemNo=st.LineItemNo','left');
// $this->db->join ('T_Bankporeport BR','igrli.IGRItemNo = BR.IGRLineItemNo','left');
// if ($fdate and $tdate != ''){
// $fromdate= date("Y-m-d",strtotime($fdate));
// $todate=date("Y-m-d",strtotime($tdate));
// $date = "date(igr.CreatedDate) >= '".$fromdate."'
// and date(igr.CreatedDate) <= '".$todate."'";
// $this->db->where($date);
// }
// if ($Supplierid != ''){
// $this->db->where('supp.SupplierID',$Supplierid);
// }
// $this->db->where_in('igr.IGRStatus','ST027');
// //$this->db->where_in('pom.Status',[ST044,ST056]);
// $this->db->where('igrli.BankStatus !=','ST070');
// $this->db->group_by('igrli.IGRItemNo');
// $query = $this->db->get();
// return $query->result();
}
// }
function amountunpaid($Supplierid,$fdate,$tdate)
{
$sql="select im.IGRNO as igrn,pm.POType as potype,im.PONO as PONO,im.IGRNO,id.IGRItemNo,id.CreatedDate,br.Balancetopay,br.Amountpaid,sd.SupplierName as SupplierName,
round(ifnull(if(POType = 'REVENUE',
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.SGST/100)),
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.SGST /100))),0),2) as sgst,
round(ifnull(if(POType = 'REVENUE',
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.CGST/100)),
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.CGST /100))),0),2) as cgst,
round(ifnull(if(POType = 'REVENUE',
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(rt.IGST/100)),
(id.QuantityAsPerInvoice * pl.Rate)+((id.QuantityAsPerInvoice * pl.Rate)*(st.IGST /100))),0),2) as igst,
round(ifnull(if(POType = 'REVENUE',
(id.QuantityAsPerInvoice * pl.Rate)- (rt.AfterDiscount),
(id.QuantityAsPerInvoice * pl.Rate)- (st.Afterdiscountval)),0),2) as discount,
round(ifnull(if(POType = 'REVENUE',
(id.QuantityAsPerInvoice * pl.Rate) + (rt.AfterFreightValue),
(id.QuantityAsPerInvoice * pl.Rate) + (st.AfterFreightValue)),0),2) as freight,
round(ifnull(if(POType = 'REVENUE',
(id.QuantityAsPerInvoice * pl.Rate) +(rt.AfterPackagingValue),0),0),2) as Package,
round((
if(POType = 'IMPORT',(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)),
if(POType = 'CAPITAL' && CapitalRange = 0,(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)),
ifnull((id.QuantityAsPerInvoice * pl.Rate),0)))
+ round(ifnull(if(POType = 'REVENUE',
(id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity),
(id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2)
+ round(ifnull(if(POType = 'REVENUE',
(id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity),
(id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2)
+ round(ifnull(if(POType = 'REVENUE',
(id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity),
(id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2)
+ round(ifnull(if(POType = 'REVENUE',
(id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity),
(id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2)
+ round(ifnull(if(POType = 'REVENUE',
(id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2)
- round(ifnull(if(POType = 'REVENUE',
(id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity),
(id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)),2) as total
from T_IGR_Master im
left join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO
join T_IGR_Details id on id.IGRNO = im.IGRNO and id.MaterialCode = pl.MaterialCode
join T_PurchaseOrder_Master pm on pm.PONO = pl.PONO
left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID
left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo
left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo
left join T_Bankporeport br on br.IGRLineItemNo=id.IGRItemNo
where im.IGRStatus = 'ST027' and id.BankStatus ='ST072' ";
if ($Supplierid!= ''){
$sql.="and sd.SupplierID = '".$Supplierid."'";
}
if ($fdate and $tdate != ''){
$fromd= date("Y-m-d",strtotime($fdate));
$tod=date("Y-m-d",strtotime($tdate));
$sql.="and date(im.CreatedDate) >= '".$fromd."'
and date(im.CreatedDate) <= '".$tod."'";
}
$sql.="group by id.IGRItemNo";
//echo $sql;
$query = $this->db->query($sql);
return $query->result();
}
function bankinvoice($Customer,$fdate,$tdate)
{
// $status='ST065';

View File

@ -151,7 +151,7 @@ foreach($financialyear as $item)
$status=$t->Paymentstatus;
$balancetopay=$t->Balancetopay;
$ReceivedQuantity=$t->ReceivedQuantity;
$rate=$t->finalamount;
$rate=$t->total;
if($status !='ST057')

View File

@ -46,11 +46,11 @@ foreach($financialyear as $item)
<thead>
<tr>
<th style="text-align:center">Payment ID</th>
<th style="text-align:center">Payment Mode</th>
<th style="text-align:center">Payment Amount (&#8377;)</th>
<th style="text-align:center">Payment date </th>
<th style="text-align:center">Narration </th>
<th>Payment ID</th>
<th>Payment Mode</th>
<th>Payment Amount (&#8377;)</th>
<th>Payment date </th>
<th>Narration </th>
</tr>
@ -58,10 +58,10 @@ foreach($financialyear as $item)
<tbody>
<tr>
<td><p style="margin-left:25px;" id="bid"></p></td>
<td style="text-align:center">Bank</td>
<td><p style="text-align:center" id="bamount" ></p></td>
<td>Bank</td>
<td><p style="margin-left:25px;" id="bamount" ></p></td>
<td><p style="margin-left:25px;" id="bdate"></p></td>
<td><p style="text-align:center" id="narration"></p></td>
<td><p style="margin-left:25px;" id="narration"></p></td>
</tr>
</tbody>
</table>
@ -175,9 +175,8 @@ foreach($financialyear as $item)
$status=$t->Paymentstatus;
$balancetopay=$t->Balancetopay;
$ReceivedQuantity=$t->ReceivedQuantity;
$rate=$t->finalamount;
//$rate=$t->total;
$rate=$t->total;
if($status !='ST057')
{
?>
@ -185,8 +184,8 @@ foreach($financialyear as $item)
<td data-name="sell"><input type="checkbox" class="checkboxcheckbox" onchange="GetPayment(<?php echo $i ?>) "id="checkboxcheckbox<?php echo $i ?>" name="checkbox<?php echo $i ?>";></td>
<td align="left" id="date<?php echo $i ?>"><span><?php echo date_format(date_create($t->CreatedDate),'d-m-Y');?></span></td>
<td align="left" id="pono<?php echo $i ?>"><a href="<?= base_url() ?>cashbook/mappingdebit?sid=<?php echo $t->PONO;?>"><span><?php echo $t->PONO?></span></a></td>
<td align="left" id="igrno<?php echo $i ?>"><a href="<?= base_url() ?>cashbook/mappingdebit?sid=<?php echo $t->IGRNO;?>"><span><?php echo $t->IGRNO?></span></a></td>
<td align="left" id="pono<?php echo $i ?>"><span><?php echo $t->PONO?></span></a></td>
<td align="left" id="igrno<?php echo $i ?>"><span><?php echo $t->IGRNO?></span></a></td>
<td align="left" id="igrlineitem<?php echo $i ?>" ><span><?php echo $t->IGRItemNo?></span></td>
<td align="left" id="sn<?php echo $i ?>" ><span><?php echo $t->SupplierName?></span></td>
<td align="left" id="tov<?php echo $i ?>" ><span><?php echo round($rate,2)?></span></td>
@ -229,37 +228,25 @@ foreach($financialyear as $item)
</div><!-- /.col -->
<div class="row">
<div class="row">
<div class="col-md-12" id="date1"></div>
<div class="col-md-12" id="HideDateDiv"></div>
<div class="col-md-12" id="purchaseono"></div>
<div class="col-md-12" id="HidePONODiv"></div>
<div class="col-md-12" id="HideIGRDiv"></div>
<div class="col-md-12" id="HideIGRDiv"></div>
<div class="col-md-12" id="hideigrline"></div>
<div class="col-md-12" id="HideIGRLineItem"></div>
<div class="col-md-12" id="supname"></div>
<div class="col-md-12" id="HideSuppDiv"></div>
<div class="col-md-12" id="aa1"></div>
<!--<div class="col-md-12" id="aa2"></div>-->
<div class="col-md-12" id="HideTtlPoAmtDiv"></div>
<div class="col-md-12" id="ttamnt"></div>
<div class="col-md-12" id="totala"></div>
<!--<input type="text" name="qw1" id="qw1">-->
<input type="hidden" name="Recid" id="Recid" value="">
<!-- <input type="hidden" name="bankid" id="bankid" value="">-->
<input type="hidden" name="bankamount" id="bankamount" value="">
<div class="col-md-12" id="HideAmtPaidDiv"></div>
<input type="hidden" name="Recid" id="Recid" value="" readonly>
<input type="hidden" name="bankamount" id="bankamount" value="" readonly>
</div>
</section>
@ -293,432 +280,203 @@ foreach($financialyear as $item)
var i;
$.each(res1, function( index, value )
{
var res2 = value.split('-');
var bid=res2[0];
var bam=res2[1];
//alert(bid);
//alert(bam);
$('#bankid').val(bid);
document.getElementById("bid").innerHTML='Payment ID:' +bid;
});
//alert(res2);
//alert(res[1]);
//var text = $('#debitamount').text();
//alert($data['cash']);
// $('#debitamount').val('10');
table = $('#req').DataTable( {
var res2 = value.split('-');
var bid=res2[0];
var bam=res2[1];
$('#bankid').val(bid);
document.getElementById("bid").innerHTML=bid;
});/** foreach closed */
$.fn.dataTable.moment( 'DD-MM-YYYY' );
table = $('#req').DataTable( {
"dom": "<'row'<'col-md-6'l><'col-md-6'Bf>>" +
"<'row'<'col-md-6'><'col-md-6'>>" +
"<'row'<'col-md-12't>><'row'<'col-md-4'i><'col-md-8'p>>",
buttons: [
{
"<'row'<'col-md-6'><'col-md-6'>>" +
"<'row'<'col-md-12't>><'row'<'col-md-4'i><'col-md-8'p>>",
buttons: [
{
extend: 'excelHtml5',
footer: 'true',
messageTop: $('h3').text(),
title: 'cashbook Overall Report',
exportOptions: {
columns: ':visible'
columns: ':visible'
}
},
'colvis'
]
} );
} );
} );/** datatable closed */
} );/** ready closed */
var temppo=[]; // temppo - This array for PO with its value.
var tempTotal = []; // tempTotal - This array for get value from "temppo" to calculate grandtotal
var intex = 1;
var row = 0;
//alert(pono+'array');
var temppo=[];
var tot=0;
var tot1=0;
var intex=1;
var row=0;
var j=1;
var addvalue=0;
var tott=0;
var total=0;
function GetPayment(i)
{
//alert('check');
var value=i;
var bankdebitamount=$('#debitamount').val();
var totalvalue=$('#addvalue').val();
var balanceamount=bankdebitamount-totalvalue;
var x = document.getElementById('checkboxcheckbox'+i).checked;
var x = document.getElementById('checkboxcheckbox'+i).checked;
var amount= parseFloat( $('#invoicepaymet'+i).val() == '' ? '0.00' : $('#invoicepaymet'+i).val())
//alert(amount+'inv');
var negative=0;
if(amount<0)
{
var amount= parseFloat( $('#invoicepaymet'+i).val() == '' ? '0.00' : $('#invoicepaymet'+i).val())
var negative=0;
if(amount<0)
{
negative=1;
alert('Invalid Amount');
// $('#invoicepaymet'+i).val('');
}
temp=intex;
//alert(temp+'temp');success
}
temp=intex;
if(x==true)
{
//alert(x);
var bankdebitamount=$('#debitamount').val();
var totalvalue=$('#addvalue').val();
var balanceamount=bankdebitamount-totalvalue;
if(bankdebitamount==totalvalue)
{
//alert('you have remaining'+balanceamount);
//alert('your amount is equal to debit amount');
$(".checkboxcheckbox").prop("disabled", true);
}
else
{
//document.getElementById('checkboxcheckbox'+i).checked = false;
('your checkbox is disabled beacause already mapped amount')
}
row= parseInt(row)+1;
row = parseInt(row)+1;
$('#Rowid').val(row);
var date= document.getElementById ( "date"+i ).innerText;
var pono =document.getElementById ( "pono"+i ).innerText;
var poamount =document.getElementById ( "qw"+i ).innerText;
var igrno =document.getElementById ( "igrno"+i ).innerText;
var date= document.getElementById ( "date"+i ).innerText;//value taken from table, col name : date
var pono =document.getElementById ( "pono"+i ).innerText;//value taken from table, col name : purchase order no
var igrno =document.getElementById ( "igrno"+i ).innerText;
var igrlineitem=document.getElementById ( "igrlineitem"+i ).innerText;
var tta= $('#totala').val();
var tempid = "debited"+value;
//var credit=parseFloat(document.getElementById(tempid).innerText);
var t ="totala"+value;
var poamount1 =$(t).val();
//alert(poamount1+'amt');
var ponovalue = igrlineitem+','+poamount;
temppo.push(ponovalue);
console.log(temppo);
var total=0;
$.each(temppo, function( index, value )
{
var res2 = value.split(',');
var pono=res2[0];
//alert(pono+'pono');
var bam=res2[1];
//alert(bam+'bam');
total=parseFloat(bam)+parseFloat(total);
$('#addvalue').val(parseFloat(total).toFixed(2));
});
//console.log(temppo);
var supname =document.getElementById ("sn"+i ).innerText;
var totalordervalue =document.getElementById ("tov"+i ).innerText;
var invoicepayment =document.getElementById ( "qw"+i ).innerText;
$('#invoicepaymet'+i).val(invoicepayment);
var RowCount= $('#Rowid').val();
var supname =document.getElementById ("sn"+i ).innerText;//value taken from table col name : suppliername
var totalordervalue =document.getElementById ("tov"+i ).innerText;//value taken from table col name : total po amount
var invoicepayment =document.getElementById ( "qw"+i ).innerText;//value taken from table col name : Balance to pay
$('#invoicepaymet'+i).val(invoicepayment);//to copy the value from 'balance to pay' to 'amount paid'
$('<input>').attr({
type:'hidden',
name:'date1'+j,
id:'date1'+j,
name:'hidedate'+i,
id:'hidedate'+i,
value:date
}).appendTo('#date1');
}).appendTo('#HideDateDiv');
$('<input>').attr({
type:'hidden',
name:'purchaseono'+j,
id:'purchaseono'+j,
name:'hidepono'+i,
id:'hidepono'+i,
value:pono
}).appendTo('#purchaseono');
}).appendTo('#HidePONODiv');
$('<input>').attr({
type:'hidden',
name:'hideigrno'+j,
id:'hideigrno'+j,
name:'hideigrno'+i,
id:'hideigrno'+i,
value:igrno
}).appendTo('#HideIGRDiv');
$('<input>').attr({
type:'hidden',
name:'hideigrline'+j,
id:'hideigrline'+j,
name:'hideigrline'+i,
id:'hideigrline'+i,
value:igrlineitem
}).appendTo('#hideigrline');
}).appendTo('#HideIGRLineItem');
$('<input>').attr({
type:'hidden',
name:'supname'+j,
id:'supname'+j,
name:'hidesupname'+i,
id:'hidesupname'+i,
value:supname
}).appendTo('#supname');
}).appendTo('#HideSuppDiv');
$('<input>').attr({
type:'hidden',
name:'totala'+j,
id:'totala'+j,
value:invoicepayment
}).appendTo('#totala');
$('<input>').attr({
type:'hidden',
name:'ttamnt'+j,
id:'ttamnt'+j,
name:'hidettlPoamt'+i,
id:'hidettlPoamt'+i,
value:totalordervalue
}).appendTo('#ttamnt');
}).appendTo('#HideTtlPoAmtDiv');
intex = parseInt(intex)+1;
j=parseInt(j)+1;
//alert(j+'j');
var to=0;
// for(t=1;t<j;t++)
// {
// //var pono1 =document.getElementById ( "pono"+i ).innerText;
// //alert(pono1);
// var tt=parseFloat( $('#totala'+t).val() == '' ? '0.00' : $('#totala'+t).val());
// to = parseFloat(to) + parseFloat (tt);
// $('#addvalue').val(parseFloat(to).toFixed(2));
// //var total= $('#addvalue').val();
// //total=addvalue;
// //alert(total);
// }
$('<input>').attr({
type:'hidden',
name:'hideamtpaid'+i,
id:'hideamtpaid'+i,
value:invoicepayment
}).appendTo('#HideAmtPaidDiv');
var poamount = $('#hideamtpaid'+i).val();
var ponovalue = i+','+igrlineitem+','+poamount;
temppo.push(ponovalue);
//console.log(temppo);
calculategrandtotal();
// GetAmount(i);
intex = parseInt(intex)+1;
var bankdebitamount=$('#debitamount').val();
var totalvalue=$('#addvalue').val();
//var balanceamount=bankdebitamount-totalvalue;
// alert(bankdebitamount);
// alert(totalvalue);
// if(parseFloat(totalvalue)>=parseFloat(bankdebitamount))
// {
// alert('your checkbox is disabled beacause already mapped amount');
// $(".checkboxcheckbox").prop("disabled", true);
// }
}
else
{
//alert(i)
var rr= $('#Rowid').val();
var ro= parseInt(rr)-1;
var rr = $('#Rowid').val();
row = parseInt(rr)-1;
var Payment= parseFloat( $('#invoicepaymet'+i).val() == '' ? '0.00' : $('#invoicepaymet'+i).val());
var Payment = parseFloat( $('#invoicepaymet'+i).val() == '' ? '0.00' : $('#invoicepaymet'+i).val());
var Inid = document.getElementById ('igrlineitem'+i ).innerText
var ponovalue = Inid+','+Payment;
var a = temppo.indexOf(ponovalue);
//console.log(a);
if(a!=-1)
{
temppo.splice(a,1);
console.log(temppo);
}
//alert(Inid)
for(s=1;s<=j;s++)
{
// alert(j+'else');
var ch= $('#hideigrline'+s).val();
if(Inid==ch)
{
var w=s;
delamount= $('#totala'+w).val();
break;
}
}
// //alert(w);
var tote= $('#addvalue').val();
var afterdeltot= parseFloat(tote)- parseFloat(delamount);
tot=parseFloat(tot)- parseFloat(Payment);
$('#invoicepaymet'+i).val('');
$('#addvalue').val(parseFloat(afterdeltot).toFixed(2));
//alert(ro);
$('#Rowid').val(ro);
//$('#addvalue').val('');
$('#invoicepaymet'+i).val('');
$('#hideigrline'+i).val('');
$('#date1'+i).val('');
$('#purchaseono'+i).val('');
$('#supname'+i).val('');
$('#ttamnt'+i).val('');
$('#totala'+i).val('');
//$('#aa'+i).val('');
}
}
function GetAmount(i)
{
//alert('text');
var amount= parseFloat( $('#invoicepaymet'+i).val() == '' ? '0.00' : $('#invoicepaymet'+i).val())
//alert(amount);
var negative=0;
if(amount<0)
{
negative=1;
alert("Invalid Amount")
$('#invoicepaymet'+i).val('');
}
var x = document.getElementById('checkboxcheckbox'+i).checked;
if(x==true )
{
//alert(x);
var date= document.getElementById ( "date"+i ).innerText;
var pono =document.getElementById ( "pono"+i ).innerText;
var igr =document.getElementById ( "igrno"+i ).innerText;
var igrlineitem=document.getElementById ( "igrlineitem"+i ).innerText;
var supname =document.getElementById ("sn"+i ).innerText;
var totalordervalue =document.getElementById ("tov"+i ).innerText;
var balancetopay=document.getElementById ( "qw"+i ).innerText;
for(k=1;k<=j-1;k++)
{
//alert(k)
var idcheck=$('#hideigrline'+k).val();
// alert(idcheck)
if(igrlineitem==idcheck)
{
var cid=k;
//alert(cid+'if');
//die();
break;
}
}
if(amount<=totalordervalue)
{
//alert(cid+'cid');
$('#date1').val(date);
$('#hideigrline'+cid).val(igrlineitem);
$('#supname'+cid).val(supname);
$('#ttamnt'+cid).val(totalordervalue);
$('#totala'+cid).val(amount);
var totalvalue=$('#addvalue').val();
var bid=$('#bankid').val();
//$('#inv_total'+cid).val(invoicepayment);
}
else
{
alert('You are exceeding the payment get!!');
$('#invoicepaymet'+i).val(amount)
location.reload();
}
var tot11=0
for(l=1;l<j;l++)
{
var Payingamount=parseFloat( $('#totala'+l).val() == '' ? '0.00' : $('#totala'+l).val());
tot11= parseFloat(tot11)+parseFloat(Payingamount);
$('#addvalue').val(parseFloat(tot11).toFixed(2));
}
}
// else
// {
// //document.getElementById('checkboxcheckbox'+i).checked = false;
// $('#invoicepaymet'+i).val('');
// $('#addvalue').val('');
// }
}
function Save()
{
$('#content').loader('show');
var rowCount= $('#Rowid').val();
var check= 0;
var rw= 0;
for(i=1;i<=rowCount;i++)
{
//alert(i);
rw= parseFloat(rw)+1;
check = parseFloat(check)+1;
var bankdebitamount=$('#debitamount').val();
var bid=$('#bankid').val();
var date =$('#date1'+i).val();
var pono =$('#purchaseono'+i).val();
var igrno =$('#hideigrno'+i).val();
var igrlineitem =$('#hideigrline'+i).val();
var suppliername=$('#supname'+i).val();
//alert(suppliername);
var totalordervalue=$('#ttamnt'+i).val();
var amountpaid=$('#totala'+i).val();
//alert(amountpaid+'qw1');
var invoicepaymet=$('#invoicepaymet'+i).text();
// alert(invoicepaymet);
var totalvalue=$('#addvalue').val();
//alert(totalvalue);
if(totalvalue!=0)
{
var payment = parseFloat(amountpaid);
var balnceamount=bankdebitamount-totalvalue;
if(parseFloat(bankdebitamount)>=parseFloat(totalvalue))
{
//alert(date+'date');
//die();
//alert('you have remainining'+balnceamount);
$.ajax(
{
data:{podate:date,pono:pono,igrno:igrno,igrlineitem:igrlineitem,sname:suppliername,tot:totalordervalue,aa:amountpaid,ip:invoicepaymet,rc:rowCount,tpv:totalvalue,bda:bankdebitamount,bi:bid,check:check,rw:rw},
type:"POST",
url:"<?php echo base_url() ?>cashbook/receipt",
success:function(data)
{
if(data)
{
window.location.href ="Bankingstatement";
//location.reload();
}
}
});
}
}
else{
var ponovalue = i+','+Inid+','+Payment;
alert('You are payment exceeding');
location.reload();
}
}
}
$.each(temppo,function(i,val){
var a = temppo.indexOf(ponovalue);
var b = tempTotal.indexOf(Payment);
//console.log(a);
if(a != -1){
//sconsole.log('if');
temppo.splice(a,1);
//console.log(temppo);
}
if(b!=-1)
{
tempTotal.splice(ponovalue,1);
//console.log(tempTotal);
}
});
calculategrandtotal();
$('#invoicepaymet'+i).val('');
$('#Rowid').val(row);
$('#invoicepaymet'+i).val('');
$('#hidedate'+i).val('');
$('#hidepono'+i).val('');
$('#hideigrno'+i).val('');
$('#hideigrline'+i).val('');
$('#hidesupname'+i).val('');
$('#hidettlPoamt'+i).val('');
$('#hideamtpaid'+i).val('');
//$('#invoicepaymet'+i).remove();
$('#hidedate'+i).remove();
$('#hidepono'+i).remove();
$('#hideigrno'+i).remove();
$('#hideigrline'+i).remove();
$('#hidesupname'+i).remove();
$('#hidettlPoamt'+i).remove();
$('#hideamtpaid'+i).remove();
}
}
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : evt.keyCode;
@ -731,6 +489,194 @@ function isNumberKey(evt)
return true;
}
function GetAmount(i)
{
//alert("onchnage function getamount"+i);
var amount = parseFloat( $('#invoicepaymet'+i).val() == '' ? '0.00' : $('#invoicepaymet'+i).val())
var negative=0;
if(amount<0)
{
negative=1;
alert("Invalid Amount")
$('#invoicepaymet'+i).val('');
}
var x = document.getElementById('checkboxcheckbox'+i).checked;
if(x==true )
{
var date= document.getElementById ( "date"+i ).innerText;
var pono =document.getElementById ( "pono"+i ).innerText;
var igr =document.getElementById ( "igrno"+i ).innerText;
var igrlineitem=document.getElementById ( "igrlineitem"+i ).innerText;
var supname =document.getElementById ("sn"+i ).innerText;
var totalordervalue =document.getElementById ("tov"+i ).innerText;
var balancetopay =document.getElementById ( "qw"+i ).innerText;
for(k=1;k<=i;k++)
{
//alert(k);
var idcheck=$('#igrlineitem'+k).val();
if(igrlineitem == idcheck)
{
var cid=k;
break;
}
}
if(amount<=balancetopay)//amount paid value is less than or equal to total amount paid value means
{
$('#hidedate'+cid).val(date);
$('#hidepono'+cid).val(pono);
$('#hidesupname'+cid).val(supname);
$('#hidettlPoamt'+cid).val(totalordervalue);
$('#hideamtpaid'+cid).val(amount);
$('#hideigrno'+cid).val(igr);
$('#hideigrline'+cid).val(igrlineitem);
var totalvalue=$('#addvalue').val();
var bid=$('#bankid').val();
}
else
{
alert('You are exceeding the payment get!!');
$('#invoicepaymet'+i).val(amount)
// location.reload();
}
$.each(temppo, function( index, value )
{
var res2 = value.split(',');
if(res2[1] == igrlineitem){
temppo[index] = i+','+igrlineitem+','+amount;
}
});
calculategrandtotal()
}
}
/** To calculate the overall total and store the value in table's footer */
function calculategrandtotal(){
$.each(temppo, function( index, value )
{
var res2 = value.split(',');
tempTotal[index]=parseFloat(res2[2]);
//alert(tempTotal[index]);
});
var sum = 0;
for (var i = 0; i < tempTotal.length; i++) {
sum += tempTotal[i];
}
$('#addvalue').val(parseFloat(sum).toFixed(2));
// console.log(tempTotal);
}
function Save()
{
$('#content').loader('show');
var rowCount= $('#Rowid').val();
var check= 0;
var rw= 0;
for(i=1;i<=rowCount;i++)
{
var arrval = temppo[i-1];
var number = arrval.split(',');
number = number[0];
//alert('rowcount'+i+'selectedcheckboxnumber'+number+'tempinvoice'+arrval);
rw= parseFloat(rw)+1;
// alert('rwval'+'-'+rw);
check = parseFloat(check)+1;
var bankdebitamount=$('#debitamount').val();
// alert('bankdebitamountval'+'-'+bankdebitamount);
var bid =$('#bankid').val();
// alert('bidval'+'-'+bid);
var date =$('#hidedate'+number).val();
// alert('dateval'+'-'+date);
var pono =$('#hidepono'+number).val();
//alert('ponoval'+'-'+pono);
var igrno =$('#hideigrno'+number).val();
// alert('igrnoval'+'-'+igrno);
var igrlineitem =$('#hideigrline'+number).val();
// alert('igrlineitemval'+'-'+igrlineitem);
var suppliername=$('#hidesupname'+number).val();
// alert('suppliernameval'+'-'+suppliername);
var totalordervalue=$('#hidettlPoamt'+number).val();
// alert('totalordervalueval'+'-'+totalordervalue);
var amountpaid=$('#hideamtpaid'+number).val();
// alert('amountpaidval'+'-'+amountpaid);
var invoicepaymet=$('#invoicepaymet'+number).val();
//alert(invoicepaymet);
var totalvalue=$('#addvalue').val();
// alert('totalvalueval'+'-'+totalvalue);
var payment = parseFloat(amountpaid);
//alert('paymentval'+'-'+payment);
var balnceamount=bankdebitamount-totalvalue;
// alert('balnceamountval'+'-'+balnceamount);
if(parseFloat(bankdebitamount)>=parseFloat(totalvalue))
{
$.ajax(
{
data:{podate:date,pono:pono,igrno:igrno,igrlineitem:igrlineitem,sname:suppliername,tot:totalordervalue,aa:invoicepaymet,rc:rowCount,tpv:totalvalue,bda:bankdebitamount,bi:bid,check:check,rw:rw},
type:"POST",
url:"<?php echo base_url() ?>cashbook/receipt",
success:function(data)
{
if(data)
{
//$('#content').loader('hide');
//alert(data);
window.location.href ="Bankingstatement";
//location.reload();
}
}
});
}
else{
alert('Your payment exceeding ');
location.reload();
}
}
}
</script>
<script>
@ -771,6 +717,6 @@ $( function() {
return date;
}
} );
</script>
</script>

File diff suppressed because it is too large Load Diff