Merge pull request 'added settings' (#9) from paulcortezl5 into main

Reviewed-on: #9
pull/12/head
paul 8 months ago
commit 669eb26f81

@ -47,6 +47,9 @@ $routes->post('payroll/addemppayinfo', 'PayrollController::addEmployeePayrollInf
$routes->get('payroll/compben', 'PayrollController::employeeCompensationBenefits');
$routes->post('payroll/addcompben', 'PayrollController::addEmployeeCompensationBenefits');
$routes->get('payroll/paysettings', 'PayrollController::payrollSettings');
$routes->post('payroll/paysettings', 'PayrollController::payrollSettings');
// Administrator Routes
$routes->get('adminuser', 'AdministratorController::index');
$routes->get('adminuser/newuser', 'AdministratorController::newUserView');

@ -12,6 +12,8 @@ use App\Models\PayrollTypeModel;
use App\Models\EmployeePayrollInfoModel;
use App\Models\EmployeeModel;
use App\Models\EmpPayIncomeDeductionModel;
use App\Models\SettingsModel;
use App\Models\PayrollScheduleModel;
// Entities
@ -21,6 +23,8 @@ use App\Entities\PayrollType;
use App\Entities\EmployeePayrollInfo;
use App\Entities\Employee;
use App\Entities\EmpPayIncomeDeduction;
use App\Entities\Settings;
use App\Entities\PayrollSchedule;
// Class Library
use App\ClassLib\MiscLib;
@ -247,6 +251,7 @@ class PayrollController extends BaseController
$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();
@ -256,8 +261,8 @@ class PayrollController extends BaseController
{
$data['empLoaded'] = true;
$data['selectedEmployee'] = $empPayInfoModel->getEmpPayInfoJoinedEmpPayTypeByEmpID($this->request->getGet('empid'));
$data['empPayIncomeList'] = $empPayInDedModel->getEmpPayInDedByEmpPayId($data['selectedEmployee']->emppay_id, true);
$data['empPayDeductionList'] = $empPayInDedModel->getEmpPayInDedByEmpPayId($data['selectedEmployee']->emppay_id, false);
$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);
@ -294,6 +299,29 @@ class PayrollController extends BaseController
if($empPayInDedModel->getInsertID() == 0)
return redirect()->back()->withInput()->with('error', 'Failed to add employee compensation benefits');
else
return redirect()->to('/payroll/compben?empid='.$this->request->getPost('emp_id'))->with('message', 'Employee Compensation Benefits Added');
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);
}
}

@ -0,0 +1,65 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreatePaySchedule extends Migration
{
public function up()
{
$this->forge->addField([
'payschedule_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true
],
'sched_code' => [
'type' => 'VARCHAR',
'constraint' => 25,
'null' => false
],
'sched_name' => [
'type' => 'VARCHAR',
'constraint' => 255,
'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('payschedule_id', true);
$this->forge->createTable('pay_schedule');
}
public function down()
{
$this->forge->dropTable('pay_schedule');
}
}

@ -20,6 +20,11 @@ class CreateEmpPayIncomeDeduction extends Migration
'constraint' => 11,
'unsigned' => true,
],
'payschedule_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
],
'inded_id' => [
'type' => 'INT',
'constraint' => 11,
@ -74,6 +79,7 @@ class CreateEmpPayIncomeDeduction extends Migration
$this->forge->addKey('emppayinded_id', true);
$this->forge->addForeignKey('emppay_id', 'emp_pay_info', 'emppay_id', 'CASCADE', 'RESTRICT');
$this->forge->addForeignKey('payschedule_id', 'pay_schedule', 'payschedule_id', 'CASCADE', 'RESTRICT');
$this->forge->addForeignKey('inded_id', 'pay_income_deduction', 'inded_id', 'CASCADE', 'RESTRICT');
$this->forge->createTable('emp_pay_inded');
}

@ -9,6 +9,7 @@ class EmpPayIncomeDeduction extends Entity
protected $attributes = [
'emppayinded_id' => null,
'emppay_id' => null,
'payschedule_id' => null,
'inded_id' => null,
'is_fixed_amt' => null,
'is_percent_amt' => null,

@ -0,0 +1,17 @@
<?php
namespace App\Entities;
use CodeIgniter\Entity\Entity;
class PayrollSchedule extends Entity
{
protected $attributes = [
'sched_code' => null,
'sched_name' => null,
];
protected $datamap = [];
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
protected $casts = [];
}

@ -0,0 +1,20 @@
<?php
namespace App\Entities;
use CodeIgniter\Entity\Entity;
class Settings extends Entity
{
protected $attributes = [
'id' => null,
'class' => null,
'key' => null,
'value' => null,
'type' => null,
'context' => null,
];
protected $datamap = [];
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
protected $casts = [];
}

@ -13,6 +13,7 @@ class EmpPayIncomeDeductionModel extends Model
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = ['emppay_id',
'payschedule_id',
'inded_id',
'is_fixed_amt',
'is_percent_amt',
@ -61,12 +62,16 @@ class EmpPayIncomeDeductionModel extends Model
return $data;
}
public function getEmpPayInDedByEmpPayId($empPayId, $isIncome)
public function getEmpPayInDedByEmpPayId($empPayId, $paySchedId, $isIncome)
{
$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, 'pay_income_deduction.is_income' => $isIncome]);
$builder->where([
'emp_pay_inded.emppay_id' => $empPayId,
'pay_income_deduction.is_income' => $isIncome,
'emp_pay_inded.payschedule_id' => $paySchedId
]);
return $builder->get()->getResult();
}
}

@ -30,7 +30,7 @@ class EmployeePayrollInfoModel extends Model
protected bool $allowEmptyInserts = false;
// Dates
protected $useTimestamps = false;
protected $useTimestamps = true;
protected $dateFormat = 'datetime';
protected $createdField = 'created_at';
protected $updatedField = 'updated_at';
@ -44,9 +44,9 @@ class EmployeePayrollInfoModel extends Model
// Callbacks
protected $allowCallbacks = true;
protected $beforeInsert = ['assignCreatedAt'];
protected $beforeInsert = ['assignCreatedBy'];
protected $afterInsert = [];
protected $beforeUpdate = ['assignUpdatedAt'];
protected $beforeUpdate = ['assignUpdatedBy'];
protected $afterUpdate = [];
protected $beforeFind = [];
protected $afterFind = [];
@ -54,16 +54,14 @@ class EmployeePayrollInfoModel extends Model
protected $afterDelete = [];
public function assignCreatedAt(array $data)
public function assignCreatedBy(array $data)
{
$data['data']['created_at'] = date('Y-m-d H:i:s');
$data['data']['created_by'] = auth()->user()->employee_id;
return $data;
}
public function assignUpdatedAt(array $data)
public function assignUpdatedBy(array $data)
{
$data['data']['updated_at'] = date('Y-m-d H:i:s');
$data['data']['updated_by'] = auth()->user()->employee_id;
return $data;
}

@ -0,0 +1,54 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class PayrollScheduleModel extends Model
{
protected $table = 'pay_schedule';
protected $primaryKey = 'payschedule_id';
protected $useAutoIncrement = true;
protected $returnType = \App\Entities\PayrollSchedule::class;
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = ['sched_code', 'sched_name'];
protected bool $allowEmptyInserts = false;
// Dates
protected $useTimestamps = false;
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 = ['assignCreatedAt'];
protected $afterInsert = [];
protected $beforeUpdate = ['assignUpdatedAt'];
protected $afterUpdate = [];
protected $beforeFind = [];
protected $afterFind = [];
protected $beforeDelete = [];
protected $afterDelete = [];
public function assignCreatedAt(array $data)
{
$data['data']['created_by'] = auth()->user()->employee_id;
return $data;
}
public function assignUpdatedAt(array $data)
{
$data['data']['updated_by'] = auth()->user()->employee_id;
return $data;
}
}

@ -0,0 +1,54 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class SettingsModel extends Model
{
protected $table = 'settings';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = \App\Entities\Settings::class;
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = ['class', 'key', 'value', 'type', 'context'];
protected bool $allowEmptyInserts = false;
// Dates
protected $useTimestamps = false;
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 = ['assignCreatedAt'];
protected $afterInsert = [];
protected $beforeUpdate = ['assignUpdatedAt'];
protected $afterUpdate = [];
protected $beforeFind = [];
protected $afterFind = [];
protected $beforeDelete = [];
protected $afterDelete = [];
public function assignCreatedAt(array $data)
{
$data['data']['created_at'] = date('Y-m-d H:i:s');
return $data;
}
public function assignUpdatedAt(array $data)
{
$data['data']['updated_at'] = date('Y-m-d H:i:s');
return $data;
}
}

@ -9,6 +9,10 @@
<!-- CSS of the page -->
<?= $this->section('css') ?>
<!-- Select2 -->
<link rel="stylesheet" href="/adminlte/plugins/select2/css/select2.min.css">
<link rel="stylesheet" href="/adminlte/plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css">
<?= $this->endSection() ?>
<!-- .CSS -->
@ -52,6 +56,7 @@
<option value="<?= $income->inded_id ?>"><?= $income->inded_name ?></option>
<?php endforeach; ?>
</select>
<input type="hidden" name="payschedule_id" value="<?= $_GET['payschedid'] ?>">
<input type="hidden" name="emppay_id" value="<?= $selectedEmployee->emppay_id ?>" >
<input type="hidden" name="emp_id" value="<?= $selectedEmployee->employee_id ?>" >
</div>
@ -120,6 +125,7 @@
<option value="<?= $deduction->inded_id ?>"><?= $deduction->inded_name ?></option>
<?php endforeach; ?>
</select>
<input type="hidden" name="payschedule_id" value="<?= $_GET['payschedid'] ?>">
<input type="hidden" name="emppay_id" value="<?= $selectedEmployee->emppay_id ?>" >
<input type="hidden" name="emp_id" value="<?= $selectedEmployee->employee_id ?>" >
</div>
@ -174,8 +180,20 @@
<div class="row">
<div class="col-12">
<form action="/payroll/compben" method="get">
<div class="row">
<div class="col-12 col-sm-4">
<div class="form-group">
<label>Select Schedule</label>
<select class="form-control" style="width: 100%;" name="payschedid">
<?php foreach($paySchedules as $paySchedule): ?>
<?php $selected = ($empLoaded && $_GET['payschedid'] == $paySchedule->payschedule_id) ? 'selected' : ''; ?> <?= '<option value="'.$paySchedule->payschedule_id.'" '.$selected.'>['.$paySchedule->sched_code.'] '.$paySchedule->sched_name.'</option>' ?>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="col-12 col-sm-8">
<label>Select Employee</label>
<div class="form-group">
<div class="input-group mb-3">
<select class="form-control select2 rounded-0" name="empid">
<?php foreach($empPayInfos as $empPayInfo): ?>
@ -188,6 +206,8 @@
</span>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
@ -279,9 +299,20 @@
<?= $this->section('js') ?>
<!-- Select2 -->
<script src="/adminlte/plugins/select2/js/select2.full.min.js"></script>
<script>
$(document).ready(function() {
//Initialize Select2 Elements
$('.select2').select2();
//Initialize Select2 Elements
$('.select2bs4').select2({
theme: 'bootstrap4'
});
});
</script>

@ -0,0 +1,207 @@
<!-- Extend area where template is defined -->
<?= $this->extend('templates/adminlte/generalcontent') ?>
<!-- .Extend -->
<!-- Title of the page -->
<?= $this->section('title') ?>Payroll Settings<?= $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') ?>Payroll Settings<?= $this->endSection() ?>
<!-- .Container title -->
<!-- Active breadcrumb -->
<?= $this->section('activebreadcrumb') ?>Payroll Settings<?= $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">List of Payroll Settings</h3>
</div>
<div class="card-body">
<p>Assign proper value to each payroll settings for proper payroll computation during payroll processing.</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Setting</th>
<th>Value</th>
<th>Type</th>
<th>Description</th>
<th>Save Action</th>
</tr>
</thead>
<tbody>
<form action="/payroll/paysettings" method="POST">
<tr>
<td>
<?php if($basicSalVal != null): ?>
<input type="hidden" name="id" value="<?= $basicSalVal->id ?>">
<?php endif ?>
<input type="hidden" name="class" value="Payroll">
<input type="text" class="form-control" name="key" value="BasicSalary" readonly>
</td>
<td>
<select class="form-control" style="width: 100%;" name="value">
<?php foreach($indedList as $inded): ?>
<?php $selected = ($basicSalVal != null && $basicSalVal->value == $inded->inded_id) ? 'selected' : ''; ?>
<?= '<option value="'.$inded->inded_id.'" '.$selected.'>'.$inded->inded_name.'</option>' ?>
<?php endforeach; ?>
</select>
</td>
<td><input type="text" class="form-control" name="type" value="int" readonly></td>
<td><input type="text" class="form-control" name="context" value="Basic Salary" readonly></td>
<td><input type="submit" class="btn btn-primary" value="Save"></td>
</tr>
</form>
<form action="/payroll/paysettings" method="POST">
<tr>
<td>
<?php if($COLAVal != null): ?>
<input type="hidden" name="id" value="<?= $COLAVal->id ?>">
<?php endif ?>
<input type="hidden" name="class" value="Payroll">
<input type="text" class="form-control" name="key" value="COLA" readonly>
</td>
<td>
<select class="form-control" style="width: 100%;" name="value">
<?php foreach($indedList as $inded): ?>
<?php $selected = ($COLAVal != null && $COLAVal->value == $inded->inded_id) ? 'selected' : ''; ?>
<?= '<option value="'.$inded->inded_id.'" '.$selected.'>'.$inded->inded_name.'</option>' ?>
<?php endforeach; ?>
</select>
</td>
<td><input type="text" class="form-control" name="type" value="int" readonly></td>
<td><input type="text" class="form-control" name="context" value="Cost of Living Allowance" readonly></td>
<td><input type="submit" class="btn btn-primary" value="Save"></td>
</tr>
</form>
<form action="/payroll/paysettings" method="POST">
<tr>
<td>
<?php if($PhilhealthVal != null): ?>
<input type="hidden" name="id" value="<?= $PhilhealthVal->id ?>">
<?php endif ?>
<input type="hidden" name="class" value="Payroll">
<input type="text" class="form-control" name="key" value="Philhealth" readonly>
</td>
<td>
<select class="form-control" style="width: 100%;" name="value">
<?php foreach($indedList as $inded): ?>
<?php $selected = ($PhilhealthVal != null && $PhilhealthVal->value == $inded->inded_id) ? 'selected' : ''; ?>
<?= '<option value="'.$inded->inded_id.'" '.$selected.'>'.$inded->inded_name.'</option>' ?>
<?php endforeach; ?>
</select>
</td>
<td><input type="text" class="form-control" name="type" value="int" readonly></td>
<td><input type="text" class="form-control" name="context" value="Philhealth Contribution" readonly></td>
<td><input type="submit" class="btn btn-primary" value="Save"></td>
</tr>
</form>
<form action="/payroll/paysettings" method="POST">
<tr>
<td>
<?php if($HDMFVal != null): ?>
<input type="hidden" name="id" value="<?= $HDMFVal->id ?>">
<?php endif ?>
<input type="hidden" name="class" value="Payroll">
<input type="text" class="form-control" name="key" value="HDMF" readonly>
</td>
<td>
<select class="form-control" style="width: 100%;" name="value">
<?php foreach($indedList as $inded): ?>
<?php $selected = ($HDMFVal != null && $HDMFVal->value == $inded->inded_id) ? 'selected' : ''; ?>
<?= '<option value="'.$inded->inded_id.'" '.$selected.'>'.$inded->inded_name.'</option>' ?>
<?php endforeach; ?>
</select>
</td>
<td><input type="text" class="form-control" name="type" value="int" readonly></td>
<td><input type="text" class="form-control" name="context" value="Pag-IBIG Contribution" readonly></td>
<td><input type="submit" class="btn btn-primary" value="Save"></td>
</tr>
</form>
<form action="/payroll/paysettings" method="POST">
<tr>
<td>
<?php if($SSSVal != null): ?>
<input type="hidden" name="id" value="<?= $SSSVal->id ?>">
<?php endif ?>
<input type="hidden" name="class" value="Payroll">
<input type="text" class="form-control" name="key" value="SSS" readonly>
</td>
<td>
<select class="form-control" style="width: 100%;" name="value">
<?php foreach($indedList as $inded): ?>
<?php $selected = ($SSSVal != null && $SSSVal->value == $inded->inded_id) ? 'selected' : ''; ?>
<?= '<option value="'.$inded->inded_id.'" '.$selected.'>'.$inded->inded_name.'</option>' ?>
<?php endforeach; ?>
</select>
</td>
<td><input type="text" class="form-control" name="type" value="int" readonly></td>
<td><input type="text" class="form-control" name="context" value="SSS Contribution" readonly></td>
<td><input type="submit" class="btn btn-primary" value="Save"></td>
</tr>
</form>
<form action="/payroll/paysettings" method="POST">
<tr>
<td>
<?php if($GSISVal != null): ?>
<input type="hidden" name="id" value="<?= $GSISVal->id ?>">
<?php endif ?>
<input type="hidden" name="class" value="Payroll">
<input type="text" class="form-control" name="key" value="GSIS" readonly>
</td>
<td>
<select class="form-control" style="width: 100%;" name="value">
<?php foreach($indedList as $inded): ?>
<?php $selected = ($GSISVal != null && $GSISVal->value == $inded->inded_id) ? 'selected' : ''; ?>
<?= '<option value="'.$inded->inded_id.'" '.$selected.'>'.$inded->inded_name.'</option>' ?>
<?php endforeach; ?>
</select>
</td>
<td><input type="text" class="form-control" name="type" value="int" readonly></td>
<td><input type="text" class="form-control" name="context" value="GSIS Contribution" readonly></td>
<td><input type="submit" class="btn btn-primary" value="Save"></td>
</tr>
</form>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?= $this->endSection() ?>
<!-- .Main content -->
<!-- Javascript -->
<?= $this->section('js') ?>
<script>
$(document).ready(function() {
});
</script>
<?= $this->endSection() ?>
<!-- .Javascript -->

@ -234,6 +234,14 @@
</p>
</a>
</li>
<li class="nav-item">
<a href="/payroll/paysettings" class="nav-link">
<i class="far fa-circle nav-icon"></i>
<p>
Payroll Settings
</p>
</a>
</li>
</ul>
</li>
<li class="nav-item">

Loading…
Cancel
Save