BBnepal-Accounts/application/views/admin/invoice-reports.php
Sampanna Rimal 9cd05ef3cb commitall
2024-07-10 18:28:19 +05:45

448 lines
22 KiB
PHP

<style>
table.dataTable tfoot th {
font-weight: 600 !important;
}
.form-group .bootstrap-select>.dropdown-toggle {
padding: 9px 9px !important;
font-size: 12px !important;
border: 1px solid #c8c8c8 !important;
background: #fff !important;
}
</style>
<div class="wraper responsive-width">
<main class="long-tbl-main" id="main">
<!-- admin template section -->
<div class="admin_tempblock">
<div class="admin_tempsec">
<div class="admin_sec">
<div class="subsec_sec" style="display:block">
<div class="subject_lsec dashboard_graph report_sec_graph">
<div class="report_sec_cover">
<div class="report_sec_left">
<?php
$currency_symbol = $school_info['currency_symbol'];
$theExportHeader = 'The Fee Invoice Reports';
if (isset($school_info) && !empty($school_info)) {
$theExportHeader = $school_info['school_name'] . ' - Invoice Reports';
}
?>
</div>
<div class="subject_lhead">Invoice Reports</div>
<?php
$f_f_types = array();
$f_from_date = '';
$f_to_date = '';
$select_particular = '';
if (count($_POST) > 0) {
//echo '<pre>'; print_r($_POST);exit;
if (isset($_POST['filter_fee_types']) && !empty($_POST['filter_fee_types']))
$f_f_types = $_POST['filter_fee_types'];
$f_from_date = $_POST['filter_from_date'];
$f_to_date = $_POST['filter_to_date'];
$select_particular = $_POST['select_particular'];
if ($select_particular == 'today')
$theExportHeader .= ' For Today';
if ($f_from_date != '')
$theExportHeader .= ' From ' . $f_from_date;
if ($f_to_date != '')
$theExportHeader .= ' To ' . $f_to_date;
}
?>
<form action="<?= base_url(); ?>admin/invoice-reports" method="POST" id='searchInvoiceReports'>
<div class="row">
<div class="col-md-1">
<div class="filter_lbl">
<i class="fas fa-filter"></i>
Filter
</div>
</div>
<div class="col-md-3">
<div class="subject-filter">
<div class="form-group assign_fee_toall">
<label>Select Fees Type</label>
<select name="filter_fee_types[]" id="filter_fee_types" class=" form-control selectpicker" multiple data-live-search="true">
<option value="" disabled="">Select Fees Type</option>
<?php
if (!empty($all_fee_types)) {
foreach ($all_fee_types as $ftypes) {
?>
<option value="<?php echo $ftypes['id'] ?>" <?php if (in_array($ftypes['id'], $f_f_types)) { ?> selected <?php } ?>> <?php echo $ftypes['feetype_name'] ?> </option>
<?php
}
}
?>
</select>
</div>
</div>
</div>
<div class="col-md-2">
<div class="subject-filter">
<div class="form-group assign_fee_toall">
<label>Select Particular</label>
<select name="select_particular" id="select_particular" class="form-control selectpicker" onchange='manage_select_particular()'>
<option value=''>Select</option>
<option value='today' <?php if ($select_particular == 'today') { ?> selected <?php } ?>>Today</option>
<option value='select_date_range' <?php if ($select_particular == 'select_date_range') { ?> selected <?php } ?>>Select Date Range</option>
</select>
</div>
</div>
</div>
<div class="col-md-2 the-dates" style='display:none;'>
<div class="date-filter">
<div class="date-fil-row">
<label>Start Date</label>
<input type="text" name="filter_from_date" id="filter_from_date" class="form-control nepal-date" value="<?php echo $f_from_date; ?>" placeholder='yyyy-mm-dd'>
</div>
</div>
</div>
<div class="col-md-2 the-dates" style='display:none;'>
<div class="date-filter">
<div class="date-fil-row">
<label>End Date</label>
<input type="text" name="filter_to_date" id="filter_to_date" class="form-control nepal-date" value="<?php echo $f_to_date; ?>" placeholder='yyyy-mm-dd'>
</div>
</div>
</div>
<div class="col-md-2">
<div class="filter-reset">
<input type="button" name="filtersubmit" id="filter_reset1" class="btn btn-success" value="Filter" onclick="search_invoice_reports()">
<a href="<?php echo base_url() ?>admin/invoice-reports">
<button type="button" name="reset_filter" id="reset_filter" value="reset_filter" class="subject_addbtn subject_addbtn_nobg">
<i class="fas fa-redo"></i>Reset
</button>
</a>
</div>
</div>
</div>
</form>
<!-- tab added -->
<!-- new divs added -->
<div class="tab-content">
<!-- new divs added -->
<div class="applicnts-list-wrap ">
<div class=" ">
<!-- changed ID -->
<table id="tbl1" class="display table-responsive text-center">
<thead>
<tr>
<th>S.No</th>
<th>Date</th>
<th>Invoice No</th>
<th>Student Name</th>
<th>Class</th>
<th>Roll No</th>
<?php
if (isset($selected_fee_types) && !empty($selected_fee_types)) {
foreach ($selected_fee_types as $sftypes) {
?>
<th><?php echo $sftypes['feetype_name']; ?></th>
<?php
}
}
?>
<th>Discount</th>
<th>Fine</th>
<th>Total Paid</th>
</tr>
</thead>
<tbody>
<?php
$tdCnt = 1;
if (isset($the_results) && !empty($the_results)) {
// echo '
// <pre>';
// print_r($the_results);
$sno = 1;
foreach ($the_results as $res) {
$tdCnt = 9;
?>
<tr>
<td><?php echo $sno; ?></td>
<td><?php echo date('d-m-Y', strtotime($res['payment_date'])); ?></td>
<td><?php echo $res['invoice_no']; ?></td>
<td><?php echo $res['std_name']; ?></td>
<td><?php echo $res['classroom_name']; ?></td>
<td><?php echo $res['roll_no']; ?></td>
<?php
if (isset($selected_fee_types) && !empty($selected_fee_types)) {
$theRowTotal = 0;
foreach ($selected_fee_types as $sftypes) {
$theRowTotal = ($theRowTotal + $res[$sftypes['feetype_name']]);
// echo '=> Deduction Amount = ' . $totalDeductionAmount;
?>
<td><?php echo $res[$sftypes['feetype_name']]; ?></td>
<?php
$tdCnt++;
}
}
?>
<?php
$a = 0;
$totalDeductionAmount = 0;
$deduction_amt_arr = explode(",", $res['deduction_amt']);
// print_r(count($deduction_amt_arr));
// print_r(($deduction_amt_arr));
for ($x = 0; $x < count($deduction_amt_arr); $x++) {
// echo
// $deduction_amt_arr[$x];
$totalDeductionAmount = $totalDeductionAmount + $deduction_amt_arr[$x];
}
$totalFineAmount = 0;
$fine_amt_arr = explode(",", $res['fine_amt']);
for ($y = 0; $y < count($fine_amt_arr); $y++) {
$totalFineAmount = $totalFineAmount + $fine_amt_arr[$y];
}
?>
<td style='font-size: 13px;'><?= $totalDeductionAmount; ?></td>
<td style='font-size: 13px;'><?= $totalFineAmount; ?></td>
<td style='font-size: 13px;'><?= $theRowTotal - $totalDeductionAmount + $totalFineAmount; ?></td>
</tr>
<?php
$sno++;
}
}
?>
<tfoot>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<!-- <th></th> -->
<th>In <?php echo $currency_symbol; ?></th>
<?php
if (isset($selected_fee_types) && !empty($selected_fee_types)) {
foreach ($selected_fee_types as $sftypes) {
?>
<th style='font-size: 13px;'></th>
<?php
}
}
?>
<th></th>
<th></th>
<th></th>
</tr>
</tfoot>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- admin template section end -->
</main>
<!--End right-top side-->
</div>
<script defer src="<?php echo base_url(); ?>assets_admin/js/bootstrap-select.min.js"></script>
<script>
var theTdCnt = '<?php echo $tdCnt; ?>';
var theTdStr = new Array();
for (let n = 0; n < theTdCnt; n++) {
theTdStr.push(n);
}
//alert(theTdCnt);
var jsSdate = '<?php echo $f_from_date; ?>';
var jsTdate = '<?php echo $f_to_date; ?>';
//alert(jsSdate+' = '+jsTdate);
var jsTheExportHeader = '<?php echo $theExportHeader; ?>';
$(document).ready(function() {
$('.user-drpdown').click(function() {
$('.drpdown-items').toggle();
});
var currency_symbol = "<?php echo $currency_symbol; ?>";
//table js
$('#tbl1').DataTable({
"lengthMenu": [
[100, -1],
[100, "All"]
],
"dom": 'lBfrtip',
"buttons": [{
extend: 'pdfHtml5',
header: true,
footer: true,
title: jsTheExportHeader,
customize: function(doc) {
var rowCount = document.getElementById("tbl1").rows.length;
//alert(rowCount);
for (i = 0; i < rowCount; i++) {
for (j = 0; j < theTdCnt; j++) {
doc.content[1].table.body[i][j].alignment = 'center';
}
}
doc.styles.table = {
alignment: 'center'
}
},
exportOptions: {
columns: theTdStr,
alignment: 'center',
modifier: {
page: 'current'
}
},
orientation: 'landscape',
pageSize: 'LEGAL'
},
{
extend: 'csvHtml5',
exportOptions: {
columns: theTdStr
}
},
{
extend: 'excelHtml5',
header: true,
footer: true,
title: jsTheExportHeader,
exportOptions: {
columns: "thead th:not(.noExport)",
rows: function(indx, rowData, domElement) {
return $(domElement).css("display") != "none";
}
},
customize: function(xlsx) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
$('row c[r^="C"]', sheet).attr('s', '2');
}
}
],
"footerCallback": function(row, data, start, end, display) {
//var theDynTdCnt = (theTdCnt - 7);
for (let fi = 6; fi < theTdCnt; fi++) {
var api = this.api(),
data;
// Remove the formatting to get integer data for summation
var intVal = function(i) {
return typeof i === 'string' ?
i.replace(/[\$,]/g, '') * 1 :
typeof i === 'number' ?
i : 0;
};
// Total over all pages
total = api
.column(fi)
.data()
.reduce(function(a, b) {
return intVal(a) + intVal(b);
}, 0);
// Total over this page
pageTotal = api
.column(fi, {
page: 'current'
})
.data()
.reduce(function(a, b) {
return intVal(a) + intVal(b);
}, 0);
$(api.column(fi).footer()).html(
//currency_symbol + ' ' + pageTotal + ' ( ' + currency_symbol + ' ' + total + ' total )'
pageTotal
);
}
}
});
//table js end
//multiple select js start
$('#filter_fee_types').selectpicker();
//multiple select js end
manage_select_particular();
});
function manage_select_particular() {
if ($('#select_particular').val() == 'select_date_range') {
$('#filter_from_date').val(jsSdate);
$('#filter_to_date').val(jsTdate);
$('.the-dates').show();
} else {
$('#filter_from_date').val('');
$('#filter_to_date').val('');
$('.the-dates').hide();
}
}
function search_invoice_reports() {
$('#searchInvoiceReports').submit();
}
</script>
</body>
</html>