This commit is contained in:
Dennis Eichhorn 2024-04-07 17:31:42 +00:00
parent 4673f1de53
commit 007b51b418
17 changed files with 114 additions and 34 deletions

View File

@ -23,6 +23,7 @@ return [
'dest' => '\Modules\FleetManagement\Controller\ApiVehicleController:apiVehicleFind',
'verb' => RouteVerb::GET,
'csrf' => true,
'active' => true,
'permission' => [
'module' => Controller::NAME,
'type' => PermissionType::READ,
@ -36,6 +37,7 @@ return [
'dest' => '\Modules\FleetManagement\Controller\ApiVehicleAttributeController:apiVehicleAttributeCreate',
'verb' => RouteVerb::PUT,
'csrf' => true,
'active' => true,
'permission' => [
'module' => Controller::NAME,
'type' => PermissionType::READ,
@ -46,6 +48,7 @@ return [
'dest' => '\Modules\FleetManagement\Controller\ApiVehicleAttributeController:apiVehicleAttributeUpdate',
'verb' => RouteVerb::SET,
'csrf' => true,
'active' => true,
'permission' => [
'module' => Controller::NAME,
'type' => PermissionType::READ,
@ -59,6 +62,7 @@ return [
'dest' => '\Modules\FleetManagement\Controller\ApiDriverAttributeController:apiDriverAttributeCreate',
'verb' => RouteVerb::PUT,
'csrf' => true,
'active' => true,
'permission' => [
'module' => Controller::NAME,
'type' => PermissionType::READ,
@ -69,6 +73,7 @@ return [
'dest' => '\Modules\FleetManagement\Controller\ApiDriverAttributeController:apiDriverAttributeUpdate',
'verb' => RouteVerb::SET,
'csrf' => true,
'active' => true,
'permission' => [
'module' => Controller::NAME,
'type' => PermissionType::READ,
@ -82,6 +87,7 @@ return [
'dest' => '\Modules\FleetManagement\Controller\ApiVehicleController:apiNoteCreate',
'verb' => RouteVerb::PUT,
'csrf' => true,
'active' => true,
'permission' => [
'module' => Controller::NAME,
'type' => PermissionType::READ,
@ -92,6 +98,7 @@ return [
'dest' => '\Modules\FleetManagement\Controller\ApiVehicleController:apiNoteUpdate',
'verb' => RouteVerb::SET,
'csrf' => true,
'active' => true,
'permission' => [
'module' => Controller::NAME,
'type' => PermissionType::READ,
@ -105,6 +112,7 @@ return [
'dest' => '\Modules\FleetManagement\Controller\ApiDriverController:apiNoteCreate',
'verb' => RouteVerb::PUT,
'csrf' => true,
'active' => true,
'permission' => [
'module' => Controller::NAME,
'type' => PermissionType::READ,
@ -115,6 +123,7 @@ return [
'dest' => '\Modules\FleetManagement\Controller\ApiDriverController:apiNoteUpdate',
'verb' => RouteVerb::SET,
'csrf' => true,
'active' => true,
'permission' => [
'module' => Controller::NAME,
'type' => PermissionType::READ,

View File

@ -22,6 +22,7 @@ return [
[
'dest' => '\Modules\FleetManagement\Controller\BackendController:viewFleetManagementAttributeTypeList',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
@ -33,6 +34,7 @@ return [
[
'dest' => '\Modules\FleetManagement\Controller\BackendController:viewFleetManagementAttributeType',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
@ -44,6 +46,7 @@ return [
[
'dest' => '\Modules\FleetManagement\Controller\BackendController:viewFleetManagementAttributeTypeCreate',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::CREATE,
@ -55,6 +58,7 @@ return [
[
'dest' => '\Modules\FleetManagement\Controller\BackendController:viewFleetManagementAttributeValue',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
@ -66,6 +70,7 @@ return [
[
'dest' => '\Modules\FleetManagement\Controller\BackendController:viewFleetManagementAttributeValueCreate',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::CREATE,
@ -78,6 +83,7 @@ return [
[
'dest' => '\Modules\FleetManagement\Controller\BackendController:viewFleetManagementVehicleList',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
@ -89,6 +95,7 @@ return [
[
'dest' => '\Modules\FleetManagement\Controller\BackendController:viewFleetManagementVehicleCreate',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::CREATE,
@ -100,6 +107,7 @@ return [
[
'dest' => '\Modules\FleetManagement\Controller\BackendController:viewFleetManagementVehicleView',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
@ -112,6 +120,7 @@ return [
[
'dest' => '\Modules\FleetManagement\Controller\BackendController:viewFleetManagementDriverAttributeTypeList',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
@ -123,6 +132,7 @@ return [
[
'dest' => '\Modules\FleetManagement\Controller\BackendController:viewFleetManagementDriverAttributeType',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
@ -134,6 +144,7 @@ return [
[
'dest' => '\Modules\FleetManagement\Controller\BackendController:viewFleetManagementDriverAttributeTypeCreate',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::CREATE,
@ -145,6 +156,7 @@ return [
[
'dest' => '\Modules\FleetManagement\Controller\BackendController:viewFleetManagementDriverAttributeValue',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
@ -156,6 +168,7 @@ return [
[
'dest' => '\Modules\FleetManagement\Controller\BackendController:viewFleetManagementDriverAttributeValueCreate',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::CREATE,
@ -168,6 +181,7 @@ return [
[
'dest' => '\Modules\FleetManagement\Controller\BackendController:viewFleetManagementDriverList',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
@ -179,6 +193,7 @@ return [
[
'dest' => '\Modules\FleetManagement\Controller\BackendController:viewFleetManagementDriverCreate',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::CREATE,
@ -190,6 +205,7 @@ return [
[
'dest' => '\Modules\FleetManagement\Controller\BackendController:viewFleetManagementDriverView',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
@ -202,6 +218,7 @@ return [
[
'dest' => '\Modules\FleetManagement\Controller\BackendController:viewFleetManagementInspectionList',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
@ -213,6 +230,7 @@ return [
[
'dest' => '\Modules\FleetManagement\Controller\BackendController:viewFleetManagementInspectionTypeList',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
@ -224,6 +242,7 @@ return [
[
'dest' => '\Modules\FleetManagement\Controller\BackendController:viewFleetManagementInspectionCreate',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::CREATE,
@ -235,6 +254,7 @@ return [
[
'dest' => '\Modules\FleetManagement\Controller\BackendController:viewFleetManagementInspectionView',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
@ -246,6 +266,7 @@ return [
[
'dest' => '\Modules\FleetManagement\Controller\BackendController:viewFleetManagementDriverInspectionTypeList',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
@ -257,6 +278,7 @@ return [
[
'dest' => '\Modules\FleetManagement\Controller\BackendController:viewFleetManagementDriverInspectionCreate',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::CREATE,
@ -268,6 +290,7 @@ return [
[
'dest' => '\Modules\FleetManagement\Controller\BackendController:viewFleetManagementDriverInspectionView',
'verb' => RouteVerb::GET,
'active' => true,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,

View File

@ -40,7 +40,7 @@ final class ApiDriverAttributeController extends Controller
use \Modules\Attribute\Controller\ApiAttributeTraitController;
/**
* Api method to create item attribute
* Api method to create Attribute
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response

View File

@ -625,7 +625,7 @@ final class ApiDriverController extends Controller
}
/**
* Validate item note create request
* Validate note create request
*
* @param RequestAbstract $request Request
*

View File

@ -40,7 +40,7 @@ final class ApiVehicleAttributeController extends Controller
use \Modules\Attribute\Controller\ApiAttributeTraitController;
/**
* Api method to create item attribute
* Api method to create Attribute
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response

View File

@ -1001,7 +1001,7 @@ final class ApiVehicleController extends Controller
}
/**
* Validate item note create request
* Validate note create request
*
* @param RequestAbstract $request Request
*

View File

@ -63,7 +63,7 @@ final class BackendController extends Controller
public function viewFleetManagementAttributeTypeList(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$view = new \Modules\Attribute\Theme\Backend\Components\AttributeTypeListView($this->app->l11nManager, $request, $response);
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1003503001, $request, $response);
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1003505001, $request, $response);
$view->attributes = VehicleAttributeTypeMapper::getAll()
->with('l11n')
@ -90,7 +90,7 @@ final class BackendController extends Controller
public function viewFleetManagementDriverAttributeTypeList(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$view = new \Modules\Attribute\Theme\Backend\Components\AttributeTypeListView($this->app->l11nManager, $request, $response);
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1003503001, $request, $response);
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1003506001, $request, $response);
$view->attributes = DriverAttributeTypeMapper::getAll()
->with('l11n')
@ -182,19 +182,43 @@ final class BackendController extends Controller
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1003504001, $request, $response);
$vehicles = InspectionMapper::getAll()
->with('type')
->with('type/l11n')
->where('type/l11n/language', $request->header->l11n->language)
->sort('id', 'DESC')
->limit(100)
->executeGetArray();
$drivers = DriverInspectionMapper::getAll()
->with('type')
->with('type/l11n')
->where('type/l11n/language', $request->header->l11n->language)
->sort('id', 'DESC')
->limit(100)
->executeGetArray();
$inspections = \array_merge($vehicles, $drivers);
\usort($inspections, function (Inspection $a, Inspection $b) : int {
return $a->date?->getTimestamp() <=> $b->date?->getTimestamp();
$inspections = [];
foreach ($vehicles as $inspection) {
$inspections[] = ['type' => 'vehicle', 'inspection' => $inspection];
}
foreach ($drivers as $inspection) {
$inspections[] = ['type' => 'driver', 'inspection' => $inspection];
}
\usort($inspections, function (array $a, array $b) : int {
return $a['inspection']->date?->getTimestamp() <=> $b['inspection']->date?->getTimestamp();
});
$view->data['inspections'] = $inspections;
$view->data['vehicles'] = VehicleMapper::getAll()
->where('id', \array_map(function (Inspection $inspection) { return $inspection->reference; }, $vehicles))
->executeGetArray();
$view->data['drivers'] = DriverMapper::getAll()
->with('account')
->where('id', \array_map(function (Inspection $inspection) { return $inspection->reference; }, $drivers))
->executeGetArray();
return $view;
}
@ -492,7 +516,7 @@ final class BackendController extends Controller
->with('attributes/type')
->with('attributes/value')
->with('attributes/type/l11n')
//->with('attributes/value/l11n')
->with('attributes/value/l11n')
->with('files')
->with('files/types')
->with('type')
@ -503,7 +527,7 @@ final class BackendController extends Controller
->where('type/l11n/language', $response->header->l11n->language)
->where('fuelType/l11n/language', $response->header->l11n->language)
->where('attributes/type/l11n/language', $response->header->l11n->language)
//->where('attributes/value/l11n/language', $response->header->l11n->language)
->where('attributes/value/l11n/language', [$response->header->l11n->language, null])
->execute();
$view->data['vehicle'] = $vehicle;
@ -586,12 +610,12 @@ final class BackendController extends Controller
->with('attributes/type')
->with('attributes/value')
->with('attributes/type/l11n')
//->with('attributes/value/l11n')
->with('attributes/value/l11n')
->with('files')
->with('files/types')
->where('id', (int) $request->getData('id'))
->where('attributes/type/l11n/language', $response->header->l11n->language)
//->where('attributes/value/l11n/language', $response->header->l11n->language)
->where('attributes/value/l11n/language', [$response->header->l11n->language, null])
->execute();
$view->data['driver'] = $driver;

View File

@ -18,7 +18,7 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
use phpOMS\Localization\BaseStringL11nType;
/**
* Item mapper class.
* DriverInspectionType mapper class.
*
* @package Modules\FleetManagement\Models\Driver
* @license OMS License 2.0

View File

@ -21,7 +21,7 @@ use Modules\Media\Models\MediaMapper;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
/**
* Mapper class.
* Driver mapper class.
*
* @package Modules\FleetManagement\Models\Driver
* @license OMS License 2.0

View File

@ -18,7 +18,7 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
use phpOMS\Localization\BaseStringL11nType;
/**
* Item mapper class.
* FuelType mapper class.
*
* @package Modules\FleetManagement\Models
* @license OMS License 2.0

View File

@ -20,6 +20,14 @@ use phpOMS\Localization\BaseStringL11nType;
/**
* Inspection class.
*
* The scheduling works as follows:
* date = when did the inspection take place
* next = when is the next inspection
*
* When you create an inspection you define the next date
* After an inspection is completed and it is recurring it sets date = actual date and next to null
* Additionally, a new inspection element is generated with the next field set based on the interval setting
*
* @package Modules\Attribute\Models
* @license OMS License 2.0
* @link https://jingga.app

View File

@ -18,7 +18,7 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
use phpOMS\Localization\BaseStringL11nType;
/**
* Item mapper class.
* InspectionType mapper class.
*
* @package Modules\FleetManagement\Models
* @license OMS License 2.0

View File

@ -20,7 +20,7 @@ use Modules\Media\Models\MediaMapper;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
/**
* Mapper class.
* Vehicle mapper class.
*
* @package Modules\FleetManagement\Models
* @license OMS License 2.0

View File

@ -18,7 +18,7 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
use phpOMS\Localization\BaseStringL11nType;
/**
* Item mapper class.
* VehicleType mapper class.
*
* @package Modules\FleetManagement\Models
* @license OMS License 2.0

View File

@ -25,6 +25,7 @@ return ['FleetManagement' => [
'Date' => 'Datum',
'Driver' => 'Fahrer',
'Drivers' => 'Fahrer',
'Reference' => 'Referenz',
'End' => 'Ende',
'From' => 'Von',
'Description' => 'Beschreibung',

View File

@ -30,6 +30,7 @@ return ['FleetManagement' => [
'To' => 'To',
'Description' => 'Description',
'Files' => 'Files',
'Reference' => 'Reference',
'History' => 'History',
'Inspections' => 'Inspections',
'LeasingFee' => 'Leasing Fee',

View File

@ -12,6 +12,8 @@
*/
declare(strict_types=1);
use phpOMS\Uri\UriFactory;
echo $this->data['nav']->render();
?>
@ -23,23 +25,29 @@ echo $this->data['nav']->render();
<thead>
<tr>
<td><?= $this->getHtml('Date'); ?>
<td class="wf-100"><?= $this->getHtml('Type'); ?>
<td><?= $this->getHtml('Responsible'); ?>
<td><?= $this->getHtml('Type'); ?>
<td class="wf-100"><?= $this->getHtml('Reference'); ?>
<tbody>
<?php
$count = 0;
foreach (($this->data['inspections'] ?? []) as $inspection) :
foreach (($this->data['inspections'] ?? []) as $i) :
// @todo handle old inspections in the past? maybe use a status?!
if ($inspection->next === null) {
if ($i['inspection']->next === null) {
continue;
}
++$count;
$inspection = $i['inspection'];
$url = UriFactory::build('{/base}/fleet/inspection/' . $i['type'] . '/view?id=' . $inspection->id);
?>
<tr>
<td><?= $inspection->next->format('Y-m-d H:i'); ?>
<td><?= $this->printHtml($inspection->type->getL11n()); ?>
<td>
<tr data-href="<?= $url ?>">
<td><a href="<?= $url; ?>"><?= $inspection->next?->format('Y-m-d H:i'); ?></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($inspection->type->getL11n()); ?></a>
<td><a href="<?= $url; ?>"><?= $i['type'] === 'vehicle'
? $this->data['vehicles'][$inspection->reference]->name
: $this->data['drivers'][$inspection->reference]->account->name1 . ' ' . $this->data['drivers'][$inspection->reference]->account->name2;
?></a>
<?php endforeach; ?>
<?php if ($count === 0) : ?>
<tr><td colspan="3" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
@ -57,18 +65,24 @@ echo $this->data['nav']->render();
<thead>
<tr>
<td><?= $this->getHtml('Date'); ?>
<td class="wf-100"><?= $this->getHtml('Type'); ?>
<td><?= $this->getHtml('Responsible'); ?>
<td><?= $this->getHtml('Type'); ?>
<td class="wf-100"><?= $this->getHtml('Reference'); ?>
<tbody>
<?php
$count = 0;
foreach (($this->data['inspections'] ?? []) as $inspection) :
foreach (($this->data['inspections'] ?? []) as $i) :
++$count;
$inspection = $i['inspection'];
$url = UriFactory::build('{/base}/fleet/inspection/' . $i['type'] . '/view?id=' . $inspection->id);
?>
<tr>
<td><?= $inspection->date->format('Y-m-d H:i'); ?>
<td><?= $this->printHtml($inspection->type->getL11n()); ?>
<td>
<tr data-href="<?= $url ?>">
<td><a href="<?= $url; ?>"><?= $inspection->date?->format('Y-m-d H:i'); ?></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($inspection->type->getL11n()); ?></a>
<td><a href="<?= $url; ?>"><?= $i['type'] === 'vehicle'
? $this->data['vehicles'][$inspection->reference]->name
: $this->data['drivers'][$inspection->reference]->account->name1 . ' ' . $this->data['drivers'][$inspection->reference]->account->name2;
?></a>
<?php endforeach; ?>
<?php if ($count === 0) : ?>
<tr><td colspan="3" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>