FIX_ADD_CLIENT

This commit is contained in:
Srinivas-Saravanan 2025-05-17 12:33:20 +05:30
parent 68c3d72741
commit 65b405d3e4
3 changed files with 74 additions and 21 deletions

View File

@ -681,7 +681,9 @@ class LeadsController extends BaseController
if ($lead_data['lead_type'] != 1) {
$client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $lead_data['source_policy_id'])->first();
$data['policy_terms'] = $client_policy_data['policy_terms'];
if (isset($client_policy_data)) {
$data['policy_terms'] = $client_policy_data['policy_terms'];
}
}
$data['question_json'] = $lead_data['question_json'];
@ -740,7 +742,10 @@ class LeadsController extends BaseController
if ($lead_data['lead_type'] != 1 && $data['rfq_count'] == 0) {
$client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $lead_data['source_policy_id'])->first();
$data['rfq_data']['json'] = $client_policy_data['placement_json'];
if (isset($client_policy_data)) {
$data['rfq_data']['json'] = $client_policy_data['placement_json'];
}
}
if (!empty($data['question_json'])) {

View File

@ -338,24 +338,24 @@ if (isset($selected_lead_type)) {
$('#salse_person_id').trigger('change');
}
function validateInput(input, table, field){
// function validateInput(input, table, field){
let value = $(input).val();
let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim();
// let value = $(input).val();
// let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim();
let message = "Value is duplicate!";
if(label){
message = label + " already exists!";
}
// let message = "Value is duplicate!";
// if(label){
// message = label + " already exists!";
// }
checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) {
if (isDuplicate) {
toastr.warning(message, 'WARNING');
$(input).val('')
}
});
// checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) {
// if (isDuplicate) {
// toastr.warning(message, 'WARNING');
// $(input).val('')
// }
// });
}
// }
// --------------------------------------------------------------------------------------------------------

View File

@ -22,7 +22,7 @@
<div class="form-group col-md-12">
<label for="cost_center">PAN</label>
<input type="text" class="form-control" id="pan" placeholder="Enter PAN No" name="pan" onchange="validateInput(this, 'clients', 'pan')">
<input type="text" class="form-control" id="pan" placeholder="Enter PAN No" name="pan" onchange="validateInputForClient(this, 'clients', 'pan')">
</div>
</div>
@ -39,7 +39,7 @@
<div class="form-group col-md-6">
<label for="cost_center">Mobile<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="phone" placeholder="Enter Mobile Number" maxlength="10" name="phone"
onkeypress="return onlyNumbers(event)" onchange="validateInput(this, 'clients', 'phone')">
onkeypress="return onlyNumbers(event)" onchange="validateInputForClient(this, 'clients', 'phone')">
</div>
<div class="form-group col-md-12">
@ -48,7 +48,7 @@
</div>
<div class="form-group col-md-12">
<label for="aadhar">Aadhar</label>
<input type="text" class="form-control" id="aadhar" placeholder="Enter Aadher No" name="aadhar" maxlength="12" onchange="validateInput(this, 'clients', 'aadhar')">
<input type="text" class="form-control" id="aadhar" placeholder="Enter Aadher No" name="aadhar" maxlength="12" onchange="validateInputForClient(this, 'clients', 'aadhar')">
</div>
</div>
@ -96,7 +96,7 @@
<div class="form-group col-md-12">
<label for="gst">GST<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="gst" placeholder="Enter GST Number" onchange="validateInput(this, 'client_branch', 'gst')"
<input type="text" class="form-control" id="gst" placeholder="Enter GST Number" oninput="validateInputForClient(this, 'client_branch', 'gst')"
data-parsley-error-message="Invalid GST Number. Example: 12ABCDE1234F5Z6" name="gst" data-parsley-trigger="change" data-parsley-pattern="^\d{2}[A-Z]{5}\d{4}[A-Z]{1}[A-Z\d]{1}[Z]{1}[A-Z\d]{1}$" required>
</div>
@ -113,8 +113,52 @@
</div>
<script>
let isGSTValidating = false;
let isGSTValid = false;
function validateInputForClient(input, table, field) {
let value = $(input).val();
if (!value) return;
let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim();
let message = label ? label + " already exists!" : "Value is duplicate!";
// Set validating state
isGSTValidating = true;
isGSTValid = false;
$('#hide_smbt_btn button').prop('disabled', true);
checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) {
isGSTValidating = false;
if (isDuplicate) {
toastr.warning(message, 'WARNING');
$(input).val('');
isGSTValid = false;
} else {
isGSTValid = true;
}
});
$('#hide_smbt_btn button').prop('disabled', false);
}
$("#client_form").submit(function(event) {
// alert("Function Called from Modal")
event.preventDefault();
// If GST is currently validating, wait for it to complete
if (isGSTValidating) {
toastr.info('Please wait while we validate your GST number...', 'Validating');
return;
}
// If GST validation failed, prevent submission
if ($('#gst').val() && !isGSTValid) {
toastr.warning('Please fix the GST number before submitting', 'Validation Error');
return;
}
let form_type = $(this).data('id') || 0;
console.log('onsubmit event', this)
@ -169,6 +213,10 @@
setTimeout(function(){
$('#client_id').val(res.client_id).change();
$('#client_id').prepend($('<option>', {
value: 'add_client',
text: '+ Add Client'
}));
setTimeout(function(){
$('#client_branch_id').val(res.branch_id).change();
// try {