1132 lines
44 KiB
PHP
1132 lines
44 KiB
PHP
<?php
|
|
helper('datatable_view');
|
|
$vr_header_labels = [
|
|
'S.No', 'Client', 'Client Branch', 'Insurer', 'Insurer Branch', 'Policy Type', 'Policy No', 'Endorsement No',
|
|
'Premium', 'Statement Premium', 'Premium Variance', 'Expected Amount', 'Statement Amount', 'Variance',
|
|
];
|
|
$vr_col_count = count($vr_header_labels);
|
|
$vr_col_max_len = array_fill(0, $vr_col_count, 0);
|
|
for ($i = 0; $i < $vr_col_count; $i++) {
|
|
$vr_col_max_len[$i] = mb_strlen($vr_header_labels[$i]);
|
|
}
|
|
$varience_list = $varience_list ?? [];
|
|
foreach ($varience_list as $index => $row) {
|
|
$vr_col_max_len[0] = max($vr_col_max_len[0], mb_strlen((string) ($index + 1)));
|
|
$vr_col_max_len[1] = max($vr_col_max_len[1], mb_strlen((string) ($row['client_name'] ?? '')));
|
|
$vr_col_max_len[2] = max($vr_col_max_len[2], mb_strlen((string) ($row['client_branch_name'] ?? '')));
|
|
$vr_col_max_len[3] = max($vr_col_max_len[3], mb_strlen((string) ($row['insurer_name'] ?? '')));
|
|
$vr_col_max_len[4] = max($vr_col_max_len[4], mb_strlen((string) ($row['insurer_branch_name'] ?? '')));
|
|
$vr_col_max_len[5] = max($vr_col_max_len[5], mb_strlen((string) ($row['policy_type'] ?? '')));
|
|
$vr_col_max_len[6] = max($vr_col_max_len[6], mb_strlen((string) ($row['policy_no'] ?? '')));
|
|
$vr_col_max_len[7] = max($vr_col_max_len[7], mb_strlen((string) ($row['endorsement_no'] ?? '')));
|
|
$vr_col_max_len[8] = max($vr_col_max_len[8], mb_strlen((string) ($row['original_premium'] ?? '')));
|
|
$vr_col_max_len[9] = max($vr_col_max_len[9], mb_strlen((string) (isset($row['statement_premium']) ? $row['statement_premium'] : '0.00')));
|
|
$vr_col_max_len[10] = max($vr_col_max_len[10], mb_strlen((string) ($row['premium_variance_amt'] ?? '')));
|
|
$vr_col_max_len[11] = max($vr_col_max_len[11], mb_strlen((string) ($row['exp_amt'] ?? '')));
|
|
$vr_col_max_len[12] = max($vr_col_max_len[12], mb_strlen((string) (isset($row['statement_amount']) ? $row['statement_amount'] : '0.00')));
|
|
$vr_col_max_len[13] = max($vr_col_max_len[13], mb_strlen((string) (isset($row['variance_amt']) ? $row['variance_amt'] : '0.00')));
|
|
}
|
|
$vr_col_min_px = array_fill(0, $vr_col_count, 88);
|
|
$vr_col_min_px[0] = 48;
|
|
$vr_col_max_px = array_fill(0, $vr_col_count, 360);
|
|
$vr_col_max_px[0] = 64;
|
|
$vr_col_width_px = nhance_dt_column_widths_px($vr_header_labels, $vr_col_max_len, $vr_col_min_px, $vr_col_max_px);
|
|
?>
|
|
<style>
|
|
.table th,
|
|
.table td {
|
|
padding: 8px;
|
|
}
|
|
|
|
table.dataTable tbody td {
|
|
padding: 4px 4px !important;
|
|
}
|
|
|
|
.dataTables_filter {
|
|
position: absolute;
|
|
}
|
|
|
|
.column-header {
|
|
margin-right: 10px;
|
|
}
|
|
|
|
.form-section {
|
|
border: 1px solid #ccc;
|
|
padding: 15px;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.row-box {
|
|
border: 1px solid #ccc;
|
|
padding: 10px;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.custom-dropdown-menu {
|
|
display: none;
|
|
position: fixed;
|
|
background-color: #ffffff !important;
|
|
border: 1px solid rgba(0, 0, 0, .15);
|
|
border-radius: 0.25rem;
|
|
padding: 0.5rem 0;
|
|
min-width: 10rem;
|
|
z-index: 9999;
|
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.custom-dropdown-menu .dropdown-item {
|
|
display: block !important;
|
|
width: 100% !important;
|
|
padding: 0.5rem 1rem !important;
|
|
clear: both !important;
|
|
font-weight: 400 !important;
|
|
color: #212529 !important;
|
|
text-align: inherit !important;
|
|
white-space: nowrap !important;
|
|
background-color: transparent !important;
|
|
border: 0 !important;
|
|
text-decoration: none !important;
|
|
position: relative !important;
|
|
}
|
|
|
|
.custom-dropdown-menu .dropdown-item:hover {
|
|
background-color: #f8f9fa !important;
|
|
color: #16181b !important;
|
|
cursor: pointer !important;
|
|
}
|
|
|
|
.custom-dropdown-menu .dropdown-item i {
|
|
margin-right: 8px !important;
|
|
vertical-align: middle !important;
|
|
}
|
|
|
|
.table tbody tr {
|
|
cursor: pointer;
|
|
}
|
|
|
|
.custom-dropdown-menu::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
background: #ffffff;
|
|
z-index: -1;
|
|
}
|
|
|
|
.custom-dropdown-menu::after {
|
|
content: '';
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
background: rgba(0, 0, 0, 0.05);
|
|
z-index: -2;
|
|
pointer-events: none;
|
|
}
|
|
.filter-sidebar {
|
|
height: 100%;
|
|
width: 0;
|
|
position: fixed;
|
|
z-index: 1001;
|
|
top: 0;
|
|
right: 0;
|
|
background-color: #f8f9fa;
|
|
overflow-x: hidden;
|
|
transition: 0.5s;
|
|
box-shadow: -2px 0 5px rgba(0,0,0,0.1);
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.filter-sidebar-header {
|
|
padding: 15px 20px;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
border-bottom: 1px solid #dee2e6;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.filter-sidebar-header .closebtn {
|
|
font-size: 28px;
|
|
text-decoration: none;
|
|
color: #6c757d;
|
|
}
|
|
|
|
.filter-sidebar .closebtn:hover {
|
|
color: #000;
|
|
}
|
|
|
|
.filter-sidebar-content {
|
|
padding: 20px;
|
|
flex-grow: 1;
|
|
overflow-y: auto;
|
|
}
|
|
|
|
.filter-sidebar-footer {
|
|
padding: 15px 20px;
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
border-top: 1px solid #dee2e6;
|
|
flex-shrink: 0;
|
|
gap: 10px;
|
|
}
|
|
</style>
|
|
|
|
<style>
|
|
.table th,
|
|
.table td {
|
|
padding: 8px;
|
|
}
|
|
|
|
table.dataTable tbody td {
|
|
padding: 4px 4px !important;
|
|
}
|
|
|
|
|
|
|
|
.dataTables_filter {
|
|
position: absolute;
|
|
}
|
|
|
|
.right-align-input {
|
|
text-align: right;
|
|
}
|
|
|
|
.center-align-input {
|
|
text-align: center;
|
|
}
|
|
.dataTables_length label {height: 21px !important;}
|
|
</style>
|
|
|
|
<style>
|
|
<?php for ($i = 0; $i < $vr_col_count; $i++) : ?>
|
|
#variance-report-list-table_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
|
|
#variance-report-list-table thead th:nth-child(<?= $i + 1 ?>) {
|
|
min-width: <?= (int) $vr_col_width_px[$i] ?>px;
|
|
width: <?= (int) $vr_col_width_px[$i] ?>px;
|
|
box-sizing: border-box;
|
|
vertical-align: middle;
|
|
overflow: visible !important;
|
|
}
|
|
#variance-report-list-table tbody td:nth-child(<?= $i + 1 ?>) {
|
|
width: <?= (int) $vr_col_width_px[$i] ?>px;
|
|
max-width: <?= (int) $vr_col_width_px[$i] ?>px;
|
|
min-width: <?= (int) $vr_col_width_px[$i] ?>px;
|
|
box-sizing: border-box;
|
|
vertical-align: middle;
|
|
}
|
|
<?php endfor; ?>
|
|
#variance-report-list-table tbody td {
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
padding: 5px 11px !important;
|
|
font-size: 13px;
|
|
line-height: 1.25;
|
|
}
|
|
#variance-report-list-table thead th {
|
|
padding: 5px 2.35rem 5px 11px !important;
|
|
font-size: 13px;
|
|
line-height: 1.25;
|
|
}
|
|
</style>
|
|
|
|
<div class="container-fluid-min">
|
|
<div id="filter-sidebar" class="filter-sidebar">
|
|
<div class="filter-sidebar-header">
|
|
<h4 class="m-0">Filter</h4>
|
|
<a href="javascript:void(0)" class="closebtn" onclick="closeFilterNav()">×</a>
|
|
</div>
|
|
<div class="filter-sidebar-content">
|
|
<div class="form-group">
|
|
<div class="form-row">
|
|
|
|
<div class="form-group col-md-12">
|
|
<label for="client_branch">Client<span class="text-danger"></span></label>
|
|
<select class="form-control" id="client_id" name="client_id" onchange="getClientPolicyDataBasedOnClientAndInsuer()">
|
|
<option value="0">Select Client</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group col-md-12">
|
|
<label for="client_branch_id">Client Branch<span class="text-danger"></span></label>
|
|
<select class="form-control" id="client_branch_id" name="client_branch_id" onchange="getClientPolicyDataBasedOnClientAndInsuer()">
|
|
<option value="0">Select Client Branch</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group col-md-12">
|
|
<label for="insurer_id"> Insurer <span id="base_danger" class="text-danger"></span></label>
|
|
<select class="form-control" id="insurer_id" name="insurer_id" onchange="getClientPolicyDataBasedOnClientAndInsuer()">
|
|
<option value="0" selected>Select Insurer</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group col-md-12">
|
|
<label for="insurer_branch_id"> Insurer Branch <span id="base_danger" class="text-danger"></span></label>
|
|
<select class="form-control" id="insurer_branch_id" name="insurer_branch_id" onchange="getClientPolicyDataBasedOnClientAndInsuer()">
|
|
<option value="0" selected>Select Insurer Branch</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group col-md-12">
|
|
<label for="email"> Policy Type <span class="text-danger"></span></label>
|
|
<select class="form-control" id="policy_type_id" name="policy_type_id" onchange="getClientPolicyDataBasedOnClientAndInsuer()">
|
|
<option value="0">Select Policy Type</option>
|
|
<?php
|
|
if (isset($policy_types) && count($policy_types)) {
|
|
foreach ($policy_types as $key => $value) {
|
|
echo "<option value='" . $value['id'] . "'>" . $value['policy_type'] . "</option>";
|
|
}
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group col-md-12">
|
|
<label for="client_policy_id"> Client Policy <span id="base_danger" class="text-danger"></span></label>
|
|
<select class="form-control" id="client_policy_id" name="client_policy_id">
|
|
<option value="0" selected>Select client policy</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group col-md-12">
|
|
<label for="client_branch">Issuer<span class="text-danger">*</span></label>
|
|
<select class="form-control" id="issuer" name="issuer" required>
|
|
<option value="0">Select Issure</option>
|
|
<?php
|
|
if (isset($issuer) && count($issuer)) {
|
|
foreach ($issuer as $key => $value) {
|
|
echo "<option value=" . $key . ">" . $value . "</option>";
|
|
}
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group col-md-12">
|
|
<label>Date Type<span class="text-danger"></span></label>
|
|
<select class="form-control" id="date_type" name="date_type"
|
|
onchange="hideDateField()">
|
|
<option value="0">Select Date Type</option>
|
|
<?php
|
|
if (isset($date_type) && count($date_type)) {
|
|
foreach ($date_type as $key => $value) {
|
|
echo "<option value='" . $key . "'>" . $value . "</option>";
|
|
}
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group col-md-12" style="display: none;" id="date_div">
|
|
<label>Date<span class="text-danger"></span></label>
|
|
<div id="reportrange" class="form-control" style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc; width: 100%">
|
|
<i class="mdi mdi-calendar-blank"></i>
|
|
<span></span> <i class="mdi mdi-menu-down"></i>
|
|
</div>
|
|
<input type="hidden" id="startDate">
|
|
<input type="hidden" id="endDate">
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="filter-sidebar-footer">
|
|
<a href="<?= base_url("/policy_tranction/report/report-varience-list"); ?>" class="btn btn-secondary" id="clear-filters">Clear</a>
|
|
<a href="<?= base_url("/policy_tranction/report/report-varience-list"); ?>" class="btn btn-primary" id="get-emp-list" onclick="fetchEmpolyeeList(event);closeFilterNav();">Submit</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-12" id="varience_list">
|
|
<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;">Variance Report</h4>
|
|
</div>
|
|
|
|
</div>
|
|
-->
|
|
<div class="table-responsive">
|
|
<table data-custom-table-css="table" data-nhance-list-dt="1" id="variance-report-list-table" class="table w-100 nowrap">
|
|
<thead class="bg-light">
|
|
<tr>
|
|
<th>S.No </th>
|
|
<th>Client </th>
|
|
<th style="display: none;">Client Branch </th>
|
|
<th style="display: none;">Insurer </th>
|
|
<th>Insurer Branch </th>
|
|
<th>Policy Type </th>
|
|
<th>Policy No </th>
|
|
<th>Endorsement No </th>
|
|
<th>Premium </th>
|
|
<th>Statement Premium </th>
|
|
<th>Premium Variance </th>
|
|
<th>Expected Amount </th>
|
|
<th>Statement Amount </th>
|
|
<th>Variance </th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (isset($varience_list)) { ?>
|
|
<?php foreach($varience_list as $index => $row){ ?>
|
|
<tr>
|
|
<td><?= $index + 1 ?></td>
|
|
<td><?php echo $row['client_name']; ?></td>
|
|
<td style="display: none;"><?php echo $row['client_branch_name']; ?></td>
|
|
<td style="display: none;"><?php echo $row['insurer_name']; ?></td>
|
|
<td><?php echo $row['insurer_branch_name']; ?></td>
|
|
<td><?php echo $row['policy_type']; ?></td>
|
|
<td><?php echo $row['policy_no']; ?></td>
|
|
<td><?php echo $row['endorsement_no']; ?></td>
|
|
<td class="right-align-input"><?php echo $row['original_premium']; ?></td>
|
|
<td class="right-align-input"><?php echo isset($row['statement_premium']) ? $row['statement_premium'] : '0.00'; ?></td>
|
|
<td class="right-align-input"><?php echo $row['premium_variance_amt']; ?></td>
|
|
<td class="right-align-input"><?php echo $row['exp_amt']; ?></td>
|
|
<td class="right-align-input"><?php echo isset($row['statement_amount']) ? $row['statement_amount'] : '0.00'; ?></td>
|
|
<td class="right-align-input"><?php echo isset($row['variance_amt']) ? $row['variance_amt'] : '0.00'; ?></td>
|
|
</tr>
|
|
<?php } ?>
|
|
<?php } ?>
|
|
</tbody>
|
|
</table>
|
|
<div>
|
|
</div>
|
|
</div><!-- end col -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<script>
|
|
/* Modified by Gemini Code Assist */
|
|
function openFilterNav() {
|
|
document.getElementById("filter-sidebar").style.width = "350px";
|
|
}
|
|
|
|
/* Modified by Gemini Code Assist */
|
|
function closeFilterNav() {
|
|
document.getElementById("filter-sidebar").style.width = "0";
|
|
}
|
|
</script>
|
|
|
|
<script>
|
|
|
|
let client_list = [];
|
|
let branch_list = [];
|
|
let policy_list = [];
|
|
let insurer_list = [];
|
|
let insurer_branch_list = [];
|
|
|
|
// Datatable document ready
|
|
$(document).ready(function() {
|
|
var ticketsTable = $('#variance-report-list-table');
|
|
if (ticketsTable.length) {
|
|
nhanceListDataTableBeforeInit();
|
|
var nhVarianceTable = ticketsTable.DataTable(nhanceMergeListDataTableOptions({
|
|
// 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
|
|
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
|
|
"<'row'<'col-sm-12'tr>>" +
|
|
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
|
|
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
|
|
buttons: [
|
|
{
|
|
text: '<i class="mdi mdi-filter"></i><span class="btn-custom"> Filter </span>',
|
|
className: 'btn app-btn-primary mr-2',
|
|
action: function (e, dt, node, config) {
|
|
openFilterNav();
|
|
}
|
|
}, {
|
|
extend: 'collection',
|
|
text: '<span class=" btn-custom"> Export </span><i class="mdi mdi-menu-down"></i>',
|
|
className: 'btn app-btn-secondary ',
|
|
buttons: [{
|
|
extend: 'csv',
|
|
text: '<i class="mdi mdi-file-delimited " ></i><span class=" btn-custom"> CSV </span>',
|
|
title: 'Variance-Report-List',
|
|
},
|
|
{
|
|
extend: 'excel',
|
|
text: '<i class="mdi mdi-file-excel " ></i><span class=" btn-custom"> EXCEL </span>',
|
|
title: 'Variance-Report-List',
|
|
sheetName: 'Variance-Report-List', // Sheet name
|
|
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: `
|
|
<div class="datatable-search-wrapper" style="position:relative; display:inline-block;">
|
|
_INPUT_
|
|
<i class="mdi mdi-magnify datatable-search-icon"
|
|
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666;"></i>
|
|
<i class="mdi mdi-close-circle datatable-clear-icon"
|
|
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666; display:none;"></i>
|
|
</div>`,
|
|
searchPlaceholder: "Search",
|
|
emptyTable: '<div class="text-center text-muted">No Data found</div>'
|
|
},
|
|
paging: true, // Enable pagination
|
|
pageLength: 25, // Set default number of rows per page (optional)
|
|
columnDefs: [
|
|
<?php for ($i = 0; $i < $vr_col_count; $i++) : ?>
|
|
{ targets: <?= $i ?>, width: '<?= (int) $vr_col_width_px[$i] ?>px' },
|
|
<?php endfor; ?>
|
|
],
|
|
}));
|
|
nhanceListDataTableAfterInit();
|
|
nhanceListDataTableBindAdjust(nhVarianceTable);
|
|
} else {
|
|
console.error("Table not found.");
|
|
}
|
|
});
|
|
|
|
$(document).ready(function() {
|
|
getClientAndBranchAndPolicy()
|
|
getURLParams()
|
|
$('#client_id').select2();
|
|
$('#client_branch_id').select2();
|
|
$('#insurer_id').select2();
|
|
$('#insurer_branch_id').select2();
|
|
$('#client_policy_id').select2();
|
|
$('#policy_type_id').select2();
|
|
})
|
|
|
|
function fetchEmpolyeeList(event){
|
|
event.preventDefault(); // Prevent default action
|
|
|
|
var start_date = $('#startDate').val();
|
|
var end_date = $('#endDate').val();
|
|
var client_id = $('#client_id').val();
|
|
var insurer_id = $('#insurer_id').val();
|
|
var policy_type_id = $('#policy_type_id').val();
|
|
var date_type = $('#date_type').val();
|
|
var issuer = $('#issuer').val();
|
|
var client_branch_id = $('#client_branch_id').val();
|
|
var insurer_branch_id = $('#insurer_branch_id').val();
|
|
var client_policy_id = $('#client_policy_id').val();
|
|
|
|
console.log(start_date + '-' + end_date);
|
|
|
|
var queryParams = {
|
|
start_date: start_date,
|
|
end_date: end_date,
|
|
client_id: client_id,
|
|
insurer_id: insurer_id,
|
|
policy_type_id: policy_type_id,
|
|
date_type: date_type,
|
|
issuer: issuer,
|
|
client_branch_id: client_branch_id,
|
|
insurer_branch_id: insurer_branch_id,
|
|
client_policy_id: client_policy_id,
|
|
};
|
|
|
|
const queryString = objectToQueryString(queryParams);
|
|
const apiURL = $('#get-emp-list').attr('href') + "?" + queryString;
|
|
console.log(apiURL);
|
|
window.location.href = apiURL;
|
|
}
|
|
|
|
function objectToQueryString(obj) {
|
|
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
|
|
}
|
|
|
|
function getURLParams() {
|
|
const url = new URL(window.location.href);
|
|
const params = new URLSearchParams(url.search);
|
|
|
|
const startDate = params.get('start_date') || 0; // Default to 0 if not found
|
|
const endDate = params.get('end_date') || 0; // Default to 0 if not found
|
|
const client_id = params.get('client_id') || 0; // Default to 0 if not found
|
|
const insurer_id = params.get('insurer_id') || 0; // Default to 0 if not found
|
|
const policy_type_id = params.get('policy_type_id') || 0; // Default to 0 if not found
|
|
const date_type = params.get('date_type') || 0; // Default to 0 if not found
|
|
const issuer = params.get('issuer') || 0; // Default to 0 if not found
|
|
const client_branch_id = params.get('client_branch_id') || 0; // Default to 0 if not found
|
|
const insurer_branch_id = params.get('insurer_branch_id') || 0; // Default to 0 if not found
|
|
const client_policy_id = params.get('client_policy_id') || 0; // Default to 0 if not found
|
|
|
|
hideDateField(date_type)
|
|
|
|
console.log('startDate', startDate)
|
|
console.log('endDate', endDate)
|
|
console.log('client_id', client_id)
|
|
console.log('insurer_id', insurer_id)
|
|
console.log('policy_type_id', policy_type_id)
|
|
console.log('date_type', date_type)
|
|
console.log('issuer', issuer)
|
|
console.log('client_branch_id', client_branch_id)
|
|
console.log('insurer_branch_id', insurer_branch_id)
|
|
console.log('client_policy_id', client_policy_id)
|
|
|
|
// Log the values or use them as needed
|
|
console.log('Start Date:', startDate);
|
|
console.log('End Date:', endDate);
|
|
|
|
if (startDate != 0 && endDate != 0) {
|
|
setTimeout(function(){
|
|
$('#start_date').val(startDate)
|
|
$('#end_date').val(endDate)
|
|
$('#client_id').val(client_id).change()
|
|
$('#insurer_id').val(insurer_id).change()
|
|
$('#policy_type_id').val(policy_type_id).change()
|
|
$('#date_type').val(date_type)
|
|
$('#issuer').val(issuer)
|
|
setTimeout(function(){
|
|
$('#client_branch_id').val(client_branch_id).change()
|
|
$('#insurer_branch_id').val(insurer_branch_id).change()
|
|
setTimeout(function(){
|
|
$('#client_policy_id').val(client_policy_id).change();
|
|
}, 1000);
|
|
}, 2000)
|
|
},2000)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$(function() {
|
|
|
|
const url = new URL(window.location.href);
|
|
const params = new URLSearchParams(url.search);
|
|
|
|
// Get start and end dates from URL parameters, or use default values
|
|
const startDateParam = params.get('start_date') || moment().subtract(29, 'days').format('DD-MM-YYYY');
|
|
const endDateParam = params.get('end_date') || moment().format('DD-MM-YYYY');
|
|
|
|
// Parse the dates to moment objects
|
|
var start = moment(startDateParam, 'DD-MM-YYYY');
|
|
var end = moment(endDateParam, 'DD-MM-YYYY');
|
|
|
|
// var start = moment().subtract(29, 'days');
|
|
// var end = moment();
|
|
|
|
function cb(start, end) {
|
|
$('#reportrange').html(start.format('D-MM-YYYY') + ' - ' + end.format('D-MM-YYYY'));
|
|
$('#startDate').val(start.format('DD-MM-YYYY'));
|
|
$('#endDate').val(end.format('DD-MM-YYYY'));
|
|
}
|
|
|
|
$('#reportrange').daterangepicker({
|
|
startDate: start,
|
|
endDate: end,
|
|
locale: { format: 'DD-MM-YYYY' },
|
|
ranges: {
|
|
'Today': [moment(), moment()],
|
|
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
|
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
|
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
|
|
'This Month': [moment().startOf('month'), moment().endOf('month')],
|
|
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month')
|
|
.endOf('month')
|
|
]
|
|
}
|
|
}, cb);
|
|
|
|
cb(start, end);
|
|
|
|
$('#clear-filters').on('click', function() {
|
|
// Reset all select dropdowns to the first option
|
|
$('#client_id').val('0').change();
|
|
$('#insurer_id').val('0').change();
|
|
$('#policy_type_id').val('0').change();
|
|
$('#date_type').val('0');
|
|
$('#issuer').val('0');
|
|
$('#date_div').hide()
|
|
|
|
// Reset the date range picker to default
|
|
$('#reportrange').data('daterangepicker').setStartDate(moment().subtract(29, 'days'));
|
|
$('#reportrange').data('daterangepicker').setEndDate(moment());
|
|
cb(start, end); // Update the displayed date range
|
|
});
|
|
|
|
});
|
|
|
|
function hideDateField(input = null) {
|
|
let val = $('#date_type').val();
|
|
|
|
if (input) {
|
|
val = input;
|
|
}
|
|
|
|
if (val != 0) {
|
|
$('#date_div').show()
|
|
} else {
|
|
$('#date_div').hide()
|
|
}
|
|
}
|
|
|
|
function sendPolicyTransactionID(event, pt_id) {
|
|
event.preventDefault(); // Prevent default action
|
|
|
|
console.log(pt_id);
|
|
|
|
var queryParams = {
|
|
pt_id: pt_id,
|
|
};
|
|
|
|
const queryString = objectToQueryString(queryParams);
|
|
const apiURL = $('#get-policy-list').attr('href') + "?" + queryString;
|
|
console.log(apiURL);
|
|
window.location.href = apiURL;
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
|
|
//featch client, client branch, insurer, insurer branch and client policy list data
|
|
function getClientAndBranchAndPolicy(){
|
|
$.ajax({
|
|
url: '<?= base_url("/util/getClientAndBranchAndPolicy") ?>',
|
|
type: "GET",
|
|
dataType: 'json',
|
|
success: function(res) {
|
|
|
|
console.log('getClientAndBranchAndPolicy', res);
|
|
if(res.status == true){
|
|
client_list = res.client_data;
|
|
branch_list = res.branch_data;
|
|
policy_list = res.policy_data;
|
|
insurer_list = res.insurer_data;
|
|
insurer_branch_list = res.insurer_branch_data;
|
|
appendClients(res.client_data);
|
|
appendInsurer(res.insurer_data);
|
|
}else{
|
|
console.log('No data found');
|
|
}
|
|
|
|
},
|
|
error: function(xhr, status, error) {
|
|
console.error(xhr.responseText);
|
|
console.error(status, error);
|
|
}
|
|
});
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
getClientAndBranchAndPolicy()
|
|
getURLParams()
|
|
$('#client_id').select2();
|
|
$('#client_branch_id').select2();
|
|
$('#insurer_id').select2();
|
|
$('#insurer_branch_id').select2();
|
|
$('#client_policy_id').select2();
|
|
$('#policy_type_id').select2();
|
|
})
|
|
|
|
function fetchEmpolyeeList(event) {
|
|
event.preventDefault(); // Prevent default action
|
|
|
|
var start_date = $('#startDate').val();
|
|
var end_date = $('#endDate').val();
|
|
var client_id = $('#client_id').val();
|
|
var insurer_id = $('#insurer_id').val();
|
|
var policy_type_id = $('#policy_type_id').val();
|
|
var date_type = $('#date_type').val();
|
|
var issuer = $('#issuer').val();
|
|
var client_branch_id = $('#client_branch_id').val();
|
|
var insurer_branch_id = $('#insurer_branch_id').val();
|
|
var client_policy_id = $('#client_policy_id').val();
|
|
|
|
console.log(start_date + '-' + end_date);
|
|
|
|
var queryParams = {
|
|
start_date: start_date,
|
|
end_date: end_date,
|
|
client_id: client_id,
|
|
insurer_id: insurer_id,
|
|
policy_type_id: policy_type_id,
|
|
date_type: date_type,
|
|
issuer: issuer,
|
|
client_branch_id: client_branch_id,
|
|
insurer_branch_id: insurer_branch_id,
|
|
client_policy_id: client_policy_id,
|
|
};
|
|
|
|
const queryString = objectToQueryString(queryParams);
|
|
const apiURL = $('#get-emp-list').attr('href') + "?" + queryString;
|
|
console.log(apiURL);
|
|
window.location.href = apiURL;
|
|
}
|
|
|
|
function objectToQueryString(obj) {
|
|
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
|
|
}
|
|
|
|
function getURLParams() {
|
|
const url = new URL(window.location.href);
|
|
const params = new URLSearchParams(url.search);
|
|
|
|
const startDate = params.get('start_date') || 0; // Default to 0 if not found
|
|
const endDate = params.get('end_date') || 0; // Default to 0 if not found
|
|
const client_id = params.get('client_id') || 0; // Default to 0 if not found
|
|
const insurer_id = params.get('insurer_id') || 0; // Default to 0 if not found
|
|
const policy_type_id = params.get('policy_type_id') || 0; // Default to 0 if not found
|
|
const date_type = params.get('date_type') || 0; // Default to 0 if not found
|
|
const issuer = params.get('issuer') || 0; // Default to 0 if not found
|
|
const client_branch_id = params.get('client_branch_id') || 0; // Default to 0 if not found
|
|
const insurer_branch_id = params.get('insurer_branch_id') || 0; // Default to 0 if not found
|
|
const client_policy_id = params.get('client_policy_id') || 0; // Default to 0 if not found
|
|
|
|
hideDateField(date_type)
|
|
|
|
console.log('startDate', startDate)
|
|
console.log('endDate', endDate)
|
|
console.log('client_id', client_id)
|
|
console.log('insurer_id', insurer_id)
|
|
console.log('policy_type_id', policy_type_id)
|
|
console.log('date_type', date_type)
|
|
console.log('issuer', issuer)
|
|
console.log('client_branch_id', client_branch_id)
|
|
console.log('insurer_branch_id', insurer_branch_id)
|
|
console.log('client_policy_id', client_policy_id)
|
|
|
|
// Log the values or use them as needed
|
|
console.log('Start Date:', startDate);
|
|
console.log('End Date:', endDate);
|
|
|
|
if (startDate != 0 && endDate != 0) {
|
|
setTimeout(function() {
|
|
$('#start_date').val(startDate)
|
|
$('#end_date').val(endDate)
|
|
$('#client_id').val(client_id).change()
|
|
$('#insurer_id').val(insurer_id).change()
|
|
$('#policy_type_id').val(policy_type_id).change()
|
|
$('#date_type').val(date_type)
|
|
$('#issuer').val(issuer)
|
|
setTimeout(function() {
|
|
$('#client_branch_id').val(client_branch_id).change()
|
|
$('#insurer_branch_id').val(insurer_branch_id).change()
|
|
setTimeout(function() {
|
|
$('#client_policy_id').val(client_policy_id).change();
|
|
}, 1000);
|
|
}, 2000)
|
|
}, 2000)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$(function() {
|
|
|
|
const url = new URL(window.location.href);
|
|
const params = new URLSearchParams(url.search);
|
|
|
|
// Get start and end dates from URL parameters, or use default values
|
|
const startDateParam = params.get('start_date') || moment().subtract(29, 'days').format('DD-MM-YYYY');
|
|
const endDateParam = params.get('end_date') || moment().format('DD-MM-YYYY');
|
|
|
|
// Parse the dates to moment objects
|
|
var start = moment(startDateParam, 'DD-MM-YYYY');
|
|
var end = moment(endDateParam, 'DD-MM-YYYY');
|
|
|
|
// var start = moment().subtract(29, 'days');
|
|
// var end = moment();
|
|
|
|
function cb(start, end) {
|
|
$('#reportrange').html(start.format('D-MM-YYYY') + ' - ' + end.format('D-MM-YYYY'));
|
|
$('#startDate').val(start.format('DD-MM-YYYY'));
|
|
$('#endDate').val(end.format('DD-MM-YYYY'));
|
|
}
|
|
|
|
$('#reportrange').daterangepicker({
|
|
startDate: start,
|
|
endDate: end,
|
|
locale: {
|
|
format: 'DD-MM-YYYY'
|
|
},
|
|
ranges: {
|
|
'Today': [moment(), moment()],
|
|
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
|
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
|
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
|
|
'This Month': [moment().startOf('month'), moment().endOf('month')],
|
|
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month')
|
|
.endOf('month')
|
|
]
|
|
}
|
|
}, cb);
|
|
|
|
cb(start, end);
|
|
|
|
$('#clear-filters').on('click', function() {
|
|
// Reset all select dropdowns to the first option
|
|
$('#client_id').val('0').change();
|
|
$('#insurer_id').val('0').change();
|
|
$('#policy_type_id').val('0').change();
|
|
$('#date_type').val('0');
|
|
$('#issuer').val('0');
|
|
$('#date_div').hide()
|
|
|
|
// Reset the date range picker to default
|
|
$('#reportrange').data('daterangepicker').setStartDate(moment().subtract(29, 'days'));
|
|
$('#reportrange').data('daterangepicker').setEndDate(moment());
|
|
cb(start, end); // Update the displayed date range
|
|
});
|
|
|
|
});
|
|
|
|
function hideDateField(input = null) {
|
|
let val = $('#date_type').val();
|
|
|
|
if (input) {
|
|
val = input;
|
|
}
|
|
|
|
if (val != 0) {
|
|
$('#date_div').show()
|
|
} else {
|
|
$('#date_div').hide()
|
|
}
|
|
}
|
|
|
|
function sendPolicyTransactionID(event, pt_id) {
|
|
event.preventDefault(); // Prevent default action
|
|
|
|
console.log(pt_id);
|
|
|
|
var queryParams = {
|
|
pt_id: pt_id,
|
|
};
|
|
|
|
const queryString = objectToQueryString(queryParams);
|
|
const apiURL = $('#get-policy-list').attr('href') + "?" + queryString;
|
|
console.log(apiURL);
|
|
window.location.href = apiURL;
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
|
|
//featch client, client branch, insurer, insurer branch and client policy list data
|
|
function getClientAndBranchAndPolicy() {
|
|
$.ajax({
|
|
url: '<?= base_url("/util/getClientAndBranchAndPolicy") ?>',
|
|
type: "GET",
|
|
dataType: 'json',
|
|
success: function(res) {
|
|
|
|
console.log('getClientAndBranchAndPolicy', res);
|
|
if (res.status == true) {
|
|
client_list = res.client_data;
|
|
branch_list = res.branch_data;
|
|
policy_list = res.policy_data;
|
|
insurer_list = res.insurer_data;
|
|
insurer_branch_list = res.insurer_branch_data;
|
|
appendClients(res.client_data);
|
|
appendInsurer(res.insurer_data);
|
|
} else {
|
|
console.log('No data found');
|
|
}
|
|
|
|
},
|
|
error: function(xhr, status, error) {
|
|
console.error(xhr.responseText);
|
|
console.error(status, error);
|
|
}
|
|
});
|
|
}
|
|
|
|
//append clients for filter
|
|
function appendClients(data) {
|
|
$('#client_id').empty();
|
|
|
|
$('#client_id').append($('<option>', {
|
|
value: '',
|
|
text: 'Select Client'
|
|
}));
|
|
|
|
$.each(data, function(index, item) {
|
|
var option = $('<option>', {
|
|
value: item.id,
|
|
text: item.client_name,
|
|
'data-cn': item.client_name,
|
|
'data-ct': item.client_type,
|
|
class: (item.client_type == 1) ? 'group' : (item.client_type == 2) ? 'individual' : ''
|
|
});
|
|
|
|
$('#client_id').append(option);
|
|
});
|
|
|
|
}
|
|
|
|
//append clients branch for filter
|
|
function appendBranch(data) {
|
|
|
|
$('#client_branch_id').empty();
|
|
|
|
$('#client_branch_id').append($('<option>', {
|
|
value: '',
|
|
text: 'Select Branch'
|
|
}));
|
|
|
|
$.each(data, function(index, item) {
|
|
|
|
var option = $('<option>', {
|
|
value: item.id,
|
|
text: item.branch_name
|
|
});
|
|
$('#client_branch_id').append(option);
|
|
});
|
|
}
|
|
|
|
//append insurer for filter
|
|
function appendInsurer(data) {
|
|
$('#insurer_id').empty();
|
|
|
|
$('#insurer_id').append($('<option>', {
|
|
value: '',
|
|
text: 'Select Insurer'
|
|
}));
|
|
|
|
$.each(data, function(index, item) {
|
|
var option = $('<option>', {
|
|
value: item.id,
|
|
text: item.name,
|
|
});
|
|
|
|
$('#insurer_id').append(option);
|
|
});
|
|
|
|
}
|
|
|
|
//append insurer branch for filter
|
|
function appendInsurerBranch(data) {
|
|
|
|
$('#insurer_branch_id').empty();
|
|
|
|
$('#insurer_branch_id').append($('<option>', {
|
|
value: '',
|
|
text: 'Select Insurer Branch'
|
|
}));
|
|
|
|
$.each(data, function(index, item) {
|
|
|
|
var option = $('<option>', {
|
|
value: item.id,
|
|
text: item.branch_name
|
|
});
|
|
$('#insurer_branch_id').append(option);
|
|
});
|
|
}
|
|
|
|
//append client policy for filter
|
|
function appendPolicies(data) {
|
|
// console.log('appendPolicies', data);
|
|
// console.log('appendPolicies', $('#client_policy_id'));
|
|
|
|
$('#client_policy_id').empty();
|
|
$('#client_policy_id').append($('<option>', {
|
|
value: '',
|
|
text: 'Select Policy',
|
|
}));
|
|
|
|
$.each(data, function(index, item) {
|
|
var option = $('<option>', {
|
|
value: item.id,
|
|
text: item.policy_type + '-' + item.policy_no,
|
|
});
|
|
$('#client_policy_id').append(option);
|
|
});
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------
|
|
|
|
//client branch and insurer branch onchange document ready function
|
|
$(document).ready(function() {
|
|
|
|
$('#client_id').change(function() {
|
|
|
|
let client_id = $(this).val();
|
|
console.log('client_id', client_id);
|
|
|
|
if (branch_list != '') {
|
|
// console.log(branch_list[client_id]);
|
|
let data = branch_list[client_id];
|
|
appendBranch(data);
|
|
}
|
|
|
|
})
|
|
|
|
$('#insurer_id').change(function() {
|
|
|
|
let insurer_id = $(this).val();
|
|
console.log('insurer_id', insurer_id);
|
|
|
|
if (insurer_branch_list != '') {
|
|
// console.log(insurer_branch_list[insurer_id]);
|
|
let data = insurer_branch_list[insurer_id];
|
|
appendInsurerBranch(data);
|
|
}
|
|
|
|
})
|
|
|
|
});
|
|
|
|
//get policy list based on the client, client_branch, insurer, insurer_branch and policy type
|
|
function getClientPolicyDataBasedOnClientAndInsuer() {
|
|
|
|
let client_id = $('#client_id').val() ?? 0;
|
|
let client_branch_id = $('#client_branch_id').val() ?? 0;
|
|
let insurer_id = $('#insurer_id').val() ?? 0;
|
|
let insurer_branch_id = $('#insurer_branch_id').val() ?? 0;
|
|
let policy_type_id = $('#policy_type_id').val() ?? 0;
|
|
|
|
let url = '<?= base_url('util/getClientPolicyDataBasedOnClientAndInsuer/') ?>';
|
|
|
|
let requestData = {
|
|
client_id: client_id,
|
|
client_branch_id: client_branch_id,
|
|
insurer_id: insurer_id,
|
|
insurer_branch_id: insurer_branch_id,
|
|
policy_type_id: policy_type_id,
|
|
};
|
|
|
|
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
|
|
console.log('Data fetched successfully:', response);
|
|
|
|
if (response.status === true) {
|
|
|
|
appendPolicies(response.data)
|
|
|
|
} else {
|
|
toastr.warning(response.message, 'Warning');
|
|
}
|
|
}, function(xhr, status, error) {
|
|
console.error('Error fetching data:', error);
|
|
console.error(xhr.responseText);
|
|
});
|
|
|
|
}
|
|
</script>
|