ria/app/Views/bankstatement.php
2024-09-11 08:54:25 +05:30

797 lines
22 KiB
PHP
Executable File

<?php
foreach($financialyear as $item)
{
$finyear = $item->financial_year;
} ?>
<?php
foreach($bankreport as $t)
{
$Bankname = $t->Bankname;
} ?>
<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" style="font-size: 12px;">
<div id="content"></div>
<!-- TABLE: LATEST ORDERS. -->
<div class="box box-info">
<center><h3 class="box-title"><p style="color: #00d976;"><b>Bank Report</b></p></h3></center>
<div class="box-body">
<?php
// $attributes = array('class' => 'form-label-left bankdata ','name' => 'bankdata','id' => 'bankdata');
// echo form_open(base_url().'/cashbook/bankdebitdata/',$attributes); ?>
<form method="post" action="<?php echo base_url($this->uri->uri_string()); ?>">
<div class="modal" id="myModaldebit" role="dialog">
<div class="modal-dialog modal-sm">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<!-- <button type="button" class="close" data-dismiss="modal">&times;</button> -->
<h4 class="modal-title">Select Options</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-12">
<div class="col-md-12">
<div title="Select Your Option">
<!-- <option value="-1" style="color:#FFF;">Select Option</option>
<option value="1">Sales Receipts</option>
<option value="2">Purchase Payments</option>
<option value="3">Income/Expense</option> -->
<!-- <input type="radio" name="selectedId" id="selectedId<?php echo $i?>" onchange="checkscreen(<?php echo $i?>);" value="1"> <label for="contactChoice2">Sales Receipts</label><br>-->
<input type="radio" name="selectedId" id="selectedId<?php echo $i?>" onchange="checkscreen(<?php echo $i?>);" value="2"> <label for="contactChoice2">Purchase Payments</label><br>
<input type="radio" name="selectedId" id="selectedId<?php echo $i?>" onchange="checkscreen(<?php echo $i?>);" value="3"> <label for="contactChoice2">Income/Expense</label><br>
</div>
</div>
<div class="col-md-2">
<input type="hidden" name="Rowid" id="Rowid">
</div>
<div class="col-md-2">
<input type="hidden" id="addvalue" name="addvalue">
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" id="myCheckBoxCanceldebit" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div class="row">
<div class="modal" id="myModalcredit" role="dialog">
<div class="modal-dialog modal-sm">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<!-- <button type="button" class="close" data-dismiss="modal">&times;</button> -->
<h4 class="modal-title">Select Options</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-12">
<div class="col-md-12">
<div title="Select Your Option">
<!-- <option value="-1" style="color:#FFF;">Select Option</option>
<option value="1">Sales Receipts</option>
<option value="2">Purchase Payments</option>
<option value="3">Income/Expense</option> -->
<input type="radio" name="selectedId" id="selectedId<?php echo $i?>" onchange="checkscreen(<?php echo $i?>);" value="1"> <label for="contactChoice2">Sales Receipts</label><br>
<!--<input type="radio" name="selectedId" id="selectedId<?php echo $i?>" onchange="checkscreen(<?php echo $i?>);" value="2"> <label for="contactChoice2">Purchase Payments</label><br>-->
<input type="radio" name="selectedId" id="selectedId<?php echo $i?>" onchange="checkscreen(<?php echo $i?>);" value="3"> <label for="contactChoice2">Income/Expense</label><br>
</div>
</div>
<div class="col-md-2">
<input type="hidden" name="Rowid" id="Rowid">
</div>
<div class="col-md-2">
<input type="hidden" id="addvalue" name="addvalue">
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" id="myCheckBoxCancelcredit" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-2">
<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-2">
<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-2" style="margin-top:24px;">
<select class="form-control" id="financialyear" name="financialyear">
<option value="">Select Year</option>
<?php
foreach($finyear as $item):
{?>
<option value="<?php echo $item->financial_year;?>"><?php echo $item->financial_year ; ?></option>
<?php } endforeach; ?>
</select>
</div>
<?php
if(!empty($bankreport)){
foreach($bankreport as $t)
{
$status=$t->Status;
$type=0;
if(!empty($t->Debit))
{
$type = 1;
}
}
}
?>
<div class="col-md-2" style="margin-top:24px;">
<input type="submit" class="btn btn-success" name="btn_submit"
value="View Report">
</div>
</form>
<br>
<br>
<br>
<center><h3>Bank Name:<?php echo $Bankname?></h3></center>
<table class="table table-bordered table-hover" data-order='[[1,"desc"]]' id="req" style="table-layout:auto;">
<thead>
<tr>
<th>S.No</th>
<th>Select</th>
<th>Date</th>
<th>Cheque No</th>
<th>Narration</th>
<th style="text-align:right;"> Debit (&#8377;)</th>
<!--<th style="text-align:right;">Balance (&#8377;)</th>-->
<th style="text-align:right;"> Cleard Balance (&#8377;)</th>
<th style="text-align:right;"> Balance to Clear (&#8377;)</th>
<!-- <th style="text-align:right;"> Status </th> -->
<th style="text-align:right;"> Credit (&#8377;)</th>
<th style="text-align:right;"> Cleard Balance (&#8377;)</th>
<th style="text-align:right;"> Balance to Clear (&#8377;)</th>
<th>Status</th>
<th>Balance</th>
</tr>
</thead>
<tbody>
<?php
$i=1;
$ti=0.00;
$tvt=0.00;
if(!empty($bankreport)){
foreach($bankreport as $t)
{
$debit=$t->Debit;
$status=$t->Status;
$type=0;
//if(!empty($t->Debit))
if($t->Debit != 0.00)
{
$type = 1;
}
?>
<tr>
<td align="left" id="bankid<?php echo $i ?>"><span><?php echo $t->ID?></span></td>
<td data-name="sell"><input type="checkbox" onchange="checkamount(<?php echo $type ?>,<?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 $t->date?></span></td>
<!-- <td align="left"><span><?php echo $t->valuedate?></span></td> -->
<!-- <td align="left"><span><?php echo $t->Bankname?></span></td> -->
<td align="left"><span><?php echo $t->chequeNo?></span></td>
<td align="left" id="narration<?php echo $i ?>"><span><?php echo $t->Narration?></span></td>
<!-- <td align="left"><span><?php echo $t->Cod?></span></td> -->
<td align="left" id="debit<?php echo $i ?>"><span><?php echo $t->Debit;?></span></td>
<?php
$clearbalance=$t->Clearbalance;
?>
<td align="left" id="totalpaid<?php echo $i?>"><a href="<?php echo base_url() ?>MappingPo?d=<?php echo $t->ID?>&clearbalance=<?php echo $clearbalance;?>&balancetoclear=<?php echo $t->Debit-$clearbalance;?>"><span><?php echo $clearbalance?></a></span></td>
<?php
if($status=='CLOSE')
{
?>
<td align="left" id="btc<?php echo $i ?>"><span><?php echo ($t->Debit) - ($t->Clearbalance);?></span></td>
<?php
}
else
{
?>
<td align="left" id="btc<?php echo $i ?>"><?php echo $t->Debit-$clearbalance?></span></td>
<?php
}
?>
<!-- <td align="left"><span><?php echo $t->Status?></span></td> -->
<!-- <td align="left" id="dsta<?php echo $i ?>"><span><?php echo $t->Status?></span></td> -->
<td align="left" id="credit1<?php echo $i ?>"><span><?php echo $t->Credit;?></span></td>
<?php
$clearbalance=$t->cclearbalance;
$credit=$t->Credit;
$balanctoclear=$credit-$clearbalance;
?>
<td align="left" id="credit2<?php echo $i ?>"><a href="<?php echo base_url() ?>MappingInvoice?d=<?php echo $t->ID?>&cb=<?php echo $clearbalance?>&btc=<?php echo $balanctoclear?>"><span><?php echo $clearbalance?></a></span></td>
<td align="left" id="credited<?php echo $i ?>"><span><?php echo ($t->Credit)-($t->cclearbalance);?></span></td>
<td align="left" id="csta<?php echo $i ?>"><span><?php echo $t->cstatus?><?php echo $t->Status?></span></td>
<!-- <td align="left" id="dsta<?php echo $i ?>"><span><?php echo $t->Status?></span></td> -->
<!-- <td><?php echo $t->cstatus;?></td> -->
<td><?php echo $t->Balance;?></td>
</tr>
<?php
$i++;
}
}
?>
</tbody>
</table>
<input type="hidden" name="bankid1" id="bankid1">
</div>
</div>
</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 src="https://cdn.datatables.net/plug-ins/1.10.16/sorting/datetime-moment.js"></script>
<script>
var row=0;
var j=1;
//var tot11=0;
var tempidvalue=[];
var tempcredit=[];
var overalltype;
var before='';
var amounttype='';
var i1='';
var tpaid='';
var debit1='';
var credit1='';
var tcpaid='';
function checkamount(type,ide)
{
globalModelValue = ide;
var checkInput = document.getElementById("checkboxcheckbox"+ide);
var id=$('#dsta'+ide).text();
var idc=$('#csta'+ide).text();
if ($(checkInput).is(':checked'))
{
if(type==1 && id!= "CLOSE" )
{
$("#myModaldebit").modal({
backdrop: 'static',
eyboard: false
});
}
else if(type==0 && idc!= "CLOSE")
{
$("#myModalcredit").modal({
backdrop: 'static',
eyboard: false
});
}
else
{
// alert('status is ddd closed');
}
}
$('#myCheckBoxCanceldebit').click(function() {
//overalltype = undefined;
$('#checkboxcheckbox'+globalModelValue).attr('checked', false);
location.reload();
});
$('#myCheckBoxCancelcredit').click(function() {
//overalltype = undefined;
$('#checkboxcheckbox'+globalModelValue).attr('checked', false);
location.reload();
});
var value=ide;
//alert('row id'+value);
i1=value;
type2= type;
amounttype=type2;
var totalpaid= document.getElementById("totalpaid"+value).innerText;
tpaid=totalpaid;
//alert('Paid Amount'+tpaid);
var totalcreditpaid= document.getElementById("credit2"+value).innerText;
tcpaid=totalcreditpaid;
//alert(tcpaid);
var btp=document.getElementById ("btc"+value).innerText;
var x = document.getElementById('checkboxcheckbox'+value).checked;
//alert('checkbox staus'+x);
if (x==true)
{
//alert('check');
if(overalltype == type || overalltype == undefined) {
if(type==1){ // 1 means Debit, 0 means Credit
overalltype = 1;
row= parseInt(row)+1;
$('#Rowid').val(row);
var id=document.getElementById ("bankid"+value).innerText;
//alert(id+'id');
var debit=document.getElementById ("btc"+value ).innerText;
//alert(debit+'hd');
debit1=debit;
//alert('bal to pay'+ debit);
//alert('You have selected bankid=' +id+ '\n and your amount is=' +debit+ '\n Please select Poscreen');
var idvalue = id+'-'+debit;
//alert(idvalue);
tempidvalue.push(idvalue);
var total=0;
$.each(tempidvalue, function( index, value )
{
var debited = value.split('-');
var bankid=debited[0];
var debit=debited[1];
total=parseFloat(debit)+parseFloat(total);
$('#addvalue').val(parseFloat(total).toFixed(2));
});
if(debit==0)
{
alert('status is closed');
document.getElementById('checkboxcheckbox'+value).checked = false;
window.location.reload();
}
}
else{
overalltype = 0;
var id=document.getElementById ("bankid"+value).innerText;
var tempid = "credited"+value;
var credit=parseFloat(document.getElementById(tempid).innerText);
//alert(credit+'credit');
credit1=credit;
//alert('You have selected bankid=' +id+ '\n and your amount is=' +credit+ '\n Please select Invoice screen');
var idvalue1 = id+'-'+credit;
tempcredit.push(idvalue1);
console.log(tempcredit);
var totalcredit=0;
$.each(tempcredit, function( index, value)
{
var credited = value.split('-');
var bankidc=credited[0];
var creditc=credited[1];
totalcredit=parseFloat(creditc)+parseFloat(totalcredit);
$('#addvalue').val(parseFloat(totalcredit).toFixed(2));
});
}
}
else{
alert("Select One Row");
window.location.reload();
document.getElementById('checkboxcheckbox'+value).checked = false;
}
if(credit==0)
{
alert('status is closed');
document.getElementById('checkboxcheckbox'+value).checked = false;
window.location.reload();
}
}
else
{
//alert('uncheck');
var id=document.getElementById ("bankid"+value).innerText;
delamount= document.getElementById ( "debit"+value ).innerText;
var tempcid = "credited"+value;
delcredit= document.getElementById (tempcid).innerText;
//alert(delcredit+'dc');
var tote= $('#addvalue').val();
var afterdeltot= parseFloat(tote)- parseFloat(delamount);
var updatetotal=0;
var updatecredit=0;
var debitvalue = id+'-'+delamount;
var creditvalue= id+'-'+delcredit;
var a = tempidvalue.indexOf(debitvalue);
if(a!=-1)
{
tempidvalue.splice(a,1);
$.each(tempidvalue, function( index, value )
{
var debited = value.split('-');
var bankid=debited[0];
var debit=debited[1];
total=parseFloat(debit)+parseFloat(updatetotal);
$('#addvalue').val(parseFloat(total).toFixed(2));
});
}
var a = tempcredit.indexOf(creditvalue);
if(a!=-1)
{
//alert('credit');
tempcredit.splice(a,1);
console.log(tempcredit);
$.each(tempcredit, function( index, value )
{
var credited = value.split('-');
var bankid=credited[0];
var credit=credited[1];
//alert(credit+'credit');
total1=parseFloat(credit)+parseFloat(updatecredit);
//alert(total1+'addvalue');
$('#addvalue').val(parseFloat(total1).toFixed(2));
});
}
}
}
function checkscreen()
{
var i=i1;
var avalue= $('#addvalue').val();
localStorage.setItem('test',avalue);
var value= document.querySelector('input[name="selectedId"]:checked').value;
var id=$('#bankid'+i).text();
var date=$('#date'+i).text();
var debit=$('#debit'+i).text();
var alreadypaid=$('#totalpaid'+i).text();
var credit=$('#credit1'+i).text();
localStorage.setItem('totcredit', credit);
var narration=$('#narration'+i).text();
localStorage.setItem('narr',narration);
var alreadycredit=$('#credit2'+i).text();
localStorage.setItem('alreadyreceived',alreadycredit);
localStorage.setItem('paidedamount',alreadypaid);
var RowCount= $('#Rowid').val();
var idvalue = id+'-'+debit;
if(avalue=='')
{
//alert(avalue);
alert('you have select debit or credit');
window.location.reload();
}
else if(value=='2' && amounttype=='1')
{
if(avalue>0)
{
$('#content').loader('show');
localStorage.setItem('test1',tempidvalue);
localStorage.setItem('test', avalue);
localStorage.setItem('debitamount',debit);
localStorage.setItem('cddate',date);
localStorage.setItem('narration', narration)
window.location.href="Debitstatement";
}
else
{
alert('your amount is empty');
}
}
else if(value=='1' && amounttype=='0')
{
//alert(avalue);
if(avalue>0)
{
$('#content').loader('show');
//alert(tempidvalue);
localStorage.setItem('test2',tempcredit);
localStorage.setItem('tes', avalue);
localStorage.setItem('ccdate',date);
localStorage.setItem('narration', narration)
window.location.href="Invoice";
}
else
{
alert('your amount is empty');
document.getElementById('checkboxcheckbox'+i).checked = false;
}
}
else if(value=='3')
{
//alert(avalue)
if(avalue>0)
{
localStorage.setItem('typeamount',amounttype);
localStorage.setItem('bankiddebit',tempidvalue);
localStorage.setItem('test',avalue);
localStorage.setItem('debitamount',debit);
localStorage.setItem('bankidcredit',tempcredit);
localStorage.setItem('cbdate',date);
localStorage.setItem('narration', narration)
window.location.href="Bankcash";
}
else
{
alert('your amount is empty');
document.getElementById('checkboxcheckbox'+i).checked = false;
}
}
else
{
alert('you have must select correct option');
window.location.reload();
}
}
$(document).ready(function() {
$.fn.dataTable.moment( 'DD-MM-YYYY' );
table = $('#req').DataTable( {
"aaSorting": [[ 2, "desc" ]],
"info": true,
"autoWidth": false,
"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'
]
} );
} );
$( 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>