This commit is contained in:
Dennis Eichhorn 2023-05-30 13:52:15 +00:00
commit d47be77c70
22 changed files with 627 additions and 389 deletions

View File

@ -95,6 +95,54 @@
}
}
},
"fleetmgmt_inspection_type": {
"name": "fleetmgmt_inspection_type",
"fields": {
"fleetmgmt_inspection_type_id": {
"name": "fleetmgmt_inspection_type_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"fleetmgmt_inspection_type_name": {
"name": "fleetmgmt_inspection_type_name",
"type": "VARCHAR(255)",
"null": false
}
}
},
"fleetmgmt_inspection_type_l11n": {
"name": "fleetmgmt_inspection_type_l11n",
"fields": {
"fleetmgmt_inspection_type_l11n_id": {
"name": "fleetmgmt_inspection_type_l11n_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"fleetmgmt_inspection_type_l11n_title": {
"name": "fleetmgmt_inspection_type_l11n_title",
"type": "VARCHAR(255)",
"null": false
},
"fleetmgmt_inspection_type_l11n_type": {
"name": "fleetmgmt_inspection_type_l11n_type",
"type": "INT(11)",
"null": false,
"foreignTable": "fleetmgmt_inspection_type",
"foreignKey": "fleetmgmt_inspection_type_id"
},
"fleetmgmt_inspection_type_l11n_lang": {
"name": "fleetmgmt_inspection_type_l11n_lang",
"type": "VARCHAR(2)",
"null": false,
"foreignTable": "language",
"foreignKey": "language_639_1"
}
}
},
"fleetmgmt_vehicle": {
"name": "fleetmgmt_vehicle",
"fields": {
@ -155,6 +203,46 @@
}
}
},
"fleetmgmt_vehicle_inspection": {
"name": "fleetmgmt_vehicle_inspection",
"fields": {
"fleetmgmt_vehicle_inspection_id": {
"name": "fleetmgmt_vehicle_inspection_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"fleetmgmt_vehicle_inspection_description": {
"name": "fleetmgmt_vehicle_inspection_description",
"type": "TEXT",
"null": false
},
"fleetmgmt_vehicle_inspection_status": {
"name": "fleetmgmt_vehicle_inspection_status",
"type": "TINYINT(1)",
"null": false
},
"fleetmgmt_vehicle_inspection_interval": {
"name": "fleetmgmt_vehicle_inspection_interval",
"type": "TINYINT(3)",
"null": false
},
"fleetmgmt_vehicle_inspection_next": {
"name": "fleetmgmt_vehicle_inspection_next",
"type": "DATETIME",
"null": true,
"default": null
},
"fleetmgmt_vehicle_inspection_type": {
"name": "fleetmgmt_vehicle_inspection_type",
"type": "INT",
"null": false,
"foreignTable": "fleetmgmt_inspection_type",
"foreignKey": "fleetmgmt_inspection_type_id"
}
}
},
"fleetmgmt_vehicle_usage": {
"name": "fleetmgmt_vehicle_usage",
"fields": {

View File

@ -20,11 +20,10 @@ use Modules\Attribute\Models\AttributeType;
use Modules\Attribute\Models\AttributeValue;
use Modules\Attribute\Models\NullAttributeType;
use Modules\Attribute\Models\NullAttributeValue;
use Modules\FleetManagement\Models\FuelType;
use Modules\FleetManagement\Models\FuelTypeL11nMapper;
use Modules\FleetManagement\Models\FuelTypeMapper;
use Modules\FleetManagement\Models\NullFuelType;
use Modules\FleetManagement\Models\NullVehicleType;
use Modules\FleetManagement\Models\InspectionTypeL11nMapper;
use Modules\FleetManagement\Models\InspectionTypeMapper;
use Modules\FleetManagement\Models\Vehicle;
use Modules\FleetManagement\Models\VehicleAttributeMapper;
use Modules\FleetManagement\Models\VehicleAttributeTypeL11nMapper;
@ -33,7 +32,8 @@ use Modules\FleetManagement\Models\VehicleAttributeValueL11nMapper;
use Modules\FleetManagement\Models\VehicleAttributeValueMapper;
use Modules\FleetManagement\Models\VehicleMapper;
use Modules\FleetManagement\Models\VehicleStatus;
use Modules\FleetManagement\Models\VehicleType;
use phpOMS\Localization\NullBaseStringL11nType;
use phpOMS\Localization\BaseStringL11nType;
use Modules\FleetManagement\Models\VehicleTypeL11nMapper;
use Modules\FleetManagement\Models\VehicleTypeMapper;
use Modules\Media\Models\CollectionMapper;
@ -75,13 +75,13 @@ final class ApiController extends Controller
public function apiVehicleTypeCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
{
if (!empty($val = $this->validateVehicleTypeCreate($request))) {
$response->set($request->uri->__toString(), new FormValidation($val));
$response->data[$request->uri->__toString()] = new FormValidation($val);
$response->header->status = RequestStatusCode::R_400;
return;
}
/** @var VehicleType $vehicle */
/** @var BaseStringL11nType $vehicle */
$vehicle = $this->createVehicleTypeFromRequest($request);
$this->createModel($request->header->account, $vehicle, VehicleTypeMapper::class, 'vehicle_type', $request->getOrigin());
@ -90,7 +90,7 @@ final class ApiController extends Controller
$response,
NotificationLevel::OK,
'',
$this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'SucessfulCreate'),
$this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'SucessfulCreate'),
$vehicle
);
}
@ -100,14 +100,14 @@ final class ApiController extends Controller
*
* @param RequestAbstract $request Request
*
* @return VehicleType Returns the created vehicle from the request
* @return BaseStringL11nType Returns the created vehicle from the request
*
* @since 1.0.0
*/
public function createVehicleTypeFromRequest(RequestAbstract $request) : VehicleType
public function createVehicleTypeFromRequest(RequestAbstract $request) : BaseStringL11nType
{
$type = new VehicleType();
$type->name = $request->getDataString('name') ?? '';
$type = new BaseStringL11nType();
$type->title = $request->getDataString('name') ?? '';
$type->setL11n($request->getDataString('title') ?? '', $request->getDataString('language') ?? ISO639x1Enum::_EN);
return $type;
@ -150,7 +150,7 @@ final class ApiController extends Controller
public function apiVehicleTypeL11nCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
{
if (!empty($val = $this->validateVehicleTypeL11nCreate($request))) {
$response->set('vehicle_type_l11n_create', new FormValidation($val));
$response->data['vehicle_type_l11n_create'] = new FormValidation($val);
$response->header->status = RequestStatusCode::R_400;
return;
@ -175,7 +175,7 @@ final class ApiController extends Controller
$typeL11n = new BaseStringL11n();
$typeL11n->ref = $request->getDataInt('type') ?? 0;
$typeL11n->setLanguage(
$request->getDataString('language') ?? $request->getLanguage()
$request->getDataString('language') ?? $request->header->l11n->language
);
$typeL11n->content = $request->getDataString('title') ?? '';
@ -219,13 +219,13 @@ final class ApiController extends Controller
public function apiFuelTypeCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
{
if (!empty($val = $this->validateFuelTypeCreate($request))) {
$response->set($request->uri->__toString(), new FormValidation($val));
$response->data[$request->uri->__toString()] = new FormValidation($val);
$response->header->status = RequestStatusCode::R_400;
return;
}
/** @var FuelType $vehicle */
/** @var BaseStringL11nType $vehicle */
$vehicle = $this->createFuelTypeFromRequest($request);
$this->createModel($request->header->account, $vehicle, FuelTypeMapper::class, 'fuel_type', $request->getOrigin());
@ -234,7 +234,7 @@ final class ApiController extends Controller
$response,
NotificationLevel::OK,
'',
$this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'SucessfulCreate'),
$this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'SucessfulCreate'),
$vehicle
);
}
@ -244,14 +244,14 @@ final class ApiController extends Controller
*
* @param RequestAbstract $request Request
*
* @return FuelType Returns the created vehicle from the request
* @return BaseStringL11nType Returns the created vehicle from the request
*
* @since 1.0.0
*/
public function createFuelTypeFromRequest(RequestAbstract $request) : FuelType
public function createFuelTypeFromRequest(RequestAbstract $request) : BaseStringL11nType
{
$type = new FuelType();
$type->name = $request->getDataString('name') ?? '';
$type = new BaseStringL11nType();
$type->title = $request->getDataString('name') ?? '';
$type->setL11n($request->getDataString('title') ?? '', $request->getDataString('language') ?? ISO639x1Enum::_EN);
return $type;
@ -294,7 +294,7 @@ final class ApiController extends Controller
public function apiFuelTypeL11nCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
{
if (!empty($val = $this->validateFuelTypeL11nCreate($request))) {
$response->set('fuel_type_l11n_create', new FormValidation($val));
$response->data['fuel_type_l11n_create'] = new FormValidation($val);
$response->header->status = RequestStatusCode::R_400;
return;
@ -319,7 +319,7 @@ final class ApiController extends Controller
$typeL11n = new BaseStringL11n();
$typeL11n->ref = $request->getDataInt('type') ?? 0;
$typeL11n->setLanguage(
$request->getDataString('language') ?? $request->getLanguage()
$request->getDataString('language') ?? $request->header->l11n->language
);
$typeL11n->content = $request->getDataString('title') ?? '';
@ -363,7 +363,7 @@ final class ApiController extends Controller
public function apiVehicleCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
{
if (!empty($val = $this->validateVehicleCreate($request))) {
$response->set($request->uri->__toString(), new FormValidation($val));
$response->data[$request->uri->__toString()] = new FormValidation($val);
$response->header->status = RequestStatusCode::R_400;
return;
@ -373,7 +373,7 @@ final class ApiController extends Controller
$vehicle = $this->createVehicleFromRequest($request);
$this->createModel($request->header->account, $vehicle, VehicleMapper::class, 'vehicle', $request->getOrigin());
if (!empty($request->getFiles())
if (!empty($request->files)
|| !empty($request->getDataJson('media'))
) {
$this->createVehicleMedia($vehicle, $request);
@ -384,7 +384,7 @@ final class ApiController extends Controller
$response,
NotificationLevel::OK,
'',
$this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'SucessfulCreate'),
$this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'SucessfulCreate'),
$vehicle
);
}
@ -403,8 +403,8 @@ final class ApiController extends Controller
$vehicle = new Vehicle();
$vehicle->name = $request->getDataString('name') ?? '';
$vehicle->info = $request->getDataString('info') ?? '';
$vehicle->type = new NullVehicleType((int) ($request->getDataInt('type') ?? 0));
$vehicle->fuelType = new NullFuelType((int) ($request->getDataInt('fuel') ?? 0));
$vehicle->type = new NullBaseStringL11nType((int) ($request->getDataInt('type') ?? 0));
$vehicle->fuelType = new NullBaseStringL11nType((int) ($request->getDataInt('fuel') ?? 0));
$vehicle->status = (int) ($request->getDataInt('status') ?? VehicleStatus::INACTIVE);
$vehicle->unit = $request->getDataInt('unit') ?? $this->app->unitId;
@ -425,7 +425,7 @@ final class ApiController extends Controller
{
$path = $this->createVehicleDir($vehicle);
if (!empty($uploadedFiles = $request->getFiles())) {
if (!empty($uploadedFiles = $request->files)) {
$uploaded = $this->app->moduleManager->get('Media')->uploadFiles(
names: [],
fileNames: [],
@ -561,7 +561,7 @@ final class ApiController extends Controller
public function apiVehicleAttributeCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
{
if (!empty($val = $this->validateVehicleAttributeCreate($request))) {
$response->set('attribute_create', new FormValidation($val));
$response->data['attribute_create'] = new FormValidation($val);
$response->header->status = RequestStatusCode::R_400;
return;
@ -640,7 +640,7 @@ final class ApiController extends Controller
public function apiVehicleAttributeUpdate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
{
if (!empty($val = $this->validateVehicleAttributeUpdate($request))) {
$response->set('attribute_update', new FormValidation($val));
$response->data['attribute_update'] = new FormValidation($val);
$response->header->status = RequestStatusCode::R_400;
return;
@ -730,7 +730,7 @@ final class ApiController extends Controller
public function apiVehicleAttributeTypeL11nCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
{
if (!empty($val = $this->validateVehicleAttributeTypeL11nCreate($request))) {
$response->set('attr_type_l11n_create', new FormValidation($val));
$response->data['attr_type_l11n_create'] = new FormValidation($val);
$response->header->status = RequestStatusCode::R_400;
return;
@ -755,7 +755,7 @@ final class ApiController extends Controller
$attrL11n = new BaseStringL11n();
$attrL11n->ref = $request->getDataInt('type') ?? 0;
$attrL11n->setLanguage(
$request->getDataString('language') ?? $request->getLanguage()
$request->getDataString('language') ?? $request->header->l11n->language
);
$attrL11n->content = $request->getDataString('title') ?? '';
@ -799,7 +799,7 @@ final class ApiController extends Controller
public function apiVehicleAttributeTypeCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
{
if (!empty($val = $this->validateVehicleAttributeTypeCreate($request))) {
$response->set('attr_type_create', new FormValidation($val));
$response->data['attr_type_create'] = new FormValidation($val);
$response->header->status = RequestStatusCode::R_400;
return;
@ -870,7 +870,7 @@ final class ApiController extends Controller
public function apiVehicleAttributeValueCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
{
if (!empty($val = $this->validateVehicleAttributeValueCreate($request))) {
$response->set('attr_value_create', new FormValidation($val));
$response->data['attr_value_create'] = new FormValidation($val);
$response->header->status = RequestStatusCode::R_400;
return;
@ -955,7 +955,7 @@ final class ApiController extends Controller
public function apiVehicleAttributeValueL11nCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
{
if (!empty($val = $this->validateVehicleAttributeValueL11nCreate($request))) {
$response->set('attr_value_l11n_create', new FormValidation($val));
$response->data['attr_value_l11n_create'] = new FormValidation($val);
$response->header->status = RequestStatusCode::R_400;
return;
@ -980,7 +980,7 @@ final class ApiController extends Controller
$attrL11n = new BaseStringL11n();
$attrL11n->ref = $request->getDataInt('value') ?? 0;
$attrL11n->setLanguage(
$request->getDataString('language') ?? $request->getLanguage()
$request->getDataString('language') ?? $request->header->l11n->language
);
$attrL11n->content = $request->getDataString('title') ?? '';
@ -1024,7 +1024,7 @@ final class ApiController extends Controller
public function apiVehicleAttribute(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
{
if (!empty($val = $this->validateVehicleAttributeValueL11nCreate($request))) {
$response->set('attr_value_l11n_create', new FormValidation($val));
$response->data['attr_value_l11n_create'] = new FormValidation($val);
$response->header->status = RequestStatusCode::R_400;
return;
@ -1051,7 +1051,7 @@ final class ApiController extends Controller
public function apiMediaAddToVehicle(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
{
if (!empty($val = $this->validateMediaAddToVehicle($request))) {
$response->set($request->uri->__toString(), new FormValidation($val));
$response->data[$request->uri->__toString()] = new FormValidation($val);
$response->header->status = RequestStatusCode::R_400;
return;
@ -1062,7 +1062,7 @@ final class ApiController extends Controller
$path = $this->createVehicleDir($vehicle);
$uploaded = [];
if (!empty($uploadedFiles = $request->getFiles())) {
if (!empty($uploadedFiles = $request->files)) {
$uploaded = $this->app->moduleManager->get('Media')->uploadFiles(
names: [],
fileNames: [],
@ -1171,7 +1171,7 @@ final class ApiController extends Controller
private function validateMediaAddToVehicle(RequestAbstract $request) : array
{
$val = [];
if (($val['media'] = (!$request->hasData('media') && empty($request->getFiles())))
if (($val['media'] = (!$request->hasData('media') && empty($request->files)))
|| ($val['vehicle'] = !$request->hasData('vehicle'))
) {
return $val;
@ -1179,4 +1179,148 @@ final class ApiController extends Controller
return [];
}
/**
* Api method to create a vehicle
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiInspectionTypeCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
{
if (!empty($val = $this->validateInspectionTypeCreate($request))) {
$response->data[$request->uri->__toString()] = new FormValidation($val);
$response->header->status = RequestStatusCode::R_400;
return;
}
/** @var BaseStringL11nType $vehicle */
$vehicle = $this->createInspectionTypeFromRequest($request);
$this->createModel($request->header->account, $vehicle, InspectionTypeMapper::class, 'inspection_type', $request->getOrigin());
$this->fillJsonResponse(
$request,
$response,
NotificationLevel::OK,
'',
$this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'SucessfulCreate'),
$vehicle
);
}
/**
* Method to create vehicle from request.
*
* @param RequestAbstract $request Request
*
* @return BaseStringL11nType Returns the created vehicle from the request
*
* @since 1.0.0
*/
public function createInspectionTypeFromRequest(RequestAbstract $request) : BaseStringL11nType
{
$type = new BaseStringL11nType();
$type->title = $request->getDataString('name') ?? '';
$type->setL11n($request->getDataString('title') ?? '', $request->getDataString('language') ?? ISO639x1Enum::_EN);
return $type;
}
/**
* Validate vehicle create request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool> Returns the validation array of the request
*
* @since 1.0.0
*/
private function validateInspectionTypeCreate(RequestAbstract $request) : array
{
$val = [];
if (($val['name'] = !$request->hasData('name'))
|| ($val['title'] = !$request->hasData('title'))
) {
return $val;
}
return [];
}
/**
* Api method to create vehicle attribute l11n
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiInspectionTypeL11nCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
{
if (!empty($val = $this->validateInspectionTypeL11nCreate($request))) {
$response->data['inspection_type_l11n_create'] = new FormValidation($val);
$response->header->status = RequestStatusCode::R_400;
return;
}
$typeL11n = $this->createInspectionTypeL11nFromRequest($request);
$this->createModel($request->header->account, $typeL11n, InspectionTypeL11nMapper::class, 'inspection_type_l11n', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Localization', 'Localization successfully created', $typeL11n);
}
/**
* Method to create vehicle attribute l11n from request.
*
* @param RequestAbstract $request Request
*
* @return BaseStringL11n
*
* @since 1.0.0
*/
private function createInspectionTypeL11nFromRequest(RequestAbstract $request) : BaseStringL11n
{
$typeL11n = new BaseStringL11n();
$typeL11n->ref = $request->getDataInt('type') ?? 0;
$typeL11n->setLanguage(
$request->getDataString('language') ?? $request->header->l11n->language
);
$typeL11n->content = $request->getDataString('title') ?? '';
return $typeL11n;
}
/**
* Validate vehicle attribute l11n create request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @since 1.0.0
*/
private function validateInspectionTypeL11nCreate(RequestAbstract $request) : array
{
$val = [];
if (($val['title'] = !$request->hasData('title'))
|| ($val['type'] = !$request->hasData('type'))
) {
return $val;
}
return [];
}
}

View File

@ -53,15 +53,15 @@ final class BackendController extends Controller
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/FleetManagement/Theme/Backend/attribute-type-list');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1003503001, $request, $response));
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1003503001, $request, $response);
/** @var \Modules\Attribute\Models\AttributeType[] $attributes */
$attributes = VehicleAttributeTypeMapper::getAll()
->with('l11n')
->where('l11n/language', $response->getLanguage())
->where('l11n/language', $response->header->l11n->language)
->execute();
$view->addData('attributes', $attributes);
$view->data['attributes'] = $attributes;
return $view;
}
@ -83,16 +83,16 @@ final class BackendController extends Controller
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/FleetManagement/Theme/Backend/vehicle-list');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1003502001, $request, $response));
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1003502001, $request, $response);
$list = VehicleMapper::getAll()
->with('type')
->with('type/l11n')
->where('type/l11n/language', $response->getLanguage())
->where('type/l11n/language', $response->header->l11n->language)
->sort('id', 'DESC')
->execute();
$view->setData('vehicles', $list);
$view->data['vehicles'] = $list;
return $view;
}
@ -113,21 +113,21 @@ final class BackendController extends Controller
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/FleetManagement/Theme/Backend/attribute-type');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004801001, $request, $response));
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1004801001, $request, $response);
/** @var \Modules\Attribute\Models\AttributeType $attribute */
$attribute = VehicleAttributeTypeMapper::get()
->with('l11n')
->where('id', (int) $request->getData('id'))
->where('l11n/language', $response->getLanguage())
->where('l11n/language', $response->header->l11n->language)
->execute();
$l11ns = VehicleAttributeTypeL11nMapper::getAll()
->where('ref', $attribute->id)
->execute();
$view->addData('attribute', $attribute);
$view->addData('l11ns', $l11ns);
$view->data['attribute'] = $attribute;
$view->data['l11ns'] = $l11ns;
return $view;
}
@ -149,7 +149,7 @@ final class BackendController extends Controller
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/FleetManagement/Theme/Backend/vehicle-profile');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1003502001, $request, $response));
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1003502001, $request, $response);
$vehicle = VehicleMapper::get()
->with('attributes')
@ -161,12 +161,12 @@ final class BackendController extends Controller
->with('fuelType')
->with('fuelType/l11n')
->where('id', (int) $request->getData('id'))
->where('type/l11n/language', $response->getLanguage())
->where('fuelType/l11n/language', $response->getLanguage())
->where('attributes/type/l11n/language', $response->getLanguage())
->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)
->execute();
$view->setData('vehicle', $vehicle);
$view->data['vehicle'] = $vehicle;
$query = new Builder($this->app->dbPool->get());
$results = $query->selectAs(VehicleMapper::HAS_MANY['files']['external'], 'file')
@ -188,14 +188,14 @@ final class BackendController extends Controller
->limit(1)
->execute();
$view->addData('vehicleImage', $vehicleImage);
$view->data['vehicleImage'] = $vehicleImage;
$vehicleTypes = VehicleTypeMapper::getAll()
->with('l11n')
->where('l11n/language', $response->getLanguage())
->where('l11n/language', $response->header->l11n->language)
->execute();
$view->addData('types', $vehicleTypes);
$view->data['types'] = $vehicleTypes;
return $view;
}

View File

@ -1,121 +0,0 @@
<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package Modules\FleetManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\FleetManagement\Models;
use phpOMS\Localization\BaseStringL11n;
use phpOMS\Localization\ISO639x1Enum;
/**
* Fuel Type class.
*
* @package Modules\FleetManagement\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
class FuelType implements \JsonSerializable
{
/**
* Id
*
* @var int
* @since 1.0.0
*/
public int $id = 0;
/**
* Name/string identifier by which it can be found/categorized
*
* @var string
* @since 1.0.0
*/
public string $name = '';
/**
* Localization
*
* @var BaseStringL11n
*/
public string | BaseStringL11n $l11n = '';
/**
* Constructor.
*
* @param string $name Name/identifier of the attribute type
*
* @since 1.0.0
*/
public function __construct(string $name = '')
{
$this->name = $name;
}
/**
* Set l11n
*
* @param string|BaseStringL11n $l11n Tag article l11n
* @param string $lang Language
*
* @return void
*
* @since 1.0.0
*/
public function setL11n(string | BaseStringL11n $l11n, string $lang = ISO639x1Enum::_EN) : void
{
if ($l11n instanceof BaseStringL11n) {
$this->l11n = $l11n;
} elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) {
$this->l11n->content = $l11n;
$this->l11n->setLanguage($lang);
} else {
$this->l11n = new BaseStringL11n();
$this->l11n->content = $l11n;
$this->l11n->setLanguage($lang);
}
}
/**
* @return string
*
* @since 1.0.0
*/
public function getL11n() : string
{
if (!isset($this->l11n)) {
return '';
}
return $this->l11n instanceof BaseStringL11n ? $this->l11n->content : $this->l11n;
}
/**
* {@inheritdoc}
*/
public function toArray() : array
{
return [
'id' => $this->id,
'name' => $this->name,
];
}
/**
* {@inheritdoc}
*/
public function jsonSerialize() : mixed
{
return $this->toArray();
}
}

View File

@ -15,6 +15,7 @@ declare(strict_types=1);
namespace Modules\FleetManagement\Models;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
use phpOMS\Localization\BaseStringL11nType;
/**
* Item mapper class.
@ -24,7 +25,7 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
* @link https://jingga.app
* @since 1.0.0
*
* @template T of FuelType
* @template T of BaseStringL11nType
* @extends DataMapperFactory<T>
*/
final class FuelTypeMapper extends DataMapperFactory
@ -37,7 +38,7 @@ final class FuelTypeMapper extends DataMapperFactory
*/
public const COLUMNS = [
'fleetmgmt_fuel_type_id' => ['name' => 'fleetmgmt_fuel_type_id', 'type' => 'int', 'internal' => 'id'],
'fleetmgmt_fuel_type_name' => ['name' => 'fleetmgmt_fuel_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
'fleetmgmt_fuel_type_name' => ['name' => 'fleetmgmt_fuel_type_name', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true],
];
/**
@ -62,7 +63,7 @@ final class FuelTypeMapper extends DataMapperFactory
* @var class-string<T>
* @since 1.0.0
*/
public const MODEL = FuelType::class;
public const MODEL = BaseStringL11nType::class;
/**
* Primary table.

View File

@ -0,0 +1,54 @@
<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package Modules\FleetManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\FleetManagement\Models;
/**
* Inspection class.
*
* @package Modules\Attribute\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
class Inspection implements \JsonSerializable
{
public int $id = 0;
public string $description = '';
public BaseStringL11nType $type;
public int $status = InspectionStatus::TODO;
// Automatically get's filled from the previous inspection if available
// Alternatively define default interval from inspection type?
public ?\DateTime $next = null;
/**
* Inspectio interval in months
*
* @var int
* @since 1.0.0
*/
public int $interval = 0;
public function __construct()
{
$this->type = new BaseStringL11nType();
}
use \Modules\Media\Models\MediaListTrait;
}

View File

@ -0,0 +1,84 @@
<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package Modules\FleetManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\FleetManagement\Models;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
use phpOMS\Localization\BaseStringL11n;
/**
* mapper class.
*
* @package Modules\FleetManagement\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*
* @template T of BaseStringL11n
* @extends DataMapperFactory<T>
*/
final class InspectionMapper extends DataMapperFactory
{
/**
* Columns.
*
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
public const COLUMNS = [
'fleetmgmt_vehicle_inspection_id' => ['name' => 'fleetmgmt_vehicle_inspection_id', 'type' => 'int', 'internal' => 'id'],
'fleetmgmt_vehicle_inspection_description' => ['name' => 'fleetmgmt_vehicle_inspection_description', 'type' => 'string', 'internal' => 'description'],
'fleetmgmt_vehicle_inspection_status' => ['name' => 'fleetmgmt_vehicle_inspection_status', 'type' => 'int', 'internal' => 'status'],
'fleetmgmt_vehicle_inspection_interval' => ['name' => 'fleetmgmt_vehicle_inspection_interval', 'type' => 'int', 'internal' => 'interval'],
'fleetmgmt_vehicle_inspection_next' => ['name' => 'fleetmgmt_vehicle_inspection_next', 'type' => 'DateTime', 'internal' => 'next'],
'fleetmgmt_vehicle_inspection_type' => ['name' => 'fleetmgmt_vehicle_inspection_type', 'type' => 'int', 'internal' => 'type'],
];
/**
* Has one relation.
*
* @var array<string, array{mapper:class-string, external:string, by?:string, column?:string, conditional?:bool}>
* @since 1.0.0
*/
public const OWNS_ONE = [
'type' => [
'mapper' => InspectionTypeMapper::class,
'external' => 'fleetmgmt_vehicle_inspection_type',
],
];
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
public const TABLE = 'fleetmgmt_vehicle_inspection';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
public const PRIMARYFIELD = 'fleetmgmt_vehicle_inspection_id';
/**
* Model to use by the mapper.
*
* @var class-string<T>
* @since 1.0.0
*/
public const MODEL = Inspection::class;
}

View File

@ -14,33 +14,23 @@ declare(strict_types=1);
namespace Modules\FleetManagement\Models;
use phpOMS\Stdlib\Base\Enum;
/**
* Null model
* Inspection status enum.
*
* @package Modules\FleetManagement\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
final class NullFuelType extends FuelType
abstract class InspectionStatus extends Enum
{
/**
* Constructor
*
* @param int $id Model id
*
* @since 1.0.0
*/
public function __construct(int $id = 0)
{
$this->id = $id;
}
public const DONE = 1;
/**
* {@inheritdoc}
*/
public function jsonSerialize() : mixed
{
return ['id' => $this->id];
}
public const PASSED = 2;
public const ONGOING = 4;
public const TODO = 5;
}

View File

@ -0,0 +1,69 @@
<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package Modules\FleetManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\FleetManagement\Models;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
use phpOMS\Localization\BaseStringL11n;
/**
* mapper class.
*
* @package Modules\FleetManagement\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*
* @template T of BaseStringL11n
* @extends DataMapperFactory<T>
*/
final class InspectionTypeL11nMapper extends DataMapperFactory
{
/**
* Columns.
*
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
public const COLUMNS = [
'fleetmgmt_inspection_type_l11n_id' => ['name' => 'fleetmgmt_inspection_type_l11n_id', 'type' => 'int', 'internal' => 'id'],
'fleetmgmt_inspection_type_l11n_title' => ['name' => 'fleetmgmt_inspection_type_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true],
'fleetmgmt_inspection_type_l11n_type' => ['name' => 'fleetmgmt_inspection_type_l11n_type', 'type' => 'int', 'internal' => 'ref'],
'fleetmgmt_inspection_type_l11n_lang' => ['name' => 'fleetmgmt_inspection_type_l11n_lang', 'type' => 'string', 'internal' => 'language'],
];
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
public const TABLE = 'fleetmgmt_inspection_type_l11n';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
public const PRIMARYFIELD = 'fleetmgmt_inspection_type_l11n_id';
/**
* Model to use by the mapper.
*
* @var class-string<T>
* @since 1.0.0
*/
public const MODEL = BaseStringL11n::class;
}

View File

@ -0,0 +1,83 @@
<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package Modules\FleetManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\FleetManagement\Models;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
use phpOMS\Localization\BaseStringL11nType;
/**
* Item mapper class.
*
* @package Modules\FleetManagement\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*
* @template T of BaseStringL11nType
* @extends DataMapperFactory<T>
*/
final class InspectionTypeMapper extends DataMapperFactory
{
/**
* Columns.
*
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
public const COLUMNS = [
'fleetmgmt_inspection_type_id' => ['name' => 'fleetmgmt_inspection_type_id', 'type' => 'int', 'internal' => 'id'],
'fleetmgmt_inspection_type_name' => ['name' => 'fleetmgmt_inspection_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
];
/**
* Has many relation.
*
* @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
* @since 1.0.0
*/
public const HAS_MANY = [
'l11n' => [
'mapper' => InspectionTypeL11nMapper::class,
'table' => 'fleetmgmt_inspection_type_l11n',
'self' => 'fleetmgmt_inspection_type_l11n_type',
'column' => 'content',
'external' => null,
],
];
/**
* Model to use by the mapper.
*
* @var class-string<T>
* @since 1.0.0
*/
public const MODEL = BaseStringL11nType::class;
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
public const TABLE = 'fleetmgmt_inspection_type';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
public const PRIMARYFIELD = 'fleetmgmt_inspection_type_id';
}

View File

@ -1,46 +0,0 @@
<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package Modules\FleetManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\FleetManagement\Models;
/**
* Null model
*
* @package Modules\FleetManagement\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
final class NullVehicleType extends VehicleType
{
/**
* Constructor
*
* @param int $id Model id
*
* @since 1.0.0
*/
public function __construct(int $id = 0)
{
$this->id = $id;
}
/**
* {@inheritdoc}
*/
public function jsonSerialize() : mixed
{
return ['id' => $this->id];
}
}

View File

@ -27,4 +27,14 @@ use phpOMS\Stdlib\Base\Enum;
abstract class PermissionCategory extends Enum
{
public const VEHICLE = 1;
public const FUEL_TYPE = 2;
public const VEHICLE_TYPE = 3;
public const INSPECTION_TYPE = 4;
public const INSPECTION = 5;
public const ATTRIBUTE_TYPE = 6;
}

View File

@ -14,8 +14,10 @@ declare(strict_types=1);
namespace Modules\FleetManagement\Models;
use phpOMS\Localization\BaseStringL11nType;
/**
* class.
* Vehicle class.
*
* @package Modules\Attribute\Models
* @license OMS License 2.0
@ -30,9 +32,9 @@ class Vehicle implements \JsonSerializable
public int $status = VehicleStatus::ACTIVE;
public VehicleType $type;
public BaseStringL11nType $type;
public FuelType $fuelType;
public BaseStringL11nType $fuelType;
public string $info = '';
@ -53,8 +55,8 @@ class Vehicle implements \JsonSerializable
public function __construct()
{
$this->createdAt = new \DateTimeImmutable('now');
$this->type = new VehicleType();
$this->fuelType = new FuelType();
$this->type = new BaseStringL11nType();
$this->fuelType = new BaseStringL11nType();
}
/**

View File

@ -1,121 +0,0 @@
<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package Modules\FleetManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\FleetManagement\Models;
use phpOMS\Localization\BaseStringL11n;
use phpOMS\Localization\ISO639x1Enum;
/**
* Vehicle Type class.
*
* @package Modules\FleetManagement\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
class VehicleType implements \JsonSerializable
{
/**
* Id
*
* @var int
* @since 1.0.0
*/
public int $id = 0;
/**
* Name/string identifier by which it can be found/categorized
*
* @var string
* @since 1.0.0
*/
public string $name = '';
/**
* Localization
*
* @var BaseStringL11n
*/
public string | BaseStringL11n $l11n = '';
/**
* Constructor.
*
* @param string $name Name/identifier of the attribute type
*
* @since 1.0.0
*/
public function __construct(string $name = '')
{
$this->name = $name;
}
/**
* Set l11n
*
* @param string|BaseStringL11n $l11n Tag article l11n
* @param string $lang Language
*
* @return void
*
* @since 1.0.0
*/
public function setL11n(string | BaseStringL11n $l11n, string $lang = ISO639x1Enum::_EN) : void
{
if ($l11n instanceof BaseStringL11n) {
$this->l11n = $l11n;
} elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) {
$this->l11n->content = $l11n;
$this->l11n->setLanguage($lang);
} else {
$this->l11n = new BaseStringL11n();
$this->l11n->content = $l11n;
$this->l11n->setLanguage($lang);
}
}
/**
* @return string
*
* @since 1.0.0
*/
public function getL11n() : string
{
if (!isset($this->l11n)) {
return '';
}
return $this->l11n instanceof BaseStringL11n ? $this->l11n->content : $this->l11n;
}
/**
* {@inheritdoc}
*/
public function toArray() : array
{
return [
'id' => $this->id,
'name' => $this->name,
];
}
/**
* {@inheritdoc}
*/
public function jsonSerialize() : mixed
{
return $this->toArray();
}
}

View File

@ -40,7 +40,6 @@ final class VehicleTypeL11nMapper extends DataMapperFactory
'fleetmgmt_vehicle_type_l11n_id' => ['name' => 'fleetmgmt_vehicle_type_l11n_id', 'type' => 'int', 'internal' => 'id'],
'fleetmgmt_vehicle_type_l11n_title' => ['name' => 'fleetmgmt_vehicle_type_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true],
'fleetmgmt_vehicle_type_l11n_type' => ['name' => 'fleetmgmt_vehicle_type_l11n_type', 'type' => 'int', 'internal' => 'ref'],
'fleetmgmt_vehicle_type_l11n_lang' => ['name' => 'fleetmgmt_vehicle_type_l11n_lang', 'type' => 'string', 'internal' => 'language'],
];
/**

View File

@ -15,6 +15,7 @@ declare(strict_types=1);
namespace Modules\FleetManagement\Models;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
use phpOMS\Localization\BaseStringL11nType;
/**
* Item mapper class.
@ -24,7 +25,7 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
* @link https://jingga.app
* @since 1.0.0
*
* @template T of VehicleType
* @template T of BaseStringL11nType
* @extends DataMapperFactory<T>
*/
final class VehicleTypeMapper extends DataMapperFactory
@ -37,7 +38,8 @@ final class VehicleTypeMapper extends DataMapperFactory
*/
public const COLUMNS = [
'fleetmgmt_vehicle_type_id' => ['name' => 'fleetmgmt_vehicle_type_id', 'type' => 'int', 'internal' => 'id'],
'fleetmgmt_vehicle_type_name' => ['name' => 'fleetmgmt_vehicle_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
'fleetmgmt_vehicle_type_name' => ['name' => 'fleetmgmt_vehicle_type_name', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true],
];
/**
@ -62,7 +64,7 @@ final class VehicleTypeMapper extends DataMapperFactory
* @var class-string<T>
* @since 1.0.0
*/
public const MODEL = VehicleType::class;
public const MODEL = BaseStringL11nType::class;
/**
* Primary table.

View File

@ -15,9 +15,9 @@ declare(strict_types=1);
use phpOMS\Uri\UriFactory;
/** @var \phpOMS\Views\View $this */
$attributes = $this->getData('attributes');
$attributes = $this->data['attributes'];
echo $this->getData('nav')->render(); ?>
echo $this->data['nav']->render(); ?>
<div class="row">
<div class="col-xs-12">

View File

@ -17,10 +17,10 @@ use phpOMS\Localization\ISO639Enum;
$types = AttributeValueType::getConstants();
$attribute = $this->getData('attribute');
$l11ns = $this->getData('l11ns');
$attribute = $this->data['attribute'];
$l11ns = $this->data['l11ns'];
echo $this->getData('nav')->render(); ?>
echo $this->data['nav']->render(); ?>
<div class="row">
<div class="col-md-6 col-xs-12">

View File

@ -15,7 +15,7 @@ declare(strict_types=1);
/**
* @var \phpOMS\Views\View $this
*/
echo $this->getData('nav')->render(); ?>
echo $this->data['nav']->render(); ?>
<div class="tabview tab-2">
<div class="box">

View File

@ -16,9 +16,9 @@ declare(strict_types=1);
use phpOMS\Uri\UriFactory;
/** @var \phpOMS\Views\View $this */
$vehicles = $this->getData('vehicles') ?? [];
$vehicles = $this->data['vehicles'] ?? [];
echo $this->getData('nav')->render(); ?>
echo $this->data['nav']->render(); ?>
<div class="row">
<div class="col-xs-12">
<section class="portlet">

View File

@ -25,14 +25,14 @@ $vehicleStatus = VehicleStatus::getConstants();
* @var \Modules\FleetManagement\Models\Vehicle $vehicle
*/
$vehicle = $this->getData('vehicle') ?? new NullVehicle();
$files = $vehicle->getFiles();
$files = $vehicle->files;
$vehicleImage = $this->getData('vehicleImage') ?? new NullMedia();
$vehicleTypes = $this->getData('types') ?? [];
$vehicleTypes = $this->data['types'] ?? [];
/**
* @var \phpOMS\Views\View $this
*/
echo $this->getData('nav')->render();
echo $this->data['nav']->render();
?>
<div class="tabview tab-2">
<div class="box">