From d5e6037c0eaedb2ddc9488df0e591c745c4bbd72 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 19 May 2025 17:33:08 +0530 Subject: [PATCH] FIX_ADD_CLIENT : RV --- app/Views/newClientModal.php | 35 ++++++++++++++++--- .../policy_transaction_inception_form.php | 7 ++-- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/app/Views/newClientModal.php b/app/Views/newClientModal.php index c4285aac..b0d72494 100644 --- a/app/Views/newClientModal.php +++ b/app/Views/newClientModal.php @@ -171,14 +171,30 @@ $('#aadhar').attr('data-parsley-required', 'false'); $('#aadhar').removeAttr('required'); + if($('#Owner_type').val() == 2){ + $('#gst').removeAttr('required'); + } + isClientFormSubmitting = true; var isValid = $('#client_form').parsley().validate(); - if (!isValid) { - console.log('Form is Empty', 'Warning'); - return ; + + if (!isValid) { + var emptyFieldIds = []; + + $('#client_form').parsley().fields.forEach(function(field) { + if (!field.isValid()) { + var elem = field.$element; + var id = elem.attr('id') || elem.attr('name'); + emptyFieldIds.push(id); + } + }); + + console.log('Empty/Invalid Fields:', emptyFieldIds); + return; } + form_action = ''; $('.loader').fadeIn(); @@ -229,7 +245,7 @@ }else{ - toastr.error("Couldn't Add Client","Error"); + console.log("Couldn't Add Client","Error"); } toastr.success(res.message, 'Success'); @@ -249,7 +265,16 @@ $('#client_form').removeAttr('data-id'); // Load form data into #vehicle_form from localStorage - setFormDataFromLocalStorage("#vehicle_form", "vehicleFormData"); + setFormDataFromLocalStorage("#vehicle_form", "vehicleFormData", res.client_id); + + setTimeout(function(){ + $('#owner').val(res.client_id).change(); + $('#owner_branch').val(res.branch_id).change(); + + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + + }, 2000) } isClientFormSubmitting = false; diff --git a/app/Views/policy_transaction_inception_form.php b/app/Views/policy_transaction_inception_form.php index 1f75098a..3fbce33c 100644 --- a/app/Views/policy_transaction_inception_form.php +++ b/app/Views/policy_transaction_inception_form.php @@ -1315,10 +1315,12 @@ $(document).ready(function(){ $('#name').prop('required', false); $('#mobile').prop('required', false); $('#gst').prop('required', false); + $('#email').prop('required', false); + $('#dob').prop('required', true); $('#phone').prop('required', true); - $('#email').prop('required', true); + $('#email2').prop('required', true); $('#aadhar').prop('required', true); } else { @@ -1332,10 +1334,11 @@ $(document).ready(function(){ $('#name').prop('required', true); $('#mobile').prop('required', true); $('#gst').prop('required', true); + $('#email').prop('required', true); $('#dob').prop('required', false); $('#phone').prop('required', false); - $('#email').prop('required', false); + $('#email2').prop('required', false); $('#aadhar').prop('required', false); }