CHANGE_ADD_REPOTING_MANAGER_FIELDS
This commit is contained in:
parent
2311f3c93a
commit
cbdf8ad8eb
@ -66,6 +66,7 @@ class UserController extends AdminController
|
|||||||
// print_r($data); die;
|
// print_r($data); die;
|
||||||
$data['roleData'] = $this->roleModel->select('id, role')->findAll();
|
$data['roleData'] = $this->roleModel->select('id, role')->findAll();
|
||||||
$data['teamData'] = $this->teamModel->select('id, name')->where('is_active',1)->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();
|
$data['NHanceBranchData'] = $this->nhanceBranchModel->select('id, branch_name')->where('is_active',1)->findAll();
|
||||||
$this->loadLayout('UserList', $data);
|
$this->loadLayout('UserList', $data);
|
||||||
}
|
}
|
||||||
@ -74,7 +75,7 @@ class UserController extends AdminController
|
|||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
$this->myLogger->logme('error', 'User create function called');
|
$this->myLogger->logme('error', 'User create function called');
|
||||||
dd($this->request->getPost());
|
// dd($this->request->getPost());
|
||||||
$teams = $this->request->getPost('team');
|
$teams = $this->request->getPost('team');
|
||||||
|
|
||||||
//if this is get method return to user creation page
|
//if this is get method return to user creation page
|
||||||
|
|||||||
@ -28,6 +28,7 @@ class UserModel extends Model
|
|||||||
"updated_at",
|
"updated_at",
|
||||||
"is_active",
|
"is_active",
|
||||||
"nhance_branch_id",
|
"nhance_branch_id",
|
||||||
|
"rm_id",
|
||||||
];
|
];
|
||||||
|
|
||||||
// Dates
|
// Dates
|
||||||
|
|||||||
@ -488,7 +488,7 @@ table.dataTable tbody td {
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
||||||
<div class="form-row">
|
<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>
|
<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>
|
<select class="form-control" id="nhance_branch_id" name="nhance_branch_id" required>
|
||||||
<option value="">Select NHance Branch</option>
|
<option value="">Select NHance Branch</option>
|
||||||
@ -497,16 +497,25 @@ table.dataTable tbody td {
|
|||||||
<?php } ?>
|
<?php } ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</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>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label for="emp_code">Employee Code<span class="text-danger">*</span></label>
|
<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>
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label for="first_name">Name<span class="text-danger">*</span></label>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -514,7 +523,7 @@ table.dataTable tbody td {
|
|||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<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" 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>
|
||||||
|
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
@ -863,6 +872,7 @@ table.dataTable tbody td {
|
|||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
|
||||||
$('#nhance_branch_id').select2();
|
$('#nhance_branch_id').select2();
|
||||||
|
$('#rm_id').select2();
|
||||||
|
|
||||||
$('#nhance_branch_id')
|
$('#nhance_branch_id')
|
||||||
.val(null) // ✅ MUST be null
|
.val(null) // ✅ MUST be null
|
||||||
@ -1070,12 +1080,13 @@ table.dataTable tbody td {
|
|||||||
$('#mobile').val(res.data.mobile);
|
$('#mobile').val(res.data.mobile);
|
||||||
$('#emp_code').val(res.data.emp_code);
|
$('#emp_code').val(res.data.emp_code);
|
||||||
$('#role option[value="' + res.data.role + '"]').prop('selected', true);
|
$('#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 &&
|
if (res.data.nhance_branch_id !== null &&
|
||||||
res.data.nhance_branch_id !== "" &&
|
res.data.nhance_branch_id !== "" &&
|
||||||
res.data.nhance_branch_id !== 0) {
|
res.data.nhance_branch_id !== 0) {
|
||||||
$('#nhance_branch_id')
|
$('#nhance_branch_id')
|
||||||
.val(res.data.nhance_branch_id)
|
.val(res.data.nhance_branch_id)
|
||||||
.trigger('change.select2'); // ✅ correct trigger
|
.trigger('change.select2');
|
||||||
} else {
|
} else {
|
||||||
$('#nhance_branch_id')
|
$('#nhance_branch_id')
|
||||||
.val(null) // ✅ MUST be null
|
.val(null) // ✅ MUST be null
|
||||||
@ -1819,6 +1830,7 @@ table.dataTable tbody td {
|
|||||||
$('#mobile').val('');
|
$('#mobile').val('');
|
||||||
$('#emp_code').val('');
|
$('#emp_code').val('');
|
||||||
$('#nhance_branch_id').val('0');
|
$('#nhance_branch_id').val('0');
|
||||||
|
$('#rm_id').val('0');
|
||||||
$('#UserForm').attr('action', '<?php echo base_url('/user/create');?>');
|
$('#UserForm').attr('action', '<?php echo base_url('/user/create');?>');
|
||||||
let myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
|
let myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
|
||||||
myModal.show(); // open modal
|
myModal.show(); // open modal
|
||||||
@ -1837,5 +1849,28 @@ table.dataTable tbody td {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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>
|
</script>
|
||||||
Loading…
Reference in New Issue
Block a user