FEAT_ADD_CLIENT_ROLLOVER
This commit is contained in:
parent
74d70c6a4b
commit
9b63c61b0a
@ -3839,13 +3839,13 @@ class ClientController extends AdminController
|
||||
'dob' => change_date_format($postData['dob'],'d/m/Y','Y-m-d'),
|
||||
'aadhar' => $postData['aadhar'],
|
||||
'phone' => $postData['phone'],
|
||||
'email' => $postData['email'],
|
||||
'entity_type_id' => 7
|
||||
]);
|
||||
} else {
|
||||
$client_data['entity_type_id'] = $postData['entity_type_id'];
|
||||
}
|
||||
|
||||
// print_rr($client_data);die();
|
||||
// Insert client data
|
||||
$client_insert = $this->clientModel->insert($client_data);
|
||||
|
||||
@ -3871,6 +3871,8 @@ class ClientController extends AdminController
|
||||
'contact_type' => 'client',
|
||||
'name' => $postData['name'],
|
||||
'mobile' => $postData['mobile'],
|
||||
'email' => $postData['email'],
|
||||
|
||||
];
|
||||
$this->levelContactModel->insert($contact_data);
|
||||
}
|
||||
@ -4050,7 +4052,8 @@ class ClientController extends AdminController
|
||||
->join('clients', 'client_branch.client_id = clients.id')
|
||||
->where(['client_branch.id' => $id, 'client_branch.is_active' => 1])
|
||||
->first();
|
||||
$branch_contact_data = $this->levelContactModel->where(['ref_id' => $id, 'contact_type' => 'client', 'is_active' => 1])->orderBy('id','asc')->first();
|
||||
$branch_contact_data = $this->levelContactModel->where(['ref_id' => $id, 'contact_type' => 'client', 'is_active' => 1])->findAll();
|
||||
// print_rr($branch_contact_data);die();
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $branch_data, 'contact' => $branch_contact_data], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'no data found'], 200);
|
||||
|
||||
@ -149,7 +149,7 @@
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="client_branch_id">Branch<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="client_branch_id" name="client_branch_id"
|
||||
onchange="getBranchData(this)">
|
||||
onchange="getBranchData(this,1)">
|
||||
<option value="">Select Branch</option>
|
||||
</select>
|
||||
</div>
|
||||
@ -207,6 +207,14 @@
|
||||
placeholder="Enter Branch Code" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="contact_person_summary">Contact Person's</label>
|
||||
<select class="form-control" name="contact_person_summary" id="contact_person_summary">
|
||||
<option value="">Select a Person</option>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="client_branch">Contact Person Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="contact_person_name" name="contact_person_name"
|
||||
@ -289,6 +297,8 @@
|
||||
</div>
|
||||
</div><!-- end form row -->
|
||||
|
||||
<?php include("newClientModal.php") ?>
|
||||
|
||||
|
||||
<script>
|
||||
let claimIndex = 1;
|
||||
@ -373,6 +383,58 @@
|
||||
// }
|
||||
}
|
||||
});
|
||||
}else if (lead_type == 3) {
|
||||
|
||||
$('#client_id').prepend($('<option>', {
|
||||
value: 'add_client',
|
||||
text: '+ Add Client'
|
||||
}));
|
||||
$("#source_policy_id").removeAttr("required");
|
||||
$("#source_policy_id").closest("div") .find("label .text-danger").remove();
|
||||
|
||||
$("#source_policy_start_date").removeAttr("required");
|
||||
$("#source_policy_start_date").closest("div") .find("label .text-danger").remove();
|
||||
|
||||
$("#source_policy_end_date").removeAttr("required");
|
||||
$("#source_policy_end_date").closest("div") .find("label .text-danger").remove();
|
||||
|
||||
|
||||
|
||||
} else if (lead_type != 3) {
|
||||
$("#source_policy_id").prop("required",true);
|
||||
$("#source_policy_start_date").prop("required", true);
|
||||
$("#source_policy_end_date").prop("required", true);
|
||||
|
||||
|
||||
// Check if the asterisk doesn't already exist, then add it
|
||||
let $label = $("#source_policy_id")
|
||||
.closest("div")
|
||||
.find("label");
|
||||
|
||||
if ($label.find(".text-danger").length === 0) {
|
||||
$label.append(' <span class="text-danger">*</span>');
|
||||
}
|
||||
let $label2 = $("#source_policy_start_date")
|
||||
.closest("div")
|
||||
.find("label");
|
||||
|
||||
if ($label2.find(".text-danger").length === 0) {
|
||||
$label2.append(' <span class="text-danger">*</span>');
|
||||
}
|
||||
let $label3 = $("#source_policy_end_date")
|
||||
.closest("div")
|
||||
.find("label");
|
||||
|
||||
if ($label3.find(".text-danger").length === 0) {
|
||||
$label3.append(' <span class="text-danger">*</span>');
|
||||
}
|
||||
|
||||
var addOption = $('#client_id option[value="add_client"]');
|
||||
if (addOption.length > 0) {
|
||||
addOption.remove();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
var policy_end_datePicker = flatpickr("#policy_end_date_" + increment, {
|
||||
@ -406,8 +468,9 @@
|
||||
$('#tpa_' + increment).select2();
|
||||
$('#proposed_insurer').select2();
|
||||
$('#proposed_tpa').select2();
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
//------------------------------ GET DATA ( EDIT, BRANCH, POLICY ) ---------------------------------------------------------------------------
|
||||
|
||||
//view and edit Lead data function
|
||||
@ -576,10 +639,15 @@
|
||||
});
|
||||
}
|
||||
|
||||
var allContacts = "";
|
||||
//client branch data
|
||||
function getBranchData(input) {
|
||||
function getBranchData(input, inputType) {
|
||||
|
||||
var client_branch_id = $(input).val();
|
||||
if (inputType == 1 ) {
|
||||
var client_branch_id = $(input).val();
|
||||
} else {
|
||||
client_branch_id = input;
|
||||
}
|
||||
|
||||
if (client_branch_id) {
|
||||
|
||||
@ -600,9 +668,29 @@
|
||||
$('#pan').val(res.data.pan);
|
||||
$('#branch_name').val(res.data.branch_name);
|
||||
$('#branch_code').val(res.data.branch_code);
|
||||
$('#contact_person_name').val(res?.contact?.name || '');
|
||||
$('#contact_person_mobile').val(res?.contact?.mobile || '');
|
||||
$('#contact_person_email').val(res?.contact?.email || '');
|
||||
allContacts = res.contact;
|
||||
$('#contact_person_summary').empty();
|
||||
$('#contact_person_summary').append($('<option>', {
|
||||
value: "",
|
||||
text: "Select a Contact"
|
||||
}));
|
||||
|
||||
res.contact.forEach((value, key) => {
|
||||
|
||||
if (value.name && value.email) {
|
||||
|
||||
let display_value = `${value.name} - ${value.email} - ${value.mobile}`;
|
||||
|
||||
$('#contact_person_summary').append($('<option>', {
|
||||
value: key, // index or key in array/object
|
||||
text: display_value
|
||||
}));
|
||||
}
|
||||
|
||||
});
|
||||
// $('#contact_person_name').val(res?.contact?.name || '');
|
||||
// $('#contact_person_mobile').val(res?.contact?.mobile || '');
|
||||
// $('#contact_person_email').val(res?.contact?.email || '');
|
||||
|
||||
|
||||
$('#pan').prop('readOnly', true);
|
||||
@ -1562,7 +1650,14 @@
|
||||
$('.freshFields').hide();
|
||||
|
||||
$('.renewalFields').show();
|
||||
$('.renewalFields').find('select, input').attr('required', 'required');
|
||||
|
||||
if (value != 3) {
|
||||
$('.renewalFields').find('select, input').attr('required', 'required');
|
||||
$("#source_policy_id").removeAttr("required");
|
||||
$("#source_policy_start_date").removeAttr("required");
|
||||
$("#source_policy_end_date").removeAttr("required");
|
||||
|
||||
}
|
||||
|
||||
// $('.proposed_div').show().find('select, input').attr('required', 'required');
|
||||
|
||||
|
||||
@ -231,6 +231,16 @@ if (isset($selected_lead_type)) {
|
||||
$('#client_id').change(function() {
|
||||
|
||||
let client_id = $(this).val();
|
||||
|
||||
|
||||
if (client_id == 'add_client') {
|
||||
// alert("Hello");
|
||||
var myModal = new bootstrap.Modal(document.getElementById('upload_enrollment_model'));
|
||||
myModal.show();
|
||||
// $('#upload_enrollment_model').modal('toggle');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("client_id", client_id)
|
||||
let client_type = $('#client_id option:selected').data('ct');
|
||||
|
||||
@ -258,6 +268,17 @@ if (isset($selected_lead_type)) {
|
||||
|
||||
})
|
||||
|
||||
$("#contact_person_summary").change(function () {
|
||||
let selectedKey = $(this).val();
|
||||
|
||||
if (allContacts[selectedKey]) {
|
||||
$('#contact_person_name').val(allContacts[selectedKey].name || '');
|
||||
$('#contact_person_mobile').val(allContacts[selectedKey].mobile || '');
|
||||
$('#contact_person_email').val(allContacts[selectedKey].email || '');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$('#client_branch_id').change(function() {
|
||||
|
||||
let client_branch_id = $(this).val();
|
||||
@ -589,6 +610,39 @@ if (isset($selected_lead_type)) {
|
||||
}
|
||||
}
|
||||
|
||||
if (lead_type == 3) {
|
||||
|
||||
$('#client_id').prepend($('<option>', {
|
||||
value: 'add_client',
|
||||
text: '+ Add Client'
|
||||
}));
|
||||
|
||||
console.log("trying to remove required ");
|
||||
$("#source_policy_id").prop("required",false);
|
||||
$("#source_policy_id").closest("div") .find("label .text-danger").remove();
|
||||
|
||||
|
||||
} else if (lead_type != 3) {
|
||||
$("#source_policy_id").prop("required",true);
|
||||
$("#source_policy_id").prop("required", true);
|
||||
|
||||
// Check if the asterisk doesn't already exist, then add it
|
||||
let $label = $("#source_policy_id")
|
||||
.closest("div")
|
||||
.find("label");
|
||||
|
||||
if ($label.find(".text-danger").length === 0) {
|
||||
$label.append(' <span class="text-danger">*</span>');
|
||||
}
|
||||
|
||||
var addOption = $('#client_id option[value="add_client"]');
|
||||
if (addOption.length > 0) {
|
||||
addOption.remove();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
hide_list_show_add();
|
||||
|
||||
$('#page_title').text('Edit Lead');
|
||||
@ -763,6 +817,42 @@ if (isset($selected_lead_type)) {
|
||||
referenceDiv.innerHTML = '';
|
||||
referenceDiv.insertAdjacentHTML('beforeend', data.claims_details_html);
|
||||
|
||||
console.log("wdesfgefwregfefwregffeegf",data.lead_type);
|
||||
var lead_type_value = data.lead_type;
|
||||
// alert(lead_type);
|
||||
if (lead_type_value == 3) {
|
||||
|
||||
$('#client_id').prepend($('<option>', {
|
||||
value: 'add_client',
|
||||
text: '+ Add Client'
|
||||
}));
|
||||
|
||||
console.log("trying to remove required ");
|
||||
$("#source_policy_id").prop("required",false);
|
||||
$("#source_policy_id").closest("div") .find("label .text-danger").remove();
|
||||
|
||||
|
||||
} else if (lead_type_value != 3) {
|
||||
$("#source_policy_id").prop("required",true);
|
||||
$("#source_policy_id").prop("required", true);
|
||||
|
||||
// Check if the asterisk doesn't already exist, then add it
|
||||
let $label = $("#source_policy_id")
|
||||
.closest("div")
|
||||
.find("label");
|
||||
|
||||
if ($label.find(".text-danger").length === 0) {
|
||||
$label.append(' <span class="text-danger">*</span>');
|
||||
}
|
||||
|
||||
var addOption = $('#client_id option[value="add_client"]');
|
||||
if (addOption.length > 0) {
|
||||
addOption.remove();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error in dynamicLeadsDataForEdit function:', error);
|
||||
}
|
||||
|
||||
@ -150,7 +150,7 @@
|
||||
<div class="form-group col-md-3 renewalFields" style="display: none;">
|
||||
<label for="client_branch_id">Branch<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="client_branch_id" name="client_branch_id"
|
||||
onchange="getBranchData(this)">
|
||||
onchange="getBranchData(this,1)">
|
||||
<option value="">Select Branch</option>
|
||||
</select>
|
||||
</div>
|
||||
@ -198,6 +198,14 @@
|
||||
placeholder="Enter Branch Code" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="contact_person_summary">Contact Person's</label>
|
||||
<select class="form-control" name="contact_person_summary" id="contact_person_summary">
|
||||
<option value="">Select a Person</option>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="client_branch">Contact Person Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="contact_person_name" name="contact_person_name"
|
||||
@ -359,10 +367,14 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php include("newClientModal.php") ?>
|
||||
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
|
||||
|
||||
var today = new Date();
|
||||
|
||||
var policy_start_datePicker = flatpickr("#policy_start_date", {
|
||||
@ -559,6 +571,40 @@
|
||||
|
||||
$('#lead_type').change(function() {
|
||||
let value = $(this).val()
|
||||
// alert(value);
|
||||
if (value == 3) {
|
||||
// alert("Function Called");
|
||||
|
||||
$('#client_id').prepend($('<option>', {
|
||||
value: 'add_client',
|
||||
text: '+ Add Client'
|
||||
}));
|
||||
|
||||
$("#source_policy_id").prop("required",false);
|
||||
$("#source_policy_id").closest("div") .find("label .text-danger").remove();
|
||||
|
||||
|
||||
} else if (value != 3) {
|
||||
$("#source_policy_id").prop("required",true);
|
||||
$("#source_policy_id").prop("required", true);
|
||||
|
||||
// Check if the asterisk doesn't already exist, then add it
|
||||
let $label = $("#source_policy_id")
|
||||
.closest("div")
|
||||
.find("label");
|
||||
|
||||
if ($label.find(".text-danger").length === 0) {
|
||||
$label.append(' <span class="text-danger">*</span>');
|
||||
}
|
||||
|
||||
var addOption = $('#client_id option[value="add_client"]');
|
||||
if (addOption.length > 0) {
|
||||
addOption.remove();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
leadTypeBsedHideAndShow(value, true)
|
||||
})
|
||||
|
||||
@ -636,10 +682,16 @@
|
||||
}
|
||||
|
||||
}
|
||||
var allContacts = "";
|
||||
function getBranchData(input,inputType) {
|
||||
|
||||
function getBranchData(input) {
|
||||
// alert("get branch Function called");
|
||||
|
||||
var client_branch_id = $(input).val();
|
||||
if (inputType == 1 ) {
|
||||
var client_branch_id = $(input).val();
|
||||
} else {
|
||||
client_branch_id = input;
|
||||
}
|
||||
|
||||
if (client_branch_id) {
|
||||
|
||||
@ -660,9 +712,30 @@
|
||||
$('#pan').val(res.data.pan);
|
||||
$('#branch_name').val(res.data.branch_name);
|
||||
$('#branch_code').val(res.data.branch_code);
|
||||
$('#contact_person_name').val(res?.contact?.name || '');
|
||||
$('#contact_person_mobile').val(res?.contact?.mobile || '');
|
||||
$('#contact_person_email').val(res?.contact?.email || '');
|
||||
|
||||
allContacts = res.contact;
|
||||
$('#contact_person_summary').empty();
|
||||
$('#contact_person_summary').append($('<option>', {
|
||||
value: "",
|
||||
text: "Select a Contact"
|
||||
}));
|
||||
|
||||
res.contact.forEach((value, key) => {
|
||||
|
||||
if (value.name && value.email) {
|
||||
|
||||
let display_value = `${value.name} - ${value.email} - ${value.mobile}`;
|
||||
|
||||
$('#contact_person_summary').append($('<option>', {
|
||||
value: key, // index or key in array/object
|
||||
text: display_value
|
||||
}));
|
||||
}
|
||||
|
||||
});
|
||||
// $('#contact_person_name').val(res?.contact?.name || '');
|
||||
// $('#contact_person_mobile').val(res?.contact?.mobile || '');
|
||||
// $('#contact_person_email').val(res?.contact?.email || '');
|
||||
|
||||
|
||||
$('#pan').prop('readOnly', true);
|
||||
|
||||
218
app/Views/newClientModal.php
Normal file
218
app/Views/newClientModal.php
Normal file
@ -0,0 +1,218 @@
|
||||
<!-- 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" 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="validateInput(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="validateInput(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="validateInput(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">
|
||||
</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">
|
||||
</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">
|
||||
</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)">
|
||||
</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" onchange="validateInput(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" class="btn btn-primary waves-effect waves-light mr-1">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$("#client_form").submit(function(event) {
|
||||
// alert("Function Called from Modal")
|
||||
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');
|
||||
|
||||
|
||||
isClientFormSubmitting = true;
|
||||
var isValid = $('#client_form').parsley().validate();
|
||||
if (!isValid) {
|
||||
console.log('Form is Empty', 'Warning');
|
||||
return ;
|
||||
}
|
||||
|
||||
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();
|
||||
setTimeout(function(){
|
||||
$('#client_branch_id').val(res.branch_id).change();
|
||||
// try {
|
||||
// setTimeout(function () {(res.branch_id)},1000);
|
||||
// }catch (e) {
|
||||
// console.error('Error calling getBranchData:', e); // optional logging
|
||||
// }
|
||||
}, 1000)
|
||||
}, 2000)
|
||||
|
||||
}else{
|
||||
|
||||
toastr.error("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");
|
||||
}
|
||||
|
||||
isClientFormSubmitting = false;
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
@ -795,115 +795,7 @@
|
||||
</div>
|
||||
<!-- end form row -->
|
||||
|
||||
<!-- 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" 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="validateInput(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="validateInput(this, 'clients', 'phone')">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="cost_center">Email<span class="text-danger">*</span></label>
|
||||
<input type="email" class="form-control" id="email" placeholder="Enter Email" name="email">
|
||||
</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')">
|
||||
</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">
|
||||
</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">
|
||||
</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">
|
||||
</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)">
|
||||
</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" onchange="validateInput(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" class="btn btn-primary waves-effect waves-light mr-1">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div>
|
||||
<?php include("newClientModal.php") ?>
|
||||
|
||||
<!-- Vehicle form content modal-->
|
||||
<div class="modal fade" id="vehicle_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" data-backdrop="static">
|
||||
@ -3155,108 +3047,108 @@ $("#inception_form_id").submit(function(event) {
|
||||
});
|
||||
});
|
||||
|
||||
$("#client_form").submit(function(event) {
|
||||
// $("#client_form").submit(function(event) {
|
||||
|
||||
let form_type = $(this).data('id') || 0;
|
||||
// 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());
|
||||
// console.log('onsubmit event', this)
|
||||
// console.log('onsubmit event get data value',form_type)
|
||||
// console.log('client_type', $('#client_type').val());
|
||||
|
||||
event.preventDefault();
|
||||
// event.preventDefault();
|
||||
|
||||
|
||||
$('#aadhar').attr('data-parsley-required', 'false');
|
||||
$('#aadhar').removeAttr('required');
|
||||
// $('#aadhar').attr('data-parsley-required', 'false');
|
||||
// $('#aadhar').removeAttr('required');
|
||||
|
||||
|
||||
isClientFormSubmitting = true;
|
||||
var isValid = $('#client_form').parsley().validate();
|
||||
if (!isValid) {
|
||||
console.log('Form is Empty', 'Warning');
|
||||
return ;
|
||||
}
|
||||
// isClientFormSubmitting = true;
|
||||
// var isValid = $('#client_form').parsley().validate();
|
||||
// if (!isValid) {
|
||||
// console.log('Form is Empty', 'Warning');
|
||||
// return ;
|
||||
// }
|
||||
|
||||
form_action = '<?= base_url("util/createClientWithMinimalData"); ?>';
|
||||
// form_action = '<?= base_url("util/createClientWithMinimalData"); ?>';
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
// $('.loader').fadeIn();
|
||||
// $('.loader-mask').fadeIn();
|
||||
|
||||
var client_type = $('#client_type').val() || $('#Owner_type').val();
|
||||
console.log('client_type:', client_type);
|
||||
// var client_type = $('#client_type').val() || $('#Owner_type').val();
|
||||
// console.log('client_type:', client_type);
|
||||
|
||||
//FORM Data
|
||||
var formData = new FormData($('#client_form')[0]);
|
||||
formData.append('client_type', client_type);
|
||||
// //FORM Data
|
||||
// var formData = new FormData($('#client_form')[0]);
|
||||
// formData.append('client_type', client_type);
|
||||
|
||||
$.ajax({
|
||||
data:formData,
|
||||
url: form_action,
|
||||
type: "POST",
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(res) {
|
||||
// $.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');
|
||||
// $('.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){
|
||||
getClientAndBranchAndPolicy(res.client_id, res.branch_id);
|
||||
// if(res.status == true){
|
||||
// getClientAndBranchAndPolicy(res.client_id, res.branch_id);
|
||||
|
||||
if(form_type != 1){
|
||||
// if(form_type != 1){
|
||||
|
||||
setTimeout(function(){
|
||||
$('#client_id').val(res.client_id).change();
|
||||
setTimeout(function(){
|
||||
$('#client_branch_id').val(res.branch_id).change();
|
||||
}, 1000)
|
||||
}, 2000)
|
||||
// setTimeout(function(){
|
||||
// $('#client_id').val(res.client_id).change();
|
||||
// setTimeout(function(){
|
||||
// $('#client_branch_id').val(res.branch_id).change();
|
||||
// }, 1000)
|
||||
// }, 2000)
|
||||
|
||||
}else{
|
||||
// }else{
|
||||
|
||||
setTimeout(function(){
|
||||
$('#owner').val(res.client_id).change();
|
||||
$('#owner_branch').val(res.branch_id).change();
|
||||
// setTimeout(function(){
|
||||
// $('#owner').val(res.client_id).change();
|
||||
// $('#owner_branch').val(res.branch_id).change();
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
// $('.loader').fadeOut();
|
||||
// $('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
}, 2000)
|
||||
}
|
||||
// }, 2000)
|
||||
// }
|
||||
|
||||
toastr.success(res.message, 'Success');
|
||||
// toastr.success(res.message, 'Success');
|
||||
|
||||
}else{
|
||||
toastr.error(res.message, 'Error');
|
||||
}
|
||||
// }else{
|
||||
// toastr.error(res.message, 'Error');
|
||||
// }
|
||||
|
||||
$('#client_form')[0].reset();
|
||||
$('.close').click();
|
||||
// $('#client_form')[0].reset();
|
||||
// $('.close').click();
|
||||
|
||||
if(form_type == 1){
|
||||
// if(form_type == 1){
|
||||
|
||||
var myModal = new bootstrap.Modal(document.getElementById('vehicle_modal'));
|
||||
myModal.show();
|
||||
// var myModal = new bootstrap.Modal(document.getElementById('vehicle_modal'));
|
||||
// myModal.show();
|
||||
|
||||
$('#client_form').removeAttr('data-id');
|
||||
// $('#client_form').removeAttr('data-id');
|
||||
|
||||
// Load form data into #vehicle_form from localStorage
|
||||
setFormDataFromLocalStorage("#vehicle_form", "vehicleFormData");
|
||||
}
|
||||
// // Load form data into #vehicle_form from localStorage
|
||||
// setFormDataFromLocalStorage("#vehicle_form", "vehicleFormData");
|
||||
// }
|
||||
|
||||
isClientFormSubmitting = false;
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}
|
||||
});
|
||||
});
|
||||
// isClientFormSubmitting = false;
|
||||
// },
|
||||
// error: function (xhr, status, error) {
|
||||
// console.error(xhr.responseText);
|
||||
// console.error(status, error);
|
||||
// $('.loader').fadeOut();
|
||||
// $('.loader-mask').delay(350).fadeOut('slow');
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
|
||||
$("#vehicle_form").submit(function(event) {
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user