FIX_EMPLOYEE_EDIT_VALIDATE : RV
This commit is contained in:
parent
22f25022f7
commit
e5afea81f1
@ -133,15 +133,19 @@ class ClientController extends AdminController
|
|||||||
$field = $this->request->getPost('field');
|
$field = $this->request->getPost('field');
|
||||||
$value = $this->request->getPost('value');
|
$value = $this->request->getPost('value');
|
||||||
|
|
||||||
if($value == '')
|
// print_rr($value); die;
|
||||||
return $this->response->setJSON(['isDuplicate' => false]);
|
if($value == '') return $this->response->setJSON(['isDuplicate' => false]);
|
||||||
|
|
||||||
// Load the database if not already loaded
|
// Load the database if not already loaded
|
||||||
$db = db_connect();
|
$db = db_connect();
|
||||||
|
|
||||||
// Perform the query
|
// Perform the query
|
||||||
$builder = $db->table($table);
|
$builder = $db->table($table);
|
||||||
|
if(is_array($value)){
|
||||||
|
$isDuplicate = $builder->where($value)->where('is_active', 1)->countAllResults() > 0;
|
||||||
|
}else{
|
||||||
$isDuplicate = $builder->where($field, $value)->where('is_active', 1)->countAllResults() > 0;
|
$isDuplicate = $builder->where($field, $value)->where('is_active', 1)->countAllResults() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Return the result
|
// Return the result
|
||||||
return $this->response->setJSON(['isDuplicate' => $isDuplicate]);
|
return $this->response->setJSON(['isDuplicate' => $isDuplicate]);
|
||||||
|
|||||||
@ -348,14 +348,14 @@
|
|||||||
<label for="email">Email<span class="text-danger">*</span></label>
|
<label for="email">Email<span class="text-danger">*</span></label>
|
||||||
<input type="text" class="form-control" id="email_corporate" placeholder="Enter Email"
|
<input type="text" class="form-control" id="email_corporate" placeholder="Enter Email"
|
||||||
name="email_corporate" data-parsley-trigger="change" data-parsley-type="email"
|
name="email_corporate" data-parsley-trigger="change" data-parsley-type="email"
|
||||||
onchange="validateInput(this, 'employees', 'email_corporate')" required>
|
onkeyup="validateInput(this, 'employees', 'email_corporate')" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-md-12">
|
<div class="form-group col-md-12">
|
||||||
<label for="mobile">Mobile Number<span class="text-danger">*</span></label>
|
<label for="mobile">Mobile Number<span class="text-danger">*</span></label>
|
||||||
<input type="text" class="form-control" id="mobile" placeholder="Enter Mobile Number"
|
<input type="text" class="form-control" id="mobile" placeholder="Enter Mobile Number"
|
||||||
name="mobile" onkeypress="return onlyNumbers(event)" maxlength="10" minlength="10"
|
name="mobile" onkeypress="return onlyNumbers(event)" maxlength="10" minlength="10"
|
||||||
onchange="validateInput(this, 'employees', 'mobile')" required>
|
onkeyup="validateInput(this, 'employees', 'mobile')" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@ -677,6 +677,11 @@ function send_mail_for_individual_employee_ecard(id) {
|
|||||||
|
|
||||||
function validateInput(input, table, field) {
|
function validateInput(input, table, field) {
|
||||||
|
|
||||||
|
let emp_code = $('#emp_code_for_edit').val();
|
||||||
|
let client_id = $('#clients').val();
|
||||||
|
console.log("emp_code", emp_code);
|
||||||
|
console.log("client_id", client_id);
|
||||||
|
|
||||||
let value = $(input).val();
|
let value = $(input).val();
|
||||||
let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim();
|
let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim();
|
||||||
|
|
||||||
@ -685,10 +690,18 @@ function validateInput(input, table, field) {
|
|||||||
message = label + " already exists!";
|
message = label + " already exists!";
|
||||||
}
|
}
|
||||||
|
|
||||||
checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) {
|
let data = {};
|
||||||
|
data["emp_code !="] = emp_code;
|
||||||
|
data[field] = value;
|
||||||
|
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
|
checkDuplicateTableFieldValue(table, field, data, function(isDuplicate) {
|
||||||
if (isDuplicate) {
|
if (isDuplicate) {
|
||||||
toastr.warning(message, 'WARNING');
|
toastr.warning(message, 'WARNING');
|
||||||
$(input).val('')
|
$("#btnSubmit").prop('disabled', true);
|
||||||
|
}else{
|
||||||
|
$("#btnSubmit").prop('disabled', false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -722,7 +735,6 @@ function closeModal() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function get_emp_history(input, emp_id) {
|
function get_emp_history(input, emp_id) {
|
||||||
$('.loader').fadeIn();
|
$('.loader').fadeIn();
|
||||||
$('.loader-mask').fadeIn();
|
$('.loader-mask').fadeIn();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user