Merge pull request 'added edit of income and deduction' (#31) from paulcortezl5 into main

Reviewed-on: #31
pull/32/head
paul 5 months ago
commit fd1a9b1d36

@ -40,7 +40,9 @@ $routes->get('payroll/paygroup', 'PayrollController::payrollGroup');
$routes->post('payroll/addpaygroup', 'PayrollController::addPayrollGroup');
$routes->get('payroll/inded', 'PayrollController::incomeDeduction');
$routes->post('payroll/addinded', 'PayrollController::addIncomeDeduction');
$routes->get('payroll/indedtransupdate/(:num)', 'PayrollController::incomeDeductionTransUpdate/$1');
$routes->get('payroll/indedtransapplyupdate/(:num)/(:num)', 'PayrollController::incomeDeductionTransApplyUpdate/$1/$2');
$routes->post('payroll/saveinded', 'PayrollController::saveIncomeDeduction');
$routes->get('payroll/paytype', 'PayrollController::payrollType');
$routes->post('payroll/addpaytype', 'PayrollController::addPayrollType');

@ -49,16 +49,16 @@ class PayrollController extends BaseController
private function computeEmployeePayroll($emppaytransid, $save = false, $instanceOfEmpPayTransModel = null, $instanceOfEmpPayTransInDedModel = null)
{
if($instanceOfEmpPayTransModel == null)
if ($instanceOfEmpPayTransModel == null)
$empPayTransModel = new EmployeePayTransactionModel();
else
$empPayTransModel = $instanceOfEmpPayTransModel;
if($instanceOfEmpPayTransInDedModel == null)
if ($instanceOfEmpPayTransInDedModel == null)
$empPayTransInDedModel = new EmpPayTransIncomeDeductionModel();
else
$empPayTransInDedModel = $instanceOfEmpPayTransInDedModel;
$empPayTrans = $empPayTransModel->find($emppaytransid);
// Compute basic pay first
@ -74,7 +74,7 @@ class PayrollController extends BaseController
$empPayTrans->basic_pay = $empPayTrans->basic_monthly_pay;
break;
}
$empPayTrans->taxable_income = $empPayTransInDedModel->getTotalIncomeDeduction($emppaytransid, 1, 1) + $empPayTrans->basic_pay;
$empPayTrans->nontaxable_income = $empPayTransInDedModel->getTotalIncomeDeduction($emppaytransid, 1, 0);
$empPayTrans->taxable_deduction = $empPayTransInDedModel->getTotalIncomeDeduction($emppaytransid, 0, 1);
@ -82,7 +82,7 @@ class PayrollController extends BaseController
// Compute gross first before getting taxable income to avoid misscalculation of net income
$empPayTrans->gross_income = $empPayTrans->taxable_income + $empPayTrans->nontaxable_income;
// Deduct SSS, Philhealth, Pagibig and Union Dues
$empPayTrans->taxable_income -= $empPayTrans->nontaxable_deduction;
@ -94,12 +94,13 @@ class PayrollController extends BaseController
$empPayTrans->total_deduction = $empPayTrans->taxable_deduction + $empPayTrans->nontaxable_deduction + $empPayTrans->income_tax;
$empPayTrans->net_pay = $empPayTrans->gross_income - $empPayTrans->total_deduction;
if($save) $empPayTransModel->save($empPayTrans);
if ($save)
$empPayTransModel->save($empPayTrans);
}
private function printRaw($label, $data)
{
echo $label.": ";
echo $label . ": ";
print_r($data);
echo "<br><br>";
}
@ -115,14 +116,12 @@ class PayrollController extends BaseController
$payGroupHTMLTable = new \CodeIgniter\View\Table();
$payGroupHTMLTable->setTemplate(MiscLib::adminLTETableTemplate());
if($payGroups == null)
if ($payGroups == null)
$data['tblPayGroup'] = '<p>No groups found.</p>';
else
{
else {
$payGroupHTMLTable->setHeading('ID', 'Group Code', 'Group Name', 'Action');
foreach($payGroups as $group)
{
foreach ($payGroups as $group) {
$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");
@ -144,7 +143,7 @@ class PayrollController extends BaseController
$payrollGroup->fill($rawData);
$payrollGroupModel->save($payrollGroup);
if($payrollGroupModel->getInsertID() == 0)
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');
@ -157,17 +156,26 @@ class PayrollController extends BaseController
$inDedHTMLTable = new \CodeIgniter\View\Table();
$inDedHTMLTable->setTemplate(MiscLib::adminLTETableTemplate());
if($incomeDeductions == null)
if ($incomeDeductions == null)
$data['tblIncomeDeduction'] = '<p>No income and deduction found.</p>';
else
else
{
$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>';
$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->setHeading('ID', 'Payslip Display', 'Deduction Name', 'Income', 'Taxable', 'Include in Gross', 'Action');
foreach ($incomeDeductions as $incomeDeduction) {
$indedHTMLData = 'data-inded_id="' . $incomeDeduction->inded_id .
'" data-payslip_display="' . $incomeDeduction->payslip_display .
'" data-inded_name="' . $incomeDeduction->inded_name .
'" data-coa_code="' . $incomeDeduction->coa_code .
'" data-is_income="' . $incomeDeduction->is_income .
'" data-is_taxable="' . $incomeDeduction->is_taxable .
'" data-include_in_gross="' . $incomeDeduction->include_in_gross . '"';
$iconView = '<a href="/payroll/indedtransupdate/'.$incomeDeduction->inded_id.'" class="ml-3" data-toggle="tooltip" title="View Affected Transactions"><i class="fas fa-eye "></i></a>';
$iconEdit = '<a href="#" class="ml-3" ' . $indedHTMLData . ' onclick="editIncomeDeduction(this)" data-toggle="tooltip" title="Edit Deduction Information"><i class="fas fa-edit"></i></a>';
$iconDelete = '<a href="#" class="ml-3" data-toggle="tooltip" title="Delete Deduction Information"><i class="fas fa-trash"></i></a>';
$inDedHTMLTable->addRow($incomeDeduction->inded_id, $incomeDeduction->payslip_display, $incomeDeduction->inded_name, ($incomeDeduction->is_income) ? 'Yes' : 'No', ($incomeDeduction->is_taxable) ? 'Yes' : 'No', ($incomeDeduction->include_in_gross) ? 'Yes' : 'No', $iconView . ' ' . $iconEdit . ' ' . $iconDelete);
}
$data['tblIncomeDeduction'] = $inDedHTMLTable->generate();
@ -176,7 +184,7 @@ class PayrollController extends BaseController
return view('payroll/incomedeductionview', $data);
}
public function addIncomeDeduction()
public function saveIncomeDeduction()
{
$incomeDeduction = new IncomeDeduction();
$incomeDeductionModel = new IncomeDeductionModel();
@ -189,12 +197,63 @@ class PayrollController extends BaseController
$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');
if ($incomeDeductionModel->save($incomeDeduction))
{
if (isset($rawData['inded_id']))
return redirect()->to('/payroll/inded')->with('message', 'Income or Deduction Successfully Updated');
else
return redirect()->to('/payroll/inded')->with('message', 'Income or Deduction Added');
}
else
return redirect()->to('/payroll/inded')->with('message', 'Income or Deduction Added');
return redirect()->back()->withInput()->with('error', 'Failed to add income or deduction');
}
public function incomeDeductionTransUpdate($indedid)
{
$empPayTransInDedModel = new EmpPayTransIncomeDeductionModel();
$data['incomeDeduction'] = (new IncomeDeductionModel())->find($indedid);
$data['empPayTransInDedCount'] = $empPayTransInDedModel->getEmpPayTransInDedCountxEmPayTransPayTransByInDedId($indedid);
return view('payroll/incomedeductiontransupdateview', $data);
}
public function incomeDeductionTransApplyUpdate($indedid, $paytransid)
{
$empPayTransInDedModel = new EmpPayTransIncomeDeductionModel();
$incomeDeduction = (new IncomeDeductionModel())->find($indedid);
$empPayTransInDeds = $empPayTransInDedModel->getEmpPayTransInDedxEmPayTransByPayTransIdInDedId($paytransid, $indedid);
$empPayTransInDed = new EmpPayTransIncomeDeduction();
$updateCount = 0;
foreach($empPayTransInDeds as $empPayTransInDed)
{
$empPayTransInDed->fill([
'emppaytransinded_id' => $empPayTransInDed->emppaytransinded_id,
'emppaytrans_id' => $empPayTransInDed->emppaytrans_id,
'inded_id' => $empPayTransInDed->inded_id,
'payslip_display' => $empPayTransInDed->payslip_display,
'inded_name' => $empPayTransInDed->inded_name,
'coa_code' => $incomeDeduction->coa_code,
'is_income' => $incomeDeduction->is_income,
'is_taxable' => $incomeDeduction->is_taxable,
'include_in_gross' => $incomeDeduction->include_in_gross,
'is_fixed_amt' => $empPayTransInDed->is_fixed_amt,
'is_percent_amt' => $empPayTransInDed->is_percent_amt,
'worked_days_based' => $empPayTransInDed->worked_days_based,
'amount' => $empPayTransInDed->amount,
'base_amount' => $empPayTransInDed->base_amount,
'is_override' => $empPayTransInDed->is_override
]);
if($empPayTransInDedModel->save($empPayTransInDed))
$updateCount++;
}
return redirect()->back()->with('message', $updateCount . ' items in Income or Deduction was Successfully Updated');
}
public function payrollType()
@ -204,14 +263,12 @@ class PayrollController extends BaseController
$payTypeHTMLTable = new \CodeIgniter\View\Table();
$payTypeHTMLTable->setTemplate(MiscLib::adminLTETableTemplate());
if($payrollTypes == null)
if ($payrollTypes == null)
$data['tblPayrollType'] = '<p>No payroll type found.</p>';
else
{
else {
$payTypeHTMLTable->setHeading('ID', 'Code', 'Name', 'Monthly', 'Semi-Monthly', 'Daily', 'Hourly', 'Action');
foreach($payrollTypes as $payrollType)
{
foreach ($payrollTypes as $payrollType) {
$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);
@ -257,7 +314,7 @@ class PayrollController extends BaseController
$payrollType->fill($rawData);
$payrollTypeModel->save($payrollType);
if($payrollTypeModel->getInsertID() == 0)
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');
@ -277,40 +334,38 @@ class PayrollController extends BaseController
$empPayInfoHTMLTable = new \CodeIgniter\View\Table();
$empPayInfoHTMLTable->setTemplate(MiscLib::adminLTEDataTable1Template("tblEmployeeInfo"));
if($empPayInfos == null)
if ($empPayInfos == null)
$data['tblEmpPayInfo'] = '<p>No employee payroll type found.</p>';
else
{
else {
$empPayInfoHTMLTable->setHeading('ID', 'Payroll Type', 'Employee ID', 'Employee Name', 'Monthly', 'Semi-Monthly', 'Daily', 'Hourly', 'Action');
foreach($empPayInfos as $empPayInfo)
{
$empayHTMLData = 'data-emppay_id="'.$empPayInfo->emppay_id.
'" data-employee_id="'.$empPayInfo->employee_id.
'" data-paytype_id="'.$empPayInfo->paytype_id.
'" data-is_atm="'.$empPayInfo->is_ATM.
'" data-savings_account="'.$empPayInfo->savings_account.
'" data-work_days="'.$empPayInfo->work_days.
'" data-basic_sal_computation="'.$empPayInfo->basic_sal_computation.
'" data-basic_monthly_pay="'.$empPayInfo->basic_monthly_pay.
'" data-basic_semi_monthly_pay="'.$empPayInfo->basic_semi_monthly_pay.
'" data-basic_daily_pay="'.$empPayInfo->basic_daily_pay.
'" data-basic_hourly_pay="'.$empPayInfo->basic_hourly_pay.
'" data-has_cola="'.$empPayInfo->has_cola.
'" data-has_philhealth="'.$empPayInfo->has_philhealth.
'" data-has_hdmf="'.$empPayInfo->has_hdmf.
'" data-has_sss="'.$empPayInfo->has_sss.
'" data-has_gsis="'.$empPayInfo->has_gsis.
'" data-company_issued_id="'.$empPayInfo->company_issued_id.
'" data-last_name="'.$empPayInfo->last_name.
'" data-first_name="'.$empPayInfo->first_name.'"';
foreach ($empPayInfos as $empPayInfo) {
$empayHTMLData = 'data-emppay_id="' . $empPayInfo->emppay_id .
'" data-employee_id="' . $empPayInfo->employee_id .
'" data-paytype_id="' . $empPayInfo->paytype_id .
'" data-is_atm="' . $empPayInfo->is_ATM .
'" data-savings_account="' . $empPayInfo->savings_account .
'" data-work_days="' . $empPayInfo->work_days .
'" data-basic_sal_computation="' . $empPayInfo->basic_sal_computation .
'" data-basic_monthly_pay="' . $empPayInfo->basic_monthly_pay .
'" data-basic_semi_monthly_pay="' . $empPayInfo->basic_semi_monthly_pay .
'" data-basic_daily_pay="' . $empPayInfo->basic_daily_pay .
'" data-basic_hourly_pay="' . $empPayInfo->basic_hourly_pay .
'" data-has_cola="' . $empPayInfo->has_cola .
'" data-has_philhealth="' . $empPayInfo->has_philhealth .
'" data-has_hdmf="' . $empPayInfo->has_hdmf .
'" data-has_sss="' . $empPayInfo->has_sss .
'" data-has_gsis="' . $empPayInfo->has_gsis .
'" data-company_issued_id="' . $empPayInfo->company_issued_id .
'" data-last_name="' . $empPayInfo->last_name .
'" data-first_name="' . $empPayInfo->first_name . '"';
$iconView = '<a href="#" class="ml-3" data-toggle="tooltip" title="View Information"><i class="fas fa-eye "></i></a>';
$iconEdit = '<a href="#" class="ml-3" '.$empayHTMLData.' onclick="editEmpPayInfo(this)" data-toggle="tooltip" title="Edit Information"><i class="fas fa-edit "></i></a>';
$iconDelete = '<a href="/payroll/delempayinfo/'.$empPayInfo->emppay_id.'" onclick="return confirm(\'Are you sure you want to delete this employee?\')" class="ml-3" data-toggle="tooltip" title="Delete Information"><i class="fas fa-trash "></i></a>';
$iconEdit = '<a href="#" class="ml-3" ' . $empayHTMLData . ' onclick="editEmpPayInfo(this)" data-toggle="tooltip" title="Edit Information"><i class="fas fa-edit "></i></a>';
$iconDelete = '<a href="/payroll/delempayinfo/' . $empPayInfo->emppay_id . '" onclick="return confirm(\'Are you sure you want to delete this employee?\')" class="ml-3" data-toggle="tooltip" title="Delete Information"><i class="fas fa-trash "></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." ".$iconEdit." ".$iconDelete);
$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 . " " . $iconEdit . " " . $iconDelete);
}
$data['tblEmpPayInfo'] = $empPayInfoHTMLTable->generate();
@ -333,16 +388,14 @@ class PayrollController extends BaseController
$rawData['has_sss'] = isset($rawData['has_sss']) ? 1 : 0;
$rawData['has_gsis'] = isset($rawData['has_gsis']) ? 1 : 0;
$empPayInfo->fill($rawData);;
$empPayInfo->fill($rawData);
if($empPayInfoModel->save($empPayInfo))
{
if(isset($rawData['emppay_id']))
if ($empPayInfoModel->save($empPayInfo)) {
if (isset($rawData['emppay_id']))
return redirect()->to('/payroll/emppayinfo')->with('message', 'Employee Payroll Successfully Updated');
else
return redirect()->to('/payroll/emppayinfo')->with('message', 'Employee Payroll Type Added');
}
else
} else
return redirect()->back()->withInput()->with('error', 'Failed to add employee payroll type');
}
@ -350,7 +403,7 @@ class PayrollController extends BaseController
{
$empPayInfoModel = new EmployeePayrollInfoModel();
if($empPayInfoModel->delete($emppayid))
if ($empPayInfoModel->delete($emppayid))
return redirect()->back()->with('message', 'Employee Deleted on Payroll');
else
return redirect()->back()->with('error', 'Failed to delete employee on payroll');
@ -368,8 +421,7 @@ class PayrollController extends BaseController
$data['empPayInfos'] = $empPayInfoModel->getAllEmpPayInfoXEmpPayType();
$data['empLoaded'] = false;
if($this->request->getGet('empid') != null)
{
if ($this->request->getGet('empid') != null) {
$settingsModel = new SettingsModel();
$iconView = '<a href="#" class="ml-3" data-toggle="tooltip" title="View Employee Information" ><i class="fas fa-eye "></i></a>';
@ -379,7 +431,7 @@ class PayrollController extends BaseController
$data['empLoaded'] = true;
$data['selectedEmployee'] = $empPayInfoModel->getEmpPayInfoXEmpPayTypeByEmpID($this->request->getGet('empid'));
$data['empPayIncomeList'] = $empPayInDedModel->getEmpPayInDedByEmpPayIdSchedIdIsIncome($data['selectedEmployee']->emppay_id, $this->request->getGet('payschedid'), true);
$data['empPayDeductionList'] = $empPayInDedModel->getEmpPayInDedByEmpPayIdSchedIdIsIncome($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);
@ -416,14 +468,12 @@ class PayrollController extends BaseController
$empPayInDed->fill($rawData);
if($empPayInDedModel->save($empPayInDed))
{
if(isset($rawData['emppayinded_id']))
return redirect()->to('/payroll/compben?payschedid='.$this->request->getPost('payschedule_id').'&empid='.$this->request->getPost('emp_id'))->with('message', 'Employee Compensation Benefits edited');
if ($empPayInDedModel->save($empPayInDed)) {
if (isset($rawData['emppayinded_id']))
return redirect()->to('/payroll/compben?payschedid=' . $this->request->getPost('payschedule_id') . '&empid=' . $this->request->getPost('emp_id'))->with('message', 'Employee Compensation Benefits edited');
else
return redirect()->to('/payroll/compben?payschedid='.$this->request->getPost('payschedule_id').'&empid='.$this->request->getPost('emp_id'))->with('message', 'Employee Compensation Benefits Added');
}
else
return redirect()->to('/payroll/compben?payschedid=' . $this->request->getPost('payschedule_id') . '&empid=' . $this->request->getPost('emp_id'))->with('message', 'Employee Compensation Benefits Added');
} else
return redirect()->back()->withInput()->with('error', 'Failed to add employee compensation benefits');
}
@ -431,8 +481,8 @@ class PayrollController extends BaseController
{
$empPayInDedModel = new EmpPayIncomeDeductionModel();
if($empPayInDedModel->delete($this->request->getPost('emppayinded_id')))
return redirect()->to('/payroll/compben?payschedid='.$this->request->getPost('payschedule_id').'&empid='.$this->request->getPost('emp_id'))->with('message', 'Employee Compensation Benefits deleted');
if ($empPayInDedModel->delete($this->request->getPost('emppayinded_id')))
return redirect()->to('/payroll/compben?payschedid=' . $this->request->getPost('payschedule_id') . '&empid=' . $this->request->getPost('emp_id'))->with('message', 'Employee Compensation Benefits deleted');
else
return redirect()->back()->with('error', 'Failed to delete employee compensation benefits');
}
@ -443,8 +493,7 @@ class PayrollController extends BaseController
$settingsModel = new SettingsModel();
$settings = new Settings();
if($this->request->is('post'))
{
if ($this->request->is('post')) {
$settings->fill($this->request->getPost());
$settingsModel->save($settings);
}
@ -464,24 +513,22 @@ class PayrollController extends BaseController
{
$data['paytypes'] = (new PayrollTypeModel())->findAll();
$data['paySchedules'] = (new PayrollScheduleModel())->findAll();
$payTrans = (new PayrollTransactionModel())->orderBy('created_at', 'DESC')->findAll();
$payTransHTMLTable = new \CodeIgniter\View\Table();
$payTransHTMLTable->setTemplate(MiscLib::adminLTETableTemplate());
if($payTrans == null)
if ($payTrans == null)
$data['tblPayTrans'] = '<p>No transactions found.</p>';
else
{
else {
$payTransHTMLTable->setHeading('ID', 'From', 'To', 'No. of Days', 'Status', 'Remarks', 'Action');
foreach($payTrans as $trans)
{
$iconView = '<a href="/payroll/paytransreview/'.$trans->paytrans_id.'" class="ml-3" data-toggle="tooltip" title="View Payroll Transaction"><i class="fas fa-eye "></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>';
foreach ($payTrans as $trans) {
$iconView = '<a href="/payroll/paytransreview/' . $trans->paytrans_id . '" class="ml-3" data-toggle="tooltip" title="View Payroll Transaction"><i class="fas fa-eye "></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, $iconView.' '.$iconEdit);
$payTransHTMLTable->addRow($trans->paytrans_id, $trans->payroll_from, $trans->payroll_to, $trans->no_of_days, $trans->is_open ? 'Open' : ' Closed', $trans->remarks, $iconView . ' ' . $iconEdit);
}
$data['tblPayTrans'] = $payTransHTMLTable->generate();
@ -498,8 +545,8 @@ class PayrollController extends BaseController
$rawData = $this->request->getPost();
$payTrans->fill($rawData);
if($payTransModel->save($payTrans))
if ($payTransModel->save($payTrans))
return redirect()->to('/payroll/paytrans')->with('message', 'Payroll Transaction Added');
else
return redirect()->back()->withInput()->with('error', 'Failed to add payroll transaction');
@ -510,10 +557,10 @@ class PayrollController extends BaseController
$incomeDeductionModel = new IncomeDeductionModel();
$data['paygroupid'] = $this->request->getGet('grpid');
// INIT, OPEN, CLOSED
$data['transactionStatus'] = 'INIT';
//$payTrans = (new PayrollTransactionModel())->where('paytrans_id', $paytransid)->first();
$data['payTrans'] = (new PayrollTransactionModel())->find($paytransid);
@ -525,48 +572,43 @@ class PayrollController extends BaseController
$empPayTransHTMLTable = new \CodeIgniter\View\Table();
$empPayTransHTMLTable->setTemplate(MiscLib::adminLTETableTemplate());
if($empPayTrans == null)
{
if ($empPayTrans == null) {
$empPayTrans = (new EmployeePayrollInfoModel())->getEmpPayInfoXEmpPayTypeByPayGrpId($data['paygroupid'], $data['payTrans']->paytype_id);
$attSummary = (new AttendanceSummaryModel())->where('paytrans_id', $paytransid)->findAll();
$empPayTransHTMLTable->setHeading('ID', 'Company ID', 'Name', 'Branch', 'Daily Basic', 'Work Days');
if($empPayTrans != null)
{
if ($empPayTrans != null) {
$data['transactionStatus'] = 'INIT';
foreach($empPayTrans as $trans)
{
foreach ($empPayTrans as $trans) {
$empAttSum = MiscLib::searchFromAsocArray('employee_id', $trans->employee_id, $attSummary);
$empPayTransHTMLTable->addRow($trans->employee_id, $trans->company_issued_id, $trans->last_name . ', ' . $trans->first_name, $trans->branch_code, $trans->basic_monthly_pay, ($empAttSum === null) ? 0 : $empAttSum->att_work_days);
}
$data['tblEmpPayTrans'] = $empPayTransHTMLTable->generate();
}
else
} else
$data['tblEmpPayTrans'] = '<p>No Employee Found on this Payroll Group</p>';
}
else
{
} else {
$data['transactionStatus'] = 'OPEN';
$empPayTransHTMLTable->setHeading('ID', 'Name', 'Branch', 'Basic Salary', 'Days Work', 'Gross', 'Deduction', 'Net', 'Action');
foreach($empPayTrans as $trans)
{
foreach ($empPayTrans as $trans) {
//$iconView = '<a href="#" class="ml-3" data-toggle="tooltip" title="View Information" onclick="showEmpPayTransDetails('.$trans->emppaytrans_id.')"><i class="fas fa-eye "></i></a>';
$iconCopy = '<a href="/payroll/emppaytransempreinitpay/'.$trans->emppaytrans_id.'/'.$trans->employee_id.'/'.$trans->paytype_id.'" class="ml-3" data-toggle="tooltip" title="Copy from Payroll Information" onclick="return confirm(\'This will copy payroll information to this record but income and deduction is not affected. Would you like to proceed?\')"><i class="fa fa-copy" aria-hidden="true"></i></a>';
$iconEdit = '<a href="#" class="ml-3" data-toggle="tooltip" title="Edit Information" onclick="showEmpPayTransDetails('.$trans->emppaytrans_id.')"><i class="fas fa-edit "></i></a>';
$iconCopy = '<a href="/payroll/emppaytransempreinitpay/' . $trans->emppaytrans_id . '/' . $trans->employee_id . '/' . $trans->paytype_id . '" class="ml-3" data-toggle="tooltip" title="Copy from Payroll Information" onclick="return confirm(\'This will copy payroll information to this record but income and deduction is not affected. Would you like to proceed?\')"><i class="fa fa-copy" aria-hidden="true"></i></a>';
$iconEdit = '<a href="#" class="ml-3" data-toggle="tooltip" title="Edit Information" onclick="showEmpPayTransDetails(' . $trans->emppaytrans_id . ')"><i class="fas fa-edit "></i></a>';
$empPayTransHTMLTable->addRow($trans->employee_id, $trans->last_name . ', ' . $trans->first_name, $trans->branch_code, $trans->basic_pay, $trans->actual_work_days, $trans->gross_income, $trans->total_deduction, $trans->net_pay, $iconCopy . ' ' . $iconEdit);
// Get Emp Trans In Ded
$empPayTransInDedModel = new EmpPayTransIncomeDeductionModel();
$data['emppaytrans'][] = ["empPayTrans"=>$trans,
"empPayTransInDedIncome"=>$empPayTransInDedModel->getEmpPayTransInDedxInDedByEmpTransIdIsIncome($trans->emppaytrans_id, true),
"empPayTransInDedDeduction"=>$empPayTransInDedModel->getEmpPayTransInDedxInDedByEmpTransIdIsIncome($trans->emppaytrans_id, false)];
$data['emppaytrans'][] = [
"empPayTrans" => $trans,
"empPayTransInDedIncome" => $empPayTransInDedModel->getEmpPayTransInDedxInDedByEmpTransIdIsIncome($trans->emppaytrans_id, true),
"empPayTransInDedDeduction" => $empPayTransInDedModel->getEmpPayTransInDedxInDedByEmpTransIdIsIncome($trans->emppaytrans_id, false)
];
}
$data['tblEmpPayTrans'] = $empPayTransHTMLTable->generate();
@ -595,11 +637,10 @@ class PayrollController extends BaseController
$empPayTransHTMLTable->setHeading('ID', 'Company ID', 'Name', 'Branch', 'Daily Basic', 'Work Days', 'Action');
foreach($empPayInfos as $empPayInfo)
{
foreach ($empPayInfos as $empPayInfo) {
$empAttSum = MiscLib::searchFromAsocArray('employee_id', $empPayInfo->employee_id, $attSummary);
$empIsInEmpPayTrans = (MiscLib::searchFromAsocArray('employee_id', $empPayInfo->employee_id, $empPayTrans) == null) ? false : true;
$empPayTransHTMLTable->addRow($empPayInfo->employee_id, $empPayInfo->company_issued_id, $empPayInfo->last_name . ', ' . $empPayInfo->first_name, $empPayInfo->branch_code, $empPayInfo->basic_monthly_pay, ($empAttSum === null) ? 0 : $empAttSum->att_work_days, ($empIsInEmpPayTrans) ? '<button type="button" class="btn btn-primary btn-sm" disabled>Already Initialized</button>' : '<a href="/payroll/emppaytransempinit/'.$data['payTrans']->paytrans_id.'/'.$empPayInfo->emppay_id.'" class="btn btn-warning btn-sm">Initialize</a>');
$empPayTransHTMLTable->addRow($empPayInfo->employee_id, $empPayInfo->company_issued_id, $empPayInfo->last_name . ', ' . $empPayInfo->first_name, $empPayInfo->branch_code, $empPayInfo->basic_monthly_pay, ($empAttSum === null) ? 0 : $empAttSum->att_work_days, ($empIsInEmpPayTrans) ? '<button type="button" class="btn btn-primary btn-sm" disabled>Already Initialized</button>' : '<a href="/payroll/emppaytransempinit/' . $data['payTrans']->paytrans_id . '/' . $empPayInfo->emppay_id . '" class="btn btn-warning btn-sm">Initialize</a>');
}
$data['tblEmpPayTrans'] = $empPayTransHTMLTable->generate();
@ -609,60 +650,64 @@ class PayrollController extends BaseController
public function empPayTransFillArrayFromEmpPayInfo($paytransid, $empPayInfo, $empAttSum)
{
return ['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_sal_computation' => $empPayInfo->basic_sal_computation,
'basic_monthly_pay' => $empPayInfo->basic_monthly_pay,
'basic_semi_monthly_pay' => $empPayInfo->basic_semi_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' => ($empAttSum === null) ? 0 : $empAttSum->att_work_days,
'basic_pay' => 0,
'gross_income' => 0,
'taxable_income' => 0,
'nontaxable_income' => 0,
'income_tax' => 0,
'total_deduction' => 0,
'taxable_deduction' => 0,
'nontaxable_deduction' => 0,
'net_pay' => 0];
return [
'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_sal_computation' => $empPayInfo->basic_sal_computation,
'basic_monthly_pay' => $empPayInfo->basic_monthly_pay,
'basic_semi_monthly_pay' => $empPayInfo->basic_semi_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' => ($empAttSum === null) ? 0 : $empAttSum->att_work_days,
'basic_pay' => 0,
'gross_income' => 0,
'taxable_income' => 0,
'nontaxable_income' => 0,
'income_tax' => 0,
'total_deduction' => 0,
'taxable_deduction' => 0,
'nontaxable_deduction' => 0,
'net_pay' => 0
];
}
public function empPayTransInDedFillArrayFromEmpPayInDed($emppaytransid, $empPayInDed, $amount)
{
return ['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,
'worked_days_based' => $empPayInDed->worked_days_based,
'amount' => $amount,
'base_amount' => $empPayInDed->amount,
'is_override' => $empPayInDed->is_override];
return [
'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,
'worked_days_based' => $empPayInDed->worked_days_based,
'amount' => $amount,
'base_amount' => $empPayInDed->amount,
'is_override' => $empPayInDed->is_override
];
}
public function empPayTransInitializePayroll($paytransid, $paygroupid, $transtypid)
@ -671,31 +716,31 @@ class PayrollController extends BaseController
$attSummary = (new AttendanceSummaryModel())->where('paytrans_id', $paytransid)->findAll();
$payTrans = (new PayrollTransactionModel())->find($paytransid);
$empPayTransactionModel = new EmployeePayTransactionModel();
foreach($empPayInfos as $empPayInfo)
{
foreach ($empPayInfos as $empPayInfo) {
$empPayTransaction = new EmployeePayTransaction();
$empAttSum = MiscLib::searchFromAsocArray('employee_id', $empPayInfo->employee_id, $attSummary);
$empPayTransaction->fill($this->empPayTransFillArrayFromEmpPayInfo($paytransid, $empPayInfo, $empAttSum));
$empPayTransactionModel->save($empPayTransaction);
$empPayTransaction = $empPayTransactionModel->find($empPayTransactionModel->getInsertID());
$empPayInDeds = (new EmpPayIncomeDeductionModel())->getEmpPayInDedByEmpPayIdSchedId($empPayInfo->emppay_id, $payTrans->payschedule_id);
foreach($empPayInDeds as $empPayInDed)
{
foreach ($empPayInDeds as $empPayInDed) {
$empPayTransInDed = new EmpPayTransIncomeDeduction();
$empPayTransInDedModel = new EmpPayTransIncomeDeductionModel();
$payCompute = new PayrollComputation();
$rawData = ['amount'=>$empPayInDed->amount,
'is_fixed_amt'=>$empPayInDed->is_fixed_amt,
'is_percent_amt'=>$empPayInDed->is_percent_amt,
'worked_days_based'=>$empPayInDed->worked_days_based];
$rawData = [
'amount' => $empPayInDed->amount,
'is_fixed_amt' => $empPayInDed->is_fixed_amt,
'is_percent_amt' => $empPayInDed->is_percent_amt,
'worked_days_based' => $empPayInDed->worked_days_based
];
$amount = $payCompute->computeIncomeDeductionByComputationType($rawData, $empPayTransaction);
$empPayTransInDed->fill($this->empPayTransInDedFillArrayFromEmpPayInDed($empPayTransaction->emppaytrans_id, $empPayInDed, $amount));
$empPayTransInDedModel->save($empPayTransInDed);
@ -718,24 +763,25 @@ class PayrollController extends BaseController
$empPayTransaction = new EmployeePayTransaction();
$empPayTransaction->fill($this->empPayTransFillArrayFromEmpPayInfo($paytransid, $empPayInfo, $empAttSum));
$empPayTransactionModel->save($empPayTransaction);
$empPayTransaction = $empPayTransactionModel->find($empPayTransactionModel->getInsertID());
$empPayInDeds = (new EmpPayIncomeDeductionModel())->getEmpPayInDedByEmpPayIdSchedId($empPayInfo->emppay_id, $payTrans->payschedule_id);
foreach($empPayInDeds as $empPayInDed)
{
foreach ($empPayInDeds as $empPayInDed) {
$empPayTransInDed = new EmpPayTransIncomeDeduction();
$empPayTransInDedModel = new EmpPayTransIncomeDeductionModel();
$payCompute = new PayrollComputation();
$rawData = ['amount'=>$empPayInDed->amount,
'is_fixed_amt'=>$empPayInDed->is_fixed_amt,
'is_percent_amt'=>$empPayInDed->is_percent_amt,
'worked_days_based'=>$empPayInDed->worked_days_based];
$rawData = [
'amount' => $empPayInDed->amount,
'is_fixed_amt' => $empPayInDed->is_fixed_amt,
'is_percent_amt' => $empPayInDed->is_percent_amt,
'worked_days_based' => $empPayInDed->worked_days_based
];
$amount = $payCompute->computeIncomeDeductionByComputationType($rawData, $empPayTransaction);
$empPayTransInDed->fill($this->empPayTransInDedFillArrayFromEmpPayInDed($empPayTransaction->emppaytrans_id, $empPayInDed, $amount));
$empPayTransInDedModel->save($empPayTransInDed);
@ -752,9 +798,9 @@ class PayrollController extends BaseController
$currentEmpPayTransaction = $empPayTransactionModel->find($emppaytransid);
$empPayInfo = (new EmployeePayrollInfoModel())->where(['employee_id'=>$employeeid, 'paytype_id'=>$paytypeid])->first();
$empPayInfo = (new EmployeePayrollInfoModel())->where(['employee_id' => $employeeid, 'paytype_id' => $paytypeid])->first();
if($empPayInfo == null)
if ($empPayInfo == null)
return redirect()->back()->withInput()->with('error', 'Employee Payroll Information not found. Please check payroll information.');
$attSummary = (new AttendanceSummaryModel())->where('paytrans_id', $currentEmpPayTransaction->paytrans_id)->findAll();
@ -764,12 +810,10 @@ class PayrollController extends BaseController
$empPayTransaction->fill($this->empPayTransFillArrayFromEmpPayInfo($currentEmpPayTransaction->paytrans_id, $empPayInfo, $empAttSum));
$empPayTransaction->emppaytrans_id = $emppaytransid;
if($empPayTransactionModel->save($empPayTransaction))
{
if ($empPayTransactionModel->save($empPayTransaction)) {
$this->computeEmployeePayroll($emppaytransid, true);
return redirect()->back()->withInput()->with('message', 'Payroll re-initialize. Please verify the entries.');
}
else
} else
return redirect()->back()->withInput()->with('error', 'Failed to re-initialize payroll.');
}
@ -830,33 +874,33 @@ class PayrollController extends BaseController
$amount = $payCompute->computeIncomeDeductionByComputationType($rawData, $empPayTrans);
$empPayTransInDed->fill(
['emppaytransinded_id' => (isset($rawData['emppaytransinded_id'])) ? $rawData['emppaytransinded_id'] : null,
'emppaytrans_id' => $rawData['emppaytrans_id'],
'inded_id' => $rawData['inded_id'],
'payslip_display' => $incomeDeduction->payslip_display,
'inded_name' => $incomeDeduction->inded_name,
'coa_code' => $incomeDeduction->coa_code,
'is_income' => $incomeDeduction->is_income,
'is_taxable' => $incomeDeduction->is_taxable,
'include_in_gross' => $incomeDeduction->include_in_gross,
'is_fixed_amt' => $rawData['is_fixed_amt'],
'is_percent_amt' => $rawData['is_percent_amt'],
'worked_days_based' => $rawData['worked_days_based'],
'amount' => $amount,
'base_amount' => $rawData['amount'],
'is_override' => $rawData['is_override']]
[
'emppaytransinded_id' => (isset($rawData['emppaytransinded_id'])) ? $rawData['emppaytransinded_id'] : null,
'emppaytrans_id' => $rawData['emppaytrans_id'],
'inded_id' => $rawData['inded_id'],
'payslip_display' => $incomeDeduction->payslip_display,
'inded_name' => $incomeDeduction->inded_name,
'coa_code' => $incomeDeduction->coa_code,
'is_income' => $incomeDeduction->is_income,
'is_taxable' => $incomeDeduction->is_taxable,
'include_in_gross' => $incomeDeduction->include_in_gross,
'is_fixed_amt' => $rawData['is_fixed_amt'],
'is_percent_amt' => $rawData['is_percent_amt'],
'worked_days_based' => $rawData['worked_days_based'],
'amount' => $amount,
'base_amount' => $rawData['amount'],
'is_override' => $rawData['is_override']
]
);
if($empPayTransInDedModel->save($empPayTransInDed))
{
if ($empPayTransInDedModel->save($empPayTransInDed)) {
$this->computeEmployeePayroll($rawData['emppaytrans_id'], true, $empPayTransactionModel, $empPayTransInDedModel);
if(isset($rawData['emppaytransinded_id']))
if (isset($rawData['emppaytransinded_id']))
return redirect()->back()->with('message', 'Income or Deduction Updated');
else
return redirect()->back()->with('message', 'Income or Deduction Added');
}
else
} else
return redirect()->back()->withInput()->with('error', 'Failed to add income or deduction');
}
@ -864,12 +908,10 @@ class PayrollController extends BaseController
{
$empPayTransInDedModel = new EmpPayTransIncomeDeductionModel();
if($empPayTransInDedModel->delete($emppaytransindedid))
{
if ($empPayTransInDedModel->delete($emppaytransindedid)) {
$this->computeEmployeePayroll($emppaytransid, true, null, $empPayTransInDedModel);
return redirect()->back()->with('message', 'Income or Deduction Deleted');
}
else
} else
return redirect()->back()->with('error', 'Failed to delete income or deduction');
}

@ -99,4 +99,50 @@ class EmpPayTransIncomeDeductionModel extends Model
if($result->amount == null) return 0;
else return $result->amount;
}
public function getEmpPayTransInDedxEmPayTransByPayTransIdInDedId($paytransid, $indedid)
{
$builder = $this->db->table('emp_pay_trans_inded');
$builder->select('*');
$builder->join('emp_pay_trans', 'emp_pay_trans.emppaytrans_id = emp_pay_trans_inded.emppaytrans_id');
$builder->where([
'emp_pay_trans.paytrans_id' => $paytransid,
'emp_pay_trans_inded.inded_id' => $indedid,
'emp_pay_trans_inded.deleted_at' => null
]);
return $builder->get()->getResult();
}
public function getEmpPayTransInDedCountxEmPayTransPayTransByInDedId($indedid)
{
$builder = $this->db->table('emp_pay_trans_inded');
$builder->select(['pay_trans.paytrans_id',
'pay_trans.paytype_id',
'pay_trans.payschedule_id',
'pay_trans.payroll_from',
'pay_trans.payroll_to',
'pay_trans.no_of_days',
'pay_trans.total_emp',
'pay_trans.total_gross',
'pay_trans.remarks',
'pay_trans.is_open']);
$builder->selectCount('emp_pay_trans_inded.emppaytransinded_id', 'emp_count');
$builder->join('emp_pay_trans', 'emp_pay_trans.emppaytrans_id = emp_pay_trans_inded.emppaytrans_id');
$builder->join('pay_trans', 'pay_trans.paytrans_id = emp_pay_trans.paytrans_id');
$builder->where([
'emp_pay_trans_inded.inded_id' => $indedid,
'emp_pay_trans_inded.deleted_at' => null
]);
$builder->groupBy(['pay_trans.paytrans_id',
'pay_trans.paytype_id',
'pay_trans.payschedule_id',
'pay_trans.payroll_from',
'pay_trans.payroll_to',
'pay_trans.no_of_days',
'pay_trans.total_emp',
'pay_trans.total_gross',
'pay_trans.remarks',
'pay_trans.is_open']);
return $builder->get()->getResult();
}
}

@ -0,0 +1,84 @@
<!-- Extend area where template is defined -->
<?= $this->extend('templates/adminlte/generalcontent') ?>
<!-- .Extend -->
<!-- Title of the page -->
<?= $this->section('title') ?>Income and Deduction Transaction Update<?= $this->endSection() ?>
<!-- .Title -->
<!-- CSS of the page -->
<?= $this->section('css') ?>
<?= $this->endSection() ?>
<!-- .CSS -->
<!-- body attribute - class definition -->
<?= $this->section('bodyclass') ?>sidebar-mini<?= $this->endSection() ?>
<!-- .body attribute -->
<!-- Container title -->
<?= $this->section('containertitle') ?>Transaction Update of Income and Deduction<?= $this->endSection() ?>
<!-- .Container title -->
<!-- Active breadcrumb -->
<?= $this->section('breadcrumbs') ?>
<li class="breadcrumb-item active"><a href="/payroll/inded">Income and Deduction</a></li>
<li class="breadcrumb-item active">Transaction Update</li>
<?= $this->endSection() ?>
<!-- .Active breadcrumb -->
<!-- Main content -->
<?= $this->section('main') ?>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3 class="card-title"><?= $incomeDeduction->inded_name ?></h3>
</div>
<div class="card-body">
<p>Here are the list of payroll transaction and the number of affected transactions when we update this Income or Deduction item.</p>
<table class="table table-bordered">
<thead>
<tr>
<th>ID</th>
<th>Description</th>
<th>No. of Affected Transactions</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach($empPayTransInDedCount as $empPayTransInDed): ?>
<tr>
<td><?= $empPayTransInDed->paytrans_id ?></td>
<td><?= $empPayTransInDed->payroll_from . " - " . $empPayTransInDed->payroll_to ?></td>
<td><?= $empPayTransInDed->emp_count ?></td>
<td><a href="/payroll/indedtransapplyupdate/<?= $incomeDeduction->inded_id."/".$empPayTransInDed->paytrans_id ?>" class="btn btn-secondary">Update Income/Deduction Transaction</a></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?= $this->endSection() ?>
<!-- .Main content -->
<!-- Javascript -->
<?= $this->section('js') ?>
<script>
$(document).ready(function() {
});
</script>
<?= $this->endSection() ?>
<!-- .Javascript -->

@ -28,11 +28,11 @@
<!-- Main content -->
<?= $this->section('main') ?>
<!-- Modal Add Branch -->
<!-- Modal Add Income and Deduction -->
<div class="modal fade" id="mdlAddInDed">
<div class="modal-dialog">
<div class="modal-content">
<form action="<?= url_to('payroll/addinded') ?>" method="post">
<form action="<?= url_to('payroll/saveinded') ?>" method="post">
<div class="modal-header">
<h4 class="modal-title" >New Income or Deduction</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
@ -91,6 +91,69 @@
</div>
</div>
<!-- Modal Edit Income and Deduction -->
<div class="modal fade" id="mdlEditInDed">
<div class="modal-dialog">
<div class="modal-content">
<form action="<?= url_to('payroll/saveinded') ?>" method="post">
<div class="modal-header bg-warning">
<h4 class="modal-title" >Edit Income or Deduction</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">Income or Deduction Information</p>
<div class="row">
<div class="col-12">
<div class="form-group">
<label for="txtEditInDedName">Income or Deduction Name</label>
<input class="form-control" type="text" id="txtEditInDedName" name="inded_name" readonly>
<input type="hidden" name="inded_id" id="hdnEditInDedID">
</div>
<div class="form-group">
<label for="txtEditPayslipDisplay">Display on Payslip</label>
<input class="form-control" type="text" id="txtEditPayslipDisplay" name="payslip_display" readonly>
</div>
<div class="form-group">
<label for="txtEditCOACode">COA Code</label>
<input class="form-control" type="text" id="txtEditCOACode" name="coa_code" value="<?= old('coa_code') ?>">
<p style="font-size: smaller"><i>COA code (Chart of Account) is a code used by accounting department</i></p>
</div>
<div class="form-group">
<div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" id="chkEditIsIncome" name="is_income">
<label for="chkEditIsIncome" class="custom-control-label">Is Income? this will be treated as deduction if unchecked</label>
</div>
</div>
<div class="form-group">
<div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" id="chkEditIsTaxable" name="is_taxable">
<label for="chkEditIsTaxable" class="custom-control-label">Is Taxable? this will be treated as non-taxable if unchecked</label>
</div>
</div>
<div class="form-group">
<div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" id="chkEditIncludeInGross" name="include_in_gross" checked>
<label for="chkEditIncludeInGross" class="custom-control-label">Include in Gross?</label>
</div>
</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">
@ -119,10 +182,21 @@
<script>
$(document).ready(function() {
});
function editIncomeDeduction(element)
{
$("#hdnEditInDedID").val($(element).data("inded_id"));
$("#txtEditInDedName").val($(element).data("inded_name"));
$("#txtEditPayslipDisplay").val($(element).data("payslip_display"));
$("#txtEditCOACode").val($(element).data("coa_code"));
$("#chkEditIsIncome").prop("checked", $(element).data("is_income"));
$("#chkEditIsTaxable").prop("checked", $(element).data("is_taxable"));
$("#chkEditIncludeInGross").prop("checked", $(element).data("include_in_gross"));
$("#mdlEditInDed").modal("show");
}
</script>

Loading…
Cancel
Save