593 lines
17 KiB
PHP
593 lines
17 KiB
PHP
<?php
|
|
foreach($financialyear as $item)
|
|
{
|
|
$finyear = $item->financial_year;
|
|
|
|
}
|
|
?>
|
|
|
|
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css">
|
|
<style>
|
|
.dataTables_filter input {padding: 4px;}
|
|
|
|
.dataTables_filter {
|
|
width: 50%;
|
|
float: right;
|
|
text-align: right;
|
|
}
|
|
.dataTables_paginate {
|
|
width: 50%;
|
|
float: right;
|
|
text-align: right;
|
|
}
|
|
div.dt-buttons {
|
|
position: relative;
|
|
float: right;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
|
<div class="content-wrapper">
|
|
<section class="content">
|
|
<div class="row">
|
|
|
|
<!-- Left col -->
|
|
<div class="col-md-12">
|
|
<!-- TABLE: LATEST ORDERS -->
|
|
<div class="box box-info" id="content">
|
|
|
|
<div class="box-body">
|
|
<form method="post" action="<?php echo base_url($this->uri->uri_string()); ?>">
|
|
|
|
<center><h3 class="box-title"><p style="color:#3c8dbc"><b>Invoice Report</b></p></h3></center>
|
|
|
|
<div class="row">
|
|
<div class="col-md-3">
|
|
<label for="from_date"> <?php echo 'From Date'; ?></label>
|
|
<div class="input-group">
|
|
<input name="from_date" id="max-date" class="form-control datepicker">
|
|
<span class="input-group-addon">
|
|
<i class="fa fa-calendar fa-fw"></i>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="col-md-3">
|
|
<label for="to_date">
|
|
<?php echo 'To Date'; ?>
|
|
</label>
|
|
<div class="input-group">
|
|
<input name="to_date" id="min-date" class="form-control datepicker">
|
|
<span class="input-group-addon">
|
|
<i class="fa fa-calendar fa-fw"></i>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-3" >
|
|
<label for="customer">
|
|
<?php echo 'Customer'; ?>
|
|
</label>
|
|
<select class="form-control" id="Customer" name="Customer">
|
|
<option value="">Select Customer</option>
|
|
<?php
|
|
foreach($getcustomer as $gc):
|
|
{?>
|
|
<option value="<?php echo $gc->client_id;?>"><?php echo $gc->client_name ; ?></option>
|
|
|
|
<?php } endforeach; ?>
|
|
|
|
</select>
|
|
</div>
|
|
|
|
<div class="col-md-1" style="margin-top:24px;">
|
|
<input type="submit" class="btn btn-success" name="btn_submit"
|
|
value="View Report">
|
|
|
|
</div>
|
|
|
|
</div><!--/ inside 1st .row closed -->
|
|
<br>
|
|
<br>
|
|
<br>
|
|
<br>
|
|
|
|
<div class="row">
|
|
|
|
<input type="hidden" id="debitamount" value="<?php echo $cash; ?>" placeholder="Debit Amount" readonly>
|
|
|
|
<input type="hidden" id="bankid" value="<?php echo $bankid; ?>" placeholder="Bank Id" readonly>
|
|
|
|
|
|
<div class="col-md-3 col-md-offset-9">
|
|
<div style=" border: 2px solid black;margin-left:0%;margin-top: -55px;font-size:14px;background-color:#ccc;">
|
|
<p style="margin-left:25px;" id="bid" value=""</b>>Payment ID: </p>
|
|
<p style="margin-left:25px;">Payment Mode: Bank</p>
|
|
<p style="margin-left:25px;" id="bamount" value="">Payment Amount: </p>
|
|
</div>
|
|
</div>
|
|
</div><!--/ inside 2nd .row closed -->
|
|
</form>
|
|
<br>
|
|
<br>
|
|
<input type="hidden" name="Rowid" id="Rowid" placeholder="Row Id" readonly >
|
|
<table class="table table-bordered table-hover" id="req" style="table-layout:auto;">
|
|
<thead>
|
|
<tr>
|
|
<th>Select</th>
|
|
<th>Date</th>
|
|
<th>Invoice Number</th>
|
|
<th>Customer Name</th>
|
|
<th>Invoice Amount (₹)</th>
|
|
<th>Balance To Received</th>
|
|
<th>AmountReceived</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
$i=1;
|
|
$ti=0.00;
|
|
$tvt=0.00;
|
|
if(!empty($bankinvoicedata)){
|
|
foreach($bankinvoicedata as $t)
|
|
|
|
{
|
|
$status=$t->Paymentstatus;
|
|
$balancetopay=$t->Balancetopay;
|
|
if($status !='ST057')
|
|
{
|
|
?>
|
|
<tr>
|
|
|
|
<td data-name="sell"><input type="checkbox" onchange="GetPayment(<?php echo $i ?>) "id="checkboxcheckbox<?php echo $i ?>" name="checkbox<?php echo $i ?>";></td>
|
|
<td align="left" id="invoicedate<?php echo $i ?>"><span><?php echo date_format(date_create($t->invoice_date_created),'d-m-Y');?></span></td>
|
|
<td align="left" id="invoice_id<?php echo $i ?>"><a href="<?= base_url() ?>cashbook/mappingcredit?sid=<?php echo $t->invoice_number;?>"><span><?php echo $t->invoice_number?></span></td>
|
|
<td align="left" id="client_name<?php echo $i ?>"><span><?php echo $t->client_name?></span></td>
|
|
<td align="left" id="invoice_paid<?php echo $i ?>"><span><?php echo $t->invoice_total?></span></td>
|
|
<td align="left" id="invoice_balance<?php echo $i ?>"><span><?php echo ($t->invoice_total)-($t->amountreceived)?></span></td>
|
|
<td data-name="sel"><input type="text" onkeypress="return isNumberKey(event)" onchange="GetAmount(<?php echo $i ?>)" id="invoicereceived<?php echo $i ?>"></td>
|
|
|
|
</tr>
|
|
<?php
|
|
$i++;
|
|
}
|
|
}
|
|
?>
|
|
</tbody>
|
|
<tfoot width="100%">
|
|
<tr>
|
|
<td style="text-align:left;"><strong>Total</strong></td>
|
|
<td> </td>
|
|
<td> </td>
|
|
<td> </td>
|
|
<td> </td>
|
|
<td> </td>
|
|
<td class="amount"><strong>
|
|
|
|
<input type="text" id="addvalue" name="addvalue">
|
|
|
|
</strong>
|
|
</td>
|
|
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
</tfoot>
|
|
<?php } ?>
|
|
</table>
|
|
|
|
<div class="col-md-2 col-md-offset-10" style="margin-top:24px;">
|
|
<a style="float:right;" class="btn btn-success ajax-loader" ID="Save" onclick="Save()" > <span class="bold">Save</span></a>
|
|
</div>
|
|
|
|
</div><!-- / .box-body closed -->
|
|
</div><!-- /.box box-info closed-->
|
|
|
|
</div><!--/ .col (col-md-12)-->
|
|
|
|
</div><!-- /. 1st row closed -->
|
|
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-12" id="HideInvoiceDateDiv"></div>
|
|
|
|
<div class="col-md-12" id="HideInvoiceIdDiv"></div>
|
|
|
|
<div class="col-md-12" id="HideCustomerNameDiv"></div>
|
|
|
|
<div class="col-md-12" id="HideInvoiceAmtDiv"></div>
|
|
|
|
<div class="col-md-12" id="HideInvoiceRecdDiv"></div>
|
|
|
|
<input type="hidden" name="Recid" id="Recid" value="" placeholder="Rec Id" readonly>
|
|
|
|
</div><!-- /. 2nd row closed -->
|
|
|
|
</section>
|
|
</div>
|
|
|
|
<script src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
|
|
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.html5.min.js"></script>
|
|
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.colVis.min.js"></script>
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
var res=localStorage.getItem('test2');
|
|
$('#debitamount').val(localStorage.getItem('tes'));
|
|
var amount=localStorage.getItem('tes');
|
|
document.getElementById("bamount").innerHTML='Payment Amount:'+amount+'Rs';
|
|
var res1 = res.split(',');
|
|
var i;
|
|
$.each(res1, function(index, value)
|
|
{
|
|
var res2 = value.split('-');
|
|
var bid=res2[0];
|
|
var bam=res2[1];
|
|
|
|
$('#bankid').val(bid);
|
|
|
|
document.getElementById("bid").innerHTML='Payment ID:' +bid;
|
|
});/** foreach closed */
|
|
|
|
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: [
|
|
{
|
|
extend: 'excelHtml5',
|
|
footer: 'true',
|
|
messageTop: $('h3').text(),
|
|
title: 'cashbook Overall Report',
|
|
exportOptions: {
|
|
columns: ':visible'
|
|
|
|
}
|
|
},
|
|
|
|
'colvis'
|
|
]
|
|
} );/** datatable closed */
|
|
} );/** ready closed */
|
|
|
|
var tempinvoice=[]; // tempinvoice - This array for Invoice no with its value and its checkbox select number('checkbox_select_number'-'id'-'value').
|
|
var tempTotal = []; // tempTotal - This array for get value from "tempinvoice" to calculate grandtotal
|
|
var row=0;
|
|
var intex=1;
|
|
|
|
function GetPayment(i)
|
|
{
|
|
var x = document.getElementById('checkboxcheckbox'+i).checked;
|
|
|
|
var amount= parseFloat( $('#invoicereceived'+i).val() == '' ? '0.00' : $('#invoicereceived'+i).val())
|
|
var negative=0;
|
|
if(amount<0)
|
|
{
|
|
negative=1;
|
|
alert("Invalid Amount")
|
|
$('#invoicereceived'+i).val('');
|
|
|
|
}
|
|
temp=intex;
|
|
if(x==true)
|
|
{
|
|
|
|
row = parseInt(row)+1;
|
|
$('#Rowid').val(row);
|
|
var date= document.getElementById ( "invoicedate"+i ).innerText;
|
|
var invid =document.getElementById ( "invoice_id"+i ).innerText;
|
|
var cusname =document.getElementById ("client_name"+i ).innerText;
|
|
var invoiceamount =document.getElementById ("invoice_paid"+i ).innerText;
|
|
var invoicereceived=document.getElementById ("invoice_balance"+i ).innerText;
|
|
$('#invoicereceived'+i).val(invoicereceived);
|
|
|
|
$('<input>').attr({
|
|
type:'hidden',
|
|
name:'hideinvoicedate'+i,
|
|
id:'hideinvoicedate'+i,
|
|
value:date
|
|
}).appendTo('#HideInvoiceDateDiv');
|
|
|
|
$('<input>').attr({
|
|
type:'hidden',
|
|
name:'hideinvoiceid'+i,
|
|
id:'hideinvoiceid'+i,
|
|
value:invid
|
|
}).appendTo('#HideInvoiceIdDiv');
|
|
|
|
$('<input>').attr({
|
|
type:'hidden',
|
|
name:'hidecustomername'+i,
|
|
id:'hidecustomername'+i,
|
|
value:cusname
|
|
}).appendTo('#HideCustomerNameDiv');
|
|
|
|
$('<input>').attr({
|
|
type:'hidden',
|
|
name:'hideinvoiceamount'+i,
|
|
id:'hideinvoiceamount'+i,
|
|
value:invoiceamount
|
|
}).appendTo('#HideInvoiceAmtDiv');
|
|
|
|
$('<input>').attr({
|
|
type:'hidden',
|
|
name:'hideinvoicerecd'+i,
|
|
id:'hideinvoicerecd'+i,
|
|
value:invoicereceived
|
|
}).appendTo('#HideInvoiceRecdDiv');
|
|
|
|
if(negative==1)
|
|
{
|
|
|
|
|
|
for(o=1;o<i;o++)//need to ask
|
|
{
|
|
$('#invoice_balance1'+o).val('')
|
|
|
|
}
|
|
}
|
|
|
|
|
|
var invoicevalue = i+'-'+invid+'-'+invoicereceived;
|
|
tempinvoice.push(invoicevalue);
|
|
|
|
calculategrandtotal();
|
|
|
|
intex = parseInt(intex)+1;
|
|
|
|
}
|
|
|
|
else
|
|
{
|
|
|
|
var rr= $('#Rowid').val();
|
|
row = parseInt(rr)-1;
|
|
|
|
var Payment= parseFloat( $('#invoicereceived'+i).val() == '' ? '0.00' : $('#invoicereceived'+i).val());
|
|
var Inid = document.getElementById ('invoice_id'+i ).innerText
|
|
var invoicevalue = i+'-'+Inid+'-'+Payment;
|
|
var a = tempinvoice.indexOf(invoicevalue);
|
|
var b = tempTotal.indexOf(Payment);
|
|
|
|
if(a!=-1)
|
|
{
|
|
tempinvoice.splice(a,1);
|
|
//console.log(tempinvoice);
|
|
}
|
|
if(b!=-1)
|
|
{
|
|
tempTotal.splice(a,1);
|
|
//console.log(tempTotal);
|
|
}
|
|
calculategrandtotal();
|
|
|
|
$('#invoicereceived'+i).val('');
|
|
|
|
$('#Rowid').val(row);
|
|
|
|
$('#invoicereceived'+i).val('');
|
|
$('#hideinvoicedate'+i).val('');
|
|
$('#hideinvoiceid'+i).val('');
|
|
$('#hidecustomername'+i).val('');
|
|
$('#hideinvoiceamount'+i).val('');
|
|
$('#hideinvoicerecd'+i).val('');
|
|
|
|
$('#hideinvoicedate'+i).remove();
|
|
$('#hideinvoiceid'+i).remove();
|
|
$('#hidecustomername'+i).remove();
|
|
$('#hideinvoiceamount'+i).remove();
|
|
$('#hideinvoicerecd'+i).remove();
|
|
|
|
}
|
|
|
|
}
|
|
function isNumberKey(evt)
|
|
{
|
|
var charCode = (evt.which) ? evt.which : evt.keyCode;
|
|
// Added to allow decimal, period, or delete
|
|
if (charCode == 110 || charCode == 190 || charCode == 46)
|
|
return true;
|
|
|
|
if (charCode > 31 && (charCode < 48 || charCode > 57))
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
function GetAmount(i)
|
|
{
|
|
|
|
var amount= parseFloat( $('#invoicereceived'+i).val() == '' ? '0.00' : $('#invoicereceived'+i).val());
|
|
|
|
var negative=0;
|
|
if(amount<0)
|
|
{
|
|
negative=1;
|
|
alert("Invalid Amount")
|
|
$('#invoicereceived'+i).val('');
|
|
}
|
|
var x = document.getElementById('checkboxcheckbox'+i).checked;
|
|
if(x==true && negative == 0)
|
|
{
|
|
|
|
var date= document.getElementById ( "invoicedate"+i ).innerText;
|
|
var invid =document.getElementById ( "invoice_id"+i ).innerText;
|
|
var cusname =document.getElementById ("client_name"+i ).innerText;
|
|
var invoiceamount =document.getElementById ("invoice_paid"+i ).innerText;
|
|
|
|
var invoicereceived=document.getElementById ("invoice_balance"+i ).innerText;
|
|
|
|
for(k=1;k<=i;k++)
|
|
{
|
|
var idcheck=$('#hideinvoiceid'+k).val();
|
|
if(invid==idcheck)
|
|
{
|
|
var cid=k;
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
if(amount<=invoiceamount)//amount value is less than or equal to invoice received value means
|
|
{
|
|
|
|
$('#hideinvoicedate').val(date);
|
|
$('#hideinvoiceid'+cid).val(invid);
|
|
$('#hidecustomername'+cid).val(cusname);
|
|
$('#hideinvoiceamount'+cid).val(invoiceamount);
|
|
$('#hideinvoicerecd'+cid).val(amount);
|
|
var totalvalue=$('#addvalue').val();
|
|
var bid=$('#bankid').val();
|
|
}
|
|
else
|
|
{
|
|
alert('You are exceeding the payment get!!');
|
|
$('#invoicereceived'+i).val(amount)
|
|
location.reload();
|
|
|
|
}
|
|
|
|
|
|
$.each(tempinvoice, function( index, value )
|
|
{
|
|
var res2 = value.split('-');
|
|
if(res2[1] == invid){
|
|
|
|
tempinvoice[index] = i+'-'+invid+'-'+amount;
|
|
}
|
|
});
|
|
calculategrandtotal();
|
|
|
|
}
|
|
}
|
|
|
|
function calculategrandtotal(){
|
|
|
|
$.each(tempinvoice, function( index, value )
|
|
{
|
|
var res2 = value.split('-');
|
|
tempTotal[index]=parseFloat(res2[2]);
|
|
});
|
|
//console.log(tempTotal);
|
|
var sum = 0;
|
|
|
|
for (var i = 0; i < tempTotal.length; i++) {
|
|
sum += tempTotal[i] << 0;
|
|
}
|
|
$('#addvalue').val(parseFloat(sum).toFixed(2));
|
|
|
|
}
|
|
|
|
function Save()
|
|
{
|
|
$('#content').loader('show');
|
|
var totalvalue=$('#addvalue').val();
|
|
|
|
var rowCount = $('#Rowid').val();
|
|
|
|
var check= 0;
|
|
var rw= 0;
|
|
for(i=1;i<=rowCount;i++)
|
|
{
|
|
|
|
var arrval = tempinvoice[i-1];
|
|
var number = arrval.split('-');
|
|
number = number[0];
|
|
|
|
//alert('rowcount'+i+'selectedcheckboxnumber'+number+'tempinvoice'+arrval);
|
|
rw= parseFloat(rw)+1;
|
|
check = parseFloat(check)+1;
|
|
var bankdebitamount=$('#debitamount').val();
|
|
|
|
var bid=$('#bankid').val();
|
|
|
|
var date =$('#hideinvoicedate'+number).val();
|
|
|
|
var invid =$('#hideinvoiceid'+number).val();
|
|
|
|
var customername=$('#hidecustomername'+number).val();
|
|
|
|
var invoiceamount=$('#hideinvoiceamount'+number).val();
|
|
|
|
var amountreceived=$('#hideinvoicerecd'+number).val();
|
|
|
|
var invoicereceived=$('#invoicereceived'+number).val();
|
|
|
|
//var payment = parseFloat(invoiceamount);
|
|
if(parseFloat(totalvalue)<=parseFloat(bankdebitamount))
|
|
{
|
|
|
|
$.ajax(
|
|
{
|
|
data:{date:date,invid:invid,cname:customername,invamount:invoiceamount,ar:amountreceived,rc:rowCount,tpv:totalvalue,bda:bankdebitamount,bi:bid,check:check,rw:rw,invrec:invoicereceived},
|
|
type:"POST",
|
|
url:"<?php echo base_url() ?>cashbook/invoiceamount1",
|
|
success:function(data)
|
|
{
|
|
if(data)
|
|
{
|
|
//alert('Saved Successfully');
|
|
window.location.href ="Bankingstatement";
|
|
|
|
}
|
|
}
|
|
});
|
|
}
|
|
else{
|
|
|
|
alert('You are payment exceeding');
|
|
location.reload();
|
|
}
|
|
// j=j+1;
|
|
}
|
|
}
|
|
</script>
|
|
<script>
|
|
$( function() {
|
|
//var dateFormat = "mm/dd/yy",
|
|
from = $( "#min-date" )
|
|
.datepicker({
|
|
dateFormat: "dd-mm-yy",
|
|
defaultDate: "+0d",
|
|
changeMonth: true,
|
|
//numberOfMonths: 1
|
|
|
|
})
|
|
.on( "change", function() {
|
|
to.datepicker("option", "minDate", getDate( this ) );
|
|
}),
|
|
to = $( "#max-date" ).datepicker({
|
|
dateFormat: "dd-mm-yy",
|
|
defaultDate: "+0d",
|
|
changeMonth: true,
|
|
//numberOfMonths: 1
|
|
|
|
})
|
|
.on( "change", function() {
|
|
from.datepicker( "option", "maxDate", getDate( this ) );
|
|
});
|
|
|
|
function getDate( element ) {
|
|
var date;
|
|
|
|
try {
|
|
date = $.datepicker.parseDate( dateFormat, element.value );
|
|
|
|
} catch( error ) {
|
|
date = null;
|
|
}
|
|
|
|
return date;
|
|
}
|
|
} );
|
|
</script>
|