CHANGE_ADD_REPOTING_MANAGER_FIELDS

This commit is contained in:
VENKATESHWARAN 2025-12-06 16:54:13 +05:30
parent 2311f3c93a
commit cbdf8ad8eb
3 changed files with 43 additions and 6 deletions

View File

@ -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

View File

@ -28,6 +28,7 @@ class UserModel extends Model
"updated_at",
"is_active",
"nhance_branch_id",
"rm_id",
];
// Dates

View File

@ -488,7 +488,7 @@ table.dataTable tbody td {
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-12">
<div class="form-group col-md-6">
<label for="nhance_branch_id">NHance Branch<span class="text-danger">*</span></label>
<select class="form-control" id="nhance_branch_id" name="nhance_branch_id" required>
<option value="">Select NHance Branch</option>
@ -497,16 +497,25 @@ table.dataTable tbody td {
<?php } ?>
</select>
</div>
<div class="form-group col-md-6">
<label for="rm_id">Reporting Manager<span class="text-danger">*</span></label>
<select class="form-control" id="rm_id" name="rm_id" required>
<option value="">Select Reporting Manager</option>
<?php foreach($user_data as $value) { ?>
<option value="<?= $value['id'] ?>"><?= $value['first_name'] ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="emp_code">Employee Code<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="emp_code" placeholder="Enter Code" name="emp_code" required>
<input type="text" class="form-control" id="emp_code" placeholder="Enter Code" name="emp_code" onchange="validateInput(this, 'user_profiles', 'emp_code', 'btnSubmit')" required>
</div>
<div class="form-group col-md-6">
<label for="first_name">Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_name" placeholder="Ente Name" name="first_name" required>
<input type="text" class="form-control" id="first_name" placeholder="Enter Name" name="first_name" required>
</div>
</div>
@ -514,7 +523,7 @@ table.dataTable tbody td {
<div class="form-row">
<div class="form-group col-md-6">
<label for="email">Email<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="email" placeholder="Enter Email" name="email" data-parsley-trigger="change" data-parsley-type="email" required>
<input type="text" class="form-control" id="email" placeholder="Enter Email" name="email" data-parsley-trigger="change" data-parsley-type="email" onchange="validateInput(this, 'user_profiles', 'email', 'btnSubmit')" required>
</div>
<div class="form-group col-md-6">
@ -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', '<?php echo base_url('/user/create');?>');
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);
}
});
}
</script>