1665 lines
56 KiB
PHP
Executable File
1665 lines
56 KiB
PHP
Executable File
<style>
|
|
.table th,
|
|
.table td {
|
|
padding: 8px;
|
|
}
|
|
|
|
table.dataTable tbody td {
|
|
padding: 4px 4px !important;
|
|
}
|
|
|
|
/* table.dataTable thead th {
|
|
padding: 4px 4px !important;
|
|
} */
|
|
|
|
.col-12 {
|
|
|
|
max-width: 98% !important;
|
|
}
|
|
|
|
.dataTables_filter {
|
|
position: absolute;
|
|
}
|
|
|
|
.highlight {
|
|
border: 2px solid red;
|
|
background-color: #ffe6e6;
|
|
}
|
|
|
|
.column-header {
|
|
margin-right: 10px; /* Adjust this value as needed */
|
|
}
|
|
|
|
.form-section {
|
|
border: 1px solid #ccc;
|
|
padding: 15px;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.row-box {
|
|
border: 1px solid #ccc;
|
|
padding: 10px;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.addbtnStyle{
|
|
margin-left: 20px !important;
|
|
}
|
|
.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>
|
|
|
|
<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%;
|
|
}
|
|
</style>
|
|
|
|
<div class="row" id="inception_filter">
|
|
<div class="col-12" style="margin-top: -12px;">
|
|
<div id="accordion" class="mb-3">
|
|
<div class="card mb-1">
|
|
<h4 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>
|
|
</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_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-3">
|
|
<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-3">
|
|
<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-3">
|
|
<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>
|
|
|
|
<div class="form-row">
|
|
|
|
<div class="form-group col-md-3">
|
|
<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-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/inception/list"); ?>" class="btn btn-secondary" id="clear-filters">Clear</a>
|
|
<a href="<?= base_url("/policy_tranction/inception/list"); ?>" class="btn btn-primary" id="get-emp-list" onclick="fetchEmpolyeeList(event);">Submit</a>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row" id="inception_list">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="row" style="margin-bottom:1rem;">
|
|
<div class="col-6" style="align-self: center;">
|
|
<h4 style="position: relative;">Policy List</h4>
|
|
</div>
|
|
|
|
<div class="col-3" id="status_change" style="text-align: right; position: relative;top: 56px; left: 291px;">
|
|
<!-- <button type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light" onclick="hide_list_show_add();">Add</button> -->
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<table class="table table-striped mb-0 nowrap" cellspacing="0" id="tickets-table">
|
|
<thead class="bg-light">
|
|
<tr>
|
|
<th><div class="column-header">S.No.</div></th>
|
|
<th><div class="column-header">Issuer</div></th>
|
|
<th><div class="column-header">Issuing Type</div></th>
|
|
<th><div class="column-header">Client Type</div></th>
|
|
<th><div class="column-header">Client / Branch</div></th>
|
|
<th><div class="column-header">Insurer</div></th>
|
|
<th><div class="column-header">Policy</div></th>
|
|
<th><div class="column-header">Policy No</div></th>
|
|
<th><div class="column-header">Policy Issue Date</div></th>
|
|
<th><div class="column-header">D.O.C</div></th>
|
|
<th><div class="column-header">D.O.E</div></th>
|
|
<th><div class="column-header">No of Insured</div></th>
|
|
<th><div class="column-header">No of Dependents</div></th>
|
|
<th><div class="column-header">Status</div></th>
|
|
<th><div class="column-header">Action</div></th>
|
|
</tr>
|
|
</thead>
|
|
|
|
<tbody>
|
|
<?php foreach($inception_data_list as $index => $row){ ?>
|
|
<tr>
|
|
<td><?php echo $index+1; ?></td>
|
|
<td><?php echo $issuer[$row['issuer']]; ?></td>
|
|
<td><?php echo $issuing_type[$row['issue_type']]; ?></td>
|
|
<td><?php echo $client_type[$row['client_type']] ?? '-'; ?></td>
|
|
<td><?php echo $row['client_type'] == 2 ? $row['client_name'] : $row['client_short_name'] . ' - ' . $row['client_branch_name']; ?></td>
|
|
<td><?php echo $row['insurer_short_name']; ?></td>
|
|
<td><?php echo $row['policy_type']; ?></td>
|
|
<td><?php echo $row['policy_no']; ?></td>
|
|
<td><?php echo empty($row['policy_issue_date']) ? '' : date('d/m/Y', strtotime($row['policy_issue_date'])); ?></td>
|
|
<td><?php echo empty($row['policy_issue_date']) ? '' : date('d/m/Y', strtotime($row['policy_start_date'])); ?></td>
|
|
<td><?php echo empty($row['policy_issue_date']) ? '' : date('d/m/Y', strtotime($row['policy_end_date'])); ?></td>
|
|
<td class="right-align-input"><?php echo $row['emp_count']; ?></td>
|
|
<td class="right-align-input"><?php echo $row['dependent_count']; ?></td>
|
|
<td><?php echo $policy_status[$row['status']]; ?></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 class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" onclick="getPolicyTransactionDataForEdit('<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>')">
|
|
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
|
|
</a>
|
|
<a class="dropdown-item" data-id="<?= $row['id'];?>" onclick="removePolicyTransaction(this, '<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>')">
|
|
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<?php } ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div><!-- end col -->
|
|
</div>
|
|
<!-- end table row -->
|
|
|
|
|
|
<?php include('pt_form_file_upload_tab.php'); ?>
|
|
|
|
<div class="modal fade" id="file_upload" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog modal-full-width">
|
|
<div class="modal-content">
|
|
|
|
|
|
<div class="modal-body p-4">
|
|
<div class="">
|
|
|
|
<form role="form" class="parsley-examples" action="<?= base_url('util/file_upload') ?>" method="post" id="file_upload_form" enctype="multipart/form-data">
|
|
|
|
<div class="form-group">
|
|
|
|
<div id="dynamic-form-container"></div>
|
|
|
|
</div>
|
|
|
|
<div class="form-group text-right m-b-0">
|
|
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
|
|
id="btnSubmit">Submit</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|
const table = document.getElementById("tickets-table");
|
|
|
|
// 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;
|
|
|
|
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>
|
|
|
|
var client_list = ''; // local variable for storing the client branch list
|
|
var branch_list = ''; // local variable for storing the client branch list
|
|
var policy_list = ''; // local variable for storing the client policy list
|
|
var vehicle_list = ''; // local variable for storing the client policy list
|
|
var branch_policy = '';
|
|
var unit_list = '';
|
|
var count = 0
|
|
|
|
//for disable all field if client and client branch is empty
|
|
$(document).ready(function() {
|
|
|
|
function checkAndDisableFields() {
|
|
var clientId = $('#client_id').val();
|
|
var clientBranchId = $('#client_branch_id').val();
|
|
|
|
if (!clientId || !clientBranchId) {
|
|
// Disable all input, select, textarea, and button elements, including policy_no and insurer_id
|
|
$('#inception_form_id').find(':input, select, textarea, button').not('#client_id, #client_branch_id').prop('disabled', true).addClass('disabled-field');
|
|
} else {
|
|
$('#inception_form_id').find(':input, select, textarea, button').not('#client_id, #client_branch_id').prop('disabled', false).removeClass('disabled-field');
|
|
}
|
|
}
|
|
|
|
// Check on page load
|
|
// checkAndDisableFields();
|
|
|
|
// // Check whenever these fields are updated
|
|
// $('#client_id, #client_branch_id').on('change keyup', function() {
|
|
// checkAndDisableFields();
|
|
// });
|
|
|
|
// Attach event handler to show toastr if user clicks on any disabled field
|
|
$('#inception_form_id').on('click', '.disabled-field', function(e) {
|
|
e.preventDefault();
|
|
toastr.warning('Please select Client and Client Branch before filling out the form.');
|
|
});
|
|
});
|
|
|
|
// select2 document ready
|
|
$(document).ready(function(){
|
|
|
|
getClientAndBranchAndPolicy()
|
|
addHTMLInput();
|
|
addHTMLInputForVehicleFileUpload()
|
|
|
|
<?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();
|
|
$('#insurer_branch').select2();
|
|
$('#tpa').select2();
|
|
$('#base_policy').select2();
|
|
$('#source_client_policy_id').select2();
|
|
$('#sales_generated_by').select2();
|
|
$('#serviced_by').select2();
|
|
$('#policy_type_id').select2();
|
|
$('#ppteam').select2();
|
|
})
|
|
|
|
// Datatable document ready
|
|
$(document).ready(function() {
|
|
|
|
var ticketsTable = $('#tickets-table');
|
|
|
|
if (ticketsTable.length) {
|
|
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'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
|
|
buttons: [
|
|
{
|
|
extend: 'csv',
|
|
text: 'CSV',
|
|
title: 'Policy-Tranction-Inception-List',
|
|
exportOptions: {
|
|
columns: ':not(:last-child)'
|
|
},
|
|
},
|
|
{
|
|
text: 'Add',
|
|
className: 'buttons-html5 addbtnStyle',
|
|
action: function (e, dt, node, config) {
|
|
hide_list_show_add();
|
|
}
|
|
}
|
|
|
|
],
|
|
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.");
|
|
}
|
|
});
|
|
|
|
// Date document ready
|
|
$(document).ready(function(){
|
|
|
|
var today = new Date();
|
|
|
|
var opening_date = flatpickr("#opening_date", {
|
|
dateFormat: "d/m/Y",
|
|
allowInput: false
|
|
});
|
|
|
|
var policy_start_date = flatpickr("#policy_start_date", {
|
|
dateFormat: "d/m/Y",
|
|
defaultDate: today,
|
|
allowInput: false,
|
|
onChange: function(selectedDates, dateStr, instance) {
|
|
var policy_end_date = new Date(selectedDates[0]);
|
|
policy_end_date.setFullYear(policy_end_date.getFullYear() + 1);
|
|
policy_end_date.setDate(policy_end_date.getDate() - 1); // Set end date to last day of selected year
|
|
policy_end_datePicker.setDate(policy_end_date);
|
|
|
|
// Calculate renewal date (one month before the end date)
|
|
var renewal_date = new Date(policy_end_date);
|
|
// renewal_date.setMonth(renewal_date.getMonth() - 1);
|
|
renewal_datePicker.setDate(renewal_date); // Set renewal date
|
|
}
|
|
});
|
|
|
|
// Calculate the end date (today + 1 year)
|
|
var closeDate = new Date(today);
|
|
closeDate.setFullYear(closeDate.getFullYear() + 1);
|
|
closeDate.setDate(closeDate.getDate() - 1); // Set end date to last day of next year
|
|
|
|
var policy_end_datePicker = flatpickr("#policy_end_date", {
|
|
dateFormat: "d/m/Y",
|
|
defaultDate: closeDate,
|
|
allowInput: false
|
|
});
|
|
|
|
var renewal_datePicker = flatpickr("#renewal_date", {
|
|
dateFormat: "d/m/Y",
|
|
allowInput: false
|
|
});
|
|
|
|
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);
|
|
}
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
//--------------------------------------------------------------------------------------------------------
|
|
|
|
function hide_list_show_add()
|
|
{
|
|
$('#page_title').text('Add Policy')
|
|
$('#inception_form_id')[0].reset();
|
|
$('#client_id').val('').change().prop('disabled', false);
|
|
$('#tpa').val('').change().prop('disabled', false);
|
|
$('#client_id_for_edit').val('');
|
|
$('#policy_tranction_primarykey').val('');
|
|
$('#client_policy_id').val('');
|
|
$('#client_branch_id').val('').change().prop('disabled', false);
|
|
$('#insurer_id').val('');
|
|
$('#cd_ac_no').empty().prop('disabled', false);
|
|
$('#policy_no').val('').change().prop('disabled', false);
|
|
$('#source_client_policy_id').val('').prop('disabled', false);
|
|
$('#policy_end_date').prop('disabled', false);
|
|
$('#policy_start_date').prop('disabled', false);
|
|
$('#client_type').prop('disabled', false);
|
|
$('#policy_type_id').prop('disabled', false);
|
|
|
|
$('#invoice_no_div').hide()
|
|
$('.current_date').hide()
|
|
$('#invoice_no').attr('required', false)
|
|
|
|
$('#pt_onboarding').show()
|
|
$('#inception_list').hide()
|
|
$('#inception_filter').hide()
|
|
$('#policyholdernamediv').hide();
|
|
$('.branchdiv').show();
|
|
}
|
|
|
|
function show_list_hide_add()
|
|
{
|
|
$('#pt_onboarding').hide()
|
|
$('#inception_list').show()
|
|
$('#inception_filter').show();
|
|
$('#nav_pills').empty()
|
|
$('#tab_content').empty()
|
|
count = 0
|
|
}
|
|
|
|
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;
|
|
vehicle_list = res.vehicle_data;
|
|
unit_list = res.unit_data;
|
|
appendClients(res.client_data);
|
|
appendVehicles(res.vehicle_data);
|
|
appendOwner(client_list)
|
|
}else{
|
|
console.log('No data found');
|
|
}
|
|
|
|
},
|
|
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) {
|
|
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);
|
|
});
|
|
|
|
}
|
|
|
|
function appendVehicles(data, vehicle_id)
|
|
{
|
|
$('#vehicle_no').empty();
|
|
|
|
$('#vehicle_no').append($('<option>', {
|
|
value: '',
|
|
text: 'Select Vehicle'
|
|
}));
|
|
|
|
$('#vehicle_no').append($('<option>', {
|
|
value: 'add_vehicle',
|
|
text: '+ Add Vehicle'
|
|
}));
|
|
|
|
$.each(data, function(index, item) {
|
|
var option = $('<option>', {
|
|
value: item.id,
|
|
text: item.vehicle_no,
|
|
'data-cid': item.owner,
|
|
'data-bid': item.branch_id,
|
|
'data-cty': item.client_type,
|
|
});
|
|
if (vehicle_id == item.id) {
|
|
option.attr('selected', true);
|
|
}
|
|
$('#vehicle_no').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 appendRenewalPolicies(data)
|
|
{
|
|
console.log('appendRenewalPolicies', data);
|
|
console.log('appendRenewalPolicies', $('#source_client_policy_id'));
|
|
|
|
$('#source_client_policy_id').empty();
|
|
$('#source_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-insurer' : item.insurer_id,
|
|
'data-ib' : item.insurer_branch_id,
|
|
'data-policy' : item.policy_no,
|
|
'data-cd' : item.cd_ac_no,
|
|
'data-ps' : item.policy_start_date,
|
|
'data-pe' : item.policy_end_date,
|
|
'data-tpa' : item.tpa_id,
|
|
'data-tpab' : item.tpa_branch_id,
|
|
});
|
|
$('#source_client_policy_id').append(option);
|
|
});
|
|
}
|
|
|
|
// function getCDAccountNumber(client_id, insurer_id)
|
|
// {
|
|
// console.log('getCDAccountNumber')
|
|
|
|
// // var client_id = $('#client_id').val()
|
|
// // var insurer_id = $('#insurer_id').find('option:selected').attr('data-id');
|
|
|
|
// console.log('client_id', client_id)
|
|
// console.log('insurer_id', insurer_id)
|
|
|
|
// if(client_id && insurer_id){
|
|
// $.ajax({
|
|
// url: '<?= base_url("/util/getCDAccNoByClientAndInsurer/") ?>' + client_id + '/' + insurer_id,
|
|
// type: "GET",
|
|
// dataType: 'json',
|
|
// success: function(res) {
|
|
|
|
// console.log('cd_res', res);
|
|
// if(res.status == true){
|
|
// // appendCDAccountNumber(res.data[0].cd_ac_no)
|
|
// if(res.data[0].cd_ac_no){
|
|
// $('#cd_ac_no').val(res.data[0].cd_ac_no)
|
|
// }
|
|
// }else{
|
|
// toastr.warning('The insurer does not has a CD account number');
|
|
// }
|
|
|
|
// },
|
|
// error: function(xhr, status, error) {
|
|
// console.error(xhr.responseText);
|
|
// console.error(status, error);
|
|
// }
|
|
// });
|
|
// }
|
|
// }
|
|
|
|
// function appendCDAccountNumber(data)
|
|
// {
|
|
// console.log('appendCDAccountNumber', data);
|
|
// console.log('appendCDAccountNumber', $('#cd_ac_no'));
|
|
|
|
// $('#cd_ac_no').empty();
|
|
|
|
// $('#cd_ac_no').append($('<option>', {
|
|
// value: '',
|
|
// text: 'Select Policy',
|
|
// }));
|
|
|
|
// $('#cd_ac_no').append($('<option>', {
|
|
// value: 'add_cd',
|
|
// text: '+ Add CD'
|
|
// }));
|
|
|
|
// $.each(data, function(index, item) {
|
|
// var option = $('<option>', {
|
|
// value: item.cd_ac_no,
|
|
// text: item.cd_ac_no,
|
|
// });
|
|
// $('#cd_ac_no').append(option);
|
|
// });
|
|
// }
|
|
|
|
// function addCDAccountNumber(input)
|
|
// {
|
|
// var val = $(input).val();
|
|
// var client_id = $('#client_id').val();
|
|
// var insurer_id = $('#insurer_id').val();
|
|
|
|
// console.log('addCDAccountNumber', 'addCDAccountNumber');
|
|
// console.log('client_id', client_id);
|
|
// console.log('insurer_id', insurer_id);
|
|
|
|
// if(client_id == '' || insurer_id == ''){
|
|
// toastr.warning('Client, Insurer, or both do not exist.');
|
|
// $(input).val('')
|
|
// return false;
|
|
// }
|
|
|
|
// if(val == 'add_cd')
|
|
// {
|
|
// var myModal = new bootstrap.Modal(document.getElementById('cd_form_modal'));
|
|
// myModal.show();
|
|
// $(input).val('')
|
|
// }
|
|
// }
|
|
|
|
function getPolicyDetailsByPolicyId(input)
|
|
{
|
|
var policy_id = $(input).val()
|
|
|
|
if(policy_id){
|
|
|
|
$.ajax({
|
|
url: '<?= base_url("/util/getPolicyDetailsByPolicyId/") ?>' + policy_id,
|
|
type: "GET",
|
|
dataType: 'json',
|
|
success: function(res) {
|
|
|
|
console.log('cd_res', res);
|
|
|
|
},
|
|
error: function(xhr, status, error) {
|
|
console.error(xhr.responseText);
|
|
console.error(status, error);
|
|
}
|
|
});
|
|
|
|
}
|
|
}
|
|
|
|
function addHTMLInput(data = null)
|
|
{
|
|
const container = document.getElementById('dynamic-form-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">*</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">*</span></label>
|
|
<input type="file" class="form-control" id="file_name" name="file[]" required>
|
|
</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)">x</a>
|
|
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="addHTMLInput(this)">+</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)
|
|
{
|
|
const container = document.getElementById('dynamic-form-container');
|
|
const rows = container.querySelectorAll('.dynamic-form-row');
|
|
|
|
if (rows.length > 1) {
|
|
const row = element.closest('.dynamic-form-row');
|
|
row.remove();
|
|
}
|
|
}
|
|
|
|
function appendBasePolicyList(data, select = null)
|
|
{
|
|
console.log('---------------------------------------------------------------')
|
|
console.log('first')
|
|
console.log('---------------------------------------------------------------')
|
|
|
|
$('#base_policy').empty();
|
|
$('#base_policy').append($('<option>', {
|
|
value: '',
|
|
text: 'Select Base Policy'
|
|
}));
|
|
|
|
$.each(data, function(index, item) {
|
|
|
|
const option = $('<option>', {
|
|
value: item.id,
|
|
text:`${item.policy_type ?? ''} - ${item.policy_no ?? ''}`,
|
|
'data-id': item.id
|
|
});
|
|
|
|
$('#base_policy').append(option);
|
|
});
|
|
}
|
|
|
|
function appendUnits(data)
|
|
{
|
|
$('#units').empty()
|
|
$('#units').append($('<option>', {
|
|
value: '',
|
|
text: 'Select Unit'
|
|
}));
|
|
|
|
|
|
|
|
$.each(data, function(index, item) {
|
|
|
|
var option = $('<option>', {
|
|
value: item,
|
|
text: item
|
|
});
|
|
|
|
if(data.length == 1){
|
|
option.attr('selected', true);
|
|
}
|
|
|
|
$('#units').append(option);
|
|
});
|
|
}
|
|
|
|
function fileupload(input)
|
|
{
|
|
var myModal = new bootstrap.Modal(document.getElementById('file_upload'));
|
|
myModal.show();
|
|
}
|
|
|
|
function logSelectedIds()
|
|
{
|
|
var selectedIds = [];
|
|
$('.row-select:checked').each(function() {
|
|
selectedIds.push($(this).data('id'));
|
|
});
|
|
// console.log('Selected IDs:', selectedIds);
|
|
return selectedIds;
|
|
|
|
}
|
|
|
|
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('/downloadGdriveFile'); ?>" +
|
|
// "?client_id=" + item.client_id +
|
|
// "&file_type=policy" +
|
|
// "&file_name=" + item.file_name +
|
|
// "&client_policy_id=" + item.client_policy_id;
|
|
|
|
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('fa fa-download')
|
|
|
|
|
|
// Append the <a> tag inside the <td>
|
|
row.append($('<td>').append(link));
|
|
$('#table_bd').append(row);
|
|
});
|
|
}
|
|
|
|
function checkInputs()
|
|
{
|
|
let isValid = true;
|
|
|
|
// Iterate through each dynamic row
|
|
$('.dynamic-form-row').each(function() {
|
|
const docNameField = $(this).find('input[name="doc_name[]"]');
|
|
const fileField = $(this).find('input[name="file[]"]');
|
|
const docName = docNameField.val().trim();
|
|
const fileName = fileField.val().trim();
|
|
|
|
// Remove previous highlight classes
|
|
docNameField.removeClass('highlight');
|
|
fileField.removeClass('highlight');
|
|
|
|
if (docName === '' && fileName !== '') {
|
|
toastr.warning('Document Name is required.');
|
|
docNameField.addClass('highlight');
|
|
isValid = false;
|
|
} else if (docName !== '' && fileName === '') {
|
|
toastr.warning('File is required.');
|
|
fileField.addClass('highlight');
|
|
isValid = false;
|
|
} else if(docName === '' && fileName === '') {
|
|
toastr.warning('Both Fields is required.');
|
|
fileField.addClass('highlight');
|
|
docNameField.addClass('highlight');
|
|
isValid = false;
|
|
}
|
|
});
|
|
|
|
return isValid;
|
|
}
|
|
|
|
function validateForm()
|
|
{
|
|
return checkInputs(); // Call checkInputs before form submission
|
|
}
|
|
|
|
function addHTMLInputForVehicleFileUpload(data = null)
|
|
{
|
|
const container = document.getElementById('dynamic-form-container-for-vehicle-file-upload');
|
|
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">*</span></label>
|
|
<input type="text" class="form-control" id="docs_name" name="other_docs_name[]" placeholder="Enter file name" required>
|
|
</div>
|
|
<div class="form-group col-md-5">
|
|
<label for="file">Upload File<span class="text-danger">*</span></label>
|
|
<input type="file" class="form-control" id="file_name" name="file_name[]" required>
|
|
</div>
|
|
<div class="form-group col-md-2" style="position: relative;top: 28px;">
|
|
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInputForVehicleFileUpload(this)">x</a>
|
|
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="addHTMLInputForVehicleFileUpload(this)">+</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 appendVehicleFileTableBody(data)
|
|
{
|
|
console.log(data);
|
|
|
|
// Clear the table body
|
|
$('#vehicle_table_bd').empty();
|
|
|
|
$.each(data, function(index, item) {
|
|
var row = $('<tr>');
|
|
|
|
// Add row number, document name, and file name
|
|
row.append($('<td>').text(index + 1));
|
|
row.append($('<td>').text(item.other_docs_name));
|
|
row.append($('<td>').text(item.file_name));
|
|
|
|
// Create the download link
|
|
var downloadLink = $('<a>')
|
|
.attr('href', '<?= base_url('download-kyc-docs/') ?>' + item.file_name)
|
|
.attr('style', 'font-size:18px;')
|
|
.attr('data-id', item.id)
|
|
.addClass('fa fa-download')
|
|
.text(' '); // Space after the icon
|
|
|
|
// Create the delete link
|
|
var deleteLink = $('<a>')
|
|
.attr('style', 'font-size:18px;')
|
|
.attr('data-id', item.id)
|
|
.addClass('fa fa-trash')
|
|
.text(' '); // Space after the icon
|
|
|
|
// Append the download and delete icons inside the same <td>
|
|
row.append($('<td>').append(downloadLink));
|
|
|
|
// Append the row to the table body
|
|
$('#vehicle_table_bd').append(row);
|
|
});
|
|
}
|
|
|
|
function removeHTMLInputForVehicleFileUpload(element)
|
|
{
|
|
const container = document.getElementById('dynamic-form-container-for-vehicle-file-upload');
|
|
const rows = container.querySelectorAll('.dynamic-form-row');
|
|
|
|
if (rows.length > 1) {
|
|
const row = element.closest('.dynamic-form-row');
|
|
row.remove();
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
$(document).ready(function(){
|
|
|
|
$('#client_id').change(function(){
|
|
|
|
let client_id = $(this).val();
|
|
let client_name = $('#client_id option:selected').data('cn');
|
|
let client_type = $('#client_id option:selected').data('ct');
|
|
|
|
|
|
console.log('client_name',client_name);
|
|
console.log('client_type',client_type);
|
|
console.log('client_id', client_id);
|
|
|
|
$('#policy_holder_name').val(client_name);
|
|
|
|
if(client_id == 'add_client') {
|
|
|
|
if($('#client_type').val()){
|
|
$('#client_id').val('').change();
|
|
var myModal = new bootstrap.Modal(document.getElementById('upload_enrollment_model'));
|
|
myModal.show();
|
|
}else{
|
|
$('#client_id').val('').change();
|
|
toastr.warning('Please select the client type', 'Warning')
|
|
}
|
|
}
|
|
|
|
if(branch_list != '') {
|
|
// console.log(branch_list[client_id]);
|
|
let data = branch_list[client_id];
|
|
appendBranch(data);
|
|
}
|
|
|
|
})
|
|
|
|
// $('#client_branch_id').change(function(){
|
|
|
|
// let client_branch_id = $(this).val();
|
|
|
|
// console.log('client_branch_id', client_branch_id);
|
|
// console.log('unit_list', unit_list);
|
|
|
|
|
|
// if(unit_list != '') {
|
|
// console.log(unit_list[client_branch_id]);
|
|
// let data = unit_list[client_branch_id];
|
|
// appendUnits(data);
|
|
// }
|
|
|
|
// })
|
|
});
|
|
|
|
$('#issue_type').change(function(){
|
|
|
|
let value = $(this).val()
|
|
|
|
if(value == 1){
|
|
$('#revenue_type').val('NA');
|
|
}
|
|
|
|
if(value == 2){
|
|
$('#revenue_type').val('EA')
|
|
$('#renewal').show()
|
|
// $('.sded_dates').show()
|
|
// $('#source_client_policy_id').attr('required', true)
|
|
}else{
|
|
$('#renewal').hide()
|
|
// $('.sded_dates').hide()
|
|
// $('#source_client_policy_id').attr('required', false)
|
|
$('#policy_start_date').val('');
|
|
$('#policy_end_date').val('');
|
|
}
|
|
|
|
if(value == 3){
|
|
$('.roll_div').show();
|
|
}else{
|
|
$('.roll_div').hide();
|
|
}
|
|
})
|
|
|
|
$('#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)
|
|
|
|
}
|
|
})
|
|
|
|
$("#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');
|
|
}
|
|
});
|
|
});
|
|
|
|
$('#cd_ac_no_data').change(function(){
|
|
|
|
var cd_ac_no = $(this).val();
|
|
// console.log(cd_ac_no +'-'+cd_ac_no.length);
|
|
cd_ac_no = cd_ac_no.trim();
|
|
// console.log(cd_ac_no +'-'+cd_ac_no.length);
|
|
|
|
|
|
$.ajax({
|
|
url: '<?php echo base_url('util/check_cd_ac_no/');?>'+cd_ac_no,
|
|
type: "GET",
|
|
dataType: 'json',
|
|
success: function (res) {
|
|
|
|
console.log('CD Account Number Responcce', res)
|
|
if(res.status == true){
|
|
toastr.warning(res.message, 'Warning');
|
|
$('#cd_ac_no_data').val('');
|
|
}
|
|
},
|
|
error: function (xhr, status, error) {
|
|
console.error(xhr.responseText);
|
|
console.error(status, error);
|
|
}
|
|
});
|
|
|
|
})
|
|
|
|
// $('#policy_type_id').change(function() {
|
|
|
|
// var policy_type_id = $(this).val();
|
|
|
|
// var client_id = $('#client_id').val();
|
|
// var client_branch_id = $('#client_branch_id').val();
|
|
|
|
// // if (policy_type_id == 1 || policy_type_id == 6 || policy_type_id == 7) {
|
|
// // $('#tpa').prop('required', false);
|
|
// // $('#tpa_danger').hide()
|
|
// // } else {
|
|
// // $('#tpa').prop('required', true);
|
|
// // $('#tpa_danger').show()
|
|
// // }
|
|
|
|
// if(policy_type_id == 3 || policy_type_id == 4 || policy_type_id == 5) {
|
|
// $('#base_policy_id').show();
|
|
// }else{
|
|
// $('#base_policy_id').hide();
|
|
// }
|
|
|
|
// if(client_id && client_branch_id){
|
|
|
|
// var url_for_get_policy_type_list = '<?php echo base_url('util/get_policy_type_for_base_policy/') ?>' + client_id + '/' + client_branch_id;
|
|
// $.get(url_for_get_policy_type_list, function(response){
|
|
// console.log(response)
|
|
// appendBasePolicyList(response.data);
|
|
// }).fail(function(xhr, status, error) {
|
|
// console.error(xhr.responseText);
|
|
// console.error(status, error);
|
|
// });
|
|
// }
|
|
|
|
// //------------------------------------------------------------
|
|
|
|
|
|
// // var selectedOption = this.options[this.selectedIndex];
|
|
|
|
// // var ebp = selectedOption.getAttribute('data-ebp');
|
|
// // var etp = selectedOption.getAttribute('data-etp');
|
|
// // var iep = selectedOption.getAttribute('data-iep');
|
|
// // var itp = selectedOption.getAttribute('data-itp');
|
|
|
|
// // console.log('EBP:', ebp);
|
|
// // console.log('ETP:', etp);
|
|
// // console.log('IEP:', iep);
|
|
// // console.log('ITP:', itp);
|
|
|
|
// // document.getElementById('Standard_bp').value = ebp;
|
|
// // document.getElementById('Standard_tp').value = etp;
|
|
|
|
// })
|
|
|
|
$('#issue_type').change(function(){
|
|
|
|
let issue_type = $(this).val();
|
|
let branch_id = $('#client_branch_id').val();
|
|
|
|
console.log(branch_id);
|
|
|
|
if(policy_list != '' && branch_id != '') {
|
|
console.log(policy_list[branch_id]);
|
|
let data = policy_list[branch_id];
|
|
if(issue_type == 2)
|
|
{
|
|
appendRenewalPolicies(data);
|
|
}
|
|
}
|
|
});
|
|
|
|
//--------------------------------------------------------------------------------------------------------
|
|
|
|
function formatDateforpolicy(dateStr)
|
|
{
|
|
|
|
let dateParts = dateStr.split('-');
|
|
let year = dateParts[0];
|
|
let month = dateParts[1];
|
|
let day = dateParts[2];
|
|
|
|
var date = day + '-' + month + '-' + year;
|
|
|
|
// return `${day}-${month}-${year}`;
|
|
return date;
|
|
}
|
|
|
|
function onlyNumbers(event)
|
|
{
|
|
var charcode;
|
|
charcode = event.which || event.keyCode;
|
|
if (charcode >= 48 && charcode <= 57 || charcode == 46) return true;
|
|
return 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)
|
|
|
|
// 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('status', status)
|
|
|
|
// 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_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');
|
|
|
|
// 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_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) {
|
|
|
|
confirmActionSweertAlert("Do you want to delete this transaction?", "Yes, Proceed!", "No, Cancel").then((confirmed) => {
|
|
if (confirmed) {
|
|
let url = '<?= base_url('policy_tranction/inception/removePolicyTransaction/') ?>' + pt_id;
|
|
|
|
// Include `pt_id` in the AJAX request if necessary
|
|
let requestData = { pt_id: pt_id };
|
|
|
|
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);
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
|
|
</script>
|