Merge pull request 'Added employee editing' (#2) from paulcortezl5 into main

Reviewed-on: #2
pull/3/head
paul 8 months ago
commit 94ef2e070a

@ -26,6 +26,7 @@ $routes->post('hr/addempstatus', 'HRController::addEmploymentStatus');
$routes->get('hr/emp', 'HRController::employee');
$routes->post('hr/addemp', 'HRController::addEmployee');
$routes->post('hr/editemp', 'HRController::editEmployee');
// Payroll Routes

@ -222,9 +222,24 @@ class HRController extends BaseController
foreach($employees as $employee)
{
$employeeHTMLTable->setHeading('Employee ID', 'First Name', 'Last Name', 'Action');
$empHTMLData = 'data-employee_id="'.$employee->employee_id.
'" data-company_id="'.$employee->company_id.
'" data-branch_code="'.$employee->branch_code.
'" data-dept_id="'.$employee->dept_id.
'" data-job_title_id="'.$employee->job_title_id.
'" data-emp_status_id="'.$employee->emp_status_id.
'" data-pay_group_id="'.$employee->pay_group_id.
'" data-company_issued_id="'.$employee->company_issued_id.
'" data-last_name="'.$employee->last_name.
'" data-first_name="'.$employee->first_name.
'" data-middle_name="'.$employee->middle_name.
'" data-suffix="'.$employee->suffix.
'" data-email_address="'.$employee->email_address.
'" data-contact_number="'.$employee->contact_number.'"';
$iconView = '<a href="#" class="ml-3" data-toggle="tooltip" title="View Employee Information"><i class="fas fa-eye "></i></a>';
$iconEdit = '<a href="#" class="ml-3" data-toggle="tooltip" title="Edit Employee Information"><i class="fas fa-edit "></i></a>';
$iconView = '<a href="#" class="ml-3" data-toggle="tooltip" title="View Employee Information" '.$empHTMLData.'><i class="fas fa-eye "></i></a>';
$iconEdit = '<a href="#" class="ml-3" data-toggle="tooltip" title="Edit Employee Information" '.$empHTMLData.' onclick="editEmployee(this)"><i class="fas fa-edit "></i></a>';
$iconDelete = '<a href="#" class="ml-3" data-toggle="tooltip" title="Delete Employee Information"><i class="fas fa-trash "></i></a>';
$employeeHTMLTable->addRow($employee->company_issued_id, $employee->first_name, $employee->last_name, "$iconView $iconEdit $iconDelete");
@ -251,4 +266,20 @@ class HRController extends BaseController
else
return redirect()->to('/hr/emp')->with('message', 'Employee Added');
}
public function editEmployee()
{
$employee = new Employee();
$employeeModel = new EmployeeModel();
$rawData = $this->request->getPost();
$employee->fill($rawData);
$employeeModel->save($employee);
if($employeeModel->save($employee))
return redirect()->to('/hr/emp')->with('message', 'Modified employee information');
else
return redirect()->back()->withInput()->with('error', 'Failed to add employee');
}
}

@ -17,6 +17,7 @@ class EmployeeModel extends Model
'dept_id',
'job_title_id',
'emp_status_id',
'pay_group_id',
'company_issued_id',
'last_name',
'first_name',

@ -26,7 +26,7 @@
<!-- Main content -->
<?= $this->section('main') ?>
<!-- Modal Add Branch -->
<!-- Modal Add Employee -->
<div class="modal fade" id="mdlAddEmployee">
<div class="modal-dialog">
<div class="modal-content">
@ -173,6 +173,149 @@
</div>
<!-- Modal Edit Emloyee -->
<div class="modal fade" id="mdlEditEmployee">
<div class="modal-dialog">
<div class="modal-content">
<form action="<?= url_to('hr/editemp') ?>" method="post">
<div class="modal-header bg-warning">
<h4 class="modal-title" >Edit Employee</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-12">
<p class="lead">Employee Information</p>
<div class="row">
<div class="col-12">
<p><strong>Company Name</strong></p>
<input type="hidden" name="employee_id" id="hdnEditEmployeeID">
<input type="hidden" name="company_id" id="hdnEditCompanyID">
<p><?= session()->get('companyInfo')->company_name ?></p> <!-- To be modified since this should get the company name from the database according to company_id -->
</div>
</div>
<div class="row">
<div class="col-12">
<div class="form-group">
<!-- select -->
<div class="form-group">
<label>Select Branch Assignment</label>
<select class="form-control" name="branch_code" id="cmbEditBranch">
<?Php
foreach($branches as $branch){
echo '<option value="'.$branch->branch_code.'">['.$branch->branch_code.'] '.$branch->branch_name.'</option>';
}
?>
</select>
</div>
</div>
<div class="form-group">
<!-- select -->
<div class="form-group">
<label>Select Department</label>
<select class="form-control" name="dept_id" id="cmbEditDepartment">
<?Php
foreach($departments as $department){
echo '<option value="'.$department->dept_id.'">['.$department->department_code.'] '.$department->department_name.'</option>';
}
?>
</select>
</div>
</div>
<div class="form-group">
<!-- select -->
<div class="form-group">
<label>Job Title</label>
<select class="form-control" name="job_title_id" id="cmbEditJobTitle">
<?Php
foreach($jobTitles as $jobTitle){
echo '<option value="'.$jobTitle->job_title_id.'">'.$jobTitle->job_title_name.'</option>';
}
?>
</select>
</div>
</div>
<div class="form-group">
<!-- select -->
<div class="form-group">
<label>Employment Status</label>
<select class="form-control" name="emp_status_id" id="cmbEditEmploymentStatus">
<?Php
foreach($employmentStatus as $empStatus){
echo '<option value="'.$empStatus->emp_status_id.'">'.$empStatus->status_name.'</option>';
}
?>
</select>
</div>
</div>
<div class="form-group">
<!-- select -->
<div class="form-group">
<label>Payroll Group</label>
<select class="form-control" name="pay_group_id" id="cmbEditPayGroup">
<?Php
foreach($payGroups as $payGroup){
echo '<option value="'.$payGroup->pay_group_id.'">'.$payGroup->pay_group_name.'</option>';
}
?>
</select>
</div>
</div>
<div class="form-group">
<label for="txtEditCompanyIssuedID">ID Number</label>
<input class="form-control" type="text" id="txtEditCompanyIssuedID" name="company_issued_id">
</div>
<div class="form-group">
<label for="txtEditLastname">Last Name</label>
<input class="form-control" type="text" id="txtEditLastname" name="last_name">
</div>
<div class="form-group">
<label for="txtEditFirstName">First Name</label>
<input class="form-control" type="text" id="txtEditFirstName" name="first_name">
</div>
<div class="form-group">
<label for="txtEditMiddleName">Middle Name</label>
<input class="form-control" type="text" id="txtEditMiddleName" name="middle_name">
</div>
<div class="form-group">
<label for="txtEditSuffix">Suffix (e.g. Jr, Sr, III)</label>
<input class="form-control" type="text" id="txtEditSuffix" name="suffix">
</div>
<div class="form-group">
<label for="txtEditEmailAddress">Email Address</label>
<input class="form-control" type="text" id="txtEditEmailAddress" name="email_address">
</div>
<div class="form-group">
<label for="txtEditContactNumber">Contact Number</label>
<input class="form-control" type="text" id="txtEditContactNumber" name="contact_number">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Save changes</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</form>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="card">
@ -203,7 +346,25 @@ $(document).ready(function() {
});
function editEmployee(data)
{
$("#hdnEditEmployeeID").val($(data).data("employee_id"));
$("#hdnEditCompanyID").val($(data).data("company_id"));
$("#cmbEditBranch").val($(data).data("branch_code"));
$("#cmbEditDepartment").val($(data).data("dept_id"));
$("#cmbEditJobTitle").val($(data).data("job_title_id"));
$("#cmbEditEmploymentStatus").val($(data).data("emp_status_id"));
$("#cmbEditPayGroup").val($(data).data("pay_group_id"));
$("#txtEditCompanyIssuedID").val($(data).data("company_issued_id"));
$("#txtEditLastname").val($(data).data("last_name"));
$("#txtEditFirstName").val($(data).data("first_name"));
$("#txtEditMiddleName").val($(data).data("middle_name"));
$("#txtEditSuffix").val($(data).data("suffix"));
$("#txtEditEmailAddress").val($(data).data("email_address"));
$("#txtEditContactNumber").val($(data).data("contact_number"));
$("#mdlEditEmployee").modal("show");
}
</script>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -26,3 +26,52 @@ in APPPATH\Controllers\HRController.php on line 211.
5 SYSTEMPATH\Commands\Server\rewrite.php(47): require_once('C:\\Projects\\webroot\\www\\kwpayroll\\public\\index.php')
INFO - 2024-09-11 08:51:11 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 08:51:11 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 09:54:32 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 09:54:32 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 09:58:13 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 09:58:13 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:06:06 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:06:06 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:06:42 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:06:42 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:14:13 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:14:13 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:14:28 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:14:29 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:25:38 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:25:38 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:26:10 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:26:10 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:26:33 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:26:33 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:26:34 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:26:40 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:26:40 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:29:14 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:29:14 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:29:28 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:29:28 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:29:29 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:29:41 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:29:41 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:30:33 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:30:33 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:30:34 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:30:57 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:30:58 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:31:15 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:31:15 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:31:15 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:31:32 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:31:32 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:31:32 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:39:05 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:39:06 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:39:08 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:39:08 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:39:08 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:39:12 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:39:12 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:40:37 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:40:38 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2024-09-11 10:40:38 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.

@ -0,0 +1 @@
__ci_last_regenerate|i:1726049669;csrf_test_name|s:32:"ed6e1473d2f3c51bcafefa3c48fa20d0";_ci_previous_url|s:27:"http://localhost:8080/login";

@ -0,0 +1 @@
__ci_last_regenerate|i:1726051237;csrf_test_name|s:32:"b51217379da0b60e2486dc03c8785d46";_ci_previous_url|s:27:"http://localhost:8080/login";

@ -0,0 +1 @@
__ci_last_regenerate|i:1726049668;beforeLoginUrl|s:28:"http://localhost:8080/hr/emp";__ci_vars|a:1:{s:14:"beforeLoginUrl";i:1726049968;}
Loading…
Cancel
Save