diff --git a/Application/Timerecording/login.tpl.php b/Application/Timerecording/login.tpl.php index ea8dfb8..0a7094a 100755 --- a/Application/Timerecording/login.tpl.php +++ b/Application/Timerecording/login.tpl.php @@ -36,8 +36,8 @@ $head = $this->getData('head'); --input-border: rgba(166, 135, 232, .4); --input-border-active: rgba(166, 135, 232, .7); - --input-color: rgba(255, 255, 255, 0.7); - --input-color-active: rgba(255, 255, 255, 0.7); + --input-color: rgba(166, 135, 232, .6); + --input-color-active: rgba(166, 135, 232, .8); --input-icon-color: rgba(166, 135, 232, .6); --input-icon-color-active: rgba(166, 135, 232, 1); diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 82119cb..f37358e 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -180,10 +180,12 @@ final class ApiController extends Controller if ($element === null) { $this->fillJsonResponse($request, $response, NotificationLevel::ERROR, 'Session Element', 'You cannot create a session element for another person!', $element); + + return; } if ($element->getStatus() === ClockingStatus::END) { - $session = SessionMapper::get($element->getSession()->getId()); + $session = SessionMapper::get($element->session->getId()); $session->addSessionElement($element); SessionMapper::update($session); } diff --git a/Models/Session.php b/Models/Session.php index 0855f8f..14f7f0b 100755 --- a/Models/Session.php +++ b/Models/Session.php @@ -14,6 +14,8 @@ declare(strict_types=1); namespace Modules\HumanResourceTimeRecording\Models; +use Modules\HumanResourceManagement\Models\Employee; +use Modules\HumanResourceManagement\Models\NullEmployee; use phpOMS\Contract\ArrayableInterface; /** @@ -77,22 +79,22 @@ class Session implements \JsonSerializable, ArrayableInterface /** * Employee. * - * @var int|Employee + * @var Employee * @since 1.0.0 */ - private $employee = 0; + private Employee $employee; /** * Constructor. * - * @param int|Employee $employee Employee + * @param Employee $employee Employee * * @since 1.0.0 */ - public function __construct($employee = 0) + public function __construct(Employee $employee = null) { $this->start = new \DateTime('now'); - $this->employee = $employee; + $this->employee = $employee ?? new NullEmployee(); } /** @@ -110,11 +112,11 @@ class Session implements \JsonSerializable, ArrayableInterface /** * Get employee. * - * @return int|Employee + * @return Employee * * @since 1.0.0 */ - public function getEmployee() + public function getEmployee() : Employee { return $this->employee; } @@ -122,13 +124,13 @@ class Session implements \JsonSerializable, ArrayableInterface /** * Add a session element to the session * - * @param int|SessionElement $element Session element + * @param SessionElement $element Session element * * @return void * * @since 1.0.0 */ - public function addSessionElement($element) : void + public function addSessionElement(SessionElement $element) : void { if ($element->getStatus() === ClockingStatus::START) { foreach ($this->sessionElements as $e) { diff --git a/Models/SessionElement.php b/Models/SessionElement.php index 21126fd..c90008b 100755 --- a/Models/SessionElement.php +++ b/Models/SessionElement.php @@ -53,22 +53,22 @@ class SessionElement implements \JsonSerializable, ArrayableInterface /** * Session id this element belongs to * - * @var int|Session + * @var Session * @since 1.0.0 */ - private $session = 0; + public Session $session; /** * Constructor. * - * @param int $session Session id + * @param Session $session Session id * @param null|\DateTime $dt DateTime of the session element * * @since 1.0.0 */ - public function __construct($session = 0, \DateTime $dt = null) + public function __construct(Session $session = null, \DateTime $dt = null) { - $this->session = $session; + $this->session = $session ?? new NullSession(); $this->dt = $dt ?? new \DateTime('now'); } @@ -122,18 +122,6 @@ class SessionElement implements \JsonSerializable, ArrayableInterface $this->status = $status; } - /** - * Get session this element is for - * - * @return int|Session - * - * @since 1.0.0 - */ - public function getSession() - { - return $this->session; - } - /** * {@inheritdoc} */ @@ -143,7 +131,7 @@ class SessionElement implements \JsonSerializable, ArrayableInterface 'id' => $this->id, 'status' => $this->status, 'dt' => $this->dt, - 'session' => \is_int($this->session) ? $this->session : $this->session->getId(), + 'session' => $this->session->getId(), ]; }