phpcs fixes

This commit is contained in:
Dennis Eichhorn 2019-10-06 17:50:12 +02:00
parent 50b183de3e
commit 55f89cb385
18 changed files with 550 additions and 22 deletions

70
Admin/Install/db.json Normal file
View File

@ -0,0 +1,70 @@
{
"hr_timerecording_session": {
"name": "hr_timerecording_session",
"fields": {
"hr_timerecording_session_id": {
"name": "hr_timerecording_session_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"hr_timerecording_session_type": {
"name": "hr_timerecording_session_type",
"type": "TINYINT",
"null": false
},
"hr_timerecording_session_start": {
"name": "hr_timerecording_session_start",
"type": "DATETIME",
"null": false
},
"hr_timerecording_session_end": {
"name": "hr_timerecording_session_end",
"type": "DATETIME",
"null": false
},
"hr_timerecording_session_busy": {
"name": "hr_timerecording_session_busy",
"type": "DATETIME",
"null": false
},
"hr_timerecording_session_employee": {
"name": "hr_timerecording_session_employee",
"type": "INT",
"null": false,
"foreignTable": "hr_staff",
"foreignKey": "hr_staff_id"
}
}
},
"hr_timerecording_session_element": {
"name": "hr_timerecording_session_element",
"fields": {
"hr_timerecording_session_element_id": {
"name": "hr_timerecording_session_element_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"hr_timerecording_session_element_type": {
"name": "hr_timerecording_session_element_type",
"type": "TINYINT",
"null": false
},
"hr_timerecording_session_element_dt": {
"name": "hr_timerecording_session_element_dt",
"type": "DATETIME",
"null": false
},
"hr_timerecording_session_element_session": {
"name": "hr_timerecording_session_element_session",
"type": "INT",
"null": false,
"foreignTable": "hr_timerecording_session",
"foreignKey": "hr_timerecording_session_id"
}
}
}
}

View File

@ -0,0 +1,31 @@
<?php declare(strict_types=1);
use Modules\HumanResourceTimeRecording\Controller\TimerecordingController;
use Modules\HumanResourceTimeRecording\Models\PermissionState;
use phpOMS\Account\PermissionType;
use phpOMS\Router\RouteVerb;
return [
'^.*?$' => [
[
'dest' => '\Modules\HumanResourceTimeRecording\Controller\TimerecordingController:viewDashboard',
'verb' => RouteVerb::GET,
'permission' => [
'module' => TimerecordingController::MODULE_NAME,
'type' => PermissionType::READ,
'state' => PermissionState::DASHBOARD,
],
],
],
'^.*/timerecording/dashboard.*$' => [
[
'dest' => '\Modules\HumanResourceTimeRecording\Controller\TimerecordingController:viewDashboard',
'verb' => RouteVerb::GET,
'permission' => [
'module' => TimerecordingController::MODULE_NAME,
'type' => PermissionType::READ,
'state' => PermissionState::DASHBOARD,
],
],
],
];

7
Docs/Help/en/SUMMARY.md Normal file
View File

@ -0,0 +1,7 @@
# Table of Contents
* [Login]({%}&page=login)
* [Recording]({%}&page=recording)
* [Employee Dashboard]({%}&page=employee_dashboard)
* [Correction]({%}&page=correction)
* [Analysis]({%}&page=analysis)

0
Docs/Help/en/analysis.md Normal file
View File

View File

View File

View File

@ -0,0 +1,19 @@
# Introduction
The **HumanResourceTimeRecording** module is for handling time recording of employees working hours, vacations and sick days.
## Target Group
The target group for this module are employees and employers.
# Setup
The module can be installed through the integrated module downloader and installer or by uploading the module into the `Modules/` directory and executing the installation through the module installer.
The module is depending on the **HumanResourceManagement** module which provides most of the employee handling features.
# Features
* Track working hours
* Track vacations
* Track sick days

0
Docs/Help/en/login.md Normal file
View File

View File

View File

@ -26,8 +26,8 @@ use phpOMS\Stdlib\Base\Enum;
*/
abstract class ClockingStatus extends Enum
{
public const START = 1;
public const PAUSE = 2;
public const ON_THE_MOVE = 3;
public const END = 4;
public const START = 1;
public const PAUSE = 2;
public const CONTINUE = 3;
public const END = 4;
}

View File

@ -26,9 +26,10 @@ use phpOMS\Stdlib\Base\Enum;
*/
abstract class ClockingType extends Enum
{
public const OFFICE = 1;
public const HOME = 2;
public const REMOTE = 3;
public const VACATION = 4;
public const SICK = 5;
public const OFFICE = 1;
public const HOME = 2;
public const REMOTE = 3;
public const VACATION = 4;
public const SICK = 5;
public const ON_THE_MOVE = 6;
}

View File

@ -15,7 +15,7 @@ declare(strict_types=1);
namespace Modules\HumanResourceTimeRecording\Models;
/**
* Null model
* Session model
*
* @package Modules\HumanResourceTimeRecording\Models
* @license OMS License 1.0
@ -24,20 +24,175 @@ namespace Modules\HumanResourceTimeRecording\Models;
*/
class Session implements ArrayableInterface, \JsonSerializable
{
private $id = 0;
/**
* Session ID.
*
* @var int
* @since 1.0.0
*/
private int $id = 0;
/**
* Session start
*
* @var \DateTime
* @since 1.0.0
*/
private \DateTime $start;
/**
* Session end
*
* @var null|\DateTime
* @since 1.0.0
*/
private ?\DateTime $end = null;
/**
* Busy time.
*
* @var int
* @since 1.0.0
*/
private int $busy = 0;
/**
* Session type.
*
* @var int
* @since 1.0.0
*/
private int $type = ClockingType::OFFICE;
/**
* Session elements.
*
* @var array
* @since 1.0.0
*/
private array $sessionElements = [];
/**
* Employee.
*
* @var int|Employee
* @since 1.0.0
*/
private $employee = 0;
/**
* Constructor.
*
* @since 1.0.0
*/
public function __construct()
{
$this->start = new \DateTime('now');
}
/**
* Get id.
*
* @return int Account id
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* Add a session element to the session
*
* @param int|SessionElement $element Session element
*
* @return void
*
* @since 1.0.0
*/
public function addSessionElement($element) : void
{
$this->sessionElement[] = $element;
// todo: if quit element or pause element re-calculate busy time!
}
/**
* Get busy time
*
* @return int
*
* @since 1.0.0
*/
public function getBusy() : int
{
return $this->busy;
}
/**
* Get the session type
*
* @return int
*
* @since 1.0.0
*/
public function getType() : int
{
return $this->type;
}
/**
* Set the session type
*
* @param int $type Session type
*
* @return void
*
* @since 1.0.0
*/
public function setType(int $type) : void
{
$this->type = $type;
}
/**
* Return session start
*
* @return \DateTime
*
* @since 1.0.0
*/
public function getStart() : \DateTime
{
return $this->start;
}
/**
* Return session end
*
* @return null|\DateTime
*
* @since 1.0.0
*/
public function getEnd() : ?\DateTime
{
return $this->end;
}
/**
* {@inheritdoc}
*/
public function toArray() : array
{
return [
'id' => $this->id,
'id' => $this->id,
'start' => $this->start->format('Y-m-d H:i:s'),
'end' => $this->end === null ? null : $this->end->format('Y-m-d H:i:s'),
'busy' => $this->busy,
'type' => $this->type,
'employee' => $this->employee,
'elements' => $this->sessionElements,
];
}
@ -54,6 +209,6 @@ class Session implements ArrayableInterface, \JsonSerializable
*/
public function jsonSerialize()
{
eturn $this->toArray();
return $this->toArray();
}
}

View File

@ -15,7 +15,7 @@ declare(strict_types=1);
namespace Modules\HumanResourceTimeRecording\Models;
/**
* Null model
* Session element model
*
* @package Modules\HumanResourceTimeRecording\Models
* @license OMS License 1.0
@ -24,20 +24,112 @@ namespace Modules\HumanResourceTimeRecording\Models;
*/
class SessionElement implements ArrayableInterface, \JsonSerializable
{
private $id = 0;
/**
* Session element ID.
*
* @var int
* @since 1.0.0
*/
private int $id = 0;
/**
* Session element type.
*
* @var int
* @since 1.0.0
*/
private int $type = ClockingStatus::START;
/**
* DateTime
*
* @var \DateTime
* @since 1.0.0
*/
private \DateTime $dt;
/**
* Session id this element belongs to
*
* @var int
* @since 1.0.0
*/
private int $session = 0;
/**
* Constructor.
*
* @param int $session Session id
* @param null|\DateTiem $dt DateTime of the session element
*
* @since 1.0.0
*/
public function __construct(int $session = 0, \DateTime $dt = null)
{
$this->session = $session;
$this->dt = $dt ?? new \DateTime('now');
}
/**
* Get id.
*
* @return int Account id
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* Get the dt data
*
* @return \DateTime
*
* @since 1.0.0
*/
public function getDatetime() : \DateTime
{
return $this->dt;
}
/**
* Get the session element type
*
* @return int
*
* @since 1.0.0
*/
public function getType() : int
{
return $this->type;
}
/**
* Set the session element type
*
* @param int $type Session element type
*
* @return void
*
* @since 1.0.0
*/
public function setType(int $type) : void
{
$this->type = $type;
}
/**
* {@inheritdoc}
*/
public function toArray() : array
{
return [
'id' => $this->id,
'id' => $this->id,
'type' => $this->type,
'dt' => $this->dt->format('Y-m-d H:i:s'),
'sesseion' => $this->session,
];
}
@ -54,6 +146,6 @@ class SessionElement implements ArrayableInterface, \JsonSerializable
*/
public function jsonSerialize()
{
eturn $this->toArray();
return $this->toArray();
}
}

View File

@ -1 +1,58 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\HumanResourceTimeRecording\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\HumanResourceTimeRecording\Models;
use phpOMS\DataStorage\Database\DataMapperAbstract;
/**
* Mapper class.
*
* @package Modules\HumanResourceTimeRecording\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class SessionElementMapper extends DataMapperAbstract
{
/**
* Columns.
*
* @var array<string, array<string, bool|string>>
* @since 1.0.0
*/
protected static array $columns = [
'hr_timerecording_session_element_id' => ['name' => 'hr_timerecording_session_element_id', 'type' => 'int', 'internal' => 'id'],
'hr_timerecording_session_element_type' => ['name' => 'hr_timerecording_session_element_type', 'type' => 'int', 'internal' => 'type'],
'hr_timerecording_session_element_dt' => ['name' => 'hr_timerecording_session_element_dt', 'type' => 'DateTime', 'internal' => 'dt'],
'hr_timerecording_session_element_session' => ['name' => 'hr_timerecording_session_element_session', 'type' => 'int', 'internal' => 'session'],
];
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
protected static string $table = 'hr_timerecording_session_element';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'hr_timerecording_session_element_id';
}

View File

@ -1 +1,89 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\HumanResourceTimeRecording\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\HumanResourceTimeRecording\Models;
use Modules\HumanResourceManagement\Models\EmployeeMapper;
use phpOMS\DataStorage\Database\DataMapperAbstract;
/**
* Mapper class.
*
* @package Modules\HumanResourceTimeRecording\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class SessionMapper extends DataMapperAbstract
{
/**
* Columns.
*
* @var array<string, array<string, bool|string>>
* @since 1.0.0
*/
protected static array $columns = [
'hr_timerecording_session_id' => ['name' => 'hr_timerecording_session_id', 'type' => 'int', 'internal' => 'id'],
'hr_timerecording_session_type' => ['name' => 'hr_timerecording_session_type', 'type' => 'int', 'internal' => 'type'],
'hr_timerecording_session_start' => ['name' => 'hr_timerecording_session_start', 'type' => 'DateTime', 'internal' => 'start'],
'hr_timerecording_session_end' => ['name' => 'hr_timerecording_session_end', 'type' => 'DateTime', 'internal' => 'end'],
'hr_timerecording_session_busy' => ['name' => 'hr_timerecording_session_busy', 'type' => 'int', 'internal' => 'busy'],
'hr_timerecording_session_employee' => ['name' => 'hr_timerecording_session_employee', 'type' => 'int', 'internal' => 'employee'],
];
/**
* Has many relation.
*
* @var array<string, array<string, null|string>>
* @since 1.0.0
*/
protected static array $hasMany = [
'sessionElements' => [
'mapper' => SessionElementMapper::class,
'table' => 'hr_timerecording_session_element',
'dst' => 'hr_timerecording_session_element_session',
'src' => null,
],
];
/**
* Belongs to.
*
* @var array<string, array<string, string>>
* @since 1.0.0
*/
protected static array $belongsTo = [
'employee' => [
'mapper' => EmployeeMapper::class,
'src' => 'hr_timerecording_session_employee',
],
];
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
protected static string $table = 'hr_timerecording_session';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'hr_timerecording_session_id';
}

View File

@ -1,4 +1,4 @@
<?php declare(strict_types=1);
<?php
/**
* Orange Management
*
@ -10,6 +10,8 @@
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
return ['Navigation' => [
'Create' => 'Create',
'List' => 'List',

View File

@ -1,4 +1,4 @@
<?php declare(strict_types=1);
<?php
/**
* Orange Management
*
@ -10,16 +10,19 @@
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
return ['HumanResourceTimeRecording' => [
'CS0' => 'Start',
'CS1' => 'Pause',
'CS2' => 'On the move',
'CS2' => 'Continue',
'CS3' => 'End',
'CT0' => 'Office',
'CT1' => 'Remote',
'CT2' => 'Home',
'CT3' => 'Vacation',
'CT4' => 'Sick',
'CT5' => 'On the move',
'End' => 'End',
'Start' => 'Start',
'Status' => 'Status',

View File

@ -1,4 +1,4 @@
<?php declare(strict_types=1);
<?php
/**
* Orange Management
*
@ -10,6 +10,8 @@
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
use \Modules\HumanResourceTimeRecording\Models\ClockingType;
use \Modules\HumanResourceTimeRecording\Models\ClockingStatus;
@ -30,13 +32,14 @@ echo $this->getData('nav')->render(); ?>
<option value="<?= ClockingType::HOME; ?>"><?= $this->getHtml('CT2') ?>
<option value="<?= ClockingType::VACATION; ?>"><?= $this->getHtml('CT3') ?>
<option value="<?= ClockingType::SICK; ?>"><?= $this->getHtml('CT4') ?>
<option value="<?= ClockingType::ON_THE_MOVE; ?>"><?= $this->getHtml('CT5') ?>
</select>
<tr><td><label for="iStatus"><?= $this->getHtml('Status') ?></label>
<tr><td>
<select id="iStatus" name="Status">
<option value="<?= ClockingStatus::START; ?>"><?= $this->getHtml('CS0') ?>
<option value="<?= ClockingStatus::PAUSE; ?>"><?= $this->getHtml('CS1') ?>
<option value="<?= ClockingStatus::ON_THE_MOVE; ?>"><?= $this->getHtml('CS2') ?>
<option value="<?= ClockingStatus::CONTINUE; ?>"><?= $this->getHtml('CS2') ?>
<option value="<?= ClockingStatus::END; ?>"><?= $this->getHtml('CS3') ?>
</select>
<tr><td>