4586 lines
220 KiB
PHP
Executable File
4586 lines
220 KiB
PHP
Executable File
<style>
|
||
.co_share_table {
|
||
width: 39% !important;
|
||
/* margin-bottom: 1rem;
|
||
color: #212529; */
|
||
}
|
||
|
||
#insurerTableContainer {
|
||
/* max-height: 400px; */
|
||
overflow-y: auto;
|
||
margin-top: 20px;
|
||
/* overflow-x: auto; */
|
||
position: relative;
|
||
}
|
||
|
||
#insurerTable thead th:first-child,
|
||
#insurerTable tbody td:first-child {
|
||
position: sticky;
|
||
left: 0;
|
||
background-color: #fff;
|
||
z-index: 1;
|
||
width: 200px;
|
||
min-width: 200px;
|
||
max-width: 200px;
|
||
white-space: nowrap;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
}
|
||
|
||
#insurerTable input[type="text"] {
|
||
border: none;
|
||
box-shadow: none;
|
||
outline: none;
|
||
width: 100%;
|
||
}
|
||
#insurerTable th,
|
||
#insurerTable td {
|
||
padding: 5px;
|
||
height: 30px;
|
||
vertical-align: middle;
|
||
}
|
||
|
||
#insurerTable select {
|
||
height: 30px;
|
||
padding: 2px 5px;
|
||
}
|
||
|
||
#insurerTable input[type="checkbox"] {
|
||
margin: 0;
|
||
height: 20px;
|
||
width: 20px;
|
||
}
|
||
#insurerTable th,
|
||
#insurerTable th {
|
||
min-width: 230px;
|
||
}
|
||
|
||
.readonly-color {
|
||
background-color: #e0e0e0; /* Darker background */
|
||
color: #666; /* Darker text color */
|
||
}
|
||
|
||
.readonly-select {
|
||
pointer-events: none;
|
||
background-color: #f0f0f0;
|
||
color: #666;
|
||
}
|
||
|
||
.select2-hidden-accessible + .select2-container .select2-dropdown {
|
||
display: none !important;
|
||
}
|
||
|
||
.select2-container .select2-selection--multiple .select2-selection__choice {
|
||
color: #000000;
|
||
}
|
||
|
||
.highlighted {
|
||
background-color: #f0ad4e;
|
||
color: #fff;
|
||
}
|
||
|
||
.right-align-input {
|
||
text-align: right;
|
||
}
|
||
|
||
.input-with-percentage {
|
||
position: relative;
|
||
}
|
||
|
||
.input-with-percentage input {
|
||
padding-right: 20px;
|
||
text-align: right;
|
||
}
|
||
|
||
.input-with-percentage::after {
|
||
content: '%';
|
||
position: absolute;
|
||
right: 5px;
|
||
top: 50%;
|
||
transform: translateY(-50%);
|
||
font-weight: bold;
|
||
color: #000;
|
||
}
|
||
|
||
/* .select2-container .select2-selection__rendered {
|
||
min-height: 38px;
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
|
||
.select2-search__field{
|
||
height: 0px !important;
|
||
} */
|
||
|
||
.select2-selection__choice {
|
||
background-color: #0a8794 !important;
|
||
color: white !important;
|
||
font-weight: bold;
|
||
}
|
||
|
||
.select2-selection__choice__remove {
|
||
color: white !important;
|
||
margin-right: 5px;
|
||
}
|
||
</style>
|
||
|
||
<div class="tab-pane fade active show" id="form">
|
||
<input type="hidden" id="entity_type_id">
|
||
<div class="row" id="inception_form">
|
||
<div class="col-xl-12" style="max-width: 100% !important;">
|
||
<div class="card">
|
||
<div class="card-body">
|
||
<div class="row" style="margin-bottom:1rem;">
|
||
|
||
<div class="col-6" style="align-self: center;">
|
||
<h4 id="page_title" style="position: relative;">Add Policy</h4>
|
||
</div>
|
||
<div class="col-3" style="text-align: right; position: relative; left: 211px;">
|
||
<!-- <button class="btn btn-primary waves-effect waves-light" onclick="fileupload(this)">file upload</button> -->
|
||
</div>
|
||
<div class="col-1" style="text-align: right; position: relative; left: 193px;">
|
||
<a href="<?= base_url('policy_tranction/inception/list') ?>" type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light"
|
||
>Back</a>
|
||
</div>
|
||
</div>
|
||
<form role="form" class="parsley-examples" method="post" id="inception_form_id"
|
||
enctype="multipart/form-data">
|
||
|
||
<input type="hidden" name="id" id="policy_tranction_primarykey">
|
||
<input type="hidden" name="client_policy_id" id="client_policy_id">
|
||
<input type="hidden" name="client_id" id="client_id_for_edit">
|
||
<input type="hidden" name="insurer_id" id="insurer_id">
|
||
<input type="hidden" name="cd_ac_no" id="cd_ac_no">
|
||
<input type="hidden" name="ct_type" id="ct_type">
|
||
|
||
<!-- <input type="hidden" id="cd_ac_no_for_edit"> -->
|
||
<input type="hidden" id="premium_details_unique_id">
|
||
<input type="hidden" id="policy_tranction_policy_number">
|
||
|
||
<!-- Client Row -->
|
||
<div class="row">
|
||
<!-- Section 1 -->
|
||
<div class="col-md-12">
|
||
<div class="form-section">
|
||
<div id="accordion_0" class="mb-0">
|
||
<div class="card mb-0">
|
||
<h4 class="m-1">Client Details
|
||
<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_0">
|
||
<div class="row">
|
||
<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"
|
||
required>
|
||
<option value="">Select Policy Type</option>
|
||
<?php
|
||
if (isset($policy_types) && count($policy_types)) {
|
||
foreach ($policy_types as $key => $value) {
|
||
echo "<option value='" . $value['id'] . "'
|
||
data-ebp='" . $value['ebp'] . "'
|
||
data-etp='" . $value['etp'] . "'
|
||
data-etep='" . $value['etep'] . "'
|
||
data-iep='" . $value['iep'] . "'
|
||
data-itep='" . $value['itep'] . "'
|
||
data-itp='" . $value['itp'] . "'
|
||
data-bap='" . $value['bap'] . "'
|
||
>" .
|
||
$value['policy_type'] .
|
||
"</option>";
|
||
}
|
||
}
|
||
?>
|
||
</select>
|
||
</div>
|
||
<div class="form-group col-md-3" id="vhnodiv" style="display: none;">
|
||
<label for="bp_sgst">Vehicle No</label>
|
||
<select id="vehicle_no" type="text" class="form-control" name="vehicle_id">
|
||
<option value="">Select Vehicle</option>
|
||
<option value="add_vehicle"> + Add Vehicle</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="row">
|
||
|
||
<div class="form-group col-md-3 client_type_div">
|
||
<label for="client_type">Client Type<span class="text-danger">*</span></label>
|
||
<select class="form-control" id="client_type" name="client_type" required>
|
||
<option value="">Select Client type</option>
|
||
<option value="1">Group</option>
|
||
<option value="2">Individual</option>
|
||
</select>
|
||
</div>
|
||
|
||
<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" required>
|
||
<option value="">Select Client</option>
|
||
<option value="add_client"> + Add Client</option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group col-md-3 branchdiv">
|
||
<label for="client_branch">Branch<span class="text-danger">*</span></label>
|
||
<select class="form-control" id="client_branch_id" name="client_branch_id">
|
||
<option value="">Select Branch</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="">Select Issuer</option>
|
||
<?php
|
||
if (isset($issuer) && count($issuer)) {
|
||
foreach ($issuer as $key => $value) {
|
||
echo "<option value=" . $key . ">" . $value . "</option>";
|
||
}
|
||
}
|
||
?>
|
||
</select>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Pre sales Row -->
|
||
<div class="row">
|
||
<div class="col-md-12">
|
||
<div class="form-section">
|
||
<div id="accordion_1" class="mb-0">
|
||
<div class="card mb-0">
|
||
<h4 class="m-1">Pre Sales
|
||
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseTwo" aria-expanded="true">
|
||
<i id="icon" class="mdi mdi-chevron-down mr-1 text-primary" style="font-size: 28px;"></i>
|
||
</a>
|
||
</h4>
|
||
<div id="collapseTwo" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_1">
|
||
|
||
<div class="row" id="policyholdernamediv" style="display: none;">
|
||
<div class="form-group col-md-3">
|
||
<label for="bp_igst">Policyholder Name</label>
|
||
<input id="policy_holder_name" value="" type="text" class="form-control" name="policy_holder_name">
|
||
</div>
|
||
|
||
<div class="form-group col-md-3">
|
||
<label class="switch" style="position: relative;top: 30px;left: 4px;">
|
||
<input id="same_as_proposer" type="checkbox" name="same_as_proposer" checked>
|
||
<span class="slider round" style="height: 27px;"></span>
|
||
</label>
|
||
|
||
<label for="same_as_proposer"
|
||
style="position: relative;top: 31px;left: 17px;">Insured (Same as Proposer)</label>
|
||
</div>
|
||
</div>
|
||
<div class="row" id="family_details" style="display: none;">
|
||
<div class="col-md-12">
|
||
<div class="form-section">
|
||
<h4>Family details</h4>
|
||
<div id="dynamic-form-container-for-insured"></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<hr>
|
||
<div class="row">
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="addon_policy"> Issuing Type <span id="base_danger"
|
||
class="text-danger">*</span></label>
|
||
<select class="form-control" id="issue_type" name="issue_type" required>
|
||
<option value="" selected>Select Issue Type</option>
|
||
<?php
|
||
if (isset($issuing_type) && count($issuing_type)) {
|
||
foreach ($issuing_type as $key => $value) {
|
||
echo "<option value=" . $key . ">" . $value . "</option>";
|
||
}
|
||
}
|
||
?>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="bp_gst_amt">Business Type</label>
|
||
<select id="revenue_type" class="form-control" name="revenue_type">
|
||
<option>Select</option>
|
||
<option value="NA">NA</option>
|
||
<option value="EA">EA</option>
|
||
<option value="EANR">EANR</option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group col-md-3" id="renewal" style="display: none;">
|
||
<label for="addon_policy"> Renewal Source Policy <span id="base_danger"class="text-danger"></span></label>
|
||
<select class="form-control" id="source_client_policy_id"name="source_client_policy_id" onchange="setRenewalPolicyData(this)">
|
||
<option value="" selected>Select Renewal Source Policy</option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group col-md-3 sded_dates" style="display: none;">
|
||
<label for="addon_policy">Policy Start Date<span id="base_danger"
|
||
class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="renewal_policy_start_date"
|
||
name="renewal_policy_start_date" placeholder="DD/MM/YYYY" >
|
||
</div>
|
||
|
||
<div class="form-group col-md-3 sded_dates" style="display: none;">
|
||
<label for="addon_policy">Policy End Date<span id="base_danger"
|
||
class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="renewal_policy_end_date"
|
||
name="renewal_policy_end_date" placeholder="DD/MM/YYYY" >
|
||
</div>
|
||
|
||
<div class="form-group col-md-3 roll_div" style="display: none;">
|
||
<label for="rollover_date">Date of Expiring Policy for Rollover</label>
|
||
<input id="rollover_date" value="" type="text" class="form-control" name="rollover_date" placeholder="DD/MM/YYYY">
|
||
</div>
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="ref">Reference</label>
|
||
<input id="ref" value="" type="text" class="form-control" name="ref">
|
||
</div>
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="fund_received">Fund Recd / Sent to Insurer</label>
|
||
<input id="fund_received" value="" type="text" class="form-control" name="fund_received">
|
||
</div>
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="ppteam">PP Team</label>
|
||
<!-- <input id="ppteam" type="text" class="form-control" name="ppteam"> -->
|
||
<select class="form-control" id="ppteam" name="ppteam">
|
||
<option value="">Select PP Team</option>
|
||
<?php if (isset($ppTeamsData)) { ?>
|
||
<?php foreach ($ppTeamsData as $value) { ?>
|
||
<option value="<?= $value['id'];?>">
|
||
<?= $value['first_name'];?>
|
||
</option>
|
||
<?php } ?>
|
||
<?php } ?>
|
||
</select>
|
||
|
||
</div>
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="remark">Remarks</label>
|
||
<textarea id="remark" class="form-control" name="remarks" rows="1"></textarea>
|
||
</div>
|
||
|
||
<div class="form-group col-md-6">
|
||
<label for="listed_insurers">Shortlisted Insurers</label>
|
||
<select class="form-control" id="listed_insurers" name="listed_insurers" multiple>
|
||
<option value=""></option>
|
||
<?php foreach ($insurer_branch as $value) { ?>
|
||
<option value="<?= $value['id'] . '-' . $value['insurer_id'] ?>" data-id="<?= $value['insurer_id'] ?>">
|
||
<?= $value['insurer_name'] . '-' . $value['branch_code'] ?>
|
||
</option>
|
||
<?php } ?>
|
||
</select>
|
||
</div>
|
||
|
||
</div>
|
||
<hr>
|
||
<div class="row">
|
||
<div class="form-group col-md-3">
|
||
<label for="addon_policy"> Status <span id="base_danger"class="text-danger">*</span></label>
|
||
<select class="form-control" id="policy_status" name="status" required>
|
||
<option value="" selected>Select Status</option>
|
||
<?php
|
||
if (isset($policy_status) && count($policy_status)) {
|
||
foreach ($policy_status as $key => $value) {
|
||
if($key == 'pending'){
|
||
echo "<option value=" . $key . " selected>" . $value . "</option>";
|
||
}else{
|
||
echo "<option value=" . $key . ">" . $value . "</option>";
|
||
}
|
||
}
|
||
}
|
||
?>
|
||
</select>
|
||
</div>
|
||
<div class="form-group col-md-3 current_date" style="display: none;">
|
||
<label for="bp_cgst">Latest Action Date</label>
|
||
<input id="last_action_date" type="text" class="form-control" name="last_action_date" placeholder="DD/MM/YYYY">
|
||
</div>
|
||
<div class="form-group col-md-3 current_date" style="display: none;">
|
||
<label for="bp_igst">Process Start Date</label>
|
||
<input id="process_start_date" type="text" class="form-control" name="process_start_date" placeholder="DD/MM/YYYY">
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- sales Row -->
|
||
<div class="row" id="sales_row" style="display: none;">
|
||
<div class="col-md-12">
|
||
<div class="form-section">
|
||
<div id="accordion_2" class="mb-0">
|
||
<div class="card mb-0">
|
||
<h4 class="m-1">Sales
|
||
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseThree" aria-expanded="true">
|
||
<i id="icon" class="mdi mdi-chevron-down mr-1 text-primary" style="font-size: 28px;"></i>
|
||
</a>
|
||
</h4>
|
||
<div id="collapseThree" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_2">
|
||
<div class="row">
|
||
|
||
<div class="form-group col-md-3" id="base_policy_id" style="display: none;">
|
||
<label for="addon_policy">Base Policy<span id="base_danger"
|
||
class="text-danger">*</span></label>
|
||
<select class="form-control" id="base_policy" name="base_policy">
|
||
<option value="" selected>Select Base Policy</option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="addon_policy">Policy No<span id="base_danger"class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="policy_no" name="policy_no"placeholder="Enter Policy No" >
|
||
</div>
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="addon_policy">Policy Issue Date<span id="base_danger" class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="policy_issue_date" name="policy_issue_date" placeholder="DD/MM/YYYY" >
|
||
</div>
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="addon_policy">Policy Issue Month<span id="base_danger" class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="month" name="month" placeholder="MM/YYYY" >
|
||
</div>
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="bp_cgst">D.O.C</label>
|
||
<input id="policy_start_date" type="text" class="form-control" name="policy_start_date" placeholder="DD/MM/YYYY" >
|
||
</div>
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="bp_igst">D.O.E</label>
|
||
<input id="policy_end_date" type="text" class="form-control" name="policy_end_date" placeholder="DD/MM/YYYY" >
|
||
</div>
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="tpa"> TPA <span id="tpa_danger"class="text-danger"></span></label>
|
||
<select class="form-control" id="tpa" name="tpa" >
|
||
<option value="" selected>Select TPA</option>
|
||
<?php foreach ($tpa as $value) { ?>
|
||
<option value="<?= $value['id'] . '-' . $value['tpa_id'] ?>">
|
||
<?= $value['tpa_short_name'] . '-' . $value['branch_code'] ?>
|
||
</option>
|
||
<?php } ?>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="addon_policy">No of Insured<span id="base_danger"class="text-danger"></span></label>
|
||
<input type="text" class="form-control" id="emp_count" name="emp_count" placeholder="Enter Employeee" onkeypress="return onlyNumbers(event)">
|
||
</div>
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="addon_policy">No of Dependents<span id="base_danger" class="text-danger"></span></label>
|
||
<input type="text" class="form-control" id="dependent_count" name="dependent_count" placeholder="Enter Dependent" onkeypress="return onlyNumbers(event)">
|
||
</div>
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="installment">Installment</label>
|
||
<input id="installment" value="" type="text" class="form-control" name="installment">
|
||
</div>
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="installment_data">Installment Data</label>
|
||
<input id="installment_data" class="form-control" name="installment_data">
|
||
</div>
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="spl">SPL</label>
|
||
<input id="spl" value="" type="text" class="form-control" name="spl">
|
||
</div>
|
||
|
||
|
||
<div class="form-group col-md-2">
|
||
<label class="switch" style="position: relative;top: 30px;left: 4px;">
|
||
<input id="cop_yes" type="checkbox" name="co_share">
|
||
<span class="slider round" style="height: 27px;"></span>
|
||
</label>
|
||
|
||
<label for="inception_type"
|
||
style="position: relative;top: 31px;left: 17px;">CoP Yes</label>
|
||
</div>
|
||
|
||
<div class="form-group col-md-4 payby d-none">
|
||
<label class="switch" style="position: relative;top: 30px;left: 4px;">
|
||
<input id="bro_payable_by" type="checkbox" name="bro_payable_by" checked>
|
||
<span class="slider round" style="height: 27px;"></span>
|
||
</label>
|
||
|
||
<label for="inception_type" style="position: relative;top: 31px;left: 17px;">Remuneration Pay By Leader</label>
|
||
</div>
|
||
|
||
</div>
|
||
<hr>
|
||
<div class="row">
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="location">Location<span id="base_danger"class="text-danger"></span></label>
|
||
<input type="text" class="form-control" id="location" name="location"placeholder="Enter location" >
|
||
</div>
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="renewal_date">Renewal Date<span id="base_danger"
|
||
class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="renewal_date"
|
||
name="renewal_date" placeholder="DD/MM/YYYY">
|
||
</div>
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="sales_generated_by">Sales Generated By</label>
|
||
<select class="form-control" id="sales_generated_by" name="sales_generated_by">
|
||
<option value="" selected>Select Sales Person</option>
|
||
<?php if (isset($salse_team)) { ?>
|
||
<?php foreach ($salse_team as $value) { ?>
|
||
<option value="<?= $value['id'];?>">
|
||
<?= $value['first_name'];?>
|
||
</option>
|
||
<?php } ?>
|
||
<?php } ?>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group col-md-3">
|
||
<label for="serviced_by">Serviced By</label>
|
||
<select class="form-control" id="serviced_by" name="serviced_by">
|
||
<option value="" selected>Select Service Person</option>
|
||
<?php if (isset($ACM)) { ?>
|
||
<?php foreach ($ACM as $value) { ?>
|
||
<option value="<?= $value['id'];?>">
|
||
<?= $value['first_name'];?>
|
||
</option>
|
||
<?php } ?>
|
||
<?php } ?>
|
||
</select>
|
||
</div>
|
||
|
||
</div>
|
||
<hr>
|
||
<!-- Premium Details -->
|
||
<div class="row">
|
||
<div class="col-md-12">
|
||
<div class="form-section">
|
||
<div id="accordion_3" class="mb-0">
|
||
<div class="card mb-0">
|
||
<h4 class="m-1">Premium Details
|
||
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseFour" aria-expanded="true">
|
||
<i id="icon" class="mdi mdi-chevron-down mr-1 text-primary" style="font-size: 28px;"></i>
|
||
</a>
|
||
</h4>
|
||
<div id="collapseFour" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_3">
|
||
<div class="row d-none" id="add_more_row">
|
||
<div class="col-md-2">
|
||
<!-- <label for="setInsurerCount">Insurer Count : </label> -->
|
||
<!-- <input type="number" id="setInsurerCount" class="form-control" placeholder="Enter count"> -->
|
||
<a id="setInsurerCount" class="btn btn-primary" >Add Insurer</a>
|
||
</div>
|
||
<!-- <div class="col-md-2">
|
||
<a id="addInsurer" class="btn btn-primary mb-3">Add Insurer</a>
|
||
</div> -->
|
||
<!-- <div class="col-md-1">
|
||
<a id="submitForm" class="btn btn-success mb-3">Submit</a>
|
||
</div> -->
|
||
</div>
|
||
|
||
<div id="insurerTableContainer" style="overflow: auto;">
|
||
<table class="table table-bordered co_share_table" id="insurerTable">
|
||
<thead>
|
||
<tr>
|
||
<th>Premium Details</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr id="table_tr_1">
|
||
<td>Insurer</td>
|
||
</tr>
|
||
<tr id="table_tr_2" style="display: none;">
|
||
<td>Is Leader?</td>
|
||
</tr>
|
||
<tr id="table_tr_34">
|
||
<td>CD Acc No</td>
|
||
</tr>
|
||
<tr id="table_tr_35">
|
||
<td>Follower Policy No</td>
|
||
</tr>
|
||
<tr id="table_tr_3" style="display: none;">
|
||
<td>Co-Share %</td>
|
||
</tr>
|
||
<tr id="table_tr_4">
|
||
<td>Base Premium</td>
|
||
</tr>
|
||
<tr class="hidetp" id="table_tr_5">
|
||
<td id="tp_premium_td">TP Premium</td>
|
||
</tr>
|
||
<tr class="hideter" id="table_tr_6" style="display: none;">
|
||
<td>TEP Premium</td>
|
||
</tr>
|
||
<tr id="table_tr_7" style="display: none;">
|
||
<td>Co-Premium</td>
|
||
</tr>
|
||
<tr id="table_tr_8">
|
||
<td>CGST</td>
|
||
</tr>
|
||
<tr id="table_tr_9">
|
||
<td>SGST</td>
|
||
</tr>
|
||
<tr id="table_tr_10">
|
||
<td>IGST</td>
|
||
</tr>
|
||
<tr id="table_tr_11">
|
||
<td>GST Amount</td>
|
||
</tr>
|
||
<tr id="table_tr_12">
|
||
<td>Stamp Duty</td>
|
||
</tr>
|
||
<tr id="table_tr_13">
|
||
<td>Total</td>
|
||
</tr>
|
||
|
||
<tr id="table_tr_14">
|
||
<td>Agreed BP %</td>
|
||
</tr>
|
||
<tr class="hidetp" id="table_tr_15">
|
||
<td id="agree_tp_td">Agreed TP %</td>
|
||
</tr>
|
||
<tr class="hideter" id="table_tr_16" style="display: none;">
|
||
<td id="agree_tp_td">Agreed TEP %</td>
|
||
</tr>
|
||
|
||
<?php if (in_array(MANAGEMENT_TEAM_ID, user_team())) { ?>
|
||
|
||
<tr id="table_tr_17">
|
||
<td>Agreed Amount</td>
|
||
</tr>
|
||
|
||
<?php } ?>
|
||
|
||
<tr id="table_tr_18">
|
||
<td>Standard BP %</td>
|
||
</tr>
|
||
<tr class="hidetp" id="table_tr_19">
|
||
<td>Standard TP %</td>
|
||
</tr>
|
||
<tr class="hideter" id="table_tr_20" style="display: none;">
|
||
<td>Standard TEP %</td>
|
||
</tr>
|
||
|
||
<?php if (in_array(FINANCE_TEAM_ID, user_team()) || in_array(MANAGEMENT_TEAM_ID, user_team())) { ?>
|
||
|
||
<tr id="table_tr_21">
|
||
<td>Actual BP Amount</td>
|
||
</tr>
|
||
<tr class="hidetp" id="table_tr_22">
|
||
<td>Actual TP Amount</td>
|
||
</tr>
|
||
<tr class="hideter" id="table_tr_23" style="display: none;">
|
||
<td>Actual TEP Amount</td>
|
||
</tr>
|
||
<tr id="table_tr_24">
|
||
<td>Actual BP %</td>
|
||
</tr>
|
||
<tr class="hidetp" id="table_tr_25">
|
||
<td>Actual TP %</td>
|
||
</tr>
|
||
<tr class="hideter" id="table_tr_26" style="display: none;">
|
||
<td>Actual TEP %</td>
|
||
</tr>
|
||
<tr id="table_tr_27">
|
||
<td>Actual BP <br> Remuneration Amount</td>
|
||
</tr>
|
||
<tr class="hidetp" id="table_tr_28">
|
||
<td>Actual TP <br> Remuneration Amount</td>
|
||
</tr>
|
||
<tr class="hideter" id="table_tr_29" style="display: none;">
|
||
<td>Actual TEP <br> Remuneration Amount</td>
|
||
</tr>
|
||
<tr id="table_tr_30">
|
||
<td>Expected Amount</td>
|
||
</tr>
|
||
<tr id="table_tr_31">
|
||
<td>Variance</td>
|
||
</tr>
|
||
<tr id="table_tr_32">
|
||
<td>Reward</td>
|
||
</tr>
|
||
|
||
<?php } ?>
|
||
|
||
<tr id="table_tr_33" style="display: none;">
|
||
<td></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group text-right m-b-0" id="submitButton">
|
||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
|
||
id="btnSubmit">Submit</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<!-- end form row -->
|
||
|
||
<!-- Client form content modal-->
|
||
<div class="modal fade" id="upload_enrollment_model" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" data-backdrop="static">
|
||
<div class="modal-dialog modal-dialog-centered">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title" id="myCenterModalLabel">Add New Client</h4>
|
||
<button type="button" id="close_btn" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<div class="modal-body" style="overflow-y: auto;height: 90vh;">
|
||
<form class="parsley-examples" method="post" id="client_form" enctype="multipart/form-data">
|
||
<div class="form-group">
|
||
|
||
<div class="form-row">
|
||
<div class="form-group col-md-12">
|
||
<label for="client_name">Client Name<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="client_name" name="client_name" required>
|
||
</div>
|
||
<div class="form-group col-md-12">
|
||
<label for="short_name">Client Short name<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="short_name" name="short_name" required>
|
||
</div>
|
||
|
||
<div class="form-group col-md-12">
|
||
<label for="cost_center">PAN<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="pan" placeholder="Enter PAN No" name="pan" onchange="validateInput(this, 'clients', 'pan')" required>
|
||
</div>
|
||
</div>
|
||
|
||
<hr>
|
||
|
||
<!-- Client Type -->
|
||
<div class="form-row clienttypediv" style="display: none;">
|
||
|
||
<div class="form-group col-md-6">
|
||
<label for="dob">Date of Birth<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="dob" placeholder="DD/MM/YYYY" name="dob" >
|
||
</div>
|
||
|
||
<div class="form-group col-md-6">
|
||
<label for="cost_center">Mobile<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="phone" placeholder="Enter Mobile Number" maxlength="10" name="phone"
|
||
onkeypress="return onlyNumbers(event)" onchange="validateInput(this, 'clients', 'phone')">
|
||
</div>
|
||
|
||
<div class="form-group col-md-12">
|
||
<label for="cost_center">Email<span class="text-danger">*</span></label>
|
||
<input type="email" class="form-control" id="email" placeholder="Enter Email" name="email">
|
||
</div>
|
||
|
||
<div class="form-group col-md-12">
|
||
<label for="aadhar">Aadhar<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="aadhar" placeholder="Enter Aadher No" name="aadhar" maxlength="12" onchange="validateInput(this, 'clients', 'aadhar')">
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<!-- branch -->
|
||
<div class="form-row branchdiv">
|
||
|
||
<div class="form-group col-md-12">
|
||
<label for="short_name">Entity Type<span class="text-danger">*</span></label>
|
||
<select class="form-control" id="entity_type_id_for_client" name="entity_type_id">
|
||
<option value="" selected>Select Entity</option>
|
||
<?php
|
||
if (isset($entity) && count($entity)) {
|
||
foreach ($entity as $key => $value) {
|
||
echo "<option value=" . $value['id'] . ">" . $value['name'] . "</option>";
|
||
}
|
||
}
|
||
?>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group col-md-6">
|
||
<label for="client_name">Branch Name<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="branch_name" name="branch_name">
|
||
</div>
|
||
|
||
<div class="form-group col-md-6">
|
||
<label for="branch_code">Branch Code<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="branch_code" name="branch_code">
|
||
</div>
|
||
|
||
<div class="form-group col-md-6">
|
||
<label for="branch_code">Name<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="name" name="name">
|
||
</div>
|
||
|
||
<div class="form-group col-md-6">
|
||
<label for="branch_code">Mobile<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="mobile" maxlength="10" name="mobile" onkeypress="return onlyNumbers(event)">
|
||
</div>
|
||
|
||
<div class="form-group col-md-12">
|
||
<label for="gst">GST<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="gst" placeholder="Enter GST Number" onchange="validateInput(this, 'client_branch', 'gst')"
|
||
data-parsley-error-message="Invalid GST Number. Example: 12ABCDE1234F5Z6" name="gst" data-parsley-trigger="change" data-parsley-pattern="^\d{2}[A-Z]{5}\d{4}[A-Z]{1}[A-Z\d]{1}[Z]{1}[A-Z\d]{1}$" required>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
</div>
|
||
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1">Submit</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div><!-- /.modal-content -->
|
||
</div><!-- /.modal-dialog -->
|
||
</div>
|
||
|
||
<!-- Vehicle form content modal-->
|
||
<div class="modal fade" id="vehicle_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" data-backdrop="static">
|
||
<div class="modal-dialog modal-dialog-centered">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title" id="myCenterModalLabel">Add New Vehicle</h4>
|
||
<button type="button" id="vehicle_close_btn" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<div class="modal-body" style="overflow-y: auto;height: 90vh;">
|
||
<form class="parsley-examples" method="post" id="vehicle_form" enctype="multipart/form-data">
|
||
<div class="form-group">
|
||
|
||
<div class="form-row">
|
||
|
||
<div class="form-group col-md-6 client_type_div">
|
||
<label for="Owner_type">Owner Type<span class="text-danger">*</span></label>
|
||
<select class="form-control" id="Owner_type" name="Owner_type" required>
|
||
<option value="">Select Owner type</option>
|
||
<option value="1">Group</option>
|
||
<option value="2">Individual</option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group col-md-6">
|
||
<label for="cost_center">Vehicle No<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="modal_vehicle_no" placeholder="Enter Vehicle No" name="vehicle_no" onchange="validateInput(this, 'vehicle', 'vehicle_no')" required>
|
||
</div>
|
||
|
||
<div class="form-group col-md-6">
|
||
<label for="rc">RC Book <span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="rc" placeholder="Enter RC Book No" name="rc" onchange="validateInput(this, 'vehicle', 'rc')" required>
|
||
</div>
|
||
|
||
<div class="form-group col-md-6">
|
||
<label for="type">Type<span class="text-danger">*</span></label>
|
||
<select class="form-control" id="type" name="type" required>
|
||
<option value="">Select Type</option>
|
||
<?php
|
||
if (isset($vehicle_type) && count($vehicle_type)) {
|
||
foreach ($vehicle_type as $key => $value) {
|
||
echo "<option value=" . $key . ">" . $value . "</option>";
|
||
}
|
||
}
|
||
?>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group col-md-6">
|
||
<label for="description">Description<span class="text-danger">*</span></label>
|
||
<select class="form-control" id="description" name="description" required>
|
||
<option value="">Select Description</option>
|
||
<?php
|
||
if (isset($vehicle_des) && count($vehicle_des)) {
|
||
foreach ($vehicle_des as $key => $value) {
|
||
echo "<option value=" . $key . ">" . $value . "</option>";
|
||
}
|
||
}
|
||
?>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group col-md-12">
|
||
<label for="owner">Owner Name <span class="text-danger">*</span></label>
|
||
<select class="form-control" id="owner" name="owner" required>
|
||
<option value="">Select Owner</option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group col-md-12 ownerbranchdiv">
|
||
<label for="client_branch">Branch<span class="text-danger">*</span></label>
|
||
<select class="form-control" id="owner_branch" name="branch_id">
|
||
<option value="">Select Branch</option>
|
||
</select>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
</div>
|
||
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1">Submit</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div><!-- /.modal-content -->
|
||
</div><!-- /.modal-dialog -->
|
||
</div>
|
||
|
||
<!-- CD No form content modal-->
|
||
<div class="modal fade" id="cd_form_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
|
||
<div class="modal-dialog">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title" id="title">Add CD Account Number</h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
|
||
<div class="modal-body p-4">
|
||
<div class="">
|
||
|
||
<form role="form" class="parsley-examples" method="post" id="CDMasterForm" enctype="multipart/form-data">
|
||
|
||
<div class="form-group">
|
||
|
||
<div class="form-row">
|
||
<div class="form-group col-md-12">
|
||
<label for="email">Opening Date<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" name="opening_date" id="opening_date" required>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-row">
|
||
<div class="form-group col-md-12">
|
||
<label for="mobile">CD Account Number<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="cd_ac_no_data" name="cd_ac_no" required>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-row">
|
||
<div class="form-group col-md-12">
|
||
<label for="mobile">Opening Amount<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="opening_bal" name="opening_bal" onkeypress="return onlyNumbers(event)" required>
|
||
</div>
|
||
</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>
|
||
|
||
var team_id = [];
|
||
let isClientFormSubmitting = false;
|
||
var insurer_count_array = [];
|
||
|
||
$(document).ready(function(){
|
||
|
||
// hidePermiumDetailsBasedOnTheTeam()
|
||
|
||
// $('#upload_enrollment_model').modal({
|
||
// backdrop: 'static',
|
||
// keyboard: false
|
||
// })
|
||
|
||
$('#upload_enrollment_model').on('hide.bs.modal', function (e) {
|
||
if (!isClientFormSubmitting) {
|
||
// Ask for confirmation
|
||
if (confirm("Are you sure you want to close? Unsaved changes will be lost.")) {
|
||
// If confirmed, reset the form
|
||
$('#client_form')[0].reset();
|
||
} else {
|
||
// If not confirmed, prevent the modal from closing
|
||
e.preventDefault();
|
||
}
|
||
}
|
||
});
|
||
|
||
|
||
team_id = <?php echo json_encode(user_team()); ?>;
|
||
console.log('team_id', team_id);
|
||
|
||
if (team_id.includes('4')) {
|
||
console.log('Finance Team Logged in.');
|
||
} else if (team_id.includes('3')) {
|
||
console.log('Business Team Logged in.');
|
||
}
|
||
|
||
$('#listed_insurers').select2({
|
||
placeholder: "Select Insurers", // Placeholder for a better UX
|
||
});
|
||
|
||
$("textarea.select2-search__field").attr('rows', '1');
|
||
$("textarea.select2-search__field").css('resize', 'none');
|
||
|
||
// $('#listed_insurers').select2();
|
||
$('#owner').select2();
|
||
$('#owner_branch').select2();
|
||
$('#vehicle_no').select2();
|
||
var today = new Date();
|
||
|
||
var dob = flatpickr("#dob", {
|
||
dateFormat: "d/m/Y",
|
||
allowInput: false
|
||
});
|
||
|
||
var rollover_date = flatpickr("#rollover_date", {
|
||
dateFormat: "d/m/Y",
|
||
allowInput: false
|
||
});
|
||
|
||
var process_start_date = flatpickr("#process_start_date", {
|
||
dateFormat: "d/m/Y",
|
||
defaultDate: today,
|
||
allowInput: false
|
||
});
|
||
|
||
var last_action_date = flatpickr("#last_action_date", {
|
||
dateFormat: "d/m/Y",
|
||
defaultDate: today,
|
||
allowInput: false
|
||
});
|
||
|
||
var renewal_date1 = flatpickr("#renewal_policy_start_date", {
|
||
dateFormat: "d/m/Y",
|
||
defaultDate: 'today',
|
||
allowInput: false
|
||
});
|
||
|
||
var renewal_date2 = flatpickr("#renewal_policy_end_date", {
|
||
dateFormat: "d/m/Y",
|
||
defaultDate: 'today',
|
||
allowInput: false
|
||
});
|
||
|
||
|
||
})
|
||
|
||
$(document).ready(function(){
|
||
getURLParamsForReport();
|
||
})
|
||
|
||
$(document).ready(function(){
|
||
|
||
$('#vehicle_no').change(function(){
|
||
|
||
var val = $(this).val()
|
||
var selectedOption = $(this).find('option:selected');
|
||
var client_id = selectedOption.data('cid')
|
||
var branch_id = selectedOption.data('bid')
|
||
var client_type = selectedOption.data('cty')
|
||
|
||
console.log(client_id)
|
||
console.log(branch_id)
|
||
console.log(client_type)
|
||
|
||
$('#client_id').val(client_id).change()
|
||
$('#client_type').val(client_type)
|
||
|
||
if(client_type == 1){
|
||
|
||
$('.branchdiv').show()
|
||
$('#client_branch_id').prop('required', true);
|
||
setTimeout(function(){
|
||
$('#client_branch_id').val(branch_id).change()
|
||
}, 800)
|
||
}else{
|
||
$('.branchdiv').hide()
|
||
$('#client_branch_id').prop('required', false);
|
||
|
||
}
|
||
|
||
if(val == 'add_vehicle'){
|
||
|
||
$('#modal_vehicle_no').val('');
|
||
var myModal = new bootstrap.Modal(document.getElementById('vehicle_modal'));
|
||
myModal.show();
|
||
|
||
$(this).val('').select2();
|
||
}
|
||
})
|
||
|
||
$('#owner').change(function(){
|
||
|
||
let owner_id = $(this).val();
|
||
console.log('owner_id', owner_id);
|
||
|
||
if(owner_id == 'add_client'){
|
||
|
||
if($('#client_type').val()){
|
||
|
||
$('#vehicle_close_btn').click();
|
||
|
||
if ($('#client_type').val() == 2) {
|
||
|
||
$('.branchdiv').hide();
|
||
$('.clienttypediv').show();
|
||
$('#entity_type_id_for_client').prop('required', false);
|
||
$('#branch_name').prop('required', false);
|
||
$('#client_branch_id').prop('required', false);
|
||
$('#branch_code').prop('required', false);
|
||
$('#name').prop('required', false);
|
||
$('#mobile').prop('required', false);
|
||
$('#gst').prop('required', false);
|
||
|
||
$('#dob').prop('required', true);
|
||
$('#phone').prop('required', true);
|
||
$('#email').prop('required', true);
|
||
$('#aadhar').prop('required', true);
|
||
|
||
} else {
|
||
|
||
$('.branchdiv').show();
|
||
$('.clienttypediv').hide();
|
||
$('#entity_type_id_for_client').prop('required', true);
|
||
$('#branch_name').prop('required', true);
|
||
$('#client_branch_id').prop('required', true);
|
||
$('#branch_code').prop('required', true);
|
||
$('#name').prop('required', true);
|
||
$('#mobile').prop('required', true);
|
||
$('#gst').prop('required', true);
|
||
|
||
$('#dob').prop('required', false);
|
||
$('#phone').prop('required', false);
|
||
$('#email').prop('required', false);
|
||
$('#aadhar').prop('required', false);
|
||
|
||
}
|
||
|
||
var myModal = new bootstrap.Modal(document.getElementById('upload_enrollment_model'));
|
||
myModal.show();
|
||
|
||
}else{
|
||
|
||
toastr.warning('Please select the Owner type', 'Warning');
|
||
}
|
||
|
||
|
||
$('#client_form').attr('data-id', 1);
|
||
|
||
// Save form data from the #vehicle_form to localStorage
|
||
saveFormDataToLocalStorage("#vehicle_form", "vehicleFormData");
|
||
|
||
|
||
}
|
||
|
||
if(branch_list != '') {
|
||
// console.log(branch_list[client_id]);
|
||
let data = branch_list[owner_id];
|
||
appendOwnerBranch(data);
|
||
}
|
||
|
||
})
|
||
|
||
$('#policy_type_id').change(function() {
|
||
|
||
// hidePermiumDetailsBasedOnTheTeam();
|
||
|
||
$('#client_type').val('');
|
||
$('#client_id').val('').select2();
|
||
$('#client_branch_id').val('').select2();
|
||
|
||
var client_type = $('#client_type').val();
|
||
var value = $(this).val();
|
||
var selectedOption = $(this).find('option:selected');
|
||
|
||
var ebp = selectedOption.data('ebp');
|
||
var etp = selectedOption.data('etp');
|
||
var etep = selectedOption.data('etep');
|
||
var iep = selectedOption.data('iep');
|
||
var itp = selectedOption.data('itp');
|
||
var itep = selectedOption.data('itep');
|
||
|
||
var bap = selectedOption.data('bap');
|
||
|
||
// console.log('EBP:', ebp);
|
||
// console.log('ETP:', etp);
|
||
// console.log('ETEP:', etep);
|
||
// console.log('IEP:', iep);
|
||
// console.log('ITP:', itp);
|
||
// console.log('ITEP:', itep);
|
||
|
||
var std_bp = 0;
|
||
var std_tp = 0;
|
||
var std_tep = 0;
|
||
|
||
|
||
if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
|
||
$('.hideter').show();
|
||
$('.hidetp').hide();
|
||
}else{
|
||
if(bap == 'Motor'){
|
||
$('.hidetp').show();
|
||
$('.hideter').hide();
|
||
}else{
|
||
$('.hideter').hide();
|
||
$('.hidetp').hide();
|
||
}
|
||
}
|
||
|
||
$('[name="standard_bp[]"]').val(ebp);
|
||
$('[name="standard_tp[]"]').val(etp);
|
||
$('[name="standard_ter[]"]').val(etep);
|
||
|
||
// hidePermiumDetailsBasedOnTheTeam()
|
||
|
||
|
||
if(value == 8){
|
||
$('#vhnodiv').show();
|
||
$('#client_type_div').hide();
|
||
$('#policyholdernamediv').hide();
|
||
$('#hide_vehicle_tab').show();
|
||
$('#client_type').addClass('readonly-select ');
|
||
$('#client_id').addClass('readonly-select ').select2('destroy');
|
||
$('#client_branch_id').addClass('readonly-select ').select2('destroy');
|
||
}else{
|
||
$('#vhnodiv').hide();
|
||
$('#client_type_div').show();
|
||
$('#hide_vehicle_tab').hide();
|
||
$('#client_type').removeClass('readonly-select ');
|
||
$('#client_id').removeClass('readonly-select ').select2();
|
||
$('#client_branch_id').removeClass('readonly-select ').select2();
|
||
}
|
||
|
||
// hidePermiumDetailsBasedOnTheTeam();
|
||
});
|
||
|
||
})
|
||
|
||
$(document).on('change', 'input[type="checkbox"][name="co_share_type[]"]', function() {
|
||
|
||
$('[name="base_premium[]"]').val("");
|
||
$('[name="co_premium[]"]').val("");
|
||
|
||
let isAnyChecked = $('input[type="checkbox"][name="co_share_type[]"]:checked').length > 1;
|
||
|
||
if (isAnyChecked) {
|
||
toastr.warning('Only one leader can be selected.', 'Warning!');
|
||
$(this).prop('checked', false);
|
||
}
|
||
});
|
||
|
||
function checkLeaderSelected(){
|
||
|
||
}
|
||
|
||
// $(document).on('input', '[name="cgst[]"]', function() {
|
||
|
||
// let val = $(this).val();
|
||
|
||
// if(val){
|
||
// $('[name="igst[]"]').val(0);
|
||
// $('[name="cgst[]"]').val(val);
|
||
// $('[name="sgst[]"]').val(val);
|
||
|
||
// }else{
|
||
// $('[name="igst[]"]').val('');
|
||
// $('[name="sgst[]"]').val('');
|
||
// }
|
||
// // console.log('cgst value', val);
|
||
// });
|
||
|
||
// $(document).on('input', '[name="sgst[]"]', function() {
|
||
|
||
// let val = $(this).val();
|
||
|
||
// if(val){
|
||
// $('[name="igst[]"]').val(0);
|
||
// $('[name="sgst[]"]').val(val)
|
||
// $('[name="cgst[]"]').val(val)
|
||
// }else{
|
||
// $('[name="igst[]"]').val('');
|
||
// $('[name="sgst[]"]').val('')
|
||
// $('[name="cgst[]"]').val('')
|
||
// }
|
||
// // console.log('cgst value', val);
|
||
// });
|
||
|
||
// $(document).on('input', '[name="igst[]"]', function() {
|
||
|
||
// let val = $(this).val();
|
||
|
||
// if(val){
|
||
// $('[name="cgst[]"], [name="sgst[]"]').val(0);
|
||
// $('[name="igst[]"]').val(val)
|
||
// }else{
|
||
// $('[name="cgst[]"], [name="sgst[]"]').val('');
|
||
// $('[name="igst[]"]').val('')
|
||
|
||
// }
|
||
|
||
// // console.log('igst value', val);
|
||
// });
|
||
|
||
$(document).on('click', '[name="co_share_type[]"]', function() {
|
||
|
||
let val = $(this).val();
|
||
let uniqueid = $(this).data('id');
|
||
let insurer = $('#follow_insurer_id_'+uniqueid).val()
|
||
|
||
var client_id = $('#client_id').val()
|
||
var insurer_id = $('#follow_insurer_id_'+uniqueid).find('option:selected').attr('data-id');
|
||
var insurer_branch_id = $('#follow_insurer_id_'+uniqueid).find('option:selected').attr('data-bid');
|
||
|
||
// console.log('client_id', client_id);
|
||
// console.log('insurer_id', insurer_id);
|
||
|
||
if(insurer == ""){
|
||
toastr.warning('Please select the insurer.', 'Warning!');
|
||
$(this).prop('checked', false);
|
||
}else{
|
||
|
||
$('#insurer_id').val(insurer)
|
||
// if(client_id && insurer_id){
|
||
// // $('#insurer_id').val(insurer)
|
||
// // getCDAccountNumber(client_id, insurer_id);
|
||
// }else{
|
||
// console.log('getCDAccountNumber cannot be call because of absence of client id and insurer id');
|
||
// }
|
||
}
|
||
|
||
// console.log('co_share_type value', val);
|
||
// console.log('co_share_type uniqueid', uniqueid);
|
||
// console.log('co_share_type insurer', insurer);
|
||
});
|
||
|
||
$(document).on('change', 'select[name="relationship[]"]', function() {
|
||
var selectedValues = [];
|
||
var hasDuplicate = false;
|
||
var currentSelect = $(this);
|
||
|
||
// Collect all selected values
|
||
$('select[name="relationship[]"]').each(function() {
|
||
var value = $(this).val();
|
||
if (value) {
|
||
if (selectedValues.indexOf(value) !== -1) {
|
||
hasDuplicate = true; // Mark if duplicate is found
|
||
}
|
||
selectedValues.push(value);
|
||
}
|
||
});
|
||
|
||
if (hasDuplicate) {
|
||
// Show toastr warning if duplicate is detected
|
||
toastr.warning('Duplicate relationship selected. Please choose a different one.');
|
||
|
||
// Reset the current selection to default (unselected)
|
||
currentSelect.val('');
|
||
}
|
||
|
||
// Highlight already selected options in other dropdowns
|
||
$('select[name="relationship[]"]').each(function() {
|
||
var current = $(this);
|
||
current.find('option').removeClass('highlighted'); // Remove previous highlights
|
||
current.find('option').each(function() {
|
||
if (selectedValues.indexOf($(this).val()) !== -1 && $(this).val() !== current.val()) {
|
||
$(this).addClass('highlighted'); // Add highlight class to duplicates
|
||
}
|
||
});
|
||
});
|
||
});
|
||
|
||
$(document).ready(function() {
|
||
|
||
$(document).on('change', '[name="follow_insurer_id[]"]', function() {
|
||
|
||
let insurer = $(this).val();
|
||
let unique_id = $(this).data('count');
|
||
let client_id = $('#client_id').val();
|
||
|
||
console.log('insurer', insurer);
|
||
console.log('follow_insurer_id client_id', client_id);
|
||
console.log('follow_insurer_id unique_id', unique_id);
|
||
|
||
$('#insurer_id').val(insurer)
|
||
|
||
if(!client_id){
|
||
$(this).val('').select2();
|
||
toastr.warning('Please select the Client', 'Warning');
|
||
}
|
||
|
||
});
|
||
|
||
// $(document).on('change', '[name="follow_insurer_id[]"]', function() {
|
||
|
||
// let insurer = $(this).val();
|
||
// let unique_id = $(this).data('count');
|
||
// let client_id = $('#client_id').val();
|
||
// let insurer_id = $(this).find('option:selected').attr('data-id');
|
||
// let insurer_branch_id = $(this).find('option:selected').attr('data-bid');
|
||
|
||
// console.log('insurer', insurer);
|
||
// console.log('follow_insurer_id client_id', client_id);
|
||
// console.log('follow_insurer_id insurer_id', insurer_id);
|
||
// console.log('follow_insurer_id unique_id', unique_id);
|
||
// // console.log('follow_insurer_id insurer_id', insurer_branch_id);
|
||
|
||
// // if (!$('#cop_yes').is(':checked')) {
|
||
|
||
// if(client_id && insurer_id){
|
||
// $('#insurer_id').val(insurer)
|
||
// getCDAccountNumber(client_id, insurer_id, unique_id);
|
||
// } else {
|
||
// console.log('getCDAccountNumber cannot be called because of the absence of client id and insurer id');
|
||
// }
|
||
// // }
|
||
// });
|
||
});
|
||
|
||
//---------------------------------------------------------------------------------------------------------
|
||
|
||
//edit function
|
||
function getPolicyTransactionDataForEdit(input) {
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
$('#inception_form_id')[0].reset();
|
||
// var id = $(input).attr('data-id');
|
||
var id = input;
|
||
console.log('Selected policy transaction ID:', id);
|
||
|
||
$.ajax({
|
||
url: '<?= base_url("/policy_tranction/inception/list/") ?>' + id,
|
||
type: "GET",
|
||
dataType: 'json',
|
||
success: function(res) {
|
||
console.log('getPolicyTransactionDataForEdit', res);
|
||
|
||
if (res.status == true) {
|
||
|
||
hide_list_show_add();
|
||
|
||
var page_title = 'Edit Policy' + (res.data.client_short_name || res.data.policy_type || res.data.policy_no ?
|
||
' - ' + [res.data.client_short_name, res.data.policy_type, res.data.policy_no]
|
||
.filter(Boolean).join('-') : '');
|
||
|
||
$('#page_title').text(page_title);
|
||
$('#client_id_kyc').val(res.data.client_id);
|
||
$('#policy_tranction_primarykey_for_file_upload').val(res.data.id);
|
||
$('#client_id_for_vehicle_file_upload').val(res.data.client_id);
|
||
$('#vehicle_id_for_file_upload').val(res.data.vehicle_id);
|
||
$('#client_policy_id_for_file_upload').val(res.data.client_policy_id);
|
||
$('#policy_tranction_policy_number').val(res.data.policy_no);
|
||
|
||
// $('#cd_ac_no_for_edit').val(res.data.cd_ac_no);
|
||
$('#cd_ac_no').val(res.data.id);
|
||
|
||
// $('#entity_type_id').val(res.data.entity_type_id);
|
||
getKYCEntityDocument(res.data.entity_type_id, res.data.client_id);
|
||
appendKycTableListData(res.data.client_kyc);
|
||
|
||
|
||
// Setting values to correct fields
|
||
$('#policy_tranction_primarykey').val(res.data.id);
|
||
$('#client_policy_id').val(res.data.client_policy_id);
|
||
$('#client_id_for_edit').val(res.data.client_id);
|
||
$('#issuer').val(res.data.issuer);
|
||
$('#issue_type').val(res.data.issue_type);
|
||
|
||
setTimeout(function() {
|
||
$('#client_id').val(res.data.client_id).change();
|
||
$('#client_type').val(res.data.client_type);
|
||
$('#insurer_id').val(res.data.insurer_branch_id + '-' + res.data.insurer_id);
|
||
$('#vehicle_no').val(res.data.vehicle_id).select2();
|
||
}, 1000);
|
||
|
||
var tpaValue = '';
|
||
if (res.data.master_tpa_branch_id && res.data.master_tpa_id) {
|
||
tpaValue = res.data.master_tpa_branch_id + '-' + res.data.master_tpa_id;
|
||
} else if (res.data.tpa_branch_id && res.data.tpa_id) {
|
||
tpaValue = res.data.tpa_branch_id + '-' + res.data.tpa_id;
|
||
}
|
||
|
||
$('#tpa').val(tpaValue).change();
|
||
|
||
if(res.data.client_policy_id != 0 && res.data.client_policy_id != null){
|
||
$('#hide_file_upload').show();
|
||
}else{
|
||
$('#hide_file_upload').hide();
|
||
}
|
||
|
||
if (res.data.master_policy_type_id) {
|
||
$('#policy_type_id').val(res.data.master_policy_type_id).change();
|
||
} else {
|
||
$('#policy_type_id').val(res.data.policy_type_id).change();
|
||
}
|
||
|
||
if (res.data.issue_type == 2) {
|
||
appendRenewalPolicies(res.data.renewal_policy);
|
||
}
|
||
|
||
if (res.data.is_addon == 2 || res.data.is_addon == 3) {
|
||
appendBasePolicyList(res.data.base_policy_data);
|
||
}
|
||
|
||
appendFileTableBody(res.data.pt_files);
|
||
|
||
appendVehicleFileTableBody(res.data.vehicle_docs);
|
||
|
||
if (res.data.pt_co_share_details) {
|
||
setTimeout(function() {
|
||
populateTable(res.data.pt_co_share_details);
|
||
}, 1000);
|
||
}
|
||
|
||
if (res.data.listed_insurers) {
|
||
selectListedInsurers(res.data.listed_insurers);
|
||
}
|
||
|
||
if (res.data.pt_co_share_details && res.data.pt_co_share_details.length > 0) {
|
||
$('#tab_content').empty();
|
||
count = 0;
|
||
$.each(res.data.pt_co_share_details, function(index, item) {
|
||
// appendNewTab(item); // Uncomment when implementing tab addition logic
|
||
});
|
||
}
|
||
|
||
setTimeout(function() {
|
||
$('#cd_ac_no').val(res.data.id);
|
||
$('#client_branch_id').val(res.data.client_branch_id).change();
|
||
$('#source_client_policy_id').val(res.data.source_client_policy_id).change();
|
||
$('#base_policy').val(res.data.base_policy).select2();
|
||
// $('.loader').fadeOut();
|
||
// $('.loader-mask').delay(350).fadeOut('slow');
|
||
}, 2000);
|
||
|
||
setTimeout(function(){
|
||
// $('select[name="cd_ac_no_for_child[]"]').val(res.data.cd_ac_no ?? "");
|
||
$('select[name="cd_ac_no_for_child[]"] option').each(function() {
|
||
if ($(this).val() == res.data.id) {
|
||
$(this).prop('selected', true);
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}else{
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}
|
||
});
|
||
}, 4000)
|
||
|
||
// Set additional fields
|
||
$('#policy_status').val(res.data.status);
|
||
$('#ref').val(res.data.ref);
|
||
$('#spl').val(res.data.spl);
|
||
$('#fund_received').val(res.data.fund_received);
|
||
$('#revenue_type').val(res.data.revenue_type);
|
||
$('#month').val(res.data.month);
|
||
|
||
$('#policy_no').val(res.data.policy_no);
|
||
$('#policy_issue_date').val(res.data.policy_issue_date);
|
||
$('#policy_start_date').val(res.data.policy_start_date);
|
||
$('#policy_end_date').val(res.data.policy_end_date);
|
||
$('#emp_count').val(res.data.emp_count);
|
||
$('#dependent_count').val(res.data.dependent_count);
|
||
$('#ppteam').val(res.data.ppteam).change();
|
||
$('#fund_received').val(res.data.fund_received);
|
||
$('#renewal_date').val(res.data.renewal_date);
|
||
$('#rollover_date').val(res.data.rollover_date);
|
||
$('#policy_holder_name').val(res.data.policy_holder_name);
|
||
$('#location').val(res.data.location);
|
||
$('#installment').val(res.data.installment);
|
||
$('#installment_data').val(res.data.installment_data);
|
||
$('#last_action_date').val(res.data.updated_at);
|
||
$('#process_start_date').val(res.data.created_at);
|
||
$('#remark').val(res.data.remarks);
|
||
$('.current_date').show();
|
||
$('#sales_generated_by').val(res.data.sales_generated_by ?? '').change();
|
||
$('#serviced_by').val(res.data.serviced_by ?? '').change();
|
||
|
||
// Additional form handling logic
|
||
if (res.data.issue_type == 2) {
|
||
$('#renewal').show();
|
||
// $('#source_client_policy_id').attr('required', true);
|
||
} else {
|
||
$('#renewal').hide();
|
||
// $('#source_client_policy_id').attr('required', false);
|
||
}
|
||
|
||
// Handle base policy visibility
|
||
if (res.data.is_addon == 2 || res.data.is_addon == 3) {
|
||
$('#base_policy_id').show();
|
||
} else {
|
||
$('#base_policy_id').hide();
|
||
}
|
||
|
||
// Handle co-share percentage
|
||
if (res.data.co_share == 1) {
|
||
$('#cop_yes').prop('checked', true);
|
||
$('#add_more_row').removeClass('d-none');
|
||
$('.payby').removeClass('d-none');
|
||
$('#table_tr_2').show();
|
||
$('#table_tr_3').show();
|
||
$('#table_tr_7').show();
|
||
$('#table_tr_35').show();
|
||
} else {
|
||
$('#cop_yes').prop('checked', false);
|
||
$('#add_more_row').addClass('d-none');
|
||
$('.payby').addClass('d-none');
|
||
$('#table_tr_2').hide();
|
||
$('#table_tr_3').hide();
|
||
$('#table_tr_7').hide();
|
||
$('#table_tr_35').hide();
|
||
|
||
setTimeout(function(){
|
||
$('input[name="co_share_per[]"], input[name="co_premium[]"]').each(function () {
|
||
$(this).val(''); // Clear value
|
||
console.log('Input cleared:', $(this).attr('name'));
|
||
});
|
||
}, 4000);
|
||
}
|
||
|
||
// Handle "Same Insured Name"
|
||
if (res.data.same_as_proposer == 1) {
|
||
$('#same_as_proposer').prop('checked', true);
|
||
$('#dynamic-form-container-for-insured').empty();
|
||
$('#family_details').hide();
|
||
} else {
|
||
$('#same_as_proposer').prop('checked', false);
|
||
if (res.data.client_type == 2 && res.data.policy_type_id != 8) {
|
||
$('#family_details').show();
|
||
$.each(res.data.emp_data, function(index, emp) {
|
||
appendInsured(emp);
|
||
});
|
||
} else {
|
||
$('#dynamic-form-container-for-insured').empty();
|
||
$('#family_details').hide();
|
||
}
|
||
}
|
||
|
||
// Handle brokerage pay by
|
||
if (res.data.bro_payable_by == 1) {
|
||
$('#bro_payable_by').prop('checked', true);
|
||
} else {
|
||
$('#bro_payable_by').prop('checked', false);
|
||
}
|
||
|
||
// Policy transaction status handling
|
||
if (res.data.status == "completed") {
|
||
$('#sales_row').show();
|
||
$('#policy_no').prop('required', true);
|
||
$('#policy_issue_date').prop('required', true);
|
||
$('#policy_start_date').prop('required', true);
|
||
$('#policy_end_date').prop('required', true);
|
||
// $('#tpa').prop('required', true);
|
||
// $('#emp_count').prop('required', true);
|
||
// $('#dependent_count').prop('required', true);
|
||
$('.follow_insurer').prop('required', true);
|
||
} else {
|
||
$('#sales_row').hide();
|
||
$('#policy_no').prop('required', false);
|
||
$('#policy_issue_date').prop('required', false);
|
||
$('#policy_start_date').prop('required', false);
|
||
$('#policy_end_date').prop('required', false);
|
||
// $('#tpa').prop('required', false);
|
||
// $('#emp_count').prop('required', false);
|
||
// $('#dependent_count').prop('required', false);
|
||
$('.follow_insurer').prop('required', false);
|
||
}
|
||
|
||
// Client type changes
|
||
if (res.data.client_type == 2) {
|
||
if (res.data.policy_type_id == 8) {
|
||
$('#policyholdernamediv').hide();
|
||
} else {
|
||
$('#policyholdernamediv').show();
|
||
}
|
||
$('.branchdiv').hide();
|
||
$('#client_branch_id').prop('required', false);
|
||
$('#table_tr_34').hide();
|
||
|
||
} else {
|
||
$('#policyholdernamediv').hide();
|
||
$('.branchdiv').show();
|
||
$('#client_branch_id').prop('required', true);
|
||
$('#table_tr_34').show();
|
||
}
|
||
|
||
//Vehicle File Upload Tab Hide And show
|
||
if(res.data.policy_type_id == 8){
|
||
$('#hide_vehicle_tab').show();
|
||
}else{
|
||
$('#hide_vehicle_tab').hide();
|
||
}
|
||
|
||
} else {
|
||
console.log('No data found');
|
||
}
|
||
},
|
||
error: function(xhr, status, error) {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
}
|
||
});
|
||
|
||
checkInvoiceStatusToHideSubmitBtn(id)
|
||
}
|
||
|
||
function checkAndDistributeTax(input)
|
||
{
|
||
const event = window.event;
|
||
// console.log("Event type:", event.type);
|
||
// console.log("Event target:", event.target);
|
||
console.log("Event id:", event.target.id);
|
||
|
||
let cgst = parseFloat($('#cgst_' + input).val());
|
||
let sgst = parseFloat($('#sgst_' + input).val());
|
||
let igst = parseFloat($('#igst_' + input).val());
|
||
|
||
if(((event.target.id).startsWith('cgst') || (event.target.id).startsWith('sgst') ))
|
||
{
|
||
if(cgst !== 0) { $('#sgst_' + input).val(cgst); }
|
||
else if(sgst !== 0) { $('#cgst_' + input).val(sgst); }
|
||
|
||
$('#igst_' + input).val(0);
|
||
}
|
||
else if((event.target.id).startsWith('igst'))
|
||
{
|
||
$('#cgst_' + input).val(0);
|
||
$('#sgst_' + input).val(0);
|
||
}
|
||
}
|
||
|
||
function amountCalculation(input) {
|
||
|
||
console.log('amountCalculation - ' + input);
|
||
let selectedOption = $('#policy_type_id').find('option:selected');
|
||
let bap = selectedOption.data('bap');
|
||
|
||
|
||
// Retrieve and parse the values or default to 0 if not a number
|
||
let bp = parseFloat($('#base_premium_' + input).val()) || 0;
|
||
|
||
var tp = 0;
|
||
if(bap == 'Motor'){
|
||
tp = parseFloat($('#tp_premium_' + input).val()) || 0;
|
||
}
|
||
|
||
var tep = 0;
|
||
if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
|
||
tep = parseFloat($('#ter_premium_' + input).val()) || 0;
|
||
}
|
||
|
||
let cop = parseFloat($('#co_premium_' + input).val()) || 0;
|
||
checkAndDistributeTax(input);
|
||
let cgst = parseFloat($('#cgst_' + input).val()) || 0;
|
||
let sgst = parseFloat($('#sgst_' + input).val()) || 0;
|
||
let igst = parseFloat($('#igst_' + input).val()) || 0;
|
||
|
||
|
||
let stamp_duty_amt = parseFloat($('#stamp_duty_' + input).val()) || 0;
|
||
let agreed_amount = parseFloat($('#agreed_amount_' + input).val()) || 0;
|
||
|
||
let agreed_bp_per = parseFloat($('#agreed_bp_' + input).val()) || 0;
|
||
let agreed_tp_per = parseFloat($('#agreed_tp_' + input).val()) || 0;
|
||
let agreed_tep_per = parseFloat($('#agreed_ter_' + input).val()) || 0;
|
||
|
||
let standard_bp_per = parseFloat($('#standard_bp_' + input).val()) || 0;
|
||
let standard_tp_per = parseFloat($('#standard_tp_' + input).val()) || 0;
|
||
let standard_tep_per = parseFloat($('#standard_tep_' + input).val()) || 0;
|
||
|
||
let co_share_per = parseFloat($('#co_share_per_' + input).val()) || 0;
|
||
|
||
// console.log(standard_bp_per, standard_tp_per, standard_tep_per);
|
||
|
||
// let co_premium_amt = ((bp + tp + tep) * co_share_per) / 100;
|
||
|
||
// $('#co_premium_' + input).val(!isNaN(co_premium_amt) && isFinite(co_premium_amt) ? co_premium_amt.toFixed(2) : '0.00');
|
||
|
||
|
||
// Calculate GST percentage
|
||
let gst_per = igst;
|
||
if (igst === 0) {
|
||
console.log('called' + cgst + sgst);
|
||
gst_per = parseFloat(cgst) + parseFloat(sgst);
|
||
// gst_per = (cgst) + (sgst);
|
||
console.log(gst_per);
|
||
}
|
||
|
||
console.log('gst_per', gst_per);
|
||
console.log('igst', igst);
|
||
console.log('cgst', cgst);
|
||
console.log('sgst', sgst);
|
||
|
||
// Calculate the total premium (Base + TP + Co-Premium)
|
||
let tpTotal = cop;
|
||
if($('#bro_payable_by').is(':checked')){
|
||
tpTotal = bp + tp + tep;
|
||
}
|
||
|
||
console.log('bp', bp);
|
||
console.log('tp', tp);
|
||
console.log('tep', tep);
|
||
console.log('cop', cop);
|
||
console.log('tpTotal', tpTotal);
|
||
|
||
|
||
let gst_per_amt = (tpTotal * gst_per) / 100;
|
||
console.log('gst_per_amt', gst_per_amt);
|
||
|
||
|
||
// $('#gst_amount_' + input).val(gst_per_amt.toFixed(2));
|
||
$('#gst_amount_' + input).val(!isNaN(gst_per_amt) && isFinite(gst_per_amt) ? gst_per_amt.toFixed(2) : '0.00');
|
||
|
||
|
||
let finalTotal = tpTotal + gst_per_amt + stamp_duty_amt;
|
||
|
||
console.log('Summed Amount:', finalTotal);
|
||
// $('#total_amt_' + input).val(finalTotal.toFixed(2));
|
||
$('#total_amt_' + input).val(!isNaN(finalTotal) && isFinite(finalTotal) ? finalTotal.toFixed(2) : '0.00');
|
||
|
||
|
||
let sum_of_agreed_premium = agreed_bp_per + agreed_tp_per + agreed_tep_per;
|
||
// console.log('sum_of_agreed_precentage : ', sum_of_agreed_premium);
|
||
|
||
var expectedAmount = 0;
|
||
|
||
if(agreed_amount > 0 ){
|
||
expectedAmount = agreed_amount;
|
||
// console.log('Formula 1 AGREED AMOUNT');
|
||
}else if(sum_of_agreed_premium > 0){
|
||
expectedAmount = ((bp + cop) * agreed_bp_per)+ ((tp + tep)*(agreed_tp_per + agreed_tep_per));
|
||
expectedAmount = expectedAmount / 100;
|
||
// console.log('Formula 2 AGREED BP TP/TEP %');
|
||
}else{
|
||
expectedAmount = ((bp + cop) * standard_bp_per)+ ((tp + tep)*(standard_tp_per + standard_tep_per));
|
||
console.log(expectedAmount)
|
||
expectedAmount = expectedAmount / 100;
|
||
// console.log('Formula 3 STANDARD BP TP/TEP %');
|
||
}
|
||
|
||
// console.log('expectedAmount', expectedAmount);
|
||
|
||
//Expected Amount
|
||
// $('#exp_amt_' + input).val(expectedAmount.toFixed(2));
|
||
$('#exp_amt_' + input).val(!isNaN(expectedAmount) && isFinite(expectedAmount) ? expectedAmount.toFixed(2) : '0.00');
|
||
|
||
|
||
let actual_bp_brokerage_amount = parseFloat($('#actual_bp_brokerage_amt_' + input).val()) || 0;
|
||
let actual_tp_brokerage_amount = parseFloat($('#actual_tp_brokerage_amt_' + input).val()) || 0;
|
||
let actual_tep_brokerage_amount = parseFloat($('#actual_tep_brokerage_amt_' + input).val()) || 0;
|
||
|
||
// console.log('actual_bp_brokerage_amount', actual_bp_brokerage_amount);
|
||
// console.log('actual_tp_brokerage_amount', actual_tp_brokerage_amount);
|
||
// console.log('actual_tep_brokerage_amount', actual_tep_brokerage_amount);
|
||
|
||
|
||
|
||
// let variance = expectedAmount - (actual_bp_brokerage_amount + actual_tp_brokerage_amount + actual_tep_brokerage_amount)
|
||
let variance = (actual_bp_brokerage_amount + actual_tp_brokerage_amount + actual_tep_brokerage_amount) - expectedAmount;
|
||
// console.log('variance', variance);
|
||
|
||
|
||
// $('#variance_' + input).val(variance.toFixed(2));
|
||
$('#variance_' + input).val(!isNaN(variance) && isFinite(variance) ? variance.toFixed(2) : '0.00');
|
||
|
||
// console.log('variance', variance);
|
||
}
|
||
|
||
function actualAmountCalculation(input, field = null){
|
||
|
||
console.log('actualAmountCalculation function called')
|
||
console.log('actualAmountCalculation function input', input)
|
||
console.log('actualAmountCalculation function field', field)
|
||
|
||
let selectedOption = $('#policy_type_id').find('option:selected');
|
||
let bap = selectedOption.data('bap');
|
||
|
||
console.log('actualAmountCalculation function bap', bap)
|
||
|
||
let actual_bp_amt = parseFloat($('#actual_bp_amt_' + input).val()) || 0;
|
||
let actual_tp_amt = parseFloat($('#actual_tp_amt_' + input).val()) || 0;
|
||
let actual_tep_amt = parseFloat($('#actual_tep_amt_' + input).val()) || 0;
|
||
|
||
let actual_bp_per = parseFloat($('#actual_bp_per_' + input).val()) || 0;
|
||
let actual_tp_per = parseFloat($('#actual_tp_per_' + input).val()) || 0;
|
||
let actual_tep_per = parseFloat($('#actual_tep_per_' + input).val()) || 0;
|
||
|
||
let actual_bp_brokerage_amt = parseFloat($('#actual_bp_brokerage_amt_' + input).val()) || 0;
|
||
let actual_tp_brokerage_amt = parseFloat($('#actual_tp_brokerage_amt_' + input).val()) || 0;
|
||
let actual_tep_brokerage_amt = parseFloat($('#actual_tep_brokerage_amt_' + input).val()) || 0;
|
||
|
||
//------------------------------------------------------------------------------------------
|
||
|
||
if (field === 'bp_per') {
|
||
console.log()
|
||
if (actual_bp_amt > 0 && actual_bp_per >= 0) {
|
||
let actual_bp_brokerage_amount = (actual_bp_amt * actual_bp_per) / 100;
|
||
// $('#actual_bp_brokerage_amt_' + input).val(actual_bp_brokerage_amount.toFixed(2));
|
||
$('#actual_bp_brokerage_amt_' + input).val(!isNaN(actual_bp_brokerage_amount) && isFinite(actual_bp_brokerage_amount) ? actual_bp_brokerage_amount.toFixed(2) : '0.00');
|
||
|
||
}
|
||
} else if (field === 'bp_broker_amt') {
|
||
// If brokerage amount is changed, update percentage
|
||
if (actual_bp_amt > 0 && actual_bp_brokerage_amt >= 0) {
|
||
let actual_bp_percentage = (actual_bp_brokerage_amt / actual_bp_amt) * 100;
|
||
// $('#actual_bp_per_' + input).val(actual_bp_percentage.toFixed(2));
|
||
$('#actual_bp_per_' + input).val(!isNaN(actual_bp_percentage) && isFinite(actual_bp_percentage) ? actual_bp_percentage.toFixed(2) : '0.00');
|
||
|
||
}
|
||
} else if (field === 'bp_amt_for_calc') {
|
||
|
||
if(actual_bp_per > 0){
|
||
|
||
if (actual_bp_amt > 0 && actual_bp_per >= 0) {
|
||
let actual_bp_brokerage_amount = (actual_bp_amt * actual_bp_per) / 100;
|
||
// $('#actual_bp_brokerage_amt_' + input).val(actual_bp_brokerage_amount.toFixed(2));
|
||
$('#actual_bp_brokerage_amt_' + input).val(!isNaN(actual_bp_brokerage_amount) && isFinite(actual_bp_brokerage_amount) ? actual_bp_brokerage_amount.toFixed(2) : '0.00');
|
||
}
|
||
|
||
}else if(actual_bp_brokerage_amt > 0){
|
||
|
||
if (actual_bp_amt > 0 && actual_bp_brokerage_amt >= 0) {
|
||
let actual_bp_percentage = (actual_bp_brokerage_amt / actual_bp_amt) * 100;
|
||
// $('#actual_bp_per_' + input).val(actual_bp_percentage.toFixed(2));
|
||
$('#actual_bp_per_' + input).val(!isNaN(actual_bp_percentage) && isFinite(actual_bp_percentage) ? actual_bp_percentage.toFixed(2) : '0.00');
|
||
}
|
||
|
||
}else{
|
||
|
||
if (actual_bp_amt > 0 && actual_bp_per >= 0) {
|
||
let actual_bp_brokerage_amount = (actual_bp_amt * actual_bp_per) / 100;
|
||
// $('#actual_bp_brokerage_amt_' + input).val(actual_bp_brokerage_amount.toFixed(2));
|
||
$('#actual_bp_brokerage_amt_' + input).val(!isNaN(actual_bp_brokerage_amount) && isFinite(actual_bp_brokerage_amount) ? actual_bp_brokerage_amount.toFixed(2) : '0.00');
|
||
}
|
||
|
||
if (actual_bp_amt > 0 && actual_bp_brokerage_amt >= 0) {
|
||
let actual_bp_percentage = (actual_bp_brokerage_amt / actual_bp_amt) * 100;
|
||
// $('#actual_bp_per_' + input).val(actual_bp_percentage.toFixed(2));
|
||
$('#actual_bp_per_' + input).val(!isNaN(actual_bp_percentage) && isFinite(actual_bp_percentage) ? actual_bp_percentage.toFixed(2) : '0.00');
|
||
}
|
||
}
|
||
}
|
||
|
||
//-----------------------------------------------------------------------------------------
|
||
|
||
if(bap == 'Motor'){
|
||
|
||
if (field === 'tp_per') {
|
||
if (actual_tp_amt > 0 && actual_tp_per >= 0) {
|
||
let actual_tp_brokerage_amount = (actual_tp_amt * actual_tp_per) / 100;
|
||
// $('#actual_tp_brokerage_amt_' + input).val(actual_tp_brokerage_amount.toFixed(2));
|
||
$('#actual_tp_brokerage_amt_' + input).val(!isNaN(actual_tp_brokerage_amount) && isFinite(actual_tp_brokerage_amount) ? actual_tp_brokerage_amount.toFixed(2) : '0.00');
|
||
}
|
||
} else if (field === 'tp_broker_amt') {
|
||
// If brokerage amount is changed, update percentage
|
||
if (actual_tp_amt > 0 && actual_tp_brokerage_amt >= 0) {
|
||
let actual_tp_percentage = (actual_tp_brokerage_amt / actual_tp_amt) * 100;
|
||
// $('#actual_tp_per_' + input).val(actual_tp_percentage.toFixed(2));
|
||
$('#actual_tp_per_' + input).val(!isNaN(actual_tp_percentage) && isFinite(actual_tp_percentage) ? actual_tp_percentage.toFixed(2) : '0.00');
|
||
}
|
||
} else if (field === 'tp_amt_for_calc') {
|
||
|
||
if(actual_tp_amt > 0){
|
||
|
||
if (actual_tp_amt > 0 && actual_tp_per >= 0) {
|
||
let actual_tp_brokerage_amount = (actual_tp_amt * actual_tp_per) / 100;
|
||
// $('#actual_tp_brokerage_amt_' + input).val(actual_tp_brokerage_amount.toFixed(2));
|
||
$('#actual_tp_brokerage_amt_' + input).val(!isNaN(actual_tp_brokerage_amount) && isFinite(actual_tp_brokerage_amount) ? actual_tp_brokerage_amount.toFixed(2) : '0.00');
|
||
|
||
}
|
||
|
||
}else if(actual_tp_brokerage_amt > 0){
|
||
|
||
if (actual_tp_amt > 0 && actual_tp_brokerage_amt >= 0) {
|
||
let actual_tp_percentage = (actual_tp_brokerage_amt / actual_tp_amt) * 100;
|
||
// $('#actual_tp_per_' + input).val(actual_tp_percentage.toFixed(2));
|
||
$('#actual_tp_per_' + input).val(!isNaN(actual_tp_percentage) && isFinite(actual_tp_percentage) ? actual_tp_percentage.toFixed(2) : '0.00');
|
||
}
|
||
|
||
}else{
|
||
if (actual_tp_amt > 0 && actual_tp_per >= 0) {
|
||
let actual_tp_brokerage_amount = (actual_tp_amt * actual_tp_per) / 100;
|
||
// $('#actual_tp_brokerage_amt_' + input).val(actual_tp_brokerage_amount.toFixed(2));
|
||
$('#actual_tp_brokerage_amt_' + input).val(!isNaN(actual_tp_brokerage_amount) && isFinite(actual_tp_brokerage_amount) ? actual_tp_brokerage_amount.toFixed(2) : '0.00');
|
||
}
|
||
|
||
if (actual_tp_amt > 0 && actual_tp_brokerage_amt >= 0) {
|
||
let actual_tp_percentage = (actual_tp_brokerage_amt / actual_tp_amt) * 100;
|
||
// $('#actual_tp_per_' + input).val(actual_tp_percentage.toFixed(2));
|
||
$('#actual_tp_per_' + input).val(!isNaN(actual_tp_percentage) && isFinite(actual_tp_percentage) ? actual_tp_percentage.toFixed(2) : '0.00');
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
}else{
|
||
|
||
$('#actual_tp_brokerage_amt_' + input).val(0);
|
||
$('#actual_tp_per_' + input).val(0);
|
||
}
|
||
|
||
//-----------------------------------------------------------------------------------------
|
||
|
||
|
||
if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
|
||
|
||
if (field === 'tep_per') {
|
||
if (actual_tep_amt > 0 && actual_tep_per >= 0) {
|
||
let actual_tep_brokerage_amount = (actual_tep_amt * actual_tep_per) / 100;
|
||
// $('#actual_tep_brokerage_amt_' + input).val(actual_tep_brokerage_amount.toFixed(2));
|
||
$('#actual_tep_brokerage_amt_' + input).val(!isNaN(actual_tep_brokerage_amount) && isFinite(actual_tep_brokerage_amount) ? actual_tep_brokerage_amount.toFixed(2) : '0.00');
|
||
|
||
}
|
||
} else if (field === 'tep_broker_amt') {
|
||
// If brokerage amount is changed, update percentage
|
||
if (actual_tep_amt > 0 && actual_tep_brokerage_amt >= 0) {
|
||
let actual_tep_percentage = (actual_tep_brokerage_amt / actual_tep_amt) * 100;
|
||
// $('#actual_tep_per_' + input).val(actual_tep_percentage.toFixed(2));
|
||
$('#actual_tep_per_' + input).val(!isNaN(actual_tep_percentage) && isFinite(actual_tep_percentage) ? actual_tep_percentage.toFixed(2) : '0.00');
|
||
|
||
}
|
||
} else if (field === 'tep_amt_for_calc') {
|
||
|
||
if(actual_tep_amt > 0){
|
||
|
||
if (actual_tep_amt > 0 && actual_tep_per >= 0) {
|
||
let actual_tep_brokerage_amount = (actual_tep_amt * actual_tep_per) / 100;
|
||
// $('#actual_tep_brokerage_amt_' + input).val(actual_tep_brokerage_amount.toFixed(2));
|
||
$('#actual_tep_brokerage_amt_' + input).val(!isNaN(actual_tep_brokerage_amount) && isFinite(actual_tep_brokerage_amount) ? actual_tep_brokerage_amount.toFixed(2) : '0.00');
|
||
|
||
}
|
||
|
||
}else if(actual_tep_brokerage_amt > 0){
|
||
|
||
if (actual_tep_amt > 0 && actual_tep_brokerage_amt >= 0) {
|
||
let actual_tep_percentage = (actual_tep_brokerage_amt / actual_tep_amt) * 100;
|
||
// $('#actual_tep_per_' + input).val(actual_tep_percentage.toFixed(2));
|
||
$('#actual_tep_per_' + input).val(!isNaN(actual_tep_percentage) && isFinite(actual_tep_percentage) ? actual_tep_percentage.toFixed(2) : '0.00');
|
||
}
|
||
|
||
}else{
|
||
|
||
if (actual_tep_amt > 0 && actual_tep_per >= 0) {
|
||
let actual_tep_brokerage_amount = (actual_tep_amt * actual_tep_per) / 100;
|
||
// $('#actual_tep_brokerage_amt_' + input).val(actual_tep_brokerage_amount.toFixed(2));
|
||
$('#actual_tep_brokerage_amt_' + input).val(!isNaN(actual_tep_brokerage_amount) && isFinite(actual_tep_brokerage_amount) ? actual_tep_brokerage_amount.toFixed(2) : '0.00');
|
||
}
|
||
|
||
if (actual_tep_amt > 0 && actual_tep_brokerage_amt >= 0) {
|
||
let actual_tep_percentage = (actual_tep_brokerage_amt / actual_tep_amt) * 100;
|
||
// $('#actual_tep_per_' + input).val(actual_tep_percentage.toFixed(2));
|
||
$('#actual_tep_per_' + input).val(!isNaN(actual_tep_percentage) && isFinite(actual_tep_percentage) ? actual_tep_percentage.toFixed(2) : '0.00');
|
||
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
}else{
|
||
|
||
$('#actual_tep_brokerage_amt_' + input).val(0);
|
||
$('#actual_tep_per_' + input).val(0);
|
||
}
|
||
|
||
//-----------------------------------------------------------------------------------------
|
||
|
||
let expectedAmount = parseFloat($('#exp_amt_' + input).val()) || 0;
|
||
var actual_bp_brokerage_amount2 = parseFloat($('#actual_bp_brokerage_amt_' + input).val()) || 0;
|
||
let actual_tp_brokerage_amount2 = parseFloat($('#actual_tp_brokerage_amt_' + input).val()) || 0;
|
||
let actual_tep_brokerage_amount2 = parseFloat($('#actual_tep_brokerage_amt_' + input).val()) || 0;
|
||
|
||
// let variance = expectedAmount - (actual_bp_brokerage_amount2 + actual_tp_brokerage_amount2 + actual_tep_brokerage_amount2)
|
||
let variance = (actual_bp_brokerage_amount2 + actual_tp_brokerage_amount2 + actual_tep_brokerage_amount2) - expectedAmount
|
||
|
||
// $('#variance_' + input).val(variance.toFixed(2));
|
||
$('#variance_' + input).val(!isNaN(variance) && isFinite(variance) ? variance.toFixed(2) : '0.00');
|
||
|
||
// console.log('expectedAmount', expectedAmount);
|
||
console.log('variance', variance);
|
||
}
|
||
|
||
function co_share_percentage_calculation(input, extra = null){
|
||
|
||
console.log('input', input)
|
||
var inputs = $('input[name="co_share_per[]"]'); // Specifically select input elements
|
||
console.log('Number of inputs:', inputs.length);
|
||
|
||
let insurer_count = insurer_count_array.length;
|
||
console.log('insurer_count', insurer_count);
|
||
console.log('insurer_count_array', insurer_count_array);
|
||
|
||
if(input){
|
||
if(insurer_count == 2){
|
||
|
||
// Find the index of the value
|
||
let index = insurer_count_array.indexOf(Number(input));
|
||
let second_value_index = "";
|
||
|
||
if (index !== -1) {
|
||
|
||
console.log(`Value ${input} exists at index ${index}.`);
|
||
|
||
let beforeValue = index > 0 ? insurer_count_array[index - 1] : null;
|
||
let afterValue = index < insurer_count_array.length - 1 ? insurer_count_array[index + 1] : null;
|
||
|
||
if (beforeValue != null) {
|
||
second_value_index = beforeValue;
|
||
} else if (afterValue != null) {
|
||
second_value_index = afterValue;
|
||
}
|
||
|
||
}
|
||
|
||
let value1 = $('#co_share_per_' + input).val();
|
||
let value2 = $('#co_share_per_' + second_value_index).val();
|
||
|
||
value1 = Number(value1);
|
||
value2 = Number(value2);
|
||
|
||
console.log('value1', value1);
|
||
console.log('value2', value2);
|
||
|
||
if(extra == "add"){
|
||
|
||
if(value2 == 0){
|
||
value1 = 50;
|
||
value2 = 50;
|
||
}else{
|
||
if(value2 == 100){
|
||
value1 = 0;
|
||
}else{
|
||
value1 = 100 - value2;
|
||
}
|
||
}
|
||
|
||
}else{
|
||
|
||
if(value1 == 100){
|
||
value2 = 0;
|
||
}else{
|
||
value2 = 100 - value1;
|
||
}
|
||
}
|
||
|
||
console.log('value1', value1);
|
||
console.log('value2', value2);
|
||
|
||
$('#co_share_per_' + input).val(value1);
|
||
$('#co_share_per_' + second_value_index).val(value2);
|
||
|
||
}else if(insurer_count > 2){
|
||
|
||
let total_val = 0;
|
||
|
||
// Calculate the total sum of input values
|
||
inputs.each(function () {
|
||
let val = Number($(this).val()) || 0;
|
||
if(val == 0){
|
||
$(this).val(0)
|
||
}
|
||
total_val += val;
|
||
});
|
||
|
||
// if (total_val < 100) {
|
||
// let remaining_val = 100 - total_val; // Calculate the remaining value
|
||
|
||
// // Assign the remaining value to the first empty input
|
||
// let assigned = false;
|
||
// inputs.each(function () {
|
||
// let current_val = Number($(this).val()) || 0;
|
||
// if (current_val === 0 && !assigned) { // Assign only once
|
||
// $(this).val(remaining_val);
|
||
// assigned = true;
|
||
// } else if (current_val === 0) {
|
||
// $(this).val(0); // Set other empty inputs to 0
|
||
// }
|
||
// });
|
||
// } else if (total_val > 100) {
|
||
// toastr.warning('Sum of the co-share is greater than 100');
|
||
// }
|
||
|
||
}
|
||
}else{
|
||
inputs.each(function (index) {
|
||
if (inputs.length === 1) {
|
||
$(this).val(100);
|
||
} else if(inputs.length === 2) {
|
||
let first = $('#co_share_per_1').val();
|
||
first = Number(first)
|
||
let second_val = 100 - first;
|
||
|
||
if (index === 1) {
|
||
$(this).val(second_val);
|
||
}
|
||
}
|
||
});
|
||
|
||
}
|
||
|
||
let val_sum = 0;
|
||
|
||
inputs.each(function () {
|
||
let val = Number($(this).val()) || 0;
|
||
val_sum += val;
|
||
});
|
||
|
||
if (val_sum > 100) {
|
||
toastr.warning('Sum of the co-share is greater than 100', 'Warning');
|
||
}
|
||
|
||
// // Find the empty input(s)
|
||
// var emptyInputs = inputs.filter(function() {
|
||
// return $(this).val().trim() === ''; // Check for empty values
|
||
// });
|
||
|
||
// // Get the number of empty inputs
|
||
// var emptyCount = emptyInputs.length;
|
||
// console.log('Number of empty inputs:', emptyCount);
|
||
|
||
// // If there's exactly one empty input, calculate and set its value
|
||
// if (emptyCount === 1) {
|
||
|
||
// // Calculate the sum of filled values
|
||
// let sumFilled = 0;
|
||
// inputs.each(function() {
|
||
// var val = parseFloat($(this).val()) || 0;
|
||
// sumFilled += val;
|
||
// });
|
||
|
||
// // Calculate the balance percentage
|
||
// let balance_per = 100 - sumFilled;
|
||
// console.log('Balance percentage:', balance_per);
|
||
|
||
// // Set the balance value to the empty input
|
||
// emptyInputs.val(balance_per);
|
||
// }
|
||
|
||
}
|
||
|
||
// function co_share_percentage_calculation(input) {
|
||
|
||
// console.log('Input ID:', input);
|
||
|
||
// const inputs = $('input[name="co_share_per[]"]');
|
||
// const totalInputs = inputs.length;
|
||
|
||
// console.log('Number of inputs:', totalInputs);
|
||
|
||
// const inputValues = {};
|
||
// inputs.each(function () {
|
||
// const id = $(this).attr('id').split('_').pop(); // Extract ID
|
||
// inputValues[id] = parseFloat($(this).val()) || 0; // Parse value or default to 0
|
||
// });
|
||
|
||
// console.log('Initial input values:', inputValues);
|
||
|
||
// // Handle value calculation for the given input
|
||
// const currentValue = inputValues[input] || 0;
|
||
// const remainingPercentage = 100 - currentValue;
|
||
|
||
// if (totalInputs === 2) {
|
||
// // Specific handling for exactly 2 inputs
|
||
// const otherInputId = Object.keys(inputValues).find(id => id !== input);
|
||
// const otherValue = inputValues[otherInputId] || 0;
|
||
|
||
// // if (extra === 'add') {
|
||
// // inputValues[input] = otherValue === 100 ? 0 : remainingPercentage;
|
||
// // } else {
|
||
// inputValues[otherInputId] = currentValue === 100 ? 0 : remainingPercentage;
|
||
// // }
|
||
// }
|
||
|
||
// // else {
|
||
// // // Distribute remaining percentage among other inputs proportionally
|
||
// // let totalFilled = 0;
|
||
// // let emptyInputs = [];
|
||
|
||
// // Object.keys(inputValues).forEach(id => {
|
||
// // if (id === input) {
|
||
// // totalFilled += currentValue;
|
||
// // } else if (inputValues[id] > 0) {
|
||
// // totalFilled += inputValues[id];
|
||
// // } else {
|
||
// // emptyInputs.push(id);
|
||
// // }
|
||
// // });
|
||
|
||
// // console.log('Total filled percentage:', totalFilled);
|
||
|
||
// // if (emptyInputs.length > 0) {
|
||
// // const balancePerInput = remainingPercentage / emptyInputs.length;
|
||
// // emptyInputs.forEach(id => {
|
||
// // inputValues[id] = balancePerInput.toFixed(2); // Distribute evenly
|
||
// // });
|
||
// // }
|
||
|
||
// // console.log('Empty input IDs:', emptyInputs);
|
||
// // }
|
||
|
||
// // Update input values in DOM
|
||
// Object.keys(inputValues).forEach(id => {
|
||
// $(`#co_share_per_${id}`).val(inputValues[id]);
|
||
// });
|
||
|
||
// console.log('Updated input values:', inputValues);
|
||
// }
|
||
|
||
// function co_share_percentage_calculation(input) {
|
||
// console.log('Input ID:', input);
|
||
|
||
// const inputs = $('input[name="co_share_per[]"]');
|
||
// const totalInputs = inputs.length;
|
||
|
||
// console.log('Number of inputs:', totalInputs);
|
||
|
||
// const inputValues = {};
|
||
// let totalFilled = 0;
|
||
// let emptyInputs = [];
|
||
|
||
// // Collect input values and track empty inputs
|
||
// inputs.each(function () {
|
||
// const id = $(this).attr('id').split('_').pop(); // Extract ID
|
||
// const value = parseFloat($(this).val()) || 0;
|
||
|
||
// inputValues[id] = value;
|
||
// totalFilled += value;
|
||
|
||
// if (value === 0) {
|
||
// emptyInputs.push(id); // Track empty inputs
|
||
// }
|
||
// });
|
||
|
||
// console.log('Initial input values:', inputValues);
|
||
// console.log('Total filled percentage:', totalFilled);
|
||
// console.log('Empty input IDs:', emptyInputs);
|
||
|
||
// // Ensure total percentage does not exceed 100
|
||
// if (totalFilled > 100) {
|
||
// console.error("Error: Total percentage exceeds 100!");
|
||
// return;
|
||
// }
|
||
|
||
// // Adjust empty inputs to balance the total to 100%
|
||
// const remainingPercentage = 100 - totalFilled;
|
||
|
||
// if (emptyInputs.length > 0) {
|
||
// const balancePerInput = (remainingPercentage / emptyInputs.length).toFixed(2);
|
||
|
||
// emptyInputs.forEach(id => {
|
||
// inputValues[id] = parseFloat(balancePerInput);
|
||
// });
|
||
|
||
// console.log('Remaining percentage:', remainingPercentage);
|
||
// console.log('Balanced input values:', inputValues);
|
||
// }
|
||
|
||
// // Update all input values in the DOM
|
||
// Object.keys(inputValues).forEach(id => {
|
||
// $(`#co_share_per_${id}`).val(inputValues[id]);
|
||
// });
|
||
|
||
// console.log('Final input values:', inputValues);
|
||
// }
|
||
|
||
$(document).on('change', '[name="base_premium[]"], [name="co_share_per[]"]', function() {
|
||
|
||
console.log('Triggered change event.');
|
||
|
||
// Get the first non-empty base premium value
|
||
let basePremium = $('input[name="base_premium[]"]').toArray()
|
||
.map(input => parseFloat($(input).val()) || 0)
|
||
.find(value => value > 0) || 0;
|
||
|
||
console.log('Base Premium:', basePremium);
|
||
|
||
// Loop through all co_share_per[] fields
|
||
$('input[name="co_share_per[]"]').each(function(index) {
|
||
const coSharePer = parseFloat($(this).val()) || 0; // Get co_share_per value
|
||
const coPremium = (basePremium * coSharePer) / 100; // Calculate co_premium
|
||
|
||
console.log(`Index: ${index}, Co-Share Percentage: ${coSharePer}, Co-Premium: ${coPremium}`);
|
||
|
||
// Update corresponding co_premium field
|
||
$('input[name="co_premium[]"]').eq(index).val(coPremium.toFixed(2));
|
||
});
|
||
});
|
||
|
||
function select_leader_disable_premium_amt(input, value) {
|
||
|
||
if ($(input).is(':checked')) {
|
||
// Disable and add readonly-select class to all premiums except the one with the given value
|
||
$('input[name="base_premium[]"]').addClass('readonly-select');
|
||
$('#base_premium_' + value).removeClass('readonly-select');
|
||
|
||
$('input[name="tp_premium[]"]').addClass('readonly-select');
|
||
$('#tp_premium_' + value).removeClass('readonly-select');
|
||
|
||
$('input[name="ter_premium[]"]').addClass('readonly-select');
|
||
$('#ter_premium_' + value).removeClass('readonly-select');
|
||
|
||
$('input[name="stamp_duty[]"]').addClass('readonly-select');
|
||
$('#stamp_duty_' + value).removeClass('readonly-select');
|
||
|
||
$('input[name="co_premium[]"]').addClass('readonly-select');
|
||
$('#co_premium_' + value).removeClass('readonly-select');
|
||
|
||
} else {
|
||
// Enable and remove readonly-select class from all premiums except the one with the given value
|
||
$('input[name="base_premium[]"]').removeClass('readonly-select');
|
||
$('input[name="tp_premium[]"]').removeClass('readonly-select');
|
||
$('input[name="ter_premium[]"]').removeClass('readonly-select');
|
||
$('input[name="stamp_duty[]"]').removeClass('readonly-select');
|
||
$('input[name="co_premium[]"]').removeClass('readonly-select');
|
||
}
|
||
}
|
||
|
||
function validateRange(input) {
|
||
// if (input.value < 1) input.value = 1;
|
||
if (input.value > 100) input.value = 100;
|
||
}
|
||
|
||
function setRenewalPolicyData(input) {
|
||
|
||
var selectedOption = $(input).find('option:selected');
|
||
|
||
var policy_no = selectedOption.data('policy');
|
||
var insurer = selectedOption.data('insurer');
|
||
var insurer_branch_id = selectedOption.data('ib');
|
||
var tpa = selectedOption.data('tpa');
|
||
var tpa_branch_id = selectedOption.data('tpab');
|
||
var cd_ac_no = selectedOption.data('cd');
|
||
var policy_start_date = selectedOption.data('ps');
|
||
var policy_end_date = selectedOption.data('pe');
|
||
|
||
// console.log('policy_no', policy_no);
|
||
// console.log('insurer', insurer);
|
||
// console.log('cd_ac_no', cd_ac_no);
|
||
// console.log('insurer_branch_id', insurer_branch_id);
|
||
|
||
$('#renewal_policy_start_date').val(policy_start_date);
|
||
$('#renewal_policy_end_date').val(policy_end_date);
|
||
|
||
}
|
||
|
||
function appendInsured(data = null) {
|
||
const container = document.getElementById('dynamic-form-container-for-insured');
|
||
// console.log(container);
|
||
const newRow = document.createElement('div');
|
||
newRow.className = 'form-row insured-dynamic-form-row';
|
||
newRow.innerHTML = `
|
||
<input type="hidden" id="emp_id" name="emp_id[]">
|
||
<input type="hidden" id="emp_policy_id" name="emp_policy_id[]">
|
||
<div class="form-group col-md-5">
|
||
<label for="file_name">Name<span class="text-danger"></span></label>
|
||
<input type="text" class="form-control" id="name" name="family_name[]" placeholder="Enter Name" required>
|
||
</div>
|
||
|
||
<div class="form-group col-md-5">
|
||
<label for="relationship">Relationship<span class="text-danger"></span></label>
|
||
<select class="form-control" id="relationship" name="relationship[]" required>
|
||
<option value="" disabled selected>Select Relationship</option>
|
||
<option value="Father">Father</option>
|
||
<option value="Mother">Mother</option>
|
||
<option value="Son">Son</option>
|
||
<option value="Daughter">Daughter</option>
|
||
<option value="Father in law">Father-in-law</option>
|
||
<option value="Mother in law">Mother-in-law</option>
|
||
<option value="Spouse">Spouse</option>
|
||
</select>
|
||
</div>
|
||
|
||
|
||
<div class="form-group col-md-2" style="position: relative;top: 28px;">
|
||
<a class="btn btn-danger waves-effect waves-light" onclick="removeRemoveInsured(this)">x</a>
|
||
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="appendInsured(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;
|
||
}
|
||
|
||
if (data !== null) {
|
||
if (data.name) {
|
||
newRow.querySelector('#name').value = data.name;
|
||
}
|
||
if (data.relationship) {
|
||
newRow.querySelector('#relationship').value = data.relationship;
|
||
}
|
||
if (data.id) {
|
||
newRow.querySelector('#emp_id').value = data.id;
|
||
}
|
||
}
|
||
}
|
||
|
||
function removeRemoveInsured(element) {
|
||
const container = document.getElementById('dynamic-form-container');
|
||
const rows = container.querySelectorAll('.insured-dynamic-form-row');
|
||
|
||
if (rows.length > 1) {
|
||
const row = element.closest('.insured-dynamic-form-row');
|
||
row.remove();
|
||
}
|
||
}
|
||
|
||
function appendOwner(data) {
|
||
|
||
$('#owner').empty();
|
||
|
||
$('#owner').append($('<option>', {
|
||
value: '',
|
||
text: 'Select Owner'
|
||
}));
|
||
|
||
$('#owner').append(
|
||
$('<option>', {
|
||
value: 'add_client',
|
||
text: ' + Add Owner',
|
||
})
|
||
);
|
||
|
||
|
||
$.each(data, function(index, item) {
|
||
var option = $('<option>', {
|
||
value: item.id,
|
||
text: item.client_name,
|
||
});
|
||
|
||
$('#owner').append(option);
|
||
});
|
||
|
||
}
|
||
|
||
function appendOwnerBranch(data) {
|
||
|
||
$('#owner_branch').empty();
|
||
|
||
$('#owner_branch').append($('<option>', {
|
||
value: '',
|
||
text: 'Select Branch'
|
||
}));
|
||
|
||
$.each(data, function(index, item) {
|
||
|
||
var option = $('<option>', {
|
||
value: item.id,
|
||
text: item.branch_name
|
||
});
|
||
$('#owner_branch').append(option);
|
||
});
|
||
}
|
||
|
||
function selectListedInsurers(listedInsurers) {
|
||
listedInsurers = JSON.parse(listedInsurers);
|
||
// Loop through each insurer-branch combination
|
||
$.each(listedInsurers, function(index, value) {
|
||
// Use value in the format 'branch_id-insurer_id'
|
||
$('#listed_insurers option').each(function() {
|
||
if ($(this).val() === value) {
|
||
$(this).prop('selected', true); // Select the matching option
|
||
}
|
||
});
|
||
});
|
||
// Trigger change for plugins (like Select2)
|
||
$('#listed_insurers').trigger('change');
|
||
}
|
||
|
||
function checkInvoiceStatusToHideSubmitBtn(id){
|
||
|
||
$.ajax({
|
||
url: '<?php echo base_url('util/checkInvoiceStatus/');?>'+ id,
|
||
type: "GET",
|
||
dataType: 'json',
|
||
success: function (res) {
|
||
|
||
console.log('checkInvoiceStatusToHideSubmitBtn response', res)
|
||
|
||
if(res.status == true){
|
||
if(res.count > 0){
|
||
$('#submitButton').hide()
|
||
}else{
|
||
$('#submitButton').show()
|
||
}
|
||
}else{
|
||
|
||
console.log(res.message, 'warning');
|
||
}
|
||
},
|
||
error: function (xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
}
|
||
});
|
||
|
||
}
|
||
|
||
function getCDAccountNumber(input)
|
||
{
|
||
console.log('##########################################')
|
||
console.log('getCDAccountNumber')
|
||
console.log('##########################################')
|
||
|
||
|
||
// var client_id = $('#client_id').val()
|
||
// var insurer_id = $('#insurer_id').find('option:selected').attr('data-id');
|
||
|
||
// var client_id = $('#client_id').val()
|
||
// var insurer_id = $(this).val();
|
||
|
||
let insurer = $(input).val();
|
||
let unique_id = $(input).data('count');
|
||
let client_id = $('#client_id').val();
|
||
let client_type = $('#client_type').val();
|
||
let insurer_id = $(input).find('option:selected').attr('data-id');
|
||
|
||
console.log('insurer', insurer);
|
||
console.log('follow_insurer_id client_id', client_id);
|
||
console.log('follow_insurer_id insurer_id', insurer_id);
|
||
console.log('follow_insurer_id unique_id', unique_id);
|
||
|
||
if(client_id && insurer_id){
|
||
if(client_type == 1){
|
||
$.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, unique_id)
|
||
appendCDAccountNumber(res.data, unique_id)
|
||
if(res.data[0].cd_ac_no){
|
||
$('#cd_ac_no').val(res.data[0].cd_ac_no)
|
||
}
|
||
}else{
|
||
var pt_id = $('#policy_tranction_primarykey').val();
|
||
if(pt_id == ''){
|
||
toastr.warning('The insurer does not has a CD account number');
|
||
}
|
||
console.log('The insurer does not has a CD account number');
|
||
|
||
$('#cd_ac_no_'+unique_id).empty();
|
||
$('#cd_ac_no_'+unique_id).append($('<option>', {
|
||
value: '',
|
||
text: 'Select CD No',
|
||
}));
|
||
$('#cd_ac_no_'+unique_id).append($('<option>', {
|
||
value: 'add_cd',
|
||
text: '+ Add CD'
|
||
}));
|
||
}
|
||
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
}
|
||
});
|
||
}else{
|
||
console.error('Client type Not found')
|
||
console.log('client_type', client_type);
|
||
}
|
||
}else{
|
||
console.error('Client ID or Insurer ID Not found')
|
||
console.log('client_id', client_id);
|
||
console.log('insurer_id', insurer_id);
|
||
}
|
||
}
|
||
|
||
function appendCDAccountNumber(data, unique_id, new_cd_ac_no = null)
|
||
{
|
||
console.log('appendCDAccountNumber', data);
|
||
console.log('appendCDAccountNumber', $('#cd_ac_no'));
|
||
|
||
$('#cd_ac_no_'+unique_id).empty();
|
||
|
||
$('#cd_ac_no_'+unique_id).append($('<option>', {
|
||
value: '',
|
||
text: 'Select CD No',
|
||
}));
|
||
|
||
$('#cd_ac_no_'+unique_id).append($('<option>', {
|
||
value: 'add_cd',
|
||
text: '+ Add CD'
|
||
}));
|
||
|
||
$.each(data, function(index, item) {
|
||
var option = $('<option>', {
|
||
value: item.id,
|
||
text: item.cd_ac_no,
|
||
});
|
||
if (new_cd_ac_no == item.cd_ac_no) {
|
||
option.attr('selected', true);
|
||
}
|
||
$('#cd_ac_no_'+unique_id).append(option);
|
||
});
|
||
}
|
||
|
||
function addCDAccountNumber(input)
|
||
{
|
||
var val = $(input).val();
|
||
var uniqueid = $(input).data('count');
|
||
$('#premium_details_unique_id').val(uniqueid);
|
||
var client_id = $('#client_id').val();
|
||
let insurer_id = $('#follow_insurer_id_'+uniqueid).val();
|
||
let leader = $('#co_share_type_' + uniqueid).is(':checked');
|
||
let isAnyLeaderChecked = $('input[type="checkbox"][name="co_share_type[]"]:checked').length == 0;
|
||
let cop_yes = $('#cop_yes').is(':checked');
|
||
|
||
|
||
console.log('addCDAccountNumber', 'addCDAccountNumber');
|
||
console.log('client_id', client_id);
|
||
console.log('insurer_id', insurer_id);
|
||
console.log('leader', leader);
|
||
|
||
|
||
if(client_id == '' || insurer_id == ''){
|
||
toastr.warning('Client, Insurer, or both do not exist.', 'Warning!');
|
||
$(input).val('')
|
||
return false;
|
||
}
|
||
|
||
if (isAnyLeaderChecked) {
|
||
if(cop_yes){
|
||
$('#cd_ac_no_'+uniqueid).val('');
|
||
toastr.warning('Please select the Leader.', 'Warning!');
|
||
return false;
|
||
}
|
||
}
|
||
|
||
if(!leader){
|
||
if(cop_yes){
|
||
$('#cd_ac_no_'+uniqueid).val('');
|
||
toastr.warning('The CD account number not for the Leader.', 'Warning!');
|
||
return false;
|
||
}
|
||
}
|
||
|
||
if(val == 'add_cd')
|
||
{
|
||
var myModal = new bootstrap.Modal(document.getElementById('cd_form_modal'));
|
||
myModal.show();
|
||
$(input).val('')
|
||
}else{
|
||
$('#cd_ac_no').val(val)
|
||
}
|
||
}
|
||
|
||
function restrictCDACNO(currentSelect){
|
||
|
||
const selectedValue = $(currentSelect).val();
|
||
|
||
if (selectedValue) {
|
||
$('.follow_insurer_cd').not(currentSelect).prop('disabled', true);
|
||
} else {
|
||
$('.follow_insurer_cd').prop('disabled', false);
|
||
}
|
||
}
|
||
|
||
function hidePermiumDetailsBasedOnTheTeam(){
|
||
|
||
var teams = <?php echo json_encode(user_team()); ?>;
|
||
console.log('teams', teams);
|
||
|
||
// var teams = <?php echo json_encode(teams()); ?>;
|
||
// console.log('teams', teams);
|
||
|
||
var ids = [
|
||
'table_tr_14',
|
||
'table_tr_15',
|
||
'table_tr_16',
|
||
'table_tr_17',
|
||
'table_tr_18',
|
||
'table_tr_19',
|
||
'table_tr_20',
|
||
'table_tr_21',
|
||
'table_tr_22',
|
||
'table_tr_23',
|
||
'table_tr_24',
|
||
'table_tr_25',
|
||
'table_tr_26',
|
||
'table_tr_27',
|
||
'table_tr_28',
|
||
'table_tr_29',
|
||
'table_tr_30',
|
||
'table_tr_31',
|
||
'table_tr_32'
|
||
];
|
||
|
||
if (teams.includes('4')) {
|
||
console.log('Finance Team Logged in.');
|
||
ids.forEach(function(id) {
|
||
$('#' + id).show();
|
||
// $('#' + id + ' input').prop('disabled', false);
|
||
});
|
||
} else {
|
||
console.log('Business Team Logged in.');
|
||
ids.forEach(function(id) {
|
||
$('#' + id).hide(); // Hide the row
|
||
// $('#' + id + ' input').prop('disabled', true);
|
||
});
|
||
|
||
$('.hideter').hide();
|
||
$('.hidetp').hide();
|
||
}
|
||
}
|
||
|
||
function removeAllColumnsExceptFirst(tableId) {
|
||
|
||
console.log('######################################')
|
||
console.log('removeAllColumnsExceptFirst function called');
|
||
console.log('######################################');
|
||
|
||
// Remove all headers except the first one
|
||
$('#' + tableId + ' thead tr th').each(function(index) {
|
||
if (index > 0) { // Keep the first column (index 0)
|
||
$(this).remove();
|
||
}
|
||
});
|
||
|
||
// Remove corresponding data cells in each row except the first one
|
||
$('#' + tableId + ' tbody tr').each(function() {
|
||
$(this).find('td').each(function(index) {
|
||
if (index > 0) { // Keep the first column (index 0)
|
||
$(this).remove();
|
||
}
|
||
});
|
||
});
|
||
|
||
insurerCount = 0;
|
||
}
|
||
|
||
//---------------------------------------------------------------------------------------------------------
|
||
function convertToMySQLDate(dateString) {
|
||
|
||
// console.log('convertToMySQLDate' + dateString);
|
||
if(dateString !== "" && dateString !== undefined)
|
||
{
|
||
// Split the input date string by '/'
|
||
const [day, month, year] = dateString.split('/');
|
||
|
||
// Return the date in MySQL format: YYYY-MM-DD
|
||
return `${year}-${month}-${day}`;
|
||
}
|
||
return '';
|
||
}
|
||
|
||
// function convertMonthYearToMySQLDate(dateString) {
|
||
// console.log('convertMonthYearToMySQLDate' + dateString);
|
||
|
||
// if(dateString !== "" && dateString !== undefined)
|
||
// {
|
||
// // Create a new Date object using the string with '01' as the day
|
||
// const date = new Date(dateString + '/01');
|
||
// console.log(date);
|
||
// // Format the date to MySQL style: YYYY-MM-DD
|
||
// return date.toISOString().split('T')[0];
|
||
// }
|
||
|
||
// return '';
|
||
// }
|
||
|
||
function convertMonthYearToMySQLDate(dateString) {
|
||
console.log('convertMonthYearToMySQLDate: ' + dateString);
|
||
|
||
if(dateString !== "" && dateString !== undefined) {
|
||
// Map month abbreviations to their respective numbers
|
||
const months = {
|
||
'jan': '01', 'feb': '02', 'mar': '03', 'apr': '04',
|
||
'may': '05', 'jun': '06', 'jul': '07', 'aug': '08',
|
||
'sep': '09', 'oct': '10', 'nov': '11', 'dec': '12'
|
||
};
|
||
|
||
// Split the input string by '/'
|
||
const parts = dateString.toLowerCase().split('/');
|
||
const month = months[parts[0]]; // Convert the month abbreviation to its numeric form
|
||
const year = parts[1]; // Year remains unchanged
|
||
|
||
// Format the date as YYYY-MM-DD
|
||
if (month && year) {
|
||
return `${year}-${month}-01`;
|
||
}
|
||
}
|
||
|
||
return '';
|
||
}
|
||
|
||
|
||
$("#inception_form_id").submit(function(event) {
|
||
|
||
event.preventDefault();
|
||
|
||
var isValid = $('#inception_form_id').parsley().validate();
|
||
var client_type_id = $('#client_type').val();
|
||
var policy_status = $('#policy_status').val();
|
||
|
||
if (!isValid) {
|
||
$('#inception_form_id').find('input, select, textarea').each(function() {
|
||
if ($(this).parsley().isValid() === false && !$(this).val()) {
|
||
console.log('Empty field ID:', this.id);
|
||
}
|
||
});
|
||
console.log('Form is Empty', 'Warning');
|
||
return;
|
||
}
|
||
|
||
|
||
if(client_type_id == 1 && policy_status == 'completed'){
|
||
|
||
let isAnyDropdownSelected = $('select[name="cd_ac_no_for_child[]"]').filter(function() {
|
||
return $(this).val() !== "";
|
||
}).length > 0;
|
||
|
||
console.log('isAnyDropdownSelected', isAnyDropdownSelected);
|
||
|
||
if(!isAnyDropdownSelected){
|
||
toastr.warning('CD account number is Empty', 'Warning');
|
||
return;
|
||
}
|
||
}
|
||
|
||
let co_share_type = []; // Initialize an object to mimic the array structure
|
||
|
||
$('[name="cd_ac_no_for_child[]"]').each(function(index) {
|
||
let value = $(this).val();
|
||
if(value){
|
||
co_share_type.push(1); // Assign value with index as key
|
||
|
||
}else{
|
||
co_share_type.push(2); // Assign value with index as key
|
||
}
|
||
});
|
||
|
||
// console.log(co_share_type);
|
||
|
||
|
||
|
||
var shortListedInsurer = $("#listed_insurers").val();
|
||
// console.log('shortListedInsurer : ', shortListedInsurer);
|
||
|
||
|
||
form_action = '<?= base_url('policy_tranction/inception/create') ?>';
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
var formData = new FormData($('#inception_form_id')[0]);
|
||
|
||
console.log(formData);
|
||
|
||
|
||
const jsonString = JSON.stringify(shortListedInsurer);
|
||
// console.log('jsonString', jsonString);
|
||
|
||
// Append the JSON string to the FormData object
|
||
formData.append('listed_insurers', jsonString);
|
||
co_share_type.forEach((value, index) => {
|
||
formData.append(`co_share_type[${index}]`, value);
|
||
});
|
||
//covert date to mysql format
|
||
// alert(formData.get('policy_issue_date'));
|
||
|
||
formData.set('policy_issue_date',convertToMySQLDate(formData.get('policy_issue_date')));
|
||
formData.set('policy_start_date',convertToMySQLDate(formData.get('policy_start_date')));
|
||
formData.set('policy_end_date',convertToMySQLDate(formData.get('policy_end_date')));
|
||
formData.set('renewal_date',convertToMySQLDate(formData.get('renewal_date')));
|
||
formData.set('rollover_date',convertToMySQLDate(formData.get('rollover_date')));
|
||
formData.set('month',convertMonthYearToMySQLDate(formData.get('month')));
|
||
|
||
// formData['policy_start_date'] = convertToMySQLDate(formData['policy_start_date']);
|
||
// formData['policy_end_date'] = convertToMySQLDate(formData['policy_end_date']);
|
||
// formData['renewal_date'] = convertToMySQLDate(formData['renewal_date']);
|
||
// formData['rollover_date'] = convertToMySQLDate(formData['rollover_date']);
|
||
// formData['month'] = convertMonthYearToMySQLDate(formData['month']);
|
||
// console.log(formData);
|
||
// return false;
|
||
$.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');
|
||
|
||
console.log('inception_form_response', res)
|
||
|
||
if (res.status == true) {
|
||
|
||
toastr.success(res.message, 'Success');
|
||
|
||
show_list_hide_add();
|
||
window.location.href = '<?= base_url('policy_tranction/inception/list') ?>';
|
||
|
||
|
||
$('#policy_tranction_primarykey').val(res.pt_id);
|
||
$('#client_id_kyc').val(res.data.client_id);
|
||
$('#policy_tranction_primarykey_for_file_upload').val(res.pt_id);
|
||
$('#client_policy_id_for_file_upload').val(res.data.client_policy_id);
|
||
|
||
if(res.data.client_policy_id != 0 && res.data.client_policy_id != null){
|
||
$('#hide_file_upload').show();
|
||
}else{
|
||
$('#hide_file_upload').hide();
|
||
}
|
||
|
||
$('#client_id_for_vehicle_file_upload').val(res.data.client_id);
|
||
$('#vehicle_id_for_file_upload').val(res.data.vehicle_id);
|
||
|
||
getKYCEntityDocument(res.data.entity_type_id, res.data.client_id);
|
||
appendKycTableListData(res.data.client_kyc);
|
||
|
||
//setTimeout(function(){
|
||
//}, 1000)
|
||
|
||
if (res.data.pt_co_share_details && res.data.pt_co_share_details.length > 0) {
|
||
|
||
$('#tab_content').empty()
|
||
count = 0
|
||
$.each(res.data.pt_co_share_details, function(index, item) {
|
||
// appendNewTab(item);
|
||
});
|
||
}
|
||
|
||
} else {
|
||
toastr.error(res.message, 'Error');
|
||
}
|
||
|
||
// $('#kyc_tab2').click();
|
||
// $('#kyc_tab').click();
|
||
// $('#g_drive_file_upload_sbt_btn').show()
|
||
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}
|
||
});
|
||
});
|
||
|
||
$("#client_form").submit(function(event) {
|
||
|
||
let form_type = $(this).data('id') || 0;
|
||
|
||
console.log('onsubmit event', this)
|
||
console.log('onsubmit event get data value',form_type)
|
||
console.log('client_type', $('#client_type').val());
|
||
|
||
event.preventDefault();
|
||
isClientFormSubmitting = true;
|
||
var isValid = $('#client_form').parsley().validate();
|
||
if (!isValid) {
|
||
console.log('Form is Empty', 'Warning');
|
||
return ;
|
||
}
|
||
|
||
form_action = '<?= base_url("util/createClientWithMinimalData"); ?>';
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
var client_type = $('#client_type').val() || $('#Owner_type').val();
|
||
console.log('client_type:', client_type);
|
||
|
||
//FORM Data
|
||
var formData = new FormData($('#client_form')[0]);
|
||
formData.append('client_type', client_type);
|
||
|
||
$.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');
|
||
|
||
console.log('create_Client_With_Minimal_Data', res)
|
||
|
||
if(res.status == true){
|
||
getClientAndBranchAndPolicy(res.client_id, res.branch_id);
|
||
|
||
if(form_type != 1){
|
||
|
||
setTimeout(function(){
|
||
$('#client_id').val(res.client_id).change();
|
||
setTimeout(function(){
|
||
$('#client_branch_id').val(res.branch_id).change();
|
||
}, 1000)
|
||
}, 2000)
|
||
|
||
}else{
|
||
|
||
setTimeout(function(){
|
||
$('#owner').val(res.client_id).change();
|
||
$('#owner_branch').val(res.branch_id).change();
|
||
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
|
||
}, 2000)
|
||
}
|
||
|
||
toastr.success(res.message, 'Success');
|
||
|
||
}else{
|
||
toastr.error(res.message, 'Error');
|
||
}
|
||
|
||
$('#client_form')[0].reset();
|
||
$('.close').click();
|
||
|
||
if(form_type == 1){
|
||
|
||
var myModal = new bootstrap.Modal(document.getElementById('vehicle_modal'));
|
||
myModal.show();
|
||
|
||
$('#client_form').removeAttr('data-id');
|
||
|
||
// Load form data into #vehicle_form from localStorage
|
||
setFormDataFromLocalStorage("#vehicle_form", "vehicleFormData");
|
||
}
|
||
|
||
isClientFormSubmitting = false;
|
||
},
|
||
error: function (xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}
|
||
});
|
||
});
|
||
|
||
$("#vehicle_form").submit(function(event) {
|
||
|
||
event.preventDefault();
|
||
|
||
var isValid = $('#vehicle_form').parsley().validate();
|
||
if (!isValid) {
|
||
console.log('Form is Empty', 'Warning');
|
||
return ;
|
||
}
|
||
|
||
form_action = '<?= base_url("util/createVehicleWithMinimalData"); ?>';
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
var formData = new FormData($('#vehicle_form')[0]);
|
||
|
||
$.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');
|
||
|
||
console.log('create Vehicle With Minimal Data response', res);
|
||
|
||
if(res.status == true){
|
||
getClientAndBranchAndPolicy();
|
||
$('#client_type').val(res.owner_type);
|
||
setTimeout(function(){
|
||
appendVehicles(res.vehicles, res.vehicle_id);
|
||
$('#client_id').val(res.owner_id).change();
|
||
if(res.owner_type == 1){
|
||
|
||
$('.branchdiv').show()
|
||
$('#client_branch_id').prop('required', true);
|
||
|
||
setTimeout(function(){
|
||
$('#client_branch_id').val(res.owner_branch_id).change();
|
||
}, 1000)
|
||
}else{
|
||
$('.branchdiv').hide()
|
||
$('#client_branch_id').prop('required', false);
|
||
}
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}, 2000)
|
||
toastr.success(res.message, 'Success');
|
||
}else{
|
||
toastr.error(res.message, 'Error');
|
||
}
|
||
|
||
$('#vehicle_form')[0].reset();
|
||
$('.close').click();
|
||
},
|
||
error: function (xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}
|
||
});
|
||
});
|
||
|
||
$("#CDMasterForm").submit(function(event) {
|
||
|
||
event.preventDefault();
|
||
|
||
var isValid = $('#CDMasterForm').parsley().validate();
|
||
if (!isValid) {
|
||
console.log('Form is Empty', 'Warning');
|
||
return ;
|
||
}
|
||
|
||
form_action = '<?= base_url("util/createCDAccountNumberUsingAjax"); ?>';
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
var unique_id = $('#premium_details_unique_id').val();
|
||
var client_id = $('#client_id').val();
|
||
var insurer_id = $('#follow_insurer_id_'+unique_id).find('option:selected').attr('data-id');
|
||
|
||
|
||
console.log('unique_id', unique_id);
|
||
console.log('client_id', client_id);
|
||
console.log('insurer_id', insurer_id);
|
||
|
||
var formData = new FormData($('#CDMasterForm')[0]);
|
||
formData.append('client_id', client_id);
|
||
formData.append('insurer_id', insurer_id);console.log(formData);
|
||
|
||
$.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){
|
||
appendCDAccountNumber(res.data, unique_id, res.cd_ac_no)
|
||
$('#cd_ac_no').val(res.id)
|
||
toastr.success(res.message, 'Success');
|
||
}else{
|
||
toastr.error(res.message, 'Error');
|
||
}
|
||
|
||
$('#CDMasterForm')[0].reset();
|
||
$('.close').click();
|
||
},
|
||
error: function (xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}
|
||
});
|
||
});
|
||
|
||
//-----------------------------------------------------------------------------------------------------------
|
||
|
||
$('#cop_yes').change(function() {
|
||
|
||
if ($(this).is(':checked')) {
|
||
$('#add_more_row').removeClass('d-none');
|
||
$('.payby').removeClass('d-none');
|
||
$('#table_tr_2').show()
|
||
$('#table_tr_3').show()
|
||
$('#table_tr_7').show()
|
||
$('#table_tr_35').show()
|
||
|
||
$('input[name="co_share_per[]"], input[name="co_premium[]"]').each(function () {
|
||
$(this).val(''); // Clear value
|
||
console.log('Input cleared:', $(this).attr('name')); // Log cleared input
|
||
});
|
||
|
||
} else {
|
||
$('#add_more_row').addClass('d-none');
|
||
$('.payby').addClass('d-none');
|
||
// $('#bro_payable_by').prop('checked', false);
|
||
$('#table_tr_2').hide()
|
||
$('#table_tr_3').hide()
|
||
$('#table_tr_7').hide()
|
||
$('#table_tr_35').hide()
|
||
|
||
$('input[name="co_share_per[]"], input[name="co_premium[]"]').each(function () {
|
||
$(this).val(''); // Clear value
|
||
console.log('Input cleared:', $(this).attr('name')); // Log cleared input
|
||
});
|
||
}
|
||
});
|
||
|
||
$('#client_type').change(function() {
|
||
|
||
if ($(this).val() == 2) {
|
||
if($('#policy_type_id').val() == 8){
|
||
$('#policyholdernamediv').hide();
|
||
}else{
|
||
$('#policyholdernamediv').show();
|
||
}
|
||
} else {
|
||
$('#policyholdernamediv').hide();
|
||
}
|
||
|
||
if ($(this).val() == 2) {
|
||
|
||
$('.branchdiv').hide();
|
||
$('.clienttypediv').show();
|
||
$('#entity_type_id_for_client').prop('required', false);
|
||
$('#branch_name').prop('required', false);
|
||
$('#client_branch_id').prop('required', false);
|
||
$('#branch_code').prop('required', false);
|
||
$('#name').prop('required', false);
|
||
$('#mobile').prop('required', false);
|
||
$('#gst').prop('required', false);
|
||
|
||
$('#dob').prop('required', true);
|
||
$('#phone').prop('required', true);
|
||
$('#email').prop('required', true);
|
||
$('#aadhar').prop('required', true);
|
||
|
||
$('#owner_branch').prop('required', false);
|
||
|
||
$('#table_tr_34').hide();
|
||
|
||
} else {
|
||
$('.branchdiv').show();
|
||
$('.clienttypediv').hide();
|
||
$('#entity_type_id_for_client').prop('required', true);
|
||
$('#branch_name').prop('required', true);
|
||
$('#client_branch_id').prop('required', true);
|
||
$('#branch_code').prop('required', true);
|
||
$('#name').prop('required', true);
|
||
$('#mobile').prop('required', true);
|
||
$('#gst').prop('required', true);
|
||
|
||
$('#dob').prop('required', false);
|
||
$('#phone').prop('required', false);
|
||
$('#email').prop('required', false);
|
||
$('#aadhar').prop('required', false);
|
||
|
||
$('#owner_branch').prop('required', true);
|
||
|
||
$('#table_tr_34').show();
|
||
|
||
}
|
||
});
|
||
|
||
$('#same_as_proposer').change(function() {
|
||
var client_type = $('#client_type').val()
|
||
var policy_type = $('#policy_type_id').val()
|
||
if ($(this).is(':checked')) {
|
||
$('#dynamic-form-container-for-insured').empty();
|
||
$('#family_details').hide();
|
||
} else {
|
||
if(client_type == 2 && policy_type != 8){
|
||
$('#family_details').show();
|
||
appendInsured()
|
||
}else{
|
||
$('#dynamic-form-container-for-insured').empty();
|
||
$('#family_details').hide();
|
||
}
|
||
}
|
||
});
|
||
|
||
$('#client_type').on('change', function() {
|
||
var selectedClientType = $(this).val();
|
||
|
||
// console.log('selectedClientType', selectedClientType);
|
||
|
||
// Clear and add default options for client
|
||
$('#client_id').empty().append($('<option>', {
|
||
value: '',
|
||
text: 'Select Client'
|
||
})).append($('<option>', {
|
||
value: 'add_client',
|
||
text: '+ Add Client'
|
||
}));
|
||
|
||
// Populate client options based on selected client type
|
||
if (selectedClientType) {
|
||
|
||
$.each(client_list, function(index, item) {
|
||
if (item.client_type == selectedClientType) {
|
||
var option = $('<option>', {
|
||
value: item.id,
|
||
text: item.client_name,
|
||
'data-cn': item.client_name,
|
||
'data-ct': item.client_type
|
||
});
|
||
$('#client_id').append(option);
|
||
}
|
||
});
|
||
|
||
}
|
||
|
||
// Initialize or refresh Select2 for both dropdowns
|
||
$('#client_id').select2();
|
||
});
|
||
|
||
$('#Owner_type').on('change', function() {
|
||
|
||
var selectedClientType = $(this).val();
|
||
|
||
$('#client_type').val(selectedClientType).change();
|
||
|
||
if ($(this).val() == 2) {
|
||
$('.ownerbranchdiv').hide();
|
||
$('#owner_branch').prop('required', false);
|
||
} else {
|
||
$('.ownerbranchdiv').show();
|
||
$('#owner_branch').prop('required', true);
|
||
}
|
||
|
||
// console.log('selected Owner type', selectedClientType);
|
||
|
||
// Clear and add default options for vehicle
|
||
$('#owner').empty().append($('<option>', {
|
||
value: '',
|
||
text: 'Select Owner'
|
||
}))
|
||
|
||
$('#owner').append(
|
||
$('<option>', {
|
||
value: 'add_client',
|
||
text: ' + Add Owner',
|
||
})
|
||
);
|
||
|
||
// Populate client options based on selected client type
|
||
if (selectedClientType) {
|
||
// Populate vehicle options based on selected client type
|
||
$.each(client_list, function(index, owner) {
|
||
|
||
if (owner.client_type == selectedClientType) {
|
||
|
||
if(selectedClientType == '2'){
|
||
|
||
var option = $('<option>', {
|
||
value: owner.id,
|
||
text: (owner.client_name + ' - ' + (owner.pan ?? ''))
|
||
});
|
||
|
||
$('#owner').append(option);
|
||
|
||
}else{
|
||
|
||
var option = $('<option>', {
|
||
value: owner.id,
|
||
text: owner.client_name,
|
||
});
|
||
$('#owner').append(option);
|
||
|
||
}
|
||
|
||
}
|
||
});
|
||
}
|
||
|
||
// Initialize or refresh Select2 for both dropdowns
|
||
$('#owner').select2();
|
||
});
|
||
|
||
$('#policy_status').change(function(){
|
||
|
||
var pt_id = $('#policy_tranction_primarykey').val();
|
||
var status = $(this).val()
|
||
var policy_type_id = $('#policy_type_id').val()
|
||
var client_id = $('#client_id').val();
|
||
var client_branch_id = $('#client_branch_id').val();
|
||
|
||
if(status == 'completed'){
|
||
if(pt_id == ''){
|
||
removeAllColumnsExceptFirst('insurerTable');
|
||
}
|
||
addInsurerColumn() ;
|
||
$('#sales_row').show();
|
||
$('#policy_no').prop('required', true);
|
||
$('#policy_issue_date').prop('required', true);
|
||
$('#policy_start_date').prop('required', true);
|
||
$('#policy_end_date').prop('required', true);
|
||
// $('#tpa').prop('required', true);
|
||
// $('#emp_count').prop('required', true);
|
||
// $('#dependent_count').prop('required', true);
|
||
$('.follow_insurer').prop('required', true);
|
||
|
||
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/base_policy_for_policy_inception/') ?>' + client_id + '/' + client_branch_id;
|
||
$.get(url_for_get_policy_type_list, function(response){
|
||
console.log('base_policy_for_policy_inception response', response)
|
||
appendBasePolicyList(response.data);
|
||
}).fail(function(xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
});
|
||
}
|
||
|
||
}else{
|
||
$('#sales_row').hide()
|
||
$('#policy_no').prop('required', false)
|
||
$('#policy_issue_date').prop('required', false)
|
||
$('#policy_start_date').prop('required', false)
|
||
$('#policy_end_date').prop('required', false)
|
||
// $('#tpa').prop('required', false)
|
||
// $('#emp_count').prop('required', false)
|
||
// $('#dependent_count').prop('required', false)
|
||
$('.follow_insurer').prop('required', false)
|
||
|
||
}
|
||
|
||
});
|
||
|
||
$('#policy_no').change(function(){
|
||
|
||
var policy_no = $(this).val();
|
||
policy_no = policy_no.trim();
|
||
|
||
$pt_id = $('#policy_tranction_policy_number').val();
|
||
console.log('$pt_id', $pt_id);
|
||
|
||
if($pt_id == "" && policy_no != ""){
|
||
$.ajax({
|
||
url: '<?php echo base_url('util/get_client_policy_data_using_policy_no/');?>'+policy_no,
|
||
type: "GET",
|
||
dataType: 'json',
|
||
success: function (res) {
|
||
|
||
console.log('get_client_policy_data_using_policy_no response', res)
|
||
|
||
if(res.status == true){
|
||
$('#ct_type').val(1);
|
||
$('#client_policy_id').val(res.data.client_policy_id);
|
||
$('#policy_start_date').val(res.data.policy_start_date);
|
||
$('#policy_end_date').val(res.data.policy_end_date);
|
||
$('#tpa').val(res.data.tpa_branch_id+'-'+res.data.tpa_id).select2();
|
||
}else{
|
||
$('#ct_type').val(2);
|
||
$('#client_policy_id').val();
|
||
$('#policy_start_date').val();
|
||
$('#policy_end_date').val();
|
||
$('#tpa').val('').select2();
|
||
console.log(res.message, 'warning');
|
||
}
|
||
},
|
||
error: function (xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
}
|
||
});
|
||
}else{
|
||
|
||
$('#ct_type').val(2)
|
||
$('#client_policy_id').val();
|
||
$('#policy_start_date').val();
|
||
$('#policy_end_date').val();
|
||
$('#tpa').val('').select2();
|
||
console.log("Could not get policy data")
|
||
}
|
||
});
|
||
|
||
// $('.follow_insurer_cd').on('change', function(){
|
||
|
||
// const selectedValue = $(this).val();
|
||
// const unique_id = $(this).data('count');
|
||
// let leader = $('#co_share_type_' + unique_id).is(':checked');
|
||
|
||
// console.log('leader', leader);
|
||
// console.log('selectedValue', selectedValue);
|
||
// console.log('unique_id', unique_id);
|
||
|
||
// if (!leader) {
|
||
// $(this).val('');
|
||
// toastr.warning('Please select the Leader.', 'Warning!');
|
||
// }
|
||
// });
|
||
|
||
$('.close').on('click', function(){
|
||
$('#client_form')[0].reset();
|
||
$('#vehicle_form')[0].reset();
|
||
$('#CDMasterForm')[0].reset();
|
||
});
|
||
|
||
//------------------------------------------------------------------------------------------------------------
|
||
|
||
var insurerCount = 0;
|
||
|
||
$('#setInsurerCount').on('click', function() {
|
||
|
||
// var count = parseInt($('#setInsurerCount').val()) || 1;
|
||
|
||
// count = count - 1; // Reduce the count by 1
|
||
|
||
// if (count >= 0) { // Ensure count is valid after reduction
|
||
// for (var i = 0; i < count; i++) {
|
||
addInsurerColumn(); // Ensure this function is defined properly
|
||
// }
|
||
// } else {
|
||
// toastr.warning('Please enter a valid insurer count', 'Warning');
|
||
// }
|
||
});
|
||
|
||
function addInsurerColumn() {
|
||
insurerCount++;
|
||
|
||
// hidePermiumDetailsBasedOnTheTeam()
|
||
|
||
// Update header
|
||
$('#insurerTable thead tr').append(`
|
||
<th>
|
||
Insurer ${insurerCount}
|
||
${insurerCount > 1 ? `<a data-count="${insurerCount}" class="text-danger fa fa-trash delete-insurer" style="margin-left: 135px;"></a>` : ''}
|
||
</th>
|
||
`);
|
||
|
||
// Add a new column for each data row
|
||
$('#insurerTable tbody tr').each(function(index) {
|
||
|
||
let newCell = '';
|
||
|
||
if(team_id.includes('4')){
|
||
|
||
console.log(
|
||
'################ TEAM ID 4 insurerTable '+ index + '########################'
|
||
)
|
||
|
||
switch(index) {
|
||
case 0: // Insurer selection
|
||
newCell = `<td>
|
||
<select class="form-control follow_insurer" data-count="${insurerCount}" id="follow_insurer_id_${insurerCount}" name="follow_insurer_id[]" onchange="getCDAccountNumber(this)">
|
||
<option value="" selected>Select Insurer</option>
|
||
<?php foreach ($insurer_branch as $value) { ?>
|
||
<option value="<?= $value['id'] . '-' . $value['insurer_id'] ?>" data-id="<?= $value['insurer_id'] ?>" data-bid="<?= $value['id'] ?>">
|
||
<?= $value['insurer_name'] . '-' . $value['branch_code'] ?>
|
||
</option>
|
||
<?php } ?>
|
||
</select>
|
||
</td>`;
|
||
break;
|
||
case 1: // Is Leader?
|
||
newCell = `<td>
|
||
<label class="switch" style="position: relative; top: 5px; left: 35px;">
|
||
<input data-id="${insurerCount}" id="co_share_type_${insurerCount}" type="checkbox" name="co_share_type[]" onchange="select_leader_disable_premium_amt(this, '${insurerCount}')">
|
||
<span class="slider round" style="height: 27px;"></span>
|
||
</label>
|
||
<label for="inception_type" style="position: relative; top: 5px; left: 40px;">Leader Yes</label>
|
||
</td>`;
|
||
break;
|
||
case 2: // CD Account Number selectionclass="std_tp_td"
|
||
newCell = `<td>
|
||
<select class="form-control follow_insurer_cd" data-count="${insurerCount}" id="cd_ac_no_${insurerCount}" name="cd_ac_no_for_child[]" onchange="addCDAccountNumber(this); restrictCDACNO(this)">
|
||
<option value="" selected>Select CD No</option>
|
||
<option value="add_cd"> + Add CD No</option>
|
||
</select>
|
||
</td>`;
|
||
break;
|
||
case 3: // follower policy no %
|
||
newCell = `<td class=""><input type="text" class="" id="follower_policy_no_${insurerCount}" name="follower_policy_no[]" oninput="" onchange=""></td>`;
|
||
break;
|
||
case 4: // Co-Share %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="co_share_per_${insurerCount}" name="co_share_per[]" oninput="validateRange(this); amountCalculation('${insurerCount}')" onchange="co_share_percentage_calculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 5: // Base Premium
|
||
newCell = `<td><input type="text" class="right-align-input" id="base_premium_${insurerCount}" name="base_premium[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 6: // TP Premium
|
||
newCell = `<td><input type="text" class="right-align-input" id="tp_premium_${insurerCount}" name="tp_premium[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 7: // Ter Premium
|
||
newCell = `<td><input type="text" class="right-align-input" id="ter_premium_${insurerCount}" name="ter_premium[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 8: // co Premium
|
||
newCell = `<td><input type="text" class="right-align-input" id="co_premium_${insurerCount}" name="co_premium[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 9: // CGST
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="cgst_${insurerCount}" name="cgst[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 10: // SGST
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="sgst_${insurerCount}" name="sgst[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 11: // IGST
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="igst_${insurerCount}" name="igst[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 12: // GST Amount
|
||
newCell = `<td><input type="text" class="readonly-color right-align-input" id="gst_amount_${insurerCount}" name="gst_amount[]" oninput="amountCalculation('${insurerCount}')" readonly onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 13: // Stamp Duty
|
||
newCell = `<td><input type="text" class="right-align-input" id="stamp_duty_${insurerCount}" name="stamp_duty[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 14: // Total
|
||
newCell = `<td><input type="text" class="readonly-color right-align-input" id="total_amt_${insurerCount}" name="total[]" readonly onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 15: // Agreed BP %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="agreed_bp_${insurerCount}" name="agreed_bp[]" oninput="validateRange(this); amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)" ></td>`;
|
||
break;
|
||
case 16: // Agreed TP %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="agreed_tp_${insurerCount}" name="agreed_tp[]" oninput="validateRange(this); amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 17: // Agreed Ter %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="agreed_ter_${insurerCount}" name="agreed_ter[]" oninput="validateRange(this); amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)" ></td>`;
|
||
break;
|
||
case 18: // Standard BP %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-color right-align-input" id="standard_bp_${insurerCount}" name="standard_bp[]" onkeypress="return onlyNumbers(event)" readonly></td>`;
|
||
break;
|
||
case 19: // Standard TP %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-color right-align-input" id="standard_tp_${insurerCount}" name="standard_tp[]" onkeypress="return onlyNumbers(event)" readonly ></td>`;
|
||
break;
|
||
case 20: // Standard Ter %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-color right-align-input" id="standard_tep_${insurerCount}" name="standard_ter[]" onkeypress="return onlyNumbers(event)" readonly></td>`;
|
||
break;
|
||
case 21: // Actual BP Amount
|
||
newCell = `<td><input type="text" class="right-align-input" id="actual_bp_amt_${insurerCount}" name="actual_bp_amt[]" onchange="actualAmountCalculation('${insurerCount}', 'bp_amt_for_calc')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 22: // Actual TP Amount
|
||
newCell = `<td><input type="text" class="right-align-input" id="actual_tp_amt_${insurerCount}" name="actual_tp_amt[]" onchange="actualAmountCalculation('${insurerCount}', 'tp_amt_for_calc')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 23: // Actual TEP Amount
|
||
newCell = `<td><input type="text" class="right-align-input" id="actual_tep_amt_${insurerCount}" name="actual_tep_amt[]" onchange="actualAmountCalculation('${insurerCount}', 'tep_amt_for_calc')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 24: // Actual BP %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="actual_bp_per_${insurerCount}" name="actual_bp_per[]" onchange="actualAmountCalculation('${insurerCount}', 'bp_per')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 25: // Actual TP %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="actual_tp_per_${insurerCount}" name="actual_tp_per[]" onchange="actualAmountCalculation('${insurerCount}', 'tp_per')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 26: // Actual TEP %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="actual_tep_per_${insurerCount}" name="actual_tp_per[]" onchange="actualAmountCalculation('${insurerCount}', 'tep_per')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 27: // Actual BP Brokerage Amount
|
||
newCell = `<td><input type="text" class="right-align-input" id="actual_bp_brokerage_amt_${insurerCount}" name="actual_bp_brokerage_amt[]" onchange="actualAmountCalculation('${insurerCount}', 'bp_broker_amt')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 28: // Actual TP Brokerage Amount
|
||
newCell = `<td><input type="text" class="right-align-input" id="actual_tp_brokerage_amt_${insurerCount}" name="actual_tp_brokerage_amt[]" onchange="actualAmountCalculation('${insurerCount}', 'tp_broker_amt')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 29: // Actual TEP Brokerage Amount
|
||
newCell = `<td><input type="text" class="right-align-input" id="actual_tep_brokerage_amt_${insurerCount}" name="actual_tep_brokerage_amt[]" onchange="actualAmountCalculation('${insurerCount}', 'tep_broker_amt')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 30: // Expected Amount
|
||
newCell = `<td><input type="text" class="right-align-input" id="exp_amt_${insurerCount}" name="exp_amt[]" onchange="actualAmountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 31: // Variance
|
||
newCell = `<td><input type="text" class="readonly-color right-align-input" id="variance_${insurerCount}" name="variance[]" onchange="actualAmountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)" readonly></td>`;
|
||
break;
|
||
case 32: // Reward
|
||
newCell = `<td><input type="text" class="right-align-input" id="reward_${insurerCount}" name="reward[]" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 33: // ID For Update
|
||
newCell = `<td><input type="hidden" name="co_share_id[]" id="co_share_id[]" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
|
||
}
|
||
|
||
}else if(team_id.includes('3')){
|
||
|
||
console.log(
|
||
'################ TEAM ID 3 ########################'
|
||
)
|
||
|
||
switch(index) {
|
||
case 0: // Insurer selection
|
||
newCell = `<td>
|
||
<select class="form-control follow_insurer" data-count="${insurerCount}" id="follow_insurer_id_${insurerCount}" name="follow_insurer_id[]" onchange="getCDAccountNumber(this)">
|
||
<option value="" selected>Select Insurer</option>
|
||
<?php foreach ($insurer_branch as $value) { ?>
|
||
<option value="<?= $value['id'] . '-' . $value['insurer_id'] ?>" data-id="<?= $value['insurer_id'] ?>" data-bid="<?= $value['id'] ?>">
|
||
<?= $value['insurer_name'] . '-' . $value['branch_code'] ?>
|
||
</option>
|
||
<?php } ?>
|
||
</select>
|
||
</td>`;
|
||
break;
|
||
case 1: // Is Leader?
|
||
newCell = `<td>
|
||
<label class="switch" style="position: relative; top: 5px; left: 35px;">
|
||
<input data-id="${insurerCount}" id="co_share_type_${insurerCount}" type="checkbox" name="co_share_type[]" onchange="select_leader_disable_premium_amt(this, '${insurerCount}')">
|
||
<span class="slider round" style="height: 27px;"></span>
|
||
</label>
|
||
<label for="inception_type" style="position: relative; top: 5px; left: 40px;">Leader Yes</label>
|
||
</td>`;
|
||
break;
|
||
case 2: // CD Account Number selectionclass="std_tp_td"
|
||
newCell = `<td>
|
||
<select class="form-control follow_insurer_cd" data-count="${insurerCount}" id="cd_ac_no_${insurerCount}" name="cd_ac_no_for_child[]" onchange="addCDAccountNumber(this); restrictCDACNO(this)">
|
||
<option value="" selected>Select CD No</option>
|
||
<option value="add_cd"> + Add CD No</option>
|
||
</select>
|
||
</td>`;
|
||
break;
|
||
case 3: // follower policy no %
|
||
newCell = `<td class=""><input type="text" class="" id="follower_policy_no_${insurerCount}" name="follower_policy_no[]" oninput="" onchange=""></td>`;
|
||
break;
|
||
case 4: // Co-Share %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="co_share_per_${insurerCount}" name="co_share_per[]" oninput="validateRange(this); amountCalculation('${insurerCount}')" onchange="co_share_percentage_calculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 5: // Base Premium
|
||
newCell = `<td><input type="text" class="right-align-input" id="base_premium_${insurerCount}" name="base_premium[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 6: // TP Premium
|
||
newCell = `<td><input type="text" class="right-align-input" id="tp_premium_${insurerCount}" name="tp_premium[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 7: // Ter Premium
|
||
newCell = `<td><input type="text" class="right-align-input" id="ter_premium_${insurerCount}" name="ter_premium[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 8: // co Premium
|
||
newCell = `<td><input type="text" class="right-align-input" id="co_premium_${insurerCount}" name="co_premium[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 9: // CGST
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="cgst_${insurerCount}" name="cgst[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 10: // SGST
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="sgst_${insurerCount}" name="sgst[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 11: // IGST
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="igst_${insurerCount}" name="igst[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 12: // GST Amount
|
||
newCell = `<td><input type="text" class="readonly-color right-align-input" id="gst_amount_${insurerCount}" name="gst_amount[]" oninput="amountCalculation('${insurerCount}')" readonly onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 13: // Stamp Duty
|
||
newCell = `<td><input type="text" class="right-align-input" id="stamp_duty_${insurerCount}" name="stamp_duty[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 14: // Total
|
||
newCell = `<td><input type="text" class="readonly-color right-align-input" id="total_amt_${insurerCount}" name="total[]" readonly onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 15: // Agreed BP %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="agreed_bp_${insurerCount}" name="agreed_bp[]" oninput="validateRange(this); amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)" ></td>`;
|
||
break;
|
||
case 16: // Agreed TP %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="agreed_tp_${insurerCount}" name="agreed_tp[]" oninput="validateRange(this); amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 17: // Agreed Ter %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="agreed_ter_${insurerCount}" name="agreed_ter[]" oninput="validateRange(this); amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)" ></td>`;
|
||
break;
|
||
case 18: // Standard BP %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-color right-align-input" id="standard_bp_${insurerCount}" name="standard_bp[]" onkeypress="return onlyNumbers(event)" readonly></td>`;
|
||
break;
|
||
case 19: // Standard TP %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-color right-align-input" id="standard_tp_${insurerCount}" name="standard_tp[]" onkeypress="return onlyNumbers(event)" readonly ></td>`;
|
||
break;
|
||
case 20: // Standard Ter %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-color right-align-input" id="standard_tep_${insurerCount}" name="standard_ter[]" onkeypress="return onlyNumbers(event)" readonly></td>`;
|
||
break;
|
||
|
||
case 21: // ID For Update
|
||
newCell = `<td><input type="hidden" name="co_share_id[]" id="co_share_id[]" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
}
|
||
|
||
}else if(team_id.includes('6')){
|
||
|
||
console.log(
|
||
'################ TEAM ID 6 ########################'
|
||
)
|
||
|
||
switch(index) {
|
||
case 0: // Insurer selection
|
||
newCell = `<td>
|
||
<select class="form-control follow_insurer" data-count="${insurerCount}" id="follow_insurer_id_${insurerCount}" name="follow_insurer_id[]" onchange="getCDAccountNumber(this)">
|
||
<option value="" selected>Select Insurer</option>
|
||
<?php foreach ($insurer_branch as $value) { ?>
|
||
<option value="<?= $value['id'] . '-' . $value['insurer_id'] ?>" data-id="<?= $value['insurer_id'] ?>" data-bid="<?= $value['id'] ?>">
|
||
<?= $value['insurer_name'] . '-' . $value['branch_code'] ?>
|
||
</option>
|
||
<?php } ?>
|
||
</select>
|
||
</td>`;
|
||
break;
|
||
case 1: // Is Leader?
|
||
newCell = `<td>
|
||
<label class="switch" style="position: relative; top: 5px; left: 35px;">
|
||
<input data-id="${insurerCount}" id="co_share_type_${insurerCount}" type="checkbox" name="co_share_type[]" onchange="select_leader_disable_premium_amt(this, '${insurerCount}')">
|
||
<span class="slider round" style="height: 27px;"></span>
|
||
</label>
|
||
<label for="inception_type" style="position: relative; top: 5px; left: 40px;">Leader Yes</label>
|
||
</td>`;
|
||
break;
|
||
case 2: // CD Account Number selectionclass="std_tp_td"
|
||
newCell = `<td>
|
||
<select class="form-control follow_insurer_cd" data-count="${insurerCount}" id="cd_ac_no_${insurerCount}" name="cd_ac_no_for_child[]" onchange="addCDAccountNumber(this); restrictCDACNO(this);">
|
||
<option value="" selected>Select CD No</option>
|
||
<option value="add_cd"> + Add CD No</option>
|
||
</select>
|
||
</td>`;
|
||
break;
|
||
case 3: // follower policy no %
|
||
newCell = `<td class=""><input type="text" class="" id="follower_policy_no_${insurerCount}" name="follower_policy_no[]" onchange="validateInput(this, 'client_policy', 'policy_no')"></td>`;
|
||
break;
|
||
case 4: // Co-Share %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="co_share_per_${insurerCount}" name="co_share_per[]" oninput="validateRange(this); amountCalculation('${insurerCount}')" onchange="co_share_percentage_calculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 5: // Base Premium
|
||
newCell = `<td><input type="text" class="right-align-input" id="base_premium_${insurerCount}" name="base_premium[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)" onchange="checkCDAmountForBasePremium(this);"></td>`;
|
||
break;
|
||
case 6: // TP Premium
|
||
newCell = `<td><input type="text" class="right-align-input" id="tp_premium_${insurerCount}" name="tp_premium[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 7: // Ter Premium
|
||
newCell = `<td><input type="text" class="right-align-input" id="ter_premium_${insurerCount}" name="ter_premium[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 8: // co Premium
|
||
newCell = `<td><input type="text" class="right-align-input" id="co_premium_${insurerCount}" name="co_premium[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 9: // CGST
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="cgst_${insurerCount}" name="cgst[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 10: // SGST
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="sgst_${insurerCount}" name="sgst[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 11: // IGST
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="igst_${insurerCount}" name="igst[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 12: // GST Amount
|
||
newCell = `<td><input type="text" class="readonly-color right-align-input" id="gst_amount_${insurerCount}" name="gst_amount[]" oninput="amountCalculation('${insurerCount}')" readonly onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 13: // Stamp Duty
|
||
newCell = `<td><input type="text" class="right-align-input" id="stamp_duty_${insurerCount}" name="stamp_duty[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 14: // Total
|
||
newCell = `<td><input type="text" class="readonly-color right-align-input" id="total_amt_${insurerCount}" name="total[]" readonly onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 15: // Agreed BP %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="agreed_bp_${insurerCount}" name="agreed_bp[]" oninput="validateRange(this); amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)" ></td>`;
|
||
break;
|
||
case 16: // Agreed TP %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="agreed_tp_${insurerCount}" name="agreed_tp[]" oninput="validateRange(this); amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 17: // Agreed Ter %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="agreed_ter_${insurerCount}" name="agreed_ter[]" oninput="validateRange(this); amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)" ></td>`;
|
||
break;
|
||
case 18: // Agreed Amount
|
||
newCell = `<td><input type="text" class="right-align-input" id="agreed_amount_${insurerCount}" name="agreed_amount[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 19: // Standard BP %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-color right-align-input" id="standard_bp_${insurerCount}" name="standard_bp[]" onkeypress="return onlyNumbers(event)" readonly></td>`;
|
||
break;
|
||
case 20: // Standard TP %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-color right-align-input" id="standard_tp_${insurerCount}" name="standard_tp[]" onkeypress="return onlyNumbers(event)" readonly ></td>`;
|
||
break;
|
||
case 21: // Standard Ter %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-color right-align-input" id="standard_tep_${insurerCount}" name="standard_ter[]" onkeypress="return onlyNumbers(event)" readonly></td>`;
|
||
break;
|
||
case 22: // Actual BP Amount
|
||
newCell = `<td><input type="text" class="right-align-input" id="actual_bp_amt_${insurerCount}" name="actual_bp_amt[]" onchange="actualAmountCalculation('${insurerCount}', 'bp_amt_for_calc')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 23: // Actual TP Amount
|
||
newCell = `<td><input type="text" class="right-align-input" id="actual_tp_amt_${insurerCount}" name="actual_tp_amt[]" onchange="actualAmountCalculation('${insurerCount}', 'tp_amt_for_calc')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 24: // Actual TEP Amount
|
||
newCell = `<td><input type="text" class="right-align-input" id="actual_tep_amt_${insurerCount}" name="actual_tep_amt[]" onchange="actualAmountCalculation('${insurerCount}', 'tep_amt_for_calc')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 25: // Actual BP %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="actual_bp_per_${insurerCount}" name="actual_bp_per[]" onchange="actualAmountCalculation('${insurerCount}', 'bp_per')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 26: // Actual TP %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="actual_tp_per_${insurerCount}" name="actual_tp_per[]" onchange="actualAmountCalculation('${insurerCount}', 'tp_per')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 27: // Actual TEP %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="actual_tep_per_${insurerCount}" name="actual_tp_per[]" onchange="actualAmountCalculation('${insurerCount}', 'tep_per')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 28: // Actual BP Brokerage Amount
|
||
newCell = `<td><input type="text" class="right-align-input" id="actual_bp_brokerage_amt_${insurerCount}" name="actual_bp_brokerage_amt[]" onchange="actualAmountCalculation('${insurerCount}', 'bp_broker_amt')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 29: // Actual TP Brokerage Amount
|
||
newCell = `<td><input type="text" class="right-align-input" id="actual_tp_brokerage_amt_${insurerCount}" name="actual_tp_brokerage_amt[]" onchange="actualAmountCalculation('${insurerCount}', 'tp_broker_amt')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 30: // Actual TEP Brokerage Amount
|
||
newCell = `<td><input type="text" class="right-align-input" id="actual_tep_brokerage_amt_${insurerCount}" name="actual_tep_brokerage_amt[]" onchange="actualAmountCalculation('${insurerCount}', 'tep_broker_amt')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 31: // Expected Amount
|
||
newCell = `<td><input type="text" class="right-align-input" id="exp_amt_${insurerCount}" name="exp_amt[]" onchange="actualAmountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 32: // Variance
|
||
newCell = `<td><input type="text" class="readonly-color right-align-input" id="variance_${insurerCount}" name="variance[]" onchange="actualAmountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)" readonly></td>`;
|
||
break;
|
||
case 33: // Reward
|
||
newCell = `<td><input type="text" class="right-align-input" id="reward_${insurerCount}" name="reward[]" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 34: // ID For Update
|
||
newCell = `<td><input type="hidden" name="co_share_id[]" id="co_share_id[]" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
|
||
}
|
||
}
|
||
|
||
console.log('#################################################################');
|
||
console.log(newCell);
|
||
console.log('#################################################################');
|
||
$(this).append(newCell);
|
||
|
||
$('#follow_insurer_id_' + insurerCount).select2()
|
||
|
||
var selectedOption = $('#policy_type_id').find('option:selected');
|
||
|
||
var ebp = selectedOption.data('ebp');
|
||
var etp = selectedOption.data('etp');
|
||
var etep = selectedOption.data('etep');
|
||
var iep = selectedOption.data('iep');
|
||
var itp = selectedOption.data('itp');
|
||
var itep = selectedOption.data('itep');
|
||
|
||
var bap = selectedOption.data('bap');
|
||
|
||
|
||
if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
|
||
$('.hideter').show();
|
||
$('.hidetp').hide();
|
||
}else{
|
||
if(bap == 'Motor'){
|
||
$('.hidetp').show()
|
||
$('.hideter').hide()
|
||
}else{
|
||
$('.hideter').hide()
|
||
$('.hidetp').hide()
|
||
}
|
||
}
|
||
|
||
$('[name="standard_bp[]"]').val(ebp);
|
||
$('[name="standard_tp[]"]').val(etp);
|
||
$('[name="standard_ter[]"]').val(etep);
|
||
|
||
if(insurerCount > 1){
|
||
$('.follow_insurer').prop('required', true);
|
||
}else{
|
||
$('.follow_insurer').prop('required', false);
|
||
}
|
||
|
||
});
|
||
|
||
insurer_count_array.push(insurerCount)
|
||
|
||
// Add click event for delete button
|
||
$('.delete-insurer').off('click').on('click', function() {
|
||
const index = $(this).closest('th').index();
|
||
let count_index = $(this).data('count');
|
||
removeInsurerColumn(index, count_index);
|
||
});
|
||
|
||
// hidePermiumDetailsBasedOnTheTeam()
|
||
|
||
co_share_percentage_calculation(insurerCount, "add");
|
||
|
||
}
|
||
|
||
function removeInsurerColumn(index, count_index) {
|
||
// Remove the header
|
||
$('#insurerTable thead tr th').eq(index).remove();
|
||
|
||
// Remove the corresponding data cells in each row
|
||
$('#insurerTable tbody tr').each(function() {
|
||
$(this).find('td').eq(index).remove();
|
||
});
|
||
|
||
insurer_count_array = insurer_count_array.filter(item => item !== count_index);
|
||
co_share_percentage_calculation(null, "remove");
|
||
insurerCount--;
|
||
}
|
||
|
||
function populateTable(dataArray) {
|
||
|
||
console.log('populateTable data', dataArray)
|
||
|
||
dataArray.forEach((data, index) => {
|
||
// Add a new insurer column for each entry in the data array
|
||
addInsurerColumn(); // This will add a new column dynamically
|
||
|
||
// let disable_td = disable_td ? true : false;
|
||
let disable_td = false;
|
||
if(data.record_count > 0){
|
||
disable_td = true;
|
||
}
|
||
console.log('disable_td', disable_td);
|
||
|
||
// Populate the fields with the provided data
|
||
$('#insurerTable tbody tr').each(function(rowIndex, row) {
|
||
const cell = $(row).find('td').eq(insurerCount); // Get the newly added column by `insurerCount`
|
||
|
||
let insurer = data.insurer_branch_id + '-' + data.insurer_id;
|
||
|
||
if(team_id.includes('4')){
|
||
|
||
console.log(
|
||
'################ TEAM ID 4 ########################'
|
||
)
|
||
|
||
switch (rowIndex) {
|
||
case 0: // Insurer selection
|
||
cell.find('select').val(insurer).change().toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 1: // Is Leader?
|
||
cell.find('input[type="checkbox"]').prop('checked', data.co_share_type === '1').change().toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 2: // CD Account Number selection
|
||
cell.find('select').val(data.cd_ac_no).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 3: // Co-Share %
|
||
cell.find('input').val(data.follower_policy_no).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 4: // Co-Share %
|
||
cell.find('input').val(data.co_share_per).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 5: // Base Premium
|
||
cell.find('input').val(data.bp_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 6: // TP Premium
|
||
cell.find('input').val(data.tp_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 7: // Ter Premium
|
||
cell.find('input').val(data.tep_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 8: // Co Premium
|
||
cell.find('input').val(data.cop_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 9: // CGST
|
||
cell.find('input').val(data.bp_cgst).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 10: // SGST
|
||
cell.find('input').val(data.bp_sgst).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 11: // IGST
|
||
cell.find('input').val(data.bp_igst).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 12: // GST Amount
|
||
cell.find('input').val(data.bp_gst_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 13: // Stamp Duty
|
||
cell.find('input').val(data.stamp_duty).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 14: // Total
|
||
cell.find('input').val(data.amount).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 15: // Agreed BP %
|
||
cell.find('input').val(data.agreed_bp_per).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 16: // Agreed TP %
|
||
cell.find('input').val(data.agreed_tp_per).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 17: // Agreed Ter %
|
||
cell.find('input').val(data.agreed_tep_per).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 18: // Standard BP %
|
||
cell.find('input').val(data.standerd_bp_per).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 19: // Standard TP %
|
||
cell.find('input').val(data.standerd_tp_per).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 20: // Standard Ter %
|
||
cell.find('input').val(data.standerd_tep_per).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 21: // Actual BP Amount
|
||
cell.find('input').val(data.actual_bp_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 22: // Actual TP Amount
|
||
cell.find('input').val(data.actual_tp_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 23: // Actual Ter Amount
|
||
cell.find('input').val(data.actual_tep_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 24: // Actual BP %
|
||
cell.find('input').val(data.actual_bp_per).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 25: // Actual TP %
|
||
cell.find('input').val(data.actual_tp_per).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 26: // Actual Ter %
|
||
cell.find('input').val(data.actual_tep_per).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 27: // Actual BP Brokerage Amount
|
||
cell.find('input').val(data.actual_bp_brokerage_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 28: // Actual TP Brokerage Amount
|
||
cell.find('input').val(data.actual_tp_brokerage_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 29: // Actual Ter Brokerage Amount
|
||
cell.find('input').val(data.actual_tep_brokerage_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 30: // Expected Amount
|
||
cell.find('input').val(data.exp_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 31: // Variance
|
||
cell.find('input').val(data.variance).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 32: // Reward
|
||
cell.find('input').val(data.reward).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 33: // Co-share ID (hidden field)
|
||
cell.find('input[type="hidden"]').val(data.id);
|
||
break;
|
||
}
|
||
|
||
}else if(team_id.includes('3')){
|
||
|
||
console.log(
|
||
'################ TEAM ID 3 ########################'
|
||
)
|
||
|
||
switch (rowIndex) {
|
||
case 0: // Insurer selection
|
||
cell.find('select').val(insurer).change().toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 1: // Is Leader?
|
||
cell.find('input[type="checkbox"]').prop('checked', data.co_share_type === '1').change().toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 2: // CD Account Number selection
|
||
cell.find('select').val(data.cd_ac_no).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 3: // Co-Share %
|
||
cell.find('input').val(data.follower_policy_no).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 4: // Co-Share %
|
||
cell.find('input').val(data.co_share_per).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 5: // Base Premium
|
||
cell.find('input').val(data.bp_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 6: // TP Premium
|
||
cell.find('input').val(data.tp_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 7: // Ter Premium
|
||
cell.find('input').val(data.tep_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 8: // Co Premium
|
||
cell.find('input').val(data.cop_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 9: // CGST
|
||
cell.find('input').val(data.bp_cgst).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 10: // SGST
|
||
cell.find('input').val(data.bp_sgst).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 11: // IGST
|
||
cell.find('input').val(data.bp_igst).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 12: // GST Amount
|
||
cell.find('input').val(data.bp_gst_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 13: // Stamp Duty
|
||
cell.find('input').val(data.stamp_duty).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 14: // Total
|
||
cell.find('input').val(data.amount).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 15: // Agreed BP %
|
||
cell.find('input').val(data.agreed_bp_per).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 16: // Agreed TP %
|
||
cell.find('input').val(data.agreed_tp_per).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 17: // Agreed Ter %
|
||
cell.find('input').val(data.agreed_tep_per).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 18: // Standard BP %
|
||
cell.find('input').val(data.standerd_bp_per).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 19: // Standard TP %
|
||
cell.find('input').val(data.standerd_tp_per).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 20: // Standard Ter %
|
||
cell.find('input').val(data.standerd_tep_per).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 21: // Co-share ID (hidden field)
|
||
cell.find('input[type="hidden"]').val(data.id);
|
||
break;
|
||
}
|
||
|
||
}else if(team_id.includes('6')){
|
||
|
||
console.log(
|
||
'################ TEAM ID 6 ########################'
|
||
)
|
||
|
||
switch (rowIndex) {
|
||
case 0: // Insurer selection
|
||
cell.find('select').val(insurer).change().toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 1: // Is Leader?
|
||
cell.find('input[type="checkbox"]').prop('checked', data.co_share_type === '1').change().toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 2: // CD Account Number selection
|
||
cell.find('select').val(data.cd_ac_no).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 3: // Co-Share %
|
||
cell.find('input').val(data.follower_policy_no).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 4: // Co-Share %
|
||
cell.find('input').val(data.co_share_per).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 5: // Base Premium
|
||
cell.find('input').val(data.bp_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 6: // TP Premium
|
||
cell.find('input').val(data.tp_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 7: // Ter Premium
|
||
cell.find('input').val(data.tep_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 8: // Co Premium
|
||
cell.find('input').val(data.cop_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 9: // CGST
|
||
cell.find('input').val(data.bp_cgst).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 10: // SGST
|
||
cell.find('input').val(data.bp_sgst).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 11: // IGST
|
||
cell.find('input').val(data.bp_igst).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 12: // GST Amount
|
||
cell.find('input').val(data.bp_gst_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 13: // Stamp Duty
|
||
cell.find('input').val(data.stamp_duty).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 14: // Total
|
||
cell.find('input').val(data.amount).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 15: // Agreed BP %
|
||
cell.find('input').val(data.agreed_bp_per).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 16: // Agreed TP %
|
||
cell.find('input').val(data.agreed_tp_per).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 17: // Agreed Ter %
|
||
cell.find('input').val(data.agreed_tep_per).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 18: // Agreed Amount
|
||
cell.find('input').val(data.agreed_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 19: // Standard BP %
|
||
cell.find('input').val(data.standerd_bp_per).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 20: // Standard TP %
|
||
cell.find('input').val(data.standerd_tp_per).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 21: // Standard Ter %
|
||
cell.find('input').val(data.standerd_tep_per).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 22: // Actual BP Amount
|
||
cell.find('input').val(data.actual_bp_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 23: // Actual TP Amount
|
||
cell.find('input').val(data.actual_tp_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 24: // Actual Ter Amount
|
||
cell.find('input').val(data.actual_tep_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 25: // Actual BP %
|
||
cell.find('input').val(data.actual_bp_per).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 26: // Actual TP %
|
||
cell.find('input').val(data.actual_tp_per).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 27: // Actual Ter %
|
||
cell.find('input').val(data.actual_tep_per).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 28: // Actual BP Brokerage Amount
|
||
cell.find('input').val(data.actual_bp_brokerage_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 29: // Actual TP Brokerage Amount
|
||
cell.find('input').val(data.actual_tp_brokerage_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 30: // Actual Ter Brokerage Amount
|
||
cell.find('input').val(data.actual_tep_brokerage_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 31: // Expected Amount
|
||
cell.find('input').val(data.exp_amt).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 32: // Variance
|
||
cell.find('input').val(data.variance).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 33: // Reward
|
||
cell.find('input').val(data.reward).toggleClass('readonly-select', !!disable_td);
|
||
break;
|
||
case 34: // Co-share ID (hidden field)
|
||
cell.find('input[type="hidden"]').val(data.id);
|
||
break;
|
||
}
|
||
}
|
||
});
|
||
});
|
||
|
||
// $('input:disabled, select:disabled, textarea:disabled').addClass('readonly-color');
|
||
|
||
}
|
||
|
||
//-----------------------------------------------------------------------------------------------------------
|
||
|
||
function getURLParamsForReport() {
|
||
const params = new URLSearchParams(window.location.search);
|
||
const pt_id = params.get('pt_id') ?? 0;
|
||
|
||
if (pt_id != 0) {
|
||
hide_list_show_add();
|
||
setTimeout(() =>
|
||
getPolicyTransactionDataForEdit(pt_id),
|
||
1500); // Reduced timeout
|
||
} else {
|
||
show_list_hide_add();
|
||
}
|
||
|
||
console.log('pt_id', pt_id); // Retain the log if necessary
|
||
}
|
||
|
||
function validateInput(input, table, field){
|
||
|
||
let value = $(input).val();
|
||
let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim();
|
||
|
||
let message = "Value is duplicate!";
|
||
if(label){
|
||
message = label + " already exists!";
|
||
}
|
||
|
||
checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) {
|
||
if (isDuplicate) {
|
||
toastr.warning(message, 'Warning');
|
||
$(input).val('')
|
||
}
|
||
});
|
||
|
||
}
|
||
|
||
function saveFormDataToLocalStorage(formSelector, storageKey) {
|
||
// Initialize an empty object to store form data
|
||
let formData = {};
|
||
|
||
// Iterate over all inputs in the form
|
||
$(formSelector + " :input").each(function() {
|
||
let input = $(this);
|
||
let name = input.attr("name"); // Get the input's name attribute
|
||
let value = input.val(); // Get the input's value
|
||
|
||
if (name) {
|
||
if (name !== 'owner' && name !== 'branch_id') {
|
||
formData[name] = value; // Add to the formData object if the input has a name
|
||
}
|
||
}
|
||
|
||
});
|
||
|
||
// Save the form data to local storage with the provided key
|
||
localStorage.setItem(storageKey, JSON.stringify(formData));
|
||
|
||
console.log("Form data saved to local storage:", formData);
|
||
}
|
||
|
||
function setFormDataFromLocalStorage(formSelector, storageKey) {
|
||
// Retrieve the saved form data from localStorage
|
||
let savedData = JSON.parse(localStorage.getItem(storageKey));
|
||
|
||
// If there's no saved data, do nothing
|
||
if (!savedData) return;
|
||
|
||
// Iterate through the saved data and set the form inputs accordingly
|
||
$.each(savedData, function(name, value) {
|
||
let input = $(formSelector + " :input[name='" + name + "']");
|
||
|
||
// Check if the input is a checkbox or radio button
|
||
if (input.is(':checkbox') || input.is(':radio')) {
|
||
input.prop('checked', value); // Set the checked property
|
||
} else {
|
||
input.val(value); // Set the value for other input types
|
||
}
|
||
});
|
||
|
||
console.log("Form data loaded from local storage:", savedData);
|
||
}
|
||
|
||
function checkCDAmountForBasePremium(input) {
|
||
|
||
console.log(input)
|
||
|
||
let base_premium = $(input).val();
|
||
console.log("base_premium:", base_premium);
|
||
|
||
// Extract increment value from input ID
|
||
let input_id = input.id;
|
||
console.log("input_id:", input_id);
|
||
let increment = input_id.split("_").pop();
|
||
console.log("increment:", increment);
|
||
|
||
// Get the corresponding `cd_ac_no` value
|
||
let cd_ac_no = $('#cd_ac_no_' + increment).val();
|
||
console.log("cd_ac_no:", cd_ac_no);
|
||
|
||
// Validate inputs
|
||
if (!base_premium || !cd_ac_no) {
|
||
toastr.warning('Base premium or CD account number is missing', 'Warning');
|
||
return;
|
||
}
|
||
|
||
let url = '<?= base_url('util/checkCDAmountForBasePremium') ?>';
|
||
|
||
// Data to send in the AJAX request
|
||
let requestData = {
|
||
base_premium: base_premium,
|
||
cd_ac_no: cd_ac_no
|
||
};
|
||
|
||
// Send AJAX request
|
||
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
|
||
console.log('Data fetched successfully:', response);
|
||
|
||
if (response.status) {
|
||
if (!response.base_premium_greater_than_balance) {
|
||
console.log('Base premium is less than or equal to CD balance:', 'SUCCESS');
|
||
} else {
|
||
toastr.warning('Base premium greater than CD Amount', 'Warning');
|
||
$(input).val("0")
|
||
}
|
||
} else {
|
||
toastr.error(response.message || 'Unable to fetch data', 'Error');
|
||
}
|
||
}, function(xhr, status, error) {
|
||
console.error('Error fetching data:', error);
|
||
console.error(xhr.responseText);
|
||
toastr.error('An error occurred while checking the CD amount.', 'Error');
|
||
});
|
||
}
|
||
|
||
|
||
</script>
|