to(base_url('/login')); } public function payrollGroup() { $payGroups = (new PayrollGroupModel())->findAll(); $payGroupHTMLTable = new \CodeIgniter\View\Table(); $payGroupHTMLTable->setTemplate(MiscLib::adminLTETableTemplate()); if($payGroups == null) $data['tblPayGroup'] = '

No groups found.

'; else { foreach($payGroups as $group) { $payGroupHTMLTable->setHeading('ID', 'Group Name', 'Action'); $iconView = ''; $payGroupHTMLTable->addRow($group->pay_group_id, $group->pay_group_code, $group->pay_group_name, "$iconView"); } $data['tblPayGroup'] = $payGroupHTMLTable->generate(); } return view('payroll/paygroupview', $data); } public function addPayrollGroup() { $payrollGroup = new PayrollGroup(); $payrollGroupModel = new PayrollGroupModel(); $rawData = $this->request->getPost(); $payrollGroup->fill($rawData); $payrollGroupModel->save($payrollGroup); if($payrollGroupModel->getInsertID() == 0) return redirect()->back()->withInput()->with('error', 'Failed to add payroll group'); else return redirect()->to('/payroll/paygroup')->with('message', 'Payroll Group Added'); } public function incomeDeduction() { $incomeDeductions = (new IncomeDeductionModel())->findAll(); $inDedHTMLTable = new \CodeIgniter\View\Table(); $inDedHTMLTable->setTemplate(MiscLib::adminLTETableTemplate()); if($incomeDeductions == null) $data['tblIncomeDeduction'] = '

No income and deduction found.

'; else { foreach($incomeDeductions as $incomeDeduction) { $inDedHTMLTable->setHeading('ID', 'Payslip Display', 'COA Code', 'Deduction Name', 'Income', 'Taxable', 'Include in Gross', 'Action'); $iconView = ''; $inDedHTMLTable->addRow($incomeDeduction->inded_id, $incomeDeduction->payslip_display, $incomeDeduction->coa_code, $incomeDeduction->income_deduction_name, ($incomeDeduction->is_income) ? 'Yes' : 'No', ($incomeDeduction->is_taxable) ? 'Yes' : 'No', ($incomeDeduction->include_in_gross) ? 'Yes' : 'No', $iconView); } $data['tblIncomeDeduction'] = $inDedHTMLTable->generate(); } return view('payroll/incomedeductionview', $data); } public function addIncomeDeduction() { $incomeDeduction = new IncomeDeduction(); $incomeDeductionModel = new IncomeDeductionModel(); $rawData = $this->request->getPost(); // Handle checkbox inputs $rawData['is_income'] = isset($rawData['is_income']) ? 1 : 0; // Set to 1 if checked, 0 if not $rawData['is_taxable'] = isset($rawData['is_taxable']) ? 1 : 0; // Same for taxable $rawData['include_in_gross'] = isset($rawData['include_in_gross']) ? 1 : 0; // Same for include in gross $incomeDeduction->fill($rawData); $incomeDeductionModel->save($incomeDeduction); if($incomeDeductionModel->getInsertID() == 0) return redirect()->back()->withInput()->with('error', 'Failed to add income or deduction'); 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() { $empPayInfoModel = new EmployeePayrollInfoModel(); $empPayInfos = $empPayInfoModel->getAllEmpPayInfoJoinedEmpPayType(); $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_name, $empPayInfo->company_issued_id, $empPayInfo->last_name . ', ' . $empPayInfo->first_name, $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'); } public function employeeCompensationBenefits() { $empPayInfoModel = new EmployeePayrollInfoModel(); $incomeDeductionModel = new IncomeDeductionModel(); $empPayInDedModel = new EmpPayIncomeDeductionModel(); $data['paySchedules'] = (new PayrollScheduleModel())->findAll(); $data['incomeList'] = $incomeDeductionModel->where("is_income", 1)->findAll(); $data['deductionList'] = $incomeDeductionModel->where("is_income", 0)->findAll(); $data['empPayInfos'] = $empPayInfoModel->getAllEmpPayInfoJoinedEmpPayType(); $data['empLoaded'] = false; if($this->request->getGet('empid') != null) { $data['empLoaded'] = true; $data['selectedEmployee'] = $empPayInfoModel->getEmpPayInfoJoinedEmpPayTypeByEmpID($this->request->getGet('empid')); $data['empPayIncomeList'] = $empPayInDedModel->getEmpPayInDedByEmpPayId($data['selectedEmployee']->emppay_id, $this->request->getGet('payschedid'), true); $data['empPayDeductionList'] = $empPayInDedModel->getEmpPayInDedByEmpPayId($data['selectedEmployee']->emppay_id, $this->request->getGet('payschedid'),false); } return view('payroll/compensationbenefitsview', $data); } public function addEmployeeCompensationBenefits() { $empPayInDed = new EmpPayIncomeDeduction(); $empPayInDedModel = new EmpPayIncomeDeductionModel(); $rawData = $this->request->getPost(); // Initialize all payroll type fields to 0 $rawData['is_fixed_amt'] = 0; $rawData['is_percent_amt'] = 0; // Handle radio button input if (isset($rawData['amount_type'])) { switch ($rawData['amount_type']) { case 'fixed': $rawData['is_fixed_amt'] = 1; break; case 'perc': $rawData['is_percent_amt'] = 1; break; } } $rawData['is_override'] = isset($rawData['is_override']) ? 1 : 0; $empPayInDed->fill($rawData); $empPayInDedModel->save($empPayInDed); if($empPayInDedModel->getInsertID() == 0) return redirect()->back()->withInput()->with('error', 'Failed to add employee compensation benefits'); else return redirect()->to('/payroll/compben?payschedid='.$this->request->getPost('payschedule_id').'&empid='.$this->request->getPost('emp_id'))->with('message', 'Employee Compensation Benefits Added'); } public function payrollSettings() { $incomeDeductionModel = new IncomeDeductionModel(); $settingsModel = new SettingsModel(); $settings = new Settings(); if($this->request->is('post')) { $settings->fill($this->request->getPost()); $settingsModel->save($settings); } $data['indedList'] = $incomeDeductionModel->findAll(); $data['basicSalVal'] = $settingsModel->where('key', 'BasicSalary')->first(); $data['COLAVal'] = $settingsModel->where('key', 'COLA')->first(); $data['PhilhealthVal'] = $settingsModel->where('key', 'Philhealth')->first(); $data['HDMFVal'] = $settingsModel->where('key', 'HDMF')->first(); $data['SSSVal'] = $settingsModel->where('key', 'SSS')->first(); $data['GSISVal'] = $settingsModel->where('key', 'GSIS')->first(); return view('payroll/paysettingsview', $data); } }