1068 lines
40 KiB
PHP
1068 lines
40 KiB
PHP
<style>
|
|
.col-12 {
|
|
max-width: 98% !important;
|
|
}
|
|
|
|
.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 .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>
|
|
.switch {
|
|
position: relative;
|
|
display: inline-block;
|
|
width: 54px;
|
|
height: 34px;
|
|
}
|
|
|
|
.switch input {
|
|
opacity: 0;
|
|
width: 0;
|
|
height: 0;
|
|
}
|
|
|
|
.slider {
|
|
position: absolute;
|
|
cursor: pointer;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
background-color: #ccc;
|
|
-webkit-transition: .4s;
|
|
transition: .4s;
|
|
}
|
|
|
|
.slider:before {
|
|
position: absolute;
|
|
content: "";
|
|
height: 19px;
|
|
width: 19px;
|
|
left: 4px;
|
|
bottom: 4px;
|
|
background-color: white;
|
|
-webkit-transition: .4s;
|
|
transition: .4s;
|
|
}
|
|
|
|
input:checked+.slider {
|
|
background-color: #2196F3;
|
|
}
|
|
|
|
input:focus+.slider {
|
|
box-shadow: 0 0 1px #2196F3;
|
|
}
|
|
|
|
input:checked+.slider:before {
|
|
-webkit-transform: translateX(26px);
|
|
-ms-transform: translateX(26px);
|
|
transform: translateX(26px);
|
|
}
|
|
|
|
/* Rounded sliders */
|
|
.slider.round {
|
|
border-radius: 34px;
|
|
}
|
|
|
|
.slider.round:before {
|
|
border-radius: 50%;
|
|
}
|
|
.dataTables_length label {height: 21px !important;}
|
|
</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_for_search" name="client_id">
|
|
<option value="0">Select Client</option>
|
|
<?php
|
|
if (isset($client) && count($client)) {
|
|
foreach ($client as $key => $value) {
|
|
echo "<option value='" . $value['id'] . "'>" . $value['client_name'] . "</option>";
|
|
}
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group col-md-12">
|
|
<label for="addon_policy"> Insurer <span id="base_danger" class="text-danger"></span></label>
|
|
<select class="form-control" id="insurer_id_for_search" name="insurer_id">
|
|
<option value="0" selected>Select Insurer</option>
|
|
<?php foreach ($insurer as $value) { ?>
|
|
<option value="<?= $value['id'] ?>"><?= $value['name'] ?></option>
|
|
<?php } ?>
|
|
</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_for_search" 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-12">
|
|
<label for="client_branch">Issuer<span class="text-danger">*</span></label>
|
|
<select class="form-control" id="issuer_for_search" 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 for="email"> Status <span class="text-danger"></span></label>
|
|
<select class="form-control" id="policy_status_for_search" name="policy_type_id">
|
|
<option value="0">Select Status</option>
|
|
<?php
|
|
if (isset($policy_status) && count($policy_status)) {
|
|
foreach ($policy_status 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/endorsement/list"); ?>" class="btn btn-secondary" id="clear-filters">Clear</a>
|
|
<a href="<?= base_url("/policy_tranction/endorsement/list"); ?>" class="btn btn-primary" id="get-emp-list" onclick="fetchEmpolyeeList(event);closeFilterNav();">Submit</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-12" id="endorsement_list">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<table data-custom-table-css="table" class="table mb-0 nowrap" cellspacing="0" id="tickets-table">
|
|
<thead class="bg-light">
|
|
<tr>
|
|
<th class="font-weight-medium">Sno </th>
|
|
<th class="font-weight-medium">Issuer </th>
|
|
<th class="font-weight-medium">Client </th>
|
|
<th class="font-weight-medium">Branch </th>
|
|
<th class="font-weight-medium">Insurer </th>
|
|
<th class="font-weight-medium">Policy </th>
|
|
<th class="font-weight-medium">Endorsement Type </th>
|
|
<th class="font-weight-medium">Endorsement No </th>
|
|
<th class="font-weight-medium">Data Recived Date </th>
|
|
<th class="font-weight-medium">No of Insured </th>
|
|
<th class="font-weight-medium">No of Dependence </th>
|
|
<th class="font-weight-medium">Policy Issue Date </th>
|
|
<th class="font-weight-medium">Status </th>
|
|
<th class="font-weight-medium text-center">Action </th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($endorsement_data_list as $index => $row) { ?>
|
|
<tr>
|
|
<td class="text-center"><?php echo $index + 1; ?></td>
|
|
<td><?php echo $issuer[$row['issuer']] ?? 'N/A'; ?></td><!-- Issuer -->
|
|
<td><?php echo $row['client_short_name'] ?: 'N/A'; ?></td><!-- Client -->
|
|
<td><?php echo $row['client_branch_name'] ?: 'N/A'; ?></td><!-- Branch -->
|
|
<td><?php echo $row['insurer_short_name'] ?: 'N/A'; ?></td><!-- Insurer -->
|
|
<td><?php echo $row['policy_type'] ?: 'N/A'; ?></td><!-- Policy -->
|
|
<td><?php echo $action_type[$row['action_type']] ?: 'N/A';?></td>
|
|
<td><?php echo $row['endorsement_no'] ?: 'N/A'; ?></td>
|
|
<td><?php echo empty($row['data_received_date']) ? 'N/A' : date('d/m/Y', strtotime($row['data_received_date'])); ?></td>
|
|
<td class="right-align-input"><?php echo $row['emp_count'] ?: '0'; ?></td>
|
|
<td class="right-align-input"><?php echo $row['dependent_count'] ?: '0'; ?></td>
|
|
<td><?php echo empty($row['policy_issue_date']) ? 'N/A' : date('d/m/Y', strtotime($row['policy_issue_date'])); ?></td>
|
|
<td><?php echo $policy_status[$row['status']] ?: 'N/A'; ?></td>
|
|
<td class="text-center table-action-cell">
|
|
<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 class="dropdown-item btnEdit" data-id="<?= $row['id']; ?>" onclick="getPolicyTransactionDataForEndorsementEdit('<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>')">
|
|
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
|
|
</a>
|
|
<?php if(get_role_id() == 5): ?>
|
|
<a class="dropdown-item delete" data-id="<?= $row['id'];?>" onclick="removePolicyTransaction(this, '<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>', <?= $row['policy_type_id'] ?>)">
|
|
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
|
|
</a>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<?php } ?>
|
|
</tbody>
|
|
</table><!-- table -->
|
|
</div><!-- card-body -->
|
|
</div><!-- card -->
|
|
</div><!-- end col -->
|
|
</div>
|
|
|
|
<!-- end table row -->
|
|
<?php include('pt_endorsement_form_file_upload_tab.php'); ?>
|
|
|
|
<script>
|
|
function openEndorsementFilterNav() {
|
|
document.getElementById("filter-sidebar").style.width = "350px";
|
|
}
|
|
|
|
function closeFilterNav() {
|
|
document.getElementById("filter-sidebar").style.width = "0";
|
|
}
|
|
</script>
|
|
|
|
<script>
|
|
var client_list = '';
|
|
var branch_list = '';
|
|
var policy_list = <?= json_encode($endorsementPolicies) ?>;
|
|
// console.log("POLICY List",policy_list);
|
|
var policyListByClient = <?= json_encode($endorsementPolicyListByClient) ?>;
|
|
var branch_policy = '';
|
|
var unit_list = '';
|
|
|
|
// select2 document ready
|
|
$(document).ready(function() {
|
|
|
|
// getClientAndBranchAndPolicy()
|
|
getClientAndBranchAndPolicy(function() {
|
|
getURLParamsForReport();
|
|
});
|
|
|
|
addHTMLInput();
|
|
|
|
<?php if (session()->has('create_failed')) : ?>
|
|
toastr.error('<?= session()->getFlashdata('create_failed') ?>', 'Failed');
|
|
<?php endif; ?>
|
|
|
|
<?php if (session()->has('update_failed')) : ?>
|
|
toastr.error('<?= session()->getFlashdata('update_failed') ?>', 'Failed');
|
|
<?php endif; ?>
|
|
|
|
<?php if (session()->has('create_success')) : ?>
|
|
toastr.success('<?= session()->getFlashdata('create_success') ?>', 'Success');
|
|
<?php endif; ?>
|
|
|
|
<?php if (session()->has('update_success')) : ?>
|
|
toastr.success('<?= session()->getFlashdata('update_success') ?>', 'Success');
|
|
<?php endif; ?>
|
|
|
|
|
|
$('#client_id').select2();
|
|
$('#client_branch_id').select2();
|
|
$('#client_policy_id').select2();
|
|
|
|
})
|
|
|
|
//DataTable document ready
|
|
$(document).ready(function() {
|
|
var ticketsTable = $('#tickets-table');
|
|
|
|
if (ticketsTable.length) {
|
|
var table = ticketsTable.DataTable({
|
|
scrollX: true,
|
|
dom: "<'row'<'col-sm-7'f><'col-sm-5 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) {
|
|
openEndorsementFilterNav();
|
|
}
|
|
},
|
|
{
|
|
text: '<i class="mdi mdi-plus" ></i><span class=" btn-custom"> Add </span>',
|
|
className: 'btn app-btn-primary mr-2',
|
|
action: function (e, dt, node, config) {
|
|
hide_list_show_add();
|
|
addHTMLInput(null, 'policy_docs_div');
|
|
$('#policy_docs').show()
|
|
},
|
|
attr: { id: 'btnAdd' }
|
|
},
|
|
{
|
|
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-Endorsement-List',
|
|
exportOptions: {
|
|
columns: ':not(:last-child)'
|
|
},
|
|
}
|
|
]
|
|
}
|
|
],
|
|
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>',
|
|
paginate: {
|
|
previous: '◄',
|
|
next: '►'
|
|
}
|
|
},
|
|
paging: true, // Enable pagination
|
|
pageLength: 10, // Set default number of rows per page (optional)
|
|
ordering: false,
|
|
});
|
|
|
|
function applyBottomRowDropup() {
|
|
if (!table) return;
|
|
|
|
const currentRows = table.rows({ page: 'current' }).nodes().toArray();
|
|
$('#tickets-table tbody tr').removeClass('nh-force-dropup');
|
|
$('#tickets-table tbody tr td.table-action-cell .btn-group.dropdown').removeClass('dropup');
|
|
|
|
const targetCount = Math.min(2, currentRows.length);
|
|
for (let i = 0; i < targetCount; i++) {
|
|
const row = currentRows[currentRows.length - 1 - i];
|
|
if (!row) continue;
|
|
$(row).addClass('nh-force-dropup');
|
|
$(row).find('td.table-action-cell .btn-group.dropdown').addClass('dropup');
|
|
}
|
|
}
|
|
applyBottomRowDropup();
|
|
ticketsTable.on('draw.dt', applyBottomRowDropup);
|
|
} else {
|
|
console.error("Table not found.");
|
|
}
|
|
$('#btnAdd').wrap('<div id="status_change"></div>');
|
|
});
|
|
|
|
// Date document ready
|
|
$(document).ready(function() {
|
|
|
|
var today = new Date();
|
|
|
|
var data_received_date = flatpickr("#data_received_date", {
|
|
dateFormat: "d/m/Y",
|
|
allowInput: false,
|
|
parseDate: (datestr, format) => {
|
|
return new Date(datestr.replace(/(\d{2})-(\d{2})-(\d{4})/, "$2/$1/$3"));
|
|
},
|
|
onOpen: function(selectedDates, dateStr, instance) {
|
|
instance.setDate(instance.input.value, false);
|
|
},
|
|
onInput: function(selectedDates, dateStr, instance) {
|
|
let inputValue = instance.input.value;
|
|
let formattedDate = inputValue.replace(/(\d{2})-(\d{2})-(\d{4})/, "$2/$1/$3");
|
|
instance.input.value = formattedDate;
|
|
}
|
|
});
|
|
|
|
var last_action_date = flatpickr("#last_action_date", {
|
|
dateFormat: "d/m/Y", // Display format in DD/MM/YYYY
|
|
defaultDate: today, // Today's date as the default value
|
|
allowInput: false,
|
|
maxDate: today // Disallow future dates
|
|
});
|
|
|
|
var month = flatpickr("#month", {
|
|
dateFormat: "M/Y", // Format as month and year
|
|
allowInput: false, // Disable manual input
|
|
});
|
|
|
|
var policy_issue_date = flatpickr("#policy_issue_date", {
|
|
dateFormat: "d/m/Y", // Format as day-month-year
|
|
allowInput: false, // Disable manual input
|
|
onChange: function(selectedDates, dateStr, instance) {
|
|
// Get the selected date
|
|
var selectedDate = new Date(selectedDates[0]);
|
|
|
|
// Format the selected date to "M-Y"
|
|
var formattedMonth = flatpickr.formatDate(selectedDate, "M/Y");
|
|
|
|
// Set the value of the #month input
|
|
month.setDate(formattedMonth);
|
|
}
|
|
});
|
|
|
|
var install_due_date = flatpickr("#install_due_date", {
|
|
dateFormat: "d/m/Y",
|
|
allowInput: false
|
|
});
|
|
|
|
var endorse_eff_date = flatpickr("#endorse_eff_date", {
|
|
dateFormat: "d/m/Y",
|
|
allowInput: false
|
|
});
|
|
|
|
});
|
|
|
|
var pageName = "<?= esc($page_name ?? '') ?>";
|
|
var userName = "<?= esc(get_session_userdata()->first_name ?? 'NOT SET') ?>";
|
|
|
|
function updateNavTitle(subTitle, backButton) {
|
|
var titleHtml = "";
|
|
var $titleEl = $(".top-navbar-title");
|
|
var $navDiv = $(".top-navbar-div");
|
|
|
|
if (pageName && backButton && subTitle) {
|
|
titleHtml = `<h3 style="margin-right:5px !important;">${pageName}</h3>`;
|
|
titleHtml += `<h6>${backButton} ${subTitle}</h6>`;
|
|
$titleEl.css({ display: "block", bottom: "12px" });
|
|
$navDiv.css({ marginTop: "0px" });
|
|
} else if (pageName && subTitle) {
|
|
titleHtml = `<h3 style="margin-right:5px !important;">${pageName}</h3>`;
|
|
titleHtml += `<h6>${subTitle}</h6>`;
|
|
$titleEl.css({ display: "block", bottom: "12px" });
|
|
$navDiv.css({ marginTop: "0px" });
|
|
} else {
|
|
titleHtml = `<h3 style="margin-right:5px !important;">${pageName}</h3>`;
|
|
$titleEl.css({ display: "flex", bottom: "0px" });
|
|
$navDiv.css({ marginTop: "20px" });
|
|
}
|
|
|
|
$titleEl.html(titleHtml);
|
|
}
|
|
|
|
function hide_list_show_add() {
|
|
var backUrl = '<?= base_url("policy_tranction/endorsement/list"); ?>';
|
|
var backButton = `<a href="${backUrl}" aria-label="Back to list"><i class="mdi mdi-arrow-left" style="font-size: 17px;"></i></a>`;
|
|
updateNavTitle('Add Endorsement', backButton);
|
|
removeAllColumnsExceptFirst('insurerTable');
|
|
$('.hideter').hide()
|
|
$('.hidetp').hide()
|
|
$('#endorsement_form_id')[0].reset();
|
|
if (typeof window.resetEndorsementFormParsley === 'function') {
|
|
window.resetEndorsementFormParsley('#endorsement_form_id');
|
|
}
|
|
$('#client_id').val('').change();
|
|
$('#client_policy_id').val('').change();
|
|
$('#invoice_no_div').hide();
|
|
$('#invoice_no').attr('required', false)
|
|
|
|
$('#pt_onboarding').show();
|
|
$('#endorsement_list').hide();
|
|
$('#endorsement_filter').hide();
|
|
}
|
|
|
|
function show_list_hide_add() {
|
|
updateNavTitle(false, false);
|
|
$('#pt_onboarding').hide()
|
|
$('#endorsement_list').show()
|
|
$('#endorsement_filter').show()
|
|
|
|
}
|
|
|
|
function getClientAndBranchAndPolicy(callback) {
|
|
$.ajax({
|
|
url: '<?= base_url("/util/getClientAndBranchAndPolicy") ?>',
|
|
type: "GET",
|
|
dataType: 'json',
|
|
success: function(res) {
|
|
|
|
console.log('getClientAndBranchAndPolicy', res);
|
|
|
|
if (res.status == true) {
|
|
branch_list = res.branch_data;
|
|
// policy_list = res.policy_data;
|
|
// policyListByClient = res.policyListByClient;
|
|
client_list = res.client_data;
|
|
unit_list = res.unit_data;
|
|
appendClients(res.client_data);
|
|
} else {
|
|
console.log('No data found');
|
|
}
|
|
|
|
// ✅ Data ellam set aanadhuku aparam callback call panrom
|
|
if (typeof callback === "function") {
|
|
callback();
|
|
}
|
|
|
|
},
|
|
error: function(xhr, status, error) {
|
|
console.error(xhr.responseText);
|
|
console.error(status, error);
|
|
}
|
|
});
|
|
}
|
|
|
|
function appendClients(data) {
|
|
$('#client_id').empty();
|
|
|
|
$('#client_id').append($('<option>', {
|
|
value: '',
|
|
text: 'Select Client'
|
|
}));
|
|
|
|
// $('#client_id').append($('<option>', {
|
|
// value: 'add_client',
|
|
// text: '+ Add Client'
|
|
// }));
|
|
|
|
$.each(data, function(index, item) {
|
|
|
|
if (item.client_policy_count > 0) {
|
|
|
|
var option = $('<option>', {
|
|
value: item.id,
|
|
text: item.client_name
|
|
});
|
|
$('#client_id').append(option);
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
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);
|
|
});
|
|
}
|
|
|
|
function appendPolicies(data, policy_id=null) {
|
|
if (!data) {
|
|
|
|
toastr.warning("There are no policies in Inception for the selected client and branch.");
|
|
}
|
|
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,
|
|
'data-sd': item.policy_start_date,
|
|
'data-ed': item.policy_end_date,
|
|
'data-insurer': item.insurer_branch_id + '-' + item.insurer_id,
|
|
'data-policy': item.policy_no,
|
|
'data-cd': item.cd_ac_no,
|
|
'data-ebp': item.ebp,
|
|
'data-etp': item.etp,
|
|
'data-iep': item.iep,
|
|
'data-itp': item.itp,
|
|
'data-bap': item.bap,
|
|
'data-allocg': item.allocg,
|
|
'data-tpa': item.tpa_branch_id + '-' + item.tpa_id,
|
|
'data-ptid': item.policy_type_id,
|
|
});
|
|
|
|
if (policy_id == item.id) {
|
|
option.attr('selected', true);
|
|
}
|
|
|
|
$('#client_policy_id').append(option);
|
|
});
|
|
}
|
|
|
|
function logSelectedIds() {
|
|
var selectedIds = [];
|
|
$('.row-select:checked').each(function() {
|
|
selectedIds.push($(this).data('id'));
|
|
});
|
|
|
|
console.log('Selected IDs:', selectedIds);
|
|
|
|
return selectedIds;
|
|
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------
|
|
|
|
$("#invoiceForm").submit(function(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
var isValid = $('#invoiceForm').parsley().validate();
|
|
if (!isValid) {
|
|
console.log('Form is Empty', 'Warning');
|
|
return;
|
|
}
|
|
|
|
form_action = '<?= base_url("util/updateInvoiceStatus"); ?>';
|
|
|
|
$('.loader').fadeIn();
|
|
$('.loader-mask').fadeIn();
|
|
|
|
var ids = logSelectedIds();
|
|
console.log(ids);
|
|
|
|
var formData = new FormData($('#invoiceForm')[0]);
|
|
formData.append('ids', JSON.stringify(ids));
|
|
|
|
$.ajax({
|
|
data: formData,
|
|
url: form_action,
|
|
type: "POST",
|
|
dataType: 'json',
|
|
processData: false,
|
|
contentType: false,
|
|
success: function(res) {
|
|
|
|
$('.loader').fadeOut();
|
|
$('.loader-mask').delay(350).fadeOut('slow');
|
|
|
|
if (res.status == true) {
|
|
toastr.success(res.message, 'Success');
|
|
} else {
|
|
toastr.error(res.message, 'Error');
|
|
}
|
|
|
|
window.location.reload();
|
|
$('.close').click();
|
|
},
|
|
error: function(xhr, status, error) {
|
|
console.error(xhr.responseText);
|
|
console.error(status, error);
|
|
$('.loader').fadeOut();
|
|
$('.loader-mask').delay(350).fadeOut('slow');
|
|
}
|
|
});
|
|
});
|
|
|
|
$('#invoice_status').change(function() {
|
|
|
|
let value = $(this).val()
|
|
|
|
if (value == 'generated') {
|
|
$('#invoice_no_div').show()
|
|
$('#invoice_no').attr('required', true)
|
|
} else {
|
|
$('#invoice_no_div').hide()
|
|
$('#invoice_no').attr('required', false)
|
|
}
|
|
})
|
|
|
|
$('#invoice_status_modal').change(function() {
|
|
|
|
let value = $(this).val()
|
|
|
|
if (value == 'generated') {
|
|
$('#invoice_no_div_modal').show()
|
|
$('#invoice_no_modal').attr('required', true)
|
|
} else {
|
|
$('#invoice_no_div_modal').hide()
|
|
$('#invoice_no_modal').attr('required', false)
|
|
|
|
}
|
|
})
|
|
</script>
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
getURLParams()
|
|
$('#client_id_for_search').select2();
|
|
$('#insurer_id_for_search').select2();
|
|
$('#policy_type_for_search').select2();
|
|
})
|
|
|
|
function fetchEmpolyeeList(event) {
|
|
event.preventDefault(); // Prevent default action
|
|
|
|
var start_date = $('#startDate').val();
|
|
var end_date = $('#endDate').val();
|
|
var client_id = $('#client_id_for_search').val();
|
|
var insurer_id = $('#insurer_id_for_search').val();
|
|
var policy_type_id = $('#policy_type_for_search').val();
|
|
var date_type = $('#date_type').val();
|
|
var issuer = $('#issuer_for_search').val();
|
|
var status = $('#policy_status_for_search').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,
|
|
status: status,
|
|
};
|
|
|
|
console.log(queryParams)
|
|
|
|
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 status = params.get('status') || 0; // Default to 0 if not found
|
|
|
|
hideDateField(date_type)
|
|
|
|
if (startDate != 0 && endDate != 0) {
|
|
setTimeout(function() {
|
|
$('#start_date').val(startDate)
|
|
$('#end_date').val(endDate)
|
|
$('#client_id_for_search').val(client_id).change()
|
|
$('#insurer_id_for_search').val(insurer_id).change()
|
|
$('#policy_type_for_search').val(policy_type_id).change()
|
|
$('#date_type').val(date_type)
|
|
$('#issuer_for_search').val(issuer)
|
|
$('#policy_status_for_search').val(status)
|
|
}, 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');
|
|
|
|
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,
|
|
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_for_search').val('0').change();
|
|
$('#insurer_id_for_search').val('0').change();
|
|
$('#policy_type_for_search').val('0').change();
|
|
$('#date_type').val('0');
|
|
$('#issuer_for_search').val('0');
|
|
$('#policy_status_for_search').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 removePolicyTransaction(input, pt_id, policy_type_id) {
|
|
|
|
let string = "Do you want to delete this transaction?";
|
|
if(policy_type_id > 7){
|
|
string = "Do you want to delete this transaction? Deleting this will also remove the linked CRM policy entry.";
|
|
}
|
|
|
|
confirmActionSweertAlert(string, "Yes, Proceed!", "No, Cancel").then((confirmed) => {
|
|
if (confirmed) {
|
|
|
|
let type = '1';
|
|
let url = '<?= base_url('policy_tranction/inception/removePolicyTransaction/') ?>' + pt_id + '/' + type;
|
|
|
|
// Include `pt_id` in the AJAX request if necessary
|
|
let requestData = {
|
|
pt_id: pt_id ,
|
|
type: 1 ,
|
|
};
|
|
|
|
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
|
|
console.log('Data fetched successfully:', response);
|
|
|
|
if (response.status === true) {
|
|
toastr.success(response.message, 'Success');
|
|
window.location.reload();
|
|
} else {
|
|
toastr.warning(response.message, 'Warning');
|
|
}
|
|
}, function(xhr, status, error) {
|
|
console.error('Error fetching data:', error);
|
|
console.error(xhr.responseText);
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
function addHTMLInput(data = null, container_id = 'dynamic-form-container')
|
|
{
|
|
console.log('container_id', container_id);
|
|
const container = document.getElementById(container_id);
|
|
|
|
let required = ''
|
|
let required_star = ''
|
|
if(container_id == 'dynamic-form-container'){
|
|
required = 'required';
|
|
required_star = '*';
|
|
}
|
|
console.log('container', container);
|
|
|
|
const newRow = document.createElement('div');
|
|
newRow.className = 'form-row dynamic-form-row';
|
|
newRow.innerHTML = `
|
|
<div class="form-group col-md-5">
|
|
<label for="file_name">Document Name<span class="text-danger">${required_star}</span></label>
|
|
<input type="text" class="form-control" id="docs_name" name="doc_name[]" placeholder="Enter file name" ${required}>
|
|
</div>
|
|
<div class="form-group col-md-5">
|
|
<label for="file">Upload File<span class="text-danger">${required_star}</span></label>
|
|
<input type="file" class="form-control" id="file_name" name="file[]" ${required} accept=".pdf,.jpg,.jpeg,.png">
|
|
<small class="text-muted d-block">Allowed: PDF, PNG, JPG, JPEG. </small>
|
|
</div>
|
|
<div class="form-group col-md-2" style="position: relative;top: 28px;">
|
|
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInput(this, '${container_id}')">x</a>
|
|
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="addHTMLInput(null, '${container_id}')">+</a>
|
|
</div>
|
|
`;
|
|
container.appendChild(newRow);
|
|
|
|
if (data !== null && data.db_column_name !== undefined) {
|
|
const selectElement = newRow.querySelector('.db-column-name-select');
|
|
selectElement.value = data.db_column_name;
|
|
}
|
|
}
|
|
|
|
function removeHTMLInput(element, container_id)
|
|
{
|
|
const container = document.getElementById(container_id);
|
|
const rows = container.querySelectorAll('.dynamic-form-row');
|
|
|
|
if (rows.length > 1) {
|
|
const row = element.closest('.dynamic-form-row');
|
|
row.remove();
|
|
}
|
|
}
|
|
|
|
function appendFileTableBody(data)
|
|
{
|
|
console.log(data);
|
|
|
|
$('#table_bd').empty();
|
|
|
|
$.each(data, function(index, item) {
|
|
var row = $('<tr>');
|
|
|
|
row.append($('<td>').text(index+1));
|
|
row.append($('<td>').text(item.doc_name));
|
|
row.append($('<td>').text(item.file_name));
|
|
|
|
var url = '<?= base_url('download-kyc-docs/') ?>' + item.file_name;
|
|
|
|
|
|
var link = $('<a>')
|
|
.attr('href', url)
|
|
.attr('target', '_blank') // Open in a new tab
|
|
.attr('style', 'font-size:18px;')
|
|
.attr('data-id', item.id)
|
|
.addClass('mdi mdi-download')
|
|
|
|
|
|
// Append the <a> tag inside the <td>
|
|
row.append($('<td>').append(link));
|
|
$('#table_bd').append(row);
|
|
});
|
|
}
|
|
</script>
|