3037 lines
149 KiB
PHP
3037 lines
149 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%;
|
|
padding: 5px 30px !important;
|
|
}
|
|
|
|
#insurerTable th,
|
|
#insurerTable td {
|
|
padding: 2px 4px !important;
|
|
/* height: 30px; */
|
|
vertical-align: middle;
|
|
}
|
|
|
|
#insurerTable select {
|
|
height: 30px;
|
|
padding: 2px 5px;
|
|
}
|
|
|
|
#insurerTable input[type="checkbox"] {
|
|
margin: 0;
|
|
height: 20px;
|
|
width: 20px;
|
|
}
|
|
|
|
#insurerTable th {
|
|
min-width: 230px;
|
|
}
|
|
|
|
/** newly implemented */
|
|
#insurerTable thead th:first-child {
|
|
border-top: 0px solid #fff !important;
|
|
border-bottom: 0px solid #fff !important;
|
|
background-color: transparent !important;
|
|
}
|
|
#insurerTable tbody td {
|
|
border-top: 0px solid #fff !important;
|
|
border-bottom: 0px solid #fff !important;
|
|
background-color: transparent !important;
|
|
}
|
|
#insurerTable th{
|
|
color: black !important;
|
|
background-color: transparent !important;
|
|
}
|
|
|
|
#insurerTable input[type="text"],
|
|
#insurerTable select {
|
|
width: 100%;
|
|
font-size: 14px;
|
|
line-height: 1.5;
|
|
color: #000;
|
|
background-color: #fff;
|
|
background-clip: padding-box;
|
|
border: 1px solid #ced4da;
|
|
border-radius: 4px;
|
|
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
/* Focus effect like form-control */
|
|
#insurerTable input[type="text"]:focus,
|
|
#insurerTable select:focus {
|
|
border-color: #80bdff;
|
|
outline: 0;
|
|
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
|
|
}
|
|
|
|
/* Disabled & readonly styling */
|
|
#insurerTable input[readonly],
|
|
#insurerTable input:disabled,
|
|
#insurerTable select:disabled {
|
|
background-color: #e0e0e0; /* Darker background */
|
|
color: #666; /* Darker text color */
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
</style>
|
|
|
|
<style>
|
|
.readonly-color {
|
|
background-color: #e0e0e0; /* Darker background */
|
|
color: #666; /* Darker text color */
|
|
}
|
|
.readonly-select {
|
|
pointer-events: none;
|
|
/* background-color: #f0f0f0; */
|
|
background-color: #e0e0e0;
|
|
color: #666;
|
|
}
|
|
|
|
.select2-hidden-accessible + .select2-container .select2-dropdown {
|
|
display: none !important;
|
|
}
|
|
|
|
.select2-container .select2-selection--multiple .select2-selection__choice {
|
|
color: #000000;
|
|
}
|
|
|
|
.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: 10px;
|
|
top: 50%;
|
|
transform: translateY(-50%);
|
|
font-weight: bold;
|
|
color: #000;
|
|
}
|
|
|
|
</style>
|
|
|
|
<div class="row" id="endorsement_form" style="display: none;">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="row" style="margin-bottom:1rem;">
|
|
<div class="col-6" style="align-self: center;">
|
|
<h4 style="position: relative;">Add Endorsement</h4>
|
|
</div>
|
|
<div class="col-6" style="text-align: right;">
|
|
<a href="<?= base_url('policy_tranction/endorsement/list') ?>" id="btnAdd" class="btn btn-primary waves-effect waves-light"
|
|
>Back</a>
|
|
</div>
|
|
</div>
|
|
<form role="form" class="parsley-examples" method="post" id="endorsement_form_id" enctype="multipart/form-data">
|
|
|
|
<input type="hidden" name="id" id="policy_tranction_primarykey">
|
|
<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="cd_ac_pk" id="cd_ac_pk">
|
|
<input type="hidden" name="ct_type" id="ct_type">
|
|
<input type="hidden" name="bro_payable_by" id="bro_payable_by">
|
|
<input type="hidden" name="cop_yes" id="cop_yes">
|
|
<input type="hidden" name="base_cd_amount" id="base_cd_amount">
|
|
<input type="hidden" name="cd_amt_changed" id="cd_amt_changed" disabled>
|
|
|
|
|
|
<!-- Client Row -->
|
|
<div class="row">
|
|
<!-- Section 1 -->
|
|
<div class="col-md-12">
|
|
<div id="accordion_0" class="mb-0">
|
|
<label id="policyAccordion" class="m-1 d-flex justify-content-between align-items-center">
|
|
<span class="font-color-black">Client Details</span>
|
|
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseOne"
|
|
aria-expanded="true">
|
|
<i id="icon" class="mdi mdi-chevron-up mr-1 text-primary" style="font-size: 28px;"></i>
|
|
</a>
|
|
</label>
|
|
<div class="card mb-1">
|
|
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_0">
|
|
<div class="card-body">
|
|
<div class="row">
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="client_type">Client Type<span class="text-danger"></span></label>
|
|
<select class="form-control" id="client_type" name="client_type" >
|
|
<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="email"> Policy <span class="text-danger">*</span></label>
|
|
<select class="form-control" id="client_policy_id" name="client_policy_id" required>
|
|
<option value="">Select Policy</option>
|
|
</select>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Endorsement details -->
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<div id="accordion_2" class="mb-0">
|
|
<label id="policyAccordion" class="m-1 d-flex justify-content-between align-items-center">
|
|
<span class="font-color-black">Endorsement</span>
|
|
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseThree"
|
|
aria-expanded="true">
|
|
<i id="icon" class="mdi mdi-chevron-up mr-1 text-primary" style="font-size: 28px;"></i>
|
|
</a>
|
|
</label>
|
|
<div class="card mb-1">
|
|
<div id="collapseThree" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_2">
|
|
<div class="card-body">
|
|
<div class="row">
|
|
|
|
<!-- <div class="form-group col-md-3" id="tpa_endorse_div">
|
|
<label for="tpa"> TPA <span id="tpa_danger"class="text-danger"></span></label>
|
|
<select class="form-control readonly-select" 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">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" readonly>
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="bp_cgst">D.O.C <span id="base_danger" class="text-danger"></span></label>
|
|
<input id="policy_start_date" type="text" class="form-control" placeholder="DD/MM/YYYY" readonly>
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="bp_igst">D.O.E <span id="base_danger" class="text-danger"></span></label>
|
|
<input id="policy_end_date" type="text" class="form-control" placeholder="DD/MM/YYYY" readonly>
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="addon_policy"> Endorsement Type <span id="base_danger" class="text-danger">*</span></label>
|
|
<select class="form-control" id="action_type" name="action_type" required>
|
|
<option value="" selected>Select Endorsement Type</option>
|
|
<?php
|
|
if (isset($action_type) && count($action_type)) {
|
|
foreach ($action_type as $key => $value) {
|
|
echo "<option value=" . $key . ">" . $value . "</option>";
|
|
}
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="addon_policy">Endorsement No<span id="base_danger" class="text-danger"></span></label>
|
|
<input type="text" class="form-control" id="endorsement_no" name="endorsement_no" placeholder="Enter Endorsement No" onchange="validateInput(this, 'policy_transaction', 'endorsement_no')">
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="addon_policy">Data Received Date<span id="base_danger" class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="data_received_date" name="data_received_date" placeholder="DD/MM/YYYY" required>
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="policy_issue_date">Endorsement 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" required>
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="month">Endorsement Issue Month<span id="base_danger" class="text-danger">*</span></label>
|
|
<input type="text" class="form-control readonly-select" id="month" name="month" placeholder="MM/YYYY" required>
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="endorse_eff_date">Endorsement Effective Date<span id="base_danger" class="text-danger"></span></label>
|
|
<input type="text" class="form-control" id="endorse_eff_date" name="endorse_eff_date" placeholder="DD/MM/YYYY" >
|
|
</div>
|
|
|
|
<div class="form-group col-md-3" id="no_of_insured_endorse_div">
|
|
<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" id="no_of_dependents_endorse_div">
|
|
<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>
|
|
|
|
<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">
|
|
<label for="last_action_date">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 install_due_date_div" style="display: none;">
|
|
<label for="install_due_date">Installment due Date</label>
|
|
<input id="install_due_date" type="text" class="form-control" name="install_due_date" placeholder="DD/MM/YYYY">
|
|
</div>
|
|
|
|
<!-- <div class="form-group col-md-3">
|
|
<label class="switch" style="position: relative;top: 32px;left: 20px;">
|
|
<input id="policy_with_corr" type="checkbox" name="policy_with_corr">
|
|
<span class="slider round" style="height: 27px;"></span>
|
|
</label>
|
|
|
|
<label for="policy_with_corr" style="position: relative;top: 33px;left: 25px;"> Policy with Correction</label>
|
|
</div> -->
|
|
|
|
<!-- <div class="form-group col-md-3">
|
|
<label class="switch" style="position: relative;top: 32px;left: 20px;">
|
|
<input id="is_cd_reduce_from_bds" type="checkbox" name="is_cd_reduce_from_bds">
|
|
<span class="slider round" style="height: 27px;"></span>
|
|
</label>
|
|
|
|
<label for="is_cd_reduce_from_bds" style="position: relative;top: 33px;left: 25px;">Make Entry in CD <i class="mdi mdi-information-outline" data-toggle="tooltip" title="Enabling this will affect ( Credit/Debit ) the CD transaction. ( GMC, GPA, EDLI and GTLI, CD transaction from CRM )"></i></label>
|
|
</div> -->
|
|
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Premium Details -->
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<div id="accordion_3" class="mb-0">
|
|
<label id="policyAccordion" class="m-1 d-flex justify-content-between align-items-center">
|
|
<span class="font-color-black">Premium Details</span>
|
|
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseTwo"
|
|
aria-expanded="true">
|
|
<i id="icon" class="mdi mdi-chevron-up mr-1 text-primary" style="font-size: 28px;"></i>
|
|
</a>
|
|
</label>
|
|
<div class="card mb-0">
|
|
<div id="collapseTwo" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_3">
|
|
<div class="card-body">
|
|
<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 data-custom-table-css="table" class="table co_share_table" id="insurerTable">
|
|
<thead>
|
|
<tr>
|
|
<th><span class="font-color-black">Premium Details</span></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_37">
|
|
<td>CD Amount</td>
|
|
</tr>
|
|
|
|
<tr id="table_tr_35" style="display: none;">
|
|
<td>Follower Policy No</td>
|
|
</tr>
|
|
|
|
<tr id="table_tr_40" >
|
|
<td>Endorsement Issue Date</td>
|
|
</tr>
|
|
|
|
<tr id="table_tr_3" style="display: none;">
|
|
<td>Co-Share %</td>
|
|
</tr>
|
|
<tr id="table_tr_36">
|
|
<td>Non Commissional <br> Premium Amount</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 class="hidecop" id="table_tr_7" style="display: none;">
|
|
<td>Co-Premium</td>
|
|
</tr>
|
|
<tr class="hidecotp" id="table_tr_38" style="display: none;">
|
|
<td>Co-TP Premium</td>
|
|
</tr>
|
|
<tr class="hidecoter" id="table_tr_39" style="display: none;">
|
|
<td>Co-TEP Premium</td>
|
|
</tr>
|
|
<tr id="table_tr_8">
|
|
<td>CGST</td>
|
|
</tr>
|
|
<tr id="table_tr_9">
|
|
<td>SGST</td>
|
|
</tr>
|
|
<tr id="table_tr_10">
|
|
<td>IGST</td>
|
|
</tr>
|
|
<tr id="table_tr_11">
|
|
<td>GST Amount</td>
|
|
</tr>
|
|
<tr id="table_tr_12">
|
|
<td>Stamp Duty</td>
|
|
</tr>
|
|
<tr id="table_tr_13">
|
|
<td>Total</td>
|
|
</tr>
|
|
|
|
<tr id="table_tr_14">
|
|
<td>Agreed BP %</td>
|
|
</tr>
|
|
<tr class="hidetp" id="table_tr_15">
|
|
<td id="agree_tp_td">Agreed TP %</td>
|
|
</tr>
|
|
<tr class="hideter" id="table_tr_16" style="display: none;">
|
|
<td id="agree_tp_td">Agreed TEP %</td>
|
|
</tr>
|
|
|
|
<?php if (in_array(get_role_id(), [1,5]) || in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team())) { ?>
|
|
|
|
<tr id="table_tr_17">
|
|
<td>Agreed Amount</td>
|
|
</tr>
|
|
|
|
<?php } ?>
|
|
|
|
<tr id="table_tr_18">
|
|
<td>Standard BP %</td>
|
|
</tr>
|
|
<tr class="hidetp" id="table_tr_19">
|
|
<td>Standard TP %</td>
|
|
</tr>
|
|
<tr class="hideter" id="table_tr_20" style="display: none;">
|
|
<td>Standard TEP %</td>
|
|
</tr>
|
|
|
|
<?php if (in_array(in_array(get_role_id(), [1,5]) || FINANCE_TEAM_ID, user_team()) || in_array(MANAGEMENT_TEAM_ID, user_team())) { ?>
|
|
|
|
<tr id="table_tr_21">
|
|
<td>Actual BP Amount</td>
|
|
</tr>
|
|
<tr class="hidetp" id="table_tr_22">
|
|
<td>Actual TP Amount</td>
|
|
</tr>
|
|
<tr class="hideter" id="table_tr_23" style="display: none;">
|
|
<td>Actual TEP Amount</td>
|
|
</tr>
|
|
<tr id="table_tr_24">
|
|
<td>Actual BP %</td>
|
|
</tr>
|
|
<tr class="hidetp" id="table_tr_25">
|
|
<td>Actual TP %</td>
|
|
</tr>
|
|
<tr class="hideter" id="table_tr_26" style="display: none;">
|
|
<td>Actual TEP %</td>
|
|
</tr>
|
|
<tr id="table_tr_27">
|
|
<td>Actual BP <br> Remuneration Amount</td>
|
|
</tr>
|
|
<tr class="hidetp" id="table_tr_28">
|
|
<td>Actual TP <br> Remuneration Amount</td>
|
|
</tr>
|
|
<tr class="hideter" id="table_tr_29" style="display: none;">
|
|
<td>Actual TEP <br> Remuneration Amount</td>
|
|
</tr>
|
|
<tr id="table_tr_30">
|
|
<td>Expected Amount</td>
|
|
</tr>
|
|
<!-- <tr id="table_tr_31">
|
|
<td>Variance</td>
|
|
</tr> -->
|
|
<!-- <tr id="table_tr_32">
|
|
<td>Reward</td>
|
|
</tr> -->
|
|
|
|
<?php } ?>
|
|
|
|
<tr id="table_tr_33" style="display: none;">
|
|
<td></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group text-right mt-3 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>
|
|
<!-- end form row -->
|
|
|
|
<script>
|
|
|
|
var team_id = [];
|
|
var role_id = <?php echo get_role_id(); ?>;
|
|
console.log(" role_id : ", role_id);
|
|
var insurer_count_array = [];
|
|
var pt_co_share_count_data = 0;
|
|
var redirect_url = '<?= base_url('policy_tranction/endorsement/list') ?>';
|
|
|
|
$(document).ready(function(){
|
|
|
|
team_id = <?php echo json_encode(user_team()); ?>;
|
|
console.log('team_id', team_id);
|
|
|
|
if (team_id.includes('4')) {
|
|
console.log('Finance Team Logged in.');
|
|
} else if (team_id.includes('3')) {
|
|
console.log('Business Team Logged in.');
|
|
}
|
|
|
|
getURLParamsForReport()
|
|
})
|
|
|
|
$(document).ready(function(){
|
|
|
|
$('#client_id').change(function(){
|
|
|
|
let client_id = $(this).val();
|
|
|
|
// console.log('client_id', client_id);
|
|
// console.log('branch_list', branch_list);
|
|
|
|
if(client_id == 'add_client') {
|
|
$('#client_id').val('').change();
|
|
var myModal = new bootstrap.Modal(document.getElementById('upload_enrollment_model'));
|
|
myModal.show();
|
|
}
|
|
|
|
if(branch_list != '') {
|
|
// console.log(branch_list[client_id]);
|
|
let data = branch_list[client_id];
|
|
appendBranch(data);
|
|
}
|
|
|
|
if(policyListByClient != '') {
|
|
// console.log(branch_list[client_id]);
|
|
let data = policyListByClient[client_id];
|
|
if (data) {
|
|
appendPolicies(data);
|
|
|
|
}
|
|
}
|
|
|
|
})
|
|
|
|
$('#client_branch_id').change(function(){
|
|
|
|
let branch_id = $(this).val();
|
|
// console.log(policy_list)
|
|
// console.log(branch_id)
|
|
|
|
if(policy_list != '') {
|
|
console.log(policy_list[branch_id]);
|
|
let data = policy_list[branch_id];
|
|
appendPolicies(data);
|
|
}
|
|
|
|
|
|
});
|
|
|
|
$('#client_policy_id').change(function(){
|
|
|
|
console.log('######################################')
|
|
console.log('client_policy_id onchange called')
|
|
console.log('######################################')
|
|
|
|
let client_id = $('#client_id').val();
|
|
let policy_tranction_primarykey = $('#policy_tranction_primarykey').val();
|
|
let client_policy_id = $(this).val();
|
|
var policy_no = $(this).find('option:selected').attr('data-policy');
|
|
var insurer = $(this).find('option:selected').attr('data-insurer');
|
|
var tpa = $(this).find('option:selected').attr('data-tpa');
|
|
var cd_ac_no = $(this).find('option:selected').attr('data-cd');
|
|
var start_date = $(this).find('option:selected').attr('data-sd');
|
|
var end_date = $(this).find('option:selected').attr('data-ed');
|
|
var policy_type_id = $(this).find('option:selected').attr('data-ptid');
|
|
|
|
// if(policy_type_id == 1 || policy_type_id == 2 || policy_type_id == 3 || policy_type_id == 4 || policy_type_id == 5 || policy_type_id == 6 || policy_type_id == 7){
|
|
// $('#is_cd_reduce_from_bds').prop('disabled',true).prop('checked', false)
|
|
// }else{
|
|
// $('#is_cd_reduce_from_bds').prop('disabled',false)
|
|
// }
|
|
|
|
if( policy_type_id > 7 ){
|
|
$('#tpa_endorse_div').hide();
|
|
$('#table_tr_34').show();
|
|
$('#table_tr_37').show();
|
|
}else{
|
|
$('#tpa_endorse_div').show();
|
|
$('#table_tr_34').hide();
|
|
$('#table_tr_37').hide();
|
|
}
|
|
|
|
|
|
if(policy_type_id == 2 || policy_type_id == 3 || policy_type_id == 4 || policy_type_id == 5){
|
|
$('#no_of_insured_endorse_div').show();
|
|
$('#no_of_dependents_endorse_div').show();
|
|
}else if(policy_type_id == 1 || policy_type_id == 6 || policy_type_id == 7) {
|
|
$('#no_of_insured_endorse_div').show();
|
|
$('#no_of_dependents_endorse_div').hide();
|
|
}else{
|
|
$('#no_of_insured_endorse_div').hide();
|
|
$('#no_of_dependents_endorse_div').hide();
|
|
}
|
|
|
|
|
|
// console.log('client_id', client_id);
|
|
// console.log('client_policy_id', client_policy_id);
|
|
// console.log('policy_tranction_primarykey', policy_tranction_primarykey);
|
|
// console.log('policy_no', policy_no);
|
|
// console.log('cd_ac_no',cd_ac_no);
|
|
// console.log('tpa',tpa);
|
|
|
|
$('#policy_no').val(policy_no);
|
|
$('#insurer_id').val(insurer);
|
|
$('#tpa').val(tpa).change();
|
|
// $('#cd_ac_no').val(cd_ac_no);
|
|
$('#policy_start_date').val(start_date);
|
|
$('#policy_end_date').val(end_date);
|
|
|
|
if(!policy_tranction_primarykey && client_id && client_policy_id){
|
|
|
|
removeAllColumnsExceptFirst('insurerTable');
|
|
|
|
form_action = '<?= base_url("util/getPTCOShareCount/"); ?>' + client_id + '/' + client_policy_id;
|
|
|
|
$.ajax({
|
|
url: form_action,
|
|
type: "GET",
|
|
dataType: 'json',
|
|
processData: false,
|
|
contentType: false,
|
|
success: function(res) {
|
|
|
|
console.log('policy co share data', res);
|
|
|
|
if(res.status == true){
|
|
if(res.data.length > 0){
|
|
|
|
$('#ct_type').val(2);
|
|
$('#cd_ac_pk').val(res?.is_copay_yes?.cd_ac_pk || "");
|
|
$('#cd_ac_no').val(res?.cd_master_data?.cd_ac_no || "");
|
|
$('#bro_payable_by').val(res.data[0].bro_payable_by);
|
|
|
|
if(res.is_copay_yes && res.is_copay_yes.co_share == 1){
|
|
console.log('copay yes', res.is_copay_yes);
|
|
$('#cop_yes').val(1);
|
|
}else{
|
|
console.log('copay no', res.is_copay_yes);
|
|
$('#cop_yes').val(0);
|
|
}
|
|
|
|
populateTable(res.data);
|
|
|
|
if (res?.data?.length) {
|
|
console.log('PT Co Share Count :', res.data.length);
|
|
pt_co_share_count_data = res.data.length;
|
|
}
|
|
|
|
$('#btnSubmit').prop('disabled', false).data('disable', false);
|
|
|
|
}else{
|
|
$('#ct_type').val(1)
|
|
// addInsurerColumn()
|
|
toastr.warning("There is no policy inception data.", 'WARNING!');
|
|
$('#btnSubmit').prop('disabled', true).data('disable', true);
|
|
}
|
|
}else{
|
|
$('#ct_type').val(1)
|
|
// addInsurerColumn()
|
|
toastr.warning(res.message, 'WARNING!');
|
|
$('#btnSubmit').prop('disabled', true).data('disable', true);
|
|
}
|
|
},
|
|
error: function (xhr, status, error) {
|
|
console.error(xhr.responseText);
|
|
console.error(status, error);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
})
|
|
|
|
$(document).on('change', 'input[type="checkbox"][name="co_share_type[]"]', function() {
|
|
|
|
let isAnyChecked = $('input[type="checkbox"][name="co_share_type[]"]:checked').length > 1;
|
|
|
|
if (isAnyChecked) {
|
|
toastr.warning('Only one leader can be selected.', 'WARNING!');
|
|
$(this).prop('checked', false);
|
|
}
|
|
});
|
|
|
|
$(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{
|
|
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).ready(function() {
|
|
$(document).on('change', '[name="follow_insurer_id[]"]', function() {
|
|
|
|
let insurer = $(this).val();
|
|
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 insurer_id', insurer_branch_id);
|
|
|
|
if (!$('#cop_yes').is(':checked')) {
|
|
|
|
if(client_id && insurer_id){
|
|
$('#insurer_id').val(insurer)
|
|
// getCDAccountNumber(client_id, insurer_id);
|
|
} else {
|
|
console.log('getCDAccountNumber cannot be called because of the absence of client id and insurer id');
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
//---------------------------------------------------------------------------------------------------------
|
|
|
|
$("#endorsement_form_id").submit(function(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
var isValid = $('#endorsement_form_id').parsley().validate();
|
|
|
|
if (!isValid) {
|
|
$('#endorsement_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;
|
|
}
|
|
|
|
form_action = '<?= base_url('policy_tranction/endorsement/create') ?>';
|
|
|
|
$('.loader').fadeIn();
|
|
$('.loader-mask').fadeIn();
|
|
|
|
var formData = new FormData($('#endorsement_form_id')[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('ENDORSEMENT FOR SUBMIT RESPONSE : ', res);
|
|
|
|
if (res.status == true) {
|
|
toastr.success(res.message, 'Success');
|
|
$('#policy_tranction_primarykey').val(res.pt_id);
|
|
window.location.href = redirect_url;
|
|
} else {
|
|
toastr.error(res.message, 'Error');
|
|
}
|
|
|
|
},
|
|
error: function(xhr, status, error) {
|
|
console.error(xhr.responseText);
|
|
console.error(status, error);
|
|
$('.loader').fadeOut();
|
|
$('.loader-mask').delay(350).fadeOut('slow');
|
|
}
|
|
});
|
|
});
|
|
|
|
//---------------------------------------------------------------------------------------------------------
|
|
|
|
$('#client_type').on('change', function() {
|
|
|
|
var selectedClientType = $(this).val();
|
|
|
|
if (selectedClientType == 2) {
|
|
$('.branchdiv').hide();
|
|
$('#table_tr_34').hide();
|
|
$('#table_tr_37').hide();
|
|
} else {
|
|
$('.branchdiv').show();
|
|
$('#table_tr_34').show();
|
|
$('#table_tr_37').show();
|
|
}
|
|
|
|
console.log('selectedClientType', selectedClientType);
|
|
|
|
// Clear and add default options for client
|
|
$('#client_id').empty().append($('<option>', {
|
|
value: '',
|
|
text: 'Select Client'
|
|
}))
|
|
|
|
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);
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
if(selectedClientType == 1){
|
|
$('#client_policy_id').empty().append($('<option>', {
|
|
value: '',
|
|
text: 'Select Policy'
|
|
}));
|
|
}
|
|
|
|
// Initialize or refresh Select2 for both dropdowns
|
|
$('#client_id').select2();
|
|
$('#client_policy_id').select2();
|
|
});
|
|
|
|
$('#endorsement_no').on('change', function(){
|
|
|
|
var policy_no = $('#policy_no').val();
|
|
console.log(policy_no +'-'+policy_no.length);
|
|
policy_no = policy_no.trim();
|
|
console.log(policy_no +'-'+policy_no.length);
|
|
|
|
var endorsement_no = $(this).val();
|
|
console.log(endorsement_no +'-'+endorsement_no.length);
|
|
endorsement_no = endorsement_no.trim();
|
|
console.log(endorsement_no +'-'+endorsement_no.length);
|
|
|
|
if(policy_no && endorsement_no){
|
|
$.ajax({
|
|
url: '<?php echo base_url('util/get_client_policy_data_using_policy_no_and_endo_no/');?>',
|
|
type: "GET",
|
|
data : {policy_no : policy_no, endorsement_no : endorsement_no},
|
|
dataType: 'json',
|
|
success: function (res) {
|
|
|
|
console.log("get_client_policy_data_using_policy_no_and_endo_no Response : ", res);
|
|
if(res.status == true){
|
|
$('#ct_type').val(1)
|
|
}else{
|
|
$('#ct_type').val(2)
|
|
console.log(res.message, 'warning');
|
|
}
|
|
},
|
|
error: function (xhr, status, error) {
|
|
console.error(xhr.responseText);
|
|
console.error(status, error);
|
|
}
|
|
});
|
|
}else{
|
|
console.log('Policy number or Endorsement Number is empty')
|
|
}
|
|
|
|
})
|
|
|
|
//------------- EDIT FUNCTION -----------------------------------------------------------------------------------------------
|
|
|
|
function getPolicyTransactionDataForEndorsementEdit(input){
|
|
|
|
$('.loader').fadeIn();
|
|
$('.loader-mask').fadeIn();
|
|
|
|
$('#endorsement_form_id')[0].reset();
|
|
// var id = $(input).attr('data-id');
|
|
var id = input;
|
|
|
|
$.ajax({
|
|
url: '<?= base_url("/policy_tranction/endorsement/list/") ?>' + id,
|
|
type: "GET",
|
|
dataType: 'json',
|
|
success: function(res) {
|
|
|
|
console.log('getPolicyTransactionDataForEndorsementEdit', res);
|
|
if(res.status == true){
|
|
|
|
hide_list_show_add()
|
|
|
|
$('#bro_payable_by').val(res.data.bro_payable_by)
|
|
|
|
if(res.data && res.data.co_share == 1){
|
|
console.log('copay yes', res.data);
|
|
$('#cop_yes').val(1);
|
|
}else{
|
|
console.log('copay no', res.data);
|
|
$('#cop_yes').val(0);
|
|
}
|
|
|
|
$('#policy_tranction_primarykey').val(res.data.id);
|
|
$('#client_type').val(res.data.client_type).trigger('change');
|
|
$('#client_id').val(res.data.client_id).change();
|
|
$('#base_cd_amount').val(res.data.base_cd_amount);
|
|
|
|
var tpaValue = '';
|
|
if (res.data.tpa_branch_id && res.data.tpa_id) {
|
|
tpaValue = res.data.tpa_branch_id + '-' + res.data.tpa_id;
|
|
}
|
|
$('#tpa').val(tpaValue).change();
|
|
|
|
|
|
setTimeout(function(){
|
|
$('.loader').fadeOut();
|
|
$('.loader-mask').delay(350).fadeOut('slow');
|
|
$('#client_branch_id').val(res.data.client_branch_id).select2();
|
|
// $('#client_policy_id').val(res.pt_id).select2();
|
|
}, 1000)
|
|
|
|
if(res.data.client_type == 2){
|
|
let data1 = policyListByClient[res.data.client_id];
|
|
appendPolicies(data1, res.pt_id);
|
|
}else{
|
|
let data2 = policy_list[res.data.client_branch_id];
|
|
appendPolicies(data2, res.pt_id);
|
|
}
|
|
|
|
setTimeout(function(){
|
|
$('#policy_start_date').val(res.data.policy_start_date);
|
|
$('#policy_end_date').val(res.data.policy_end_date);
|
|
$('#insurer_id').val(res.data.insurer_branch_id + '-' + res.data.insurer_id);
|
|
}, 1500)
|
|
|
|
$('#policy_no').val(res.data.policy_no);
|
|
$('#action_type').val(res.data.action_type);
|
|
$('#endorsement_no').val(res.data.endorsement_no);
|
|
$('#data_received_date').val(res.data.data_received_date);
|
|
$('#policy_issue_date').val(res.data.policy_issue_date);
|
|
$('#emp_count').val(res.data.emp_count);
|
|
$('#dependent_count').val(res.data.dependent_count);
|
|
$('#policy_status').val(res.data.status);
|
|
$('#endorse_eff_date').val(res.data.endorse_eff_date);
|
|
$('#month').val(res.data.month);
|
|
$('#last_action_date').val(res.data.last_action_date);
|
|
$('#install_due_date').val(res.data.install_due_date);
|
|
$('#bro_payable_by').val(res.data.bro_payable_by);
|
|
$('#cd_ac_pk').val(res.data.cd_ac_pk);
|
|
$('#cd_ac_no').val(res.data.cd_ac_no);
|
|
$('#ct_type').val(res.data.ct_type);
|
|
|
|
if (res.data.policy_with_corr == 1) {
|
|
$('#policy_with_corr').prop('checked', true);
|
|
} else {
|
|
$('#policy_with_corr').prop('checked', false);
|
|
}
|
|
|
|
// if (res.data.is_cd_reduce_from_bds == 1) {
|
|
// $('#is_cd_reduce_from_bds').prop('checked', true).prop('checked', false);
|
|
// } else {
|
|
// $('#is_cd_reduce_from_bds').prop('checked', false);
|
|
// }
|
|
|
|
if (res.data.action_type == 'policy_instalment') {
|
|
$('.install_due_date_div').show()
|
|
}else{
|
|
$('.install_due_date_div').hide()
|
|
}
|
|
|
|
removeAllColumnsExceptFirst('insurerTable');
|
|
|
|
if(res.data.pt_co_share_details.length > 0){
|
|
setTimeout(function(){
|
|
populateTable(res.data.pt_co_share_details, true);
|
|
}, 2000);
|
|
}else{
|
|
addInsurerColumn();
|
|
}
|
|
|
|
if (res.data.client_type == 2) {
|
|
$('.branchdiv').hide();
|
|
$('#table_tr_34').hide();
|
|
$('#table_tr_37').hide();
|
|
} else {
|
|
$('.branchdiv').show();
|
|
$('#table_tr_34').show();
|
|
$('#table_tr_37').show();
|
|
}
|
|
|
|
if (res.data.policy_type_id == 1 || res.data.policy_type_id == 2 || res.data.policy_type_id == 3 || res.data.policy_type_id == 4 || res.data.policy_type_id == 5 || res.data.policy_type_id == 6 || res.data.policy_type_id == 7 || res.data.client_type == 2) {
|
|
$('#table_tr_34').hide();
|
|
$('#table_tr_37').hide();
|
|
}
|
|
|
|
// if(res.data.policy_type_id == 1 || res.data.policy_type_id == 2 || res.data.policy_type_id == 3 || res.data.policy_type_id == 4 || res.data.policy_type_id == 5 || res.data.policy_type_id == 6 || res.data.policy_type_id == 7){
|
|
// $('#is_cd_reduce_from_bds').prop('disabled',true).prop('checked', false);
|
|
// }else{
|
|
// $('#is_cd_reduce_from_bds').prop('disabled',false);
|
|
// }
|
|
|
|
|
|
}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)
|
|
|
|
}
|
|
|
|
//------------- END EDIT FUNCTION --------------------------------------------------------------------------------------------
|
|
|
|
// do not remove this function
|
|
// function checkAndDistributeTax(input) {
|
|
// const event = window.event;
|
|
// // console.log("Event type:", event.type);
|
|
// // console.log("Event target:", event.target);
|
|
// console.log("Event id:", event.target.id);
|
|
|
|
// let cgst = parseFloat($('#cgst_' + input).val());
|
|
// let sgst = parseFloat($('#sgst_' + input).val());
|
|
// let igst = parseFloat($('#igst_' + input).val());
|
|
|
|
// if(((event.target.id).startsWith('cgst') || (event.target.id).startsWith('sgst') ))
|
|
// {
|
|
// if(cgst !== 0) { $('#sgst_' + input).val(cgst); }
|
|
// else if(sgst !== 0) { $('#cgst_' + input).val(sgst); }
|
|
|
|
// $('#igst_' + input).val(0);
|
|
// }
|
|
// else if((event.target.id).startsWith('igst'))
|
|
// {
|
|
// $('#cgst_' + input).val(0);
|
|
// $('#sgst_' + input).val(0);
|
|
// }
|
|
// }
|
|
|
|
// function amountCalculation(input) {
|
|
|
|
// console.log('############################## AMOUNT CALCULATION ############################################')
|
|
// console.log('amountCalculation : ' + input);
|
|
// let selectedOption = $('#client_policy_id').find('option:selected');
|
|
// console.log("selectedOption", selectedOption);
|
|
// let bap = selectedOption.data('bap');
|
|
// let allocg = selectedOption.data('allocg');
|
|
|
|
// const event = window.event;
|
|
// console.log("Event id:", event.target.id);
|
|
|
|
// let endorsement_type = $('#action_type').val();
|
|
// console.log('endorsement_type', endorsement_type);
|
|
|
|
// let isDeletion = (endorsement_type == "deletion");
|
|
// console.log('isDeletion:', isDeletion);
|
|
|
|
// // Retrieve and parse the values or default to 0 if not a number
|
|
// let bp = parseFloat($('#base_premium_' + input).val()) || 0;
|
|
// console.log("bp base premium", bp);
|
|
// let ncpa = parseFloat($('#non_comm_per_amt_' + input).val()) || 0;
|
|
// console.log("ncpa non comm base premium", ncpa);
|
|
|
|
// var tp = 0;
|
|
// if(allocg != 'EB'){
|
|
// tp = parseFloat($('#tp_premium_' + input).val()) || 0;
|
|
// }
|
|
// // do not remove this commented item
|
|
// // 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;
|
|
// }
|
|
|
|
// //co-share premium
|
|
// let cop = parseFloat($('#co_premium_' + input).val()) || 0;
|
|
|
|
// var cotp = 0;
|
|
// if(bap == 'Motor'){
|
|
// cotp = parseFloat($('#co_tp_premium_' + input).val()) || 0;
|
|
// }
|
|
|
|
// var cotep = 0;
|
|
// if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
|
|
// cotep = parseFloat($('#co_ter_premium_' + input).val()) || 0;
|
|
// }
|
|
|
|
// checkAndDistributeTax(input);
|
|
// let cgst = parseFloat($('#cgst_' + input).val()) || 0;
|
|
// let sgst = parseFloat($('#sgst_' + input).val()) || 0;
|
|
// let igst = parseFloat($('#igst_' + input).val()) || 0;
|
|
|
|
|
|
// let stamp_duty_amt = parseFloat($('#stamp_duty_' + input).val()) || 0;
|
|
// let agreed_amount = parseFloat($('#agreed_amount_' + input).val()) || 0;
|
|
|
|
// let agreed_bp_per = parseFloat($('#agreed_bp_' + input).val()) || 0;
|
|
// let agreed_tp_per = parseFloat($('#agreed_tp_' + input).val()) || 0;
|
|
// let agreed_tep_per = parseFloat($('#agreed_tep_' + input).val()) || 0;
|
|
|
|
// let standard_bp_per = parseFloat($('#standard_bp_' + input).val()) || 0;
|
|
// let standard_tp_per = parseFloat($('#standard_tp_' + input).val()) || 0;
|
|
// let standard_tep_per = parseFloat($('#standard_tep_' + input).val()) || 0;
|
|
|
|
// let co_share_per = parseFloat($('#co_share_per_' + input).val()) || 0;
|
|
// let gst_amount = parseFloat($('#gst_amount_' + input).val()) || 0;
|
|
|
|
|
|
// // Calculate GST percentage
|
|
// let gst_per = igst;
|
|
// if (igst === 0) {
|
|
// gst_per = parseFloat(cgst) + parseFloat(sgst);
|
|
// }
|
|
|
|
// // console.log('gst_per', gst_per);
|
|
// // console.log('igst', igst);
|
|
// // console.log('cgst', cgst);
|
|
// // console.log('sgst', sgst);
|
|
|
|
// // Calculate the total premium
|
|
|
|
// let base_premium = cop;
|
|
// let third_part_premium = cotp;
|
|
// let terrisom_premium = cotep;
|
|
|
|
// let tpTotal = cop + cotp + cotep;
|
|
// if($('#bro_payable_by').val() == 1){
|
|
|
|
// tpTotal = bp + tp + tep;
|
|
|
|
// base_premium = bp;
|
|
// third_part_premium = tp;
|
|
// terrisom_premium = tep;
|
|
// }
|
|
|
|
// console.log('base_premium', base_premium);
|
|
// console.log('third_part_premium', third_part_premium);
|
|
// console.log('terrisom_premium', terrisom_premium);
|
|
|
|
// if ($('#cop_yes').val() == 0) {
|
|
// $('#co_premium_' + input).val(bp);
|
|
// $('#co_tp_premium_' + input).val(tp);
|
|
// $('#co_ter_premium_' + input).val(tep);
|
|
// $('#co_share_per_' + input).val(100);
|
|
// }
|
|
|
|
// console.log('tpTotal', tpTotal);
|
|
// ncpaTotal = tpTotal + ncpa;
|
|
// let ncpa_gst_per_amt = (ncpaTotal * gst_per) / 100;
|
|
// console.log('ncpa_gst_per_amt', ncpa_gst_per_amt);
|
|
|
|
// let gst_per_amt = (tpTotal * gst_per) / 100;
|
|
// console.log('gst_per_amt', gst_per_amt);
|
|
|
|
// // $('#gst_amount_' + input).val(gst_per_amt.toFixed(2));
|
|
// if (event.target.id.startsWith('non_comm_per_amt')) {
|
|
// $('#gst_amount_' + input).val(!isNaN(ncpa_gst_per_amt) && isFinite(ncpa_gst_per_amt) ? ncpa_gst_per_amt.toFixed(2) : '0.00');
|
|
// }else if (event.target.id.startsWith('gst_amount')) {
|
|
// $('#gst_amount_' + input).val(!isNaN(gst_amount) && isFinite(gst_amount) ? gst_amount.toFixed(2) : '0.00');
|
|
// }else{
|
|
// if(ncpa != 0 && ncpa != ""){
|
|
// $('#gst_amount_' + input).val(!isNaN(ncpa_gst_per_amt) && isFinite(ncpa_gst_per_amt) ? ncpa_gst_per_amt.toFixed(2) : '0.00');
|
|
// }else{
|
|
// $('#gst_amount_' + input).val(!isNaN(gst_per_amt) && isFinite(gst_per_amt) ? gst_per_amt.toFixed(2) : '0.00');
|
|
// }
|
|
// }
|
|
|
|
// let finalTotal = tpTotal + gst_per_amt + stamp_duty_amt;
|
|
// console.log('Summed Amount:', finalTotal);
|
|
|
|
// //Total Amount
|
|
// $('#total_amt_' + input).val(!isNaN(finalTotal) && isFinite(finalTotal) ? finalTotal.toFixed(2) : '0.00');
|
|
|
|
// //---------------------------------------------------------------------------------------------------
|
|
|
|
// let sum_of_agreed_premium = agreed_bp_per + agreed_tp_per + agreed_tep_per;
|
|
// // console.log('sum_of_agreed_precentage : ', sum_of_agreed_premium);
|
|
|
|
// var expectedAmount = 0;
|
|
|
|
// if(agreed_amount > 0 ){
|
|
// expectedAmount = agreed_amount;
|
|
// // console.log('Formula 1 AGREED AMOUNT');
|
|
// }else if(sum_of_agreed_premium > 0){
|
|
|
|
// let sumOfTheAggreedPer = agreed_bp_per + agreed_tp_per + agreed_tep_per;
|
|
|
|
// let sum_of_bp_amt = (base_premium * agreed_bp_per) /100
|
|
// let sum_of_tp_amt = (third_part_premium * agreed_tp_per) / 100
|
|
// let sum_of_tep_amt = (terrisom_premium * agreed_tep_per) / 100
|
|
|
|
// expectedAmount = (sum_of_bp_amt + sum_of_tp_amt + sum_of_tep_amt) ?? 0;
|
|
|
|
// // console.log('Formula 2 AGREED BP TP/TEP %');
|
|
// }else{
|
|
|
|
// let sumOfTheStandardPer = standard_bp_per + standard_tp_per + standard_tep_per;
|
|
|
|
// let sum_of_bp_amt = (base_premium * standard_bp_per) /100
|
|
// let sum_of_tp_amt = (third_part_premium * standard_tp_per) / 100
|
|
// let sum_of_tep_amt = (terrisom_premium * standard_tep_per) / 100
|
|
|
|
// expectedAmount = (sum_of_bp_amt + sum_of_tp_amt + sum_of_tep_amt) ?? 0;
|
|
|
|
// // console.log('Formula 3 STANDARD BP TP/TEP %');
|
|
// }
|
|
|
|
// console.log('expectedAmount', expectedAmount);
|
|
|
|
// //Expected Amount
|
|
// $('#exp_amt_' + input).val(!isNaN(expectedAmount) && isFinite(expectedAmount) ? expectedAmount.toFixed(2) : '0.00');
|
|
|
|
|
|
// let actual_bp_brokerage_amount = parseFloat($('#actual_bp_brokerage_amt_' + input).val()) || 0;
|
|
// let actual_tp_brokerage_amount = parseFloat($('#actual_tp_brokerage_amt_' + input).val()) || 0;
|
|
// let actual_tep_brokerage_amount = parseFloat($('#actual_tep_brokerage_amt_' + input).val()) || 0;
|
|
|
|
// // console.log('actual_bp_brokerage_amount', actual_bp_brokerage_amount);
|
|
// // console.log('actual_tp_brokerage_amount', actual_tp_brokerage_amount);
|
|
// // console.log('actual_tep_brokerage_amount', actual_tep_brokerage_amount);
|
|
|
|
// let variance = (actual_bp_brokerage_amount + actual_tp_brokerage_amount + actual_tep_brokerage_amount) - expectedAmount;
|
|
// // console.log('variance', variance);
|
|
|
|
// // $('#variance_' + input).val(!isNaN(variance) && isFinite(variance) ? variance.toFixed(2) : '0.00');
|
|
|
|
// setCoPremiums(input);
|
|
|
|
// console.log('############################## END AMOUNT CALCULATION ############################################')
|
|
|
|
// applyDeletionSymbolsToFields(input, isDeletion);
|
|
|
|
// }
|
|
|
|
// function setCoPremiums(input) {
|
|
|
|
// let bp = $('input[name="base_premium[]"]').toArray()
|
|
// .map(input => parseFloat($(input).val()) || 0)
|
|
// .find(value => value > 0) || 0;
|
|
// let tp = $('input[name="tp_premium[]"]').toArray()
|
|
// .map(input => parseFloat($(input).val()) || 0)
|
|
// .find(value => value > 0) || 0;
|
|
// let tep = $('input[name="ter_premium[]"]').toArray()
|
|
// .map(input => parseFloat($(input).val()) || 0)
|
|
// .find(value => value > 0) || 0;
|
|
|
|
// // let bp = parseFloat($('#base_premium_' + input).val()) || 0;
|
|
// // let tp = parseFloat($('#tp_premium_' + input).val()) || 0;
|
|
// // let tep = parseFloat($('#ter_premium_' + input).val()) || 0;
|
|
// let coSharePer = parseFloat($('#co_share_per_' + input).val()) || 0;
|
|
|
|
// let cop = (bp * coSharePer) / 100;
|
|
// let cotp = (tp * coSharePer) / 100;
|
|
// let cotep = (tep * coSharePer) / 100;
|
|
|
|
// // Log all values to console
|
|
// console.log(`Input: ${input}`);
|
|
// console.log(`Base Premium (bp): ${bp}`);
|
|
// console.log(`TP Premium (tp): ${tp}`);
|
|
// console.log(`TEP Premium (tep): ${tep}`);
|
|
// console.log(`Co-Share Percentage (coSharePer): ${coSharePer}`);
|
|
// console.log(`Co Premium (cop): ${cop.toFixed(2)}`);
|
|
// console.log(`Co TP Premium (cotp): ${cotp.toFixed(2)}`);
|
|
// console.log(`Co TEP Premium (cotep): ${cotep.toFixed(2)}`);
|
|
|
|
// $('#co_premium_' + input).val(cop.toFixed(2));
|
|
// $('#co_tp_premium_' + input).val(cotp.toFixed(2));
|
|
// $('#co_ter_premium_' + input).val(cotep.toFixed(2));
|
|
// }
|
|
|
|
// Apply Deletion (Negative) Values
|
|
// function applyDeletionSymbolsToFields(input, isDeletion) {
|
|
// console.log('========== APPLYING DELETION SYMBOLS ==========');
|
|
|
|
// if (!isDeletion) return;
|
|
|
|
// const fieldIds = [
|
|
// 'base_premium',
|
|
// 'tp_premium',
|
|
// 'ter_premium',
|
|
// 'co_premium',
|
|
// 'co_tp_premium',
|
|
// 'co_ter_premium',
|
|
// 'gst_amount',
|
|
// 'agreed_amount',
|
|
// 'non_comm_per_amt',
|
|
// 'total_amt',
|
|
// 'exp_amt'
|
|
// ];
|
|
|
|
// fieldIds.forEach(field => {
|
|
// const $el = $('#' + field + '_' + input);
|
|
// console.log('$el', '#' + field + '_' + input);
|
|
// console.log('$el', $el);
|
|
// let val = $el.val()?.trim();
|
|
// console.log('$val', val);
|
|
// if (!val || val.startsWith('-')) return;
|
|
|
|
// let num = parseFloat(val);
|
|
// if (!isNaN(num) && num > 0) $el.val(-num);
|
|
// });
|
|
|
|
// console.log('========== COMPLETED DELETION SYMBOL APPLICATION ==========');
|
|
// }
|
|
|
|
function checkAndDistributeTax(input){
|
|
|
|
const event = window.event;
|
|
console.log("Event id:", event.target.id);
|
|
|
|
let policy_type_id = $('#client_policy_id').find('option:selected').attr('data-ptid');
|
|
policy_type_id = parseInt(policy_type_id);
|
|
console.log('policy_type_id', policy_type_id);
|
|
|
|
let cgst = parseFloat($('#cgst_' + input).val());
|
|
let sgst = parseFloat($('#sgst_' + input).val());
|
|
let igst = parseFloat($('#igst_' + input).val());
|
|
|
|
// ✅ Allow 0 only for policy types 2, 5, 7
|
|
const allowZero = [1,2,3,4,5,6,7,38,39,40].includes(policy_type_id);
|
|
console.log("allowZero", allowZero);
|
|
|
|
// 🔒 Validation: Disallow 0 or negative values for other policy types
|
|
if (!allowZero) {
|
|
if ((cgst <= 0 && (event.target.id).startsWith('cgst')) ||
|
|
(sgst <= 0 && (event.target.id).startsWith('sgst')) ||
|
|
(igst <= 0 && (event.target.id).startsWith('igst'))) {
|
|
|
|
toastr.warning('Tax value must be greater than 0 for this policy type.');
|
|
$('#'+ event.target.id).val('');
|
|
$('#igst_' + input).val('');
|
|
$('#cgst_' + input).val('');
|
|
$('#sgst_' + input).val('');
|
|
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (((event.target.id).startsWith('cgst'))) {
|
|
|
|
if (!isFinite(cgst) || isNaN(cgst) || cgst === undefined) {
|
|
cgst = '';
|
|
}
|
|
|
|
$('#cgst_' + input).val(cgst);
|
|
if(cgst == ""){
|
|
$('#sgst_' + input).val(0);
|
|
}else{
|
|
$('#sgst_' + input).val(cgst);
|
|
}
|
|
$('#igst_' + input).val(0);
|
|
}
|
|
|
|
if (((event.target.id).startsWith('sgst'))) {
|
|
|
|
if (!isFinite(sgst) || isNaN(sgst) || sgst === undefined) {
|
|
sgst = '';
|
|
}
|
|
|
|
$('#sgst_' + input).val(sgst);
|
|
if(sgst == ""){
|
|
$('#cgst_' + input).val(0);
|
|
}else{
|
|
$('#cgst_' + input).val(sgst);
|
|
}
|
|
$('#igst_' + input).val(0);
|
|
}
|
|
|
|
if ((event.target.id).startsWith('igst')) {
|
|
$('#cgst_' + input).val(0);
|
|
$('#sgst_' + input).val(0);
|
|
}
|
|
|
|
// Ensure IGST, CGST, and SGST are never NaN, undefined, or Infinity
|
|
$('#igst_' + input).val(isFinite($('#igst_' + input).val()) ? $('#igst_' + input).val() : 0);
|
|
$('#cgst_' + input).val(isFinite($('#cgst_' + input).val()) ? $('#cgst_' + input).val() : 0);
|
|
$('#sgst_' + input).val(isFinite($('#sgst_' + input).val()) ? $('#sgst_' + input).val() : 0);
|
|
}
|
|
|
|
// Main calculation function
|
|
function amountCalculation(input) {
|
|
|
|
console.log('############################## AMOUNT CALCULATION ############################################');
|
|
console.log('amountCalculation:', input);
|
|
|
|
let selectedOption = $('#client_policy_id').find('option:selected');
|
|
let bap = selectedOption.data('bap') || '';
|
|
let allocg = selectedOption.data('allocg') || '';
|
|
let endorsement_type = $('#action_type').val();
|
|
let isDeletion = false;
|
|
// let isDeletion = endorsement_type === "deletion" || endorsement_type === "policy_cancellation";
|
|
console.log({bap, allocg, isDeletion});
|
|
|
|
const event = window.event || {};
|
|
|
|
// Helper functions
|
|
const rawVal = id => {
|
|
const v = $('#' + id + '_' + input).val();
|
|
return v === undefined || v === null ? '' : String(v).trim();
|
|
};
|
|
const numVal = id => {
|
|
const n = parseFloat(rawVal(id));
|
|
return isNaN(n) ? 0 : n;
|
|
};
|
|
const absNum = id => Math.abs(numVal(id));
|
|
|
|
// Read input values
|
|
let bp = absNum('base_premium');
|
|
let ncpa = absNum('non_comm_per_amt');
|
|
let tp = (allocg !== 'EB') ? absNum('tp_premium') : 0;
|
|
let tep = (['Fire', 'Marine Cargo', 'Marine Hull'].includes(bap)) ? absNum('ter_premium') : 0;
|
|
let cop = absNum('co_premium');
|
|
let cotp = (allocg !== 'EB') ? absNum('co_tp_premium') : 0;
|
|
let cotep = (['Fire', 'Marine Cargo', 'Marine Hull'].includes(bap)) ? absNum('co_ter_premium') : 0;
|
|
|
|
console.log('premiums :', { bp, tp, tep, cop, cotp, cotep, ncpa });
|
|
|
|
let bp_raw_val = parseFloat($('#base_premium_' + input).val());
|
|
console.log('bp_raw_val', bp_raw_val);
|
|
|
|
// handel the positive(+), negative(-) symbole add the value
|
|
if(endorsement_type === "addition" || endorsement_type === "baby_addition" || endorsement_type === "addition_inception"){
|
|
isDeletion = false
|
|
}else if(endorsement_type === "deletion" || endorsement_type === "policy_cancellation"){
|
|
isDeletion = true
|
|
}else if(bp_raw_val < 0){
|
|
isDeletion = true;
|
|
console.log('Value is negative:', bp_raw_val);
|
|
}
|
|
|
|
let co_share_type_val = numVal('co_share_type');
|
|
console.log('co_share_type_val :', co_share_type_val);
|
|
|
|
// GST & Tax Setup
|
|
checkAndDistributeTax(input);
|
|
let cgst = numVal('cgst'), sgst = numVal('sgst'), igst = numVal('igst');
|
|
let gst_per = igst || (cgst + sgst);
|
|
|
|
let stamp_duty_amt = absNum('stamp_duty');
|
|
let agreed_amount = absNum('agreed_amount');
|
|
let agreed_bp_per = numVal('agreed_bp');
|
|
let agreed_tp_per = numVal('agreed_tp');
|
|
let agreed_tep_per = numVal('agreed_tep');
|
|
let standard_bp_per = numVal('standard_bp');
|
|
let standard_tp_per = numVal('standard_tp');
|
|
let standard_tep_per = numVal('standard_tep');
|
|
|
|
let gst_amount = numVal('gst_amount');
|
|
|
|
// Premiums for calculation
|
|
let base_premium = ($('#bro_payable_by').val() == 1) ? bp : cop;
|
|
let third_part_premium = ($('#bro_payable_by').val() == 1) ? tp : cotp;
|
|
let terrisom_premium = ($('#bro_payable_by').val() == 1) ? tep : cotep;
|
|
let tpTotal = base_premium + third_part_premium + terrisom_premium;
|
|
|
|
// Co-premium defaults
|
|
if ($('#cop_yes').val() == 0) {
|
|
if (!rawVal('co_premium')) $('#co_premium_' + input).val(bp);
|
|
if (!rawVal('co_tp_premium') && bap === 'Motor') $('#co_tp_premium_' + input).val(tp);
|
|
if (!rawVal('co_ter_premium') && ['Fire', 'Marine Cargo', 'Marine Hull'].includes(bap)) $('#co_ter_premium_' + input).val(tep);
|
|
if (!rawVal('co_share_per')) $('#co_share_per_' + input).val(100);
|
|
}
|
|
|
|
// GST Calculations
|
|
let ncpaTotal = tpTotal + ncpa;
|
|
let gst_per_amt = (tpTotal * gst_per) / 100;
|
|
let ncpa_gst_per_amt = (ncpaTotal * gst_per) / 100;
|
|
|
|
let gstValue =
|
|
event.target?.id?.startsWith('non_comm_per_amt') ? ncpa_gst_per_amt :
|
|
event.target?.id?.startsWith('gst_amount') ? gst_amount :
|
|
ncpa ? ncpa_gst_per_amt : gst_per_amt;
|
|
|
|
$('#gst_amount_' + input).val(isFinite(gstValue) ? gstValue : 0);
|
|
|
|
// Final total
|
|
let finalTotal = tpTotal + gst_per_amt + stamp_duty_amt;
|
|
$('#total_amt_' + input).val(isFinite(finalTotal) ? finalTotal : 0);
|
|
|
|
// Expected amount
|
|
let expectedAmount = 0;
|
|
let sum_agreed_per = agreed_bp_per + agreed_tp_per + agreed_tep_per;
|
|
|
|
if (agreed_amount > 0) {
|
|
expectedAmount = agreed_amount;
|
|
} else if (sum_agreed_per > 0) {
|
|
expectedAmount =
|
|
(base_premium * agreed_bp_per) / 100 +
|
|
(third_part_premium * agreed_tp_per) / 100 +
|
|
(terrisom_premium * agreed_tep_per) / 100;
|
|
} else {
|
|
expectedAmount =
|
|
(base_premium * standard_bp_per) / 100 +
|
|
(third_part_premium * standard_tp_per) / 100 +
|
|
(terrisom_premium * standard_tep_per) / 100;
|
|
}
|
|
|
|
$('#exp_amt_' + input).val(isFinite(expectedAmount) ? expectedAmount : 0);
|
|
|
|
setCoPremiums(input);
|
|
|
|
// ✅ Apply deletion symbols last (safely);
|
|
// if (isDeletion) {
|
|
applyDeletionSymbolsToFields(input, isDeletion);
|
|
// }
|
|
|
|
console.log('############################## END AMOUNT CALCULATION ############################################');
|
|
}
|
|
|
|
// Apply Deletion (Negative) Values
|
|
function applyDeletionSymbolsToFields(input, isDeletion) {
|
|
|
|
console.log('========== APPLYING DELETION SYMBOLS ==========');
|
|
|
|
const fieldIds = [
|
|
'base_premium',
|
|
'tp_premium',
|
|
'ter_premium',
|
|
'co_premium',
|
|
'co_tp_premium',
|
|
'co_ter_premium',
|
|
'gst_amount',
|
|
'agreed_amount',
|
|
'non_comm_per_amt',
|
|
'total_amt',
|
|
'exp_amt'
|
|
];
|
|
|
|
fieldIds.forEach(field => {
|
|
const $el = $('#' + field + '_' + input);
|
|
let val = $el.val()?.trim();
|
|
if (!val) return;
|
|
|
|
let num = parseFloat(val.replace(/^-/, '')); // remove any existing minus first
|
|
console.log('num', num);
|
|
if (isNaN(num)) return;
|
|
|
|
if (isDeletion) {
|
|
// Apply minus sign
|
|
if (num > 0) $el.val(-num);
|
|
} else {
|
|
// Remove minus sign
|
|
$el.val(num);
|
|
}
|
|
});
|
|
|
|
console.log('========== COMPLETED DELETION SYMBOL APPLICATION ==========');
|
|
}
|
|
|
|
function setCoPremiums(input) {
|
|
// Get base, TP, and TEP premiums for the given input row
|
|
let bp = parseFloat($('#base_premium_' + input).val()) || 0;
|
|
let tp = parseFloat($('#tp_premium_' + input).val()) || 0;
|
|
let tep = parseFloat($('#ter_premium_' + input).val()) || 0;
|
|
let coSharePer = parseFloat($('#co_share_per_' + input).val()) || 0;
|
|
|
|
// Calculate co-share premiums
|
|
let cop = (bp * coSharePer) / 100;
|
|
let cotp = (tp * coSharePer) / 100;
|
|
let cotep = (tep * coSharePer) / 100;
|
|
|
|
// Log for debugging
|
|
console.log(`Row: ${input}`);
|
|
console.log(`Base Premium: ${bp}`);
|
|
console.log(`TP Premium: ${tp}`);
|
|
console.log(`TEP Premium: ${tep}`);
|
|
console.log(`Co-Share %: ${coSharePer}`);
|
|
console.log(`Co Base Premium: ${cop.toFixed(2)}`);
|
|
console.log(`Co TP Premium: ${cotp.toFixed(2)}`);
|
|
console.log(`Co TEP Premium: ${cotep.toFixed(2)}`);
|
|
|
|
// Set calculated values
|
|
$('#co_premium_' + input).val(cop.toFixed(2));
|
|
$('#co_tp_premium_' + input).val(cotp.toFixed(2));
|
|
$('#co_ter_premium_' + input).val(cotep.toFixed(2));
|
|
}
|
|
|
|
function actualAmountCalculation(input, field = null){
|
|
|
|
console.log('actualAmountCalculation function called')
|
|
console.log('actualAmountCalculation function input', input)
|
|
console.log('actualAmountCalculation function field', field)
|
|
|
|
let selectedOption = $('#client_policy_id').find('option:selected');
|
|
let bap = selectedOption.data('bap');
|
|
|
|
console.log('actualAmountCalculation function bap', bap)
|
|
|
|
let actual_bp_amt = parseFloat($('#actual_bp_amt_' + input).val()) || 0;
|
|
let actual_tp_amt = parseFloat($('#actual_tp_amt_' + input).val()) || 0;
|
|
let actual_tep_amt = parseFloat($('#actual_tep_amt_' + input).val()) || 0;
|
|
|
|
let actual_bp_per = parseFloat($('#actual_bp_per_' + input).val()) || 0;
|
|
let actual_tp_per = parseFloat($('#actual_tp_per_' + input).val()) || 0;
|
|
let actual_tep_per = parseFloat($('#actual_tep_per_' + input).val()) || 0;
|
|
|
|
let actual_bp_brokerage_amt = parseFloat($('#actual_bp_brokerage_amt_' + input).val()) || 0;
|
|
let actual_tp_brokerage_amt = parseFloat($('#actual_tp_brokerage_amt_' + input).val()) || 0;
|
|
let actual_tep_brokerage_amt = parseFloat($('#actual_tep_brokerage_amt_' + input).val()) || 0;
|
|
|
|
//------------------------------------------------------------------------------------------
|
|
|
|
if (field === 'bp_per') {
|
|
console.log()
|
|
if (actual_bp_amt > 0 && actual_bp_per >= 0) {
|
|
let actual_bp_brokerage_amount = (actual_bp_amt * actual_bp_per) / 100;
|
|
// $('#actual_bp_brokerage_amt_' + input).val(actual_bp_brokerage_amount.toFixed(2));
|
|
$('#actual_bp_brokerage_amt_' + input).val(!isNaN(actual_bp_brokerage_amount) && isFinite(actual_bp_brokerage_amount) ? actual_bp_brokerage_amount.toFixed(2) : '0.00');
|
|
|
|
}
|
|
} else if (field === 'bp_broker_amt') {
|
|
// If brokerage amount is changed, update percentage
|
|
if (actual_bp_amt > 0 && actual_bp_brokerage_amt >= 0) {
|
|
let actual_bp_percentage = (actual_bp_brokerage_amt / actual_bp_amt) * 100;
|
|
// $('#actual_bp_per_' + input).val(actual_bp_percentage.toFixed(2));
|
|
$('#actual_bp_per_' + input).val(!isNaN(actual_bp_percentage) && isFinite(actual_bp_percentage) ? actual_bp_percentage.toFixed(2) : '0.00');
|
|
|
|
}
|
|
} else if (field === 'bp_amt_for_calc') {
|
|
|
|
if(actual_bp_per > 0){
|
|
|
|
if (actual_bp_amt > 0 && actual_bp_per >= 0) {
|
|
let actual_bp_brokerage_amount = (actual_bp_amt * actual_bp_per) / 100;
|
|
// $('#actual_bp_brokerage_amt_' + input).val(actual_bp_brokerage_amount.toFixed(2));
|
|
$('#actual_bp_brokerage_amt_' + input).val(!isNaN(actual_bp_brokerage_amount) && isFinite(actual_bp_brokerage_amount) ? actual_bp_brokerage_amount.toFixed(2) : '0.00');
|
|
}
|
|
|
|
}else if(actual_bp_brokerage_amt > 0){
|
|
|
|
if (actual_bp_amt > 0 && actual_bp_brokerage_amt >= 0) {
|
|
let actual_bp_percentage = (actual_bp_brokerage_amt / actual_bp_amt) * 100;
|
|
// $('#actual_bp_per_' + input).val(actual_bp_percentage.toFixed(2));
|
|
$('#actual_bp_per_' + input).val(!isNaN(actual_bp_percentage) && isFinite(actual_bp_percentage) ? actual_bp_percentage.toFixed(2) : '0.00');
|
|
}
|
|
|
|
}else{
|
|
|
|
if (actual_bp_amt > 0 && actual_bp_per >= 0) {
|
|
let actual_bp_brokerage_amount = (actual_bp_amt * actual_bp_per) / 100;
|
|
// $('#actual_bp_brokerage_amt_' + input).val(actual_bp_brokerage_amount.toFixed(2));
|
|
$('#actual_bp_brokerage_amt_' + input).val(!isNaN(actual_bp_brokerage_amount) && isFinite(actual_bp_brokerage_amount) ? actual_bp_brokerage_amount.toFixed(2) : '0.00');
|
|
}
|
|
|
|
if (actual_bp_amt > 0 && actual_bp_brokerage_amt >= 0) {
|
|
let actual_bp_percentage = (actual_bp_brokerage_amt / actual_bp_amt) * 100;
|
|
// $('#actual_bp_per_' + input).val(actual_bp_percentage.toFixed(2));
|
|
$('#actual_bp_per_' + input).val(!isNaN(actual_bp_percentage) && isFinite(actual_bp_percentage) ? actual_bp_percentage.toFixed(2) : '0.00');
|
|
}
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------------------
|
|
|
|
if(bap == 'Motor'){
|
|
|
|
if (field === 'tp_per') {
|
|
if (actual_tp_amt > 0 && actual_tp_per >= 0) {
|
|
let actual_tp_brokerage_amount = (actual_tp_amt * actual_tp_per) / 100;
|
|
// $('#actual_tp_brokerage_amt_' + input).val(actual_tp_brokerage_amount.toFixed(2));
|
|
$('#actual_tp_brokerage_amt_' + input).val(!isNaN(actual_tp_brokerage_amount) && isFinite(actual_tp_brokerage_amount) ? actual_tp_brokerage_amount.toFixed(2) : '0.00');
|
|
}
|
|
} else if (field === 'tp_broker_amt') {
|
|
// If brokerage amount is changed, update percentage
|
|
if (actual_tp_amt > 0 && actual_tp_brokerage_amt >= 0) {
|
|
let actual_tp_percentage = (actual_tp_brokerage_amt / actual_tp_amt) * 100;
|
|
// $('#actual_tp_per_' + input).val(actual_tp_percentage.toFixed(2));
|
|
$('#actual_tp_per_' + input).val(!isNaN(actual_tp_percentage) && isFinite(actual_tp_percentage) ? actual_tp_percentage.toFixed(2) : '0.00');
|
|
}
|
|
} else if (field === 'tp_amt_for_calc') {
|
|
|
|
if(actual_tp_amt > 0){
|
|
|
|
if (actual_tp_amt > 0 && actual_tp_per >= 0) {
|
|
let actual_tp_brokerage_amount = (actual_tp_amt * actual_tp_per) / 100;
|
|
// $('#actual_tp_brokerage_amt_' + input).val(actual_tp_brokerage_amount.toFixed(2));
|
|
$('#actual_tp_brokerage_amt_' + input).val(!isNaN(actual_tp_brokerage_amount) && isFinite(actual_tp_brokerage_amount) ? actual_tp_brokerage_amount.toFixed(2) : '0.00');
|
|
|
|
}
|
|
|
|
}else if(actual_tp_brokerage_amt > 0){
|
|
|
|
if (actual_tp_amt > 0 && actual_tp_brokerage_amt >= 0) {
|
|
let actual_tp_percentage = (actual_tp_brokerage_amt / actual_tp_amt) * 100;
|
|
// $('#actual_tp_per_' + input).val(actual_tp_percentage.toFixed(2));
|
|
$('#actual_tp_per_' + input).val(!isNaN(actual_tp_percentage) && isFinite(actual_tp_percentage) ? actual_tp_percentage.toFixed(2) : '0.00');
|
|
}
|
|
|
|
}else{
|
|
if (actual_tp_amt > 0 && actual_tp_per >= 0) {
|
|
let actual_tp_brokerage_amount = (actual_tp_amt * actual_tp_per) / 100;
|
|
// $('#actual_tp_brokerage_amt_' + input).val(actual_tp_brokerage_amount.toFixed(2));
|
|
$('#actual_tp_brokerage_amt_' + input).val(!isNaN(actual_tp_brokerage_amount) && isFinite(actual_tp_brokerage_amount) ? actual_tp_brokerage_amount.toFixed(2) : '0.00');
|
|
}
|
|
|
|
if (actual_tp_amt > 0 && actual_tp_brokerage_amt >= 0) {
|
|
let actual_tp_percentage = (actual_tp_brokerage_amt / actual_tp_amt) * 100;
|
|
// $('#actual_tp_per_' + input).val(actual_tp_percentage.toFixed(2));
|
|
$('#actual_tp_per_' + input).val(!isNaN(actual_tp_percentage) && isFinite(actual_tp_percentage) ? actual_tp_percentage.toFixed(2) : '0.00');
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
}else{
|
|
|
|
$('#actual_tp_brokerage_amt_' + input).val(0);
|
|
$('#actual_tp_per_' + input).val(0);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------------------
|
|
|
|
|
|
if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
|
|
|
|
if (field === 'tep_per') {
|
|
if (actual_tep_amt > 0 && actual_tep_per >= 0) {
|
|
let actual_tep_brokerage_amount = (actual_tep_amt * actual_tep_per) / 100;
|
|
// $('#actual_tep_brokerage_amt_' + input).val(actual_tep_brokerage_amount.toFixed(2));
|
|
$('#actual_tep_brokerage_amt_' + input).val(!isNaN(actual_tep_brokerage_amount) && isFinite(actual_tep_brokerage_amount) ? actual_tep_brokerage_amount.toFixed(2) : '0.00');
|
|
|
|
}
|
|
} else if (field === 'tep_broker_amt') {
|
|
// If brokerage amount is changed, update percentage
|
|
if (actual_tep_amt > 0 && actual_tep_brokerage_amt >= 0) {
|
|
let actual_tep_percentage = (actual_tep_brokerage_amt / actual_tep_amt) * 100;
|
|
// $('#actual_tep_per_' + input).val(actual_tep_percentage.toFixed(2));
|
|
$('#actual_tep_per_' + input).val(!isNaN(actual_tep_percentage) && isFinite(actual_tep_percentage) ? actual_tep_percentage.toFixed(2) : '0.00');
|
|
|
|
}
|
|
} else if (field === 'tep_amt_for_calc') {
|
|
|
|
if(actual_tep_amt > 0){
|
|
|
|
if (actual_tep_amt > 0 && actual_tep_per >= 0) {
|
|
let actual_tep_brokerage_amount = (actual_tep_amt * actual_tep_per) / 100;
|
|
// $('#actual_tep_brokerage_amt_' + input).val(actual_tep_brokerage_amount.toFixed(2));
|
|
$('#actual_tep_brokerage_amt_' + input).val(!isNaN(actual_tep_brokerage_amount) && isFinite(actual_tep_brokerage_amount) ? actual_tep_brokerage_amount.toFixed(2) : '0.00');
|
|
|
|
}
|
|
|
|
}else if(actual_tep_brokerage_amt > 0){
|
|
|
|
if (actual_tep_amt > 0 && actual_tep_brokerage_amt >= 0) {
|
|
let actual_tep_percentage = (actual_tep_brokerage_amt / actual_tep_amt) * 100;
|
|
// $('#actual_tep_per_' + input).val(actual_tep_percentage.toFixed(2));
|
|
$('#actual_tep_per_' + input).val(!isNaN(actual_tep_percentage) && isFinite(actual_tep_percentage) ? actual_tep_percentage.toFixed(2) : '0.00');
|
|
}
|
|
|
|
}else{
|
|
|
|
if (actual_tep_amt > 0 && actual_tep_per >= 0) {
|
|
let actual_tep_brokerage_amount = (actual_tep_amt * actual_tep_per) / 100;
|
|
// $('#actual_tep_brokerage_amt_' + input).val(actual_tep_brokerage_amount.toFixed(2));
|
|
$('#actual_tep_brokerage_amt_' + input).val(!isNaN(actual_tep_brokerage_amount) && isFinite(actual_tep_brokerage_amount) ? actual_tep_brokerage_amount.toFixed(2) : '0.00');
|
|
}
|
|
|
|
if (actual_tep_amt > 0 && actual_tep_brokerage_amt >= 0) {
|
|
let actual_tep_percentage = (actual_tep_brokerage_amt / actual_tep_amt) * 100;
|
|
// $('#actual_tep_per_' + input).val(actual_tep_percentage.toFixed(2));
|
|
$('#actual_tep_per_' + input).val(!isNaN(actual_tep_percentage) && isFinite(actual_tep_percentage) ? actual_tep_percentage.toFixed(2) : '0.00');
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
$('#actual_tep_brokerage_amt_' + input).val(0);
|
|
$('#actual_tep_per_' + input).val(0);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------------------
|
|
|
|
let expectedAmount = parseFloat($('#exp_amt_' + input).val()) || 0;
|
|
var actual_bp_brokerage_amount2 = parseFloat($('#actual_bp_brokerage_amt_' + input).val()) || 0;
|
|
let actual_tp_brokerage_amount2 = parseFloat($('#actual_tp_brokerage_amt_' + input).val()) || 0;
|
|
let actual_tep_brokerage_amount2 = parseFloat($('#actual_tep_brokerage_amt_' + input).val()) || 0;
|
|
|
|
// let variance = expectedAmount - (actual_bp_brokerage_amount2 + actual_tp_brokerage_amount2 + actual_tep_brokerage_amount2)
|
|
let variance = (actual_bp_brokerage_amount2 + actual_tp_brokerage_amount2 + actual_tep_brokerage_amount2) - expectedAmount
|
|
|
|
// $('#variance_' + input).val(variance.toFixed(2));
|
|
$('#variance_' + input).val(!isNaN(variance) && isFinite(variance) ? variance.toFixed(2) : '0.00');
|
|
|
|
// console.log('expectedAmount', expectedAmount);
|
|
// console.log('variance', variance);
|
|
}
|
|
|
|
function co_share_percentage_calculation(input, extra = null){
|
|
|
|
console.log('input', input)
|
|
var inputs = $('input[name="co_share_per[]"]'); // Specifically select input elements
|
|
console.log('Number of inputs:', inputs.length);
|
|
|
|
let insurer_count = insurer_count_array.length;
|
|
console.log('insurer_count', insurer_count);
|
|
console.log('insurer_count_array', insurer_count_array);
|
|
|
|
if(input){
|
|
if(insurer_count == 2){
|
|
|
|
// Find the index of the value
|
|
let index = insurer_count_array.indexOf(Number(input));
|
|
let second_value_index = "";
|
|
|
|
if (index !== -1) {
|
|
|
|
console.log(`Value ${input} exists at index ${index}.`);
|
|
|
|
let beforeValue = index > 0 ? insurer_count_array[index - 1] : null;
|
|
let afterValue = index < insurer_count_array.length - 1 ? insurer_count_array[index + 1] : null;
|
|
|
|
if (beforeValue != null) {
|
|
second_value_index = beforeValue;
|
|
} else if (afterValue != null) {
|
|
second_value_index = afterValue;
|
|
}
|
|
|
|
}
|
|
|
|
let value1 = $('#co_share_per_' + input).val();
|
|
let value2 = $('#co_share_per_' + second_value_index).val();
|
|
|
|
value1 = Number(value1);
|
|
value2 = Number(value2);
|
|
|
|
console.log('value1', value1);
|
|
console.log('value2', value2);
|
|
|
|
if(extra == "add"){
|
|
|
|
if(value2 == 0){
|
|
value1 = 50;
|
|
value2 = 50;
|
|
}else{
|
|
if(value2 == 100){
|
|
value1 = 50;
|
|
value2 = 50;
|
|
}else{
|
|
value1 = 100 - value2;
|
|
}
|
|
}
|
|
|
|
}else{
|
|
|
|
if(value1 == 100){
|
|
value2 = 0;
|
|
}else{
|
|
value2 = 100 - value1;
|
|
}
|
|
}
|
|
|
|
console.log('value1', value1);
|
|
console.log('value2', value2);
|
|
|
|
$('#co_share_per_' + input).val(value1);
|
|
$('#co_share_per_' + second_value_index).val(value2);
|
|
|
|
}else if(insurer_count > 2){
|
|
|
|
let total_val = 0;
|
|
|
|
// Calculate the total sum of input values
|
|
inputs.each(function () {
|
|
let val = Number($(this).val()) || 0;
|
|
if(val == 0){
|
|
$(this).val(0)
|
|
}
|
|
total_val += val;
|
|
});
|
|
}
|
|
|
|
}else{
|
|
inputs.each(function (index) {
|
|
if (inputs.length === 1) {
|
|
$(this).val(100);
|
|
} else if(inputs.length === 2) {
|
|
let first = $('#co_share_per_1').val();
|
|
first = Number(first)
|
|
let second_val = 100 - first;
|
|
|
|
if (index === 1) {
|
|
$(this).val(second_val);
|
|
}
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
let val_sum = 0;
|
|
|
|
inputs.each(function () {
|
|
let val = Number($(this).val()) || 0;
|
|
val_sum += val;
|
|
});
|
|
|
|
if (val_sum > 100) {
|
|
toastr.warning('Sum of the co-share is greater than 100', 'WARNING');
|
|
}
|
|
|
|
}
|
|
|
|
function select_leader_disable_premium_amt(input, value) {
|
|
if ($(input).is(':checked')) {
|
|
// Disable and add readonly-select class to all premiums except the one with the given value
|
|
$('input[name="base_premium[]"]').addClass('readonly-select');
|
|
$('#base_premium_' + value).removeClass('readonly-select');
|
|
|
|
$('input[name="tp_premium[]"]').addClass('readonly-select');
|
|
$('#tp_premium_' + value).removeClass('readonly-select');
|
|
|
|
$('input[name="ter_premium[]"]').addClass('readonly-select');
|
|
$('#ter_premium_' + value).removeClass('readonly-select');
|
|
|
|
$('input[name="stamp_duty[]"]').addClass('readonly-select');
|
|
$('#stamp_duty_' + value).removeClass('readonly-select');
|
|
|
|
$('input[name="co_premium[]"]').addClass('readonly-select');
|
|
$('#co_premium_' + value).removeClass('readonly-select');
|
|
} else {
|
|
// Enable and remove readonly-select class from all premiums except the one with the given value
|
|
$('input[name="base_premium[]"]').removeClass('readonly-select');
|
|
$('input[name="tp_premium[]"]').removeClass('readonly-select');
|
|
$('input[name="ter_premium[]"]').removeClass('readonly-select');
|
|
$('input[name="stamp_duty[]"]').removeClass('readonly-select');
|
|
$('input[name="co_premium[]"]').removeClass('readonly-select');
|
|
}
|
|
}
|
|
|
|
function validateRange(input) {
|
|
// if (input.value < 1) input.value = 1;
|
|
if (input.value > 100) input.value = 100;
|
|
}
|
|
|
|
function checkInvoiceStatusToHideSubmitBtn(id){
|
|
|
|
$.ajax({
|
|
url: '<?php echo base_url('util/checkInvoiceStatus/');?>'+ id,
|
|
type: "GET",
|
|
dataType: 'json',
|
|
success: function (res) {
|
|
|
|
console.log(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 getpolicyDataForEndorsement(input){
|
|
|
|
var client_policy_id = $(input).val();
|
|
console.log(client_policy_id);
|
|
|
|
if(client_policy_id){
|
|
$.ajax({
|
|
url: '<?php echo base_url('util/get_client_policy_data_using_client_policy_id/');?>'+ client_policy_id,
|
|
type: "GET",
|
|
dataType: 'json',
|
|
success: function (res) {
|
|
|
|
console.log(res)
|
|
if(res.status == true){
|
|
$('#ct_type').val(1)
|
|
}else{
|
|
$('#ct_type').val(2)
|
|
console.log(res.message, 'warning');
|
|
}
|
|
},
|
|
error: function (xhr, status, error) {
|
|
console.error(xhr.responseText);
|
|
console.error(status, error);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
//---------------------------------------------------------------------------------------------------------
|
|
|
|
var insurerCount = 0;
|
|
|
|
function addInsurerColumn() {
|
|
|
|
insurerCount++;
|
|
|
|
// Update header
|
|
$('#insurerTable thead tr').append(`
|
|
<th>
|
|
<span style="display:flex; justify-content:space-between; align-items:center;">
|
|
Insurer ${insurerCount}
|
|
${insurerCount > 1 ? `<a class="text-danger mdi mdi-delete delete-insurer" data-count="${insurerCount}" style="margin-left: 135px;"></a>` : ''}
|
|
</span>
|
|
</th>
|
|
`);
|
|
|
|
// Add a new column for each data row
|
|
$('#insurerTable tbody tr').each(function(index) {
|
|
let newCell = '';
|
|
|
|
if(role_id == 1 || role_id == 5 || team_id.includes('6') || team_id.includes('4')){
|
|
|
|
switch(index) {
|
|
|
|
case 0: // Insurer selection
|
|
newCell = `<td>
|
|
<select class="form-control follow_insurer readonly-select" data-count="${insurerCount}" id="follow_insurer_id_${insurerCount}" name="follow_insurer_id[]">
|
|
<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><input data-id="${insurerCount}" id="co_share_type_${insurerCount}" type="text" name="co_share_type[]" onchange="select_leader_disable_premium_amt(this, '${insurerCount}')"></td>`;
|
|
break;
|
|
case 2: // CD Account Number selectionclass="std_tp_td"
|
|
newCell = `<td class=""><input type="text" class="readonly-color" id="cd_account_no_${insurerCount}" readonly></td>`;
|
|
break;
|
|
case 3: // CD Amount
|
|
newCell = `<td class=""><input type="text" class="readonly-color right-align-input" id="cd_current_balance_${insurerCount}" readonly></td>`;
|
|
break;
|
|
case 4: // follower policy no
|
|
newCell = `<td class=""><input type="text" class="readonly-color" id="follower_policy_no_${insurerCount}" name="follower_policy_no[]" readonly></td>`;
|
|
break;
|
|
case 5: // calc_policy_issue_date
|
|
newCell = `<td class=""><input type="text" class="" id="calc_policy_issue_date_${insurerCount}" name="calc_policy_issue_date[]"></td>`;
|
|
break;
|
|
case 6: // Co-Share %
|
|
newCell = `<td class="input-with-percentage"><input type="text" id="co_share_per_${insurerCount}" class="right-align-input" name="co_share_per[]" oninput="validateRange(this)" onchange="co_share_percentage_calculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
|
break;
|
|
case 7: // Non commissionable Premium amount %
|
|
newCell = `<td><input type="text" class="right-align-input" id="non_comm_per_amt_${insurerCount}" name="non_comm_per_amt[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
|
break;
|
|
case 8: // 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 9: // 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 10: // 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 11: // 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 12: // Co TP Premium
|
|
newCell = `<td><input type="text" class="right-align-input" id="co_tp_premium_${insurerCount}" name="co_tp_premium[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
|
|
break;
|
|
case 13: // Co Ter Premium
|
|
newCell = `<td><input type="text" class="right-align-input" id="co_ter_premium_${insurerCount}" name="co_ter_premium[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
|
|
break;
|
|
|
|
case 14: // 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 15: // 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 16: // 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 17: // GST Amount
|
|
newCell = `<td><input type="text" class="right-align-input" id="gst_amount_${insurerCount}" name="gst_amount[]" onchange="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
|
break;
|
|
case 18: // 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 19: // 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 20: // Agreed BP %
|
|
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="agreed_bp_${insurerCount}" name="agreed_bp[]" oninput="amountCalculation('${insurerCount}'); validateRange(this)" onkeypress="return onlyNumbers(event)" ></td>`;
|
|
break;
|
|
case 21: // Agreed TP %
|
|
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="agreed_tp_${insurerCount}" name="agreed_tp[]" oninput="amountCalculation('${insurerCount}'); validateRange(this)" onkeypress="return onlyNumbers(event)"></td>`;
|
|
break;
|
|
case 22: // Agreed Ter %
|
|
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="agreed_tep_${insurerCount}" name="agreed_ter[]" oninput="amountCalculation('${insurerCount}'); validateRange(this)" onkeypress="return onlyNumbers(event)" ></td>`;
|
|
break;
|
|
case 23: // 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 24: // Standard BP %
|
|
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-color right-align-input" id="standard_bp_${insurerCount}" name="standard_bp[]" onkeypress="return onlyNumbers(event)" readonly></td>`;
|
|
break;
|
|
case 25: // 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 26: // 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 27: // Actual BP Amount
|
|
newCell = `<td><input type="text" class="readonly-select 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 28: // Actual TP Amount
|
|
newCell = `<td><input type="text" class="readonly-select 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 29: // Actual TEP Amount
|
|
newCell = `<td><input type="text" class="readonly-select 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 30: // Actual BP %
|
|
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-select right-align-input" id="actual_bp_per_${insurerCount}" name="actual_bp_per[]" onchange="actualAmountCalculation('${insurerCount}', 'bp_per')" onkeypress="return onlyNumbers(event)"></td>`;
|
|
break;
|
|
case 31: // Actual TP %
|
|
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-select right-align-input" id="actual_tp_per_${insurerCount}" name="actual_tp_per[]" onchange="actualAmountCalculation('${insurerCount}', 'tp_per')" onkeypress="return onlyNumbers(event)"></td>`;
|
|
break;
|
|
case 32: // Actual TEP %
|
|
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-select right-align-input" id="actual_tep_per_${insurerCount}" name="actual_tep_per[]" onchange="actualAmountCalculation('${insurerCount}', 'tep_per')" onkeypress="return onlyNumbers(event)"></td>`;
|
|
break;
|
|
case 33: // Actual BP Brokerage Amount
|
|
newCell = `<td><input type="text" class="readonly-select 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 34: // Actual TP Brokerage Amount
|
|
newCell = `<td><input type="text" class="readonly-select 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 35: // Actual TEP Brokerage Amount
|
|
newCell = `<td><input type="text" class="readonly-select 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 36: // Expected Amount
|
|
newCell = `<td><input type="text" class="readonly-select right-align-input" id="exp_amt_${insurerCount}" name="exp_amt[]" onchange="actualAmountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
|
break;
|
|
// case 30: // 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 31: // Reward
|
|
// newCell = `<td><input type="text" class="right-align-input" id="reward_${insurerCount}" name="reward[]" onkeypress="return onlyNumbers(event)"></td>`;
|
|
// break;
|
|
case 37: // ID For Update
|
|
newCell = `<td><input type="hidden" name="co_share_id[]" id="co_share_id[]" onkeypress="return onlyNumbers(event)"></td>`;
|
|
break;
|
|
}
|
|
|
|
}else if(team_id.includes('3') || team_id.includes('8')){
|
|
|
|
switch(index) {
|
|
case 0: // Insurer selection
|
|
newCell = `<td>
|
|
<select class="form-control follow_insurer readonly-select" data-count="${insurerCount}" id="follow_insurer_id_${insurerCount}" name="follow_insurer_id[]">
|
|
<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><input data-id="${insurerCount}" id="co_share_type_${insurerCount}" type="text" name="co_share_type[]" onchange="select_leader_disable_premium_amt(this, '${insurerCount}')"></td>`;
|
|
break;
|
|
case 2: // CD Account Number selectionclass="std_tp_td"
|
|
newCell = `<td class=""><input type="text" class="readonly-color" id="cd_account_no_${insurerCount}" readonly></td>`;
|
|
break;
|
|
case 3: // CD Amount
|
|
newCell = `<td class=""><input type="text" class="readonly-color right-align-input" id="cd_current_balance_${insurerCount}" readonly></td>`;
|
|
break;
|
|
case 4: // follower policy no
|
|
newCell = `<td class=""><input type="text" class="readonly-color" id="follower_policy_no_${insurerCount}" name="follower_policy_no[]" readonly></td>`;
|
|
break;
|
|
case 5: // calc_policy_issue_date
|
|
newCell = `<td class=""><input type="text" class="" id="calc_policy_issue_date_${insurerCount}" name="calc_policy_issue_date[]"></td>`;
|
|
break;
|
|
case 6: // Co-Share %
|
|
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" name="co_share_per[]" oninput="validateRange(this)" onchange="co_share_percentage_calculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
|
break;
|
|
case 7: // Non commissionable Premium amount %
|
|
newCell = `<td><input type="text" class="right-align-input" id="non_comm_per_amt_${insurerCount}" name="non_comm_per_amt[]" oninput="amountCalculation('${insurerCount}')" onkeypress="return onlyNumbers(event)"></td>`;
|
|
break;
|
|
case 8: // 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 9: // 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 10: // 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 11: // 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 12: // Co TP Premium
|
|
newCell = `<td><input type="text" class="right-align-input" id="co_tp_premium_${insurerCount}" name="co_tp_premium[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
|
|
break;
|
|
case 13: // Co Ter Premium
|
|
newCell = `<td><input type="text" class="right-align-input" id="co_ter_premium_${insurerCount}" name="co_ter_premium[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
|
|
break;
|
|
|
|
case 14: // 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 15: // 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 16: // 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 17: // 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 18: // 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 19: // 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 20: // Agreed BP %
|
|
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="agreed_bp_${insurerCount}" name="agreed_bp[]" oninput="amountCalculation('${insurerCount}'); validateRange(this)" onkeypress="return onlyNumbers(event)" ></td>`;
|
|
break;
|
|
case 21: // Agreed TP %
|
|
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="agreed_tp_${insurerCount}" name="agreed_tp[]" oninput="amountCalculation('${insurerCount}'); validateRange(this)" onkeypress="return onlyNumbers(event)"></td>`;
|
|
break;
|
|
case 22: // Agreed Ter %
|
|
newCell = `<td class="input-with-percentage"><input type="text" class="right-align-input" id="agreed_tep_${insurerCount}" name="agreed_ter[]" oninput="amountCalculation('${insurerCount}'); validateRange(this)" onkeypress="return onlyNumbers(event)" ></td>`;
|
|
break;
|
|
case 23: // Standard BP %
|
|
newCell = `<td class="input-with-percentage"><input type="text" class="readonly-color right-align-input" id="standard_bp_${insurerCount}" name="standard_bp[]" onkeypress="return onlyNumbers(event)" readonly></td>`;
|
|
break;
|
|
case 24: // 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 25: // 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 26: // ID For Update
|
|
newCell = `<td><input type="hidden" name="co_share_id[]" id="co_share_id[]" onkeypress="return onlyNumbers(event)"></td>`;
|
|
break;
|
|
}
|
|
}
|
|
|
|
// console.log(newCell);
|
|
|
|
$(this).append(newCell);
|
|
|
|
// $('#follow_insurer_id_' + insurerCount).select2()
|
|
|
|
var selectedOption = $('#client_policy_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');
|
|
var allocg = selectedOption.data('allocg');
|
|
console.log('allocg:', allocg);
|
|
|
|
|
|
var client_type_id = $('#client_type').val() ?? 1;
|
|
var is_co_pay_yes = $('#cop_yes').val();
|
|
if(is_co_pay_yes == "" || is_co_pay_yes == null){
|
|
is_co_pay_yes = 0;
|
|
}
|
|
console.log('#cop_yes', $('#cop_yes').val());
|
|
console.log('is_co_pay_yes', is_co_pay_yes);
|
|
|
|
// do not remove this commented items
|
|
// if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
|
|
// $('.hideter').show();
|
|
// $('.hidetp').hide();
|
|
|
|
// if(is_co_pay_yes == 1){
|
|
// $('#table_tr_7').show();
|
|
// $('#table_tr_3').show();
|
|
// $('.hidecoter').show()
|
|
// $('.hidecotp').hide()
|
|
// }else{
|
|
// $('#table_tr_7').hide();
|
|
// $('#table_tr_3').hide();
|
|
// $('.hidecoter').hide()
|
|
// $('.hidecotp').hide()
|
|
// }
|
|
|
|
// }else{
|
|
// if(bap == 'Motor'){
|
|
|
|
// $('.hidetp').show()
|
|
// $('.hideter').hide()
|
|
|
|
// if(is_co_pay_yes == 1){
|
|
// $('#table_tr_7').show();
|
|
// $('#table_tr_3').show();
|
|
// $('.hidecotp').show();
|
|
// $('.hidecoter').hide();
|
|
// }else{
|
|
// $('#table_tr_7').hide();
|
|
// $('#table_tr_3').hide();
|
|
// $('.hidecoter').hide();
|
|
// $('.hidecotp').hide();
|
|
// }
|
|
|
|
// }else{
|
|
// $('.hideter').hide()
|
|
// $('.hidetp').hide()
|
|
// $('.hidecoter').hide()
|
|
// $('.hidecotp').hide()
|
|
// }
|
|
// }
|
|
|
|
// if(allocg == "EB"){
|
|
// $('.hideter').hide();
|
|
// $('.hidetp').hide();
|
|
// $('.hidecoter').hide()
|
|
// $('.hidecotp').hide()
|
|
// }else{
|
|
|
|
// $('.hidetp').show();
|
|
// if(is_co_pay_yes == 1){
|
|
// $('.hidecotp').show();
|
|
// $('#table_tr_7').show();
|
|
// $('#table_tr_35').show();
|
|
// $('#table_tr_3').show();
|
|
// }else{
|
|
// $('.hidecotp').hide();
|
|
// $('#table_tr_7').hide();
|
|
// $('#table_tr_35').hide();
|
|
// $('#table_tr_3').hide();
|
|
// }
|
|
|
|
// if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
|
|
// $('.hideter').show();
|
|
// if(is_co_pay_yes == 1){
|
|
// $('.hidecoter').show();
|
|
// }else{
|
|
// $('.hidecoter').hide();
|
|
// }
|
|
// }else{
|
|
// $('.hideter').hide();
|
|
// }
|
|
// }
|
|
|
|
if(allocg == "EB"){
|
|
|
|
$('.hideter').hide();
|
|
$('.hidetp').hide();
|
|
$('.hidecoter').hide()
|
|
$('.hidecotp').hide()
|
|
|
|
} else if(allocg == "Non-EB"){
|
|
|
|
$('.hidetp').hide();
|
|
$('.hidecotp').hide();
|
|
|
|
$('.hideter').show();
|
|
if(is_co_pay_yes == 1){
|
|
$('.hidecoter').show();
|
|
}else{
|
|
$('.hidecoter').hide();
|
|
}
|
|
|
|
} else if(allocg == "Motor"){
|
|
|
|
$('.hideter').hide();
|
|
$('.hidecoter').hide();
|
|
|
|
$('.hidetp').show();
|
|
if(is_co_pay_yes == 1){
|
|
$('.hidecotp').show();
|
|
}else{
|
|
$('.hidecotp').hide();
|
|
}
|
|
|
|
} else{
|
|
|
|
if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
|
|
$('.hideter').show();
|
|
if(is_co_pay_yes == 1){
|
|
$('.hidecoter').show();
|
|
}else{
|
|
$('.hidecoter').hide();
|
|
}
|
|
}else{
|
|
$('.hideter').hide();
|
|
}
|
|
}
|
|
|
|
var std_bp = 0;
|
|
var std_tp = 0;
|
|
var std_tep = 0;
|
|
|
|
if(client_type_id == 1){
|
|
std_bp = ebp;
|
|
std_tp = etp;
|
|
std_tep = etep;
|
|
}else{
|
|
std_bp = iep;
|
|
std_tp = itp;
|
|
std_tep = itep;
|
|
}
|
|
|
|
// console.log('client_type_id', client_type_id);
|
|
// console.log('std_bp', std_bp);
|
|
// console.log('std_tp', std_tp);
|
|
// console.log('std_tep', std_tep);
|
|
|
|
$('#standard_bp_'+insurerCount).val(std_bp);
|
|
$('[name="standard_tp[]"]').val(std_tp);
|
|
$('[name="standard_tep[]"]').val(std_tep);
|
|
|
|
if(insurerCount > 1){
|
|
$('.follow_insurer').prop('required', true);
|
|
}else{
|
|
$('.follow_insurer').prop('required', false);
|
|
}
|
|
|
|
var calc_policy_issue_date = flatpickr("#calc_policy_issue_date_" + insurerCount, {
|
|
dateFormat: "d/m/Y",
|
|
allowInput: false
|
|
});
|
|
|
|
});
|
|
|
|
// Add click event for delete button
|
|
$('.delete-insurer').off('click').on('click', function() {
|
|
const index = $(this).closest('th').index();
|
|
const count_index = $(this).data('count') || $(this).attr('data-count'); // Ensure data attribute is retrieved
|
|
removeInsurerColumn(index, count_index);
|
|
});
|
|
|
|
}
|
|
|
|
function removeInsurerColumn(index, count_index) {
|
|
// Remove the header
|
|
$('#insurerTable thead tr th').eq(index).remove();
|
|
|
|
// Remove the corresponding data cells in each row
|
|
$('#insurerTable tbody tr').each(function() {
|
|
$(this).find('td').eq(index).remove();
|
|
});
|
|
|
|
insurer_count_array = insurer_count_array.filter(item => item !== count_index);
|
|
|
|
insurerCount--;
|
|
|
|
getColumnIndexes(1);
|
|
|
|
}
|
|
|
|
function removeAllColumnsExceptFirst(tableId) {
|
|
|
|
console.log('######################################')
|
|
console.log('removeAllColumnsExceptFirst function called');
|
|
console.log('######################################');
|
|
|
|
// Remove all headers except the first one
|
|
$('#' + tableId + ' thead tr th').each(function(index) {
|
|
if (index > 0) { // Keep the first column (index 0)
|
|
$(this).remove();
|
|
}
|
|
});
|
|
|
|
// Remove corresponding data cells in each row except the first one
|
|
$('#' + tableId + ' tbody tr').each(function() {
|
|
$(this).find('td').each(function(index) {
|
|
if (index > 0) { // Keep the first column (index 0)
|
|
$(this).remove();
|
|
}
|
|
});
|
|
});
|
|
|
|
insurerCount = 0;
|
|
}
|
|
|
|
function populateTable(dataArray, status = false) {
|
|
|
|
console.log('####################################')
|
|
console.log('populateTable function called')
|
|
console.log('####################################')
|
|
|
|
console.log(dataArray);
|
|
|
|
dataArray.forEach((data, index) => {
|
|
|
|
// Add a new insurer column for each entry in the data array
|
|
addInsurerColumn(); // This will add a new column dynamically
|
|
|
|
let disable_td = false;
|
|
if(data.record_count > 0){
|
|
disable_td = true;
|
|
}
|
|
|
|
// Populate the fields with the provided data
|
|
$('#insurerTable tbody tr').each(function(rowIndex, row) {
|
|
const cell = $(row).find('td').eq(insurerCount); // Get the newly added column by `insurerCount`
|
|
|
|
let insurer = data.insurer_branch_id + '-' + data.insurer_id;
|
|
|
|
if(role_id == 1 || role_id == 5 || team_id.includes('6') || team_id.includes('4')){
|
|
switch (rowIndex) {
|
|
case 0: // Insurer selection
|
|
cell.find('select').val(insurer);
|
|
break;
|
|
case 1: // Is Leader?
|
|
$('#co_share_type_'+(index+1)).val(data.co_share_type ?? '')
|
|
cell.find('input').val(data.co_share_type ?? '');
|
|
break;
|
|
case 2: // CD Account Number
|
|
// console.log('------- CD Account Number -------')
|
|
break;
|
|
case 3: // CD AMOUNT
|
|
// console.log('------- CD AMOUNT -------')
|
|
break;
|
|
case 4: // follower_policy_no
|
|
cell.find('input').val(data.follower_policy_no);
|
|
break;
|
|
case 5: // follower_policy_no
|
|
cell.find('input').val(data.pt_policy_issue_date);
|
|
break;
|
|
case 6: // Co-Share %
|
|
cell.find('input').val(data.co_share_per).toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 7: // non_comm_per_amt
|
|
cell.find('input').val(data.non_comm_per_amt);
|
|
break;
|
|
case 8: // Base Premium
|
|
cell.find('input').val(status ? data.bp_amt : '').toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 9: // TP Premium
|
|
cell.find('input').val(status ? data.tp_amt : '').toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 10: // Ter Premium
|
|
cell.find('input').val(status ? data.tep_amt : '').toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 11: // Co Premium
|
|
cell.find('input').val(status ? data.cop_amt : '').toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 12: // Co TP Premium
|
|
cell.find('input').val(status ? data.cotp_amt : '').toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 13: // Co Ter Premium
|
|
cell.find('input').val(status ? data.cotep_amt : '').toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 14: // CGST
|
|
cell.find('input').val(data.bp_cgst).toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 15: // SGST
|
|
cell.find('input').val(data.bp_sgst).toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 16: // IGST
|
|
cell.find('input').val(data.bp_igst).toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 17: // GST Amount
|
|
cell.find('input').val(status ? data.bp_gst_amt : '').toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 18: // Stamp Duty
|
|
cell.find('input').val(status ? data.stamp_duty : '').toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 19: // Total
|
|
cell.find('input').val(status ? data.amount : '');
|
|
break;
|
|
case 20: // Agreed BP %
|
|
cell.find('input').val(data.agreed_bp_per).toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 21: // Agreed TP %
|
|
cell.find('input').val(data.agreed_tp_per).toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 22: // Agreed Ter %
|
|
cell.find('input').val(data.agreed_tep_per).toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 23: // Agreed Amount
|
|
cell.find('input').val(data.agreed_amt).toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 24: // Standard BP %
|
|
cell.find('input').val(data.standerd_bp_per);
|
|
break;
|
|
case 25: // Standard TP %
|
|
cell.find('input').val(data.standerd_tp_per);
|
|
break;
|
|
case 26: // Standard Ter %
|
|
cell.find('input').val(data.standerd_tep_per);
|
|
break;
|
|
case 27: // Actual BP Amount
|
|
cell.find('input').val(status ? data.actual_bp_amt : '');
|
|
break;
|
|
case 28: // Actual TP Amount
|
|
cell.find('input').val(status ? data.actual_tp_amt : '');
|
|
break;
|
|
case 29: // Actual Ter Amount
|
|
cell.find('input').val(status ? data.actual_tep_amt : '');
|
|
break;
|
|
case 30: // Actual BP %
|
|
cell.find('input').val(status ? data.actual_bp_per : '');
|
|
break;
|
|
case 31: // Actual TP %
|
|
cell.find('input').val(status ? data.actual_tp_per : '');
|
|
break;
|
|
case 32: // Actual Ter %
|
|
cell.find('input').val(status ? data.actual_tep_per : '');
|
|
break;
|
|
case 33: // Actual BP Brokerage Amount
|
|
cell.find('input').val(status ? data.actual_bp_brokerage_amt : '');
|
|
break;
|
|
case 34: // Actual TP Brokerage Amount
|
|
cell.find('input').val(status ? data.actual_tp_brokerage_amt : '');
|
|
break;
|
|
case 35: // Actual Ter Brokerage Amount
|
|
cell.find('input').val(status ? data.actual_tep_brokerage_amt : '');
|
|
break;
|
|
case 36: // Expected Amount
|
|
cell.find('input').val(status ? data.exp_amt : '');
|
|
break;
|
|
// case 30: // Variance
|
|
// cell.find('input').val(status ? data.variance : '');
|
|
// break;
|
|
// case 31: // Reward
|
|
// cell.find('input').val(status ? data.reward : '');
|
|
// break;
|
|
case 37: // Co-share ID (hidden field)
|
|
cell.find('input[type="hidden"]').val(status ? data.id : '');
|
|
break;
|
|
}
|
|
}else if(team_id.includes('3') || team_id.includes('8')){
|
|
switch (rowIndex) {
|
|
case 0: // Insurer selection
|
|
cell.find('select').val(insurer);
|
|
break;
|
|
case 1: // Is Leader?
|
|
$('#co_share_type_'+(index+1)).val(data.co_share_type ?? '')
|
|
cell.find('input').val(data.co_share_type ?? '');
|
|
break;
|
|
case 2: // CD Account Number
|
|
// console.log('------- CD Account Number -------')
|
|
break;
|
|
case 3: // CD AMOUNT
|
|
// console.log('------- CD AMOUNT -------')
|
|
break;
|
|
case 4: // follower_policy_no
|
|
cell.find('input').val(data.follower_policy_no);
|
|
break;
|
|
case 5: // follower_policy_no
|
|
cell.find('input').val(data.pt_policy_issue_date);
|
|
break;
|
|
case 6: // Co-Share %
|
|
cell.find('input').val(data.co_share_per).toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 7: // non_comm_per_amt
|
|
cell.find('input').val(data.non_comm_per_amt);
|
|
break;
|
|
case 8: // Base Premium
|
|
cell.find('input').val(status ? data.bp_amt : '').toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 9: // TP Premium
|
|
cell.find('input').val(status ? data.tp_amt : '').toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 10: // Ter Premium
|
|
cell.find('input').val(status ? data.tep_amt : '').toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 11: // Co Premium
|
|
cell.find('input').val(status ? data.cop_amt : '').toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 12: // Co TP Premium
|
|
cell.find('input').val(status ? data.cotp_amt : '').toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 13: // Co Ter Premium
|
|
cell.find('input').val(status ? data.cotep_amt : '').toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 14: // CGST
|
|
cell.find('input').val(data.bp_cgst).toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 15: // SGST
|
|
cell.find('input').val(data.bp_sgst).toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 16: // IGST
|
|
cell.find('input').val(data.bp_igst).toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 17: // GST Amount
|
|
cell.find('input').val(status ? data.bp_gst_amt : '').toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 18: // Stamp Duty
|
|
cell.find('input').val(status ? data.stamp_duty : '').toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 19: // Total
|
|
cell.find('input').val(status ? data.amount : '');
|
|
break;
|
|
case 20: // Agreed BP %
|
|
cell.find('input').val(data.agreed_bp_per).toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 21: // Agreed TP %
|
|
cell.find('input').val(data.agreed_tp_per).toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 22: // Agreed Ter %
|
|
cell.find('input').val(data.agreed_tep_per).toggleClass('readonly-select', !!disable_td);
|
|
break;
|
|
case 23: // Standard BP %
|
|
cell.find('input').val(data.standerd_bp_per);
|
|
break;
|
|
case 24: // Standard TP %
|
|
cell.find('input').val(data.standerd_tp_per);
|
|
break;
|
|
case 25: // Standard Ter %
|
|
cell.find('input').val(data.standerd_tep_per);
|
|
break;
|
|
case 26: // Co-share ID (hidden field)
|
|
cell.find('input[type="hidden"]').val(status ? data.id : '');
|
|
break;
|
|
}
|
|
}
|
|
});
|
|
|
|
if(data.co_share_type == 1){
|
|
appendCDData(data.cd_account_no, data.cd_amount, index)
|
|
}
|
|
|
|
insurer_count_array.push(insurerCount)
|
|
|
|
});
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------------------------------------
|
|
|
|
// function getURLParamsForReport()
|
|
// {
|
|
// console.log('getURLParamsForReport() function called')
|
|
// const url = new URL(window.location.href);
|
|
// const params = new URLSearchParams(url.search);
|
|
// const pt_id = params.get('pt_id') ?? 0
|
|
|
|
// console.log('policy tranction id ', pt_id);
|
|
|
|
// if(pt_id != 0){
|
|
// setTimeout(function(){
|
|
// hide_list_show_add()
|
|
// getPolicyTransactionDataForEndorsementEdit(pt_id)
|
|
// }, 2000)
|
|
// }else{
|
|
// show_list_hide_add()
|
|
// }
|
|
|
|
// console.log('pt_id', pt_id)
|
|
|
|
// }
|
|
|
|
function getURLParamsForReport() {
|
|
const params = new URLSearchParams(window.location.search);
|
|
const pt_id = params.get('pt_id') ?? 0;
|
|
|
|
// ✅ Get the previous page URL
|
|
const previousUrl = document.referrer || '';
|
|
|
|
console.log("PT ID:", pt_id);
|
|
console.log("Previous Page URL:", previousUrl);
|
|
|
|
if (pt_id != 0) {
|
|
hide_list_show_add();
|
|
setTimeout(() =>
|
|
getPolicyTransactionDataForEndorsementEdit(pt_id),
|
|
1500); // Reduced timeout
|
|
} else {
|
|
show_list_hide_add();
|
|
}
|
|
|
|
if(previousUrl != "" && pt_id != 0){
|
|
redirect_url = previousUrl;
|
|
$('#btnAdd').attr('href', previousUrl);
|
|
}
|
|
|
|
console.log('getURLParamsForReport pt_id', pt_id); // Retain the log if necessary
|
|
}
|
|
|
|
|
|
function onlyNumbers(event)
|
|
{
|
|
var charcode = event.which || event.keyCode;
|
|
|
|
// Allow: 0-9 (48-57), dot (46), minus (45)
|
|
if ((charcode >= 48 && charcode <= 57) || charcode === 46 || charcode === 45) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
function validateInput(input, table, field){
|
|
|
|
let value = $(input).val();
|
|
let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim();
|
|
|
|
let message = "Value is duplicate!";
|
|
if(label){
|
|
message = 'Given ' + label + " already exists!";
|
|
}
|
|
|
|
checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) {
|
|
if (isDuplicate) {
|
|
toastr.warning(message, 'WARNING');
|
|
$(input).val('')
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
function appendCDData(cd_ac_no, cd_amt, increment){
|
|
|
|
increment = increment + 1
|
|
$('#cd_account_no_'+increment).val(cd_ac_no)
|
|
$('#cd_current_balance_'+increment).val(cd_amt)
|
|
}
|
|
|
|
$('#action_type').on('change', function(){
|
|
|
|
let action_type = $(this).val();
|
|
console.log('action_type', action_type);
|
|
console.log('action_type', action_type);
|
|
if (action_type == 'policy_instalment') {
|
|
$('.install_due_date_div').show()
|
|
}else{
|
|
$('.install_due_date_div').hide()
|
|
}
|
|
|
|
if(action_type == "deletion"){
|
|
console.log('pt_co_share_count_data', pt_co_share_count_data);
|
|
for (let i = 1; i <= pt_co_share_count_data; i++) {
|
|
applyDeletionSymbolsToFields(String(i), true);
|
|
}
|
|
}else{
|
|
|
|
const fieldIds = [
|
|
'base_premium',
|
|
'tp_premium',
|
|
'ter_premium',
|
|
'co_premium',
|
|
'co_tp_premium',
|
|
'co_ter_premium',
|
|
'gst_amount',
|
|
'agreed_amount',
|
|
'non_comm_per_amt',
|
|
'total_amt',
|
|
'exp_amt'
|
|
];
|
|
|
|
for (let input = 1; input <= pt_co_share_count_data; input++) {
|
|
fieldIds.forEach(field => {
|
|
const $el = $('#' + field + '_' + input);
|
|
console.log('$el', '#' + field + '_' + input);
|
|
let val = $el.val()?.trim();
|
|
console.log('$val', val);
|
|
if (!val) return;
|
|
|
|
let num = parseFloat(val);
|
|
if (!isNaN(num)) $el.val(Math.abs(num)); // Removes '-' sign
|
|
});
|
|
}
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
$('#policy_issue_date').on('change', function(){
|
|
let date = $(this).val();
|
|
|
|
let date_set = false
|
|
$('[name="co_share_type[]"]').each(function () {
|
|
console.log('co_share_type[] value', $(this).val());
|
|
if($(this).val() == 1){
|
|
let uniqueid = $(this).data('id');
|
|
$('#calc_policy_issue_date_' + uniqueid).val(date).addClass('readonly-select');
|
|
date_set = true;
|
|
}
|
|
});
|
|
|
|
if(!date_set){
|
|
$('#calc_policy_issue_date_1').val(date).addClass('readonly-select');
|
|
}
|
|
});
|
|
|
|
|
|
//-----------------------------------------------------------------------------------------------------------
|
|
|
|
$(document).on('change', '#insurerTable input, #insurerTable select, #insurerTable textarea', function() {
|
|
getColumnIndexes()
|
|
});
|
|
|
|
function getColumnIndexes(count = 0) {
|
|
$('#insurerTable thead th').each(function(index) {
|
|
if (index === 0) {
|
|
console.log("Premium Table columnIndexes is", index);
|
|
} else {
|
|
amountCalculation(index);
|
|
if(count == 1){
|
|
amountCalculation(index);
|
|
}
|
|
co_share_percentage_calculation(index);
|
|
}
|
|
});
|
|
}
|
|
|
|
</script>
|