CHANGE_EB_CHANGES
This commit is contained in:
parent
a82e5e1bcc
commit
fca4fd7e93
@ -4564,11 +4564,11 @@ class ClientController extends AdminController
|
|||||||
// Additional logic for non-individual clients (client_type != 2)
|
// Additional logic for non-individual clients (client_type != 2)
|
||||||
$branch_insert = null;
|
$branch_insert = null;
|
||||||
if ($client_type != 2) {
|
if ($client_type != 2) {
|
||||||
$unit[] = $postData['short_name'] . '-' . 001;
|
$unit[] = $postData['short_name'] . '-' . $postData['branch_code'] ?? 001;
|
||||||
$branch_data = [
|
$branch_data = [
|
||||||
'client_id' => $client_insert,
|
'client_id' => $client_insert,
|
||||||
'branch_name' => $postData['branch_name'],
|
'branch_name' => $postData['branch_name'],
|
||||||
'branch_code' => 001,
|
'branch_code' => $postData['branch_code'] ?? 001,
|
||||||
'gst' => $postData['gst'],
|
'gst' => $postData['gst'],
|
||||||
'units' => json_encode($unit) ?? null,
|
'units' => json_encode($unit) ?? null,
|
||||||
];
|
];
|
||||||
@ -4580,6 +4580,7 @@ class ClientController extends AdminController
|
|||||||
'contact_type' => 'client',
|
'contact_type' => 'client',
|
||||||
'name' => $postData['name'],
|
'name' => $postData['name'],
|
||||||
'email' => $postData['email'],
|
'email' => $postData['email'],
|
||||||
|
'mobile' => $postData['mobile'] ?? null,
|
||||||
];
|
];
|
||||||
$this->levelContactModel->insert($contact_data);
|
$this->levelContactModel->insert($contact_data);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -189,7 +189,7 @@ if (isset($selected_lead_type)) {
|
|||||||
$('#leads_form').hide()
|
$('#leads_form').hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
function getClientAndBranchAndPolicy() {
|
function getClientAndBranchAndPolicy(append = true) {
|
||||||
|
|
||||||
console.log('getClientAndBranchAndPolicy function called')
|
console.log('getClientAndBranchAndPolicy function called')
|
||||||
|
|
||||||
@ -204,7 +204,9 @@ if (isset($selected_lead_type)) {
|
|||||||
client_list = res.client_data;
|
client_list = res.client_data;
|
||||||
branch_list = res.branch_data;
|
branch_list = res.branch_data;
|
||||||
policy_list = res.policy_data;
|
policy_list = res.policy_data;
|
||||||
appendClients(res.client_data);
|
if(append == true){
|
||||||
|
appendClients(res.client_data);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('No data found');
|
console.log('No data found');
|
||||||
}
|
}
|
||||||
@ -217,7 +219,7 @@ if (isset($selected_lead_type)) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function appendClients(data) {
|
function appendClients(data, client_id = null) {
|
||||||
// console.log("lead_type",lead_type.value);
|
// console.log("lead_type",lead_type.value);
|
||||||
|
|
||||||
$('#client_id').empty();
|
$('#client_id').empty();
|
||||||
@ -249,13 +251,17 @@ if (isset($selected_lead_type)) {
|
|||||||
class: (item.client_type == 1) ? 'group' : (item.client_type == 2) ? 'individual' : ''
|
class: (item.client_type == 1) ? 'group' : (item.client_type == 2) ? 'individual' : ''
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (client_id == item.id) {
|
||||||
|
option.attr('selected', true);
|
||||||
|
}
|
||||||
|
|
||||||
$('#client_id').append(option);
|
$('#client_id').append(option);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function appendBranch(data) {
|
function appendBranch(data, branch_id = null) {
|
||||||
|
|
||||||
$('#client_branch_id').empty();
|
$('#client_branch_id').empty();
|
||||||
|
|
||||||
@ -270,6 +276,11 @@ if (isset($selected_lead_type)) {
|
|||||||
value: item.id,
|
value: item.id,
|
||||||
text: item.branch_name
|
text: item.branch_name
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (branch_id == item.id) {
|
||||||
|
option.attr('selected', true);
|
||||||
|
}
|
||||||
|
|
||||||
$('#client_branch_id').append(option);
|
$('#client_branch_id').append(option);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -336,6 +347,8 @@ if (isset($selected_lead_type)) {
|
|||||||
$("#client_short_name").val(shortName);
|
$("#client_short_name").val(shortName);
|
||||||
|
|
||||||
if (client_id == 'add_client') {
|
if (client_id == 'add_client') {
|
||||||
|
|
||||||
|
$(this).val("").select2();
|
||||||
// alert("Hello");
|
// alert("Hello");
|
||||||
var myModal = new bootstrap.Modal(document.getElementById('upload_enrollment_model'));
|
var myModal = new bootstrap.Modal(document.getElementById('upload_enrollment_model'));
|
||||||
myModal.show();
|
myModal.show();
|
||||||
|
|||||||
312
app/Views/newClientModal-old.php
Normal file
312
app/Views/newClientModal-old.php
Normal file
@ -0,0 +1,312 @@
|
|||||||
|
<!-- Client form content modal-->
|
||||||
|
<div class="modal fade" id="upload_enrollment_model" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" data-backdrop="static">
|
||||||
|
<div class="modal-dialog modal-dialog-centered">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h4 class="modal-title" id="myCenterModalLabel">Add New Client</h4>
|
||||||
|
<button type="button" id="close_btn" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body" style="overflow-y: auto;height: 90vh;">
|
||||||
|
<form class="parsley-examples" method="post" id="client_form" enctype="multipart/form-data">
|
||||||
|
<div class="form-group">
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="form-group col-md-12">
|
||||||
|
<label for="client_name">Client Name<span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" id="client_name" name="client_name" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-12">
|
||||||
|
<label for="short_name">Client Short name<span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" id="short_name" name="short_name" onkeyup="validateInputForClient(this, 'clients', 'short_name')" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<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="validateInputForClient(this, 'clients', 'pan')">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<!-- Client Type -->
|
||||||
|
<div class="form-row clienttypediv" style="display: none;">
|
||||||
|
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
<label for="dob">Date of Birth<span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" id="dob" placeholder="DD/MM/YYYY" name="dob" >
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<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="validateInputForClient(this, 'clients', 'phone')">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-12">
|
||||||
|
<label for="email2">Email<span class="text-danger">*</span></label>
|
||||||
|
<input type="email" class="form-control" id="email2" placeholder="Enter Email" name="email2">
|
||||||
|
</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="validateInputForClient(this, 'clients', 'aadhar')">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- branch -->
|
||||||
|
<div class="form-row branchdiv">
|
||||||
|
|
||||||
|
<div class="form-group col-md-12">
|
||||||
|
<label for="short_name">Entity Type<span class="text-danger"></span></label>
|
||||||
|
<select class="form-control" id="entity_type_id_for_client" name="entity_type_id">
|
||||||
|
<option value="" selected>Select Entity</option>
|
||||||
|
<?php
|
||||||
|
if (isset($entity) && count($entity)) {
|
||||||
|
foreach ($entity as $key => $value) {
|
||||||
|
echo "<option value=" . $value['id'] . ">" . $value['name'] . "</option>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
<label for="client_name">Branch Name<span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" id="branch_name" name="branch_name" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
<label for="branch_code">Branch Code<span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" id="branch_code" name="branch_code" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
<label for="branch_code">Name<span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" id="name" name="name" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
<label for="branch_code">Mobile<span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" id="mobile" maxlength="10" name="mobile" onkeypress="return onlyNumbers(event)" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-12">
|
||||||
|
<label for="email">Email<span class="text-danger">*</span></label>
|
||||||
|
<input type="email" class="form-control" id="email" placeholder="Enter Email" name="email" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<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" 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>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
||||||
|
<button type="submit" id="client_add_modal_submit_btn" class="btn btn-primary waves-effect waves-light mr-1 your">Submit</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div><!-- /.modal-content -->
|
||||||
|
</div><!-- /.modal-dialog -->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
let isGSTValidating = false;
|
||||||
|
let isGSTValid = false;
|
||||||
|
|
||||||
|
function validateInputForClient(input, table, field) {
|
||||||
|
|
||||||
|
let owner_type = $('#Owner_type').val();
|
||||||
|
let client_type = $('#client_type').val();
|
||||||
|
|
||||||
|
console.log('owner_type', owner_type);
|
||||||
|
console.log('client_type', client_type);
|
||||||
|
|
||||||
|
if((client_type == 2 || owner_type == 2) && field == 'short_name'){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
$('#client_add_modal_submit_btn').prop('disabled', true);
|
||||||
|
} else {
|
||||||
|
isGSTValid = true;
|
||||||
|
$('#client_add_modal_submit_btn').prop('disabled', false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#hide_smbt_btn button').prop('disabled', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$("#client_form").submit(function(event) {
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
// If GST is currently validating, wait for it to complete
|
||||||
|
if (isGSTValidating) {
|
||||||
|
if($('#Owner_type').val() == 1){
|
||||||
|
toastr.info('Please wait while we validate your GST number...', 'Validating');
|
||||||
|
return;
|
||||||
|
}else if ($('#client_type').val() == 1){
|
||||||
|
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);
|
||||||
|
console.log('onsubmit event get data value',form_type);
|
||||||
|
console.log('client_type', $('#client_type').val());
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
|
||||||
|
$('#aadhar').attr('data-parsley-required', 'false');
|
||||||
|
$('#aadhar').removeAttr('required');
|
||||||
|
|
||||||
|
if($('#Owner_type').val() == 2){
|
||||||
|
$('#gst').removeAttr('required');
|
||||||
|
}
|
||||||
|
|
||||||
|
var isValid = $('#client_form').parsley().validate();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
isClientFormSubmitting = true;
|
||||||
|
|
||||||
|
form_action = '<?= base_url("util/createClientWithMinimalData"); ?>';
|
||||||
|
|
||||||
|
$('.loader').fadeIn();
|
||||||
|
$('.loader-mask').fadeIn();
|
||||||
|
|
||||||
|
var client_type = $('#client_type').val() || $('#Owner_type').val() || 1;
|
||||||
|
console.log('client_type:', client_type);
|
||||||
|
|
||||||
|
//FORM Data
|
||||||
|
var formData = new FormData($('#client_form')[0]);
|
||||||
|
formData.append('client_type', client_type);
|
||||||
|
console.log("formData : ",formData);
|
||||||
|
// return
|
||||||
|
$.ajax({
|
||||||
|
data:formData,
|
||||||
|
url: form_action,
|
||||||
|
type: "POST",
|
||||||
|
dataType: 'json',
|
||||||
|
processData: false,
|
||||||
|
contentType: false,
|
||||||
|
success: function(res) {
|
||||||
|
|
||||||
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
|
|
||||||
|
console.log('create_Client_With_Minimal_Data', res)
|
||||||
|
|
||||||
|
if(res.status == true){
|
||||||
|
getClientAndBranchAndPolicy(res.client_id, res.branch_id);
|
||||||
|
|
||||||
|
if(form_type != 1){
|
||||||
|
|
||||||
|
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();
|
||||||
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
|
|
||||||
|
}, 1000)
|
||||||
|
|
||||||
|
}, 3000)
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
console.log("Couldn't Add Client","Error");
|
||||||
|
}
|
||||||
|
|
||||||
|
toastr.success(res.message, 'Success');
|
||||||
|
|
||||||
|
}else{
|
||||||
|
toastr.error(res.message, 'Error');
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#client_form')[0].reset();
|
||||||
|
$('.close').click();
|
||||||
|
|
||||||
|
if(form_type == 1){
|
||||||
|
|
||||||
|
var myModal = new bootstrap.Modal(document.getElementById('vehicle_modal'));
|
||||||
|
myModal.show();
|
||||||
|
|
||||||
|
$('#client_form').removeAttr('data-id');
|
||||||
|
|
||||||
|
// Load form data into #vehicle_form from localStorage
|
||||||
|
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;
|
||||||
|
},
|
||||||
|
error: function (xhr, status, error) {
|
||||||
|
console.error(xhr.responseText);
|
||||||
|
console.error(status, error);
|
||||||
|
isClientFormSubmitting = false;
|
||||||
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
@ -57,7 +57,7 @@
|
|||||||
<div class="form-row branchdiv">
|
<div class="form-row branchdiv">
|
||||||
|
|
||||||
<div class="form-group col-md-12">
|
<div class="form-group col-md-12">
|
||||||
<label for="short_name">Entity Type<span class="text-danger">*</span></label>
|
<label for="short_name">Entity Type<span class="text-danger"></span></label>
|
||||||
<select class="form-control" id="entity_type_id_for_client" name="entity_type_id">
|
<select class="form-control" id="entity_type_id_for_client" name="entity_type_id">
|
||||||
<option value="" selected>Select Entity</option>
|
<option value="" selected>Select Entity</option>
|
||||||
<?php
|
<?php
|
||||||
@ -72,22 +72,22 @@
|
|||||||
|
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label for="client_name">Branch Name<span class="text-danger">*</span></label>
|
<label for="client_name">Branch Name<span class="text-danger">*</span></label>
|
||||||
<input type="text" class="form-control" id="branch_name" name="branch_name">
|
<input type="text" class="form-control" id="branch_name" name="branch_name" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label for="branch_code">Branch Code<span class="text-danger">*</span></label>
|
<label for="branch_code">Branch Code<span class="text-danger">*</span></label>
|
||||||
<input type="text" class="form-control" id="branch_code" name="branch_code">
|
<input type="text" class="form-control" id="branch_code" name="branch_code" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label for="branch_code">Name<span class="text-danger">*</span></label>
|
<label for="branch_code">Name<span class="text-danger">*</span></label>
|
||||||
<input type="text" class="form-control" id="name" name="name">
|
<input type="text" class="form-control" id="name" name="name" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label for="branch_code">Mobile<span class="text-danger"></span></label>
|
<label for="branch_code">Mobile<span class="text-danger">*</span></label>
|
||||||
<input type="text" class="form-control" id="mobile" maxlength="10" name="mobile" onkeypress="return onlyNumbers(event)">
|
<input type="text" class="form-control" id="mobile" maxlength="10" name="mobile" onkeypress="return onlyNumbers(event)" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-12">
|
<div class="form-group col-md-12">
|
||||||
<label for="email">Email<span class="text-danger">*</span></label>
|
<label for="email">Email<span class="text-danger">*</span></label>
|
||||||
@ -113,6 +113,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
let isGSTValidating = false;
|
let isGSTValidating = false;
|
||||||
let isGSTValid = false;
|
let isGSTValid = false;
|
||||||
|
|
||||||
@ -155,8 +156,6 @@
|
|||||||
$('#hide_smbt_btn button').prop('disabled', false);
|
$('#hide_smbt_btn button').prop('disabled', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$("#client_form").submit(function(event) {
|
$("#client_form").submit(function(event) {
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@ -224,7 +223,7 @@
|
|||||||
//FORM Data
|
//FORM Data
|
||||||
var formData = new FormData($('#client_form')[0]);
|
var formData = new FormData($('#client_form')[0]);
|
||||||
formData.append('client_type', client_type);
|
formData.append('client_type', client_type);
|
||||||
console.log("formData : ",formData);
|
|
||||||
// return
|
// return
|
||||||
$.ajax({
|
$.ajax({
|
||||||
data:formData,
|
data:formData,
|
||||||
@ -235,37 +234,38 @@
|
|||||||
contentType: false,
|
contentType: false,
|
||||||
success: function(res) {
|
success: function(res) {
|
||||||
|
|
||||||
$('.loader').fadeOut();
|
|
||||||
$('.loader-mask').delay(350).fadeOut('slow');
|
|
||||||
|
|
||||||
console.log('create_Client_With_Minimal_Data', res)
|
console.log('create_Client_With_Minimal_Data', res)
|
||||||
|
|
||||||
if(res.status == true){
|
if(res.status == true){
|
||||||
getClientAndBranchAndPolicy(res.client_id, res.branch_id);
|
|
||||||
|
|
||||||
if(form_type != 1){
|
getClientAndBranchAndPolicy(false);
|
||||||
|
|
||||||
setTimeout(function(){
|
appendClients(res.clients, res.client_id);
|
||||||
|
appendBranch(res.branches, res.branch_id);
|
||||||
|
|
||||||
$('#client_id').val(res.client_id).change();
|
$('#gst').val(res.data.gst);
|
||||||
$('#client_id').prepend($('<option>', {
|
$('#branch_name').val(res.data.branch_name);
|
||||||
value: 'add_client',
|
$('#branch_code').val(res.data.branch_code);
|
||||||
text: '+ Add Client'
|
$('#contact_person_mobile').val(res.data.mobile);
|
||||||
}));
|
$('#contact_person_email').val(res.data.email);
|
||||||
|
|
||||||
setTimeout(function(){
|
$('#contact_person_summary').empty();
|
||||||
|
$('#contact_person_summary').append($('<option>', {
|
||||||
|
value: "",
|
||||||
|
text: "Select a Contact"
|
||||||
|
}));
|
||||||
|
|
||||||
$('#client_branch_id').val(res.branch_id).change();
|
if (res.data.name && res.data.email) {
|
||||||
$('.loader').fadeOut();
|
|
||||||
$('.loader-mask').delay(350).fadeOut('slow');
|
|
||||||
|
|
||||||
}, 1000)
|
// let display_value = `${res.data.name} - ${res.data.email} - ${res.data.mobile}`;
|
||||||
|
let display_value = res.data.name;
|
||||||
|
|
||||||
}, 3000)
|
$('#contact_person_summary').append($('<option>', {
|
||||||
|
value: 0, // index or key in array/object
|
||||||
|
text: display_value,
|
||||||
|
selected: true
|
||||||
|
}));
|
||||||
|
|
||||||
}else{
|
|
||||||
|
|
||||||
console.log("Couldn't Add Client","Error");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toastr.success(res.message, 'Success');
|
toastr.success(res.message, 'Success');
|
||||||
@ -277,25 +277,8 @@
|
|||||||
$('#client_form')[0].reset();
|
$('#client_form')[0].reset();
|
||||||
$('.close').click();
|
$('.close').click();
|
||||||
|
|
||||||
if(form_type == 1){
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
var myModal = new bootstrap.Modal(document.getElementById('vehicle_modal'));
|
|
||||||
myModal.show();
|
|
||||||
|
|
||||||
$('#client_form').removeAttr('data-id');
|
|
||||||
|
|
||||||
// Load form data into #vehicle_form from localStorage
|
|
||||||
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;
|
isClientFormSubmitting = false;
|
||||||
},
|
},
|
||||||
|
|||||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user