From 377176151b494dcd7fcb401491459c863c3033d8 Mon Sep 17 00:00:00 2001 From: venbatechnologies Date: Fri, 27 Jul 2018 10:57:37 +0530 Subject: [PATCH] bank issue fixed --- application/controllers/cashbook.php | 3 +- application/models/cashbook_model.php | 5 +- application/views/bankdebit.php | 726 ++++++++++++-------------- 3 files changed, 343 insertions(+), 391 deletions(-) diff --git a/application/controllers/cashbook.php b/application/controllers/cashbook.php index 04ad21ba..d02929ac 100755 --- a/application/controllers/cashbook.php +++ b/application/controllers/cashbook.php @@ -1135,6 +1135,7 @@ class cashbook extends BaseController $alreadypaid = 0; //echo $earlypaid; $alreadypaid = $this->cashbook_model->getalreadypaid($bankid); + if(empty($alreadypaid)) { $aPay=0; @@ -1172,7 +1173,7 @@ class cashbook extends BaseController } $earlypaid = 0; //echo $earlypaid; - $earlypaid = $this->cashbook_model->getearlyamount($pono); + $earlypaid = $this->cashbook_model->getearlyamount($igrlineitem); if(empty($earlypaid)) { $ePay=0; diff --git a/application/models/cashbook_model.php b/application/models/cashbook_model.php index fe603759..260adcf3 100755 --- a/application/models/cashbook_model.php +++ b/application/models/cashbook_model.php @@ -115,6 +115,7 @@ class cashbook_model extends CI_Model $this->db->join('T_Employee_Details','tbl_users.EmpID=T_Employee_Details.EmpID','left'); $this->db->where('t_income_expense.IsActive',1); $this->db->where('t_income_expense.account_code','ADV001'); + $this->db->or_where('t_income_expense.account_code','0013'); if ($firstyear and $secondyear != ''){ $finyear = "t_income_expense.date >= '".$firstyear."-04-01' and t_income_expense.date <= '".$secondyear."-03-31'"; $this->db->where($finyear); @@ -800,11 +801,11 @@ function receiptdata() return TRUE; } - public function getearlyamount($pono) + public function getearlyamount($IGRLineItemNo) { $this->db->select('Amountpaid'); $this->db->from('T_Bankporeport'); - $this->db->where('PONO ',$pono); + $this->db->where('IGRLineItemNo ',$IGRLineItemNo); $query = $this->db->get(); // print_r( $this->db->last_query()); return $query->result(); diff --git a/application/views/bankdebit.php b/application/views/bankdebit.php index 533589a1..3d7968f3 100644 --- a/application/views/bankdebit.php +++ b/application/views/bankdebit.php @@ -46,11 +46,11 @@ foreach($financialyear as $item) - Payment ID - Payment Mode - Payment Amount (₹) - Payment date - Narration + Payment ID + Payment Mode + Payment Amount (₹) + Payment date + Narration @@ -58,10 +58,10 @@ foreach($financialyear as $item)

- Bank -

+ Bank +

-

+

@@ -185,9 +185,9 @@ foreach($financialyear as $item) CreatedDate),'d-m-Y');?> - PONO?> - IGRNO?> - IGRItemNo?> + PONO?> + IGRNO?> + IGRItemNo?> SupplierName?> Amountpaid)?> @@ -229,37 +229,25 @@ foreach($financialyear as $item)
-
-
+
-
+
-
+
-
+
-
+
- +
-
- -
- - - - - - - - - - - +
- + + +
@@ -293,424 +281,202 @@ 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); - - - //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' + $('').attr({ type:'hidden', - name:'date1'+j, - id:'date1'+j, + name:'hidedate'+i, + id:'hidedate'+i, value:date - }).appendTo('#date1'); + }).appendTo('#HideDateDiv'); $('').attr({ type:'hidden', - name:'purchaseono'+j, - id:'purchaseono'+j, + name:'hidepono'+i, + id:'hidepono'+i, value:pono - }).appendTo('#purchaseono'); + }).appendTo('#HidePONODiv'); $('').attr({ type:'hidden', - name:'hideigrno'+j, - id:'hideigrno'+j, + name:'hideigrno'+i, + id:'hideigrno'+i, value:igrno }).appendTo('#HideIGRDiv'); $('').attr({ type:'hidden', - name:'hideigrline'+j, - id:'hideigrline'+j, + name:'hideigrline'+i, + id:'hideigrline'+i, value:igrlineitem - }).appendTo('#hideigrline'); + }).appendTo('#HideIGRLineItem'); $('').attr({ type:'hidden', - name:'supname'+j, - id:'supname'+j, + name:'hidesupname'+i, + id:'hidesupname'+i, value:supname - }).appendTo('#supname'); + }).appendTo('#HideSuppDiv'); $('').attr({ type:'hidden', - name:'totala'+j, - id:'totala'+j, - value:invoicepayment - }).appendTo('#totala'); - - - $('').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').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; - //alert(w+'w'); - 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()) - - 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=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:"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; @@ -723,6 +489,190 @@ 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]); + }); + + var sum = 0; + + for (var i = 0; i < tempTotal.length; i++) { + sum += tempTotal[i] << 0; + } + $('#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:"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(); + } + + + } +} +