general fixes

This commit is contained in:
Dennis Eichhorn 2024-04-19 02:08:37 +00:00
parent a14b555342
commit c6d80cf309
3 changed files with 20 additions and 12 deletions

View File

@ -124,17 +124,8 @@ final class BackendController extends Controller
public function viewHrStaffView(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
if (!$request->hasData('id')) {
$response->header->status = RequestStatusCode::R_404;
$view->setTemplate('/Web/Backend/Error/404');
return $view;
}
$view->setTemplate('/Modules/HumanResourceManagement/Theme/Backend/staff-view');
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1002402001, $request, $response);
$view->data['employee'] = EmployeeMapper::get()
$view->data['employee'] = EmployeeMapper::get()
->with('profile')
->with('profile/account')
->with('profile/account/address')
@ -155,6 +146,16 @@ final class BackendController extends Controller
->sort('workHistory/start', OrderType::DESC)
->execute();
if ($view->data['employee']->id === 0) {
$response->header->status = RequestStatusCode::R_404;
$view->setTemplate('/Web/Backend/Error/404');
return $view;
}
$view->setTemplate('/Modules/HumanResourceManagement/Theme/Backend/staff-view');
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1002402001, $request, $response);
$view->data['units'] = UnitMapper::getAll()->executeGetArray();
$view->data['departments'] = DepartmentMapper::getAll()->executeGetArray();
$view->data['positions'] = PositionMapper::getAll()->executeGetArray();
@ -162,6 +163,13 @@ final class BackendController extends Controller
$view->data['media-upload'] = new \Modules\Media\Theme\Backend\Components\Upload\BaseView($this->app->l11nManager, $request, $response);
$view->data['employee-notes'] = new \Modules\Editor\Theme\Backend\Components\Compound\BaseView($this->app->l11nManager, $request, $response);
/** @var \Model\Setting $profileImage */
$profileImage = $this->app->appSettings->get(names: SettingsEnum::DEFAULT_PROFILE_IMAGE, module: 'Profile');
$view->data['defaultImage'] = MediaMapper::get()
->where('id', (int) $profileImage->content)
->execute();
if ($this->app->moduleManager->isActive('HumanResourceTimeRecording')) {
/** @var \Modules\HumanResourceTimeRecording\Models\Session $lastOpenSession */
$lastOpenSession = SessionMapper::getMostPlausibleOpenSessionForEmployee($view->data['employee']->id);

View File

@ -45,7 +45,7 @@ echo $this->data['nav']->render(); ?>
<td><a href="<?= $url; ?>"><img alt="<?= $this->getHtml('IMG_alt_user'); ?>" width="30" loading="lazy" class="profile-image"
src="<?= $value->image->id === 0
? ($value->profile->image->id === 0
? UriFactory::build($this->getData('defaultImage')->getPath())
? UriFactory::build($this->data['defaultImage']->getPath())
: UriFactory::build($value->profile->image->getPath()))
: UriFactory::build($value->image->getPath()); ?>"></a>
<td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $value->id; ?></a>

View File

@ -54,7 +54,7 @@ echo $this->data['nav']->render(); ?>
src="<?=
$employee->image->id === 0
? ($employee->profile->image->id === 0
? UriFactory::build($this->getData('defaultImage')->getPath())
? UriFactory::build($this->data['defaultImage']->getPath())
: UriFactory::build($employee->profile->image->getPath()))
: UriFactory::build($employee->image->getPath()); ?>"
>