This commit is contained in:
Dennis Eichhorn 2023-05-30 13:52:26 +00:00
commit 94a9879877
11 changed files with 41 additions and 56 deletions

View File

@ -108,7 +108,7 @@ final class Application
$pageView = new TimerecordingView($this->app->l11nManager, $request, $response);
$head = new Head();
$pageView->setData('head', $head);
$pageView->data['head'] = $head;
$response->set('Content', $pageView);
/* Timerecording only allows GET */
@ -178,7 +178,7 @@ final class Application
if ($account->id > 0) {
$response->header->l11n = $account->l11n;
} elseif ($this->app->sessionManager->get('language') !== null
&& $response->header->l11n->getLanguage() !== $this->app->sessionManager->get('language')
&& $response->header->l11n->language !== $this->app->sessionManager->get('language')
) {
$response->header->l11n
->loadFromLanguage(
@ -189,14 +189,14 @@ final class Application
$this->app->setResponseLanguage($request, $response, $this->config);
}
UriFactory::setQuery('/lang', $response->getLanguage());
UriFactory::setQuery('/lang', $response->header->l11n->language);
$this->loadLanguageFromPath(
$response->getLanguage(),
__DIR__ . '/lang/' . $response->getLanguage() . '.lang.php'
$response->header->l11n->language,
__DIR__ . '/lang/' . $response->header->l11n->language . '.lang.php'
);
$response->header->set('content-language', $response->getLanguage(), true);
$response->header->set('content-language', $response->header->l11n->language, true);
/* Create html head */
$this->initResponseHead($head, $request, $response);
@ -270,8 +270,8 @@ final class Application
$response->header->status = RequestStatusCode::R_406;
$pageView->setTemplate('/Web/Timerecording/Error/406');
$this->loadLanguageFromPath(
$response->getLanguage(),
__DIR__ . '/Error/lang/' . $response->getLanguage() . '.lang.php'
$response->header->l11n->language,
__DIR__ . '/Error/lang/' . $response->header->l11n->language . '.lang.php'
);
}
@ -290,8 +290,8 @@ final class Application
$response->header->status = RequestStatusCode::R_503;
$pageView->setTemplate('/Web/Timerecording/Error/503');
$this->loadLanguageFromPath(
$response->getLanguage(),
__DIR__ . '/Error/lang/' . $response->getLanguage() . '.lang.php'
$response->header->l11n->language,
__DIR__ . '/Error/lang/' . $response->header->l11n->language . '.lang.php'
);
}
@ -349,8 +349,8 @@ final class Application
$response->header->status = RequestStatusCode::R_403;
$pageView->setTemplate('/Web/Timerecording/Error/403');
$this->loadLanguageFromPath(
$response->getLanguage(),
__DIR__ . '/Error/lang/' . $response->getLanguage() . '.lang.php'
$response->header->l11n->language,
__DIR__ . '/Error/lang/' . $response->header->l11n->language . '.lang.php'
);
}
@ -433,7 +433,7 @@ final class Application
private function createDefaultPageView(HttpRequest $request, HttpResponse $response, TimerecordingView $pageView) : void
{
$pageView->setOrganizations(UnitMapper::getAll()->execute());
$pageView->setProfile(ProfileMapper::get()->where('account', $request->header->account)->execute());
$pageView->profile = ProfileMapper::get()->where('account', $request->header->account)->execute();
$pageView->setData('nav', $this->getNavigation($request, $response));
$pageView->setTemplate('/Web/Timerecording/index');

View File

@ -44,7 +44,7 @@ class TimerecordingView extends View
* @var Profile
* @since 1.0.0
*/
protected $profile = null;
public $profile = null;
/**
* Organizations.
@ -69,21 +69,6 @@ class TimerecordingView extends View
$this->nav = $nav;
}
/**
* Set user profile.
*
* @param Profile $profile user account
*
* @return void
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function setProfile(Profile $profile) : void
{
$this->profile = $profile;
}
/**
* Get profile image
*

View File

@ -18,13 +18,13 @@ $nav->setTemplate('/Modules/Navigation/Theme/Backend/top');
$top = $nav->render();
/** @var phpOMS\Model\Html\Head $head */
$head = $this->getData('head');
$head = $this->head;
/** @var array $dispatch */
$dispatch = $this->getData('dispatch') ?? [];
?>
<!DOCTYPE HTML>
<html lang="<?= $this->printHtml($this->response->getLanguage()); ?>">
<html lang="<?= $this->printHtml($this->response->header->l11n->language); ?>">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

View File

@ -23,10 +23,10 @@ declare(strict_types=1);
* @version 1.0.0
* @link https://jingga.app
*/
$head = $this->getData('head');
$head = $this->head;
?>
<!DOCTYPE HTML>
<html lang="<?= $this->printHtml($this->response->getLanguage()); ?>">
<html lang="<?= $this->printHtml($this->response->header->l11n->language); ?>">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">

View File

@ -142,7 +142,7 @@ final class ApiController extends Controller
}
if (!empty($val = $this->validateSessionElementCreate($request))) {
$response->set($request->uri->__toString(), new FormValidation($val));
$response->data[$request->uri->__toString()] = new FormValidation($val);
$response->header->status = RequestStatusCode::R_400;
return;

View File

@ -43,11 +43,11 @@ final class BackendController extends Controller implements DashboardElementInte
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/HumanResourceTimeRecording/Theme/Backend/dashboard');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1006301001, $request, $response));
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1006301001, $request, $response);
/** @var \Modules\HumanResourceTimeRecording\Models\Session[] $list */
$list = SessionMapper::getLastSessionsFromAllEmployees();
$view->addData('sessions', $list);
$view->data['sessions'] = $list;
return $view;
}
@ -68,7 +68,7 @@ final class BackendController extends Controller implements DashboardElementInte
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/HumanResourceTimeRecording/Theme/Backend/private-dashboard');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1006303001, $request, $response));
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1006303001, $request, $response);
/** @var \Modules\HumanResourceManagement\Models\Employee $employee */
$employee = EmployeeMapper::get()
@ -91,9 +91,9 @@ final class BackendController extends Controller implements DashboardElementInte
->sort('id', OrderType::DESC)
->execute();
$view->addData('sessions', $list);
$view->addData('lastSession', $lastOpenSession);
$view->addData('date', $limit);
$view->data['sessions'] = $list;
$view->data['lastSession'] = $lastOpenSession;
$view->data['date'] = $limit;
return $view;
}
@ -114,7 +114,7 @@ final class BackendController extends Controller implements DashboardElementInte
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/HumanResourceTimeRecording/Theme/Backend/private-session');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1006303001, $request, $response));
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1006303001, $request, $response);
/** @var \Modules\HumanResourceTimeRecording\Models\Session $session */
$session = SessionMapper::get()->where('id', (int) $request->getData('id'))->execute();
@ -127,9 +127,9 @@ final class BackendController extends Controller implements DashboardElementInte
->execute();
if ($session->employee->id !== $employee->id) {
$view->addData('session', new NullSession());
$view->data['session'] = new NullSession();
} else {
$view->addData('session', $session);
$view->data['session'] = $session;
}
return $view;
@ -151,11 +151,11 @@ final class BackendController extends Controller implements DashboardElementInte
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/HumanResourceTimeRecording/Theme/Backend/hr-stats');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1006301001, $request, $response));
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1006301001, $request, $response);
/** @var \Modules\HumanResourceTimeRecording\Models\Session[] $list */
$list = SessionMapper::getLastSessionsFromAllEmployees();
$view->addData('sessions', $list);
$view->data['sessions'] = $list;
return $view;
}

View File

@ -47,10 +47,10 @@ final class TimerecordingController extends Controller
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/HumanResourceTimeRecording/Theme/Timeterminal/overview');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1006301001, $request, $response));
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1006301001, $request, $response);
$list = SessionMapper::getAll()->sort('id', OrderType::DESC)->limit(50)->execute();
$view->addData('sessions', $list);
$view->data['sessions'] = $list;
return $view;
}

View File

@ -12,9 +12,9 @@
*/
declare(strict_types=1);
$sessions = $this->getData('sessions');
$sessions = $this->data['sessions'];
echo $this->getData('nav')->render(); ?>
echo $this->data['nav']->render(); ?>
<div class="row">
<div class="col-xs-12">

View File

@ -18,11 +18,11 @@ use \phpOMS\Stdlib\Base\SmartDateTime;
use phpOMS\Uri\UriFactory;
/** @var Session[] $sessions */
$sessions = $this->getData('sessions');
$sessions = $this->data['sessions'];
$sessionCount = \count($sessions);
/** @var Session $lastOpenSession */
$lastOpenSession = $this->getData('lastSession');
$lastOpenSession = $this->data['lastSession'];
$type = $lastOpenSession !== null ? $lastOpenSession->getType() : ClockingType::OFFICE;
$status = $lastOpenSession !== null ? $lastOpenSession->getStatus() : ClockingStatus::END;
@ -42,7 +42,7 @@ $busy = [
'week' => 0,
];
echo $this->getData('nav')->render(); ?>
echo $this->data['nav']->render(); ?>
<div class="row">
<div class="col-md-4 col-xs-12">
<section class="portlet">

View File

@ -13,10 +13,10 @@
declare(strict_types=1);
/** @var \Modules\HumanResourceTimeRecording\Models\Session $session */
$session = $this->getData('session');
$session = $this->data['session'];
$elements = $session->getSessionElements();
echo $this->getData('nav')->render(); ?>
echo $this->data['nav']->render(); ?>
<div class="row">
<div class="col-xs-12">

View File

@ -15,9 +15,9 @@ declare(strict_types=1);
use \Modules\HumanResourceTimeRecording\Models\ClockingStatus;
use \Modules\HumanResourceTimeRecording\Models\ClockingType;
$sessions = $this->getData('sessions');
$sessions = $this->data['sessions'];
echo $this->getData('nav')->render(); ?>
echo $this->data['nav']->render(); ?>
<div class="row">
<div class="col-md-4 col-xs-12">