From be9c6dbae4f56f2b85b4584a053488059dd5957c Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 21 Mar 2025 02:48:18 +0000 Subject: [PATCH] crash backup --- Controller/ApiClockingTypeController.php | 8 ++++---- Controller/BackendController.php | 7 ++++++- Theme/Backend/private-dashboard.tpl.php | 15 +++++++-------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/Controller/ApiClockingTypeController.php b/Controller/ApiClockingTypeController.php index 0a489d8..e25c387 100644 --- a/Controller/ApiClockingTypeController.php +++ b/Controller/ApiClockingTypeController.php @@ -196,7 +196,7 @@ final class ApiClockingTypeController extends Controller } /** @var ClockingType $old */ - $old = ClockingTypeMapper::get()->where('id', (int) $request->getData('id')); + $old = ClockingTypeMapper::get()->where('id', $request->getDataInt('id') ?? 0); $new = $this->updateClockingTypeFromRequest($request, clone $old); $this->updateModel($request->header->account, $old, $new, ClockingTypeMapper::class, 'clocking_type', $request->getOrigin()); @@ -264,7 +264,7 @@ final class ApiClockingTypeController extends Controller } /** @var \Modules\HumanResourceTimeRecording\Models\ClockingType $clockingType */ - $clockingType = ClockingTypeMapper::get()->where('id', (int) $request->getData('id'))->execute(); + $clockingType = ClockingTypeMapper::get()->where('id', $request->getDataInt('id') ?? 0)->execute(); $this->deleteModel($request->header->account, $clockingType, ClockingTypeMapper::class, 'clocking_type', $request->getOrigin()); $this->createStandardDeleteResponse($request, $response, $clockingType); } @@ -311,7 +311,7 @@ final class ApiClockingTypeController extends Controller } /** @var BaseStringL11n $old */ - $old = ClockingTypeL11nMapper::get()->where('id', (int) $request->getData('id')); + $old = ClockingTypeL11nMapper::get()->where('id', $request->getDataInt('id') ?? 0); $new = $this->updateClockingTypeL11nFromRequest($request, clone $old); $this->updateModel($request->header->account, $old, $new, ClockingTypeL11nMapper::class, 'clocking_type_l11n', $request->getOrigin()); @@ -379,7 +379,7 @@ final class ApiClockingTypeController extends Controller } /** @var BaseStringL11n $clockingTypeL11n */ - $clockingTypeL11n = ClockingTypeL11nMapper::get()->where('id', (int) $request->getData('id'))->execute(); + $clockingTypeL11n = ClockingTypeL11nMapper::get()->where('id', $request->getDataInt('id') ?? 0)->execute(); $this->deleteModel($request->header->account, $clockingTypeL11n, ClockingTypeL11nMapper::class, 'clocking_type_l11n', $request->getOrigin()); $this->createStandardDeleteResponse($request, $response, $clockingTypeL11n); } diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 618ed09..309ca80 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -104,6 +104,11 @@ final class BackendController extends Controller implements DashboardElementInte /** @var \Modules\HumanResourceTimeRecording\Models\Session $lastOpenSession */ $lastOpenSession = SessionMapper::getMostPlausibleOpenSessionForEmployee($employee->profile->account->id); + $view->data['session_types'] = ClockingTypeMapper::getAll() + ->with('l11n') + ->where('l11n/language', $response->header->l11n->language) + ->executeGetArray(); + $start = new SmartDateTime('now'); $start = $start->getEndOfDay(); $limit = $start->getEndOfMonth(); @@ -142,7 +147,7 @@ final class BackendController extends Controller implements DashboardElementInte $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(); + $session = SessionMapper::get()->where('id', $request->getDataInt('id') ?? 0)->execute(); /** @var \Modules\HumanResourceManagement\Models\Employee $employee */ $employee = EmployeeMapper::get() diff --git a/Theme/Backend/private-dashboard.tpl.php b/Theme/Backend/private-dashboard.tpl.php index 1c213c1..7f543cd 100755 --- a/Theme/Backend/private-dashboard.tpl.php +++ b/Theme/Backend/private-dashboard.tpl.php @@ -24,9 +24,11 @@ $sessionCount = \count($sessions); /** @var \Modules\HumanResourceTimeRecording\Models\Session $lastOpenSession */ $lastOpenSession = $this->data['lastSession']; -$type = $lastOpenSession !== null ? $lastOpenSession->type : ClockingType::OFFICE; +$current_type = $lastOpenSession !== null ? $lastOpenSession->type : null; $status = $lastOpenSession !== null ? $lastOpenSession->getStatus() : ClockingStatus::END; +$types = $this->data['session_types'] ?? []; + /** @var \phpOMS\Stdlib\Base\SmartDateTime $startWeek */ $startWeek = new SmartDateTime('now'); $startWeek = $startWeek->getStartOfWeek(); @@ -52,14 +54,11 @@ echo $this->data['nav']->render(); ?> - +