3154 lines
147 KiB
PHP
3154 lines
147 KiB
PHP
<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"
|
||
onclick="//show_list_hide_add()">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">
|
||
|
||
<!-- 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" value="" type="text" class="form-control" name="ppteam">
|
||
</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">
|
||
<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">
|
||
<input type="number" id="setInsurerCount" class="form-control" placeholder="Enter count">
|
||
</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_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>
|
||
<tr id="table_tr_17">
|
||
<td>Agreed Amount</td>
|
||
</tr>
|
||
<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>
|
||
<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>
|
||
<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" aria-hidden="false">
|
||
<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">
|
||
<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">
|
||
</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)">
|
||
</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 PAN No" name="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" 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" 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>
|
||
|
||
<!-- Client form content modal-->
|
||
<div class="modal fade" id="vehicle_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="false">
|
||
<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="close_btn" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<div class="modal-body">
|
||
<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="client_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" 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" 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" aria-hidden="true">
|
||
<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>
|
||
|
||
$(document).ready(function(){
|
||
|
||
hidePermiumDetailsBasedOnTheTeam()
|
||
|
||
$('#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();
|
||
}
|
||
})
|
||
|
||
$('#owner').change(function(){
|
||
|
||
let owner_id = $(this).val();
|
||
console.log('owner_id', owner_id);
|
||
|
||
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();
|
||
}
|
||
});
|
||
|
||
})
|
||
|
||
$(document).on('change', 'input[type="checkbox"][name="co_share_type[]"]', function() {
|
||
|
||
let isAnyChecked = $('input[type="checkbox"][name="co_share_type[]"]:checked').length > 1;
|
||
|
||
var unique_id = $(this).data('count')
|
||
console.log(unique_id);
|
||
|
||
if (isAnyChecked) {
|
||
toastr.warning('Only one leader can be selected.', 'WARNING!');
|
||
$(this).prop('checked', false);
|
||
}
|
||
});
|
||
|
||
$(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);
|
||
|
||
// $('#cd_ac_no_for_edit').val(res.data.cd_ac_no);
|
||
$('#cd_ac_no').val(res.data.cd_ac_no);
|
||
|
||
// $('#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.cd_ac_no);
|
||
$('#client_branch_id').val(res.data.client_branch_id).select2();
|
||
$('#source_client_policy_id').val(res.data.source_client_policy_id).change();
|
||
$('#base_policy').val(res.data.base_policy).select2();
|
||
//console.log('---------------------------------------------------------------')
|
||
//console.log('second')
|
||
//console.log('---------------------------------------------------------------')
|
||
|
||
$('.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.cd_ac_no) {
|
||
$(this).prop('selected', true);
|
||
}
|
||
});
|
||
}, 3000)
|
||
|
||
// 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);
|
||
$('#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();
|
||
} 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();
|
||
}
|
||
|
||
// 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 amountCalculation(input) {
|
||
|
||
// console.log(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;
|
||
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;
|
||
|
||
// Calculate GST percentage
|
||
let gst_per = igst;
|
||
if (igst === 0) {
|
||
gst_per = cgst + sgst;
|
||
}
|
||
|
||
// Calculate the total premium (Base + TP + Co-Premium)
|
||
let tpTotal = bp + tp + tep + cop;
|
||
|
||
let gst_per_amt = (tpTotal * gst_per) / 100;
|
||
$('#gst_amount_' + input).val(gst_per_amt.toFixed(2));
|
||
|
||
let finalTotal = tpTotal + gst_per_amt + stamp_duty_amt;
|
||
|
||
// console.log('Summed Amount:', finalTotal);
|
||
|
||
$('#total_amt_' + input).val(finalTotal.toFixed(2));
|
||
|
||
let sum_of_agreed_premium = agreed_bp_per + agreed_tp_per + agreed_tep_per;
|
||
|
||
var expectedAmount = 0;
|
||
if(agreed_amount > 0 ){
|
||
expectedAmount = 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;
|
||
}else{
|
||
expectedAmount = ((bp + cop) * standard_bp_per)+ ((tp + tep)*(standard_tp_per + standard_tep_per));
|
||
expectedAmount = expectedAmount / 100;
|
||
}
|
||
|
||
// console.log('expectedAmount', expectedAmount);
|
||
|
||
//Expected Amount
|
||
$('#exp_amt_' + input).val(expectedAmount.toFixed(2));
|
||
|
||
let actual_bp_brokerage_amount = $('#actual_bp_brokerage_amt_' + input).val();
|
||
let actual_tp_brokerage_amount = $('#actual_tp_brokerage_amt_' + input).val();
|
||
let actual_tep_brokerage_amount = $('#actual_tep_brokerage_amt_' + input).val();
|
||
|
||
let variance = expectedAmount - (actual_bp_brokerage_amount + actual_tp_brokerage_amount + actual_tep_brokerage_amount)
|
||
|
||
$('#variance_' + input).val(variance.toFixed(2));
|
||
// 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');
|
||
|
||
|
||
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));
|
||
}
|
||
} 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));
|
||
}
|
||
} else if (field === 'bp_amt_for_calc') {
|
||
|
||
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));
|
||
}
|
||
|
||
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));
|
||
}
|
||
}
|
||
|
||
//-----------------------------------------------------------------------------------------
|
||
|
||
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));
|
||
}
|
||
} 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));
|
||
}
|
||
} else if (field === 'tp_amt_for_calc') {
|
||
|
||
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));
|
||
}
|
||
|
||
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));
|
||
}
|
||
}
|
||
|
||
}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));
|
||
}
|
||
} 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));
|
||
}
|
||
} else if (field === 'tep_amt_for_calc') {
|
||
|
||
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));
|
||
}
|
||
|
||
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));
|
||
}
|
||
}
|
||
|
||
}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)
|
||
|
||
$('#variance_' + input).val(variance.toFixed(2));
|
||
|
||
// console.log('expectedAmount', expectedAmount);
|
||
// console.log('variance', variance);
|
||
}
|
||
|
||
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'
|
||
}));
|
||
|
||
$.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('getCDAccountNumber')
|
||
|
||
// 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);
|
||
|
||
|
||
// console.log('client_id', client_id);
|
||
// console.log('insurer_id', insurer_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{
|
||
toastr.warning('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 Policy',
|
||
}));
|
||
$('#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);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
}
|
||
|
||
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.cd_ac_no,
|
||
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()
|
||
}
|
||
}
|
||
|
||
//---------------------------------------------------------------------------------------------------------
|
||
|
||
|
||
$("#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]);
|
||
|
||
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);
|
||
});
|
||
|
||
$.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) {
|
||
|
||
event.preventDefault();
|
||
|
||
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();
|
||
|
||
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);
|
||
setTimeout(function(){
|
||
$('#client_id').val(res.client_id).change();
|
||
setTimeout(function(){
|
||
$('#client_branch_id').val(res.branch_id).change();
|
||
}, 1000)
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}, 2000)
|
||
toastr.success(res.message, 'Success');
|
||
}else{
|
||
toastr.error(res.message, 'Error');
|
||
}
|
||
|
||
$('.close').click();
|
||
},
|
||
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');
|
||
}
|
||
|
||
$('.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);
|
||
|
||
$.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.cd_ac_no)
|
||
toastr.success(res.message, 'Success');
|
||
}else{
|
||
toastr.error(res.message, 'Error');
|
||
}
|
||
|
||
$('.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()
|
||
} 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()
|
||
}
|
||
});
|
||
|
||
$('#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').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').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();
|
||
|
||
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'
|
||
}))
|
||
|
||
// 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) {
|
||
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 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'){
|
||
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/get_policy_type_for_base_policy/') ?>' + client_id + '/' + client_branch_id;
|
||
$.get(url_for_get_policy_type_list, function(response){
|
||
console.log('get_policy_type_for_base_policy 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();
|
||
// console.log(policy_no +'-'+policy_no.length);
|
||
policy_no = policy_no.trim();
|
||
// console.log(policy_no +'-'+policy_no.length);
|
||
|
||
|
||
$.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).trigger('change');
|
||
}else{
|
||
$('#ct_type').val(2)
|
||
$('#client_policy_id').val();
|
||
$('#policy_start_date').val();
|
||
$('#policy_end_date').val();
|
||
$('#tpa').val().trigger('change');
|
||
console.log(res.message, 'warning');
|
||
}
|
||
},
|
||
error: function (xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
}
|
||
});
|
||
|
||
});
|
||
|
||
// $('.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!');
|
||
// }
|
||
// });
|
||
|
||
//------------------------------------------------------------------------------------------------------------
|
||
|
||
var insurerCount = 0;
|
||
|
||
$('#setInsurerCount').on('input', function() {
|
||
var count = $('#setInsurerCount').val();
|
||
|
||
if (count) {
|
||
for (var i = 0; i < count; i++) { // Corrected loop condition
|
||
addInsurerColumn();
|
||
}
|
||
} else {
|
||
toastr.warning('Please enter the insurer count', 'WARNING');
|
||
}
|
||
});
|
||
|
||
function addInsurerColumn() {
|
||
insurerCount++;
|
||
|
||
hidePermiumDetailsBasedOnTheTeam()
|
||
|
||
// Update header
|
||
$('#insurerTable thead tr').append(`
|
||
<th>
|
||
Insurer ${insurerCount}
|
||
${insurerCount > 1 ? `<a 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 = '';
|
||
|
||
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[]">
|
||
<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: // Co-Share %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" name="co_share_per[]" oninput="validateRange(this)" onkeypress="return onlyNumbers(event)"></td>`;
|
||
break;
|
||
case 4: // 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 5: // 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 6: // 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 7: // 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 8: // 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 9: // 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 10: // 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 11: // 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 12: // 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 13: // 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 14: // 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 15: // 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 16: // 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 17: // 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 18: // Standard BP %
|
||
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-color right-align-input" 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" 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" 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;
|
||
|
||
}
|
||
|
||
$(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);
|
||
}
|
||
|
||
});
|
||
|
||
// Add click event for delete button
|
||
$('.delete-insurer').off('click').on('click', function() {
|
||
const index = $(this).closest('th').index();
|
||
removeInsurerColumn(index);
|
||
});
|
||
|
||
// hidePermiumDetailsBasedOnTheTeam()
|
||
|
||
|
||
}
|
||
|
||
function removeInsurerColumn(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();
|
||
});
|
||
|
||
insurerCount--;
|
||
}
|
||
|
||
function populateTable(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
|
||
|
||
// 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;
|
||
|
||
switch (rowIndex) {
|
||
case 0: // Insurer selection
|
||
cell.find('select').val(insurer).change();
|
||
break;
|
||
case 1: // Is Leader?
|
||
cell.find('input[type="checkbox"]').prop('checked', data.co_share_type === '1');
|
||
break;
|
||
case 2: // CD Account Number selection
|
||
cell.find('select').val(data.cd_ac_no);
|
||
break;
|
||
case 3: // Co-Share %
|
||
cell.find('input').val(data.co_share_per);
|
||
break;
|
||
case 4: // Base Premium
|
||
cell.find('input').val(data.bp_amt);
|
||
break;
|
||
case 5: // TP Premium
|
||
cell.find('input').val(data.tp_amt);
|
||
break;
|
||
case 6: // Ter Premium
|
||
cell.find('input').val(data.tep_amt);
|
||
break;
|
||
case 7: // Co Premium
|
||
cell.find('input').val(data.cop_amt);
|
||
break;
|
||
case 8: // CGST
|
||
cell.find('input').val(data.bp_cgst);
|
||
break;
|
||
case 9: // SGST
|
||
cell.find('input').val(data.bp_sgst);
|
||
break;
|
||
case 10: // IGST
|
||
cell.find('input').val(data.bp_igst);
|
||
break;
|
||
case 11: // GST Amount
|
||
cell.find('input').val(data.bp_gst_amt);
|
||
break;
|
||
case 12: // Stamp Duty
|
||
cell.find('input').val(data.stamp_duty);
|
||
break;
|
||
case 13: // Total
|
||
cell.find('input').val(data.amount);
|
||
break;
|
||
case 14: // Agreed BP %
|
||
cell.find('input').val(data.agreed_bp_per);
|
||
break;
|
||
case 15: // Agreed TP %
|
||
cell.find('input').val(data.agreed_tp_per);
|
||
break;
|
||
case 16: // Agreed Ter %
|
||
cell.find('input').val(data.agreed_tep_per);
|
||
break;
|
||
case 17: // Agreed Amount
|
||
cell.find('input').val(data.agreed_amt);
|
||
break;
|
||
case 18: // Standard BP %
|
||
cell.find('input').val(data.standerd_bp_per);
|
||
break;
|
||
case 19: // Standard TP %
|
||
cell.find('input').val(data.standerd_tp_per);
|
||
break;
|
||
case 20: // Standard Ter %
|
||
cell.find('input').val(data.standerd_tep_per);
|
||
break;
|
||
case 21: // Actual BP Amount
|
||
cell.find('input').val(data.actual_bp_amt);
|
||
break;
|
||
case 22: // Actual TP Amount
|
||
cell.find('input').val(data.actual_tp_amt);
|
||
break;
|
||
case 23: // Actual Ter Amount
|
||
cell.find('input').val(data.actual_tep_amt);
|
||
break;
|
||
case 24: // Actual BP %
|
||
cell.find('input').val(data.actual_bp_per);
|
||
break;
|
||
case 25: // Actual TP %
|
||
cell.find('input').val(data.actual_tp_per);
|
||
break;
|
||
case 26: // Actual Ter %
|
||
cell.find('input').val(data.actual_tep_per);
|
||
break;
|
||
case 27: // Actual BP Brokerage Amount
|
||
cell.find('input').val(data.actual_bp_brokerage_amt);
|
||
break;
|
||
case 28: // Actual TP Brokerage Amount
|
||
cell.find('input').val(data.actual_tp_brokerage_amt);
|
||
break;
|
||
case 29: // Actual Ter Brokerage Amount
|
||
cell.find('input').val(data.actual_tep_brokerage_amt);
|
||
break;
|
||
case 30: // Expected Amount
|
||
cell.find('input').val(data.exp_amt);
|
||
break;
|
||
case 31: // Variance
|
||
cell.find('input').val(data.variance);
|
||
break;
|
||
case 32: // Reward
|
||
cell.find('input').val(data.reward);
|
||
break;
|
||
case 33: // Co-share ID (hidden field)
|
||
cell.find('input[type="hidden"]').val(data.id);
|
||
break;
|
||
}
|
||
});
|
||
});
|
||
}
|
||
|
||
//-----------------------------------------------------------------------------------------------------------
|
||
|
||
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
|
||
}
|
||
|
||
</script>
|