diff --git a/app/ClassLib/MiscLib.php b/app/ClassLib/MiscLib.php index 109ab7c..c26a816 100644 --- a/app/ClassLib/MiscLib.php +++ b/app/ClassLib/MiscLib.php @@ -17,4 +17,13 @@ class MiscLib return $template; } + + public static function adminLTEDataTableTemplate($tableID) + { + $template = [ + 'table_open' => '' + ]; + + return $template; + } } \ No newline at end of file diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 4b86890..b7e8aa7 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -38,6 +38,12 @@ $routes->post('payroll/addpaygroup', 'PayrollController::addPayrollGroup'); $routes->get('payroll/inded', 'PayrollController::incomeDeduction'); $routes->post('payroll/addinded', 'PayrollController::addIncomeDeduction'); +$routes->get('payroll/paytype', 'PayrollController::payrollType'); +$routes->post('payroll/addpaytype', 'PayrollController::addPayrollType'); + +$routes->get('payroll/emppayinfo', 'PayrollController::employeePayrollInfo'); +$routes->post('payroll/addemppayinfo', 'PayrollController::addEmployeePayrollInfo'); + // Administrator Routes $routes->get('adminuser', 'AdministratorController::index'); $routes->get('adminuser/newuser', 'AdministratorController::newUserView'); diff --git a/app/Controllers/PayrollController.php b/app/Controllers/PayrollController.php index 3bb9f6d..5405ea3 100644 --- a/app/Controllers/PayrollController.php +++ b/app/Controllers/PayrollController.php @@ -8,11 +8,17 @@ use CodeIgniter\HTTP\ResponseInterface; // Models use App\Models\PayrollGroupModel; use App\Models\IncomeDeductionModel; +use App\Models\PayrollTypeModel; +use App\Models\EmployeePayrollInfoModel; +use App\Models\EmployeeModel; // Entities use App\Entities\PayrollGroup; use App\Entities\IncomeDeduction; +use App\Entities\PayrollType; +use App\Entities\EmployeePayrollInfo; +use App\Entities\Employee; // Class Library use App\ClassLib\MiscLib; @@ -113,4 +119,122 @@ class PayrollController extends BaseController else return redirect()->to('/payroll/inded')->with('message', 'Income or Deduction Added'); } + + public function payrollType() + { + $payrollTypes = (new PayrollTypeModel())->findAll(); + + $payTypeHTMLTable = new \CodeIgniter\View\Table(); + $payTypeHTMLTable->setTemplate(MiscLib::adminLTETableTemplate()); + + if($payrollTypes == null) + $data['tblPayrollType'] = '

No payroll type found.

'; + else + { + foreach($payrollTypes as $payrollType) + { + $payTypeHTMLTable->setHeading('ID', 'Code', 'Name', 'Monthly', 'Semi-Monthly', 'Daily', 'Hourly', 'Action'); + + $iconView = ''; + + $payTypeHTMLTable->addRow($payrollType->paytype_id, $payrollType->paytype_code, $payrollType->paytype_name, ($payrollType->is_monthly) ? 'Yes' : 'No', ($payrollType->is_semi_monthly) ? 'Yes' : 'No', ($payrollType->is_daily) ? 'Yes' : 'No', ($payrollType->is_hourly) ? 'Yes' : 'No', $iconView); + } + + $data['tblPayrollType'] = $payTypeHTMLTable->generate(); + } + + return view('payroll/paytypeview', $data); + } + + public function addPayrollType() + { + $payrollType = new PayrollType(); + $payrollTypeModel = new PayrollTypeModel(); + + $rawData = $this->request->getPost(); + + // Initialize all payroll type fields to 0 + $rawData['is_monthly'] = 0; + $rawData['is_semi_monthly'] = 0; + $rawData['is_daily'] = 0; + $rawData['is_hourly'] = 0; + + // Handle radio button input + if (isset($rawData['paytype_sched'])) { + switch ($rawData['paytype_sched']) { + case 'monthly': + $rawData['is_monthly'] = 1; + break; + case 'semi_monthly': + $rawData['is_semi_monthly'] = 1; + break; + case 'daily': + $rawData['is_daily'] = 1; + break; + case 'hourly': + $rawData['is_hourly'] = 1; + break; + } + } + + $payrollType->fill($rawData); + $payrollTypeModel->save($payrollType); + + if($payrollTypeModel->getInsertID() == 0) + return redirect()->back()->withInput()->with('error', 'Failed to add payroll type'); + else + return redirect()->to('/payroll/paytype')->with('message', 'Payroll Type Added'); + } + + public function employeePayrollInfo() + { + $empPayInfos = (new EmployeePayrollInfoModel())->findAll(); + + $data['employees'] = (new EmployeeModel())->findAll(); + $data['paytypes'] = (new PayrollTypeModel())->findAll(); + + $empPayInfoHTMLTable = new \CodeIgniter\View\Table(); + $empPayInfoHTMLTable->setTemplate(MiscLib::adminLTETableTemplate()); + + if($empPayInfos == null) + $data['tblEmpPayInfo'] = '

No employee payroll type found.

'; + else + { + foreach($empPayInfos as $empPayInfo) + { + $empPayInfoHTMLTable->setHeading('ID', 'Payroll Type', 'Employee ID', 'Employee Name', 'Monthly', 'Semi-Monthly', 'Daily', 'Hourly', 'Action'); + + $iconView = ''; + + $empPayInfoHTMLTable->addRow($empPayInfo->emppay_id, $empPayInfo->paytype_id, $empPayInfo->employee_id, "", $empPayInfo->basic_monthly_pay, $empPayInfo->basic_semi_monthly_pay, $empPayInfo->basic_daily_pay, $empPayInfo->basic_hourly_pay, $iconView); + } + + $data['tblEmpPayInfo'] = $empPayInfoHTMLTable->generate(); + } + + return view('payroll/empinfoview', $data); + } + + public function addEmployeePayrollInfo() + { + $empPayInfo = new EmployeePayrollInfo(); + $empPayInfoModel = new EmployeePayrollInfoModel(); + + $rawData = $this->request->getPost(); + + $rawData['is_ATM'] = isset($rawData['is_ATM']) ? 1 : 0; + $rawData['has_cola'] = isset($rawData['has_cola']) ? 1 : 0; + $rawData['has_philhealth'] = isset($rawData['has_philhealth']) ? 1 : 0; + $rawData['has_hdmf'] = isset($rawData['has_hdmf']) ? 1 : 0; + $rawData['has_sss'] = isset($rawData['has_sss']) ? 1 : 0; + $rawData['has_gsis'] = isset($rawData['has_gsis']) ? 1 : 0; + + $empPayInfo->fill($rawData); + $empPayInfoModel->save($empPayInfo); + + if($empPayInfoModel->getInsertID() == 0) + return redirect()->back()->withInput()->with('error', 'Failed to add employee payroll type'); + else + return redirect()->to('/payroll/emppayinfo')->with('message', 'Employee Payroll Type Added'); + } } diff --git a/app/Database/Migrations/2024-09-15-022511_CreatePayType.php b/app/Database/Migrations/2024-09-15-022511_CreatePayType.php new file mode 100644 index 0000000..68b5fe4 --- /dev/null +++ b/app/Database/Migrations/2024-09-15-022511_CreatePayType.php @@ -0,0 +1,83 @@ +forge->addField([ + 'paytype_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'auto_increment' => true, + ], + 'paytype_code' => [ + 'type' => 'VARCHAR', + 'constraint' => 25, + 'null' => true, + ], + 'paytype_name' => [ + 'type' => 'VARCHAR', + 'constraint' => 255, + 'null' => false, + ], + 'is_monthly' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'null' => false, + ], + 'is_semi_monthly' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'null' => false, + ], + 'is_daily' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'null' => false, + ], + 'is_hourly' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'null' => false, + ], + + // Common fields + 'created_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + 'created_by' => [ + 'type' => 'VARCHAR', + 'constraint' => '20', + 'null' => true + ], + 'updated_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + 'updated_by' => [ + 'type' => 'VARCHAR', + 'constraint' => '20', + 'null' => true + ], + 'deleted_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + ]); + + $this->forge->addKey('paytype_id', true); + $this->forge->createTable('pay_type'); + } + + public function down() + { + $this->forge->dropTable('pay_type'); + } +} diff --git a/app/Database/Migrations/2024-09-15-143831_CreateEmployeePayInfo.php b/app/Database/Migrations/2024-09-15-143831_CreateEmployeePayInfo.php new file mode 100644 index 0000000..b6f1078 --- /dev/null +++ b/app/Database/Migrations/2024-09-15-143831_CreateEmployeePayInfo.php @@ -0,0 +1,118 @@ +forge->addField([ + 'emppay_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true, + 'auto_increment' => true + ], + 'employee_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true + ], + 'paytype_id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'unsigned' => true + ], + 'is_ATM' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'null' => false + ], + 'savings_account' => [ + 'type' => 'VARCHAR', + 'constraint' => 50, + 'null' => true + ], + 'basic_monthly_pay' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,4', + 'null' => false + ], + 'basic_semi_monthly_pay' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,4', + 'null' => false + ], + 'basic_daily_pay' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,4', + 'null' => false + ], + 'basic_hourly_pay' => [ + 'type' => 'DECIMAL', + 'constraint' => '12,4', + 'null' => false + ], + 'has_cola' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'null' => false + ], + 'has_philhealth' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'null' => false + ], + 'has_hdmf' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'null' => false + ], + 'has_sss' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'null' => false + ], + 'has_gsis' => [ + 'type' => 'TINYINT', + 'constraint' => 1, + 'null' => false + ], + + + // Common fields + 'created_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + 'created_by' => [ + 'type' => 'VARCHAR', + 'constraint' => '20', + 'null' => true + ], + 'updated_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + 'updated_by' => [ + 'type' => 'VARCHAR', + 'constraint' => '20', + 'null' => true + ], + 'deleted_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + ]); + + $this->forge->addKey('emppay_id', true); + $this->forge->createTable('emp_pay_info'); + } + + public function down() + { + $this->forge->dropTable('emp_pay_info'); + } +} diff --git a/app/Entities/EmployeePayrollInfo.php b/app/Entities/EmployeePayrollInfo.php new file mode 100644 index 0000000..35173a3 --- /dev/null +++ b/app/Entities/EmployeePayrollInfo.php @@ -0,0 +1,28 @@ + null, + 'employee_id' => null, + 'paytype_id' => null, + 'is_ATM' => null, + 'savings_account' => null, + 'basic_monthly_pay' => null, + 'basic_semi_monthly_pay' => null, + 'basic_daily_pay' => null, + 'basic_hourly_pay' => null, + 'has_cola' => null, + 'has_philhealth' => null, + 'has_hdmf' => null, + 'has_sss' => null, + 'has_gsis' => null, + ]; + protected $datamap = []; + protected $dates = ['created_at', 'updated_at', 'deleted_at']; + protected $casts = []; +} diff --git a/app/Entities/PayrollType.php b/app/Entities/PayrollType.php new file mode 100644 index 0000000..a93bce4 --- /dev/null +++ b/app/Entities/PayrollType.php @@ -0,0 +1,21 @@ + null, + 'paytype_code' => null, + 'paytype_name' => null, + 'is_monthly' => null, + 'is_semi_monthly' => null, + 'is_daily' => null, + 'is_hourly' => null, + ]; + protected $datamap = []; + protected $dates = ['created_at', 'updated_at', 'deleted_at']; + protected $casts = []; +} diff --git a/app/Models/EmployeePayrollInfoModel.php b/app/Models/EmployeePayrollInfoModel.php new file mode 100644 index 0000000..3388d09 --- /dev/null +++ b/app/Models/EmployeePayrollInfoModel.php @@ -0,0 +1,69 @@ +user()->employee_id; + return $data; + } + + public function assignUpdatedAt(array $data) + { + $data['data']['updated_at'] = date('Y-m-d H:i:s'); + $data['data']['updated_by'] = auth()->user()->employee_id; + return $data; + } +} diff --git a/app/Models/PayrollTypeModel.php b/app/Models/PayrollTypeModel.php new file mode 100644 index 0000000..9d9a4ee --- /dev/null +++ b/app/Models/PayrollTypeModel.php @@ -0,0 +1,61 @@ +user()->employee_id; + return $data; + } + + public function assignUpdatedAt(array $data) + { + $data['data']['updated_at'] = date('Y-m-d H:i:s'); + $data['data']['updated_by'] = auth()->user()->employee_id; + return $data; + } +} diff --git a/app/Views/payroll/compensationbenefitsview copy.php b/app/Views/payroll/compensationbenefitsview copy.php new file mode 100644 index 0000000..e64bf63 --- /dev/null +++ b/app/Views/payroll/compensationbenefitsview copy.php @@ -0,0 +1,199 @@ + +extend('templates/adminlte/generalcontent') ?> + + + +section('title') ?>Compensation and BenefitsendSection() ?> + + + +section('css') ?> + + + + +endSection() ?> + + + +section('bodyclass') ?>sidebar-miniendSection() ?> + + + +section('containertitle') ?>Employee Compensation and BenefitsendSection() ?> + + + +section('activebreadcrumb') ?>Compensation and BenefitsendSection() ?> + + + +section('main') ?> + + + + + +
+
+
+
+

List of Payroll Type

+
+
+
+ +
+
+ + + + +
+ +
+
+ +
+
+
+ +
+
+
+ +
+
+
+

Employee with assigned Compensation and Benefits

+
+ + + + + + + + + + + + + + + + + + +
Rendering engineBrowserPlatform(s)Engine versionCSS grade
TridentInternet + Explorer 4.0 + Win 95+ 4X
+ +
+

Employee with unassigned Compensation and Benefits

+
+ + + + + + + +endSection() ?> + + + + +section('js') ?> + + + + + + + + + + + + + + + + + +endSection() ?> + + \ No newline at end of file diff --git a/app/Views/payroll/compensationbenefitsview.php b/app/Views/payroll/compensationbenefitsview.php new file mode 100644 index 0000000..cfb980b --- /dev/null +++ b/app/Views/payroll/compensationbenefitsview.php @@ -0,0 +1,131 @@ + +extend('templates/adminlte/generalcontent') ?> + + + +section('title') ?>Compensation and BenefitsendSection() ?> + + + +section('css') ?> + +endSection() ?> + + + +section('bodyclass') ?>sidebar-miniendSection() ?> + + + +section('containertitle') ?>Employee Compensation and BenefitsendSection() ?> + + + +section('activebreadcrumb') ?>Compensation and BenefitsendSection() ?> + + + +section('main') ?> + + + + + +
+
+
+
+

List of Payroll Type

+
+
+
+ +
+
+ + + + +
+
+
+
+ +
+
+
+ + +endSection() ?> + + + + +section('js') ?> + + + +endSection() ?> + + \ No newline at end of file diff --git a/app/Views/payroll/empinfoview.php b/app/Views/payroll/empinfoview.php new file mode 100644 index 0000000..fd4d75b --- /dev/null +++ b/app/Views/payroll/empinfoview.php @@ -0,0 +1,208 @@ + +extend('templates/adminlte/generalcontent') ?> + + + +section('title') ?>Employee Payroll InfoendSection() ?> + + + +section('css') ?> + + + + + +endSection() ?> + + + +section('bodyclass') ?>sidebar-miniendSection() ?> + + + +section('containertitle') ?>Employee Payroll InfoendSection() ?> + + + +section('activebreadcrumb') ?>Employee Payroll InfoendSection() ?> + + + +section('main') ?> + + + + + +
+
+
+
+

List of Employee Payroll Information

+
+
+
+ + +
+
+ +
+
+
+ + +endSection() ?> + + + + +section('js') ?> + + + + + + + +endSection() ?> + + \ No newline at end of file diff --git a/app/Views/payroll/paytypeview.php b/app/Views/payroll/paytypeview.php new file mode 100644 index 0000000..6ab24d9 --- /dev/null +++ b/app/Views/payroll/paytypeview.php @@ -0,0 +1,123 @@ + +extend('templates/adminlte/generalcontent') ?> + + + +section('title') ?>Payroll TypeendSection() ?> + + + +section('css') ?> +endSection() ?> + + + +section('bodyclass') ?>sidebar-miniendSection() ?> + + + +section('containertitle') ?>Payroll TypeendSection() ?> + + + +section('activebreadcrumb') ?>Payroll TypeendSection() ?> + + + +section('main') ?> + + + + + +
+
+
+
+

List of Payroll Type

+
+
+
+ +
+
+ +
+
+
+ +endSection() ?> + + + + +section('js') ?> + + + +endSection() ?> + + \ No newline at end of file diff --git a/app/Views/templates/adminlte/generalcontent.php b/app/Views/templates/adminlte/generalcontent.php index fcb7822..7a4b5dc 100644 --- a/app/Views/templates/adminlte/generalcontent.php +++ b/app/Views/templates/adminlte/generalcontent.php @@ -212,7 +212,7 @@ + +