MERGE_TEST_OPD&MINOR_ISSUES
This commit is contained in:
commit
cd51a8c0f1
16
.env.sample
16
.env.sample
@ -159,3 +159,19 @@ bds.dailyReportEmails =
|
||||
MEDIASSIST_WELLNESS_KEY =
|
||||
MEDIASSIST_WELLNESS_IV =
|
||||
MEDIASSIST_WELLNESS_LOGIN_URL =
|
||||
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Icici api details LIVE
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
ICICI_TOKEN_URL =
|
||||
ICICI_BASE_URL =
|
||||
ICICI_PASSWORD =
|
||||
ICICI_CLIENT_ID =
|
||||
ICICI_CLIENT_SECRET =
|
||||
ICICI_API_SCOPE =
|
||||
ICICI_GRANT_TYPE =
|
||||
|
||||
|
||||
ICICI_PRIMARY_KEY_CONSTANT =
|
||||
|
||||
@ -145,6 +145,7 @@ class ClientController extends AdminController
|
||||
private const ALLOWED_DUPLICATE_CHECK_TABLES = [
|
||||
'clients', 'client_branch', 'level_contacts', 'insurers', 'insurer_branch',
|
||||
'tpa', 'tpa_branch', 'policies', 'client_policy', 'user_profiles',
|
||||
'policy_transaction',
|
||||
];
|
||||
|
||||
public function checkDuplicateTableFieldValue()
|
||||
@ -5873,6 +5874,7 @@ class ClientController extends AdminController
|
||||
$policyListByClient = [];
|
||||
$unitList = [];
|
||||
$insurerBranchList = [];
|
||||
$policyCount = [];
|
||||
|
||||
//for client branch mapping to the client
|
||||
foreach ($branches as $branch) {
|
||||
@ -5901,20 +5903,30 @@ class ClientController extends AdminController
|
||||
$client['client_policy_count'] = $policyCount[$client['id']] ?? 0;
|
||||
}
|
||||
|
||||
if (!empty($branchList)) {
|
||||
if (!empty($clients)) {
|
||||
return $this->respond([
|
||||
'status' => true,
|
||||
'client_data' => $clients,
|
||||
'vehicle_data' => $vehicles,
|
||||
'branch_data' => $branchList,
|
||||
'policy_data' => $policyList,
|
||||
'policyListByClient' => $policyListByClient,
|
||||
'branch_data' => $branchList ?? [],
|
||||
'policy_data' => $policyList ?? [],
|
||||
'policyListByClient' => $policyListByClient ?? [],
|
||||
'insurer_data' => $insurers,
|
||||
'insurer_branch_data' => $insurerBranchList,
|
||||
'unit_data' => $unitList,
|
||||
'insurer_branch_data' => $insurerBranchList ?? [],
|
||||
'unit_data' => $unitList ?? [],
|
||||
], 200);
|
||||
} 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;
|
||||
$date_type = (!isset($date_type) || $date_type === '' || $date_type === null) ? 0 : $date_type;
|
||||
$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){
|
||||
$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;
|
||||
$date_type = (!isset($date_type) || $date_type === '' || $date_type === null) ? 0 : $date_type;
|
||||
$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){
|
||||
$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)
|
||||
// ->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
|
||||
->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.ebp,
|
||||
policy_type.etp,
|
||||
@ -5124,11 +5135,6 @@ class PolicyTransactionController extends BaseController
|
||||
foreach ($policies as $policy) {
|
||||
$policyList[$policy['client_branch_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];
|
||||
|
||||
@ -180,8 +180,8 @@ if (!function_exists('user_team')) {
|
||||
function user_team()
|
||||
{
|
||||
// $CI =& get_instance();
|
||||
$session = \Config\Services::session();
|
||||
return $session->get('user_team');
|
||||
$session = \Config\Services::session();
|
||||
return $session->get('user_team') ?: [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -92,7 +92,7 @@
|
||||
</div>
|
||||
<!-- 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>
|
||||
|
||||
var kycPrimaryKey = $('#client_id_kyc').val();
|
||||
|
||||
@ -164,6 +164,22 @@
|
||||
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>
|
||||
<script src="<?= base_url('public/assets/js/pages/policy_transaction_endorsement_form_validation.js') ?>"></script>
|
||||
|
||||
@ -181,7 +197,7 @@
|
||||
>Back</a>
|
||||
</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="client_id" id="client_id_for_edit">
|
||||
@ -1055,6 +1071,9 @@
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
$('#endorsement_form_id')[0].reset();
|
||||
if (typeof window.resetEndorsementFormParsley === 'function') {
|
||||
window.resetEndorsementFormParsley('#endorsement_form_id');
|
||||
}
|
||||
// var id = $(input).attr('data-id');
|
||||
var id = input;
|
||||
|
||||
@ -1088,10 +1107,77 @@
|
||||
$('#policy_tranction_primarykey_for_file_upload').val(res.data.id);
|
||||
$('#client_policy_id_for_file_upload').val(res.data.client_policy_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);
|
||||
|
||||
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 = '';
|
||||
if (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(){
|
||||
$('.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.data.client_policy_id);
|
||||
}else{
|
||||
let data2 = policy_list[res.data.client_branch_id];
|
||||
appendPolicies(data2, res.data.client_policy_id);
|
||||
}
|
||||
|
||||
setTimeout(function(){
|
||||
$('#policy_start_date').val(res.data.policy_start_date);
|
||||
$('#policy_end_date').val(res.data.policy_end_date);
|
||||
@ -1122,6 +1198,9 @@
|
||||
$('#client_id').addClass('readonly-select ').select2('destroy');
|
||||
$('#client_branch_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)
|
||||
|
||||
$('#policy_no').val(res.data.policy_no);
|
||||
|
||||
@ -181,8 +181,22 @@
|
||||
color: #dc3545;
|
||||
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>
|
||||
|
||||
<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="col-12">
|
||||
<div class="card">
|
||||
@ -196,7 +210,7 @@
|
||||
>Back</a>
|
||||
</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="client_id" id="client_id_for_edit">
|
||||
@ -931,10 +945,77 @@
|
||||
}
|
||||
|
||||
$('#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 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 = '';
|
||||
if (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(){
|
||||
$('.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);
|
||||
|
||||
@ -572,6 +572,9 @@
|
||||
$('.hideter').hide()
|
||||
$('.hidetp').hide()
|
||||
$('#endorsement_form_id')[0].reset();
|
||||
if (typeof window.resetEndorsementFormParsley === 'function') {
|
||||
window.resetEndorsementFormParsley('#endorsement_form_id');
|
||||
}
|
||||
$('#client_id').val('').change();
|
||||
$('#client_policy_id').val('').change();
|
||||
$('#invoice_no_div').hide();
|
||||
|
||||
@ -611,6 +611,9 @@ table.dataTable thead th {
|
||||
$('.hideter').hide()
|
||||
$('.hidetp').hide()
|
||||
$('#endorsement_form_id')[0].reset();
|
||||
if (typeof window.resetEndorsementFormParsley === 'function') {
|
||||
window.resetEndorsementFormParsley('#endorsement_form_id');
|
||||
}
|
||||
$('#client_id').val('').change();
|
||||
$('#client_policy_id').val('').change();
|
||||
$('#endorsement_form').show();
|
||||
|
||||
@ -307,6 +307,11 @@
|
||||
border-color: #28a745 !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>
|
||||
<script>
|
||||
var pageSubTitle = undefined;
|
||||
@ -332,7 +337,7 @@
|
||||
>Back</a>
|
||||
</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="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 unique_id', unique_id);
|
||||
|
||||
if (window.__inceptionEditHydrating === true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#insurer_id').val(insurer)
|
||||
|
||||
if (!policy_type_id || !client_id) {
|
||||
@ -2256,9 +2265,13 @@
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
$('#inception_form_id')[0].reset();
|
||||
if (typeof window.resetInceptionFormParsley === 'function') {
|
||||
window.resetInceptionFormParsley('#inception_form_id');
|
||||
}
|
||||
// var id = $(input).attr('data-id');
|
||||
var id = input;
|
||||
console.log('Selected policy transaction ID:', id);
|
||||
window.__inceptionEditHydrating = true;
|
||||
|
||||
$.ajax({
|
||||
url: '<?= base_url("/policy_tranction/inception/list/") ?>' + id,
|
||||
@ -2306,8 +2319,53 @@
|
||||
$('#issue_type').val(res.data.issue_type);
|
||||
|
||||
setTimeout(function() {
|
||||
$('#client_id').val(res.data.client_id).change();
|
||||
$('#client_type').val(res.data.client_type);
|
||||
// Order matters: client_type change rebuilds #client_id options.
|
||||
$('#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);
|
||||
$('#vehicle_no').val(res.data.vehicle_id).select2();
|
||||
}, 1000);
|
||||
@ -2583,6 +2641,7 @@
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
window.__inceptionEditHydrating = false;
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
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
|
||||
checkInvoiceStatusToHideSubmitBtn(id)
|
||||
|
||||
@ -3907,11 +3971,26 @@
|
||||
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) {
|
||||
|
||||
if (!this.checkValidity()) { return; }
|
||||
event.preventDefault();
|
||||
|
||||
normalizeDynamicRequiredBeforeInceptionSubmit();
|
||||
let policy_type_id = $('#policy_type_id').val();
|
||||
var isValid = $('#inception_form_id').parsley().validate();
|
||||
var client_type_id = $('#client_type').val();
|
||||
|
||||
@ -299,8 +299,22 @@
|
||||
color: #dc3545;
|
||||
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>
|
||||
|
||||
<script src="<?= base_url('public/assets/js/pages/policy_transaction_inception_form_validation.js') ?>"></script>
|
||||
|
||||
<div class="tab-pane fade active show" id="form">
|
||||
<input type="hidden" id="entity_type_id">
|
||||
<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>
|
||||
</div>
|
||||
</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="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 unique_id', unique_id);
|
||||
|
||||
if (window.__inceptionEditHydrating === true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#insurer_id').val(insurer)
|
||||
|
||||
if (!policy_type_id || !client_id) {
|
||||
@ -1777,9 +1795,13 @@
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
$('#inception_form_id')[0].reset();
|
||||
if (typeof window.resetInceptionFormParsley === 'function') {
|
||||
window.resetInceptionFormParsley('#inception_form_id');
|
||||
}
|
||||
// var id = $(input).attr('data-id');
|
||||
var id = input;
|
||||
console.log('Selected policy transaction ID:', id);
|
||||
window.__inceptionEditHydrating = true;
|
||||
|
||||
$.ajax({
|
||||
url: '<?= base_url("/policy_tranction/inception/list2/") ?>' + id,
|
||||
@ -1824,8 +1846,53 @@
|
||||
$('#issue_type').val(res.data.issue_type);
|
||||
|
||||
setTimeout(function() {
|
||||
$('#client_id').val(res.data.client_id).change();
|
||||
$('#client_type').val(res.data.client_type);
|
||||
// Order matters: client_type change rebuilds #client_id options.
|
||||
$('#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);
|
||||
$('#vehicle_no').val(res.data.vehicle_id).select2();
|
||||
}, 1000);
|
||||
@ -2111,6 +2178,7 @@
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
window.__inceptionEditHydrating = false;
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
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
|
||||
checkInvoiceStatusToHideSubmitBtn(id)
|
||||
|
||||
@ -3542,11 +3614,25 @@
|
||||
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) {
|
||||
|
||||
if (!this.checkValidity()) { return; }
|
||||
event.preventDefault();
|
||||
|
||||
normalizeDynamicRequiredBeforeInceptionSubmit();
|
||||
let policy_type_id = $('#policy_type_id').val();
|
||||
var isValid = $('#inception_form_id').parsley().validate();
|
||||
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>`;
|
||||
updateNavTitle('Add Policy', backButton);
|
||||
$('#inception_form_id')[0].reset();
|
||||
if (typeof window.resetInceptionFormParsley === 'function') {
|
||||
window.resetInceptionFormParsley('#inception_form_id');
|
||||
}
|
||||
$('#client_id').val('').change().prop('disabled', false);
|
||||
$('#tpa').val('').change().prop('disabled', false);
|
||||
$('#client_id_for_edit').val('');
|
||||
|
||||
@ -696,6 +696,9 @@ function hide_list_show_add_2()
|
||||
$('#pt_onboarding2').show();
|
||||
$('#page_title').text('Add Policy')
|
||||
$('#inception_form_id')[0].reset();
|
||||
if (typeof window.resetInceptionFormParsley === 'function') {
|
||||
window.resetInceptionFormParsley('#inception_form_id');
|
||||
}
|
||||
$('#client_id').val('').change().prop('disabled', false);
|
||||
$('#tpa').val('').change().prop('disabled', false);
|
||||
$('#client_id_for_edit').val('');
|
||||
|
||||
@ -249,7 +249,7 @@
|
||||
<div class="col-md-12" style="width: 94%;">
|
||||
<label class="form-label">Mobile</label>
|
||||
<!-- <input type="text" class="form-control" name="phone" style="width: 100%;" placeholder="Enter the Phone Number" oninput="this.value = this.value.replace(/[^\d\s+]/g, '')"> -->
|
||||
<input type="text" id="add_lead_phone" class="form-control" name="phone" style="width: 100%;" placeholder="Enter the Phone Number" maxlength="20" oninput="this.value = this.value.replace(/[^0-9+\\s]/g, ''); validateAddLeadField('phone')">
|
||||
<input type="text" id="add_lead_phone" class="form-control" name="phone" style="width: 100%;" placeholder="Enter the Phone Number" maxlength="10" oninput="this.value = this.value.replace(/[^0-9+\\s]/g, ''); validateAddLeadField('phone')">
|
||||
<small id="add_lead_phone_error" class="text-danger d-block mt-1 field-error"></small>
|
||||
</div>
|
||||
</div>
|
||||
@ -577,7 +577,7 @@
|
||||
<div class="col-md-12" style="width: 94%;">
|
||||
<label class="form-label">Mobile</label>
|
||||
<!-- <input type="text" class="form-control" name="phone" style="width: 100%;" placeholder="Enter the Phone Number" oninput="this.value = this.value.replace(/[^\d\s+]/g, '')"> -->
|
||||
<input type="text" id="edit_lead_phone" class="form-control" name="phone" style="width: 100%;" placeholder="Enter the Phone Number" maxlength="20" oninput="this.value = this.value.replace(/[^0-9+\s]/g, ''); validateEditLeadField('phone')">
|
||||
<input type="text" id="edit_lead_phone" class="form-control" name="phone" style="width: 100%;" placeholder="Enter the Phone Number" maxlength="10" oninput="this.value = this.value.replace(/[^0-9+\s]/g, ''); validateEditLeadField('phone')">
|
||||
<small id="edit_lead_phone_error" class="text-danger d-block mt-1 field-error"></small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
/**
|
||||
* Parsley validation for the leads form. Does not strip or rewrite user input;
|
||||
* invalid values are reported via Parsley messages only.
|
||||
*/
|
||||
(function (getJq) {
|
||||
'use strict';
|
||||
|
||||
@ -162,25 +166,6 @@
|
||||
});
|
||||
}
|
||||
|
||||
function sanitizeOnInput(el) {
|
||||
if (!el || isSkippableField(el)) {
|
||||
return;
|
||||
}
|
||||
if (isMobileField(el)) {
|
||||
var clean = (el.value || '').replace(/\D/g, '').substring(0, 10);
|
||||
if (el.value !== clean) {
|
||||
el.value = clean;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (isCharsetCandidate(el)) {
|
||||
var raw = el.value || '';
|
||||
if (!TEXT_ALLOWED.test(raw)) {
|
||||
el.value = raw.replace(/[^A-Za-z0-9/_.\- ]/g, '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function refreshParsley($form) {
|
||||
if (!$form || !$form.length || !isParsleyReady()) {
|
||||
return;
|
||||
@ -227,7 +212,6 @@
|
||||
|
||||
$form.off(NS);
|
||||
$form.on('input' + NS, 'input:not([type=hidden]), textarea', function () {
|
||||
sanitizeOnInput(this);
|
||||
validateField(this);
|
||||
});
|
||||
$form.on('change' + NS, 'select, input:not([type=hidden]), textarea', function () {
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
/**
|
||||
* Parsley validation for the new-client modal. Does not strip or rewrite user input;
|
||||
* invalid values are reported via Parsley messages only.
|
||||
*/
|
||||
(function (getJq) {
|
||||
'use strict';
|
||||
|
||||
@ -142,25 +146,6 @@
|
||||
});
|
||||
}
|
||||
|
||||
function sanitizeOnInput(el) {
|
||||
if (!el || isSkippable(el)) {
|
||||
return;
|
||||
}
|
||||
if (isMobile(el)) {
|
||||
var d = (el.value || '').replace(/\D/g, '').substring(0, 10);
|
||||
if (el.value !== d) {
|
||||
el.value = d;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (isCharsetCandidate(el)) {
|
||||
var raw = el.value || '';
|
||||
if (!TEXT_ALLOWED.test(raw)) {
|
||||
el.value = raw.replace(/[^A-Za-z0-9/_.\- ]/g, '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function refreshParsley($form) {
|
||||
try {
|
||||
var p = $form.parsley();
|
||||
@ -200,7 +185,6 @@
|
||||
|
||||
$form.off(NS);
|
||||
$form.on('input' + NS, 'input:not([type=hidden]), textarea', function () {
|
||||
sanitizeOnInput(this);
|
||||
validateField(this);
|
||||
});
|
||||
$form.on('change' + NS, 'select, input:not([type=hidden]), textarea', function () {
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
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 NS = '.endorsementFormValidate';
|
||||
var LIVE_VALIDATE_DATA = 'policyEndLiveValidate';
|
||||
|
||||
function isParsleyReady() {
|
||||
return !!window.Parsley;
|
||||
@ -62,6 +63,17 @@
|
||||
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) {
|
||||
if (!$form || !$form.length) {
|
||||
return;
|
||||
@ -77,15 +89,10 @@
|
||||
if (!$el.attr('data-parsley-endorsementcharset')) {
|
||||
$el.attr('data-parsley-endorsementcharset', 'true');
|
||||
}
|
||||
if (!$el.attr('data-parsley-trigger')) {
|
||||
$el.attr('data-parsley-trigger', 'input change');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (el.tagName === 'SELECT' && !$el.attr('data-parsley-trigger')) {
|
||||
$el.attr('data-parsley-trigger', 'change');
|
||||
}
|
||||
// Do not set data-parsley-trigger on <select> — see inception validation module.
|
||||
});
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
if (!field || isSkippableField(field) || !isParsleyReady()) {
|
||||
return;
|
||||
@ -113,6 +153,10 @@
|
||||
return;
|
||||
}
|
||||
|
||||
if (!shouldValidateLive($form, $field)) {
|
||||
return;
|
||||
}
|
||||
|
||||
applyConstraints($form);
|
||||
refreshParsley($form);
|
||||
|
||||
@ -129,9 +173,16 @@
|
||||
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();
|
||||
applyConstraints($form);
|
||||
refreshParsley($form);
|
||||
stripParsleyFormSubmitHandlers($form);
|
||||
|
||||
$form.off(NS);
|
||||
$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 () {
|
||||
validateField(this);
|
||||
});
|
||||
|
||||
$form.on('select2:select' + NS + ' select2:clear' + NS, 'select', function () {
|
||||
validateField(this);
|
||||
});
|
||||
}
|
||||
|
||||
function init() {
|
||||
if (!isParsleyReady()) {
|
||||
return;
|
||||
}
|
||||
registerSubmitAttemptLiveHook();
|
||||
FORM_SELECTORS.forEach(function (selector) {
|
||||
bindForm(selector);
|
||||
});
|
||||
}
|
||||
|
||||
function initWithRetry(attemptsLeft) {
|
||||
if (isParsleyReady()) {
|
||||
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 () {
|
||||
init();
|
||||
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) {
|
||||
@ -161,6 +256,27 @@
|
||||
}
|
||||
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 () {
|
||||
return window.jQuery;
|
||||
});
|
||||
|
||||
@ -13,6 +13,8 @@
|
||||
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 INCEPTION_NS = '.inceptionFormValidate';
|
||||
/** Enable all live field validation only after user attempted submit once. */
|
||||
var LIVE_VALIDATE_DATA = 'policyPtLiveValidate';
|
||||
|
||||
function isParsleyReady() {
|
||||
return !!window.Parsley;
|
||||
@ -74,6 +76,17 @@
|
||||
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) {
|
||||
if (!$form || !$form.length) {
|
||||
return;
|
||||
@ -91,15 +104,11 @@
|
||||
if (!$el.attr('data-parsley-inceptioncharset')) {
|
||||
$el.attr('data-parsley-inceptioncharset', 'true');
|
||||
}
|
||||
if (!$el.attr('data-parsley-trigger')) {
|
||||
$el.attr('data-parsley-trigger', 'input change');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (el.tagName === 'SELECT' && !$el.attr('data-parsley-trigger')) {
|
||||
$el.attr('data-parsley-trigger', 'change');
|
||||
}
|
||||
// Do not set data-parsley-trigger on <select>: Parsley would validate every
|
||||
// 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) {
|
||||
if (!field || isSkippableField(field) || !isParsleyReady()) {
|
||||
return;
|
||||
@ -129,6 +177,10 @@
|
||||
return;
|
||||
}
|
||||
|
||||
if (!shouldValidateLive($form, $field)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure dynamic fields also receive constraints before validation.
|
||||
applyConstraints($form);
|
||||
refreshParsleyInstance($form);
|
||||
@ -146,9 +198,17 @@
|
||||
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();
|
||||
applyConstraints($form);
|
||||
refreshParsleyInstance($form);
|
||||
stripParsleyFormSubmitHandlers($form);
|
||||
|
||||
$form.off(INCEPTION_NS);
|
||||
|
||||
@ -159,19 +219,66 @@
|
||||
$form.on('change' + INCEPTION_NS, 'select, input:not([type=hidden]), textarea', function () {
|
||||
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() {
|
||||
if (!isParsleyReady()) {
|
||||
return;
|
||||
}
|
||||
registerSubmitAttemptLiveHook();
|
||||
FORM_SELECTORS.forEach(function (selector) {
|
||||
bindFormEvents(selector);
|
||||
});
|
||||
}
|
||||
|
||||
function initWithRetry(attemptsLeft) {
|
||||
if (isParsleyReady()) {
|
||||
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 () {
|
||||
init();
|
||||
// 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) {
|
||||
@ -180,6 +287,28 @@
|
||||
}
|
||||
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 () {
|
||||
return window.jQuery;
|
||||
});
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
/**
|
||||
* Ticket forms + claim file upload: charset, email, pincode, mobile, URLs, doc names.
|
||||
* Integrates with Parsley only — no separate Bootstrap invalid-feedback.
|
||||
* Does not strip or rewrite user input; invalid values are reported via Parsley messages only.
|
||||
* Requires jQuery + Parsley. Inits run before form-validation.init binds .parsley-examples.
|
||||
*
|
||||
* Do not capture window.jQuery at parse time: layout/header.php loads full jQuery then jquery.slim,
|
||||
@ -28,6 +29,8 @@
|
||||
var MOBILE_IDS = ['emp_mobile', 'hospital_phone_no'];
|
||||
var PINCODE_IDS = ['hospital_pin_code'];
|
||||
var DIGITS_ONLY_IDS = ['claim_amount', 'approved_amount', 'si_amt'];
|
||||
/** Same validation as claim upload URL fields — charset rules would strip : ? & from https links. */
|
||||
var APPROVED_SETTLE_LETTER_URL_IDS = ['approved_letter', 'settle_letter'];
|
||||
|
||||
var MESSAGES = {
|
||||
text: 'Only letters, numbers, spaces, and the characters / _ - . are allowed.',
|
||||
@ -83,6 +86,9 @@
|
||||
if (DIGITS_ONLY_IDS.indexOf(id) !== -1) {
|
||||
return 'digits';
|
||||
}
|
||||
if (APPROVED_SETTLE_LETTER_URL_IDS.indexOf(id) !== -1) {
|
||||
return 'urlfield';
|
||||
}
|
||||
return 'text';
|
||||
}
|
||||
|
||||
@ -360,51 +366,12 @@
|
||||
});
|
||||
}
|
||||
|
||||
function sanitizeOnInput(el) {
|
||||
var id = el.id;
|
||||
if (!id || el.type === 'hidden' || isReadonly(el)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var kind = getFieldKindFromElement(el);
|
||||
var $el = $(el);
|
||||
|
||||
if (kind === 'mobile') {
|
||||
var m = (el.value || '').replace(/\D/g, '').substring(0, 10);
|
||||
if (el.value !== m) {
|
||||
el.value = m;
|
||||
}
|
||||
} else if (kind === 'pincode') {
|
||||
var p = (el.value || '').replace(/\D/g, '').substring(0, 6);
|
||||
if (el.value !== p) {
|
||||
el.value = p;
|
||||
}
|
||||
} else if (kind === 'digits') {
|
||||
var d = (el.value || '').replace(/\D/g, '');
|
||||
if (el.value !== d) {
|
||||
el.value = d;
|
||||
}
|
||||
} else if (kind === 'email' || kind === 'personalemail' || kind === 'urlfield') {
|
||||
return;
|
||||
} else if (kind === 'docname') {
|
||||
var dn = el.value || '';
|
||||
if (!DOCNAME_ALLOWED.test(dn)) {
|
||||
el.value = dn.replace(/[^a-zA-Z0-9_\- ]/g, '');
|
||||
}
|
||||
} else if (kind === 'text') {
|
||||
var raw = el.value || '';
|
||||
if (!TEXT_ALLOWED.test(raw)) {
|
||||
el.value = raw.replace(/[^A-Za-z0-9/_.\- ]/g, '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onFormInput(e) {
|
||||
var el = e.target;
|
||||
if (!el || (el.tagName !== 'INPUT' && el.tagName !== 'TEXTAREA')) {
|
||||
return;
|
||||
}
|
||||
sanitizeOnInput(el);
|
||||
revalidateParsleyField(el);
|
||||
}
|
||||
|
||||
function revalidateParsleyField(el) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user