From 55f89cb385e93e15a1f4cc0c6e3e186bb0ae827b Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 6 Oct 2019 17:50:12 +0200 Subject: [PATCH] phpcs fixes --- Admin/Install/db.json | 70 ++++++++++ Admin/Routes/Web/Timerecording.php | 31 ++++ Docs/Help/en/SUMMARY.md | 7 + Docs/Help/en/analysis.md | 0 Docs/Help/en/correction.md | 0 Docs/Help/en/employee_dashboard.md | 0 Docs/Help/en/introduction.md | 19 +++ Docs/Help/en/login.md | 0 Docs/Help/en/recording.md | 0 Models/ClockingStatus.php | 8 +- Models/ClockingType.php | 11 +- Models/Session.php | 163 +++++++++++++++++++++- Models/SessionElement.php | 100 ++++++++++++- Models/SessionElementMapper.php | 57 ++++++++ Models/SessionMapper.php | 88 ++++++++++++ Theme/Backend/Lang/Navigation.en.lang.php | 4 +- Theme/Backend/Lang/en.lang.php | 7 +- Theme/Backend/dashboard.tpl.php | 7 +- 18 files changed, 550 insertions(+), 22 deletions(-) create mode 100644 Admin/Install/db.json create mode 100644 Admin/Routes/Web/Timerecording.php create mode 100644 Docs/Help/en/SUMMARY.md create mode 100644 Docs/Help/en/analysis.md create mode 100644 Docs/Help/en/correction.md create mode 100644 Docs/Help/en/employee_dashboard.md create mode 100644 Docs/Help/en/introduction.md create mode 100644 Docs/Help/en/login.md create mode 100644 Docs/Help/en/recording.md diff --git a/Admin/Install/db.json b/Admin/Install/db.json new file mode 100644 index 0000000..ad67b20 --- /dev/null +++ b/Admin/Install/db.json @@ -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" + } + } + } +} \ No newline at end of file diff --git a/Admin/Routes/Web/Timerecording.php b/Admin/Routes/Web/Timerecording.php new file mode 100644 index 0000000..ae44f6a --- /dev/null +++ b/Admin/Routes/Web/Timerecording.php @@ -0,0 +1,31 @@ + [ + [ + '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, + ], + ], + ], +]; diff --git a/Docs/Help/en/SUMMARY.md b/Docs/Help/en/SUMMARY.md new file mode 100644 index 0000000..0df2202 --- /dev/null +++ b/Docs/Help/en/SUMMARY.md @@ -0,0 +1,7 @@ +# Table of Contents + +* [Login]({%}&page=login) +* [Recording]({%}&page=recording) +* [Employee Dashboard]({%}&page=employee_dashboard) +* [Correction]({%}&page=correction) +* [Analysis]({%}&page=analysis) \ No newline at end of file diff --git a/Docs/Help/en/analysis.md b/Docs/Help/en/analysis.md new file mode 100644 index 0000000..e69de29 diff --git a/Docs/Help/en/correction.md b/Docs/Help/en/correction.md new file mode 100644 index 0000000..e69de29 diff --git a/Docs/Help/en/employee_dashboard.md b/Docs/Help/en/employee_dashboard.md new file mode 100644 index 0000000..e69de29 diff --git a/Docs/Help/en/introduction.md b/Docs/Help/en/introduction.md new file mode 100644 index 0000000..5d9c11f --- /dev/null +++ b/Docs/Help/en/introduction.md @@ -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 \ No newline at end of file diff --git a/Docs/Help/en/login.md b/Docs/Help/en/login.md new file mode 100644 index 0000000..e69de29 diff --git a/Docs/Help/en/recording.md b/Docs/Help/en/recording.md new file mode 100644 index 0000000..e69de29 diff --git a/Models/ClockingStatus.php b/Models/ClockingStatus.php index 0737b3a..6bc5ae1 100644 --- a/Models/ClockingStatus.php +++ b/Models/ClockingStatus.php @@ -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; } diff --git a/Models/ClockingType.php b/Models/ClockingType.php index 79bf525..dc53f98 100644 --- a/Models/ClockingType.php +++ b/Models/ClockingType.php @@ -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; } diff --git a/Models/Session.php b/Models/Session.php index bcd5a36..445db01 100644 --- a/Models/Session.php +++ b/Models/Session.php @@ -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(); } } diff --git a/Models/SessionElement.php b/Models/SessionElement.php index 41e8659..c1ef09a 100644 --- a/Models/SessionElement.php +++ b/Models/SessionElement.php @@ -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(); } } diff --git a/Models/SessionElementMapper.php b/Models/SessionElementMapper.php index b3d9bbc..6133481 100644 --- a/Models/SessionElementMapper.php +++ b/Models/SessionElementMapper.php @@ -1 +1,58 @@ > + * @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'; +} diff --git a/Models/SessionMapper.php b/Models/SessionMapper.php index b3d9bbc..a7c59f6 100644 --- a/Models/SessionMapper.php +++ b/Models/SessionMapper.php @@ -1 +1,89 @@ > + * @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> + * @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> + * @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'; +} diff --git a/Theme/Backend/Lang/Navigation.en.lang.php b/Theme/Backend/Lang/Navigation.en.lang.php index 032e04e..662b952 100644 --- a/Theme/Backend/Lang/Navigation.en.lang.php +++ b/Theme/Backend/Lang/Navigation.en.lang.php @@ -1,4 +1,4 @@ - [ 'Create' => 'Create', 'List' => 'List', diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php index 7048d1f..4513a06 100644 --- a/Theme/Backend/Lang/en.lang.php +++ b/Theme/Backend/Lang/en.lang.php @@ -1,4 +1,4 @@ - [ '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', diff --git a/Theme/Backend/dashboard.tpl.php b/Theme/Backend/dashboard.tpl.php index 7aae098..a6f198b 100644 --- a/Theme/Backend/dashboard.tpl.php +++ b/Theme/Backend/dashboard.tpl.php @@ -1,4 +1,4 @@ -getData('nav')->render(); ?>