Merge pull request 'payslip viewing and user creation' (#36) from paulcortezl5 into main

Reviewed-on: #36
pull/37/head
paul 4 months ago
commit af1bb2f57c

@ -89,6 +89,8 @@ $routes->post('adminuser/deleteuser', 'AdministratorController::deleteUser');
$routes->get('adminuser/editusergroup/(:num)', 'AdministratorController::editUserGroupView/$1');
$routes->get('adminuser/edituserpermission/(:num)', 'AdministratorController::editUserPermissionView/$1');
$routes->post('adminuser/saveusergroup', 'AdministratorController::saveEditedUserGroup');
$routes->get('adminuser/fromemplist', 'AdministratorController::newUserFromEmployeeList');
$routes->get('adminuser/newuserfromemplist/(:any)', 'AdministratorController::createUserFromEmployeeList/$1');
// Timekeeper Routes`
@ -103,5 +105,7 @@ $routes->get('tk/attsumdel/(:any)/(:any)', 'TKController::attendanceSummaryDelet
// Regular Employee Routes
$routes->get('remp', 'RegularEmployeeController::index');
$routes->get('remp/payview', 'RegularEmployeeController::payslipView');
$routes->get('remp/payprint/(:num)', 'RegularEmployeeController::payslipViewPrint/$1');
service('auth')->routes($routes);

@ -6,6 +6,14 @@ use App\Controllers\BaseController;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Shield\Entities\User;
// Models
use App\Models\EmployeeModel;
// Entities
use App\Entities\Employee;
class AdministratorController extends BaseController
{
private function superadminAndAdminOnly()
@ -164,6 +172,42 @@ class AdministratorController extends BaseController
return redirect()->to('/adminuser')->with('error', 'User deletion failed.');
}
public function newUserFromEmployeeList()
{
$data['employeeList'] = (new EmployeeModel())->findAll();
return view('admin/newuserfromemplist', $data);
}
public function createUserFromEmployeeList($employeeid)
{
$employee = (new EmployeeModel())->where(['company_issued_id' => $employeeid, 'deleted_at' => NULL])->first();
$user = new User([
'username' => $employee->company_issued_id,
'email' => $employee->email_address,
'password' => $employee->company_issued_id,
'employee_id' => $employee->company_issued_id,
'display_name' => $employee->first_name." ".$employee->last_name,
]);
$users = auth()->getProvider();
if($users->save($user))
{
// To get the complete user object with ID, we need to get from the database
$user = $users->findById($users->getInsertID());
// Add to default group
$users->addToDefaultGroup($user);
// Activate user
$user->activate();
return redirect()->back()->with('message', 'User created successfully.');
}
else
return redirect()->back()->with('error', 'User creation failed.');
}
// Methods called by AJAX and return JSON

@ -5,10 +5,58 @@ namespace App\Controllers;
use App\Controllers\BaseController;
use CodeIgniter\HTTP\ResponseInterface;
// Models
use App\Models\EmployeePayTransactionModel;
use App\Models\PayrollTransactionModel;
use App\Models\EmployeeModel;
use App\Models\EmpPayTransIncomeDeductionModel;
// Entities
use App\Entities\EmployeePayTransaction;
use App\Entities\PayrollTransaction;
use App\Entities\Employee;
use App\Entities\EmpPayTransIncomeDeduction;
class RegularEmployeeController extends BaseController
{
public function index()
{
return redirect()->to(base_url('/login'));
}
public function payslipView()
{
$data['paytransid'] = $this->request->getGet('paytransid');
$data['payTransactions'] = (new PayrollTransactionModel())->orderBy('paytype_id','DESC')->limit(15)->findAll();
$data['loggedEmployee'] = (new EmployeeModel())->where('company_issued_id', auth()->user()->employee_id)->first();
if($data['paytransid'] != null)
{
$data['empPayTrans'] = (new EmployeePayTransactionModel())->where(['paytrans_id' => $data['paytransid'], 'company_issued_id'=>auth()->user()->employee_id])->first();
if($data['empPayTrans'] != null)
{
$empPayTransInDedModel = new EmpPayTransIncomeDeductionModel();
$data['empPayTransIncomes'] = $empPayTransInDedModel->where(["emppaytrans_id"=>$data['empPayTrans']->emppaytrans_id, "is_income"=>true])->findAll();
$data['empPayTransDeductions'] = $empPayTransInDedModel->where(["emppaytrans_id"=>$data['empPayTrans']->emppaytrans_id, "is_income"=>false])->findAll();
}
}
return view('regemp/payslipview', $data);
}
public function payslipViewPrint($paytransid)
{
$data['loggedEmployee'] = (new EmployeeModel())->where('company_issued_id', auth()->user()->employee_id)->first();
$data['payTransaction'] = (new PayrollTransactionModel())->find($paytransid);
$data['empPayTrans'] = (new EmployeePayTransactionModel())->where(['paytrans_id' => $paytransid, 'company_issued_id'=>auth()->user()->employee_id])->first();
if($data['empPayTrans'] != null)
{
$empPayTransInDedModel = new EmpPayTransIncomeDeductionModel();
$data['empPayTransIncomes'] = $empPayTransInDedModel->where(["emppaytrans_id"=>$data['empPayTrans']->emppaytrans_id, "is_income"=>true])->findAll();
$data['empPayTransDeductions'] = $empPayTransInDedModel->where(["emppaytrans_id"=>$data['empPayTrans']->emppaytrans_id, "is_income"=>false])->findAll();
}
return view('regemp/payslipviewprint', $data);
}
}

@ -0,0 +1,117 @@
<?php
// Class Library
use App\ClassLib\MiscLib;
?>
<!-- Extend area where template is defined -->
<?= $this->extend('templates/adminlte/generalcontent') ?>
<!-- .Extend -->
<!-- Title of the page -->
<?= $this->section('title') ?>New User from List<?= $this->endSection() ?>
<!-- .Title -->
<!-- CSS of the page -->
<?= $this->section('css') ?>
<!-- DataTables -->
<link rel="stylesheet" href="<?= base_url() ?>adminlte/plugins/datatables-bs4/css/dataTables.bootstrap4.min.css">
<link rel="stylesheet" href="<?= base_url() ?>adminlte/plugins/datatables-responsive/css/responsive.bootstrap4.min.css">
<?= $this->endSection() ?>
<!-- .CSS -->
<!-- body attribute - class definition -->
<?= $this->section('bodyclass') ?>sidebar-mini<?= $this->endSection() ?>
<!-- .body attribute -->
<!-- Container title -->
<?= $this->section('containertitle') ?>New User from Employee List<?= $this->endSection() ?>
<!-- .Container title -->
<!-- Active breadcrumb -->
<?= $this->section('breadcrumbs') ?>
<li class="breadcrumb-item"><a href="/adminuser">User Maintenance</a></li>
<li class="breadcrumb-item active">New User from List</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">List of Users</h3>
</div>
<div class="card-body">
<table id="tblEmployee" class="table table-bordered">
<thead>
<tr>
<th>Employee ID</th>
<th>Employee Name</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach ($employeeList as $employee): ?>
<tr>
<td><?= $employee->company_issued_id ?></td>
<td><?= $employee->last_name.", ".$employee->first_name ?></td>
<td>
<?php
$searchedEmp = auth()->getProvider()->where('employee_id', $employee->company_issued_id)->first();
if($searchedEmp == null):
?>
<a href="/adminuser/newuserfromemplist/<?= $employee->company_issued_id ?>" class="btn btn-secondary"><i class="fas fa-user-plus"></i>&nbsp;&nbsp;&nbsp;Create System Account</a>
<?php else: ?>
<p>Account Created Already</p>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?= $this->endSection() ?>
<!-- .Main content -->
<!-- Javascript -->
<?= $this->section('js') ?>
<!-- DataTables & Plugins -->
<script src="<?= base_url() ?>adminlte/plugins/datatables/jquery.dataTables.min.js"></script>
<script src="<?= base_url() ?>adminlte/plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="<?= base_url() ?>adminlte/plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="<?= base_url() ?>adminlte/plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
<script>
$(document).ready(function() {
$('#tblEmployee').DataTable({
"paging": true,
"lengthChange": false,
"searching": true,
"ordering": true,
"info": true,
"autoWidth": false,
"responsive": true,
});
});
</script>
<?= $this->endSection() ?>
<!-- .Javascript -->

@ -202,6 +202,7 @@
</div>
<div class="card-footer">
<a href="/adminuser/newuser" class="btn btn-primary">New User</a>
<a href="/adminuser/fromemplist" class="btn btn-primary">New From Employee List</a>
</div>
</div>
</div>

@ -0,0 +1,232 @@
<!-- Extend area where template is defined -->
<?= $this->extend('templates/adminlte/generalcontent') ?>
<!-- .Extend -->
<!-- Title of the page -->
<?= $this->section('title') ?>Payslip View<?= $this->endSection() ?>
<!-- .Title -->
<!-- CSS of the page -->
<?= $this->section('css') ?>
<!-- Select2 -->
<link rel="stylesheet" href="<?= base_url() ?>adminlte/plugins/select2/css/select2.min.css">
<link rel="stylesheet" href="<?= base_url() ?>adminlte/plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css">
<?= $this->endSection() ?>
<!-- .CSS -->
<!-- body attribute - class definition -->
<?= $this->section('bodyclass') ?>sidebar-mini<?= $this->endSection() ?>
<!-- .body attribute -->
<!-- Container title -->
<?= $this->section('containertitle') ?>Payslip View<?= $this->endSection() ?>
<!-- .Container title -->
<!-- Active breadcrumb -->
<?= $this->section('breadcrumbs') ?>
<li class="breadcrumb-item active">Payslip View</li>
<?= $this->endSection() ?>
<!-- .Active breadcrumb -->
<!-- Main content -->
<?= $this->section('main') ?>
<!-- Modal Add Branch -->
<div class="modal fade" id="mdlAddBranch">
<div class="modal-dialog">
<div class="modal-content">
<form action="<?= url_to('payroll/addpaygroup') ?>" method="post">
<div class="modal-header">
<h4 class="modal-title" >New Group</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">Select Payroll Period</p>
<div class="row">
<div class="col-12">
<div class="form-group">
<label for="txtGroupCode">Payroll Group Code</label>
<input class="form-control" type="text" id="txtGroupCode" name="pay_group_code" value="<?= old('pay_group_code') ?>">
</div>
<div class="form-group">
<label for="txtGroupName">Payroll Group Name</label>
<input class="form-control" type="text" id="txtGroupName" name="pay_group_name" values="<?= old('pay_group_name') ?>">
</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">
<div class="card">
<div class="card-header">
<h3 class="card-title">Select Payroll Period</h3>
</div>
<div class="card-body">
<form action="/remp/payview" method="get">
<div class="form-group">
<label>Payroll Group</label>
<div class="input-group mb-3">
<select class="form-control select2 rounded-0" name="paytransid">
<option value="-1">-- Select --</option>
<?php foreach($payTransactions as $payTrans): ?>
<?php $selected = ($paytransid != null && $paytransid == $payTrans->paytrans_id) ? 'selected' : ''; ?>
<option value="<?= $payTrans->paytrans_id ?>" <?= $selected ?>><?= '['.($payTrans->is_open ? 'Open' : 'Closed').'] Payroll from '.$payTrans->payroll_from.' to '.$payTrans->payroll_to ?></option>
<?php endforeach; ?>
</select>
<span class="input-group-append">
<button type="submit" class="btn btn-info btn-flat">View Payslip</button>
</span>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<?php if($paytransid != null): ?>
<?php if($empPayTrans != null): ?>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3 class="card-title">Payslip View</h3>
</div>
<div class="card-body">
<table id="tblEmpPayslipView" class="table table-bordered">
<tr>
<td>Employee Name:</td>
<td colspan="3" class="text-bold"><?= $empPayTrans->last_name.", ".$empPayTrans->first_name ?></td>
</tr>
<tr class="bg-light text-bold">
<td>Description</td>
<td>Deduction</td>
<td>Income</td>
<td>Total</td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Basic Pay @<?= number_format($empPayTrans->basic_daily_pay, 2, '.', ',') ?> x <?= number_format($empPayTrans->actual_work_days, 2, '.', ',') ?> days</td>
<td>&nbsp;</td>
<td><?= number_format($empPayTrans->basic_pay, 2, '.', ','); ?></td>
<td>&nbsp;</td>
</tr>
<?php
$grossIncome = $empPayTrans->basic_pay;
$totalDeduction = 0;
foreach($empPayTransIncomes as $empPayTransIncome):
?>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?= $empPayTransIncome->payslip_display ?></td>
<td>&nbsp;</td>
<td><?= number_format($empPayTransIncome->amount, 2, '.', ','); ?></td>
<td>&nbsp;</td>
</tr>
<?php
$grossIncome += $empPayTransIncome->amount;
endforeach;
?>
<tr>
<td><strong>Gross Income</strong></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td class="text-right"><strong><?= number_format($grossIncome, 2, ".", ",") ?></strong></td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Income Tax</td>
<td>-<?= number_format($empPayTrans->income_tax, 2, '.', ','); ?></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<?php foreach($empPayTransDeductions as $empPayTransDeduction): ?>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?= $empPayTransDeduction->payslip_display ?></td>
<td>-<?= number_format($empPayTransDeduction->amount, 2, '.', ','); ?></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<?php
$totalDeduction += $empPayTransDeduction->amount;
endforeach;
?>
<tr>
<td><strong>Total Deduction</strong></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td class="text-right">-<strong><?= number_format($totalDeduction, 2, ".", ",") ?></strong></td>
</tr>
<tr>
<td><strong>Net Income</strong></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td class="text-right"><strong><?= number_format($empPayTrans->net_pay, 2, ".", ",") ?></strong></td>
</tr>
</table>
</div>
<div class="card-footer">
<a href="/remp/payprint/<?= $paytransid ?>" target="_blank" class="btn btn-primary">Print Payslip</a>
</div>
</div>
</div>
</div>
<?php else: ?>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3 class="card-title">Payslip View</h3>
</div>
<div class="card-body">
<p>No payslip for this cut-off.</p>
</div>
</div>
</div>
</div>
<?php endif; ?>
<?php endif; ?>
<?= $this->endSection() ?>
<!-- .Main content -->
<!-- Javascript -->
<?= $this->section('js') ?>
<!-- Select2 -->
<script src="<?= base_url() ?>adminlte/plugins/select2/js/select2.full.min.js"></script>
<script>
$(document).ready(function() {
//Initialize Select2 Elements
$('.select2').select2();
});
</script>
<?= $this->endSection() ?>
<!-- .Javascript -->

@ -0,0 +1,151 @@
<!-- Extend area where template is defined -->
<?= $this->extend('templates/adminlte/printcontent') ?>
<!-- .Extend -->
<!-- Title of the page -->
<?= $this->section('title') ?>Payslip Printing<?= $this->endSection() ?>
<!-- .Title -->
<!-- Main content -->
<?= $this->section('main') ?>
<!-- title row -->
<div class="row">
<div class="col-12">
<h2 class="page-header">
KARAT WORLD
<small class="float-right"><span class="text-muted">Employee:</span> [<?= $empPayTrans->company_issued_id ?>] <?= $empPayTrans->last_name.", ".$empPayTrans->first_name ?></small>
</h2>
</div>
<!-- /.col -->
</div>
<!-- info row -->
<div class="row invoice-info">
<div class="col-sm-4 invoice-col">
Payslip of <strong><?= $empPayTrans->last_name.", ".$empPayTrans->first_name ?></strong>
</div>
<!-- /.col -->
<div class="col-sm-4 invoice-col">
Payroll Period <br>
<strong><?= date("F d, Y", strtotime($payTransaction->payroll_from))." to ".date("F d, Y", strtotime($payTransaction->payroll_to)) ?></strong><br>
</div>
<!-- /.col -->
<div class="col-sm-4 invoice-col">
Payroll Date <br>
<strong><?= ($payTransaction->payschedule_id == 1) ? date("F 7, Y", strtotime($payTransaction->payroll_to)) : date("F t, Y", strtotime($payTransaction->payroll_to)) ?></strong>
</div>
<!-- /.col -->
</div>
<!-- /.row -->
<!-- Table row -->
<div class="row">
<div class="col-12 table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Description</th>
<th>Deduction</th>
<th>Income</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Basic Pay @<?= number_format($empPayTrans->basic_daily_pay, 2, '.', ',') ?> x <?= number_format($empPayTrans->actual_work_days, 2, '.', ',') ?> days</td>
<td>&nbsp;</td>
<td><?= number_format($empPayTrans->basic_pay, 2, '.', ',') ?></td>
<td>&nbsp;</td>
</tr>
<?php
$grossIncome = $empPayTrans->basic_pay;
$totalDeduction = 0;
foreach($empPayTransIncomes as $empPayTransIncome):
?>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?= $empPayTransIncome->payslip_display ?></td>
<td>&nbsp;</td>
<td><?= number_format($empPayTransIncome->amount, 2, '.', ',') ?></td>
<td>&nbsp;</td>
</tr>
<?php
$grossIncome += $empPayTransIncome->amount;
endforeach;
?>
<tr>
<td><strong>Gross Income</strong></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td class="text-right"><strong><?= number_format($grossIncome, 2, ".", ",") ?></strong></td>
</tr>
<?php foreach($empPayTransDeductions as $empPayTransDeduction): ?>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?= $empPayTransDeduction->payslip_display ?></td>
<td>-<?= number_format($empPayTransDeduction->amount, 2, '.', ','); ?></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<?php
$totalDeduction += $empPayTransDeduction->amount;
endforeach;
?>
<tr>
<td><strong>Total Deduction</strong></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td class="text-right">-<strong><?= number_format($totalDeduction, 2, ".", ",") ?></strong></td>
</tr>
</tbody>
</table>
</div>
<!-- /.col -->
</div>
<!-- /.row -->
<div class="row">
<!-- accepted payments column -->
<div class="col-6">
<p class="text-muted well well-sm shadow-none" style="margin-top: 10px;">
I have fully read and understood all details concerning my wage for the above stated period. Wherein, I am fully satisfied with the computations made, without prejudice to my behalf. That all data stated above, I hereby acknowledge, to be true and correct.
</p>
<p class="lead"><?= $empPayTrans->last_name.", ".$empPayTrans->first_name ?></p>
<p>____________________________________</p>
<p class="text-muted well well-sm shadow-none" style="margin-top: 10px;">
<i>Signature of Employee</i>
</p>
</div>
<!-- /.col -->
<div class="col-6">
<p class="lead">Summary of Payslip</p>
<div class="table-responsive">
<table class="table">
<tr>
<th style="width:50%">Gross Income:</th>
<td><?= number_format($grossIncome, 2, ".", ",") ?></td>
</tr>
<tr>
<th>Total Deduction</th>
<td>(<?= number_format($totalDeduction, 2, ".", ",") ?>)</td>
</tr>
<tr>
<th>Tax:</th>
<td>(<?= number_format($empPayTrans->income_tax, 2, ".", ",") ?>)</td>
</tr>
<tr>
<th>Net Income:</th>
<td><?= number_format($empPayTrans->net_pay, 2, ".", ",") ?></td>
</tr>
</table>
</div>
</div>
<!-- /.col -->
</div>
<!-- /.row -->
<?= $this->endSection() ?>
<!-- .Main content -->

@ -166,26 +166,26 @@
</a>
<ul class="nav nav-treeview">
<li class="nav-item">
<a href="/tk/rawattlogupload" class="nav-link">
<a href="#" class="nav-link">
<i class="far fa-circle nav-icon"></i>
<p>
Attendance Uploading
Attendance Log
</p>
</a>
</li>
<li class="nav-item">
<a href="/tk/attsummary" class="nav-link">
<a href="#" class="nav-link">
<i class="far fa-circle nav-icon"></i>
<p>
Attendance Summary
Time Dispute
</p>
</a>
</li>
</ul>
</li>
<li class="nav-item">
<a href="/tk/rawattlogupload" class="nav-link">
<i class="far fa-circle nav-icon"></i>
<a href="/remp/payview" class="nav-link">
<i class="nav-icon fas fa-calendar-alt"></i>
<p>
View Payslip
</p>

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?= $this->renderSection('title') ?></title>
<!-- Google Font: Source Sans Pro -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
<!-- Font Awesome -->
<link rel="stylesheet" href="<?= base_url() ?>adminlte/plugins/fontawesome-free/css/all.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="<?= base_url() ?>adminlte/dist/css/adminlte.min.css">
</head>
<body>
<div class="wrapper">
<!-- Main content -->
<section class="invoice">
<?= $this->renderSection('main') ?>
</section>
<!-- /.content -->
</div>
<!-- ./wrapper -->
<!-- Page specific script -->
<script>
window.addEventListener("load", window.print());
</script>
</body>
</html>
Loading…
Cancel
Save