diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php index ee62c702..3879b49d 100755 --- a/app/Controllers/UserController.php +++ b/app/Controllers/UserController.php @@ -66,6 +66,7 @@ class UserController extends AdminController // print_r($data); die; $data['roleData'] = $this->roleModel->select('id, role')->findAll(); $data['teamData'] = $this->teamModel->select('id, name')->where('is_active',1)->findAll(); + $data['user_data'] = $this->userModel->where('is_active',1)->findAll(); $data['NHanceBranchData'] = $this->nhanceBranchModel->select('id, branch_name')->where('is_active',1)->findAll(); $this->loadLayout('UserList', $data); } @@ -74,7 +75,7 @@ class UserController extends AdminController public function create() { $this->myLogger->logme('error', 'User create function called'); - dd($this->request->getPost()); + // dd($this->request->getPost()); $teams = $this->request->getPost('team'); //if this is get method return to user creation page diff --git a/app/Models/UserModel.php b/app/Models/UserModel.php index 20baa54c..32272925 100755 --- a/app/Models/UserModel.php +++ b/app/Models/UserModel.php @@ -28,6 +28,7 @@ class UserModel extends Model "updated_at", "is_active", "nhance_branch_id", + "rm_id", ]; // Dates diff --git a/app/Views/UserList.php b/app/Views/UserList.php index 94442753..1382369b 100755 --- a/app/Views/UserList.php +++ b/app/Views/UserList.php @@ -488,7 +488,7 @@ table.dataTable tbody td {
-
+
+
+ + +
- +
- +
@@ -514,7 +523,7 @@ table.dataTable tbody td {
- +
@@ -863,6 +872,7 @@ table.dataTable tbody td { $(document).ready(function () { $('#nhance_branch_id').select2(); + $('#rm_id').select2(); $('#nhance_branch_id') .val(null) // ✅ MUST be null @@ -1070,12 +1080,13 @@ table.dataTable tbody td { $('#mobile').val(res.data.mobile); $('#emp_code').val(res.data.emp_code); $('#role option[value="' + res.data.role + '"]').prop('selected', true); + $('#rm_id').val(res.data.rm_id).select2(); // ✅ correct trigger if (res.data.nhance_branch_id !== null && res.data.nhance_branch_id !== "" && res.data.nhance_branch_id !== 0) { $('#nhance_branch_id') .val(res.data.nhance_branch_id) - .trigger('change.select2'); // ✅ correct trigger + .trigger('change.select2'); } else { $('#nhance_branch_id') .val(null) // ✅ MUST be null @@ -1819,6 +1830,7 @@ table.dataTable tbody td { $('#mobile').val(''); $('#emp_code').val(''); $('#nhance_branch_id').val('0'); + $('#rm_id').val('0'); $('#UserForm').attr('action', ''); let myModal = new bootstrap.Modal(document.getElementById('con-close-modal')); myModal.show(); // open modal @@ -1836,6 +1848,29 @@ table.dataTable tbody td { myModal.show(); // open modal }); + + function validateInput(input, table, field, submitButId){ + + 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!"; + } + + checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) { + if (isDuplicate) { + toastr.warning(message, 'WARNING'); + // $(input).val('') + $('#' + submitButId).prop('disabled', true); + } else{ + $('#' + submitButId).prop('disabled', false); + } + }); + + } + \ No newline at end of file