You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
259 lines
8.9 KiB
PHP
259 lines
8.9 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
use App\Controllers\BaseController;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
|
|
// Models
|
|
use App\Models\CompanyDepartmentModel;
|
|
use App\Models\CompanyBranchModel;
|
|
use App\Models\JobTitleModel;
|
|
use App\Models\EmploymentStatusModel;
|
|
use App\Models\EmployeeModel;
|
|
|
|
// Entities
|
|
use App\Entities\CompanyDepartment;
|
|
use App\Entities\CompanyBranch;
|
|
use App\Entities\JobTitle;
|
|
use App\Entities\EmploymentStatus;
|
|
use App\Entities\Employee;
|
|
use CodeIgniter\Shield\Entities\User;
|
|
|
|
class HRController extends BaseController
|
|
{
|
|
public function index()
|
|
{
|
|
return redirect()->to(base_url('/login'));
|
|
}
|
|
|
|
public function companyDepartment()
|
|
{
|
|
$companyDepartments = (new CompanyDepartmentModel())->findAll();
|
|
|
|
$companyDeptHTMLTable = new \CodeIgniter\View\Table();
|
|
$companyDeptHTMLTable->setTemplate($this->adminLTETableTemplate());
|
|
|
|
if($companyDepartments == null)
|
|
$data['tblCompanyDept'] = '<p>No departments found.</p>';
|
|
else
|
|
{
|
|
foreach($companyDepartments as $department)
|
|
{
|
|
$companyDeptHTMLTable->setHeading('Department ID', 'Department Code', 'Department Name', 'Action');
|
|
|
|
$iconView = '<a href="#" class="ml-3" data-toggle="tooltip" title="View Department Information"><i class="fas fa-eye "></i></a>';
|
|
|
|
$companyDeptHTMLTable->addRow($department->dept_id, $department->department_code, $department->department_name, "$iconView");
|
|
}
|
|
|
|
$data['tblCompanyDept'] = $companyDeptHTMLTable->generate();
|
|
|
|
}
|
|
|
|
return view('hr/departmentview', $data);
|
|
}
|
|
|
|
public function addCompanyDepartment()
|
|
{
|
|
$companyDepartment = new CompanyDepartment();
|
|
$companyDeptModel = new CompanyDepartmentModel();
|
|
|
|
$rawData = $this->request->getPost();
|
|
|
|
$companyDepartment->fill($rawData);
|
|
$companyDepartment->parent_dept_id = 0;
|
|
$companyDeptModel->save($companyDepartment);
|
|
|
|
if($companyDeptModel->getInsertID() == 0)
|
|
return redirect()->back()->withInput()->with('error', 'Failed to add Department');
|
|
else
|
|
return redirect()->to('/hr/dept')->with('message', 'Department Added');
|
|
|
|
}
|
|
|
|
public function companyBranch()
|
|
{
|
|
$companyBranches = (new CompanyBranchModel())->findAll();
|
|
|
|
$companyBranchHTMLTable = new \CodeIgniter\View\Table();
|
|
$companyBranchHTMLTable->setTemplate($this->adminLTETableTemplate());
|
|
|
|
if($companyBranches == null)
|
|
$data['tblCompanyBranch'] = '<p>No branches found.</p>';
|
|
else
|
|
{
|
|
foreach($companyBranches as $branch)
|
|
{
|
|
$companyBranchHTMLTable->setHeading('Branch Code', 'Branch Name', 'Address', 'Contact Number', 'Email Address', 'Action');
|
|
|
|
$iconView = '<a href="#" class="ml-3" data-toggle="tooltip" title="View Branch Information"><i class="fas fa-eye "></i></a>';
|
|
|
|
$companyBranchHTMLTable->addRow($branch->branch_code, $branch->branch_name, $branch->address, $branch->contact_number, $branch->email_address, "$iconView");
|
|
}
|
|
|
|
$data['tblCompanyBranch'] = $companyBranchHTMLTable->generate();
|
|
}
|
|
|
|
return view('hr/branchview', $data);
|
|
}
|
|
|
|
public function addCompanyBranch()
|
|
{
|
|
$companyBranch = new CompanyBranch();
|
|
$companyBranchModel = new CompanyBranchModel();
|
|
|
|
$rawData = $this->request->getPost();
|
|
|
|
$companyBranch->fill($rawData);
|
|
$companyBranchModel->save($companyBranch);
|
|
|
|
if($companyBranchModel->getInsertID() == 0)
|
|
return redirect()->back()->withInput()->with('error', 'Failed to add branch');
|
|
else
|
|
return redirect()->to('/hr/branch')->with('message', 'Branch Added ');
|
|
}
|
|
|
|
public function jobTitle()
|
|
{
|
|
$jobTitles = (new JobTitleModel())->findAll();
|
|
|
|
$jobTitleHTMLTable = new \CodeIgniter\View\Table();
|
|
$jobTitleHTMLTable->setTemplate($this->adminLTETableTemplate());
|
|
|
|
if($jobTitles == null)
|
|
$data['tblJobTitle'] = '<p>No job titles found.</p>';
|
|
else
|
|
{
|
|
foreach($jobTitles as $jobTitle)
|
|
{
|
|
$jobTitleHTMLTable->setHeading('Job Title ID', 'Job Title Name', 'Action');
|
|
|
|
$iconView = '<a href="#" class="ml-3" data-toggle="tooltip" title="View Job Title Information"><i class="fas fa-eye "></i></a>';
|
|
|
|
$jobTitleHTMLTable->addRow($jobTitle->job_title_id, $jobTitle->job_title_name, "$iconView");
|
|
}
|
|
|
|
$data['tblJobTitle'] = $jobTitleHTMLTable->generate();
|
|
}
|
|
|
|
return view('hr/jobtitleview', $data);
|
|
}
|
|
|
|
public function addJobTitle()
|
|
{
|
|
$jobTitle = new JobTitle();
|
|
$jobTitleModel = new JobTitleModel();
|
|
|
|
$rawData = $this->request->getPost();
|
|
|
|
$jobTitle->fill($rawData);
|
|
$jobTitleModel->save($jobTitle);
|
|
|
|
if($jobTitleModel->getInsertID() == 0)
|
|
return redirect()->back()->withInput()->with('error', 'Failed to add job title');
|
|
else
|
|
return redirect()->to('/hr/jobtitle')->with('message', 'Job Title Added');
|
|
}
|
|
|
|
public function employmentStatus()
|
|
{
|
|
$employmentStatus = (new EmploymentStatusModel())->findAll();
|
|
|
|
$empStatusHTMLTable = new \CodeIgniter\View\Table();
|
|
$empStatusHTMLTable->setTemplate($this->adminLTETableTemplate());
|
|
|
|
if($employmentStatus == null)
|
|
$data['tblEmploymentStatus'] = '<p>No employment status found.</p>';
|
|
else
|
|
{
|
|
foreach($employmentStatus as $empStatus)
|
|
{
|
|
$empStatusHTMLTable->setHeading('Status ID', 'Status Name', 'Action');
|
|
|
|
$iconView = '<a href="#" class="ml-3" data-toggle="tooltip" title="View Employment Status Information"><i class="fas fa-eye "></i></a>';
|
|
|
|
$empStatusHTMLTable->addRow($empStatus->emp_status_id, $empStatus->status_name, "$iconView");
|
|
}
|
|
|
|
$data['tblEmploymentStatus'] = $empStatusHTMLTable->generate();
|
|
}
|
|
|
|
return view('hr/empstatusview', $data);
|
|
}
|
|
|
|
public function addEmploymentStatus()
|
|
{
|
|
$employmentStatus = new EmploymentStatus();
|
|
$employmentStatusModel = new EmploymentStatusModel();
|
|
|
|
$rawData = $this->request->getPost();
|
|
|
|
$employmentStatus->fill($rawData);
|
|
$employmentStatusModel->save($employmentStatus);
|
|
|
|
if($employmentStatusModel->getInsertID() == 0)
|
|
return redirect()->back()->withInput()->with('error', 'Failed to add employment status');
|
|
else
|
|
return redirect()->to('/hr/empstatus')->with('message', 'Employment Status Added');
|
|
}
|
|
|
|
public function employee()
|
|
{
|
|
$employees = (new EmployeeModel())->findAll();
|
|
$data['branches'] = (new CompanyBranchModel())->findAll();
|
|
$data['departments'] = (new CompanyDepartmentModel())->findAll();
|
|
$data['jobTitles'] = (new JobTitleModel())->findAll();
|
|
$data['employmentStatus'] = (new EmploymentStatusModel())->findAll();
|
|
|
|
$employeeHTMLTable = new \CodeIgniter\View\Table();
|
|
$employeeHTMLTable->setTemplate($this->adminLTETableTemplate());
|
|
|
|
if($employees == null)
|
|
$data['tblEmployee'] = '<p>No employees found.</p>';
|
|
else
|
|
{
|
|
foreach($employees as $employee)
|
|
{
|
|
$employeeHTMLTable->setHeading('Employee ID', 'First Name', 'Last Name', 'Action');
|
|
|
|
$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>';
|
|
$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");
|
|
}
|
|
|
|
$data['tblEmployee'] = $employeeHTMLTable->generate();
|
|
}
|
|
|
|
return view('hr/employeeview', $data);
|
|
}
|
|
|
|
public function addEmployee()
|
|
{
|
|
$employee = new Employee();
|
|
$employeeModel = new EmployeeModel();
|
|
|
|
$rawData = $this->request->getPost();
|
|
|
|
$employee->fill($rawData);
|
|
$employeeModel->save($employee);
|
|
|
|
if($employeeModel->getInsertID() == 0)
|
|
return redirect()->back()->withInput()->with('error', 'Failed to add employee');
|
|
else
|
|
return redirect()->to('/hr/emp')->with('message', 'Employee Added');
|
|
}
|
|
|
|
|
|
// Class specific methods
|
|
private function adminLTETableTemplate()
|
|
{
|
|
$template = [
|
|
'table_open' => '<table class="table table-head-fixed table-hover text-nowrap">'
|
|
];
|
|
|
|
return $template;
|
|
}
|
|
} |