nhance/app/Views/finance_team_list.php
2026-04-22 11:44:38 +05:30

560 lines
24 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;
}
.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;
}
.dataTables_length label {height: 21px !important;}
</style>
<div class="col-12" id="finance_filter">
<div class="card-body">
<div id="accordion" class="mb-3">
<div class="card mb-1">
<h4 class="m-1">
<span>Filter</span>
<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>
</h4>
<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 class="input-icon">
<input type="text" id="reportrange" class="form-control" readonly style="caret-color: transparent;">
<i class="mdi mdi-calendar-blank-outline additional-icon"></i>
</div>
<input type="hidden" id="startDate">
<input type="hidden" id="endDate">
</div>
</div>
<div class="form-group text-right m-b-0">
<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 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 data-custom-table-css="table" id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead class="bg-light">
<tr>
<th>S.No&nbsp;</th>
<th>Client Name&nbsp;</th>
<th>Insurer&nbsp;</th>
<th>Policy&nbsp;</th>
<th>Policy No&nbsp;</th>
<th>Endorsement No&nbsp;</th>
<th>Event Type&nbsp;</th>
<th>Action&nbsp;</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>>" +
"<'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: [
{
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: 'Policy-Tranction-BDS-List'
},
{
extend: 'excel',
text: '<i class="mdi mdi-file-excel"></i><span class="btn-custom"> EXCEL </span>',
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());
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;
var totalRow =
'<row r="' + rowIndex + '">' +
'<c t="inlineStr" r="AA' + rowIndex + '"><is><t>Total</t></is></c>' +
'<c t="n" r="AB' + rowIndex + '"><v>' + total.toFixed(2) + '</v></c>' +
'</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,
pageLength: 10,
ordering: false
});
} else {
console.error("Table not found.");
}
getURLParams();
$('#client_id').select2();
$('#insurer_id').select2();
$('#policy_type_id').select2();
const url = new URL(window.location.href);
const params = new URLSearchParams(url.search);
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');
var start = moment(startDateParam, 'DD-MM-YYYY');
var end = moment(endDateParam, 'DD-MM-YYYY');
function cb(startDate, endDate) {
$('#reportrange').html(startDate.format('D-MM-YYYY') + ' - ' + endDate.format('D-MM-YYYY'));
$('#startDate').val(startDate.format('DD-MM-YYYY'));
$('#endDate').val(endDate.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() {
$('#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();
$('#reportrange').data('daterangepicker').setStartDate(moment().subtract(29, 'days'));
$('#reportrange').data('daterangepicker').setEndDate(moment());
cb(moment().subtract(29, 'days'), moment());
});
});
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(function(key) {
return 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() {
$('#startDate').val(startDate);
$('#endDate').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);
}, 300);
}
}
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>