emp init of payroll

emp init of payroll
pull/12/head
paulcortez 7 months ago
parent 2a6d05f9df
commit fc714c78ad

@ -55,6 +55,7 @@ $routes->get('payroll/paytrans', 'PayrollController::payrollTransactions');
$routes->post('payroll/addpaytrans', 'PayrollController::addPayrollTransactions'); $routes->post('payroll/addpaytrans', 'PayrollController::addPayrollTransactions');
$routes->get('payroll/emppaytrans/(:num)', 'PayrollController::employeePayrollTransactions/$1'); $routes->get('payroll/emppaytrans/(:num)', 'PayrollController::employeePayrollTransactions/$1');
$routes->get('payroll/emppaytransinit/(:num)/(:num)/(:num)', 'PayrollController::empPayTransInitializePayroll/$1/$2/$3');
// Administrator Routes // Administrator Routes
$routes->get('adminuser', 'AdministratorController::index'); $routes->get('adminuser', 'AdministratorController::index');

@ -42,11 +42,11 @@ class HRController extends BaseController
if($companyDepartments == null) if($companyDepartments == null)
$data['tblCompanyDept'] = '<p>No departments found.</p>'; $data['tblCompanyDept'] = '<p>No departments found.</p>';
else else
{
foreach($companyDepartments as $department)
{ {
$companyDeptHTMLTable->setHeading('Department ID', 'Department Code', 'Department Name', 'Action'); $companyDeptHTMLTable->setHeading('Department ID', 'Department Code', 'Department Name', 'Action');
foreach($companyDepartments as $department)
{
$iconView = '<a href="#" class="ml-3" data-toggle="tooltip" title="View Department Information"><i class="fas fa-eye "></i></a>'; $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"); $companyDeptHTMLTable->addRow($department->dept_id, $department->department_code, $department->department_name, "$iconView");
@ -87,11 +87,11 @@ class HRController extends BaseController
if($companyBranches == null) if($companyBranches == null)
$data['tblCompanyBranch'] = '<p>No branches found.</p>'; $data['tblCompanyBranch'] = '<p>No branches found.</p>';
else else
{
foreach($companyBranches as $branch)
{ {
$companyBranchHTMLTable->setHeading('Branch Code', 'Branch Name', 'Address', 'Contact Number', 'Email Address', 'Action'); $companyBranchHTMLTable->setHeading('Branch Code', 'Branch Name', 'Address', 'Contact Number', 'Email Address', 'Action');
foreach($companyBranches as $branch)
{
$iconView = '<a href="#" class="ml-3" data-toggle="tooltip" title="View Branch Information"><i class="fas fa-eye "></i></a>'; $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"); $companyBranchHTMLTable->addRow($branch->branch_code, $branch->branch_name, $branch->address, $branch->contact_number, $branch->email_address, "$iconView");
@ -129,11 +129,11 @@ class HRController extends BaseController
if($jobTitles == null) if($jobTitles == null)
$data['tblJobTitle'] = '<p>No job titles found.</p>'; $data['tblJobTitle'] = '<p>No job titles found.</p>';
else else
{
foreach($jobTitles as $jobTitle)
{ {
$jobTitleHTMLTable->setHeading('Job Title ID', 'Job Title Name', 'Action'); $jobTitleHTMLTable->setHeading('Job Title ID', 'Job Title Name', 'Action');
foreach($jobTitles as $jobTitle)
{
$iconView = '<a href="#" class="ml-3" data-toggle="tooltip" title="View Job Title Information"><i class="fas fa-eye "></i></a>'; $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"); $jobTitleHTMLTable->addRow($jobTitle->job_title_id, $jobTitle->job_title_name, "$iconView");
@ -171,11 +171,11 @@ class HRController extends BaseController
if($employmentStatus == null) if($employmentStatus == null)
$data['tblEmploymentStatus'] = '<p>No employment status found.</p>'; $data['tblEmploymentStatus'] = '<p>No employment status found.</p>';
else else
{
foreach($employmentStatus as $empStatus)
{ {
$empStatusHTMLTable->setHeading('Status ID', 'Status Name', 'Action'); $empStatusHTMLTable->setHeading('Status ID', 'Status Name', 'Action');
foreach($employmentStatus as $empStatus)
{
$iconView = '<a href="#" class="ml-3" data-toggle="tooltip" title="View Employment Status Information"><i class="fas fa-eye "></i></a>'; $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"); $empStatusHTMLTable->addRow($empStatus->emp_status_id, $empStatus->status_name, "$iconView");
@ -218,11 +218,11 @@ class HRController extends BaseController
if($employees == null) if($employees == null)
$data['tblEmployee'] = '<p>No employees found.</p>'; $data['tblEmployee'] = '<p>No employees found.</p>';
else else
{
foreach($employees as $employee)
{ {
$employeeHTMLTable->setHeading('Employee ID', 'First Name', 'Last Name', 'Action'); $employeeHTMLTable->setHeading('Employee ID', 'First Name', 'Last Name', 'Action');
foreach($employees as $employee)
{
$empHTMLData = 'data-employee_id="'.$employee->employee_id. $empHTMLData = 'data-employee_id="'.$employee->employee_id.
'" data-company_id="'.$employee->company_id. '" data-company_id="'.$employee->company_id.
'" data-branch_code="'.$employee->branch_code. '" data-branch_code="'.$employee->branch_code.

@ -15,6 +15,8 @@ use App\Models\EmpPayIncomeDeductionModel;
use App\Models\SettingsModel; use App\Models\SettingsModel;
use App\Models\PayrollScheduleModel; use App\Models\PayrollScheduleModel;
use App\Models\PayrollTransactionModel; use App\Models\PayrollTransactionModel;
use App\Models\EmployeePayTransactionModel;
use App\Models\EmpPayTransIncomeDeductionModel;
// Entities // Entities
@ -27,6 +29,8 @@ use App\Entities\EmpPayIncomeDeduction;
use App\Entities\Settings; use App\Entities\Settings;
use App\Entities\PayrollSchedule; use App\Entities\PayrollSchedule;
use App\Entities\PayrollTransaction; use App\Entities\PayrollTransaction;
use App\Entities\EmployeePayTransaction;
use App\Entities\EmpPayTransIncomeDeduction;
// Class Library // Class Library
use App\ClassLib\MiscLib; use App\ClassLib\MiscLib;
@ -49,11 +53,11 @@ class PayrollController extends BaseController
if($payGroups == null) if($payGroups == null)
$data['tblPayGroup'] = '<p>No groups found.</p>'; $data['tblPayGroup'] = '<p>No groups found.</p>';
else else
{
foreach($payGroups as $group)
{ {
$payGroupHTMLTable->setHeading('ID', 'Group Name', 'Action'); $payGroupHTMLTable->setHeading('ID', 'Group Name', 'Action');
foreach($payGroups as $group)
{
$iconView = '<a href="#" class="ml-3" data-toggle="tooltip" title="View Group Information"><i class="fas fa-eye "></i></a>'; $iconView = '<a href="#" class="ml-3" data-toggle="tooltip" title="View Group Information"><i class="fas fa-eye "></i></a>';
$payGroupHTMLTable->addRow($group->pay_group_id, $group->pay_group_code, $group->pay_group_name, "$iconView"); $payGroupHTMLTable->addRow($group->pay_group_id, $group->pay_group_code, $group->pay_group_name, "$iconView");
@ -91,11 +95,11 @@ class PayrollController extends BaseController
if($incomeDeductions == null) if($incomeDeductions == null)
$data['tblIncomeDeduction'] = '<p>No income and deduction found.</p>'; $data['tblIncomeDeduction'] = '<p>No income and deduction found.</p>';
else else
{
foreach($incomeDeductions as $incomeDeduction)
{ {
$inDedHTMLTable->setHeading('ID', 'Payslip Display', 'COA Code', 'Deduction Name', 'Income', 'Taxable', 'Include in Gross', 'Action'); $inDedHTMLTable->setHeading('ID', 'Payslip Display', 'COA Code', 'Deduction Name', 'Income', 'Taxable', 'Include in Gross', 'Action');
foreach($incomeDeductions as $incomeDeduction)
{
$iconView = '<a href="#" class="ml-3" data-toggle="tooltip" title="View Information"><i class="fas fa-eye "></i></a>'; $iconView = '<a href="#" class="ml-3" data-toggle="tooltip" title="View Information"><i class="fas fa-eye "></i></a>';
$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); $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);
@ -138,11 +142,11 @@ class PayrollController extends BaseController
if($payrollTypes == null) if($payrollTypes == null)
$data['tblPayrollType'] = '<p>No payroll type found.</p>'; $data['tblPayrollType'] = '<p>No payroll type found.</p>';
else else
{
foreach($payrollTypes as $payrollType)
{ {
$payTypeHTMLTable->setHeading('ID', 'Code', 'Name', 'Monthly', 'Semi-Monthly', 'Daily', 'Hourly', 'Action'); $payTypeHTMLTable->setHeading('ID', 'Code', 'Name', 'Monthly', 'Semi-Monthly', 'Daily', 'Hourly', 'Action');
foreach($payrollTypes as $payrollType)
{
$iconView = '<a href="#" class="ml-3" data-toggle="tooltip" title="View Information"><i class="fas fa-eye "></i></a>'; $iconView = '<a href="#" class="ml-3" data-toggle="tooltip" title="View Information"><i class="fas fa-eye "></i></a>';
$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); $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);
@ -197,7 +201,7 @@ class PayrollController extends BaseController
public function employeePayrollInfo() public function employeePayrollInfo()
{ {
$empPayInfoModel = new EmployeePayrollInfoModel(); $empPayInfoModel = new EmployeePayrollInfoModel();
$empPayInfos = $empPayInfoModel->getAllEmpPayInfoJoinedEmpPayType(); $empPayInfos = $empPayInfoModel->getAllEmpPayInfoXEmpPayType();
$data['employees'] = (new EmployeeModel())->findAll(); $data['employees'] = (new EmployeeModel())->findAll();
$data['paytypes'] = (new PayrollTypeModel())->findAll(); $data['paytypes'] = (new PayrollTypeModel())->findAll();
@ -208,11 +212,11 @@ class PayrollController extends BaseController
if($empPayInfos == null) if($empPayInfos == null)
$data['tblEmpPayInfo'] = '<p>No employee payroll type found.</p>'; $data['tblEmpPayInfo'] = '<p>No employee payroll type found.</p>';
else else
{
foreach($empPayInfos as $empPayInfo)
{ {
$empPayInfoHTMLTable->setHeading('ID', 'Payroll Type', 'Employee ID', 'Employee Name', 'Monthly', 'Semi-Monthly', 'Daily', 'Hourly', 'Action'); $empPayInfoHTMLTable->setHeading('ID', 'Payroll Type', 'Employee ID', 'Employee Name', 'Monthly', 'Semi-Monthly', 'Daily', 'Hourly', 'Action');
foreach($empPayInfos as $empPayInfo)
{
$iconView = '<a href="#" class="ml-3" data-toggle="tooltip" title="View Information"><i class="fas fa-eye "></i></a>'; $iconView = '<a href="#" class="ml-3" data-toggle="tooltip" title="View Information"><i class="fas fa-eye "></i></a>';
$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); $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);
@ -256,7 +260,7 @@ class PayrollController extends BaseController
$data['paySchedules'] = (new PayrollScheduleModel())->findAll(); $data['paySchedules'] = (new PayrollScheduleModel())->findAll();
$data['incomeList'] = $incomeDeductionModel->where("is_income", 1)->findAll(); $data['incomeList'] = $incomeDeductionModel->where("is_income", 1)->findAll();
$data['deductionList'] = $incomeDeductionModel->where("is_income", 0)->findAll(); $data['deductionList'] = $incomeDeductionModel->where("is_income", 0)->findAll();
$data['empPayInfos'] = $empPayInfoModel->getAllEmpPayInfoJoinedEmpPayType(); $data['empPayInfos'] = $empPayInfoModel->getAllEmpPayInfoXEmpPayType();
$data['empLoaded'] = false; $data['empLoaded'] = false;
if($this->request->getGet('empid') != null) if($this->request->getGet('empid') != null)
@ -268,9 +272,9 @@ class PayrollController extends BaseController
$iconDelete = '<a href="#" class="ml-3" data-toggle="tooltip" title="Delete Employee Information"><i class="fas fa-trash "></i></a>'; $iconDelete = '<a href="#" class="ml-3" data-toggle="tooltip" title="Delete Employee Information"><i class="fas fa-trash "></i></a>';
$data['empLoaded'] = true; $data['empLoaded'] = true;
$data['selectedEmployee'] = $empPayInfoModel->getEmpPayInfoJoinedEmpPayTypeByEmpID($this->request->getGet('empid')); $data['selectedEmployee'] = $empPayInfoModel->getEmpPayInfoXEmpPayTypeByEmpID($this->request->getGet('empid'));
$data['empPayIncomeList'] = $empPayInDedModel->getEmpPayInDedByEmpPayIdSchedId($data['selectedEmployee']->emppay_id, $this->request->getGet('payschedid'), true); $data['empPayIncomeList'] = $empPayInDedModel->getEmpPayInDedByEmpPayIdSchedIdIsIncome($data['selectedEmployee']->emppay_id, $this->request->getGet('payschedid'), true);
$data['empPayDeductionList'] = $empPayInDedModel->getEmpPayInDedByEmpPayIdSchedId($data['selectedEmployee']->emppay_id, $this->request->getGet('payschedid'),false); $data['empPayDeductionList'] = $empPayInDedModel->getEmpPayInDedByEmpPayIdSchedIdIsIncome($data['selectedEmployee']->emppay_id, $this->request->getGet('payschedid'),false);
} }
return view('payroll/compensationbenefitsview', $data); return view('payroll/compensationbenefitsview', $data);
@ -360,11 +364,11 @@ class PayrollController extends BaseController
if($payTrans == null) if($payTrans == null)
$data['tblPayTrans'] = '<p>No transactions found.</p>'; $data['tblPayTrans'] = '<p>No transactions found.</p>';
else else
{
foreach($payTrans as $trans)
{ {
$payTransHTMLTable->setHeading('ID', 'From', 'To', 'No. of Days', 'Status', 'Remarks', 'Action'); $payTransHTMLTable->setHeading('ID', 'From', 'To', 'No. of Days', 'Status', 'Remarks', 'Action');
foreach($payTrans as $trans)
{
$iconEdit = '<a href="/payroll/emppaytrans/'.$trans->paytrans_id.'" class="ml-3" data-toggle="tooltip" title="Edit Payroll Transaction"><i class="fas fa-edit"></i></a>'; $iconEdit = '<a href="/payroll/emppaytrans/'.$trans->paytrans_id.'" class="ml-3" data-toggle="tooltip" title="Edit Payroll Transaction"><i class="fas fa-edit"></i></a>';
$payTransHTMLTable->addRow($trans->paytrans_id, $trans->payroll_from, $trans->payroll_to, $trans->no_of_days, $trans->is_open ? 'Open' : ' Closed', $trans->remarks, $iconEdit); $payTransHTMLTable->addRow($trans->paytrans_id, $trans->payroll_from, $trans->payroll_to, $trans->no_of_days, $trans->is_open ? 'Open' : ' Closed', $trans->remarks, $iconEdit);
@ -393,11 +397,127 @@ class PayrollController extends BaseController
public function employeePayrollTransactions($paytransid) public function employeePayrollTransactions($paytransid)
{ {
$data['paytransid'] = $paytransid;
$data['paygroupid'] = $this->request->getGet('grpid'); $data['paygroupid'] = $this->request->getGet('grpid');
$data['showInitBtn'] = false;
$payTrans = (new PayrollTransactionModel())->where('paytrans_id', $paytransid)->first();
$data['paytransid'] = $paytransid;
$data['initURL'] = $paytransid.'/'.$data['paygroupid'].'/'.$payTrans->paytype_id;
$data['paygroups'] = (new PayrollGroupModel())->findAll(); $data['paygroups'] = (new PayrollGroupModel())->findAll();
$empPayTrans = (new EmployeePayTransactionModel())->getEmpPayTransByPayGroupId($data['paygroupid']);
$empPayTransHTMLTable = new \CodeIgniter\View\Table();
$empPayTransHTMLTable->setTemplate(MiscLib::adminLTETableTemplate());
if($empPayTrans == null)
{
$empPayTrans = (new EmployeePayrollInfoModel())->getEmpPayInfoXEmpPayTypeByPayGrpId($data['paygroupid'], $payTrans->paytype_id);
$data['showInitBtn'] = true;
$empPayTransHTMLTable->setHeading('ID', 'Company ID', 'Name', 'Branch', 'Daily Basic');
foreach($empPayTrans as $trans)
{
$empPayTransHTMLTable->addRow($trans->employee_id, $trans->company_issued_id, $trans->last_name . ', ' . $trans->first_name, $trans->branch_code, $trans->basic_monthly_pay);
}
$data['tblEmpPayTrans'] = $empPayTransHTMLTable->generate();
}
else
{
$empPayTransHTMLTable->setHeading('ID', 'Name', 'Branch', 'Monthly Basic', 'Action');
foreach($empPayTrans as $trans)
{
$iconView = '<a href="#" class="ml-3" data-toggle="tooltip" title="View Information"><i class="fas fa-eye "></i></a>';
$empPayTransHTMLTable->addRow($trans->employee_id, $trans->last_name . ', ' . $trans->first_name, $trans->branch_code, $trans->basic_monthly_pay, $iconView);
}
$data['tblEmpPayTrans'] = $empPayTransHTMLTable->generate();
}
return view('payroll/emppaytransactionview', $data); return view('payroll/emppaytransactionview', $data);
} }
public function empPayTransInitializePayroll($paytransid, $paygroupid, $transtypid)
{
$empPayInfos = (new EmployeePayrollInfoModel())->getEmpPayInfoXEmpPayTypeByPayGrpId($paygroupid, $transtypid);
$payTrans = (new PayrollTransactionModel())->where('paytrans_id', $paytransid)->first();
foreach($empPayInfos as $empPayInfo)
{
$empPayTransaction = new EmployeePayTransaction();
$empPayTransactionModel = new EmployeePayTransactionModel();
$empPayTransaction->fill(
['paytrans_id' => $paytransid,
'company_id' => $empPayInfo->company_id,
'branch_code' => $empPayInfo->branch_code,
'dept_id' => $empPayInfo->dept_id,
'job_title_id' => $empPayInfo->job_title_id,
'pay_group_id' => $empPayInfo->pay_group_id,
'emp_status_id' => $empPayInfo->emp_status_id,
'employee_id' => $empPayInfo->employee_id,
'company_issued_id' => $empPayInfo->company_issued_id,
'last_name' => $empPayInfo->last_name,
'first_name' => $empPayInfo->first_name,
'middle_name' => $empPayInfo->middle_name,
'suffix' => $empPayInfo->suffix,
'email_address' => $empPayInfo->email_address,
'is_ATM' => $empPayInfo->is_ATM,
'savings_account' => $empPayInfo->savings_account,
'basic_monthly_pay' => $empPayInfo->basic_monthly_pay,
'basic_daily_pay' => $empPayInfo->basic_daily_pay,
'basic_hourly_pay' => $empPayInfo->basic_hourly_pay,
'has_cola' => $empPayInfo->has_cola,
'has_philhealth' => $empPayInfo->has_philhealth,
'has_hdmf' => $empPayInfo->has_hdmf,
'has_sss' => $empPayInfo->has_sss,
'has_gsis' => $empPayInfo->has_gsis,
'actual_work_days' => $payTrans->no_of_days,
'basic_pay' => $payTrans->no_of_days * $empPayInfo->basic_daily_pay,
'gross_income' => 0,
'taxable_income' => 0,
'nontaxable_income' => 0,
'income_tax' => 0,
'total_deduction' => 0,
'net_pay' => 0]
);
$empPayTransactionModel->save($empPayTransaction);
$empPayTransId = $empPayTransactionModel->getInsertID();
$empPayInDeds = (new EmpPayIncomeDeductionModel())->getEmpPayInDedByEmpPayIdSchedId($empPayInfo->emppay_id, $payTrans->payschedule_id);
foreach($empPayInDeds as $empPayInDed)
{
$empPayTransInDed = new EmpPayTransIncomeDeduction();
$empPayTransInDedModel = new EmpPayTransIncomeDeductionModel();
$empPayTransInDed->fill(
['emppaytrans_id' => $empPayTransId,
'inded_id' => $empPayInDed->inded_id,
'payslip_display' => $empPayInDed->payslip_display,
'inded_name' => $empPayInDed->inded_name,
'coa_code' => $empPayInDed->coa_code,
'is_income' => $empPayInDed->is_income,
'is_taxable' => $empPayInDed->is_taxable,
'include_in_gross' => $empPayInDed->include_in_gross,
'is_fixed_amt' => $empPayInDed->is_fixed_amt,
'is_percent_amt' => $empPayInDed->is_percent_amt,
'amount' => $empPayInDed->is_fixed_amt ? $empPayInDed->amount : ($empPayInDed->amount / 100) * ($payTrans->no_of_days * $empPayInfo->basic_daily_pay),
'base_amount' => $empPayInDed->amount,
'is_override' => $empPayInDed->is_override]
);
$empPayTransInDedModel->save($empPayTransInDed);
}
}
return redirect()->back()->withInput()->with('message', 'Payroll processed. Please verify the entries.');
}
} }

@ -25,6 +25,12 @@ class CreateEmpPayTrans extends Migration
'constraint' => 11, 'constraint' => 11,
'unsigned' => true, 'unsigned' => true,
], ],
'branch_code' => [
'type' => 'VARCHAR',
'constraint' => 25,
'null' => false,
'after' => 'company_id',
],
'dept_id' => [ 'dept_id' => [
'type' => 'INT', 'type' => 'INT',
'constraint' => 11, 'constraint' => 11,
@ -35,6 +41,12 @@ class CreateEmpPayTrans extends Migration
'constraint' => 11, 'constraint' => 11,
'unsigned' => true, 'unsigned' => true,
], ],
'pay_group_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'null' => false,
],
'emp_status_id' => [ 'emp_status_id' => [
'type' => 'INT', 'type' => 'INT',
'constraint' => 11, 'constraint' => 11,
@ -123,6 +135,16 @@ class CreateEmpPayTrans extends Migration
'constraint' => 1, 'constraint' => 1,
'null' => false 'null' => false
], ],
'actual_work_days' => [
'type' => 'DECIMAL',
'constraint' => '12,4',
'null' => false
],
'basic_pay' => [
'type' => 'DECIMAL',
'constraint' => '12,4',
'null' => false
],
'gross_income' => [ 'gross_income' => [
'type' => 'DECIMAL', 'type' => 'DECIMAL',
'constraint' => '12,4', 'constraint' => '12,4',
@ -181,13 +203,19 @@ class CreateEmpPayTrans extends Migration
]); ]);
$this->forge->addKey('emppaytrans_id', true); $this->forge->addKey('emppaytrans_id', true);
$this->forge->addForeignKey('paytype_id', 'pay_type', 'paytype_id', 'CASCADE', 'RESTRICT'); $this->forge->addForeignKey('paytrans_id', 'pay_trans', 'paytrans_id', 'CASCADE', 'RESTRICT');
$this->forge->addForeignKey('payschedule_id', 'pay_schedule', 'payschedule_id', 'CASCADE', 'RESTRICT'); $this->forge->addForeignKey('company_id', 'company_info', 'company_id', 'CASCADE', 'RESTRICT');
$this->forge->createTable('pay_trans'); $this->forge->addForeignKey('branch_code', 'company_branch', 'branch_code', 'CASCADE', 'RESTRICT');
$this->forge->addForeignKey('dept_id', 'company_dept', 'dept_id', 'CASCADE', 'RESTRICT');
$this->forge->addForeignKey('job_title_id', 'job_title', 'job_title_id', 'CASCADE', 'RESTRICT');
$this->forge->addForeignKey('pay_group_id', 'pay_group', 'pay_group_id', 'CASCADE', 'RESTRICT');
$this->forge->addForeignKey('emp_status_id', 'emp_status', 'emp_status_id', 'CASCADE', 'RESTRICT');
$this->forge->addForeignKey('employee_id', 'employee', 'employee_id', 'CASCADE', 'RESTRICT');
$this->forge->createTable('emp_pay_trans');
} }
public function down() public function down()
{ {
// $this->forge->dropTable('emp_pay_trans');
} }
} }

@ -0,0 +1,120 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateEmpPayIncomeDeduction extends Migration
{
public function up()
{
$this->forge->addField([
'emppaytransinded_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true
],
'emppaytrans_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
],
'inded_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
],
'payslip_display' => [
'type' => 'VARCHAR',
'constraint' => 25,
'null' => false
],
'inded_name' => [
'type' => 'VARCHAR',
'constraint' => 255,
'null' => false
],
'coa_code' => [
'type' => 'VARCHAR',
'constraint' => 25,
'null' => true,
],
'is_income' => [
'type' => 'TINYINT',
'constraint' => 1,
'null' => false
],
'is_taxable' => [
'type' => 'TINYINT',
'constraint' => 1,
'null' => false
],
'include_in_gross' => [
'type' => 'TINYINT',
'constraint' => 1,
'null' => false
],
'is_fixed_amt' => [
'type' => 'TINYINT',
'constraint' => 1,
'null' => false
],
'is_percent_amt' => [
'type' => 'TINYINT',
'constraint' => 1,
'null' => false
],
'amount' => [
'type' => 'DECIMAL',
'constraint' => '12,4',
'null' => false
],
'base_amount' => [
'type' => 'DECIMAL',
'constraint' => '12,4',
'null' => false
],
'is_override' => [
'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('emppaytransinded_id', true);
$this->forge->addForeignKey('emppaytrans_id', 'emp_pay_trans', 'emppaytrans_id', 'CASCADE', 'RESTRICT');
$this->forge->createTable('emp_pay_trans_inded');
}
public function down()
{
$this->forge->dropTable('emp_pay_trans_inded');
}
}

@ -0,0 +1,28 @@
<?php
namespace App\Entities;
use CodeIgniter\Entity\Entity;
class EmpPayTransIncomeDeduction extends Entity
{
protected $attributes = [
'emppaytransinded_id' => null,
'emppaytrans_id' => null,
'inded_id' => null,
'payslip_display' => null,
'inded_name' => null,
'coa_code' => null,
'is_income' => null,
'is_taxable' => null,
'include_in_gross' => null,
'is_fixed_amt' => null,
'is_percent_amt' => null,
'amount' => null,
'base_amount' => null,
'is_override' => null,
];
protected $datamap = [];
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
protected $casts = [];
}

@ -13,6 +13,7 @@ class Employee extends Entity
'dept_id' => null, 'dept_id' => null,
'job_title_id' => null, 'job_title_id' => null,
'emp_status_id' => null, 'emp_status_id' => null,
'pay_group_id' => null,
'company_issued_id' => null, 'company_issued_id' => null,
'last_name' => null, 'last_name' => null,
'first_name' => null, 'first_name' => null,

@ -0,0 +1,47 @@
<?php
namespace App\Entities;
use CodeIgniter\Entity\Entity;
class EmployeePayTransaction extends Entity
{
protected $attributes = [
'emppaytrans_id' => null,
'paytrans_id' => null,
'company_id' => null,
'branch_code' => null,
'dept_id' => null,
'job_title_id' => null,
'pay_group_id' => null,
'emp_status_id' => null,
'employee_id' => null,
'company_issued_id' => null,
'last_name' => null,
'first_name' => null,
'middle_name' => null,
'suffix' => null,
'email_address' => null,
'is_ATM' => null,
'savings_account' => null,
'basic_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,
'actual_work_days' => null,
'basic_pay' => null,
'gross_income' => null,
'taxable_income' => null,
'nontaxable_income' => null,
'income_tax' => null,
'total_deduction' => null,
'net_pay' => null,
];
protected $datamap = [];
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
protected $casts = [];
}

@ -59,7 +59,7 @@ class EmpPayIncomeDeductionModel extends Model
return $data; return $data;
} }
public function getEmpPayInDedByEmpPayIdSchedId($empPayId, $paySchedId, $isIncome) public function getEmpPayInDedByEmpPayIdSchedIdIsIncome($empPayId, $paySchedId, $isIncome)
{ {
$builder = $this->db->table('emp_pay_inded'); $builder = $this->db->table('emp_pay_inded');
$builder->select('*'); $builder->select('*');
@ -71,4 +71,16 @@ class EmpPayIncomeDeductionModel extends Model
]); ]);
return $builder->get()->getResult(); return $builder->get()->getResult();
} }
public function getEmpPayInDedByEmpPayIdSchedId($empPayId, $paySchedId)
{
$builder = $this->db->table('emp_pay_inded');
$builder->select('*');
$builder->join('pay_income_deduction', 'pay_income_deduction.inded_id = emp_pay_inded.inded_id');
$builder->where([
'emp_pay_inded.emppay_id' => $empPayId,
'emp_pay_inded.payschedule_id' => $paySchedId
]);
return $builder->get()->getResult();
}
} }

@ -0,0 +1,60 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class EmpPayTransIncomeDeductionModel extends Model
{
protected $table = 'emp_pay_trans_inded';
protected $primaryKey = 'emppaytransinded_id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = ['emppaytrans_id',
'inded_id',
'is_fixed_amt',
'is_percent_amt',
'amount',
'base_amount',
'is_override'];
protected bool $allowEmptyInserts = false;
// Dates
protected $useTimestamps = true;
protected $dateFormat = 'datetime';
protected $createdField = 'created_at';
protected $updatedField = 'updated_at';
protected $deletedField = 'deleted_at';
// Validation
protected $validationRules = [];
protected $validationMessages = [];
protected $skipValidation = false;
protected $cleanValidationRules = true;
// Callbacks
protected $allowCallbacks = true;
protected $beforeInsert = ['assignCreatedBy'];
protected $afterInsert = [];
protected $beforeUpdate = ['assignUpdatedBy'];
protected $afterUpdate = [];
protected $beforeFind = [];
protected $afterFind = [];
protected $beforeDelete = [];
protected $afterDelete = [];
public function assignCreatedBy(array $data)
{
$data['data']['created_by'] = auth()->user()->employee_id;
return $data;
}
public function assignUpdatedBy(array $data)
{
$data['data']['updated_by'] = auth()->user()->employee_id;
return $data;
}
}

@ -0,0 +1,100 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class EmployeePayTransactionModel extends Model
{
protected $table = 'emp_pay_trans';
protected $primaryKey = 'emppaytrans_id';
protected $useAutoIncrement = true;
protected $returnType = \App\Entities\EmployeePayTransaction::class;
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = ['paytrans_id',
'company_id',
'branch_code',
'dept_id',
'job_title_id',
'pay_group_id',
'emp_status_id',
'employee_id',
'company_issued_id',
'last_name',
'first_name',
'middle_name',
'suffix',
'email_address',
'is_ATM',
'savings_account',
'basic_monthly_pay',
'basic_daily_pay',
'basic_hourly_pay',
'has_cola',
'has_philhealth',
'has_hdmf',
'has_sss',
'has_gsis',
'actual_work_days',
'basic_pay',
'gross_income',
'taxable_income',
'nontaxable_income',
'income_tax',
'total_deduction',
'net_pay'];
protected bool $allowEmptyInserts = false;
// Dates
protected $useTimestamps = true;
protected $dateFormat = 'datetime';
protected $createdField = 'created_at';
protected $updatedField = 'updated_at';
protected $deletedField = 'deleted_at';
// Validation
protected $validationRules = [];
protected $validationMessages = [];
protected $skipValidation = false;
protected $cleanValidationRules = true;
// Callbacks
protected $allowCallbacks = true;
protected $beforeInsert = ['assignCreatedBy'];
protected $afterInsert = [];
protected $beforeUpdate = ['assignUpdatedBy'];
protected $afterUpdate = [];
protected $beforeFind = [];
protected $afterFind = [];
protected $beforeDelete = [];
protected $afterDelete = [];
public function assignCreatedBy(array $data)
{
$data['data']['created_by'] = auth()->user()->employee_id;
return $data;
}
public function assignUpdatedBy(array $data)
{
$data['data']['updated_by'] = auth()->user()->employee_id;
return $data;
}
public function getEmpPayTransByPayGroupId($paygroupid)
{
$builder = $this->db->table('emp_pay_trans');
$builder->select('*');
$builder->join('pay_trans', 'pay_trans.paytrans_id = emp_pay_trans.paytrans_id');
$builder->join('company_branch', 'company_branch.branch_code = emp_pay_trans.branch_code');
$builder->join('company_dept', 'company_dept.dept_id = emp_pay_trans.dept_id');
$builder->join('job_title', 'job_title.job_title_id = emp_pay_trans.job_title_id');
$builder->join('pay_group', 'pay_group.pay_group_id = emp_pay_trans.pay_group_id');
$builder->join('emp_status', 'emp_status.emp_status_id = emp_pay_trans.emp_status_id');
$builder->join('employee', 'employee.employee_id = emp_pay_trans.employee_id');
$builder->where('emp_pay_trans.pay_group_id', $paygroupid);
return $builder->get()->getResult();
}
}

@ -66,7 +66,7 @@ class EmployeePayrollInfoModel extends Model
return $data; return $data;
} }
public function getAllEmpPayInfoJoinedEmpPayType() public function getAllEmpPayInfoXEmpPayType()
{ {
$builder = $this->db->table('emp_pay_info'); $builder = $this->db->table('emp_pay_info');
$builder->select('*'); $builder->select('*');
@ -75,7 +75,7 @@ class EmployeePayrollInfoModel extends Model
return $builder->get()->getResult(); return $builder->get()->getResult();
} }
public function getEmpPayInfoJoinedEmpPayTypeByEmpID($empID) public function getEmpPayInfoXEmpPayTypeByEmpID($empID)
{ {
$builder = $this->db->table('emp_pay_info'); $builder = $this->db->table('emp_pay_info');
$builder->select('*'); $builder->select('*');
@ -84,4 +84,15 @@ class EmployeePayrollInfoModel extends Model
$builder->where('emp_pay_info.employee_id', $empID); $builder->where('emp_pay_info.employee_id', $empID);
return $builder->get()->getRow(); return $builder->get()->getRow();
} }
public function getEmpPayInfoXEmpPayTypeByPayGrpId($payGroupId, $payTypeId)
{
$builder = $this->db->table('emp_pay_info');
$builder->select('*');
$builder->join('employee', 'employee.employee_id = emp_pay_info.employee_id');
$builder->join('pay_type', 'pay_type.paytype_id = emp_pay_info.paytype_id');
$builder->where(['employee.pay_group_id' => $payGroupId,
'emp_pay_info.paytype_id' => $payTypeId]);
return $builder->get()->getResult();
}
} }

@ -126,15 +126,32 @@
<div class="col-12"> <div class="col-12">
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
<h3 class="card-title">List of Payroll Transaction</h3> <h3 class="card-title">List of Employee for Payroll</h3>
</div> </div>
<div class="card-body"> <div class="card-body">
<?php if($paygroupid == null || $paygroupid == -1): ?>
<p>Please select payroll group.</p>
<?php else: ?>
<div class="card-body table-responsive p-0"> <div class="card-body table-responsive p-0">
<?= $paytransid ?> <?php if($showInitBtn): ?>
<p>You may change the working days for this payroll cutoff. Deduct days off or absences on <strong>working days</strong> field.</p>
<?php else: ?>
<p>Adjust entry of each employee by clicking on <strong>Adjust</strong> button</p>
<?php endif; ?>
<?= $tblEmpPayTrans ?>
</div> </div>
<?php endif; ?>
</div> </div>
<div class="card-footer"> <div class="card-footer">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#mdlAddPayTrans">Add Payroll Transaction</button> <?php if($showInitBtn && !($paygroupid == null || $paygroupid == -1)): ?>
<a class="btn btn-warning" href="/payroll/emppaytransinit/<?= $initURL ?>">Initialize Payroll</a>
<?php elseif($paygroupid == null || $paygroupid == -1): ?>
<button type="button" class="btn btn-warning" disabled>Initialize Payroll</button>
<?php else: ?>
<button type="button" class="btn btn-primary">Generate Payslip</button>
<?php endif; ?>
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save