fix templates

This commit is contained in:
Dennis Eichhorn 2024-04-17 17:45:07 +00:00
parent 034918a977
commit a14b555342
9 changed files with 139 additions and 26 deletions

View File

@ -29,7 +29,7 @@
"children": [ "children": [
{ {
"id": 1002402101, "id": 1002402101,
"pid": "/humanresource/staff", "pid": "/humanresource",
"type": 3, "type": 3,
"subtype": 1, "subtype": 1,
"name": "List", "name": "List",
@ -45,7 +45,7 @@
}, },
{ {
"id": 1002402201, "id": 1002402201,
"pid": "/humanresource/staff", "pid": "/humanresource",
"type": 3, "type": 3,
"subtype": 1, "subtype": 1,
"name": "Create", "name": "Create",

View File

@ -23,6 +23,7 @@ use Modules\HumanResourceManagement\Models\EmployeeHistoryMapper;
use Modules\HumanResourceManagement\Models\EmployeeMapper; use Modules\HumanResourceManagement\Models\EmployeeMapper;
use Modules\HumanResourceManagement\Models\EmployeeWorkHistory; use Modules\HumanResourceManagement\Models\EmployeeWorkHistory;
use Modules\HumanResourceManagement\Models\EmployeeWorkHistoryMapper; use Modules\HumanResourceManagement\Models\EmployeeWorkHistoryMapper;
use Modules\HumanResourceManagement\Models\NullEmployee;
use Modules\HumanResourceManagement\Models\PermissionCategory; use Modules\HumanResourceManagement\Models\PermissionCategory;
use Modules\Media\Models\NullCollection; use Modules\Media\Models\NullCollection;
use Modules\Media\Models\PathSettings; use Modules\Media\Models\PathSettings;
@ -274,7 +275,8 @@ final class ApiController extends Controller
*/ */
private function createEmployeeHistoryFromRequest(RequestAbstract $request) : EmployeeHistory private function createEmployeeHistoryFromRequest(RequestAbstract $request) : EmployeeHistory
{ {
$history = new EmployeeHistory($request->getDataInt('employee') ?? 0); $history = new EmployeeHistory();
$history->employee = new NullEmployee($request->getDataInt('employee') ?? 0);
$history->unit = new NullUnit($request->getDataInt('unit') ?? 0); $history->unit = new NullUnit($request->getDataInt('unit') ?? 0);
$history->department = new NullDepartment($request->getDataInt('department') ?? 0); $history->department = new NullDepartment($request->getDataInt('department') ?? 0);
$history->position = new NullPosition($request->getDataInt('position') ?? 0); $history->position = new NullPosition($request->getDataInt('position') ?? 0);

View File

@ -14,6 +14,7 @@ declare(strict_types=1);
namespace Modules\HumanResourceManagement\Controller; namespace Modules\HumanResourceManagement\Controller;
use Modules\HumanResourceManagement\Models\EmployeeHistory;
use Modules\HumanResourceManagement\Models\EmployeeHistoryMapper; use Modules\HumanResourceManagement\Models\EmployeeHistoryMapper;
use Modules\HumanResourceManagement\Models\EmployeeMapper; use Modules\HumanResourceManagement\Models\EmployeeMapper;
use Modules\HumanResourceTimeRecording\Models\SessionMapper; use Modules\HumanResourceTimeRecording\Models\SessionMapper;
@ -26,6 +27,7 @@ use Modules\Organization\Models\UnitMapper;
use Modules\Profile\Models\SettingsEnum; use Modules\Profile\Models\SettingsEnum;
use phpOMS\Contract\RenderableInterface; use phpOMS\Contract\RenderableInterface;
use phpOMS\DataStorage\Database\Query\OrderType; use phpOMS\DataStorage\Database\Query\OrderType;
use phpOMS\Message\Http\RequestStatusCode;
use phpOMS\Message\RequestAbstract; use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract; use phpOMS\Message\ResponseAbstract;
use phpOMS\Stdlib\Base\SmartDateTime; use phpOMS\Stdlib\Base\SmartDateTime;
@ -69,20 +71,17 @@ final class BackendController extends Controller
->with('companyHistory/unit') ->with('companyHistory/unit')
->with('companyHistory/department') ->with('companyHistory/department')
->with('companyHistory/position') ->with('companyHistory/position')
->sort('companyHistory/start', OrderType::DESC) ->sort('companyHistory/end', OrderType::DESC)
//->limit(1, 'companyHistory') // @todo This is not working since it returns 1 for ALL employees instead of per employee //->limit(1, 'companyHistory') // @todo This is not working since it returns 1 for ALL employees instead of per employee
->executeGetArray(); ->executeGetArray();
/** @var \Model\Setting $profileImage */ /** @var \Model\Setting $profileImage */
$profileImage = $this->app->appSettings->get(names: SettingsEnum::DEFAULT_PROFILE_IMAGE, module: 'Profile'); $profileImage = $this->app->appSettings->get(names: SettingsEnum::DEFAULT_PROFILE_IMAGE, module: 'Profile');
/** @var \Modules\Media\Models\Media $image */ $view->data['defaultImage'] = MediaMapper::get()
$image = MediaMapper::get()
->where('id', (int) $profileImage->content) ->where('id', (int) $profileImage->content)
->execute(); ->execute();
$view->data['defaultImage'] = $image;
return $view; return $view;
} }
@ -125,6 +124,13 @@ final class BackendController extends Controller
public function viewHrStaffView(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface public function viewHrStaffView(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{ {
$view = new View($this->app->l11nManager, $request, $response); $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->setTemplate('/Modules/HumanResourceManagement/Theme/Backend/staff-view');
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1002402001, $request, $response); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1002402001, $request, $response);
@ -144,7 +150,7 @@ final class BackendController extends Controller
->with('educationHistory') ->with('educationHistory')
->with('workHistory') ->with('workHistory')
->where('id', (int) $request->getData('id')) ->where('id', (int) $request->getData('id'))
->sort('companyHistory/start', OrderType::DESC) ->sort('companyHistory/end', OrderType::DESC)
->sort('educationHistory/start', OrderType::DESC) ->sort('educationHistory/start', OrderType::DESC)
->sort('workHistory/start', OrderType::DESC) ->sort('workHistory/start', OrderType::DESC)
->execute(); ->execute();
@ -207,6 +213,8 @@ final class BackendController extends Controller
$histories = EmployeeHistoryMapper::getAll() $histories = EmployeeHistoryMapper::getAll()
->where('department', \array_map(function (Department $department) : int { return $department->id; }, $view->data['departments'])) ->where('department', \array_map(function (Department $department) : int { return $department->id; }, $view->data['departments']))
->where('unit', $this->app->unitId)
->where('end', null)
->executeGetArray(); ->executeGetArray();
$stats = []; $stats = [];
@ -223,6 +231,100 @@ final class BackendController extends Controller
return $view; return $view;
} }
/**
* Routing end-point for application behavior.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewHrDepartmentView(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/HumanResourceManagement/Theme/Backend/staff-list');
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1002402001, $request, $response);
$histories = EmployeeHistoryMapper::getAll()
->where('unit', $this->app->unitId)
->where('department', (int) $request->getData('id'))
->where('end', null)
->executeGetArray();
$view->data['employees'] = empty($histories) ? [] : EmployeeMapper::getAll()
->with('profile')
->with('profile/account')
->with('image')
->with('profile/image')
->with('companyHistory')
->with('companyHistory/unit')
->with('companyHistory/department')
->with('companyHistory/position')
->sort('companyHistory/end', OrderType::DESC)
->where('id', \array_map(function (EmployeeHistory $history) : int { return $history->employee->id; }, $histories))
->executeGetArray();
/** @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();
return $view;
}
/**
* Routing end-point for application behavior.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewHrPositionView(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/HumanResourceManagement/Theme/Backend/staff-list');
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1002402001, $request, $response);
$histories = EmployeeHistoryMapper::getAll()
->where('unit', $this->app->unitId)
->where('position', (int) $request->getData('id'))
->where('end', null)
->executeGetArray();
$view->data['employees'] = empty($histories) ? [] : EmployeeMapper::getAll()
->with('profile')
->with('profile/account')
->with('image')
->with('profile/image')
->with('companyHistory')
->with('companyHistory/unit')
->with('companyHistory/department')
->with('companyHistory/position')
->sort('companyHistory/end', OrderType::DESC)
->where('id', \array_map(function (EmployeeHistory $history) : int { return $history->employee->id; }, $histories))
->executeGetArray();
/** @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();
return $view;
}
/** /**
* Routing end-point for application behavior. * Routing end-point for application behavior.
* *
@ -253,6 +355,8 @@ final class BackendController extends Controller
$histories = EmployeeHistoryMapper::getAll() $histories = EmployeeHistoryMapper::getAll()
->where('department', \array_map(function (Department $department) : int { return $department->id; }, $departments)) ->where('department', \array_map(function (Department $department) : int { return $department->id; }, $departments))
->where('position', \array_map(function (Position $position) : int { return $position->id; }, $view->data['positions'])) ->where('position', \array_map(function (Position $position) : int { return $position->id; }, $view->data['positions']))
->where('unit', $this->app->unitId)
->where('end', null)
->executeGetArray(); ->executeGetArray();
$stats = []; $stats = [];

View File

@ -44,10 +44,10 @@ class EmployeeHistory implements \JsonSerializable
/** /**
* Employee * Employee
* *
* @var int|Employee * @var Employee
* @since 1.0.0 * @since 1.0.0
*/ */
public $employee = 0; public Employee $employee;
/** /**
* Unit * Unit
@ -99,9 +99,9 @@ class EmployeeHistory implements \JsonSerializable
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function __construct($employee = 0) public function __construct()
{ {
$this->employee = $employee; $this->employee = new NullEmployee();
$this->start = new \DateTime('now'); $this->start = new \DateTime('now');
$this->unit = new NullUnit(); $this->unit = new NullUnit();
$this->department = new NullDepartment(); $this->department = new NullDepartment();

View File

@ -46,4 +46,6 @@ return ['HumanResourceManagement' => [
'Title' => 'Titel', 'Title' => 'Titel',
'Unit' => 'Einheit', 'Unit' => 'Einheit',
'Work' => 'Arbeiten', 'Work' => 'Arbeiten',
'Total' => 'Gesamt',
'FTE' => 'MAK',
]]; ]];

View File

@ -46,4 +46,6 @@ return ['HumanResourceManagement' => [
'Title' => 'Title', 'Title' => 'Title',
'Unit' => 'Unit', 'Unit' => 'Unit',
'Work' => 'Work', 'Work' => 'Work',
'Total' => 'Total',
'FTE' => 'FTE',
]]; ]];

View File

@ -24,7 +24,7 @@ echo $this->data['nav']->render(); ?>
<div class="row"> <div class="row">
<div class="col-xs-12"> <div class="col-xs-12">
<div class="portlet"> <section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Positions'); ?><i class="g-icon download btn end-xs">download</i></div> <div class="portlet-head"><?= $this->getHtml('Positions'); ?><i class="g-icon download btn end-xs">download</i></div>
<div class="slider"> <div class="slider">
<table class="default sticky"> <table class="default sticky">
@ -48,6 +48,6 @@ echo $this->data['nav']->render(); ?>
<?php endif; ?> <?php endif; ?>
</table> </table>
</div> </div>
</div> </section>
</div> </div>
</div> </div>

View File

@ -25,7 +25,7 @@ echo $this->data['nav']->render(); ?>
<div class="row"> <div class="row">
<div class="col-xs-12"> <div class="col-xs-12">
<div class="portlet"> <section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Staff'); ?><i class="g-icon download btn end-xs">download</i></div> <div class="portlet-head"><?= $this->getHtml('Staff'); ?><i class="g-icon download btn end-xs">download</i></div>
<div class="slider"> <div class="slider">
<table id="employeeList" class="default sticky"> <table id="employeeList" class="default sticky">
@ -58,10 +58,13 @@ echo $this->data['nav']->render(); ?>
<td><?= $value->getNewestHistory()->id > 0 ? $this->getHtml('Active') : $this->getHtml('Inactive'); ?> <td><?= $value->getNewestHistory()->id > 0 ? $this->getHtml('Active') : $this->getHtml('Inactive'); ?>
<?php endforeach; ?> <?php endforeach; ?>
<?php if ($c === 0) : ?> <?php if ($c === 0) : ?>
<tr><td colspan="6" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?> <tr><td colspan="7" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?> <?php endif; ?>
<tr class="hl-3">
<td colspan="6"><?= $this->getHtml('Total'); ?>
<td><?= $c; ?>
</table> </table>
</div> </div>
</div> </section>
</div> </div>
</div> </div>