nhance-enrollment/app/Views/report_bds.php

271 lines
11 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<style>
.table th,
.table td {
padding: 8px;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
.col-12 {
max-width: 98% !important;
}
.dataTables_filter {
position: absolute;
}
.right-align-input {
text-align: right;
}
</style>
<div class="col-12" id="second_page">
<div class="card">
<div class="card-body">
<div class="row" style="padding-bottom: 10px;">
<div class="col-6" style="align-self: center;">
<h4 style="position: relative;">BDS Report <span id="bds_title"></span></h4>
</div>
</div>
<div class="table-responsive">
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead class="bg-light">
<tr>
<th>S. No</th>
<th>Month</th>
<th>Business Type</th>
<th>Client Type</th>
<th>Insured Name</th>
<th>Policy/<br>Endorsement</th>
<th>Policy Type</th>
<th>BAP Group</th>
<th>Vehicle Number</th>
<th>Policy No</th>
<th>Endorsement No</th>
<th>Insurer Name</th>
<th>Insurer Branch</th>
<th>TPA</th>
<th>Endorsement <br> Effective Date</th>
<th>Policy <br> Effective Date</th>
<th>Policy <br> Expiry Date</th>
<th>Reference</th>
<th>Remarks</th>
<th>Base Premium</th>
<th>Terrorism/TP</th>
<th>Premium <br> (without GST)</th>
<th>GST @ 18%</th>
<th>Total Premium</th>
<th>Base <br> Revenue %</th>
<th>TP / Terrorism <br> Revenue %</th>
<th>Total IRDA <br> Revenue INR</th>
<th>Billed Amount</th>
<th>UnBilled Amount</th>
<th>Rewards</th>
</tr>
</thead>
<tbody>
<?php if (isset($report_list)) { ?>
<?php foreach($report_list as $index => $row){ ?>
<tr>
<td><?= $index + 1 ?></td>
<td><?php echo $row['policy_issue_month']; ?></td>
<td><?php echo $row['revenue_type']; ?></td>
<td><?php echo $row['client_type']; ?></td>
<td><?php echo $row['client_name']; ?></td>
<td><?php echo $row['action_type']; ?></td>
<td><?php echo $row['policy_type']; ?></td>
<td><?php echo $row['bap']; ?></td>
<td><?php echo $row['vehicle_no'] ?? 'N.A'; ?></td>
<td><?php echo $row['policy_no']; ?></td>
<td><?php echo $row['endorsement_no']; ?></td>
<td><?php echo $row['insurer_name']; ?> </td>
<td><?php echo $row['insurer_branch_name']; ?></td>
<td><?php echo $row['tpa_name']; ?></td>
<td><?php echo empty($row['endorse_eff_date']) ? '' : date('d/m/Y', strtotime($row['endorse_eff_date'])) ?></td>
<td><?php echo empty($row['policy_start_date']) ? '' : date('d/m/Y', strtotime($row['policy_start_date'])); ?></td>
<td><?php echo empty($row['policy_end_date']) ? '' : date('d/m/Y', strtotime($row['policy_end_date'])); ?></td>
<td><?php echo $row['ref']; ?></td>
<td><?php echo $row['remarks']; ?></td>
<td class="right-align-input"><?php echo $row['bp_amt']; ?></td>
<td class="right-align-input"><?php echo $row['tp_or_ter']; ?></td>
<td class="right-align-input"><?php echo $row['premium_wo_gst']; ?></td>
<td class="right-align-input"><?php echo $row['gst_amount']; ?></td>
<td class="right-align-input"><?php echo $row['total_premium']; ?></td>
<td class="right-align-input"><?php echo $row['agreed_bp_per']; ?>&nbsp;%</td>
<td class="right-align-input"><?php echo $row['agreed_tp_or_ter_per'];?>&nbsp;%</td>
<td class="right-align-input" onclick="showCoShareStatementDetails(this)" data-id="<?= $row['pt_id'] ?>"><?php echo empty($row['total_irda_amt']) ? $row['exp_amt'] : $row['total_irda_amt']; ?></td>
<td class="right-align-input"><?php echo empty($row['billed_amt']) ? '0.00' : $row['billed_amt'] ?></td>
<!-- <td class="right-align-input"><?php echo empty($row['unbilled_amt']) ? '0.00' : $row['unbilled_amt']?></td> -->
<td class="right-align-input"><?php echo number_format((float)$row['total_irda_amt'] - $row['billed_amt'],2, '.', '')?></td>
<td class="right-align-input"><?php echo $row['reward']; ?></td>
</tr>
<?php } ?>
<?php } ?>
</tbody>
</table>
<div>
</div>
</div>
</div><!-- end col -->
</div>
</div>
<!-- modal content -->
<div class="modal fade" id="centermodal" tabindex="-1" role="dialog" aria-hidden="true" aria-modal="true" data-backdrop="static">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header" style="background-color: gainsboro;">
<h4 class="modal-title" id="myCenterModalLabel">Statement Details <span id="heading"></span></h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body" id="modal_body">
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead class="bg-light" id="table_head_data">
<tr>
<th>Statement No.</th>
<th>Statement Month</th>
<th>Actual Amount</th>
<th>Invoice No.</th>
<th>Invoice Date.</th>
<th>Invoice Status.</th>
</tr>
</thead>
<tbody id="table_data">
</tbody>
</table>
</div> <!-- end table-responsive-->
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-------------------------------------------------------------------------------------------------->
<script>
// Datatable document ready
$(document).ready(function() {
var ticketsTable = $('#scroll-horizontal-datatable');
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
buttons: [
{
extend: 'csv',
text: 'CSV',
title: 'Policy-Tranction-BDS-List',
},
{
extend: 'excel',
text: 'Excel',
title: 'Policy-Tranction-BDS-List',
customize: function(xlsx) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
var total = 0;
// Find cells in column AB (28th column in Excel)
$('row c[r^="AB"]', sheet).each(function() {
var value = parseFloat($('v', this).text()); // Get the value inside the cell
if (!isNaN(value)) {
total += value;
}
});
// Get the last row index and append the total row
var lastRow = $('row:last', sheet);
var rowIndex = parseInt(lastRow.attr('r')) + 2; // Find the next row index
var totalRow = '<row r="' + rowIndex + '">' +
'<c t="inlineStr" r="AA' + rowIndex + '"><is><t>Total</t></is></c>' + // Insert "Total" in AA
'<c t="n" r="AB' + rowIndex + '"><v>' + total.toFixed(2) + '</v></c>' + // Insert sum in AB
'</row>';
// Append the new total row to the sheet
$(sheet).find('sheetData').append(totalRow);
}
}
],
language: {
search: "_INPUT_",
searchPlaceholder: "Search..."
},
paging: true, // Enable pagination
pageLength: 25, // Set default number of rows per page (optional)
ordering: false,
});
} else {
console.error("Table atet found.");
}
});
// ----------------------------------------------------------------------------------------------------
function showCoShareStatementDetails(input){
let pt_id = $(input).data('id');
console.log('pt_id', pt_id)
var myModal = new bootstrap.Modal(document.getElementById('centermodal'));
myModal.show();
getCoShareStatementDetails(pt_id)
}
function getCoShareStatementDetails(pt_id){
let url = '<?= base_url('util/getCoShareStatementDetails/') ?>' + pt_id;
sendAjaxRequestForGlobal(url, 'GET', {}, function(response) {
console.log('Data fetched successfully:', response);
if (response.status === true) {
appendTableData(response.data)
} else {
toastr.warning(response.message, 'Warning');
}
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
});
}
function appendTableData(data) {
// Ensure the table body selector matches your table's structure
let tableBody = $("#table_data");
// Clear the table body before appending new rows
tableBody.empty();
// Loop through the data and append rows
data.forEach(row => {
let tableRow = `
<tr>
<td>${row.stmt_sno ?? '-'}</td>
<td>${row.month ?? '-'}</td>
<td>${row.sum_of_actual_amt ?? '-'}</td>
<td>${row.invoice_no ?? '-'}</td>
<td>${row.invoice_date ?? '-'}</td>
<td>${row.invoice_status ?? '-'}</td>
</tr>
`;
tableBody.append(tableRow);
});
}
</script>