FIX_ENDORSEMENT_AND_INCEPTION_FRONTEND_VALIDATION
This commit is contained in:
parent
cad9599fda
commit
14ad99ac92
@ -145,6 +145,7 @@ class ClientController extends AdminController
|
|||||||
private const ALLOWED_DUPLICATE_CHECK_TABLES = [
|
private const ALLOWED_DUPLICATE_CHECK_TABLES = [
|
||||||
'clients', 'client_branch', 'level_contacts', 'insurers', 'insurer_branch',
|
'clients', 'client_branch', 'level_contacts', 'insurers', 'insurer_branch',
|
||||||
'tpa', 'tpa_branch', 'policies', 'client_policy', 'user_profiles',
|
'tpa', 'tpa_branch', 'policies', 'client_policy', 'user_profiles',
|
||||||
|
'policy_transaction',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function checkDuplicateTableFieldValue()
|
public function checkDuplicateTableFieldValue()
|
||||||
@ -5873,6 +5874,7 @@ class ClientController extends AdminController
|
|||||||
$policyListByClient = [];
|
$policyListByClient = [];
|
||||||
$unitList = [];
|
$unitList = [];
|
||||||
$insurerBranchList = [];
|
$insurerBranchList = [];
|
||||||
|
$policyCount = [];
|
||||||
|
|
||||||
//for client branch mapping to the client
|
//for client branch mapping to the client
|
||||||
foreach ($branches as $branch) {
|
foreach ($branches as $branch) {
|
||||||
@ -5901,20 +5903,30 @@ class ClientController extends AdminController
|
|||||||
$client['client_policy_count'] = $policyCount[$client['id']] ?? 0;
|
$client['client_policy_count'] = $policyCount[$client['id']] ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($branchList)) {
|
if (!empty($clients)) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => true,
|
'status' => true,
|
||||||
'client_data' => $clients,
|
'client_data' => $clients,
|
||||||
'vehicle_data' => $vehicles,
|
'vehicle_data' => $vehicles,
|
||||||
'branch_data' => $branchList,
|
'branch_data' => $branchList ?? [],
|
||||||
'policy_data' => $policyList,
|
'policy_data' => $policyList ?? [],
|
||||||
'policyListByClient' => $policyListByClient,
|
'policyListByClient' => $policyListByClient ?? [],
|
||||||
'insurer_data' => $insurers,
|
'insurer_data' => $insurers,
|
||||||
'insurer_branch_data' => $insurerBranchList,
|
'insurer_branch_data' => $insurerBranchList ?? [],
|
||||||
'unit_data' => $unitList,
|
'unit_data' => $unitList ?? [],
|
||||||
], 200);
|
], 200);
|
||||||
} else {
|
} else {
|
||||||
return $this->respond(['status' => false], 200);
|
return $this->respond([
|
||||||
|
'status' => false,
|
||||||
|
'client_data' => [],
|
||||||
|
'vehicle_data' => [],
|
||||||
|
'branch_data' => [],
|
||||||
|
'policy_data' => [],
|
||||||
|
'policyListByClient' => [],
|
||||||
|
'insurer_data' => [],
|
||||||
|
'insurer_branch_data' => [],
|
||||||
|
'unit_data' => [],
|
||||||
|
], 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2318,7 +2318,7 @@ class PolicyTransactionController extends BaseController
|
|||||||
$policy_type_id = (!isset($policy_type_id) || $policy_type_id === '' || $policy_type_id === null) ? 0 : $policy_type_id;
|
$policy_type_id = (!isset($policy_type_id) || $policy_type_id === '' || $policy_type_id === null) ? 0 : $policy_type_id;
|
||||||
$date_type = (!isset($date_type) || $date_type === '' || $date_type === null) ? 0 : $date_type;
|
$date_type = (!isset($date_type) || $date_type === '' || $date_type === null) ? 0 : $date_type;
|
||||||
$issuer = (!isset($issuer) || $issuer === '' || $issuer === null) ? 0 : $issuer;
|
$issuer = (!isset($issuer) || $issuer === '' || $issuer === null) ? 0 : $issuer;
|
||||||
$status = (!isset($issuer) || $status === '' || $status === null) ? 0 : $status;
|
$status = (!isset($status) || $status === '' || $status === null) ? 0 : $status;
|
||||||
|
|
||||||
if($bds_edit_pt_id == null){
|
if($bds_edit_pt_id == null){
|
||||||
$data['endorsement_data_list'] = $this->policyTransactionModel->getEndorsementTranctionListData($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $status);
|
$data['endorsement_data_list'] = $this->policyTransactionModel->getEndorsementTranctionListData($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $status);
|
||||||
@ -2412,7 +2412,7 @@ class PolicyTransactionController extends BaseController
|
|||||||
$policy_type_id = (!isset($policy_type_id) || $policy_type_id === '' || $policy_type_id === null) ? 0 : $policy_type_id;
|
$policy_type_id = (!isset($policy_type_id) || $policy_type_id === '' || $policy_type_id === null) ? 0 : $policy_type_id;
|
||||||
$date_type = (!isset($date_type) || $date_type === '' || $date_type === null) ? 0 : $date_type;
|
$date_type = (!isset($date_type) || $date_type === '' || $date_type === null) ? 0 : $date_type;
|
||||||
$issuer = (!isset($issuer) || $issuer === '' || $issuer === null) ? 0 : $issuer;
|
$issuer = (!isset($issuer) || $issuer === '' || $issuer === null) ? 0 : $issuer;
|
||||||
$status = (!isset($issuer) || $status === '' || $status === null) ? 0 : $status;
|
$status = (!isset($status) || $status === '' || $status === null) ? 0 : $status;
|
||||||
|
|
||||||
if($bds_edit_pt_id == null){
|
if($bds_edit_pt_id == null){
|
||||||
$data['endorsement_data_list'] = $this->policyTransactionModel->getEndorsementTranctionListData($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $status);
|
$data['endorsement_data_list'] = $this->policyTransactionModel->getEndorsementTranctionListData($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $status);
|
||||||
@ -5102,9 +5102,20 @@ class PolicyTransactionController extends BaseController
|
|||||||
// ->where('client_policy.is_active', 1)
|
// ->where('client_policy.is_active', 1)
|
||||||
// ->findAll();
|
// ->findAll();
|
||||||
|
|
||||||
|
// Only columns needed for policy_transaction_endorsement_list appendPolicies() JSON — not policy_transaction.*
|
||||||
|
// (full rows + json_encode duplicated memory and exceeded PHP memory_limit on large datasets).
|
||||||
$policies = $this->policyTransactionModel
|
$policies = $this->policyTransactionModel
|
||||||
->select("
|
->select("
|
||||||
policy_transaction.*,
|
policy_transaction.id,
|
||||||
|
policy_transaction.client_id,
|
||||||
|
policy_transaction.client_branch_id,
|
||||||
|
policy_transaction.policy_no,
|
||||||
|
policy_transaction.policy_type_id,
|
||||||
|
policy_transaction.insurer_id,
|
||||||
|
policy_transaction.insurer_branch_id,
|
||||||
|
policy_transaction.tpa_id,
|
||||||
|
policy_transaction.tpa_branch_id,
|
||||||
|
policy_transaction.cd_ac_no,
|
||||||
policy_type.policy_type,
|
policy_type.policy_type,
|
||||||
policy_type.ebp,
|
policy_type.ebp,
|
||||||
policy_type.etp,
|
policy_type.etp,
|
||||||
@ -5124,11 +5135,6 @@ class PolicyTransactionController extends BaseController
|
|||||||
foreach ($policies as $policy) {
|
foreach ($policies as $policy) {
|
||||||
$policyList[$policy['client_branch_id']][] = $policy;
|
$policyList[$policy['client_branch_id']][] = $policy;
|
||||||
$policyListByClient[$policy['client_id']][] = $policy;
|
$policyListByClient[$policy['client_id']][] = $policy;
|
||||||
if (isset($policyCount[$policy['client_id']])) {
|
|
||||||
$policyCount[$policy['client_id']]++;
|
|
||||||
} else {
|
|
||||||
$policyCount[$policy['client_id']] = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return [$policyList, $policyListByClient];
|
return [$policyList, $policyListByClient];
|
||||||
|
|||||||
@ -92,7 +92,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<!-- end -->
|
<!-- end -->
|
||||||
|
|
||||||
<script src="<?= base_url('public/assets/js/pages/policy_transaction_inception_form_validation.js') ?>"></script>
|
<!-- <script src="<?= base_url('public/assets/js/pages/policy_transaction_inception_form_validation.js') ?>"></script> -->
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
var kycPrimaryKey = $('#client_id_kyc').val();
|
var kycPrimaryKey = $('#client_id_kyc').val();
|
||||||
|
|||||||
@ -164,6 +164,22 @@
|
|||||||
box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.08) !important;
|
box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.08) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.parsley-errors-list {
|
||||||
|
list-style: none;
|
||||||
|
padding: 0;
|
||||||
|
margin: 5px 0 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.parsley-errors-list li {
|
||||||
|
color: #dc3545;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
select.select2-hidden-accessible.parsley-error + .select2-container .select2-selection {
|
||||||
|
border-color: #dc3545 !important;
|
||||||
|
box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.12) !important;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
<script src="<?= base_url('public/assets/js/pages/policy_transaction_endorsement_form_validation.js') ?>"></script>
|
<script src="<?= base_url('public/assets/js/pages/policy_transaction_endorsement_form_validation.js') ?>"></script>
|
||||||
|
|
||||||
@ -181,7 +197,7 @@
|
|||||||
>Back</a>
|
>Back</a>
|
||||||
</div>
|
</div>
|
||||||
</div> -->
|
</div> -->
|
||||||
<form role="form" class="parsley-examples" method="post" id="endorsement_form_id" enctype="multipart/form-data">
|
<form role="form" class="parsley-examples" method="post" id="endorsement_form_id" enctype="multipart/form-data" novalidate>
|
||||||
|
|
||||||
<input type="hidden" name="id" id="policy_tranction_primarykey">
|
<input type="hidden" name="id" id="policy_tranction_primarykey">
|
||||||
<input type="hidden" name="client_id" id="client_id_for_edit">
|
<input type="hidden" name="client_id" id="client_id_for_edit">
|
||||||
@ -1055,6 +1071,9 @@
|
|||||||
$('.loader-mask').fadeIn();
|
$('.loader-mask').fadeIn();
|
||||||
|
|
||||||
$('#endorsement_form_id')[0].reset();
|
$('#endorsement_form_id')[0].reset();
|
||||||
|
if (typeof window.resetEndorsementFormParsley === 'function') {
|
||||||
|
window.resetEndorsementFormParsley('#endorsement_form_id');
|
||||||
|
}
|
||||||
// var id = $(input).attr('data-id');
|
// var id = $(input).attr('data-id');
|
||||||
var id = input;
|
var id = input;
|
||||||
|
|
||||||
@ -1088,10 +1107,77 @@
|
|||||||
$('#policy_tranction_primarykey_for_file_upload').val(res.data.id);
|
$('#policy_tranction_primarykey_for_file_upload').val(res.data.id);
|
||||||
$('#client_policy_id_for_file_upload').val(res.data.client_policy_id);
|
$('#client_policy_id_for_file_upload').val(res.data.client_policy_id);
|
||||||
$('#policy_tranction_primarykey').val(res.data.id);
|
$('#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);
|
$('#base_cd_amount').val(res.data.base_cd_amount);
|
||||||
|
|
||||||
|
var applyEndorsementClientSelection = function () {
|
||||||
|
var clientType = String(res.data.client_type || '');
|
||||||
|
var clientId = String(res.data.client_id || '');
|
||||||
|
var branchId = String(res.data.client_branch_id || '');
|
||||||
|
var policyId = String(res.data.client_policy_id || '');
|
||||||
|
var $clientType = $('#client_type');
|
||||||
|
var $client = $('#client_id');
|
||||||
|
var $branch = $('#client_branch_id');
|
||||||
|
var $policy = $('#client_policy_id');
|
||||||
|
|
||||||
|
if (clientType) {
|
||||||
|
$clientType.val(clientType).trigger('change');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clientId && !$client.find("option[value='" + clientId + "']").length) {
|
||||||
|
$client.append($('<option>', {
|
||||||
|
value: clientId,
|
||||||
|
text: res.data.client_short_name || res.data.client_name || 'Selected Client'
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (clientId) {
|
||||||
|
$client.val(clientId).trigger('change');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clientId && branchId && typeof branch_list !== 'undefined' && branch_list[clientId]) {
|
||||||
|
appendBranch(branch_list[clientId], branchId);
|
||||||
|
}
|
||||||
|
if (branchId && !$branch.find("option[value='" + branchId + "']").length) {
|
||||||
|
$branch.append($('<option>', {
|
||||||
|
value: branchId,
|
||||||
|
text: res.data.branch_name || 'Selected Branch'
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (branchId) {
|
||||||
|
$branch.val(branchId).trigger('change');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (policyId && typeof policyListByClient !== 'undefined') {
|
||||||
|
if (String(clientType) === '2' && policyListByClient[clientId]) {
|
||||||
|
appendPolicies(policyListByClient[clientId], policyId);
|
||||||
|
} else if (typeof policy_list !== 'undefined' && policy_list[branchId]) {
|
||||||
|
appendPolicies(policy_list[branchId], policyId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (policyId && !$policy.find("option[value='" + policyId + "']").length) {
|
||||||
|
$policy.append($('<option>', {
|
||||||
|
value: policyId,
|
||||||
|
text: res.data.policy_no || 'Selected Policy'
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (policyId) {
|
||||||
|
$policy.val(policyId).trigger('change');
|
||||||
|
}
|
||||||
|
|
||||||
|
var clientApplied = !clientId || String($client.val() || '') === clientId;
|
||||||
|
var branchApplied = !branchId || String($branch.val() || '') === branchId;
|
||||||
|
var policyApplied = !policyId || String($policy.val() || '') === policyId;
|
||||||
|
return clientApplied && branchApplied && policyApplied;
|
||||||
|
};
|
||||||
|
|
||||||
|
var attempts = 0;
|
||||||
|
var maxAttempts = 24;
|
||||||
|
var selectionTimer = setInterval(function () {
|
||||||
|
attempts++;
|
||||||
|
if (applyEndorsementClientSelection() || attempts >= maxAttempts) {
|
||||||
|
clearInterval(selectionTimer);
|
||||||
|
}
|
||||||
|
}, 120);
|
||||||
|
|
||||||
var tpaValue = '';
|
var tpaValue = '';
|
||||||
if (res.data.tpa_branch_id && res.data.tpa_id) {
|
if (res.data.tpa_branch_id && res.data.tpa_id) {
|
||||||
tpaValue = res.data.tpa_branch_id + '-' + res.data.tpa_id;
|
tpaValue = res.data.tpa_branch_id + '-' + res.data.tpa_id;
|
||||||
@ -1102,18 +1188,8 @@
|
|||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
$('.loader').fadeOut();
|
$('.loader').fadeOut();
|
||||||
$('.loader-mask').delay(350).fadeOut('slow');
|
$('.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)
|
}, 1000)
|
||||||
|
|
||||||
if(res.data.client_type == 2){
|
|
||||||
let data1 = policyListByClient[res.data.client_id];
|
|
||||||
appendPolicies(data1, res.data.client_policy_id);
|
|
||||||
}else{
|
|
||||||
let data2 = policy_list[res.data.client_branch_id];
|
|
||||||
appendPolicies(data2, res.data.client_policy_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
$('#policy_start_date').val(res.data.policy_start_date);
|
$('#policy_start_date').val(res.data.policy_start_date);
|
||||||
$('#policy_end_date').val(res.data.policy_end_date);
|
$('#policy_end_date').val(res.data.policy_end_date);
|
||||||
@ -1122,6 +1198,9 @@
|
|||||||
$('#client_id').addClass('readonly-select ').select2('destroy');
|
$('#client_id').addClass('readonly-select ').select2('destroy');
|
||||||
$('#client_branch_id').addClass('readonly-select ').select2('destroy');
|
$('#client_branch_id').addClass('readonly-select ').select2('destroy');
|
||||||
$('#client_policy_id').addClass('readonly-select ').select2('destroy');
|
$('#client_policy_id').addClass('readonly-select ').select2('destroy');
|
||||||
|
if (typeof window.resetEndorsementFormParsley === 'function') {
|
||||||
|
window.resetEndorsementFormParsley('#endorsement_form_id');
|
||||||
|
}
|
||||||
}, 1500)
|
}, 1500)
|
||||||
|
|
||||||
$('#policy_no').val(res.data.policy_no);
|
$('#policy_no').val(res.data.policy_no);
|
||||||
|
|||||||
@ -181,8 +181,22 @@
|
|||||||
color: #dc3545;
|
color: #dc3545;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input.parsley-error,
|
||||||
|
textarea.parsley-error,
|
||||||
|
select.parsley-error {
|
||||||
|
border-color: #dc3545 !important;
|
||||||
|
box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.12) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
select.select2-hidden-accessible.parsley-error + .select2-container .select2-selection {
|
||||||
|
border-color: #dc3545 !important;
|
||||||
|
box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.12) !important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<script src="<?= base_url('public/assets/js/pages/policy_transaction_endorsement_form_validation.js') ?>"></script>
|
||||||
|
|
||||||
<div class="row" id="endorsement_form" style="display: none;">
|
<div class="row" id="endorsement_form" style="display: none;">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
@ -196,7 +210,7 @@
|
|||||||
>Back</a>
|
>Back</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<form role="form" class="parsley-examples" method="post" id="endorsement_form_id" enctype="multipart/form-data">
|
<form role="form" class="parsley-examples" method="post" id="endorsement_form_id" enctype="multipart/form-data" novalidate>
|
||||||
|
|
||||||
<input type="hidden" name="id" id="policy_tranction_primarykey">
|
<input type="hidden" name="id" id="policy_tranction_primarykey">
|
||||||
<input type="hidden" name="client_id" id="client_id_for_edit">
|
<input type="hidden" name="client_id" id="client_id_for_edit">
|
||||||
@ -931,10 +945,77 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$('#policy_tranction_primarykey').val(res.data.id);
|
$('#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);
|
$('#base_cd_amount').val(res.data.base_cd_amount);
|
||||||
|
|
||||||
|
var applyEndorsementClientSelection = function () {
|
||||||
|
var clientType = String(res.data.client_type || '');
|
||||||
|
var clientId = String(res.data.client_id || '');
|
||||||
|
var branchId = String(res.data.client_branch_id || '');
|
||||||
|
var policyId = String(res.pt_id || '');
|
||||||
|
var $clientType = $('#client_type');
|
||||||
|
var $client = $('#client_id');
|
||||||
|
var $branch = $('#client_branch_id');
|
||||||
|
var $policy = $('#client_policy_id');
|
||||||
|
|
||||||
|
if (clientType) {
|
||||||
|
$clientType.val(clientType).trigger('change');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clientId && !$client.find("option[value='" + clientId + "']").length) {
|
||||||
|
$client.append($('<option>', {
|
||||||
|
value: clientId,
|
||||||
|
text: res.data.client_short_name || res.data.client_name || 'Selected Client'
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (clientId) {
|
||||||
|
$client.val(clientId).trigger('change');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clientId && branchId && typeof branch_list !== 'undefined' && branch_list[clientId]) {
|
||||||
|
appendBranch(branch_list[clientId], branchId);
|
||||||
|
}
|
||||||
|
if (branchId && !$branch.find("option[value='" + branchId + "']").length) {
|
||||||
|
$branch.append($('<option>', {
|
||||||
|
value: branchId,
|
||||||
|
text: res.data.branch_name || 'Selected Branch'
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (branchId) {
|
||||||
|
$branch.val(branchId).trigger('change');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (policyId && typeof policyListByClient !== 'undefined') {
|
||||||
|
if (String(clientType) === '2' && policyListByClient[clientId]) {
|
||||||
|
appendPolicies(policyListByClient[clientId], policyId);
|
||||||
|
} else if (typeof policy_list !== 'undefined' && policy_list[branchId]) {
|
||||||
|
appendPolicies(policy_list[branchId], policyId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (policyId && !$policy.find("option[value='" + policyId + "']").length) {
|
||||||
|
$policy.append($('<option>', {
|
||||||
|
value: policyId,
|
||||||
|
text: res.data.policy_no || 'Selected Policy'
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (policyId) {
|
||||||
|
$policy.val(policyId).trigger('change');
|
||||||
|
}
|
||||||
|
|
||||||
|
var clientApplied = !clientId || String($client.val() || '') === clientId;
|
||||||
|
var branchApplied = !branchId || String($branch.val() || '') === branchId;
|
||||||
|
var policyApplied = !policyId || String($policy.val() || '') === policyId;
|
||||||
|
return clientApplied && branchApplied && policyApplied;
|
||||||
|
};
|
||||||
|
|
||||||
|
var attempts = 0;
|
||||||
|
var maxAttempts = 24;
|
||||||
|
var selectionTimer = setInterval(function () {
|
||||||
|
attempts++;
|
||||||
|
if (applyEndorsementClientSelection() || attempts >= maxAttempts) {
|
||||||
|
clearInterval(selectionTimer);
|
||||||
|
}
|
||||||
|
}, 120);
|
||||||
|
|
||||||
var tpaValue = '';
|
var tpaValue = '';
|
||||||
if (res.data.tpa_branch_id && res.data.tpa_id) {
|
if (res.data.tpa_branch_id && res.data.tpa_id) {
|
||||||
tpaValue = res.data.tpa_branch_id + '-' + res.data.tpa_id;
|
tpaValue = res.data.tpa_branch_id + '-' + res.data.tpa_id;
|
||||||
@ -945,18 +1026,8 @@
|
|||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
$('.loader').fadeOut();
|
$('.loader').fadeOut();
|
||||||
$('.loader-mask').delay(350).fadeOut('slow');
|
$('.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)
|
}, 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(){
|
setTimeout(function(){
|
||||||
$('#policy_start_date').val(res.data.policy_start_date);
|
$('#policy_start_date').val(res.data.policy_start_date);
|
||||||
$('#policy_end_date').val(res.data.policy_end_date);
|
$('#policy_end_date').val(res.data.policy_end_date);
|
||||||
|
|||||||
@ -572,6 +572,9 @@
|
|||||||
$('.hideter').hide()
|
$('.hideter').hide()
|
||||||
$('.hidetp').hide()
|
$('.hidetp').hide()
|
||||||
$('#endorsement_form_id')[0].reset();
|
$('#endorsement_form_id')[0].reset();
|
||||||
|
if (typeof window.resetEndorsementFormParsley === 'function') {
|
||||||
|
window.resetEndorsementFormParsley('#endorsement_form_id');
|
||||||
|
}
|
||||||
$('#client_id').val('').change();
|
$('#client_id').val('').change();
|
||||||
$('#client_policy_id').val('').change();
|
$('#client_policy_id').val('').change();
|
||||||
$('#invoice_no_div').hide();
|
$('#invoice_no_div').hide();
|
||||||
|
|||||||
@ -611,6 +611,9 @@ table.dataTable thead th {
|
|||||||
$('.hideter').hide()
|
$('.hideter').hide()
|
||||||
$('.hidetp').hide()
|
$('.hidetp').hide()
|
||||||
$('#endorsement_form_id')[0].reset();
|
$('#endorsement_form_id')[0].reset();
|
||||||
|
if (typeof window.resetEndorsementFormParsley === 'function') {
|
||||||
|
window.resetEndorsementFormParsley('#endorsement_form_id');
|
||||||
|
}
|
||||||
$('#client_id').val('').change();
|
$('#client_id').val('').change();
|
||||||
$('#client_policy_id').val('').change();
|
$('#client_policy_id').val('').change();
|
||||||
$('#endorsement_form').show();
|
$('#endorsement_form').show();
|
||||||
|
|||||||
@ -307,6 +307,11 @@
|
|||||||
border-color: #28a745 !important;
|
border-color: #28a745 !important;
|
||||||
box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.08) !important;
|
box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.08) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
select.select2-hidden-accessible.parsley-error + .select2-container .select2-selection {
|
||||||
|
border-color: #dc3545 !important;
|
||||||
|
box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.12) !important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
var pageSubTitle = undefined;
|
var pageSubTitle = undefined;
|
||||||
@ -332,7 +337,7 @@
|
|||||||
>Back</a>
|
>Back</a>
|
||||||
</div> -->
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
<form role="form" class="parsley-examples" method="post" id="inception_form_id" enctype="multipart/form-data">
|
<form role="form" class="parsley-examples" method="post" id="inception_form_id" enctype="multipart/form-data" novalidate>
|
||||||
|
|
||||||
<input type="hidden" name="id" id="policy_tranction_primarykey">
|
<input type="hidden" name="id" id="policy_tranction_primarykey">
|
||||||
<input type="hidden" name="client_policy_id" id="client_policy_id">
|
<input type="hidden" name="client_policy_id" id="client_policy_id">
|
||||||
@ -2218,6 +2223,10 @@
|
|||||||
console.log('follow_insurer_id client_id', client_id);
|
console.log('follow_insurer_id client_id', client_id);
|
||||||
console.log('follow_insurer_id unique_id', unique_id);
|
console.log('follow_insurer_id unique_id', unique_id);
|
||||||
|
|
||||||
|
if (window.__inceptionEditHydrating === true) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$('#insurer_id').val(insurer)
|
$('#insurer_id').val(insurer)
|
||||||
|
|
||||||
if (!policy_type_id || !client_id) {
|
if (!policy_type_id || !client_id) {
|
||||||
@ -2256,9 +2265,13 @@
|
|||||||
$('.loader-mask').fadeIn();
|
$('.loader-mask').fadeIn();
|
||||||
|
|
||||||
$('#inception_form_id')[0].reset();
|
$('#inception_form_id')[0].reset();
|
||||||
|
if (typeof window.resetInceptionFormParsley === 'function') {
|
||||||
|
window.resetInceptionFormParsley('#inception_form_id');
|
||||||
|
}
|
||||||
// var id = $(input).attr('data-id');
|
// var id = $(input).attr('data-id');
|
||||||
var id = input;
|
var id = input;
|
||||||
console.log('Selected policy transaction ID:', id);
|
console.log('Selected policy transaction ID:', id);
|
||||||
|
window.__inceptionEditHydrating = true;
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '<?= base_url("/policy_tranction/inception/list/") ?>' + id,
|
url: '<?= base_url("/policy_tranction/inception/list/") ?>' + id,
|
||||||
@ -2306,8 +2319,53 @@
|
|||||||
$('#issue_type').val(res.data.issue_type);
|
$('#issue_type').val(res.data.issue_type);
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
$('#client_id').val(res.data.client_id).change();
|
// Order matters: client_type change rebuilds #client_id options.
|
||||||
$('#client_type').val(res.data.client_type);
|
$('#client_type').val(res.data.client_type).trigger('change');
|
||||||
|
|
||||||
|
var applyClientBranchSelection = function () {
|
||||||
|
var clientId = String(res.data.client_id || '');
|
||||||
|
var branchId = String(res.data.client_branch_id || '');
|
||||||
|
var $client = $('#client_id');
|
||||||
|
var $branch = $('#client_branch_id');
|
||||||
|
|
||||||
|
if (clientId && !$client.find("option[value='" + clientId + "']").length) {
|
||||||
|
$client.append($('<option>', {
|
||||||
|
value: clientId,
|
||||||
|
text: res.data.client_short_name || res.data.client_name || 'Selected Client'
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (clientId) {
|
||||||
|
$client.val(clientId).trigger('change');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clientId && typeof branch_list !== 'undefined' && branch_list[clientId]) {
|
||||||
|
appendBranch(branch_list[clientId], branchId || null);
|
||||||
|
}
|
||||||
|
if (branchId && !$branch.find("option[value='" + branchId + "']").length) {
|
||||||
|
$branch.append($('<option>', {
|
||||||
|
value: branchId,
|
||||||
|
text: res.data.branch_name || 'Selected Branch'
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (branchId) {
|
||||||
|
$branch.val(branchId).trigger('change');
|
||||||
|
}
|
||||||
|
|
||||||
|
var clientApplied = !clientId || String($client.val() || '') === clientId;
|
||||||
|
var branchApplied = !branchId || String($branch.val() || '') === branchId;
|
||||||
|
return clientApplied && branchApplied;
|
||||||
|
};
|
||||||
|
|
||||||
|
var attempts = 0;
|
||||||
|
var maxAttempts = 20;
|
||||||
|
var timer = setInterval(function () {
|
||||||
|
attempts++;
|
||||||
|
if (applyClientBranchSelection() || attempts >= maxAttempts) {
|
||||||
|
clearInterval(timer);
|
||||||
|
window.__inceptionEditHydrating = false;
|
||||||
|
}
|
||||||
|
}, 120);
|
||||||
|
|
||||||
$('#insurer_id').val(res.data.insurer_branch_id + '-' + res.data.insurer_id);
|
$('#insurer_id').val(res.data.insurer_branch_id + '-' + res.data.insurer_id);
|
||||||
$('#vehicle_no').val(res.data.vehicle_id).select2();
|
$('#vehicle_no').val(res.data.vehicle_id).select2();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
@ -2583,6 +2641,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function(xhr, status, error) {
|
error: function(xhr, status, error) {
|
||||||
|
window.__inceptionEditHydrating = false;
|
||||||
$('.loader').fadeOut();
|
$('.loader').fadeOut();
|
||||||
$('.loader-mask').delay(350).fadeOut('slow');
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
console.error(xhr.responseText);
|
console.error(xhr.responseText);
|
||||||
@ -2590,6 +2649,11 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Safety fallback to avoid getting stuck in hydration mode.
|
||||||
|
window.setTimeout(function () {
|
||||||
|
window.__inceptionEditHydrating = false;
|
||||||
|
}, 7000);
|
||||||
|
|
||||||
//To check the invoice statement if statament is upload aginst this policy than change readonly the table fileds
|
//To check the invoice statement if statament is upload aginst this policy than change readonly the table fileds
|
||||||
checkInvoiceStatusToHideSubmitBtn(id)
|
checkInvoiceStatusToHideSubmitBtn(id)
|
||||||
|
|
||||||
@ -3907,11 +3971,26 @@
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalizeDynamicRequiredBeforeInceptionSubmit() {
|
||||||
|
// Hidden / non-applicable dynamic CD fields can remain marked required in Parsley cache.
|
||||||
|
// Clear required for non-visible entries so submit validates only active fields.
|
||||||
|
$('select[name="cd_ac_no_for_child[]"]').each(function () {
|
||||||
|
var $field = $(this);
|
||||||
|
var shouldIgnore = !$field.is(':visible') || $field.is(':disabled') || $field.closest('tr,td,div').is(':hidden');
|
||||||
|
if (shouldIgnore) {
|
||||||
|
$field.prop('required', false);
|
||||||
|
if (typeof $field.parsley === 'function') {
|
||||||
|
try { $field.parsley().reset(); } catch (e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$("#inception_form_id").submit(function(event) {
|
$("#inception_form_id").submit(function(event) {
|
||||||
|
|
||||||
if (!this.checkValidity()) { return; }
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
|
normalizeDynamicRequiredBeforeInceptionSubmit();
|
||||||
let policy_type_id = $('#policy_type_id').val();
|
let policy_type_id = $('#policy_type_id').val();
|
||||||
var isValid = $('#inception_form_id').parsley().validate();
|
var isValid = $('#inception_form_id').parsley().validate();
|
||||||
var client_type_id = $('#client_type').val();
|
var client_type_id = $('#client_type').val();
|
||||||
|
|||||||
@ -299,8 +299,22 @@
|
|||||||
color: #dc3545;
|
color: #dc3545;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input.parsley-error,
|
||||||
|
textarea.parsley-error,
|
||||||
|
select.parsley-error {
|
||||||
|
border-color: #dc3545 !important;
|
||||||
|
box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.12) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
select.select2-hidden-accessible.parsley-error + .select2-container .select2-selection {
|
||||||
|
border-color: #dc3545 !important;
|
||||||
|
box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.12) !important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<script src="<?= base_url('public/assets/js/pages/policy_transaction_inception_form_validation.js') ?>"></script>
|
||||||
|
|
||||||
<div class="tab-pane fade active show" id="form">
|
<div class="tab-pane fade active show" id="form">
|
||||||
<input type="hidden" id="entity_type_id">
|
<input type="hidden" id="entity_type_id">
|
||||||
<div class="row" id="inception_form">
|
<div class="row" id="inception_form">
|
||||||
@ -319,7 +333,7 @@
|
|||||||
<a href="<?= base_url('policy_tranction/inception/list2') ?>" type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light">Back</a>
|
<a href="<?= base_url('policy_tranction/inception/list2') ?>" type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light">Back</a>
|
||||||
</div>
|
</div>
|
||||||
</div><!-- row -->
|
</div><!-- row -->
|
||||||
<form role="form" class="parsley-examples" method="post" id="inception_form_id" enctype="multipart/form-data">
|
<form role="form" class="parsley-examples" method="post" id="inception_form_id" enctype="multipart/form-data" novalidate>
|
||||||
|
|
||||||
<input type="hidden" name="id" id="policy_tranction_primarykey">
|
<input type="hidden" name="id" id="policy_tranction_primarykey">
|
||||||
<input type="hidden" name="client_policy_id" id="client_policy_id">
|
<input type="hidden" name="client_policy_id" id="client_policy_id">
|
||||||
@ -1755,6 +1769,10 @@
|
|||||||
console.log('follow_insurer_id client_id', client_id);
|
console.log('follow_insurer_id client_id', client_id);
|
||||||
console.log('follow_insurer_id unique_id', unique_id);
|
console.log('follow_insurer_id unique_id', unique_id);
|
||||||
|
|
||||||
|
if (window.__inceptionEditHydrating === true) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$('#insurer_id').val(insurer)
|
$('#insurer_id').val(insurer)
|
||||||
|
|
||||||
if (!policy_type_id || !client_id) {
|
if (!policy_type_id || !client_id) {
|
||||||
@ -1777,9 +1795,13 @@
|
|||||||
$('.loader-mask').fadeIn();
|
$('.loader-mask').fadeIn();
|
||||||
|
|
||||||
$('#inception_form_id')[0].reset();
|
$('#inception_form_id')[0].reset();
|
||||||
|
if (typeof window.resetInceptionFormParsley === 'function') {
|
||||||
|
window.resetInceptionFormParsley('#inception_form_id');
|
||||||
|
}
|
||||||
// var id = $(input).attr('data-id');
|
// var id = $(input).attr('data-id');
|
||||||
var id = input;
|
var id = input;
|
||||||
console.log('Selected policy transaction ID:', id);
|
console.log('Selected policy transaction ID:', id);
|
||||||
|
window.__inceptionEditHydrating = true;
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '<?= base_url("/policy_tranction/inception/list2/") ?>' + id,
|
url: '<?= base_url("/policy_tranction/inception/list2/") ?>' + id,
|
||||||
@ -1824,8 +1846,53 @@
|
|||||||
$('#issue_type').val(res.data.issue_type);
|
$('#issue_type').val(res.data.issue_type);
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
$('#client_id').val(res.data.client_id).change();
|
// Order matters: client_type change rebuilds #client_id options.
|
||||||
$('#client_type').val(res.data.client_type);
|
$('#client_type').val(res.data.client_type).trigger('change');
|
||||||
|
|
||||||
|
var applyClientBranchSelection = function () {
|
||||||
|
var clientId = String(res.data.client_id || '');
|
||||||
|
var branchId = String(res.data.client_branch_id || '');
|
||||||
|
var $client = $('#client_id');
|
||||||
|
var $branch = $('#client_branch_id');
|
||||||
|
|
||||||
|
if (clientId && !$client.find("option[value='" + clientId + "']").length) {
|
||||||
|
$client.append($('<option>', {
|
||||||
|
value: clientId,
|
||||||
|
text: res.data.client_short_name || res.data.client_name || 'Selected Client'
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (clientId) {
|
||||||
|
$client.val(clientId).trigger('change');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clientId && typeof branch_list !== 'undefined' && branch_list[clientId]) {
|
||||||
|
appendBranch(branch_list[clientId], branchId || null);
|
||||||
|
}
|
||||||
|
if (branchId && !$branch.find("option[value='" + branchId + "']").length) {
|
||||||
|
$branch.append($('<option>', {
|
||||||
|
value: branchId,
|
||||||
|
text: res.data.branch_name || 'Selected Branch'
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (branchId) {
|
||||||
|
$branch.val(branchId).trigger('change');
|
||||||
|
}
|
||||||
|
|
||||||
|
var clientApplied = !clientId || String($client.val() || '') === clientId;
|
||||||
|
var branchApplied = !branchId || String($branch.val() || '') === branchId;
|
||||||
|
return clientApplied && branchApplied;
|
||||||
|
};
|
||||||
|
|
||||||
|
var attempts = 0;
|
||||||
|
var maxAttempts = 20;
|
||||||
|
var timer = setInterval(function () {
|
||||||
|
attempts++;
|
||||||
|
if (applyClientBranchSelection() || attempts >= maxAttempts) {
|
||||||
|
clearInterval(timer);
|
||||||
|
window.__inceptionEditHydrating = false;
|
||||||
|
}
|
||||||
|
}, 120);
|
||||||
|
|
||||||
$('#insurer_id').val(res.data.insurer_branch_id + '-' + res.data.insurer_id);
|
$('#insurer_id').val(res.data.insurer_branch_id + '-' + res.data.insurer_id);
|
||||||
$('#vehicle_no').val(res.data.vehicle_id).select2();
|
$('#vehicle_no').val(res.data.vehicle_id).select2();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
@ -2111,6 +2178,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function(xhr, status, error) {
|
error: function(xhr, status, error) {
|
||||||
|
window.__inceptionEditHydrating = false;
|
||||||
$('.loader').fadeOut();
|
$('.loader').fadeOut();
|
||||||
$('.loader-mask').delay(350).fadeOut('slow');
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
console.error(xhr.responseText);
|
console.error(xhr.responseText);
|
||||||
@ -2118,6 +2186,10 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.setTimeout(function () {
|
||||||
|
window.__inceptionEditHydrating = false;
|
||||||
|
}, 7000);
|
||||||
|
|
||||||
//To check the invoice statement if statament is upload aginst this policy than change readonly the table fileds
|
//To check the invoice statement if statament is upload aginst this policy than change readonly the table fileds
|
||||||
checkInvoiceStatusToHideSubmitBtn(id)
|
checkInvoiceStatusToHideSubmitBtn(id)
|
||||||
|
|
||||||
@ -3542,11 +3614,25 @@
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalizeDynamicRequiredBeforeInceptionSubmit() {
|
||||||
|
// Hidden / non-applicable dynamic CD fields can remain marked required in Parsley cache.
|
||||||
|
$('select[name="cd_ac_no_for_child[]"]').each(function () {
|
||||||
|
var $field = $(this);
|
||||||
|
var shouldIgnore = !$field.is(':visible') || $field.is(':disabled') || $field.closest('tr,td,div').is(':hidden');
|
||||||
|
if (shouldIgnore) {
|
||||||
|
$field.prop('required', false);
|
||||||
|
if (typeof $field.parsley === 'function') {
|
||||||
|
try { $field.parsley().reset(); } catch (e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$("#inception_form_id").submit(function(event) {
|
$("#inception_form_id").submit(function(event) {
|
||||||
|
|
||||||
if (!this.checkValidity()) { return; }
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
|
normalizeDynamicRequiredBeforeInceptionSubmit();
|
||||||
let policy_type_id = $('#policy_type_id').val();
|
let policy_type_id = $('#policy_type_id').val();
|
||||||
var isValid = $('#inception_form_id').parsley().validate();
|
var isValid = $('#inception_form_id').parsley().validate();
|
||||||
var client_type_id = $('#client_type').val();
|
var client_type_id = $('#client_type').val();
|
||||||
|
|||||||
@ -856,6 +856,9 @@ function hide_list_show_add()
|
|||||||
var backButton = `<a href="${backUrl}" aria-label="Back to list"><i class="mdi mdi-arrow-left" style="font-size: 17px;"></i></a>`;
|
var backButton = `<a href="${backUrl}" aria-label="Back to list"><i class="mdi mdi-arrow-left" style="font-size: 17px;"></i></a>`;
|
||||||
updateNavTitle('Add Policy', backButton);
|
updateNavTitle('Add Policy', backButton);
|
||||||
$('#inception_form_id')[0].reset();
|
$('#inception_form_id')[0].reset();
|
||||||
|
if (typeof window.resetInceptionFormParsley === 'function') {
|
||||||
|
window.resetInceptionFormParsley('#inception_form_id');
|
||||||
|
}
|
||||||
$('#client_id').val('').change().prop('disabled', false);
|
$('#client_id').val('').change().prop('disabled', false);
|
||||||
$('#tpa').val('').change().prop('disabled', false);
|
$('#tpa').val('').change().prop('disabled', false);
|
||||||
$('#client_id_for_edit').val('');
|
$('#client_id_for_edit').val('');
|
||||||
|
|||||||
@ -696,6 +696,9 @@ function hide_list_show_add_2()
|
|||||||
$('#pt_onboarding2').show();
|
$('#pt_onboarding2').show();
|
||||||
$('#page_title').text('Add Policy')
|
$('#page_title').text('Add Policy')
|
||||||
$('#inception_form_id')[0].reset();
|
$('#inception_form_id')[0].reset();
|
||||||
|
if (typeof window.resetInceptionFormParsley === 'function') {
|
||||||
|
window.resetInceptionFormParsley('#inception_form_id');
|
||||||
|
}
|
||||||
$('#client_id').val('').change().prop('disabled', false);
|
$('#client_id').val('').change().prop('disabled', false);
|
||||||
$('#tpa').val('').change().prop('disabled', false);
|
$('#tpa').val('').change().prop('disabled', false);
|
||||||
$('#client_id_for_edit').val('');
|
$('#client_id_for_edit').val('');
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
var MESSAGE = 'Only letters, numbers, spaces, and the characters / _ - . are allowed.';
|
var MESSAGE = 'Only letters, numbers, spaces, and the characters / _ - . are allowed.';
|
||||||
var FORM_SELECTORS = ['#endorsement_form_id', '#drive_file_upload_form', '#file_upload_form'];
|
var FORM_SELECTORS = ['#endorsement_form_id', '#drive_file_upload_form', '#file_upload_form'];
|
||||||
var NS = '.endorsementFormValidate';
|
var NS = '.endorsementFormValidate';
|
||||||
|
var LIVE_VALIDATE_DATA = 'policyEndLiveValidate';
|
||||||
|
|
||||||
function isParsleyReady() {
|
function isParsleyReady() {
|
||||||
return !!window.Parsley;
|
return !!window.Parsley;
|
||||||
@ -62,6 +63,17 @@
|
|||||||
window.Parsley.__endorsementFormValidatorRegistered = true;
|
window.Parsley.__endorsementFormValidatorRegistered = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function registerSubmitAttemptLiveHook() {
|
||||||
|
if (window.__endorsementPolicySubmitLiveHook) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
window.__endorsementPolicySubmitLiveHook = true;
|
||||||
|
var selector = '#endorsement_form_id, #drive_file_upload_form, #file_upload_form';
|
||||||
|
$(document).on('submit', selector, function () {
|
||||||
|
$(this).data(LIVE_VALIDATE_DATA, true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function applyConstraints($form) {
|
function applyConstraints($form) {
|
||||||
if (!$form || !$form.length) {
|
if (!$form || !$form.length) {
|
||||||
return;
|
return;
|
||||||
@ -77,15 +89,10 @@
|
|||||||
if (!$el.attr('data-parsley-endorsementcharset')) {
|
if (!$el.attr('data-parsley-endorsementcharset')) {
|
||||||
$el.attr('data-parsley-endorsementcharset', 'true');
|
$el.attr('data-parsley-endorsementcharset', 'true');
|
||||||
}
|
}
|
||||||
if (!$el.attr('data-parsley-trigger')) {
|
|
||||||
$el.attr('data-parsley-trigger', 'input change');
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (el.tagName === 'SELECT' && !$el.attr('data-parsley-trigger')) {
|
// Do not set data-parsley-trigger on <select> — see inception validation module.
|
||||||
$el.attr('data-parsley-trigger', 'change');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,6 +110,39 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function stripParsleyFormSubmitHandlers($form) {
|
||||||
|
if (!$form || !$form.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
$form.off('.Parsley');
|
||||||
|
} catch (e) {
|
||||||
|
// no-op
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function stripOrphanParsleyUi($form) {
|
||||||
|
if (!$form || !$form.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$form.find('ul.parsley-errors-list').remove();
|
||||||
|
$form.find('.parsley-error, .parsley-success').removeClass('parsley-error parsley-success');
|
||||||
|
$form.find('.select2-container .select2-selection').removeClass('parsley-error parsley-success');
|
||||||
|
}
|
||||||
|
|
||||||
|
function shouldValidateLive($form, $field) {
|
||||||
|
if (!$form.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ($form.data(LIVE_VALIDATE_DATA)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!$field.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return $field.hasClass('parsley-error') || $field.hasClass('parsley-success');
|
||||||
|
}
|
||||||
|
|
||||||
function validateField(field) {
|
function validateField(field) {
|
||||||
if (!field || isSkippableField(field) || !isParsleyReady()) {
|
if (!field || isSkippableField(field) || !isParsleyReady()) {
|
||||||
return;
|
return;
|
||||||
@ -113,6 +153,10 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!shouldValidateLive($form, $field)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
applyConstraints($form);
|
applyConstraints($form);
|
||||||
refreshParsley($form);
|
refreshParsley($form);
|
||||||
|
|
||||||
@ -129,9 +173,16 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Let Parsley handle required/invalid UI; native HTML5 validation can prevent
|
||||||
|
// the jQuery submit handler from running when required fields are empty.
|
||||||
|
$form.attr('novalidate', '');
|
||||||
|
stripOrphanParsleyUi($form);
|
||||||
|
$form.removeData(LIVE_VALIDATE_DATA);
|
||||||
|
|
||||||
registerValidator();
|
registerValidator();
|
||||||
applyConstraints($form);
|
applyConstraints($form);
|
||||||
refreshParsley($form);
|
refreshParsley($form);
|
||||||
|
stripParsleyFormSubmitHandlers($form);
|
||||||
|
|
||||||
$form.off(NS);
|
$form.off(NS);
|
||||||
$form.on('input' + NS, 'input:not([type=hidden]), textarea', function () {
|
$form.on('input' + NS, 'input:not([type=hidden]), textarea', function () {
|
||||||
@ -140,19 +191,63 @@
|
|||||||
$form.on('change' + NS, 'select, input:not([type=hidden]), textarea', function () {
|
$form.on('change' + NS, 'select, input:not([type=hidden]), textarea', function () {
|
||||||
validateField(this);
|
validateField(this);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$form.on('select2:select' + NS + ' select2:clear' + NS, 'select', function () {
|
||||||
|
validateField(this);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
if (!isParsleyReady()) {
|
if (!isParsleyReady()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
registerSubmitAttemptLiveHook();
|
||||||
FORM_SELECTORS.forEach(function (selector) {
|
FORM_SELECTORS.forEach(function (selector) {
|
||||||
bindForm(selector);
|
bindForm(selector);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$(function () {
|
function initWithRetry(attemptsLeft) {
|
||||||
|
if (isParsleyReady()) {
|
||||||
init();
|
init();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (attemptsLeft <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
window.setTimeout(function () {
|
||||||
|
initWithRetry(attemptsLeft - 1);
|
||||||
|
}, 50);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!window.__policyEndorsementSelect2DocHook) {
|
||||||
|
window.__policyEndorsementSelect2DocHook = true;
|
||||||
|
$(function () {
|
||||||
|
$(document).on(
|
||||||
|
'select2:select select2:clear',
|
||||||
|
'#endorsement_form_id select',
|
||||||
|
function () {
|
||||||
|
validateField(this);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$(function () {
|
||||||
|
initWithRetry(40);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(window).on('load', function () {
|
||||||
|
if (!isParsleyReady()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FORM_SELECTORS.forEach(function (selector) {
|
||||||
|
var $f = $(selector);
|
||||||
|
if ($f.length) {
|
||||||
|
refreshParsley($f);
|
||||||
|
stripParsleyFormSubmitHandlers($f);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
window.refreshEndorsementFormValidation = function (formSelector) {
|
window.refreshEndorsementFormValidation = function (formSelector) {
|
||||||
@ -161,6 +256,27 @@
|
|||||||
}
|
}
|
||||||
bindForm(formSelector);
|
bindForm(formSelector);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
window.resetEndorsementFormParsley = function (formSelector) {
|
||||||
|
var sel = formSelector || '#endorsement_form_id';
|
||||||
|
var $form = $(sel);
|
||||||
|
if (!$form.length || !isParsleyReady() || typeof $form.parsley !== 'function') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
$form.parsley().reset();
|
||||||
|
} catch (e) {
|
||||||
|
// no-op
|
||||||
|
}
|
||||||
|
stripOrphanParsleyUi($form);
|
||||||
|
$form.removeData(LIVE_VALIDATE_DATA);
|
||||||
|
try {
|
||||||
|
refreshParsley($form);
|
||||||
|
stripParsleyFormSubmitHandlers($form);
|
||||||
|
} catch (e2) {
|
||||||
|
// no-op
|
||||||
|
}
|
||||||
|
};
|
||||||
})(function () {
|
})(function () {
|
||||||
return window.jQuery;
|
return window.jQuery;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -13,6 +13,8 @@
|
|||||||
var MESSAGE = 'Only letters, numbers, spaces, and the characters / _ - . are allowed.';
|
var MESSAGE = 'Only letters, numbers, spaces, and the characters / _ - . are allowed.';
|
||||||
var FORM_SELECTORS = ['#inception_form_id', '#vehicle_form', '#CDMasterForm', '#file_upload_form', '#kyc_form'];
|
var FORM_SELECTORS = ['#inception_form_id', '#vehicle_form', '#CDMasterForm', '#file_upload_form', '#kyc_form'];
|
||||||
var INCEPTION_NS = '.inceptionFormValidate';
|
var INCEPTION_NS = '.inceptionFormValidate';
|
||||||
|
/** Enable all live field validation only after user attempted submit once. */
|
||||||
|
var LIVE_VALIDATE_DATA = 'policyPtLiveValidate';
|
||||||
|
|
||||||
function isParsleyReady() {
|
function isParsleyReady() {
|
||||||
return !!window.Parsley;
|
return !!window.Parsley;
|
||||||
@ -74,6 +76,17 @@
|
|||||||
window.Parsley.__inceptionFormValidatorRegistered = true;
|
window.Parsley.__inceptionFormValidatorRegistered = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function registerSubmitAttemptLiveHook() {
|
||||||
|
if (window.__inceptionPolicySubmitLiveHook) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
window.__inceptionPolicySubmitLiveHook = true;
|
||||||
|
var selector = '#inception_form_id, #vehicle_form, #CDMasterForm, #file_upload_form, #kyc_form';
|
||||||
|
$(document).on('submit', selector, function () {
|
||||||
|
$(this).data(LIVE_VALIDATE_DATA, true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function applyConstraints($form) {
|
function applyConstraints($form) {
|
||||||
if (!$form || !$form.length) {
|
if (!$form || !$form.length) {
|
||||||
return;
|
return;
|
||||||
@ -91,15 +104,11 @@
|
|||||||
if (!$el.attr('data-parsley-inceptioncharset')) {
|
if (!$el.attr('data-parsley-inceptioncharset')) {
|
||||||
$el.attr('data-parsley-inceptioncharset', 'true');
|
$el.attr('data-parsley-inceptioncharset', 'true');
|
||||||
}
|
}
|
||||||
if (!$el.attr('data-parsley-trigger')) {
|
|
||||||
$el.attr('data-parsley-trigger', 'input change');
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (el.tagName === 'SELECT' && !$el.attr('data-parsley-trigger')) {
|
// Do not set data-parsley-trigger on <select>: Parsley would validate every
|
||||||
$el.attr('data-parsley-trigger', 'change');
|
// change (including Select2/programmatic updates) and show required errors on load.
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,6 +127,45 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parsley registers submit.Parsley / click.Parsley on the form and, when invalid,
|
||||||
|
* calls stopImmediatePropagation() so other jQuery submit handlers may never run.
|
||||||
|
* These pages use their own submit handlers that call .parsley().validate(), so
|
||||||
|
* remove Parsley's capture on the form only (field-level .Parsley triggers stay).
|
||||||
|
*/
|
||||||
|
function stripParsleyFormSubmitHandlers($form) {
|
||||||
|
if (!$form || !$form.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
$form.off('.Parsley');
|
||||||
|
} catch (e) {
|
||||||
|
// no-op
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function stripOrphanParsleyUi($form) {
|
||||||
|
if (!$form || !$form.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$form.find('ul.parsley-errors-list').remove();
|
||||||
|
$form.find('.parsley-error, .parsley-success').removeClass('parsley-error parsley-success');
|
||||||
|
$form.find('.select2-container .select2-selection').removeClass('parsley-error parsley-success');
|
||||||
|
}
|
||||||
|
|
||||||
|
function shouldValidateLive($form, $field) {
|
||||||
|
if (!$form.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ($form.data(LIVE_VALIDATE_DATA)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!$field.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return $field.hasClass('parsley-error') || $field.hasClass('parsley-success');
|
||||||
|
}
|
||||||
|
|
||||||
function validateField(field) {
|
function validateField(field) {
|
||||||
if (!field || isSkippableField(field) || !isParsleyReady()) {
|
if (!field || isSkippableField(field) || !isParsleyReady()) {
|
||||||
return;
|
return;
|
||||||
@ -129,6 +177,10 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!shouldValidateLive($form, $field)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure dynamic fields also receive constraints before validation.
|
// Ensure dynamic fields also receive constraints before validation.
|
||||||
applyConstraints($form);
|
applyConstraints($form);
|
||||||
refreshParsleyInstance($form);
|
refreshParsleyInstance($form);
|
||||||
@ -146,9 +198,17 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Let Parsley handle required/invalid UI; native HTML5 validation can block
|
||||||
|
// the submit handler entirely or bypass Parsley (no inline "This value is required." list).
|
||||||
|
$form.attr('novalidate', '');
|
||||||
|
// Ensure no stale error/success classes are carried over on first render.
|
||||||
|
stripOrphanParsleyUi($form);
|
||||||
|
$form.removeData(LIVE_VALIDATE_DATA);
|
||||||
|
|
||||||
registerValidator();
|
registerValidator();
|
||||||
applyConstraints($form);
|
applyConstraints($form);
|
||||||
refreshParsleyInstance($form);
|
refreshParsleyInstance($form);
|
||||||
|
stripParsleyFormSubmitHandlers($form);
|
||||||
|
|
||||||
$form.off(INCEPTION_NS);
|
$form.off(INCEPTION_NS);
|
||||||
|
|
||||||
@ -159,19 +219,66 @@
|
|||||||
$form.on('change' + INCEPTION_NS, 'select, input:not([type=hidden]), textarea', function () {
|
$form.on('change' + INCEPTION_NS, 'select, input:not([type=hidden]), textarea', function () {
|
||||||
validateField(this);
|
validateField(this);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Select2 updates the native <select> but some paths need an explicit re-check
|
||||||
|
// so parsley-error / error lists clear after the user picks a value.
|
||||||
|
$form.on('select2:select' + INCEPTION_NS + ' select2:clear' + INCEPTION_NS, 'select', function () {
|
||||||
|
validateField(this);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
if (!isParsleyReady()) {
|
if (!isParsleyReady()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
registerSubmitAttemptLiveHook();
|
||||||
FORM_SELECTORS.forEach(function (selector) {
|
FORM_SELECTORS.forEach(function (selector) {
|
||||||
bindFormEvents(selector);
|
bindFormEvents(selector);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$(function () {
|
function initWithRetry(attemptsLeft) {
|
||||||
|
if (isParsleyReady()) {
|
||||||
init();
|
init();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (attemptsLeft <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
window.setTimeout(function () {
|
||||||
|
initWithRetry(attemptsLeft - 1);
|
||||||
|
}, 50);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!window.__policyInceptionSelect2DocHook) {
|
||||||
|
window.__policyInceptionSelect2DocHook = true;
|
||||||
|
$(function () {
|
||||||
|
$(document).on(
|
||||||
|
'select2:select select2:clear',
|
||||||
|
'#inception_form_id select, #vehicle_form select, #CDMasterForm select',
|
||||||
|
function () {
|
||||||
|
validateField(this);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$(function () {
|
||||||
|
// Parsley loads in the layout footer after this file; retry briefly if needed.
|
||||||
|
initWithRetry(40);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(window).on('load', function () {
|
||||||
|
if (!isParsleyReady()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FORM_SELECTORS.forEach(function (selector) {
|
||||||
|
var $f = $(selector);
|
||||||
|
if ($f.length) {
|
||||||
|
refreshParsleyInstance($f);
|
||||||
|
stripParsleyFormSubmitHandlers($f);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
window.refreshInceptionFormValidation = function (formSelector) {
|
window.refreshInceptionFormValidation = function (formSelector) {
|
||||||
@ -180,6 +287,28 @@
|
|||||||
}
|
}
|
||||||
bindFormEvents(formSelector);
|
bindFormEvents(formSelector);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Clears Parsley UI after native form.reset() or programmatic field changes. */
|
||||||
|
window.resetInceptionFormParsley = function (formSelector) {
|
||||||
|
var sel = formSelector || '#inception_form_id';
|
||||||
|
var $form = $(sel);
|
||||||
|
if (!$form.length || !isParsleyReady() || typeof $form.parsley !== 'function') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
$form.parsley().reset();
|
||||||
|
} catch (e) {
|
||||||
|
// no-op
|
||||||
|
}
|
||||||
|
stripOrphanParsleyUi($form);
|
||||||
|
$form.removeData(LIVE_VALIDATE_DATA);
|
||||||
|
try {
|
||||||
|
refreshParsleyInstance($form);
|
||||||
|
stripParsleyFormSubmitHandlers($form);
|
||||||
|
} catch (e2) {
|
||||||
|
// no-op
|
||||||
|
}
|
||||||
|
};
|
||||||
})(function () {
|
})(function () {
|
||||||
return window.jQuery;
|
return window.jQuery;
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user