attendance log uploading #22

Merged
paul merged 1 commits from paulcortezl5 into main 6 months ago

@ -133,7 +133,8 @@ class App extends BaseConfig
* @see https://www.php.net/manual/en/timezones.php for list of timezones
* supported by PHP.
*/
public string $appTimezone = 'UTC';
//public string $appTimezone = 'UTC';
public string $appTimezone = 'Asia/Manila';
/**
* --------------------------------------------------------------------------

@ -69,6 +69,10 @@ class AuthGroups extends ShieldAuthGroups
'title' => 'HR User',
'description' => 'Has access to Human Resources features.',
],
'hr' => [
'title' => 'Timekeeping User',
'description' => 'Has access to Timekeeping features.',
],
];
/**
@ -118,6 +122,15 @@ class AuthGroups extends ShieldAuthGroups
'hr.data-upload' => 'Can upload data',
'hr.data-download' => 'Can download data',
'hr.data-export' => 'Can export data',
'tk.data-create' => 'Can create new data',
'tk.data-edit' => 'Can edit existing data',
'tk.data-delete' => 'Can delete existing data',
'tk.data-view' => 'Can view existing data',
'tk.data-print' => 'Can print existing data',
'tk.data-upload' => 'Can upload data',
'tk.data-download' => 'Can download data',
'tk.data-export' => 'Can export data',
];
/**
@ -136,6 +149,7 @@ class AuthGroups extends ShieldAuthGroups
'beta.*',
'payroll.*',
'hr.*',
'tk.*',
],
'admin' => [
'admin.access',
@ -145,6 +159,7 @@ class AuthGroups extends ShieldAuthGroups
'beta.access',
'payroll.*',
'hr.*',
'tk.*',
],
'developer' => [
'admin.access',
@ -165,5 +180,8 @@ class AuthGroups extends ShieldAuthGroups
'hr' => [
'hr.*',
],
'tk' => [
'tk.*',
],
];
}

@ -11,6 +11,8 @@ $routes->get('hi', 'DashboardController::index');
$routes->get('hr', 'HRController::index');
$routes->get('tk', 'TKController::index');
// Human Resources Routes
$routes->get('hr/dept', 'HRController::companyDepartment');
$routes->post('hr/adddept', 'HRController::addCompanyDepartment');
@ -28,6 +30,8 @@ $routes->get('hr/emp', 'HRController::employee');
$routes->post('hr/addemp', 'HRController::addEmployee');
$routes->post('hr/editemp', 'HRController::editEmployee');
$routes->get('hr/att', 'HRController::employeeInfo');
// Payroll Routes
$routes->get('payroll', 'PayrollController::index');
@ -62,7 +66,6 @@ $routes->get('payroll/emppaytransrecom/(:num)', 'PayrollController::employeePayr
$routes->post('payroll/saveemppaytransaddinded', 'PayrollController::saveEmpPayTransIncomeDeduction');
$routes->get('payroll/emppaytransdelinded/(:num)/(:num)', 'PayrollController::deleteEmpPayTransIncomeDeduction/$1/$2');
//$routes->post('t', 'PayrollController::test');
@ -77,4 +80,13 @@ $routes->get('adminuser/editusergroup/(:num)', 'AdministratorController::editUse
$routes->get('adminuser/edituserpermission/(:num)', 'AdministratorController::editUserPermissionView/$1');
$routes->post('adminuser/saveusergroup', 'AdministratorController::saveEditedUserGroup');
// Timekeeper Routes`
$routes->get('tk/rawattlogupload', 'TKController::rawAttendanceLogUpload');
$routes->post('tk/rawattlogupfile/(:any)/(:any)/(:any)', 'TKController::rawAttendanceLogUploadFile/$1/$2/$3');
$routes->get('tk/rawattlogdelete/(:any)/(:any)/(:any)', 'TKController::rawAttendanceLogDelete/$1/$2/$3');
$routes->get('tk/attsummary', 'TKController::attendanceSummary');
$routes->post('tk/attsumsave/(:any)/(:any)', 'TKController::attendanceSummarySave/$1/$2');
service('auth')->routes($routes);

@ -0,0 +1,233 @@
<?php
namespace App\Controllers;
use App\Controllers\BaseController;
use CodeIgniter\HTTP\ResponseInterface;
// Models
use App\Models\CompanyBranchModel;
use App\Models\RawAttLogModel;
use App\Models\PayrollTransactionModel;
use App\Models\PayrollGroupModel;
use App\Models\AttendanceSummaryModel;
// Entities
use App\Entities\CompanyBranch;
use App\Entities\RawAttLog;
use App\Entities\PayrollTransaction;
use App\Entities\PayrollGroup;
use App\Entities\AttendanceSummary;
// Class Library
use App\ClassLib\MiscLib;
use CodeIgniter\I18n\Time;
class TKController extends BaseController
{
protected $helpers = ['form'];
public function index()
{
return redirect()->to(base_url('/login'));
}
public function attendanceSummary()
{
$rawAttLogModel = new RawAttLogModel();
$data['payrollTransactions'] = (new PayrollTransactionModel())->orderBy('created_at', 'DESC')->findAll();
$data['payGroups'] = (new PayrollGroupModel())->findAll();
$rawGetData = $this->request->getGet();
if($rawGetData != null)
{
$data['selectedData'] = $rawGetData;
$attendanceSummaryModel = new AttendanceSummaryModel();
$empSummaries = $attendanceSummaryModel->where(['paytrans_id'=>$rawGetData['paytrans_id'], 'pay_group_id'=>$rawGetData['pay_group_id']])->findAll();
if($empSummaries == null)
{
$data['attendanceSummarySaved'] = false;
$payTrans = (new PayrollTransactionModel())->find($rawGetData['paytrans_id']);
$employeeWorkDates = $rawAttLogModel->getEmployeeDaysCount($payTrans->payroll_from, $payTrans->payroll_to);
$employeeWorkDayCount = [];
foreach($employeeWorkDates as $employeeWorkDate)
{
if(!isset($employeeWorkDayCount[$employeeWorkDate->company_issued_id]))
$employeeWorkDayCount[$employeeWorkDate->company_issued_id] = [
'employee_id' => $employeeWorkDate->employee_id,
'company_issued_id' => $employeeWorkDate->company_issued_id,
'employee_name' => $employeeWorkDate->first_name . ' ' . $employeeWorkDate->last_name,
'att_work_days' => 0
];
$employeeWorkDayCount[$employeeWorkDate->company_issued_id]['att_work_days']++;
}
$data['employeeWorkDayCount'] = $employeeWorkDayCount;
}
else
{
$data['attendanceSummarySaved'] = true;
foreach($empSummaries as $empSummary)
$employeeWorkDayCount[] = [
'employee_id' => $empSummary->employee_id,
'company_issued_id' => $empSummary->company_issued_id,
'employee_name' => $empSummary->employee_name,
'att_work_days' => $empSummary->att_work_days
];
$data['employeeWorkDayCount'] = $employeeWorkDayCount;
}
}
return view('timekeeping/attsummaryview', $data);
}
public function attendanceSummarySave($payTransId, $payGroupId)
{
$rawData = $this->request->getPost();
$batchEmpSummary = [];
foreach($rawData['emp_work_day_count'] as $empWorkDayCount)
{
$empSummary = explode('|', $empWorkDayCount);
$batchEmpSummary[] = [
'paytrans_id' => $payTransId,
'pay_group_id' => $payGroupId,
'employee_id' => $empSummary[0],
'company_issued_id' => $empSummary[1],
'employee_name' => $empSummary[2],
'att_work_days' => $empSummary[3]
];
}
$attSummaryModel = new AttendanceSummaryModel();
if($attSummaryModel->insertBatch($batchEmpSummary, true))
return redirect()->back()->with('message', 'Attendance summary saved.');
else
return redirect()->back()->with('error', 'Failed to save attendance summary.');
}
public function rawAttendanceLogUpload()
{
$data['branches'] = (new CompanyBranchModel())->findAll();
$data['selectedBranch'] = $this->request->getGet('branch_code');
$data['attFromTo'] = $this->request->getGet('att_from_to');
$data['attFrom'] = $this->request->getGet('att_from');
$data['attTo'] = $this->request->getGet('att_to');
if($data['selectedBranch'] != null && $data['attFromTo'] != null)
{
$data['attendanceLog'] = (new RawAttLogModel())->where(['log_date >='=>$data['attFrom'], 'log_date <='=>$data['attTo']])->findAll();
$attLogHTMLTable = new \CodeIgniter\View\Table();
$attLogHTMLTable->setTemplate(MiscLib::adminLTETableTemplate());
if($data['attendanceLog'] == null)
$data['tblAttLog'] = '<p>No attendance log found.</p>';
else
{
$attLogHTMLTable->addRow('Employee ID', 'Log Date', 'Log Time', 'In/Out', 'Branch');
foreach($data['attendanceLog'] as $attLog)
{
$attLogHTMLTable->addRow($attLog->company_issued_id, $attLog->log_date, $attLog->log_time, ($attLog->log_type) ? 'Out' : 'In', $attLog->branch_code);
}
$data['tblAttLog'] = $attLogHTMLTable->generate();
}
}
return view('timekeeping/rawattloguploadview', $data);
}
public function rawAttendanceLogUploadFile($selectedBranch, $attendanceFrom, $attendanceTo)
{
$rawAttLogModel = new RawAttLogModel();
$batchRawAttLog = [];
$file = $this->request->getFile('att_file');
if ($file->isValid() && ! $file->hasMoved()) {
$name = $file->getName();
$filePath = WRITEPATH . 'uploads/attendance/' . $selectedBranch . '/' . $name;
$file->move(WRITEPATH . 'uploads/attendance/' . $selectedBranch, $name, true);
$data = [];
$fileHandle = fopen($filePath, 'r');
if($fileHandle)
{
while (($line = fgets($fileHandle)) !== false)
{
if(trim($line) == '') continue;
// Create DateTime objects for comparison
$dateFromFile = Time::createFromFormat('Y-m-d', substr($line, 10, 10));
$attFrom = Time::createFromFormat('Y-m-d', $attendanceFrom);
$attTo = Time::createFromFormat('Y-m-d', $attendanceTo);
// Check if the date from file falls within the specified range
if ($dateFromFile < $attFrom || $dateFromFile > $attTo) continue;
$batchRawAttLog[] = [
'company_issued_id' => trim(substr($line, 0, 9)),
'log_date' => substr($line, 10, 10),
'log_time' => substr($line, 21, 8),
'ucol1' => substr($line, 30, 1),
'log_type' => substr($line, 32, 1),
'ucol2' => substr($line, 34, 1),
'ucol3' => substr($line, 36, 1),
'branch_code' => $selectedBranch,
'att_from' => $attendanceFrom,
'att_to' => $attendanceTo,
'created_at' => Time::now(),
'created_by' => auth()->user()->employee_id,
];
// 1182 2019-10-29 10:32:41 1 0 1 0
}
fclose($fileHandle);
if($rawAttLogModel->addBatchData($batchRawAttLog, true))
return redirect()->back()->with('message', 'Raw attendance log uploaded.');
else
return redirect()->back()->with('error', 'Error uploading raw attendance log.');
}
else
return redirect()->back()->with('error', 'Error reading the file. Please check the file and try again.');
}
else
return redirect()->back()->with('error', 'Error uploading file. Please check the file and try again.');
}
public function rawAttendanceLogDelete($branchCode, $logDateFrom, $logDAteTo)
{
$attLogModel = new RawAttLogModel();
$result = $attLogModel
->where(['log_date >='=>$logDateFrom,
'log_date <='=>$logDAteTo,
'branch_code'=>$branchCode])
->delete();
if($result)
return redirect()->back()->with('message', 'Raw attendance log deleted.');
else
return redirect()->back()->with('error', 'Failed to delete raw attendance log.');
}
}

@ -0,0 +1,79 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateRawAttLog extends Migration
{
public function up()
{
$this->forge->addField([
'company_issued_id' => [
'type' => 'VARCHAR',
'constraint' => 25,
'null' => true,
],
'log_date' => [
'type' => 'DATE',
'null' => true,
],
'log_time' => [
'type' => 'TIME',
'null' => true,
],
'ucol1' => [
'type' => 'VARCHAR',
'constraint' => 2,
'null' => true,
],
'log_type' => [
'type' => 'TINYINT',
'constraint' => 1,
'null' => true,
],
'ucol2' => [
'type' => 'VARCHAR',
'constraint' => 2,
'null' => true,
],
'ucol3' => [
'type' => 'VARCHAR',
'constraint' => 2,
'null' => true,
],
'branch_code' => [
'type' => 'VARCHAR',
'constraint' => 25,
'null' => false,
],
'att_from' => [
'type' => 'DATE',
'null' => true,
],
'att_to' => [
'type' => 'DATE',
'null' => true,
],
// Common fields
'created_at' => [
'type' => 'DATETIME',
'null' => true,
],
'created_by' => [
'type' => 'VARCHAR',
'constraint' => '20',
'null' => true
],
]);
$this->forge->addKey(['company_issued_id', 'log_date', 'log_time', 'log_type'], true);
$this->forge->createTable('raw_att_log');
}
public function down()
{
$this->forge->dropTable('raw_att_log');
}
}

@ -0,0 +1,83 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateAttendanceSummary extends Migration
{
public function up()
{
$this->forge->addField([
'attlogsum_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
],
'paytrans_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
],
'pay_group_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'null' => false,
],
'employee_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
],
'company_issued_id' => [
'type' => 'VARCHAR',
'constraint' => 25,
],
'employee_name' => [
'type' => 'VARCHAR',
'constraint' => 255,
],
'att_work_days' => [
'type' => 'DECIMAL',
'constraint' => '12,4',
'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('attlogsum_id', true);
$this->forge->addForeignKey('paytrans_id', 'pay_trans', 'paytrans_id', 'CASCADE', 'RESTRICT');
$this->forge->addForeignKey('pay_group_id', 'pay_group', 'pay_group_id', 'CASCADE', 'RESTRICT');
$this->forge->createTable('att_log_summary');
}
public function down()
{
$this->forge->dropTable('att_log_summary');
}
}

@ -0,0 +1,21 @@
<?php
namespace App\Entities;
use CodeIgniter\Entity\Entity;
class AttendanceSummary extends Entity
{
protected $attributes = [
'attlogsum_id' => null,
'paytrans_id' => null,
'pay_group_id' => null,
'employee_id' => null,
'company_issued_id' => null,
'employee_name' => null,
'att_work_days' => null,
];
protected $datamap = [];
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
protected $casts = [];
}

@ -0,0 +1,24 @@
<?php
namespace App\Entities;
use CodeIgniter\Entity\Entity;
class RawAttLog extends Entity
{
protected $attributes = [
'company_issue_id' => null,
'log_date' => null,
'log_time' => null,
'ucol1' => null,
'log_type' => null,
'ucol2' => null,
'ucol3' => null,
'branch_code' => null,
'att_from' => null,
'att_to' => null,
];
protected $datamap = [];
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
protected $casts = [];
}

@ -15,6 +15,6 @@ class Settings extends Entity
'context' => null,
];
protected $datamap = [];
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
protected $dates = ['created_at', 'updated_at'];
protected $casts = [];
}

@ -0,0 +1,66 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class AttendanceSummaryModel extends Model
{
protected $table = 'att_log_summary';
protected $primaryKey = 'attlogsum_id';
protected $useAutoIncrement = true;
protected $returnType = \App\Entities\AttendanceSummary::class;
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = ['paytrans_id',
'pay_group_id',
'employee_id',
'company_issued_id',
'employee_name',
'att_work_days'];
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 addBatchData($data, $ignoreDuplicate = false)
{
$builder = $this->db->table('att_log_summary');
// ignore($ignoreDuplicate) will ignore duplicate data
return $builder->ignore($ignoreDuplicate)->insertBatch($data);
}
}

@ -7,7 +7,7 @@ use CodeIgniter\Model;
class PayrollTypeModel extends Model
{
protected $table = 'pay_type';
protected $primaryKey = 'id';
protected $primaryKey = 'paytype_id';
protected $useAutoIncrement = true;
protected $returnType = \App\Entities\PayrollType::class;
protected $useSoftDeletes = true;

@ -0,0 +1,72 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class RawAttLogModel extends Model
{
protected $table = 'raw_att_log';
protected $primaryKey = ['company_issued_id', 'log_date', 'log_time', 'log_type'];
protected $useAutoIncrement = false;
protected $returnType = \App\Entities\RawAttLog::class;
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = ['company_issued_id',
'log_date',
'log_time',
'ucol1',
'log_type',
'ucol2',
'ucol3',
'branch_code',
'att_from',
'att_to',];
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 = [];
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 addBatchData($data, $ignoreDuplicate = false)
{
$builder = $this->db->table('raw_att_log');
// ignore($ignoreDuplicate) will ignore duplicate data
return $builder->ignore($ignoreDuplicate)->insertBatch($data);
}
public function getEmployeeDaysCount($logDataFrom, $logDataTo)
{
$builder = $this->db->table('raw_att_log');
$builder->distinct()->select(['raw_att_log.company_issued_id', 'employee.employee_id', 'employee.last_name', 'employee.first_name', 'raw_att_log.log_date']);
$builder->join('employee', 'employee.company_issued_id = raw_att_log.company_issued_id');
return $builder->getWhere(['raw_att_log.log_date >='=>$logDataFrom, 'raw_att_log.log_date <='=>$logDataTo])->getResult();
}
}

@ -10,18 +10,18 @@ class SettingsModel extends Model
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = \App\Entities\Settings::class;
protected $useSoftDeletes = true;
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = ['class', 'key', 'value', 'type', 'context'];
protected bool $allowEmptyInserts = false;
// Dates
protected $useTimestamps = false;
protected $useTimestamps = true;
protected $dateFormat = 'datetime';
protected $createdField = 'created_at';
protected $updatedField = 'updated_at';
protected $deletedField = 'deleted_at';
//protected $deletedField = 'deleted_at';
// Validation
protected $validationRules = [];
@ -31,24 +31,12 @@ class SettingsModel extends Model
// Callbacks
protected $allowCallbacks = true;
protected $beforeInsert = ['assignCreatedAt'];
protected $beforeInsert = [];
protected $afterInsert = [];
protected $beforeUpdate = ['assignUpdatedAt'];
protected $beforeUpdate = [];
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;
}
}

@ -196,26 +196,40 @@
</p>
</a>
</li>
<?php endif; ?>
<?php if(auth()->user()->inGroup('admin', 'superadmin', 'hr', 'tk')): ?>
<li class="nav-header">TIMEKEEPING</li>
<li class="nav-item">
<a href="#" class="nav-link">
<i class="nav-icon fas fa-calendar-alt"></i>
<p>
Timekeeping
Raw Logs
<i class="right fas fa-angle-left"></i>
</p>
</a>
<ul class="nav nav-treeview">
<?php if(auth()->user()->can('tk.data-upload')): ?>
<li class="nav-item">
<a href="/tk/rawattlogupload" class="nav-link">
<i class="far fa-circle nav-icon"></i>
<p>
Attendance Uploading
</p>
</a>
</li>
<?php endif; ?>
<li class="nav-item">
<a href="/tk/rawattlog" class="nav-link">
<a href="/tk/attsummary" class="nav-link">
<i class="far fa-circle nav-icon"></i>
<p>
Upload from Biometrics
Attendance Summary
</p>
</a>
</li>
</ul>
</li>
<?php endif; ?>
<?php if(auth()->user()->inGroup('admin', 'superadmin', 'payroll')): ?>

@ -0,0 +1,191 @@
<!-- Extend area where template is defined -->
<?= $this->extend('templates/adminlte/generalcontent') ?>
<!-- .Extend -->
<!-- Title of the page -->
<?= $this->section('title') ?>TK Raw Log Management<?= $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') ?>Raw Attendance Log<?= $this->endSection() ?>
<!-- .Container title -->
<!-- Active breadcrumb -->
<?= $this->section('breadcrumbs') ?>
<li class="breadcrumb-item active">Raw Log</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">Payroll Group Information</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">List of Payroll Groups</h3>
</div>
<div class="card-body">
<form action="#" method="get">
<div class="row">
<div class="col-12 col-md-6">
<div class="form-group">
<label>Select Payroll Transaction</label>
<select class="form-control" name="paytrans_id">
<?php foreach($payrollTransactions as $payrollTransaction): ?>
<?php
if(isset($selectedData))
$selected = ($payrollTransaction->paytrans_id == $selectedData['paytrans_id']) ? 'selected' : '';
?>
<option value="<?= $payrollTransaction->paytrans_id ?>" <?= (isset($selected) ? $selected : '') ?>>Payroll from <?= $payrollTransaction->payroll_from ?> to <?= $payrollTransaction->payroll_to ?> [<?= $payrollTransaction->no_of_days ?> days]</option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="col-12 col-md-6">
<div class="form-group">
<label>Select Group</label>
<div class="input-group mb-3">
<select class="form-control select2 rounded-0" name="pay_group_id">
<?php foreach($payGroups as $payGroup): ?>
<?php
if(isset($selectedData))
$selected = ($payGroup->pay_group_id == $selectedData['pay_group_id']) ? 'selected' : '';
?>
<option value="<?= $payGroup->pay_group_id ?>" <?= (isset($selected) ? $selected : '') ?>>[<?= $payGroup->pay_group_code ?>] <?= $payGroup->pay_group_name ?></option>
<?php endforeach; ?>
</select>
<div class="input-group-append">
<button class="btn btn-info btn-flat">Get Attendance Log</button>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<?php if(isset($employeeWorkDayCount)): ?>
<div class="card">
<form action="/tk/attsumsave/<?= $selectedData['paytrans_id'] ?>/<?= $selectedData['pay_group_id'] ?>" method="post">
<div class="card-header">
<h3 class="card-title">List of Employee Work Day Count</h3>
</div>
<div class="card-body">
<div class="card-body">
<?php if(!$attendanceSummarySaved): ?>
<p>There is no summary yet. This record is from uploaded attendance log. Click on "Save this Summary" button to save the data.</p>
<?php endif; ?>
<?php if($attendanceSummarySaved): ?>
<p>Summary is saved already. If captured data is erronous, delete the saved data and recapture again.</p>
<?php endif; ?>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Employee ID</th>
<th>Name</th>
<th>Work Day Count</th>
</tr>
</thead>
<?php foreach($employeeWorkDayCount as $value): ?>
<tr>
<td>
<?= $value['company_issued_id'] ?>
<input type="hidden" name="emp_work_day_count[]" value="<?= $value['employee_id'].'|'.$value['company_issued_id'].'|'.$value['employee_name'].'|'.$value['att_work_days'] ?>">
</td>
<td><?= ($value['employee_name'] == '') ? 'Unkown ID' : $value['employee_name'] ?></td>
<td>
<?= $value['att_work_days'] ?>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
</div>
<div class="card-footer">
<?php if(!$attendanceSummarySaved): ?>
<button type="submit" class="btn btn-primary">Save This Summary</button>
<?php endif; ?>
<?php if($attendanceSummarySaved): ?>
<a class="btn btn-danger">Delete This Summary</a>
<?php endif; ?>
</div>
</form>
</div>
<?php endif; ?>
</div>
</div>
<?= $this->endSection() ?>
<!-- .Main content -->
<!-- Javascript -->
<?= $this->section('js') ?>
<script>
$(document).ready(function() {
});
</script>
<?= $this->endSection() ?>
<!-- .Javascript -->

@ -1,107 +0,0 @@
<!-- Extend area where template is defined -->
<?= $this->extend('templates/adminlte/generalcontent') ?>
<!-- .Extend -->
<!-- Title of the page -->
<?= $this->section('title') ?>Payroll Group<?= $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 Group<?= $this->endSection() ?>
<!-- .Container title -->
<!-- Active breadcrumb -->
<?= $this->section('breadcrumbs') ?>
<li class="breadcrumb-item active">Raw Log</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">Payroll Group Information</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">List of Payroll Groups</h3>
</div>
<div class="card-body">
<div class="card-body table-responsive p-0">
</div>
</div>
<div class="card-footer">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#mdlAddBranch">Add Payroll Group</button>
</div>
</div>
</div>
</div>
<?= $this->endSection() ?>
<!-- .Main content -->
<!-- Javascript -->
<?= $this->section('js') ?>
<script>
$(document).ready(function() {
});
</script>
<?= $this->endSection() ?>
<!-- .Javascript -->

@ -0,0 +1,183 @@
<!-- Extend area where template is defined -->
<?= $this->extend('templates/adminlte/generalcontent') ?>
<!-- .Extend -->
<!-- Title of the page -->
<?= $this->section('title') ?>TK Raw Log Upload<?= $this->endSection() ?>
<!-- .Title -->
<!-- CSS of the page -->
<?= $this->section('css') ?>
<!-- daterange picker -->
<link rel="stylesheet" href="<?= base_url() ?>adminlte/plugins/daterangepicker/daterangepicker.css">
<?= $this->endSection() ?>
<!-- .CSS -->
<!-- body attribute - class definition -->
<?= $this->section('bodyclass') ?>sidebar-mini<?= $this->endSection() ?>
<!-- .body attribute -->
<!-- Container title -->
<?= $this->section('containertitle') ?>Upload Raw Log<?= $this->endSection() ?>
<!-- .Container title -->
<!-- Active breadcrumb -->
<?= $this->section('breadcrumbs') ?>
<li class="breadcrumb-item active">Raw Log</li>
<?= $this->endSection() ?>
<!-- .Active breadcrumb -->
<!-- Main content -->
<?= $this->section('main') ?>
<!-- Modal Upload File -->
<div class="modal fade" id="mdlUploadFile">
<div class="modal-dialog">
<div class="modal-content">
<?php if($selectedBranch != null && $attFromTo != null) ?>
<form action="/tk/rawattlogupfile/<?= $selectedBranch . '/' . $attFrom . '/' . $attTo ?>" method="post" enctype="multipart/form-data">
<div class="card-header">
<h3 class="card-title">Attendance Log Uploading</h3>
</div>
<div class="card-body">
<div class="row">
<div class="col-12">
<div class="form-group">
<label for="txtAttendanceFile">Select File to Upload</label>
<div class="input-group">
<div class="custom-file">
<input type="file" class="custom-file-input" id="txtAttendanceFile" name="att_file">
<label class="custom-file-label" for="exampleInputxtAttendanceFiletFile">Choose file</label>
</div>
<!--
<div class="input-group-append">
<span class="input-group-text">Upload</span>
</div>
-->
</div>
</div>
</div>
</div>
</div>
<div class="card-footer">
<button class="btn btn-primary">Upload</button>
</div>
</form>
<?php ?>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="card">
<form action="#" method="get">
<div class="card-header">
<h3 class="card-title">Attendance Log Uploading</h3>
</div>
<div class="card-body">
<div class="row">
<div class="col-12 col-md-5">
<div class="form-group">
<label>Select Branch</label>
<select class="form-control" name="branch_code">
<?php
foreach($branches as $branch):
$selected = ($branch->branch_code == $selectedBranch) ? 'selected' : '';
?>
<option value="<?= $branch->branch_code ?>" <?= $selected ?>><?= $branch->branch_name ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="col-12 col-md-7">
<div class="form-group">
<label>Attendance Period:</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<i class="far fa-calendar-alt"></i>
</span>
</div>
<input type="text" class="form-control float-right" id="txtAttendanceFromTo" name="att_from_to" value="<?= $attFromTo ?>">
<input type="hidden" id="hdnAttendanceFrom" name="att_from" value="<?= $attFrom ?>">
<input type="hidden" id="hdnAttendanceTo" name="att_to" value="<?= $attTo ?>">
<div class="input-group-append">
<button class="btn btn-info btn-flat">Get Uploaded Log</button>
</div>
</div>
<!-- /.input group -->
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<?php if($selectedBranch != null && $attFromTo != null): ?>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3 class="card-title">Uploaded Attendance Log for Branch <?= $selectedBranch ?> from <?= $attFrom ?> to <?= $attTo ?></h3>
</div>
<div class="card-body">
<div class="card-body table-responsive p-0">
<?= $tblAttLog ?>
</div>
</div>
<div class="card-footer">
<button class="btn btn-primary" data-toggle="modal" data-target="#mdlUploadFile">Upload Attendance Log</button>
<a href="<?= base_url('tk/rawattlogdelete/'. $selectedBranch . '/' . $attFrom . '/' . $attTo . '/') ?>" onclick="return confirm('Are you sure you want to delete the data appeared on the list?')" class="btn btn-danger">Delete Data</a>
</div>
</div>
</div>
</div>
<?php endif; ?>
<?= $this->endSection() ?>
<!-- .Main content -->
<!-- Javascript -->
<?= $this->section('js') ?>
<!-- InputMask -->
<script src="<?= base_url() ?>adminlte/plugins/moment/moment.min.js"></script>
<script src="<?= base_url() ?>adminlte/plugins/inputmask/jquery.inputmask.min.js"></script>
<!-- date-range-picker -->
<script src="<?= base_url() ?>adminlte/plugins/daterangepicker/daterangepicker.js"></script>
<!-- bs-custom-file-input -->
<script src="<?= base_url() ?>adminlte/plugins/bs-custom-file-input/bs-custom-file-input.min.js"></script>
<script>
$(document).ready(function() {
bsCustomFileInput.init();
//Date range picker
$('#txtAttendanceFromTo').daterangepicker();
$("#txtAttendanceFromTo").on("change", function() {
var from = $(this).data('daterangepicker').startDate.format('YYYY-MM-DD');
var to = $(this).data('daterangepicker').endDate.format('YYYY-MM-DD');
$("#hdnAttendanceFrom").val(from);
$("#hdnAttendanceTo").val(to);
});
});
</script>
<?= $this->endSection() ?>
<!-- .Javascript -->
Loading…
Cancel
Save