335 lines
14 KiB
PHP
335 lines
14 KiB
PHP
<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">
|
||
<div id="totals" style="margin-bottom: 10px;">
|
||
<strong>Total Premium:</strong> <span id="total_premium">0.00</span> |
|
||
<strong>Total Rewards:</strong> <span id="total_rewards">0.00</span> |
|
||
<strong>Total IRDA Revenue INR:</strong> <span id="total_irda">0.00</span> |
|
||
<strong>Total Billed Amount:</strong> <span id="total_billed">0.00</span> |
|
||
<strong>Total Unbilled Amount:</strong> <span id="total_unbilled">0.00</span> |
|
||
<strong>Total Policy Count:</strong> <span id="total_policy_count"><?= $policy_count ?></span>
|
||
</div>
|
||
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
|
||
<thead class="bg-light">
|
||
<tr>
|
||
<th>S. No</th>
|
||
<th>User</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>Rewards</th>
|
||
<th>Total IRDA <br> Revenue INR</th>
|
||
<th>Billed Amount</th>
|
||
<th>UnBilled Amount</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['user_name']; ?></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']; ?> %</td>
|
||
<td class="right-align-input"><?php echo $row['agreed_tp_or_ter_per'];?> %</td>
|
||
<td class="right-align-input"><?php echo isset($row['reward']) ? $row['reward'] : '0.00'; ?></td>
|
||
|
||
<?php $total_irda_amt = empty($row['total_irda_amt']) ? $row['exp_amt'] : $row['total_irda_amt']; ?>
|
||
<td class="right-align-input" onclick="showCoShareStatementDetails(this)" data-id="<?= $row['pt_id'] ?>"><?php echo $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> -->
|
||
<?php
|
||
$unbilled_amt = $row['total_irda_amt'] - $row['billed_amt'];
|
||
$unbilled_amt = $unbilled_amt == 0 && $row['billed_amt'] == 0 ? $total_irda_amt : $unbilled_amt ;
|
||
?>
|
||
<td class="right-align-input"><?php echo number_format((float)$unbilled_amt,2, '.', '')?></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);
|
||
},
|
||
exportOptions: {
|
||
orthogonal: 'sort'
|
||
},
|
||
customizeData: function (data) {
|
||
for (var i = 0; i < data.body.length; i++) {
|
||
for (var j = 0; j < data.body[i].length; j++) {
|
||
// Check if the column is the 9th index (10th column) and 10th index (11th column)
|
||
if (j === 9 || j === 10) {
|
||
data.body[i][j] = '\u200C' + data.body[i][j];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
],
|
||
language: {
|
||
search: "_INPUT_",
|
||
searchPlaceholder: "Search..."
|
||
},
|
||
paging: true, // Enable pagination
|
||
pageLength: 25, // Set default number of rows per page (optional)
|
||
ordering: false,
|
||
"footerCallback": function(row, data, start, end, display) {
|
||
var api = this.api();
|
||
|
||
// Calculate column totals
|
||
var totalPremium = api.column(23).data().reduce(function(a, b) {
|
||
return parseFloat(a) + parseFloat(b) || 0;
|
||
}, 0);
|
||
|
||
var total_rewards = api.column(26).data().reduce(function(a, b) {
|
||
return parseFloat(a) + parseFloat(b) || 0;
|
||
}, 0); // Add initial value 0 here
|
||
|
||
console.log('total_rewards - ' + total_rewards);
|
||
|
||
var totalIrda = api.column(27).data().reduce(function(a, b) {
|
||
return parseFloat(a) + parseFloat(b) || 0;
|
||
}, 0);
|
||
|
||
var totalBilled = api.column(28).data().reduce(function(a, b) {
|
||
return parseFloat(a) + parseFloat(b) || 0;
|
||
}, 0);
|
||
|
||
var totalUnbilled = api.column(29).data().reduce(function(a, b) {
|
||
return parseFloat(a) + parseFloat(b) || 0;
|
||
}, 0);
|
||
|
||
// Update the totals in the div above the table
|
||
$('#total_premium').text(totalPremium.toFixed(2));
|
||
$('#total_rewards').text(total_rewards.toFixed(2));
|
||
$('#total_irda').text(totalIrda.toFixed(2));
|
||
$('#total_billed').text(totalBilled.toFixed(2));
|
||
$('#total_unbilled').text(totalUnbilled.toFixed(2));
|
||
}
|
||
});
|
||
} 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>
|