diff --git a/Admin/Install/Navigation.install.json b/Admin/Install/Navigation.install.json index 76cb019..723c777 100755 --- a/Admin/Install/Navigation.install.json +++ b/Admin/Install/Navigation.install.json @@ -29,7 +29,7 @@ "children": [ { "id": 1002402101, - "pid": "/humanresource/staff", + "pid": "/humanresource", "type": 3, "subtype": 1, "name": "List", @@ -45,7 +45,7 @@ }, { "id": 1002402201, - "pid": "/humanresource/staff", + "pid": "/humanresource", "type": 3, "subtype": 1, "name": "Create", diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 57bf3d4..e554927 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -23,6 +23,7 @@ use Modules\HumanResourceManagement\Models\EmployeeHistoryMapper; use Modules\HumanResourceManagement\Models\EmployeeMapper; use Modules\HumanResourceManagement\Models\EmployeeWorkHistory; use Modules\HumanResourceManagement\Models\EmployeeWorkHistoryMapper; +use Modules\HumanResourceManagement\Models\NullEmployee; use Modules\HumanResourceManagement\Models\PermissionCategory; use Modules\Media\Models\NullCollection; use Modules\Media\Models\PathSettings; @@ -274,7 +275,8 @@ final class ApiController extends Controller */ 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->department = new NullDepartment($request->getDataInt('department') ?? 0); $history->position = new NullPosition($request->getDataInt('position') ?? 0); diff --git a/Controller/BackendController.php b/Controller/BackendController.php index f7d605a..d0ac527 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -14,6 +14,7 @@ declare(strict_types=1); namespace Modules\HumanResourceManagement\Controller; +use Modules\HumanResourceManagement\Models\EmployeeHistory; use Modules\HumanResourceManagement\Models\EmployeeHistoryMapper; use Modules\HumanResourceManagement\Models\EmployeeMapper; use Modules\HumanResourceTimeRecording\Models\SessionMapper; @@ -26,6 +27,7 @@ use Modules\Organization\Models\UnitMapper; use Modules\Profile\Models\SettingsEnum; use phpOMS\Contract\RenderableInterface; use phpOMS\DataStorage\Database\Query\OrderType; +use phpOMS\Message\Http\RequestStatusCode; use phpOMS\Message\RequestAbstract; use phpOMS\Message\ResponseAbstract; use phpOMS\Stdlib\Base\SmartDateTime; @@ -69,20 +71,17 @@ final class BackendController extends Controller ->with('companyHistory/unit') ->with('companyHistory/department') ->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 ->executeGetArray(); /** @var \Model\Setting $profileImage */ $profileImage = $this->app->appSettings->get(names: SettingsEnum::DEFAULT_PROFILE_IMAGE, module: 'Profile'); - /** @var \Modules\Media\Models\Media $image */ - $image = MediaMapper::get() + $view->data['defaultImage'] = MediaMapper::get() ->where('id', (int) $profileImage->content) ->execute(); - $view->data['defaultImage'] = $image; - return $view; } @@ -125,6 +124,13 @@ 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); @@ -144,7 +150,7 @@ final class BackendController extends Controller ->with('educationHistory') ->with('workHistory') ->where('id', (int) $request->getData('id')) - ->sort('companyHistory/start', OrderType::DESC) + ->sort('companyHistory/end', OrderType::DESC) ->sort('educationHistory/start', OrderType::DESC) ->sort('workHistory/start', OrderType::DESC) ->execute(); @@ -207,6 +213,8 @@ final class BackendController extends Controller $histories = EmployeeHistoryMapper::getAll() ->where('department', \array_map(function (Department $department) : int { return $department->id; }, $view->data['departments'])) + ->where('unit', $this->app->unitId) + ->where('end', null) ->executeGetArray(); $stats = []; @@ -223,6 +231,100 @@ final class BackendController extends Controller 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. * @@ -253,6 +355,8 @@ final class BackendController extends Controller $histories = EmployeeHistoryMapper::getAll() ->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('unit', $this->app->unitId) + ->where('end', null) ->executeGetArray(); $stats = []; diff --git a/Models/EmployeeHistory.php b/Models/EmployeeHistory.php index b81a92b..4218476 100755 --- a/Models/EmployeeHistory.php +++ b/Models/EmployeeHistory.php @@ -44,10 +44,10 @@ class EmployeeHistory implements \JsonSerializable /** * Employee * - * @var int|Employee + * @var Employee * @since 1.0.0 */ - public $employee = 0; + public Employee $employee; /** * Unit @@ -99,9 +99,9 @@ class EmployeeHistory implements \JsonSerializable * * @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->unit = new NullUnit(); $this->department = new NullDepartment(); diff --git a/Theme/Backend/Lang/de.lang.php b/Theme/Backend/Lang/de.lang.php index 56aba1d..3284880 100755 --- a/Theme/Backend/Lang/de.lang.php +++ b/Theme/Backend/Lang/de.lang.php @@ -46,4 +46,6 @@ return ['HumanResourceManagement' => [ 'Title' => 'Titel', 'Unit' => 'Einheit', 'Work' => 'Arbeiten', + 'Total' => 'Gesamt', + 'FTE' => 'MAK', ]]; diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php index c0160a2..851d380 100755 --- a/Theme/Backend/Lang/en.lang.php +++ b/Theme/Backend/Lang/en.lang.php @@ -46,4 +46,6 @@ return ['HumanResourceManagement' => [ 'Title' => 'Title', 'Unit' => 'Unit', 'Work' => 'Work', + 'Total' => 'Total', + 'FTE' => 'FTE', ]]; diff --git a/Theme/Backend/position-list.tpl.php b/Theme/Backend/position-list.tpl.php index 77393c3..48eb14d 100755 --- a/Theme/Backend/position-list.tpl.php +++ b/Theme/Backend/position-list.tpl.php @@ -24,7 +24,7 @@ echo $this->data['nav']->render(); ?>
-
+
getHtml('Positions'); ?>download
@@ -48,6 +48,6 @@ echo $this->data['nav']->render(); ?>
-
+
diff --git a/Theme/Backend/staff-list.tpl.php b/Theme/Backend/staff-list.tpl.php index 3e48ce7..cb4a795 100755 --- a/Theme/Backend/staff-list.tpl.php +++ b/Theme/Backend/staff-list.tpl.php @@ -25,7 +25,7 @@ echo $this->data['nav']->render(); ?>
-
+
getHtml('Staff'); ?>download
@@ -58,10 +58,13 @@ echo $this->data['nav']->render(); ?> +
getNewestHistory()->id > 0 ? $this->getHtml('Active') : $this->getHtml('Inactive'); ?> -
getHtml('Empty', '0', '0'); ?> +
getHtml('Empty', '0', '0'); ?> +
getHtml('Total'); ?> +
-
+
diff --git a/Theme/Backend/staff-view.tpl.php b/Theme/Backend/staff-view.tpl.php index d5f0a52..5fdc243 100644 --- a/Theme/Backend/staff-view.tpl.php +++ b/Theme/Backend/staff-view.tpl.php @@ -397,20 +397,20 @@ echo $this->data['nav']->render(); ?> format('Y/m/d'); ?> - format('Y/m/d'); ?> h m createModify(0, 0, -1); - $startWeek = $startWeek->createModify(0, 0, -7); - $busy['week'] = 0; - endif; + $endWeek = $startWeek->createModify(0, 0, -1); + $startWeek = $startWeek->createModify(0, 0, -7); + $busy['week'] = 0; + endif; ?> getTimestamp() <= $startMonth->getTimestamp()) : ?> format('Y/m/d'); ?> - format('Y/m/d'); ?> h m createModify(0, 0, -1); - $startMonth = $startMonth->createModify(0, -1, 0); - $busy['month'] = 0; - endif; + $endMonth = $startMonth->createModify(0, 0, -1); + $startMonth = $startMonth->createModify(0, -1, 0); + $busy['month'] = 0; + endif; ?>