558 lines
23 KiB
PHP
Executable File
558 lines
23 KiB
PHP
Executable File
<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;
|
|
}
|
|
.custom-dropdown-menu {
|
|
display: none;
|
|
position: absolute;
|
|
background-color: #ffffff !important;
|
|
border: 1px solid rgba(0, 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;
|
|
color: #212529 !important;
|
|
text-decoration: none !important;
|
|
background-color: transparent !important;
|
|
}
|
|
|
|
.custom-dropdown-menu .dropdown-item:hover {
|
|
background-color: #f8f9fa !important;
|
|
color: #16181b !important;
|
|
cursor: pointer !important;
|
|
}
|
|
</style>
|
|
|
|
<div class="row" id="finance_filter">
|
|
<div class="col-12" style="margin-top: -12px;">
|
|
<div id="accordion" class="mb-3">
|
|
<div class="card mb-1">
|
|
<h5 class="m-1">
|
|
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseOne"
|
|
aria-expanded="true">
|
|
<i id="icon" class="mdi mdi-chevron-down mr-1 text-primary" style="font-size: 28px;"></i>
|
|
</a>
|
|
</h5>
|
|
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
|
|
<div class="card-body">
|
|
<div class="form-group">
|
|
<div class="form-row">
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="client_branch">Client<span class="text-danger"></span></label>
|
|
<select class="form-control" id="client_id" name="client_id">
|
|
<option value="0">Select Client</option>
|
|
<?php
|
|
if (isset($clients) && count($clients)) {
|
|
foreach ($clients as $key => $value) {
|
|
echo "<option value='" . $value['id'] . "'>" . $value['client_name'] . "</option>";
|
|
}
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="addon_policy"> Insurer <span id="base_danger"
|
|
class="text-danger"></span></label>
|
|
<select class="form-control" id="insurer_id" name="insurer_id">
|
|
<option value="0" selected>Select Insurer</option>
|
|
<?php if (isset($insurer) && count($insurer)) { ?>
|
|
<?php foreach ($insurer as $value) { ?>
|
|
<option value="<?= $value['id']?>"><?= $value['name']?></option>
|
|
<?php } ?>
|
|
<?php } ?>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="email"> Policy Type <span class="text-danger"></span></label>
|
|
<select class="form-control" id="policy_type_id" name="policy_type_id">
|
|
<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-3">
|
|
<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>
|
|
|
|
<div class="form-row">
|
|
|
|
<div class="form-group col-md-3">
|
|
<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-3" 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="fa fa-calendar"></i>
|
|
<span></span> <i class="fa fa-caret-down"></i>
|
|
</div>
|
|
<input type="hidden" id="startDate">
|
|
<input type="hidden" id="endDate">
|
|
</div>
|
|
|
|
<div class="form-group col-md-3 text-right m-b-0" style="margin-top: 29px;">
|
|
<a href="<?= base_url("/policy_tranction/report/report-finance-list"); ?>"
|
|
class="btn btn-secondary" id="clear-filters">Clear</a>
|
|
<a href="<?= base_url("/policy_tranction/report/report-finance-list"); ?>"
|
|
class="btn btn-primary" id="get-emp-list"
|
|
onclick="fetchEmpolyeeList(event);">Submit</a>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- <div class="form-group text-right m-b-0">
|
|
<button type="button" class="btn btn-secondary" id="clear-filters">Clear</button>
|
|
<a href="<?= base_url("/policy_tranction/report/list"); ?>"
|
|
class="btn btn-primary waves-effect waves-light" id="get-emp-list"
|
|
onclick="fetchEmpolyeeList(event);">Submit</a>
|
|
</div> -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-12" id="finance_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;">Finance Team</h4>
|
|
</div>
|
|
|
|
</div>
|
|
<div class="table-responsive" style="overflow-x: auto;">
|
|
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
|
|
<thead class="bg-light">
|
|
<tr>
|
|
<th>S.No</th>
|
|
<th>Client Name</th>
|
|
<th>Insurer</th>
|
|
<th>Policy</th>
|
|
<th>Policy No</th>
|
|
<th>Endorsement No</th>
|
|
<th>Event Type</th>
|
|
<th>Action</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (isset($finance_list)) { ?>
|
|
<?php foreach($finance_list as $index => $row){ ?>
|
|
<tr>
|
|
<td><?= $index + 1 ?></td>
|
|
<td><?php echo $row['client_name']; ?></td>
|
|
<td><?php echo $row['insurer_name']; ?></td>
|
|
<td><?php echo $row['policy_type']; ?></td>
|
|
<td><?php echo $row['policy_no']; ?></td>
|
|
<td><?php echo $row['endorsement_no']; ?></td>
|
|
<td><?php echo $row['action_type_full']; ?></td>
|
|
<td>
|
|
<div class="btn-group dropdown">
|
|
<a href="javascript: void(0);"
|
|
class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"
|
|
aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
|
<div class="dropdown-menu dropdown-menu-right">
|
|
<a href="
|
|
<?php
|
|
if ($row['action_type'] == 'I') {
|
|
echo base_url("/policy_tranction/inception/list") . '?pt_id=' . $row['id'];
|
|
} else {
|
|
echo base_url("/policy_tranction/endorsement/list") . '?pt_id=' . $row['id'];
|
|
}
|
|
?>" id="get-policy-list" class="dropdown-item btnEdit">
|
|
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<?php } ?>
|
|
<?php } ?>
|
|
</tbody>
|
|
</table>
|
|
|
|
<div>
|
|
</div>
|
|
</div>
|
|
</div><!-- end col -->
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|
const table = document.getElementById("scroll-horizontal-datatable");
|
|
|
|
// Create custom dropdown
|
|
function createCustomDropdown(row) {
|
|
// Get the original dropdown items
|
|
const originalDropdown = row.querySelector('.dropdown-menu');
|
|
if (!originalDropdown) return null;
|
|
|
|
// Create new dropdown with proper background and spacing
|
|
const customDropdown = document.createElement('div');
|
|
customDropdown.className = 'custom-dropdown-menu';
|
|
|
|
// Copy inner content while maintaining icon alignment
|
|
customDropdown.innerHTML = originalDropdown.innerHTML;
|
|
|
|
return customDropdown;
|
|
}
|
|
|
|
let activeDropdown = null;
|
|
|
|
// Add click event listener to rows
|
|
table.querySelectorAll("tbody tr").forEach(row => {
|
|
const customDropdown = createCustomDropdown(row);
|
|
if (!customDropdown) return;
|
|
|
|
// Append the custom dropdown to the body
|
|
document.body.appendChild(customDropdown);
|
|
|
|
row.addEventListener("click", function(event) {
|
|
// Ignore clicks on the action column
|
|
if (event.target.closest('td:last-child')) {
|
|
return;
|
|
}
|
|
|
|
// Hide any active dropdown
|
|
if (activeDropdown) {
|
|
activeDropdown.style.display = 'none';
|
|
}
|
|
|
|
// Get click position
|
|
const rect = event.target.getBoundingClientRect();
|
|
|
|
// Position the dropdown with some offset
|
|
customDropdown.style.display = 'block';
|
|
customDropdown.style.position = 'fixed';
|
|
customDropdown.style.left = `${rect.left}px`;
|
|
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
|
|
|
|
// Set as active dropdown
|
|
activeDropdown = customDropdown;
|
|
|
|
event.stopPropagation();
|
|
});
|
|
|
|
// Preserve click handlers and add auto-close
|
|
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
|
|
item.addEventListener('click', function(e) {
|
|
const onclickAttr = this.getAttribute('onclick');
|
|
if (onclickAttr) {
|
|
eval(onclickAttr);
|
|
}
|
|
|
|
const href = this.getAttribute('href');
|
|
if (href && href !== '#') {
|
|
window.location.href = href;
|
|
}
|
|
|
|
// Close the dropdown after handling the click
|
|
if (activeDropdown) {
|
|
activeDropdown.style.display = 'none';
|
|
activeDropdown = null;
|
|
}
|
|
|
|
e.stopPropagation();
|
|
});
|
|
});
|
|
});
|
|
|
|
// Close dropdown when clicking outside
|
|
document.addEventListener("click", function() {
|
|
if (activeDropdown) {
|
|
activeDropdown.style.display = 'none';
|
|
activeDropdown = null;
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
|
|
|
|
|
|
<script>
|
|
// Datatable document ready
|
|
$(document).ready(function() {
|
|
|
|
var ticketsTable = $('#scroll-horizontal-datatable');
|
|
|
|
if (ticketsTable.length) {
|
|
ticketsTable.DataTable({
|
|
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 not found.");
|
|
}
|
|
});
|
|
|
|
$(document).ready(function() {
|
|
getURLParams()
|
|
$('#client_id').select2();
|
|
$('#insurer_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();
|
|
|
|
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,
|
|
};
|
|
|
|
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
|
|
|
|
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)
|
|
|
|
// 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)
|
|
}, 1000)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$(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 span').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,
|
|
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;
|
|
}
|
|
</script>
|