FIX_LIVE_ISSUE
This commit is contained in:
parent
21594469bc
commit
eb3d58c69a
@ -15,6 +15,7 @@ use App\Controllers\MediAssistApiController;
|
|||||||
use App\Controllers\FhplApiController;
|
use App\Controllers\FhplApiController;
|
||||||
use App\Controllers\VoloApiController;
|
use App\Controllers\VoloApiController;
|
||||||
use App\Models\BatchFileModel;
|
use App\Models\BatchFileModel;
|
||||||
|
use App\Models\ClaimFilesModel;
|
||||||
use App\Models\FileModel;
|
use App\Models\FileModel;
|
||||||
use App\Helpers\TPADataCompareHelper;
|
use App\Helpers\TPADataCompareHelper;
|
||||||
use App\Helpers\TPADataCompareHelper2;
|
use App\Helpers\TPADataCompareHelper2;
|
||||||
@ -25,6 +26,7 @@ class ApiServiceController extends BaseController
|
|||||||
// protected $format = 'json';
|
// protected $format = 'json';
|
||||||
protected $db;
|
protected $db;
|
||||||
protected $employeePolicyModel;
|
protected $employeePolicyModel;
|
||||||
|
protected $claimFilesModel;
|
||||||
protected $medi_assist_primary_key;
|
protected $medi_assist_primary_key;
|
||||||
protected $vidal_primary_key;
|
protected $vidal_primary_key;
|
||||||
protected $icici_primary_key;
|
protected $icici_primary_key;
|
||||||
@ -36,6 +38,7 @@ class ApiServiceController extends BaseController
|
|||||||
{
|
{
|
||||||
$this->db = \Config\Database::connect();
|
$this->db = \Config\Database::connect();
|
||||||
$this->employeePolicyModel = new EmployeePolicyModel();
|
$this->employeePolicyModel = new EmployeePolicyModel();
|
||||||
|
$this->claimFilesModel = new ClaimFilesModel();
|
||||||
$this->medi_assist_primary_key = getenv('MEDI_ASSIST_PRIMARY_KEY_CONSTANT');
|
$this->medi_assist_primary_key = getenv('MEDI_ASSIST_PRIMARY_KEY_CONSTANT');
|
||||||
$this->vidal_primary_key = getenv('VIDAL_PRIMARY_KEY_CONSTANT');
|
$this->vidal_primary_key = getenv('VIDAL_PRIMARY_KEY_CONSTANT');
|
||||||
$this->icici_primary_key = getenv('ICICI_PRIMARY_KEY_CONSTANT');
|
$this->icici_primary_key = getenv('ICICI_PRIMARY_KEY_CONSTANT');
|
||||||
@ -177,26 +180,20 @@ class ApiServiceController extends BaseController
|
|||||||
$voloApiController = new VoloApiController();
|
$voloApiController = new VoloApiController();
|
||||||
$data['eCardDownload'] = $voloApiController->EcardRequest( $emp_code, $policy_no , $employee_policy[0]['tpa_id'] );
|
$data['eCardDownload'] = $voloApiController->EcardRequest( $emp_code, $policy_no , $employee_policy[0]['tpa_id'] );
|
||||||
|
|
||||||
}else{
|
|
||||||
|
|
||||||
if($type == "download"){
|
|
||||||
// direct download
|
|
||||||
$data['eCardDownload'] = base_url('download-e-card/') . $employee_policy[0]['rand_string'].'/1';
|
|
||||||
}else{
|
|
||||||
if(isset($all_member) && !empty($all_member)){
|
|
||||||
// view and download all members
|
|
||||||
$data['eCardDownload'] = base_url('download-e-card/') . $employee_policy[0]['rand_string'].'/1/1';
|
|
||||||
}else{
|
|
||||||
// view and download single member
|
|
||||||
$data['eCardDownload'] = base_url('download-e-card/') . $employee_policy[0]['rand_string'].'/0/1';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['message'] = "E-card generated";
|
if (empty($data['eCardDownload'])) {
|
||||||
if(empty($data['eCardDownload'])){
|
$data['eCardDownload'] = $this->buildDefaultEcardDownloadUrl(
|
||||||
$data['message'] = "E-card not generated";
|
$employee_policy[0]['rand_string'],
|
||||||
}
|
$type,
|
||||||
|
$all_member ?? null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['message'] = "E-card generated";
|
||||||
|
if(empty($data['eCardDownload'])){
|
||||||
|
$data['message'] = "E-card not generated";
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$data['eCardDownload'] = null;
|
$data['eCardDownload'] = null;
|
||||||
@ -220,6 +217,19 @@ class ApiServiceController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function buildDefaultEcardDownloadUrl(string $randString, string $type = 'download', $allMember = null): string
|
||||||
|
{
|
||||||
|
if ($type === 'download') {
|
||||||
|
return base_url('download-e-card/') . $randString . '/1';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($allMember)) {
|
||||||
|
return base_url('download-e-card/') . $randString . '/1/1';
|
||||||
|
}
|
||||||
|
|
||||||
|
return base_url('download-e-card/') . $randString . '/0/1';
|
||||||
|
}
|
||||||
|
|
||||||
// Get TPAID
|
// Get TPAID
|
||||||
public function getTPAID()
|
public function getTPAID()
|
||||||
{
|
{
|
||||||
@ -583,6 +593,13 @@ class ApiServiceController extends BaseController
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! $this->claimFilesModel->hasPdfFileForTicket($claimId)) {
|
||||||
|
return $this->response->setJSON([
|
||||||
|
'status' => false,
|
||||||
|
'message' => 'No PDF file found for this claim'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
$result = $this->pushClaims($claimId);
|
$result = $this->pushClaims($claimId);
|
||||||
|
|
||||||
if ($result !== null && is_array($result)) {
|
if ($result !== null && is_array($result)) {
|
||||||
|
|||||||
@ -1297,6 +1297,7 @@ class TicketServiceController extends AdminController
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
//check the employee and insured
|
//check the employee and insured
|
||||||
|
$params['is_from'] = 'claim_dump';
|
||||||
$employee_data = $ticketMasterModal->getEmployeeAndEmployeePolicyDetails($params) ?? [];
|
$employee_data = $ticketMasterModal->getEmployeeAndEmployeePolicyDetails($params) ?? [];
|
||||||
// dd($employee_data);
|
// dd($employee_data);
|
||||||
if (count($employee_data) == 0) {
|
if (count($employee_data) == 0) {
|
||||||
|
|||||||
@ -59,4 +59,18 @@ class ClaimFilesModel extends Model
|
|||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the claim (ticket) has at least one active PDF in claim_files.
|
||||||
|
*/
|
||||||
|
public function hasPdfFileForTicket($ticketId): bool
|
||||||
|
{
|
||||||
|
return $this->where('ticket_id', $ticketId)
|
||||||
|
->where('is_active', 1)
|
||||||
|
->groupStart()
|
||||||
|
->where('mime_type', 'pdf')
|
||||||
|
->orWhere('mime_type', 'application/pdf')
|
||||||
|
->groupEnd()
|
||||||
|
->countAllResults(false) > 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1118,12 +1118,23 @@ class TicketMasterModel extends Model
|
|||||||
$policy_no = $params['policy_no'] ?? null;
|
$policy_no = $params['policy_no'] ?? null;
|
||||||
$relationship = $params['relationship'] ?? null;
|
$relationship = $params['relationship'] ?? null;
|
||||||
$insured_name = $params['insured_name'] ?? null;
|
$insured_name = $params['insured_name'] ?? null;
|
||||||
|
$is_from = $params['is_from'] ?? null;
|
||||||
|
|
||||||
// $client_name = "6-Eleven";
|
// $client_name = "6-Eleven";
|
||||||
// $emp_code = "EMP0020K12";
|
// $emp_code = "EMP0020K12";
|
||||||
// $emp_name = "Lokesh";
|
// $emp_name = "Lokesh";
|
||||||
// $policy_no = "GMC-1999/2000/2021/2022";
|
// $policy_no = "GMC-1999/2000/2021/2022";
|
||||||
|
|
||||||
|
$base_policy_id = null;
|
||||||
|
if($is_from == "claim_dump"){
|
||||||
|
$client_policy_data = $this->db->table('client_policy')->where('policy_no', trim($policy_no))->where('is_active', 1)->get()->getRowArray();
|
||||||
|
if(isset($client_policy_data) && !empty($client_policy_data)){
|
||||||
|
if(!empty($client_policy_data['base_policy'])) {
|
||||||
|
$base_policy_id = $client_policy_data['base_policy'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$builder = $this->db->table('employees e');
|
$builder = $this->db->table('employees e');
|
||||||
$builder->select("
|
$builder->select("
|
||||||
e.id as emp_id,
|
e.id as emp_id,
|
||||||
@ -1161,7 +1172,13 @@ class TicketMasterModel extends Model
|
|||||||
$builder->where('e.emp_code', trim($emp_code));
|
$builder->where('e.emp_code', trim($emp_code));
|
||||||
$builder->where('e.name', trim($emp_name));
|
$builder->where('e.name', trim($emp_name));
|
||||||
$builder->where('c.client_name', trim($client_name));
|
$builder->where('c.client_name', trim($client_name));
|
||||||
$builder->where('cp.policy_no', trim($policy_no));
|
|
||||||
|
if(!empty($base_policy_id)) {
|
||||||
|
$builder->where('cp.id', trim($base_policy_id));
|
||||||
|
} else {
|
||||||
|
$builder->where('cp.policy_no', trim($policy_no));
|
||||||
|
}
|
||||||
|
|
||||||
$builder->where('LOWER(e.relationship)', strtolower('self'));
|
$builder->where('LOWER(e.relationship)', strtolower('self'));
|
||||||
|
|
||||||
$query = $builder->get();
|
$query = $builder->get();
|
||||||
|
|||||||
@ -163,7 +163,8 @@
|
|||||||
</h4> -->
|
</h4> -->
|
||||||
</div>
|
</div>
|
||||||
<form role="form" class="parsley-examples" method="post" id="leads_form_id"
|
<form role="form" class="parsley-examples" method="post" id="leads_form_id"
|
||||||
enctype="multipart/form-data">
|
enctype="multipart/form-data"
|
||||||
|
data-parsley-excluded="input[type=button], input[type=submit], input[type=reset], input[type=hidden], [disabled], :hidden, .select2-search__field">
|
||||||
|
|
||||||
<input type="hidden" name="id" id="leads_primarykey">
|
<input type="hidden" name="id" id="leads_primarykey">
|
||||||
<input type="hidden" name="lead_form_type" id="lead_form_type_id" value="<?= isset($selected_lead_type) ? $selected_lead_type : 1 ?>">
|
<input type="hidden" name="lead_form_type" id="lead_form_type_id" value="<?= isset($selected_lead_type) ? $selected_lead_type : 1 ?>">
|
||||||
@ -487,7 +488,7 @@
|
|||||||
|
|
||||||
function restoreActualLeadGstNumber() {
|
function restoreActualLeadGstNumber() {
|
||||||
if ($('#actual_lead_id').val() && $('#actual_lead_id').val() != 0 && actualLeadGstNumber) {
|
if ($('#actual_lead_id').val() && $('#actual_lead_id').val() != 0 && actualLeadGstNumber) {
|
||||||
$('#gst').val(actualLeadGstNumber);
|
$('#gst').val(String(actualLeadGstNumber).trim().toUpperCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1774,15 +1775,51 @@
|
|||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
|
if (typeof window.prepareLeadsFormForSubmit === 'function') {
|
||||||
|
window.prepareLeadsFormForSubmit();
|
||||||
|
}
|
||||||
|
|
||||||
var isValid = $('#leads_form_id').parsley().validate();
|
var isValid = $('#leads_form_id').parsley().validate();
|
||||||
|
|
||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
$('#leads_form_id').find('input, select, textarea').each(function() {
|
var invalidFields = typeof window.getLeadsFormInvalidFields === 'function'
|
||||||
if ($(this).parsley().isValid() === false && !$(this).val()) {
|
? window.getLeadsFormInvalidFields()
|
||||||
console.log('Empty field ID:', this.id);
|
: [];
|
||||||
|
|
||||||
|
if (invalidFields.length) {
|
||||||
|
console.table(invalidFields);
|
||||||
|
invalidFields.forEach(function(f) {
|
||||||
|
console.log('Invalid field:', f.label || f.name || f.id, f);
|
||||||
|
});
|
||||||
|
|
||||||
|
var firstInvalid = invalidFields[0];
|
||||||
|
var fieldLabel = firstInvalid.label || firstInvalid.name || firstInvalid.id || 'A required field';
|
||||||
|
var fieldMessage = (firstInvalid.messages && firstInvalid.messages.length)
|
||||||
|
? firstInvalid.messages[0]
|
||||||
|
: (firstInvalid.isEmpty ? 'This field is required.' : 'Please check this field.');
|
||||||
|
|
||||||
|
if (typeof toastr !== 'undefined') {
|
||||||
|
toastr.warning(fieldLabel + ': ' + fieldMessage, 'Validation');
|
||||||
}
|
}
|
||||||
});
|
|
||||||
console.log('Form is Empty', 'Warning');
|
if (firstInvalid.id) {
|
||||||
|
var $invalidField = $('#' + firstInvalid.id);
|
||||||
|
if ($invalidField.length) {
|
||||||
|
var scrollTarget = $invalidField.closest('.form-group, .card, .dynamic-form-row');
|
||||||
|
if (scrollTarget.length) {
|
||||||
|
$('html, body').animate({
|
||||||
|
scrollTop: scrollTarget.offset().top - 100
|
||||||
|
}, 300);
|
||||||
|
}
|
||||||
|
$invalidField.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.warn('Form validation failed');
|
||||||
|
if (typeof toastr !== 'undefined') {
|
||||||
|
toastr.warning('Please correct the highlighted fields.', 'Validation');
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2564,6 +2601,10 @@
|
|||||||
toggleRequiredFields();
|
toggleRequiredFields();
|
||||||
restoreActualLeadGstNumber();
|
restoreActualLeadGstNumber();
|
||||||
restoreActualLeadContactDetails();
|
restoreActualLeadContactDetails();
|
||||||
|
|
||||||
|
if (typeof window.refreshLeadsFormValidation === 'function') {
|
||||||
|
window.refreshLeadsFormValidation();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleRequiredFields() {
|
function toggleRequiredFields() {
|
||||||
@ -2694,7 +2735,7 @@
|
|||||||
actualLeadClientName = actual_lead_client_details.company_name || '';
|
actualLeadClientName = actual_lead_client_details.company_name || '';
|
||||||
$('#client_name').val(actualLeadClientName);
|
$('#client_name').val(actualLeadClientName);
|
||||||
|
|
||||||
actualLeadGstNumber = actual_lead_client_details.gst_number || actual_lead_client_details.gst || '';
|
actualLeadGstNumber = (actual_lead_client_details.gst_number || actual_lead_client_details.gst || '').toString().trim().toUpperCase();
|
||||||
$('#gst').val(actualLeadGstNumber);
|
$('#gst').val(actualLeadGstNumber);
|
||||||
if (actual_lead_client_details.client_type !== undefined && actual_lead_client_details.client_type !== null && actual_lead_client_details.client_type !== '') {
|
if (actual_lead_client_details.client_type !== undefined && actual_lead_client_details.client_type !== null && actual_lead_client_details.client_type !== '') {
|
||||||
$('#client_type').val(String(actual_lead_client_details.client_type));
|
$('#client_type').val(String(actual_lead_client_details.client_type));
|
||||||
|
|||||||
@ -39,12 +39,25 @@
|
|||||||
<div class="card" style="margin-right: 23px;">
|
<div class="card" style="margin-right: 23px;">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$tpaActionButtons = '';
|
||||||
|
if (
|
||||||
|
!empty($ticket_data['is_tpa_api_service_enabled']) &&
|
||||||
|
empty($ticket_data['tpa_claim_push_reference_no']) &&
|
||||||
|
($ticket_data['claim_created_by'] ?? '') !== 'TPA'
|
||||||
|
) {
|
||||||
|
$tpaActionButtons .= ' <a href="#" class="btn btn-success btn-sm mr-2" onclick="manualTpaClaimPush(); return false;">Manual TPA Claim Push</a>';
|
||||||
|
}
|
||||||
|
if (!empty($ticket_data['tpa_claim_push_reference_no'])) {
|
||||||
|
$tpaActionButtons .= ' <a href="#" class="btn btn-success btn-sm mr-2" onclick="fetchTpaClaimStatus(); return false;">Fetch Claim Status</a>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
<script>
|
<script>
|
||||||
var pageHideMainNavTitle = true;
|
var pageHideMainNavTitle = true;
|
||||||
var pageTitle = 'Claims<?php if(isset($ticket_data["tpa_claim_push_reference_no"]) && !empty($ticket_data["tpa_claim_push_reference_no"])) { echo " <a href=\"#\" class=\"btn btn-success mr-2\" onclick=\"fetchTpaClaimStatus()\">Fetch Claim Status</a>"; } ?>';
|
var pageTitle = 'Claims <?= $tpaActionButtons ?>';
|
||||||
var pageBackButton = '<a href="<?= base_url("ticket/list"); ?>" class="topbar-icon-btn" data-toggle="tooltip" data-placement="top" title="Back" aria-label="Back to list"><i class="ri-arrow-left-s-line"></i></a>';
|
var pageBackButton = '<a href="<?= base_url("ticket/list"); ?>" class="topbar-icon-btn" data-toggle="tooltip" data-placement="top" title="Back" aria-label="Back to list"><i class="ri-arrow-left-s-line"></i></a>';
|
||||||
</script>
|
</script>
|
||||||
<!-- Header Section -->
|
<!-- Header Section (TPA actions rendered in top navbar via pageTitle) -->
|
||||||
<!-- <div class="row mb-3 align-items-center justify-content-between">
|
<!-- <div class="row mb-3 align-items-center justify-content-between">
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
<h4 class="mb-0">Claims</h4>
|
<h4 class="mb-0">Claims</h4>
|
||||||
@ -56,7 +69,7 @@
|
|||||||
<?php if (
|
<?php if (
|
||||||
$ticket_data['is_tpa_api_service_enabled'] == true &&
|
$ticket_data['is_tpa_api_service_enabled'] == true &&
|
||||||
empty($ticket_data['tpa_claim_push_reference_no']) &&
|
empty($ticket_data['tpa_claim_push_reference_no']) &&
|
||||||
empty($ticket_data['claim_number'])
|
$ticket_data['claim_created_by'] != 'TPA'
|
||||||
) : ?>
|
) : ?>
|
||||||
<a href="#" class="btn btn-success mr-2" onclick="manualTpaClaimPush(); return false;">
|
<a href="#" class="btn btn-success mr-2" onclick="manualTpaClaimPush(); return false;">
|
||||||
Manual TPA Claim Push
|
Manual TPA Claim Push
|
||||||
|
|||||||
@ -577,6 +577,104 @@
|
|||||||
<script>
|
<script>
|
||||||
let GlobelExtraFields = [];
|
let GlobelExtraFields = [];
|
||||||
var doa;
|
var doa;
|
||||||
|
var STATUS_SECTION_CLASSES = ['cda_ir', 'settled', 'approved', 'rejected', 'up_qdr', 'up_cnu', 'canceled', 'returned', 'payment', 'non_id'];
|
||||||
|
var statusSectionInitialValues = {};
|
||||||
|
|
||||||
|
function captureSectionInitialValues(sectionClass) {
|
||||||
|
if (!sectionClass) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var values = {};
|
||||||
|
$('.' + sectionClass).find('input, textarea, select').each(function() {
|
||||||
|
var el = this;
|
||||||
|
var key = el.id || el.name;
|
||||||
|
if (!key) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
values[key] = el.type === 'file' ? '' : String($(el).val() || '');
|
||||||
|
});
|
||||||
|
statusSectionInitialValues[sectionClass] = values;
|
||||||
|
}
|
||||||
|
|
||||||
|
function captureAllStatusSectionInitialValues() {
|
||||||
|
STATUS_SECTION_CLASSES.forEach(captureSectionInitialValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasSectionChanged(sectionClass) {
|
||||||
|
if (!sectionClass) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var initial = statusSectionInitialValues[sectionClass];
|
||||||
|
if (!initial) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var changed = false;
|
||||||
|
$('.' + sectionClass).find('input, textarea, select').each(function() {
|
||||||
|
var el = this;
|
||||||
|
var key = el.id || el.name;
|
||||||
|
if (!key) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (el.type === 'file') {
|
||||||
|
if (el.files && el.files.length > 0) {
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var current = String($(el).val() || '');
|
||||||
|
var original = String(initial[key] !== undefined ? initial[key] : '');
|
||||||
|
if (current !== original) {
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateSectionRequiredLabels(sectionClass, isRequired) {
|
||||||
|
if (!sectionClass) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$('.' + sectionClass).find('input, textarea, select').each(function() {
|
||||||
|
var fieldId = $(this).attr('id');
|
||||||
|
if (!fieldId || fieldId === 'approved_description') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var $label = $("label[for='" + fieldId + "']");
|
||||||
|
if (!$label.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (isRequired && !$label.find('.text-danger').length) {
|
||||||
|
$label.append(' <span class="text-danger">*</span>');
|
||||||
|
} else if (!isRequired) {
|
||||||
|
$label.find('.text-danger').remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyConditionalRequiredForSection(sectionClass) {
|
||||||
|
if (!sectionClass) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (sectionClass === 'approved' || sectionClass === 'settled') {
|
||||||
|
enforceLetterPairRules();
|
||||||
|
updateSectionRequiredLabels(sectionClass, hasSectionChanged(sectionClass));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var changed = hasSectionChanged(sectionClass);
|
||||||
|
$('.' + sectionClass).find('input, textarea, select').each(function() {
|
||||||
|
if (this.id === 'approved_description') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$(this).prop('required', changed);
|
||||||
|
});
|
||||||
|
updateSectionRequiredLabels(sectionClass, changed);
|
||||||
|
}
|
||||||
|
|
||||||
|
function refreshAllStatusSectionRequired() {
|
||||||
|
STATUS_SECTION_CLASSES.forEach(applyConditionalRequiredForSection);
|
||||||
|
$('#approved_description').prop('required', false);
|
||||||
|
$("label[for='approved_description'] .text-danger").remove();
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
@ -645,6 +743,8 @@
|
|||||||
GlobelExtraFields = extraFields;
|
GlobelExtraFields = extraFields;
|
||||||
console.log("extraFields", extraFields);
|
console.log("extraFields", extraFields);
|
||||||
claimStatusFieldChanges(extraFields);
|
claimStatusFieldChanges(extraFields);
|
||||||
|
captureAllStatusSectionInitialValues();
|
||||||
|
refreshAllStatusSectionRequired();
|
||||||
handleTPARequired(tpa_id_for_hid_filed);
|
handleTPARequired(tpa_id_for_hid_filed);
|
||||||
// syncApprovedLetterInputs();
|
// syncApprovedLetterInputs();
|
||||||
// syncSettleLetterInputs();
|
// syncSettleLetterInputs();
|
||||||
@ -736,24 +836,16 @@
|
|||||||
showClass = '.payment';
|
showClass = '.payment';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show the relevant section and enable required attributes
|
|
||||||
if (showClass) {
|
if (showClass) {
|
||||||
// $(showClass).show().find('input, textarea').attr('required', true);
|
$(showClass).show();
|
||||||
$(showClass).show().find('input, textarea').attr('required', true).each(function() {
|
captureSectionInitialValues(showClass.replace('.', ''));
|
||||||
var $label = $("label[for='" + $(this).attr('id') + "']");
|
|
||||||
if ($label.length && !$label.find('.text-danger').length) {
|
|
||||||
$label.append(' <span class="text-danger">*</span>');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$field = $('#approved_description')
|
$field = $('#approved_description')
|
||||||
$field.prop('required', false);
|
$field.prop('required', false);
|
||||||
var $parentDiv = $field.closest("div");
|
var $parentDiv = $field.closest("div");
|
||||||
$parentDiv.find("label[for='approved_description'] .text-danger").remove();
|
$parentDiv.find("label[for='approved_description'] .text-danger").remove();
|
||||||
syncApprovedLetterInputs();
|
refreshAllStatusSectionRequired();
|
||||||
syncSettleLetterInputs();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#claim_status_id').on('change', function() {
|
$('#claim_status_id').on('change', function() {
|
||||||
@ -837,13 +929,13 @@
|
|||||||
const hasUrl = $.trim($urlInput.val()) !== '';
|
const hasUrl = $.trim($urlInput.val()) !== '';
|
||||||
const hasFile = $fileInput[0].files && $fileInput[0].files.length > 0;
|
const hasFile = $fileInput[0].files && $fileInput[0].files.length > 0;
|
||||||
const isApprovedSectionVisible = $urlInput.closest('.approved').is(':visible');
|
const isApprovedSectionVisible = $urlInput.closest('.approved').is(':visible');
|
||||||
|
const approvedSectionChanged = hasSectionChanged('approved');
|
||||||
|
|
||||||
$fileInput.prop('disabled', hasUrl);
|
$fileInput.prop('disabled', hasUrl);
|
||||||
$urlInput.prop('disabled', hasFile);
|
$urlInput.prop('disabled', hasFile);
|
||||||
|
|
||||||
// Keep the file optional; URL remains conditionally required for approved state unless file is present.
|
|
||||||
$fileInput.prop('required', false);
|
$fileInput.prop('required', false);
|
||||||
$urlInput.prop('required', isApprovedSectionVisible && !hasFile);
|
$urlInput.prop('required', isApprovedSectionVisible && approvedSectionChanged && !hasFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
function syncSettleLetterInputs() {
|
function syncSettleLetterInputs() {
|
||||||
@ -857,12 +949,13 @@
|
|||||||
const hasUrl = $.trim($urlInput.val()) !== '';
|
const hasUrl = $.trim($urlInput.val()) !== '';
|
||||||
const hasFile = $fileInput[0].files && $fileInput[0].files.length > 0;
|
const hasFile = $fileInput[0].files && $fileInput[0].files.length > 0;
|
||||||
const isSettledSectionVisible = $urlInput.closest('.settled').is(':visible');
|
const isSettledSectionVisible = $urlInput.closest('.settled').is(':visible');
|
||||||
|
const settledSectionChanged = hasSectionChanged('settled');
|
||||||
|
|
||||||
$fileInput.prop('disabled', hasUrl);
|
$fileInput.prop('disabled', hasUrl);
|
||||||
$urlInput.prop('disabled', hasFile);
|
$urlInput.prop('disabled', hasFile);
|
||||||
|
|
||||||
$fileInput.prop('required', false);
|
$fileInput.prop('required', false);
|
||||||
$urlInput.prop('required', isSettledSectionVisible && !hasFile);
|
$urlInput.prop('required', isSettledSectionVisible && settledSectionChanged && !hasFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
function enforceLetterPairRules() {
|
function enforceLetterPairRules() {
|
||||||
@ -956,10 +1049,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
var selectedClaimStatus = $('#claim_status_id').val();
|
var selectedClaimStatus = $('#claim_status_id').val();
|
||||||
|
|
||||||
|
if (thirdClass === 'approved' || thirdClass === 'settled') {
|
||||||
|
applyConditionalRequiredForSection(thirdClass);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var sectionChanged = hasSectionChanged(thirdClass);
|
||||||
var $thirdClass = $(`.${thirdClass}`);
|
var $thirdClass = $(`.${thirdClass}`);
|
||||||
var hasValue = $thirdClass.find('input, textarea, select').filter(function() {
|
|
||||||
return $(this).val().trim() !== ''; // Check if at least one field is not empty
|
|
||||||
}).length > 0;
|
|
||||||
|
|
||||||
$thirdClass.each(function() {
|
$thirdClass.each(function() {
|
||||||
var id = $(this).find('[id]').first().attr('id');
|
var id = $(this).find('[id]').first().attr('id');
|
||||||
@ -967,27 +1064,19 @@
|
|||||||
var $thisDiv = $(this);
|
var $thisDiv = $(this);
|
||||||
var $inputs = $thisDiv.find('input, textarea, select');
|
var $inputs = $thisDiv.find('input, textarea, select');
|
||||||
|
|
||||||
|
|
||||||
// ✅ Condition 1: Check if this ID is in extraFieldsArray (required by status)
|
|
||||||
var shouldAddRequired = extrafieldsArray[selectedClaimStatus] && extrafieldsArray[selectedClaimStatus].includes(id);
|
var shouldAddRequired = extrafieldsArray[selectedClaimStatus] && extrafieldsArray[selectedClaimStatus].includes(id);
|
||||||
|
|
||||||
// ✅ Condition 2: If any field in the class has a value, make all required
|
if (shouldAddRequired || sectionChanged) {
|
||||||
if (shouldAddRequired || hasValue) {
|
|
||||||
if ($label.length && !$label.find('.text-danger').length) {
|
if ($label.length && !$label.find('.text-danger').length) {
|
||||||
$label.append(' <span class="text-danger">*</span>');
|
$label.append(' <span class="text-danger">*</span>');
|
||||||
}
|
}
|
||||||
console.log("input from if ", $inputs);
|
|
||||||
// $inputs.attr('required', true);
|
|
||||||
$('.' + thirdClass).find('input, textarea,select').attr('required', true);
|
$('.' + thirdClass).find('input, textarea,select').attr('required', true);
|
||||||
} else {
|
} else {
|
||||||
$label.find('.text-danger').remove();
|
$label.find('.text-danger').remove();
|
||||||
console.log("input ", $inputs);
|
|
||||||
// $inputs.prop('required', false);
|
|
||||||
$('.' + thirdClass).find('input, textarea,select').attr('required', false);
|
$('.' + thirdClass).find('input, textarea,select').attr('required', false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Re-apply URL/file pair rules after bulk required toggles.
|
|
||||||
enforceLetterPairRules();
|
enforceLetterPairRules();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1034,12 +1123,12 @@
|
|||||||
$field.prop('required', false);
|
$field.prop('required', false);
|
||||||
var $parentDiv = $field.closest("div");
|
var $parentDiv = $field.closest("div");
|
||||||
$parentDiv.find("label[for='approved_description'] .text-danger").remove();
|
$parentDiv.find("label[for='approved_description'] .text-danger").remove();
|
||||||
enforceLetterPairRules();
|
refreshAllStatusSectionRequired();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#ticket_form_data').on('submit', function() {
|
$('#ticket_form_data').on('submit', function() {
|
||||||
enforceLetterPairRules();
|
refreshAllStatusSectionRequired();
|
||||||
});
|
});
|
||||||
|
|
||||||
// function addRequiredFieldSymbol(field_name) {
|
// function addRequiredFieldSymbol(field_name) {
|
||||||
|
|||||||
@ -29,7 +29,44 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isSkippableField(el) {
|
function isSkippableField(el) {
|
||||||
return !el || el.disabled || el.type === 'hidden';
|
if (!el || el.disabled || el.type === 'hidden') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (el.classList && el.classList.contains('select2-search__field')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isVisibleForValidation(el) {
|
||||||
|
if (isSkippableField(el)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var jq = getJq();
|
||||||
|
if (!jq) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var $el = jq(el);
|
||||||
|
if (!$el.length || !$el.is(':visible')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $el.closest('.form-group, .dynamic-form-row, .claim-row, .col-md-4, .col-md-12').filter(function () {
|
||||||
|
var display = jq(this).css('display');
|
||||||
|
return display === 'none';
|
||||||
|
}).length === 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isEmptyValue(val) {
|
||||||
|
if (val == null || val === '') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (Array.isArray(val)) {
|
||||||
|
return val.length === 0;
|
||||||
|
}
|
||||||
|
return String(val).trim() === '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function isPanOrGstField(el) {
|
function isPanOrGstField(el) {
|
||||||
@ -95,7 +132,7 @@
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (instance.$element.prop('required') && v.length === 0) {
|
if (instance.$element.prop('required') && v.length === 0) {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
return v.length === 10;
|
return v.length === 10;
|
||||||
},
|
},
|
||||||
@ -181,7 +218,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function validateField(field) {
|
function validateField(field) {
|
||||||
if (!field || isSkippableField(field) || !isParsleyReady()) {
|
if (!field || !isVisibleForValidation(field) || !isParsleyReady()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var $field = $(field);
|
var $field = $(field);
|
||||||
@ -200,6 +237,70 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function prepareHiddenFieldsForSubmit($form) {
|
||||||
|
if (!$form || !$form.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$form.find('input, textarea, select').each(function () {
|
||||||
|
var el = this;
|
||||||
|
var $el = $(el);
|
||||||
|
|
||||||
|
if (isVisibleForValidation(el)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$el.removeAttr('required').prop('required', false);
|
||||||
|
clearAttrs($el);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (typeof $el.parsley === 'function') {
|
||||||
|
var fieldInstance = $el.parsley();
|
||||||
|
if (fieldInstance && typeof fieldInstance.reset === 'function') {
|
||||||
|
fieldInstance.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// no-op
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInvalidFields($form) {
|
||||||
|
var invalid = [];
|
||||||
|
|
||||||
|
if (!$form || !$form.length || !isParsleyReady()) {
|
||||||
|
return invalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
var instance = $form.parsley();
|
||||||
|
if (!instance) {
|
||||||
|
return invalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
instance.fields.forEach(function (field) {
|
||||||
|
if (field.isValid()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var el = field.$element[0];
|
||||||
|
if (!isVisibleForValidation(el)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var val = field.$element.val();
|
||||||
|
invalid.push({
|
||||||
|
id: field.$element.attr('id') || '',
|
||||||
|
name: field.$element.attr('name') || '',
|
||||||
|
label: (field.$element.closest('.form-group, .mb-3, .col-md-4, .col-lg-4').find('label').first().text() || '').trim(),
|
||||||
|
messages: field.getErrorsMessages ? field.getErrorsMessages() : [],
|
||||||
|
isEmpty: isEmptyValue(val)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return invalid;
|
||||||
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
var $form = $(FORM_SELECTOR);
|
var $form = $(FORM_SELECTOR);
|
||||||
if (!$form.length || !isParsleyReady()) {
|
if (!$form.length || !isParsleyReady()) {
|
||||||
@ -207,6 +308,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
registerValidators();
|
registerValidators();
|
||||||
|
prepareHiddenFieldsForSubmit($form);
|
||||||
applyConstraints($form);
|
applyConstraints($form);
|
||||||
refreshParsley($form);
|
refreshParsley($form);
|
||||||
|
|
||||||
@ -226,6 +328,22 @@
|
|||||||
window.refreshLeadsFormValidation = function () {
|
window.refreshLeadsFormValidation = function () {
|
||||||
init();
|
init();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
window.prepareLeadsFormForSubmit = function () {
|
||||||
|
var $form = $(FORM_SELECTOR);
|
||||||
|
if (!$form.length || !isParsleyReady()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
registerValidators();
|
||||||
|
prepareHiddenFieldsForSubmit($form);
|
||||||
|
applyConstraints($form);
|
||||||
|
refreshParsley($form);
|
||||||
|
};
|
||||||
|
|
||||||
|
window.getLeadsFormInvalidFields = function () {
|
||||||
|
return getInvalidFields($(FORM_SELECTOR));
|
||||||
|
};
|
||||||
})(function () {
|
})(function () {
|
||||||
return window.jQuery;
|
return window.jQuery;
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user