make id public, organigram impl. media password/encryption, settings bug fix, Money->FloatInt change, ...

This commit is contained in:
Dennis Eichhorn 2023-05-06 11:42:06 +00:00
parent eeef102b27
commit 9fd9b0f462
13 changed files with 30 additions and 28 deletions

View File

@ -176,7 +176,7 @@ final class Application
$account = $this->loadAccount($request); $account = $this->loadAccount($request);
if (!($account instanceof NullAccount)) { if ($account->id > 0) {
$response->header->l11n = $account->l11n; $response->header->l11n = $account->l11n;
} elseif ($this->app->sessionManager->get('language') !== null } elseif ($this->app->sessionManager->get('language') !== null
&& $response->header->l11n->getLanguage() !== $this->app->sessionManager->get('language') && $response->header->l11n->getLanguage() !== $this->app->sessionManager->get('language')
@ -186,6 +186,8 @@ final class Application
$this->app->sessionManager->get('language'), $this->app->sessionManager->get('language'),
$this->app->sessionManager->get('country') ?? '*' $this->app->sessionManager->get('country') ?? '*'
); );
} else {
$this->app->setResponseLanguage($request, $response, $this->config);
} }
UriFactory::setQuery('/lang', $response->getLanguage()); UriFactory::setQuery('/lang', $response->getLanguage());
@ -201,7 +203,7 @@ final class Application
$this->initResponseHead($head, $request, $response); $this->initResponseHead($head, $request, $response);
/* Handle not logged in */ /* Handle not logged in */
if ($account->getId() < 1) { if ($account->id < 1) {
$this->createLoggedOutResponse($response, $head, $pageView); $this->createLoggedOutResponse($response, $head, $pageView);
return; return;

View File

@ -100,7 +100,7 @@ final class ApiController extends Controller
$type = $request->getDataInt('type') ?? ClockingType::OFFICE; $type = $request->getDataInt('type') ?? ClockingType::OFFICE;
$status = $request->getDataInt('status') ?? ClockingStatus::START; $status = $request->getDataInt('status') ?? ClockingStatus::START;
if ($employee instanceof NullEmployee) { if ($employee->id === 0) {
return null; return null;
} }
@ -219,7 +219,7 @@ final class ApiController extends Controller
$session = SessionMapper::get()->where('id', (int) $request->getData('session'))->execute(); $session = SessionMapper::get()->where('id', (int) $request->getData('session'))->execute();
// cannot create session element for none existing session // cannot create session element for none existing session
if ($session === null || $session instanceof NullSession) { if ($session->id === 0) {
return null; return null;
} }

View File

@ -78,7 +78,7 @@ final class BackendController extends Controller implements DashboardElementInte
->execute(); ->execute();
/** @var \Modules\HumanResourceTimeRecording\Models\Session $lastOpenSession */ /** @var \Modules\HumanResourceTimeRecording\Models\Session $lastOpenSession */
$lastOpenSession = SessionMapper::getMostPlausibleOpenSessionForEmployee($employee->getId()); $lastOpenSession = SessionMapper::getMostPlausibleOpenSessionForEmployee($employee->id);
$start = new SmartDateTime('now'); $start = new SmartDateTime('now');
$start = $start->getEndOfDay(); $start = $start->getEndOfDay();
@ -86,7 +86,7 @@ final class BackendController extends Controller implements DashboardElementInte
$limit->smartModify(0, -2, 0); $limit->smartModify(0, -2, 0);
$list = SessionMapper::getAll() $list = SessionMapper::getAll()
->where('employee', $employee->getId()) ->where('employee', $employee->id)
->where('createdAt', $start->format('Y-m-d H:i:s'), '<=') ->where('createdAt', $start->format('Y-m-d H:i:s'), '<=')
->sort('id', OrderType::DESC) ->sort('id', OrderType::DESC)
->execute(); ->execute();
@ -126,7 +126,7 @@ final class BackendController extends Controller implements DashboardElementInte
->where('profile/account', $request->header->account) ->where('profile/account', $request->header->account)
->execute(); ->execute();
if ($session->employee->getId() !== $employee->getId()) { if ($session->employee->id !== $employee->id) {
$view->addData('session', new NullSession()); $view->addData('session', new NullSession());
} else { } else {
$view->addData('session', $session); $view->addData('session', $session);

View File

@ -33,7 +33,7 @@ class Session implements \JsonSerializable
* @var int * @var int
* @since 1.0.0 * @since 1.0.0
*/ */
protected int $id = 0; public int $id = 0;
/** /**
* Session start * Session start
@ -65,7 +65,7 @@ class Session implements \JsonSerializable
* @var int * @var int
* @since 1.0.0 * @since 1.0.0
*/ */
private int $type = ClockingType::OFFICE; public int $type = ClockingType::OFFICE;
/** /**
* Session elements. * Session elements.

View File

@ -30,7 +30,7 @@ class SessionElement implements \JsonSerializable
* @var int * @var int
* @since 1.0.0 * @since 1.0.0
*/ */
protected int $id = 0; public int $id = 0;
/** /**
* Session element status. * Session element status.
@ -38,7 +38,7 @@ class SessionElement implements \JsonSerializable
* @var int * @var int
* @since 1.0.0 * @since 1.0.0
*/ */
private int $status = ClockingStatus::START; public int $status = ClockingStatus::START;
/** /**
* DateTime * DateTime

View File

@ -68,7 +68,7 @@ echo $this->getData('nav')->render(); ?>
<option value="<?= ClockingStatus::END; ?>"<?= $status === ClockingStatus::CONTINUE ? ' selected' : ''; ?>><?= $this->getHtml('CS4'); ?> <option value="<?= ClockingStatus::END; ?>"<?= $status === ClockingStatus::CONTINUE ? ' selected' : ''; ?>><?= $this->getHtml('CS4'); ?>
</select> </select>
<tr><td> <tr><td>
<input type="hidden" name="session" value="<?= $lastOpenSession !== null ? $lastOpenSession->getId() : ''; ?>"> <input type="hidden" name="session" value="<?= $lastOpenSession !== null ? $lastOpenSession->id : ''; ?>">
<input type="submit" id="iclockingButton" name="clockingButton" value="<?= $this->getHtml('Submit', '0', '0'); ?>" data-action='[ <input type="submit" id="iclockingButton" name="clockingButton" value="<?= $this->getHtml('Submit', '0', '0'); ?>" data-action='[
{ {
"key": 1, "listener": "click", "action": [ "key": 1, "listener": "click", "action": [
@ -204,7 +204,7 @@ echo $this->getData('nav')->render(); ?>
<?php <?php
$count = 0; $count = 0;
foreach ($sessions as $session) : ++$count; foreach ($sessions as $session) : ++$count;
$url = UriFactory::build('{/base}/private/timerecording/session?{?}&id=' . $session->getId()); $url = UriFactory::build('{/base}/private/timerecording/session?{?}&id=' . $session->id);
?> ?>
<tr data-href="<?= $url; ?>"> <tr data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"> <td><a href="<?= $url; ?>">

View File

@ -105,7 +105,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
$request->header->account = 1; $request->header->account = 1;
$this->module->apiSessionCreate($request, $response); $this->module->apiSessionCreate($request, $response);
self::assertGreaterThan(0, $sId = $response->get('')['response']->getId()); self::assertGreaterThan(0, $sId = $response->get('')['response']->id);
$response = new HttpResponse(); $response = new HttpResponse();
$request = new HttpRequest(new HttpUri('')); $request = new HttpRequest(new HttpUri(''));
@ -115,7 +115,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
$request->setData('status', ClockingStatus::END); $request->setData('status', ClockingStatus::END);
$this->module->apiSessionElementCreate($request, $response); $this->module->apiSessionElementCreate($request, $response);
self::assertGreaterThan(0, $response->get('')['response']->getId()); self::assertGreaterThan(0, $response->get('')['response']->id);
} }
/** /**

View File

@ -37,6 +37,6 @@ final class NullSessionElementTest extends \PHPUnit\Framework\TestCase
public function testId() : void public function testId() : void
{ {
$null = new NullSessionElement(2); $null = new NullSessionElement(2);
self::assertEquals(2, $null->getId()); self::assertEquals(2, $null->id);
} }
} }

View File

@ -37,6 +37,6 @@ final class NullSessionTest extends \PHPUnit\Framework\TestCase
public function testId() : void public function testId() : void
{ {
$null = new NullSession(2); $null = new NullSession(2);
self::assertEquals(2, $null->getId()); self::assertEquals(2, $null->id);
} }
} }

View File

@ -33,12 +33,12 @@ final class SessionElementMapperTest extends \PHPUnit\Framework\TestCase
$element = new SessionElement(new Session(new NullEmployee(1)), new \DateTime('now')); $element = new SessionElement(new Session(new NullEmployee(1)), new \DateTime('now'));
$id = SessionElementMapper::create()->execute($element); $id = SessionElementMapper::create()->execute($element);
self::assertGreaterThan(0, $element->getId()); self::assertGreaterThan(0, $element->id);
self::assertEquals($id, $element->getId()); self::assertEquals($id, $element->id);
$elementR = SessionElementMapper::get()->with('session')->with('employee')->where('id', $element->getId())->execute(); $elementR = SessionElementMapper::get()->with('session')->with('employee')->where('id', $element->id)->execute();
self::assertEquals($element->datetime->format('Y-m-d'), $elementR->datetime->format('Y-m-d')); self::assertEquals($element->datetime->format('Y-m-d'), $elementR->datetime->format('Y-m-d'));
self::assertEquals($element->getStatus(), $elementR->getStatus()); self::assertEquals($element->getStatus(), $elementR->getStatus());
self::assertEquals($element->session->employee->getId(), $elementR->session->employee->getId()); self::assertEquals($element->session->employee->id, $elementR->session->employee->id);
} }
} }

View File

@ -39,8 +39,8 @@ final class SessionElementTest extends \PHPUnit\Framework\TestCase
*/ */
public function testDefault() : void public function testDefault() : void
{ {
self::assertEquals(0, $this->element->getId()); self::assertEquals(0, $this->element->id);
self::assertEquals(0, $this->element->session->getId()); self::assertEquals(0, $this->element->session->id);
self::assertInstanceOf('\DateTime', $this->element->datetime); self::assertInstanceOf('\DateTime', $this->element->datetime);
self::assertEquals(ClockingStatus::START, $this->element->getStatus()); self::assertEquals(ClockingStatus::START, $this->element->getStatus());
} }

View File

@ -39,16 +39,16 @@ final class SessionMapperTest extends \PHPUnit\Framework\TestCase
$session->addSessionElement($element); $session->addSessionElement($element);
$id = SessionMapper::create()->execute($session); $id = SessionMapper::create()->execute($session);
self::assertGreaterThan(0, $session->getId()); self::assertGreaterThan(0, $session->id);
self::assertEquals($id, $session->getId()); self::assertEquals($id, $session->id);
$sessionR = SessionMapper::get()->where('id', $session->getId())->execute(); $sessionR = SessionMapper::get()->where('id', $session->id)->execute();
self::assertEquals($session->getType(), $sessionR->getType()); self::assertEquals($session->getType(), $sessionR->getType());
self::assertGreaterThan(0, \count(SessionMapper::getLastSessionsFromAllEmployees())); self::assertGreaterThan(0, \count(SessionMapper::getLastSessionsFromAllEmployees()));
self::assertNull(SessionMapper::getMostPlausibleOpenSessionForEmployee(9999)); self::assertNull(SessionMapper::getMostPlausibleOpenSessionForEmployee(9999));
// @todo implement // @todo implement
// self::assertGreaterThan(0, SessionMapper::getMostPlausibleOpenSessionForEmployee(1)->getId()); // self::assertGreaterThan(0, SessionMapper::getMostPlausibleOpenSessionForEmployee(1)->id);
} }
} }

View File

@ -40,7 +40,7 @@ final class SessionTest extends \PHPUnit\Framework\TestCase
*/ */
public function testDefault() : void public function testDefault() : void
{ {
self::assertEquals(0, $this->session->getId()); self::assertEquals(0, $this->session->id);
self::assertEquals(0, $this->session->getBusy()); self::assertEquals(0, $this->session->getBusy());
self::assertEquals(0, $this->session->getBreak()); self::assertEquals(0, $this->session->getBreak());
self::assertEquals([], $this->session->getSessionElements()); self::assertEquals([], $this->session->getSessionElements());