diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index ea65bca..fdf55ca 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -133,15 +133,19 @@ class ClientController extends AdminController $field = $this->request->getPost('field'); $value = $this->request->getPost('value'); - if($value == '') - return $this->response->setJSON(['isDuplicate' => false]); + // print_rr($value); die; + if($value == '') return $this->response->setJSON(['isDuplicate' => false]); // Load the database if not already loaded $db = db_connect(); // Perform the query $builder = $db->table($table); - $isDuplicate = $builder->where($field, $value)->where('is_active', 1)->countAllResults() > 0; + 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; + } // Return the result return $this->response->setJSON(['isDuplicate' => $isDuplicate]); diff --git a/app/Views/employee_data_list.php b/app/Views/employee_data_list.php index 292827e..c3f2c24 100755 --- a/app/Views/employee_data_list.php +++ b/app/Views/employee_data_list.php @@ -348,14 +348,14 @@ + onkeyup="validateInput(this, 'employees', 'email_corporate')" required>
+ onkeyup="validateInput(this, 'employees', 'mobile')" required>
@@ -677,6 +677,11 @@ function send_mail_for_individual_employee_ecard(id) { 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 label = $(input).closest('.form-group').find('label').text().replace('*', '').trim(); @@ -685,10 +690,18 @@ function validateInput(input, table, field) { 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) { 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) { $('.loader').fadeIn(); $('.loader-mask').fadeIn();