mirror of
https://github.com/Karaka-Management/oms-FleetManagement.git
synced 2026-02-16 13:28:41 +00:00
Implement Inspections and BaseStringL11nType
This commit is contained in:
parent
6e0198bac2
commit
44abf6044d
|
|
@ -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": {
|
"fleetmgmt_vehicle": {
|
||||||
"name": "fleetmgmt_vehicle",
|
"name": "fleetmgmt_vehicle",
|
||||||
"fields": {
|
"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": {
|
"fleetmgmt_vehicle_usage": {
|
||||||
"name": "fleetmgmt_vehicle_usage",
|
"name": "fleetmgmt_vehicle_usage",
|
||||||
"fields": {
|
"fields": {
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,8 @@ use Modules\Attribute\Models\AttributeType;
|
||||||
use Modules\Attribute\Models\AttributeValue;
|
use Modules\Attribute\Models\AttributeValue;
|
||||||
use Modules\Attribute\Models\NullAttributeType;
|
use Modules\Attribute\Models\NullAttributeType;
|
||||||
use Modules\Attribute\Models\NullAttributeValue;
|
use Modules\Attribute\Models\NullAttributeValue;
|
||||||
use Modules\FleetManagement\Models\FuelType;
|
|
||||||
use Modules\FleetManagement\Models\FuelTypeL11nMapper;
|
use Modules\FleetManagement\Models\FuelTypeL11nMapper;
|
||||||
use Modules\FleetManagement\Models\FuelTypeMapper;
|
use Modules\FleetManagement\Models\FuelTypeMapper;
|
||||||
use Modules\FleetManagement\Models\NullFuelType;
|
|
||||||
use Modules\FleetManagement\Models\NullVehicleType;
|
|
||||||
use Modules\FleetManagement\Models\Vehicle;
|
use Modules\FleetManagement\Models\Vehicle;
|
||||||
use Modules\FleetManagement\Models\VehicleAttributeMapper;
|
use Modules\FleetManagement\Models\VehicleAttributeMapper;
|
||||||
use Modules\FleetManagement\Models\VehicleAttributeTypeL11nMapper;
|
use Modules\FleetManagement\Models\VehicleAttributeTypeL11nMapper;
|
||||||
|
|
@ -33,7 +30,8 @@ use Modules\FleetManagement\Models\VehicleAttributeValueL11nMapper;
|
||||||
use Modules\FleetManagement\Models\VehicleAttributeValueMapper;
|
use Modules\FleetManagement\Models\VehicleAttributeValueMapper;
|
||||||
use Modules\FleetManagement\Models\VehicleMapper;
|
use Modules\FleetManagement\Models\VehicleMapper;
|
||||||
use Modules\FleetManagement\Models\VehicleStatus;
|
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\VehicleTypeL11nMapper;
|
||||||
use Modules\FleetManagement\Models\VehicleTypeMapper;
|
use Modules\FleetManagement\Models\VehicleTypeMapper;
|
||||||
use Modules\Media\Models\CollectionMapper;
|
use Modules\Media\Models\CollectionMapper;
|
||||||
|
|
@ -81,7 +79,7 @@ final class ApiController extends Controller
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var VehicleType $vehicle */
|
/** @var BaseStringL11nType $vehicle */
|
||||||
$vehicle = $this->createVehicleTypeFromRequest($request);
|
$vehicle = $this->createVehicleTypeFromRequest($request);
|
||||||
$this->createModel($request->header->account, $vehicle, VehicleTypeMapper::class, 'vehicle_type', $request->getOrigin());
|
$this->createModel($request->header->account, $vehicle, VehicleTypeMapper::class, 'vehicle_type', $request->getOrigin());
|
||||||
|
|
||||||
|
|
@ -100,14 +98,14 @@ final class ApiController extends Controller
|
||||||
*
|
*
|
||||||
* @param RequestAbstract $request Request
|
* @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
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function createVehicleTypeFromRequest(RequestAbstract $request) : VehicleType
|
public function createVehicleTypeFromRequest(RequestAbstract $request) : BaseStringL11nType
|
||||||
{
|
{
|
||||||
$type = new VehicleType();
|
$type = new BaseStringL11nType();
|
||||||
$type->name = $request->getDataString('name') ?? '';
|
$type->title = $request->getDataString('name') ?? '';
|
||||||
$type->setL11n($request->getDataString('title') ?? '', $request->getDataString('language') ?? ISO639x1Enum::_EN);
|
$type->setL11n($request->getDataString('title') ?? '', $request->getDataString('language') ?? ISO639x1Enum::_EN);
|
||||||
|
|
||||||
return $type;
|
return $type;
|
||||||
|
|
@ -225,7 +223,7 @@ final class ApiController extends Controller
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var FuelType $vehicle */
|
/** @var BaseStringL11nType $vehicle */
|
||||||
$vehicle = $this->createFuelTypeFromRequest($request);
|
$vehicle = $this->createFuelTypeFromRequest($request);
|
||||||
$this->createModel($request->header->account, $vehicle, FuelTypeMapper::class, 'fuel_type', $request->getOrigin());
|
$this->createModel($request->header->account, $vehicle, FuelTypeMapper::class, 'fuel_type', $request->getOrigin());
|
||||||
|
|
||||||
|
|
@ -244,14 +242,14 @@ final class ApiController extends Controller
|
||||||
*
|
*
|
||||||
* @param RequestAbstract $request Request
|
* @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
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function createFuelTypeFromRequest(RequestAbstract $request) : FuelType
|
public function createFuelTypeFromRequest(RequestAbstract $request) : BaseStringL11nType
|
||||||
{
|
{
|
||||||
$type = new FuelType();
|
$type = new BaseStringL11nType();
|
||||||
$type->name = $request->getDataString('name') ?? '';
|
$type->title = $request->getDataString('name') ?? '';
|
||||||
$type->setL11n($request->getDataString('title') ?? '', $request->getDataString('language') ?? ISO639x1Enum::_EN);
|
$type->setL11n($request->getDataString('title') ?? '', $request->getDataString('language') ?? ISO639x1Enum::_EN);
|
||||||
|
|
||||||
return $type;
|
return $type;
|
||||||
|
|
@ -403,8 +401,8 @@ final class ApiController extends Controller
|
||||||
$vehicle = new Vehicle();
|
$vehicle = new Vehicle();
|
||||||
$vehicle->name = $request->getDataString('name') ?? '';
|
$vehicle->name = $request->getDataString('name') ?? '';
|
||||||
$vehicle->info = $request->getDataString('info') ?? '';
|
$vehicle->info = $request->getDataString('info') ?? '';
|
||||||
$vehicle->type = new NullVehicleType((int) ($request->getDataInt('type') ?? 0));
|
$vehicle->type = new NullBaseStringL11nType((int) ($request->getDataInt('type') ?? 0));
|
||||||
$vehicle->fuelType = new NullFuelType((int) ($request->getDataInt('fuel') ?? 0));
|
$vehicle->fuelType = new NullBaseStringL11nType((int) ($request->getDataInt('fuel') ?? 0));
|
||||||
$vehicle->status = (int) ($request->getDataInt('status') ?? VehicleStatus::INACTIVE);
|
$vehicle->status = (int) ($request->getDataInt('status') ?? VehicleStatus::INACTIVE);
|
||||||
$vehicle->unit = $request->getDataInt('unit') ?? $this->app->unitId;
|
$vehicle->unit = $request->getDataInt('unit') ?? $this->app->unitId;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -15,6 +15,7 @@ declare(strict_types=1);
|
||||||
namespace Modules\FleetManagement\Models;
|
namespace Modules\FleetManagement\Models;
|
||||||
|
|
||||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||||
|
use phpOMS\Localization\BaseStringL11nType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Item mapper class.
|
* Item mapper class.
|
||||||
|
|
@ -37,7 +38,7 @@ final class FuelTypeMapper extends DataMapperFactory
|
||||||
*/
|
*/
|
||||||
public const COLUMNS = [
|
public const COLUMNS = [
|
||||||
'fleetmgmt_fuel_type_id' => ['name' => 'fleetmgmt_fuel_type_id', 'type' => 'int', 'internal' => 'id'],
|
'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>
|
* @var class-string<T>
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public const MODEL = FuelType::class;
|
public const MODEL = BaseStringL11nType::class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Primary table.
|
* Primary table.
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
}
|
||||||
84
Models/InspectionMapper.php
Normal file
84
Models/InspectionMapper.php
Normal 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;
|
||||||
|
}
|
||||||
|
|
@ -14,33 +14,23 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Modules\FleetManagement\Models;
|
namespace Modules\FleetManagement\Models;
|
||||||
|
|
||||||
|
use phpOMS\Stdlib\Base\Enum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Null model
|
* Inspection status enum.
|
||||||
*
|
*
|
||||||
* @package Modules\FleetManagement\Models
|
* @package Modules\FleetManagement\Models
|
||||||
* @license OMS License 2.0
|
* @license OMS License 2.0
|
||||||
* @link https://jingga.app
|
* @link https://jingga.app
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
final class NullFuelType extends FuelType
|
abstract class InspectionStatus extends Enum
|
||||||
{
|
{
|
||||||
/**
|
public const DONE = 1;
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @param int $id Model id
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
public function __construct(int $id = 0)
|
|
||||||
{
|
|
||||||
$this->id = $id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
public const PASSED = 2;
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
public const ONGOING = 4;
|
||||||
public function jsonSerialize() : mixed
|
|
||||||
{
|
public const TODO = 5;
|
||||||
return ['id' => $this->id];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
69
Models/InspectionTypeL11nMapper.php
Normal file
69
Models/InspectionTypeL11nMapper.php
Normal 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;
|
||||||
|
}
|
||||||
83
Models/InspectionTypeMapper.php
Normal file
83
Models/InspectionTypeMapper.php
Normal 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 FuelType
|
||||||
|
* @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' => FuelTypeL11nMapper::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';
|
||||||
|
}
|
||||||
|
|
@ -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];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -14,8 +14,10 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Modules\FleetManagement\Models;
|
namespace Modules\FleetManagement\Models;
|
||||||
|
|
||||||
|
use phpOMS\Localization\BaseStringL11n;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class.
|
* Vehicle class.
|
||||||
*
|
*
|
||||||
* @package Modules\Attribute\Models
|
* @package Modules\Attribute\Models
|
||||||
* @license OMS License 2.0
|
* @license OMS License 2.0
|
||||||
|
|
@ -30,7 +32,7 @@ class Vehicle implements \JsonSerializable
|
||||||
|
|
||||||
public int $status = VehicleStatus::ACTIVE;
|
public int $status = VehicleStatus::ACTIVE;
|
||||||
|
|
||||||
public VehicleType $type;
|
public BaseStringL11n $type;
|
||||||
|
|
||||||
public FuelType $fuelType;
|
public FuelType $fuelType;
|
||||||
|
|
||||||
|
|
@ -53,7 +55,7 @@ class Vehicle implements \JsonSerializable
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->createdAt = new \DateTimeImmutable('now');
|
$this->createdAt = new \DateTimeImmutable('now');
|
||||||
$this->type = new VehicleType();
|
$this->type = new BaseStringL11n();
|
||||||
$this->fuelType = new FuelType();
|
$this->fuelType = new FuelType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -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_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_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_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'],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ declare(strict_types=1);
|
||||||
namespace Modules\FleetManagement\Models;
|
namespace Modules\FleetManagement\Models;
|
||||||
|
|
||||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||||
|
use phpOMS\Localization\BaseStringL11nType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Item mapper class.
|
* Item mapper class.
|
||||||
|
|
@ -24,7 +25,7 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||||
* @link https://jingga.app
|
* @link https://jingga.app
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*
|
*
|
||||||
* @template T of VehicleType
|
* @template T of BaseStringL11nType
|
||||||
* @extends DataMapperFactory<T>
|
* @extends DataMapperFactory<T>
|
||||||
*/
|
*/
|
||||||
final class VehicleTypeMapper extends DataMapperFactory
|
final class VehicleTypeMapper extends DataMapperFactory
|
||||||
|
|
@ -37,7 +38,8 @@ final class VehicleTypeMapper extends DataMapperFactory
|
||||||
*/
|
*/
|
||||||
public const COLUMNS = [
|
public const COLUMNS = [
|
||||||
'fleetmgmt_vehicle_type_id' => ['name' => 'fleetmgmt_vehicle_type_id', 'type' => 'int', 'internal' => 'id'],
|
'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>
|
* @var class-string<T>
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public const MODEL = VehicleType::class;
|
public const MODEL = BaseStringL11nType::class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Primary table.
|
* Primary table.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user