From 32d786db4cbc274ea8901b7082fbd2df26a4e41e Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 19 May 2023 02:37:35 +0000 Subject: [PATCH] test fixes + new test data --- Admin/Install/Media.install.json | 7 + Admin/Install/Navigation.install.json | 2 +- Admin/Install/attributes.json | 285 +++++ Admin/Install/db.json | 190 +++- Admin/Install/fueltype.json | 135 +++ Admin/Install/vehicletype.json | 135 +++ Admin/Installer.php | 306 ++++++ Admin/Updater.php | 7 + Controller/ApiController.php | 1153 ++++++++++++++++++++ Controller/BackendController.php | 47 + Models/Cost.php | 48 + Models/CostType.php | 48 + Models/FuelType.php | 121 ++ Models/FuelTypeL11nMapper.php | 69 ++ Models/FuelTypeMapper.php | 82 ++ Models/Inspection.php | 0 Models/InspectionMapper_.php | 0 Models/NullFuelType.php | 46 + Models/NullInspection.php | 0 Models/NullVehicle.php | 46 + Models/NullVehicleType.php | 46 + Models/Vehicle.php | 81 ++ Models/VehicleAttributeMapper.php | 86 ++ Models/VehicleAttributeTypeL11nMapper.php | 69 ++ Models/VehicleAttributeTypeMapper.php | 94 ++ Models/VehicleAttributeValueL11nMapper.php | 69 ++ Models/VehicleAttributeValueMapper.php | 89 ++ Models/VehicleMapper.php | 110 ++ Models/VehicleStatus.php | 36 + Models/VehicleType.php | 121 ++ Models/VehicleTypeL11nMapper.php | 69 ++ Models/VehicleTypeMapper.php | 82 ++ Theme/Backend/Lang/Navigation.en.lang.php | 5 +- Theme/Backend/Lang/en.lang.php | 114 +- Theme/Backend/vehicle-list.tpl.php | 42 +- Theme/Backend/vehicle-profile.tpl.php | 624 ++--------- 36 files changed, 3694 insertions(+), 770 deletions(-) create mode 100644 Admin/Install/attributes.json create mode 100644 Admin/Install/fueltype.json create mode 100644 Admin/Install/vehicletype.json create mode 100644 Models/Cost.php create mode 100644 Models/CostType.php create mode 100644 Models/FuelType.php create mode 100644 Models/FuelTypeL11nMapper.php create mode 100644 Models/FuelTypeMapper.php create mode 100644 Models/Inspection.php create mode 100644 Models/InspectionMapper_.php create mode 100644 Models/NullFuelType.php create mode 100644 Models/NullInspection.php create mode 100644 Models/NullVehicle.php create mode 100644 Models/NullVehicleType.php create mode 100644 Models/Vehicle.php create mode 100644 Models/VehicleAttributeMapper.php create mode 100644 Models/VehicleAttributeTypeL11nMapper.php create mode 100644 Models/VehicleAttributeTypeMapper.php create mode 100644 Models/VehicleAttributeValueL11nMapper.php create mode 100644 Models/VehicleAttributeValueMapper.php create mode 100644 Models/VehicleMapper.php create mode 100644 Models/VehicleStatus.php create mode 100644 Models/VehicleType.php create mode 100644 Models/VehicleTypeL11nMapper.php create mode 100644 Models/VehicleTypeMapper.php diff --git a/Admin/Install/Media.install.json b/Admin/Install/Media.install.json index 672b5b8..58397fa 100755 --- a/Admin/Install/Media.install.json +++ b/Admin/Install/Media.install.json @@ -5,5 +5,12 @@ "name": "FleetManagement", "virtualPath": "/Modules", "user": 1 + }, + { + "type": "collection", + "create_directory": true, + "name": "Vehicle", + "virtualPath": "/Modules/FleetManagement", + "user": 1 } ] \ No newline at end of file diff --git a/Admin/Install/Navigation.install.json b/Admin/Install/Navigation.install.json index 5842634..b41258b 100755 --- a/Admin/Install/Navigation.install.json +++ b/Admin/Install/Navigation.install.json @@ -19,7 +19,7 @@ "type": 2, "subtype": 1, "name": "Vehicles", - "uri": "{/base}/fleet/client/list", + "uri": "{/base}/fleet/vehicle/list", "target": "self", "icon": null, "order": 1, diff --git a/Admin/Install/attributes.json b/Admin/Install/attributes.json new file mode 100644 index 0000000..dec23c1 --- /dev/null +++ b/Admin/Install/attributes.json @@ -0,0 +1,285 @@ +[ + { + "name": "license_plate", + "l11n": { + "en": "License plate", + "de": "Kennzeichen" + }, + "value_type": 2, + "is_custom_allowed": true, + "validation_pattern": "", + "is_required": false, + "default_value": "", + "values": [] + }, + { + "name": "insurance_provider", + "l11n": { + "en": "Insurance provider", + "de": "Versicherung" + }, + "value_type": 2, + "is_custom_allowed": true, + "validation_pattern": "", + "is_required": false, + "default_value": "", + "values": [] + }, + { + "name": "insurance_number", + "l11n": { + "en": "Insurance number", + "de": "Versicherungsnummer" + }, + "value_type": 2, + "is_custom_allowed": true, + "validation_pattern": "", + "is_required": false, + "default_value": "", + "values": [] + }, + { + "name": "leasing_provider", + "l11n": { + "en": "Leasing provider", + "de": "Leasingsnummer" + }, + "value_type": 2, + "is_custom_allowed": true, + "validation_pattern": "", + "is_required": false, + "default_value": "", + "values": [] + }, + { + "name": "leasing_number", + "l11n": { + "en": "Leasing number", + "de": "Leasingsnummer" + }, + "value_type": 2, + "is_custom_allowed": true, + "validation_pattern": "", + "is_required": false, + "default_value": "", + "values": [] + }, + { + "name": "leasing_end", + "l11n": { + "en": "Leasing end", + "de": "Leasingende" + }, + "value_type": 4, + "is_custom_allowed": true, + "validation_pattern": "", + "is_required": false, + "default_value": "", + "values": [] + }, + { + "name": "leasing_milage", + "l11n": { + "en": "Leasing milage", + "de": "Laufleistung" + }, + "value_type": 1, + "is_custom_allowed": true, + "validation_pattern": "", + "is_required": false, + "default_value": "", + "values": [] + }, + { + "name": "insurance_milage", + "l11n": { + "en": "Insurance milage", + "de": "Versicherungslaufleistung" + }, + "value_type": 1, + "is_custom_allowed": true, + "validation_pattern": "", + "is_required": false, + "default_value": "", + "values": [] + }, + { + "name": "engine_size", + "l11n": { + "en": "Engine size", + "de": "Hubraum" + }, + "value_type": 2, + "is_custom_allowed": true, + "validation_pattern": "", + "is_required": false, + "default_value": "", + "values": [] + }, + { + "name": "vin", + "l11n": { + "en": "VIN", + "de": "Fahrgestellnummer" + }, + "value_type": 2, + "is_custom_allowed": true, + "validation_pattern": "", + "is_required": false, + "default_value": "", + "values": [] + }, + { + "name": "make", + "l11n": { + "en": "Make", + "de": "Marke" + }, + "value_type": 2, + "is_custom_allowed": true, + "validation_pattern": "", + "is_required": false, + "default_value": "", + "values": [] + }, + { + "name": "model", + "l11n": { + "en": "Model", + "de": "Modell" + }, + "value_type": 2, + "is_custom_allowed": true, + "validation_pattern": "", + "is_required": false, + "default_value": "", + "values": [] + }, + { + "name": "color", + "l11n": { + "en": "Color", + "de": "Farbe" + }, + "value_type": 2, + "is_custom_allowed": true, + "validation_pattern": "", + "is_required": false, + "default_value": "", + "values": [] + }, + { + "name": "build", + "l11n": { + "en": "Build year", + "de": "Baujahr" + }, + "value_type": 4, + "is_custom_allowed": true, + "validation_pattern": "", + "is_required": false, + "default_value": "", + "values": [] + }, + { + "name": "ownership_start", + "l11n": { + "en": "Ownership start", + "de": "Besitzbeginn" + }, + "value_type": 4, + "is_custom_allowed": true, + "validation_pattern": "", + "is_required": false, + "default_value": "", + "values": [] + }, + { + "name": "ownership_end", + "l11n": { + "en": "Ownership end", + "de": "Besitzende" + }, + "value_type": 4, + "is_custom_allowed": true, + "validation_pattern": "", + "is_required": false, + "default_value": "", + "values": [] + }, + { + "name": "fuel_type", + "l11n": { + "en": "Fuel type", + "de": "Kraftstoffart" + }, + "value_type": 1, + "is_custom_allowed": false, + "validation_pattern": "", + "is_required": true, + "default_value": "", + "values": [ + { + "value": 1, + "l11n": { + "en": "None", + "de": "Kein" + } + }, + { + "value": 2, + "l11n": { + "en": "Gas", + "de": "Benzin" + } + }, + { + "value": 3, + "l11n": { + "en": "Diesel", + "de": "Diesel" + } + }, + { + "value": 4, + "l11n": { + "en": "Electric", + "de": "Elektro" + } + }, + { + "value": 5, + "l11n": { + "en": "Hydrogen", + "de": "Wasserstoff" + } + } + ] + }, + { + "name": "purchase_price", + "l11n": { + "en": "Purchase price", + "de": "Kaufpreis" + }, + "value_type": 1, + "is_custom_allowed": true, + "validation_pattern": "", + "is_required": false, + "default_value": "", + "values": [] + }, + { + "name": "leasing_residual_value", + "l11n": { + "en": "Leasing residual value", + "de": "Leasing Restwert" + }, + "value_type": 1, + "is_custom_allowed": true, + "validation_pattern": "", + "is_required": false, + "default_value": "", + "values": [] + } +] \ No newline at end of file diff --git a/Admin/Install/db.json b/Admin/Install/db.json index 651ca07..ddda20c 100755 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -1,4 +1,100 @@ { + "fleetmgmt_fuel_type": { + "name": "fleetmgmt_fuel_type", + "fields": { + "fleetmgmt_fuel_type_id": { + "name": "fleetmgmt_fuel_type_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "fleetmgmt_fuel_type_name": { + "name": "fleetmgmt_fuel_type_name", + "type": "VARCHAR(255)", + "null": false + } + } + }, + "fleetmgmt_fuel_type_l11n": { + "name": "fleetmgmt_fuel_type_l11n", + "fields": { + "fleetmgmt_fuel_type_l11n_id": { + "name": "fleetmgmt_fuel_type_l11n_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "fleetmgmt_fuel_type_l11n_title": { + "name": "fleetmgmt_fuel_type_l11n_title", + "type": "VARCHAR(255)", + "null": false + }, + "fleetmgmt_fuel_type_l11n_type": { + "name": "fleetmgmt_fuel_type_l11n_type", + "type": "INT(11)", + "null": false, + "foreignTable": "fleetmgmt_fuel_type", + "foreignKey": "fleetmgmt_fuel_type_id" + }, + "fleetmgmt_fuel_type_l11n_lang": { + "name": "fleetmgmt_fuel_type_l11n_lang", + "type": "VARCHAR(2)", + "null": false, + "foreignTable": "language", + "foreignKey": "language_639_1" + } + } + }, + "fleetmgmt_vehicle_type": { + "name": "fleetmgmt_vehicle_type", + "fields": { + "fleetmgmt_vehicle_type_id": { + "name": "fleetmgmt_vehicle_type_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "fleetmgmt_vehicle_type_name": { + "name": "fleetmgmt_vehicle_type_name", + "type": "VARCHAR(255)", + "null": false + } + } + }, + "fleetmgmt_vehicle_type_l11n": { + "name": "fleetmgmt_vehicle_type_l11n", + "fields": { + "fleetmgmt_vehicle_type_l11n_id": { + "name": "fleetmgmt_vehicle_type_l11n_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "fleetmgmt_vehicle_type_l11n_title": { + "name": "fleetmgmt_vehicle_type_l11n_title", + "type": "VARCHAR(255)", + "null": false + }, + "fleetmgmt_vehicle_type_l11n_type": { + "name": "fleetmgmt_vehicle_type_l11n_type", + "type": "INT(11)", + "null": false, + "foreignTable": "fleetmgmt_vehicle_type", + "foreignKey": "fleetmgmt_vehicle_type_id" + }, + "fleetmgmt_vehicle_type_l11n_lang": { + "name": "fleetmgmt_vehicle_type_l11n_lang", + "type": "VARCHAR(2)", + "null": false, + "foreignTable": "language", + "foreignKey": "language_639_1" + } + } + }, "fleetmgmt_vehicle": { "name": "fleetmgmt_vehicle", "fields": { @@ -9,6 +105,11 @@ "primary": true, "autoincrement": true }, + "fleetmgmt_vehicle_name": { + "name": "fleetmgmt_vehicle_name", + "type": "VARCHAR(255)", + "null": false + }, "fleetmgmt_vehicle_status": { "name": "fleetmgmt_vehicle_status", "type": "TINYINT", @@ -16,8 +117,15 @@ }, "fleetmgmt_vehicle_type": { "name": "fleetmgmt_vehicle_type", - "type": "TINYINT", - "null": false + "type": "INT", + "foreignTable": "fleetmgmt_vehicle_type", + "foreignKey": "fleetmgmt_vehicle_type_id" + }, + "fleetmgmt_vehicle_fuel": { + "name": "fleetmgmt_vehicle_fuel", + "type": "INT", + "foreignTable": "fleetmgmt_fuel_type", + "foreignKey": "fleetmgmt_fuel_type_id" }, "fleetmgmt_vehicle_info": { "name": "fleetmgmt_vehicle_info", @@ -32,7 +140,8 @@ "fleetmgmt_vehicle_responsible": { "name": "fleetmgmt_vehicle_responsible", "type": "INT", - "null": false, + "null": true, + "default": true, "foreignTable": "account", "foreignKey": "account_id" }, @@ -46,41 +155,6 @@ } } }, - "fleetmgmt_vehicle_responsible": { - "name": "fleetmgmt_vehicle_responsible", - "fields": { - "fleetmgmt_vehicle_responsible_id": { - "name": "fleetmgmt_vehicle_responsible_id", - "type": "INT", - "null": false, - "primary": true, - "autoincrement": true - }, - "fleetmgmt_vehicle_responsible_description": { - "name": "fleetmgmt_vehicle_responsible_description", - "type": "TEXT", - "null": false - }, - "fleetmgmt_vehicle_responsible_account": { - "name": "fleetmgmt_vehicle_responsible_account", - "type": "INT", - "null": false, - "foreignTable": "account", - "foreignKey": "account_id" - }, - "fleetmgmt_vehicle_responsible_start": { - "name": "fleetmgmt_vehicle_responsible_start", - "type": "DATETIME", - "null": false - }, - "fleetmgmt_vehicle_responsible_end": { - "name": "fleetmgmt_vehicle_responsible_end", - "type": "DATETIME", - "null": true, - "default": null - } - } - }, "fleetmgmt_vehicle_usage": { "name": "fleetmgmt_vehicle_usage", "fields": { @@ -326,8 +400,8 @@ "primary": true, "autoincrement": true }, - "fleetmgmt_vehicle_attr_vehicle": { - "name": "fleetmgmt_vehicle_attr_vehicle", + "fleetmgmt_vehicle_attr_item": { + "name": "fleetmgmt_vehicle_attr_item", "type": "INT(11)", "null": false, "foreignTable": "fleetmgmt_vehicle", @@ -360,19 +434,19 @@ "primary": true, "autoincrement": true }, - "fleetmgmt_vehicle_media_dst": { - "name": "fleetmgmt_vehicle_media_dst", - "type": "INT", - "null": false, - "foreignTable": "media", - "foreignKey": "media_id" - }, - "fleetmgmt_vehicle_media_src": { - "name": "fleetmgmt_vehicle_media_src", + "fleetmgmt_vehicle_media_vehicle": { + "name": "fleetmgmt_vehicle_media_vehicle", "type": "INT", "null": false, "foreignTable": "fleetmgmt_vehicle", "foreignKey": "fleetmgmt_vehicle_id" + }, + "fleetmgmt_vehicle_media_media": { + "name": "fleetmgmt_vehicle_media_media", + "type": "INT", + "null": false, + "foreignTable": "media", + "foreignKey": "media_id" } } }, @@ -386,19 +460,19 @@ "primary": true, "autoincrement": true }, - "fleetmgmt_vehicle_note_dst": { - "name": "fleetmgmt_vehicle_note_dst", - "type": "INT", - "null": false, - "foreignTable": "editor_doc", - "foreignKey": "editor_doc_id" - }, - "fleetmgmt_vehicle_note_src": { - "name": "fleetmgmt_vehicle_note_src", + "fleetmgmt_vehicle_note_item": { + "name": "fleetmgmt_vehicle_note_item", "type": "INT", "null": false, "foreignTable": "fleetmgmt_vehicle", "foreignKey": "fleetmgmt_vehicle_id" + }, + "fleetmgmt_vehicle_note_doc": { + "name": "fleetmgmt_vehicle_note_doc", + "type": "INT", + "null": false, + "foreignTable": "editor_doc", + "foreignKey": "editor_doc_id" } } } diff --git a/Admin/Install/fueltype.json b/Admin/Install/fueltype.json new file mode 100644 index 0000000..76747be --- /dev/null +++ b/Admin/Install/fueltype.json @@ -0,0 +1,135 @@ +[ + { + "name": "gasoline", + "l11n": { + "en": "Gasoline", + "de": "Benzin" + } + }, + { + "name": "diesel", + "l11n": { + "en": "Diesel", + "de": "Diesel" + } + }, + { + "name": "electirc", + "l11n": { + "en": "Electric", + "de": "Elektrisch" + } + }, + { + "name": "hydrogen", + "l11n": { + "en": "Hydrogen", + "de": "Wasserstoff" + } + }, + { + "name": "ethanol", + "l11n": { + "en": "Ethanol", + "de": "Ethanol" + } + }, + { + "name": "kerosene", + "l11n": { + "en": "Kerosene", + "de": "Kerosin" + } + }, + { + "name": "lpg", + "l11n": { + "en": "LPG", + "de": "Autogas" + } + }, + { + "name": "methanol", + "l11n": { + "en": "Methanol", + "de": "Methanol" + } + }, + { + "name": "methane", + "l11n": { + "en": "Methane", + "de": "Methan" + } + }, + { + "name": "nitromethane", + "l11n": { + "en": "Nitromethane", + "de": "Nitromethan" + } + }, + { + "name": "coal", + "l11n": { + "en": "Coal", + "de": "Kohle" + } + }, + { + "name": "wood", + "l11n": { + "en": "Wood", + "de": "Holz" + } + }, + { + "name": "petroleum", + "l11n": { + "en": "Petroleum", + "de": "Petroleum" + } + }, + { + "name": "coaltar", + "l11n": { + "en": "Coaltar", + "de": "Steinkohlenteer" + } + }, + { + "name": "coke", + "l11n": { + "en": "Coke", + "de": "Koks" + } + }, + { + "name": "charcoale", + "l11n": { + "en": "Charcoale", + "de": "Holzkohle" + } + }, + { + "name": "naturalgas", + "l11n": { + "en": "Naturalgas", + "de": "Erdgas" + } + }, + { + "name": "biogas", + "l11n": { + "en": "Biogas", + "de": "Biogas" + } + }, + { + "name": "biodiesel", + "l11n": { + "en": "Biodiesel", + "de": "Biodiesel" + } + } +] \ No newline at end of file diff --git a/Admin/Install/vehicletype.json b/Admin/Install/vehicletype.json new file mode 100644 index 0000000..f5485e0 --- /dev/null +++ b/Admin/Install/vehicletype.json @@ -0,0 +1,135 @@ +[ + { + "name": "car", + "l11n": { + "en": "Car", + "de": "Auto" + } + }, + { + "name": "truck", + "l11n": { + "en": "Truck", + "de": "LKW" + } + }, + { + "name": "motorcycle", + "l11n": { + "en": "Motorcycle", + "de": "Motorrad" + } + }, + { + "name": "bicycle", + "l11n": { + "en": "Bicycle", + "de": "Fahrrad" + } + }, + { + "name": "bus", + "l11n": { + "en": "Bus", + "de": "Bus" + } + }, + { + "name": "boat", + "l11n": { + "en": "Boat", + "de": "Boot" + } + }, + { + "name": "airplane", + "l11n": { + "en": "Airplane", + "de": "Flugzeug" + } + }, + { + "name": "helicopter", + "l11n": { + "en": "Helicopter", + "de": "Hubschrauber" + } + }, + { + "name": "train", + "l11n": { + "en": "Train", + "de": "Zug" + } + }, + { + "name": "scooter", + "l11n": { + "en": "Scooter", + "de": "Roller" + } + }, + { + "name": "moped", + "l11n": { + "en": "Moped", + "de": "Moped" + } + }, + { + "name": "RV", + "l11n": { + "en": "Recreational Vehicle", + "de": "Wohnmobil" + } + }, + { + "name": "tractor", + "l11n": { + "en": "Tractor", + "de": "Traktor" + } + }, + { + "name": "forklift", + "l11n": { + "en": "Forklift", + "de": "Gabelstapler" + } + }, + { + "name": "skateboard", + "l11n": { + "en": "Skateboard", + "de": "Skateboard" + } + }, + { + "name": "snowmobile", + "l11n": { + "en": "Snowmobile", + "de": "Schneemobil" + } + }, + { + "name": "jet_ski", + "l11n": { + "en": "Jet Ski", + "de": "Jet Ski" + } + }, + { + "name": "quad_bike", + "l11n": { + "en": "Quad Bike", + "de": "Quad Bike" + } + }, + { + "name": "golf_cart", + "l11n": { + "en": "Golf Cart", + "de": "Golf Cart" + } + } +] diff --git a/Admin/Installer.php b/Admin/Installer.php index b539310..7529423 100755 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -14,7 +14,13 @@ declare(strict_types=1); namespace Modules\FleetManagement\Admin; +use phpOMS\Application\ApplicationAbstract; +use phpOMS\Config\SettingsInterface; +use phpOMS\Message\Http\HttpRequest; +use phpOMS\Message\Http\HttpResponse; use phpOMS\Module\InstallerAbstract; +use phpOMS\Module\ModuleInfo; +use phpOMS\Uri\HttpUri; /** * Installer class. @@ -33,4 +39,304 @@ final class Installer extends InstallerAbstract * @since 1.0.0 */ public const PATH = __DIR__; + + /** + * {@inheritdoc} + */ + public static function install(ApplicationAbstract $app, ModuleInfo $info, SettingsInterface $cfgHandler) : void + { + parent::install($app, $info, $cfgHandler); + + /* Attributes */ + $fileContent = \file_get_contents(__DIR__ . '/Install/attributes.json'); + if ($fileContent === false) { + return; + } + + /** @var array $attributes */ + $attributes = \json_decode($fileContent, true); + $attrTypes = self::createAttributeTypes($app, $attributes); + $attrValues = self::createAttributeValues($app, $attrTypes, $attributes); + + /* Fuel types */ + $fileContent = \file_get_contents(__DIR__ . '/Install/fueltype.json'); + if ($fileContent === false) { + return; + } + + /** @var array $types */ + $types = \json_decode($fileContent, true); + $fuelTypes = self::createFuelTypes($app, $types); + + /* Fuel types */ + $fileContent = \file_get_contents(__DIR__ . '/Install/vehicletype.json'); + if ($fileContent === false) { + return; + } + + /** @var array $types */ + $types = \json_decode($fileContent, true); + $vehicleTypes = self::createVehicleTypes($app, $types); + } + + /** + * Install fuel type + * + * @param ApplicationAbstract $app Application + * @param array, is_required?:bool, is_custom_allowed?:bool, validation_pattern?:string, value_type?:string, values?:array}> $attributes Attribute definition + * + * @return array + * + * @since 1.0.0 + */ + private static function createFuelTypes(ApplicationAbstract $app, array $types) : array + { + /** @var array $fuelTypes */ + $fuelTypes = []; + + /** @var \Modules\FleetManagement\Controller\ApiController $module */ + $module = $app->moduleManager->getModuleInstance('FleetManagement'); + + /** @var array $type */ + foreach ($types as $type) { + $response = new HttpResponse(); + $request = new HttpRequest(new HttpUri('')); + + $request->header->account = 1; + $request->setData('name', $type['name'] ?? ''); + $request->setData('title', \reset($type['l11n'])); + $request->setData('language', \array_keys($type['l11n'])[0] ?? 'en'); + + $module->apiFuelTypeCreate($request, $response); + + $responseData = $response->get(''); + if (!\is_array($responseData)) { + continue; + } + + $fuelTypes[$type['name']] = !\is_array($responseData['response']) + ? $responseData['response']->toArray() + : $responseData['response']; + + $isFirst = true; + foreach ($type['l11n'] as $language => $l11n) { + if ($isFirst) { + $isFirst = false; + continue; + } + + $response = new HttpResponse(); + $request = new HttpRequest(new HttpUri('')); + + $request->header->account = 1; + $request->setData('title', $l11n); + $request->setData('language', $language); + $request->setData('type', $fuelTypes[$type['name']]['id']); + + $module->apiFuelTypeL11nCreate($request, $response); + } + } + + return $fuelTypes; + } + + /** + * Install fuel type + * + * @param ApplicationAbstract $app Application + * @param array, is_required?:bool, is_custom_allowed?:bool, validation_pattern?:string, value_type?:string, values?:array}> $attributes Attribute definition + * + * @return array + * + * @since 1.0.0 + */ + private static function createVehicleTypes(ApplicationAbstract $app, array $types) : array + { + /** @var array $fuelTypes */ + $vehicleTypes = []; + + /** @var \Modules\FleetManagement\Controller\ApiController $module */ + $module = $app->moduleManager->getModuleInstance('FleetManagement'); + + /** @var array $type */ + foreach ($types as $type) { + $response = new HttpResponse(); + $request = new HttpRequest(new HttpUri('')); + + $request->header->account = 1; + $request->setData('name', $type['name'] ?? ''); + $request->setData('title', \reset($type['l11n'])); + $request->setData('language', \array_keys($type['l11n'])[0] ?? 'en'); + + $module->apiVehicleTypeCreate($request, $response); + + $responseData = $response->get(''); + if (!\is_array($responseData)) { + continue; + } + + $vehicleTypes[$type['name']] = !\is_array($responseData['response']) + ? $responseData['response']->toArray() + : $responseData['response']; + + $isFirst = true; + foreach ($type['l11n'] as $language => $l11n) { + if ($isFirst) { + $isFirst = false; + continue; + } + + $response = new HttpResponse(); + $request = new HttpRequest(new HttpUri('')); + + $request->header->account = 1; + $request->setData('title', $l11n); + $request->setData('language', $language); + $request->setData('type', $vehicleTypes[$type['name']]['id']); + + $module->apiVehicleTypeL11nCreate($request, $response); + } + } + + return $vehicleTypes; + } + + /** + * Install default attribute types + * + * @param ApplicationAbstract $app Application + * @param array, is_required?:bool, is_custom_allowed?:bool, validation_pattern?:string, value_type?:string, values?:array}> $attributes Attribute definition + * + * @return array + * + * @since 1.0.0 + */ + private static function createAttributeTypes(ApplicationAbstract $app, array $attributes) : array + { + /** @var array $itemAttrType */ + $itemAttrType = []; + + /** @var \Modules\FleetManagement\Controller\ApiController $module */ + $module = $app->moduleManager->getModuleInstance('FleetManagement'); + + /** @var array $attribute */ + foreach ($attributes as $attribute) { + $response = new HttpResponse(); + $request = new HttpRequest(new HttpUri('')); + + $request->header->account = 1; + $request->setData('name', $attribute['name'] ?? ''); + $request->setData('title', \reset($attribute['l11n'])); + $request->setData('language', \array_keys($attribute['l11n'])[0] ?? 'en'); + $request->setData('is_required', $attribute['is_required'] ?? false); + $request->setData('custom', $attribute['is_custom_allowed'] ?? false); + $request->setData('validation_pattern', $attribute['validation_pattern'] ?? ''); + $request->setData('datatype', (int) $attribute['value_type']); + + $module->apiVehicleAttributeTypeCreate($request, $response); + + $responseData = $response->get(''); + if (!\is_array($responseData)) { + continue; + } + + $itemAttrType[$attribute['name']] = !\is_array($responseData['response']) + ? $responseData['response']->toArray() + : $responseData['response']; + + $isFirst = true; + foreach ($attribute['l11n'] as $language => $l11n) { + if ($isFirst) { + $isFirst = false; + continue; + } + + $response = new HttpResponse(); + $request = new HttpRequest(new HttpUri('')); + + $request->header->account = 1; + $request->setData('title', $l11n); + $request->setData('language', $language); + $request->setData('type', $itemAttrType[$attribute['name']]['id']); + + $module->apiVehicleAttributeTypeL11nCreate($request, $response); + } + } + + return $itemAttrType; + } + + /** + * Create default attribute values for types + * + * @param ApplicationAbstract $app Application + * @param array $itemAttrType Attribute types + * @param array, is_required?:bool, is_custom_allowed?:bool, validation_pattern?:string, value_type?:string, values?:array}> $attributes Attribute definition + * + * @return array + * + * @since 1.0.0 + */ + private static function createAttributeValues(ApplicationAbstract $app, array $itemAttrType, array $attributes) : array + { + /** @var array $itemAttrValue */ + $itemAttrValue = []; + + /** @var \Modules\FleetManagement\Controller\ApiController $module */ + $module = $app->moduleManager->getModuleInstance('FleetManagement'); + + foreach ($attributes as $attribute) { + $itemAttrValue[$attribute['name']] = []; + + /** @var array $value */ + foreach ($attribute['values'] as $value) { + $response = new HttpResponse(); + $request = new HttpRequest(new HttpUri('')); + + $request->header->account = 1; + $request->setData('value', $value['value'] ?? ''); + $request->setData('unit', $value['unit'] ?? ''); + $request->setData('default', true); // always true since all defined values are possible default values + $request->setData('type', $itemAttrType[$attribute['name']]['id']); + + if (isset($value['l11n']) && !empty($value['l11n'])) { + $request->setData('title', \reset($value['l11n'])); + $request->setData('language', \array_keys($value['l11n'])[0] ?? 'en'); + } + + $module->apiVehicleAttributeValueCreate($request, $response); + + $responseData = $response->get(''); + if (!\is_array($responseData)) { + continue; + } + + $attrValue = !\is_array($responseData['response']) + ? $responseData['response']->toArray() + : $responseData['response']; + + $itemAttrValue[$attribute['name']][] = $attrValue; + + $isFirst = true; + foreach (($value['l11n'] ?? []) as $language => $l11n) { + if ($isFirst) { + $isFirst = false; + continue; + } + + $response = new HttpResponse(); + $request = new HttpRequest(new HttpUri('')); + + $request->header->account = 1; + $request->setData('title', $l11n); + $request->setData('language', $language); + $request->setData('value', $attrValue['id']); + + $module->apiVehicleAttributeValueL11nCreate($request, $response); + } + } + } + + return $itemAttrValue; + } } diff --git a/Admin/Updater.php b/Admin/Updater.php index e1f5929..5d0debb 100755 --- a/Admin/Updater.php +++ b/Admin/Updater.php @@ -26,4 +26,11 @@ use phpOMS\Module\UpdaterAbstract; */ final class Updater extends UpdaterAbstract { + /** + * Path of the file + * + * @var string + * @since 1.0.0 + */ + public const PATH = __DIR__; } diff --git a/Controller/ApiController.php b/Controller/ApiController.php index a4c5c35..9cebf70 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -14,6 +14,41 @@ declare(strict_types=1); namespace Modules\FleetManagement\Controller; +use Modules\Admin\Models\NullAccount; +use Modules\Attribute\Models\Attribute; +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\Vehicle; +use Modules\FleetManagement\Models\VehicleAttributeMapper; +use Modules\FleetManagement\Models\VehicleAttributeTypeL11nMapper; +use Modules\FleetManagement\Models\VehicleAttributeTypeMapper; +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 Modules\FleetManagement\Models\VehicleTypeL11nMapper; +use Modules\FleetManagement\Models\VehicleTypeMapper; +use Modules\Media\Models\CollectionMapper; +use Modules\Media\Models\MediaMapper; +use Modules\Media\Models\NullMedia; +use Modules\Media\Models\PathSettings; +use Modules\Media\Models\Reference; +use phpOMS\Localization\BaseStringL11n; +use phpOMS\Localization\ISO639x1Enum; +use phpOMS\Message\Http\RequestStatusCode; +use phpOMS\Message\NotificationLevel; +use phpOMS\Message\RequestAbstract; +use phpOMS\Message\ResponseAbstract; +use phpOMS\Model\Message\FormValidation; + /** * FleetManagement class. * @@ -24,5 +59,1123 @@ namespace Modules\FleetManagement\Controller; */ final class ApiController extends Controller { + /** + * 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 apiVehicleTypeCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void + { + if (!empty($val = $this->validateVehicleTypeCreate($request))) { + $response->set($request->uri->__toString(), new FormValidation($val)); + $response->header->status = RequestStatusCode::R_400; + return; + } + + /** @var VehicleType $vehicle */ + $vehicle = $this->createVehicleTypeFromRequest($request); + $this->createModel($request->header->account, $vehicle, VehicleTypeMapper::class, 'vehicle_type', $request->getOrigin()); + + $this->fillJsonResponse( + $request, + $response, + NotificationLevel::OK, + '', + $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'SucessfulCreate'), + $vehicle + ); + } + + /** + * Method to create vehicle from request. + * + * @param RequestAbstract $request Request + * + * @return VehicleType Returns the created vehicle from the request + * + * @since 1.0.0 + */ + public function createVehicleTypeFromRequest(RequestAbstract $request) : VehicleType + { + $type = new VehicleType(); + $type->name = $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 Returns the validation array of the request + * + * @since 1.0.0 + */ + private function validateVehicleTypeCreate(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 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->header->status = RequestStatusCode::R_400; + + return; + } + + $typeL11n = $this->createVehicleTypeL11nFromRequest($request); + $this->createModel($request->header->account, $typeL11n, VehicleTypeL11nMapper::class, 'vehicle_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 createVehicleTypeL11nFromRequest(RequestAbstract $request) : BaseStringL11n + { + $typeL11n = new BaseStringL11n(); + $typeL11n->ref = $request->getDataInt('type') ?? 0; + $typeL11n->setLanguage( + $request->getDataString('language') ?? $request->getLanguage() + ); + $typeL11n->content = $request->getDataString('title') ?? ''; + + return $typeL11n; + } + + /** + * Validate vehicle attribute l11n create request + * + * @param RequestAbstract $request Request + * + * @return array + * + * @since 1.0.0 + */ + private function validateVehicleTypeL11nCreate(RequestAbstract $request) : array + { + $val = []; + if (($val['title'] = !$request->hasData('title')) + || ($val['type'] = !$request->hasData('type')) + ) { + return $val; + } + + 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 apiFuelTypeCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void + { + if (!empty($val = $this->validateFuelTypeCreate($request))) { + $response->set($request->uri->__toString(), new FormValidation($val)); + $response->header->status = RequestStatusCode::R_400; + + return; + } + + /** @var FuelType $vehicle */ + $vehicle = $this->createFuelTypeFromRequest($request); + $this->createModel($request->header->account, $vehicle, FuelTypeMapper::class, 'fuel_type', $request->getOrigin()); + + $this->fillJsonResponse( + $request, + $response, + NotificationLevel::OK, + '', + $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'SucessfulCreate'), + $vehicle + ); + } + + /** + * Method to create vehicle from request. + * + * @param RequestAbstract $request Request + * + * @return FuelType Returns the created vehicle from the request + * + * @since 1.0.0 + */ + public function createFuelTypeFromRequest(RequestAbstract $request) : FuelType + { + $type = new FuelType(); + $type->name = $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 Returns the validation array of the request + * + * @since 1.0.0 + */ + private function validateFuelTypeCreate(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 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->header->status = RequestStatusCode::R_400; + + return; + } + + $typeL11n = $this->createFuelTypeL11nFromRequest($request); + $this->createModel($request->header->account, $typeL11n, FuelTypeL11nMapper::class, 'fuel_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 createFuelTypeL11nFromRequest(RequestAbstract $request) : BaseStringL11n + { + $typeL11n = new BaseStringL11n(); + $typeL11n->ref = $request->getDataInt('type') ?? 0; + $typeL11n->setLanguage( + $request->getDataString('language') ?? $request->getLanguage() + ); + $typeL11n->content = $request->getDataString('title') ?? ''; + + return $typeL11n; + } + + /** + * Validate vehicle attribute l11n create request + * + * @param RequestAbstract $request Request + * + * @return array + * + * @since 1.0.0 + */ + private function validateFuelTypeL11nCreate(RequestAbstract $request) : array + { + $val = []; + if (($val['title'] = !$request->hasData('title')) + || ($val['type'] = !$request->hasData('type')) + ) { + return $val; + } + + 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 apiVehicleCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void + { + if (!empty($val = $this->validateVehicleCreate($request))) { + $response->set($request->uri->__toString(), new FormValidation($val)); + $response->header->status = RequestStatusCode::R_400; + + return; + } + + /** @var Vehicle $vehicle */ + $vehicle = $this->createVehicleFromRequest($request); + $this->createModel($request->header->account, $vehicle, VehicleMapper::class, 'vehicle', $request->getOrigin()); + + if (!empty($request->getFiles()) + || !empty($request->getDataJson('media')) + ) { + $this->createVehicleMedia($vehicle, $request); + } + + $this->fillJsonResponse( + $request, + $response, + NotificationLevel::OK, + '', + $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'SucessfulCreate'), + $vehicle + ); + } + + /** + * Method to create vehicle from request. + * + * @param RequestAbstract $request Request + * + * @return Vehicle Returns the created vehicle from the request + * + * @since 1.0.0 + */ + public function createVehicleFromRequest(RequestAbstract $request) : Vehicle + { + $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->status = (int) ($request->getDataInt('status') ?? VehicleStatus::INACTIVE); + $vehicle->unit = $request->getDataInt('unit') ?? $this->app->unitId; + + return $vehicle; + } + + /** + * Create media files for vehicle + * + * @param Vehicle $vehicle Vehicle + * @param RequestAbstract $request Request incl. media do upload + * + * @return void + * + * @since 1.0.0 + */ + private function createVehicleMedia(Vehicle $vehicle, RequestAbstract $request) : void + { + $path = $this->createVehicleDir($vehicle); + + if (!empty($uploadedFiles = $request->getFiles())) { + $uploaded = $this->app->moduleManager->get('Media')->uploadFiles( + names: [], + fileNames: [], + files: $uploadedFiles, + account: $request->header->account, + basePath: __DIR__ . '/../../../Modules/Media/Files' . $path, + virtualPath: $path, + pathSettings: PathSettings::FILE_PATH + ); + + $collection = null; + foreach ($uploaded as $media) { + $this->createModelRelation( + $request->header->account, + $vehicle->id, + $media->id, + VehicleMapper::class, + 'media', + '', + $request->getOrigin() + ); + + if ($collection === null) { + /** @var \Modules\Media\Models\Media $media */ + $collection = MediaMapper::getParentCollection($path)->limit(1)->execute(); + + if ($collection->id === 0) { + $collection = $this->app->moduleManager->get('Media')->createRecursiveMediaCollection( + $path, + $request->header->account, + __DIR__ . '/../../../Modules/Media/Files' . $path + ); + } + } + + $this->createModelRelation( + $request->header->account, + $collection->id, + $media->id, + CollectionMapper::class, + 'sources', + '', + $request->getOrigin() + ); + } + } + + if (!empty($mediaFiles = $request->getDataJson('media'))) { + $collection = null; + + foreach ($mediaFiles as $file) { + /** @var \Modules\Media\Models\Media $media */ + $media = MediaMapper::get()->where('id', (int) $file)->limit(1)->execute(); + + $this->createModelRelation( + $request->header->account, + $vehicle->id, + $media->id, + VehicleMapper::class, + 'media', + '', + $request->getOrigin() + ); + + $ref = new Reference(); + $ref->name = $media->name; + $ref->source = new NullMedia($media->id); + $ref->createdBy = new NullAccount($request->header->account); + $ref->setVirtualPath($path); + + $this->createModel($request->header->account, $ref, ReferenceMapper::class, 'media_reference', $request->getOrigin()); + + if ($collection === null) { + /** @var \Modules\Media\Models\Media $media */ + $collection = MediaMapper::getParentCollection($path)->limit(1)->execute(); + + if ($collection->id === 0) { + $collection = $this->app->moduleManager->get('Media')->createRecursiveMediaCollection( + $path, + $request->header->account, + __DIR__ . '/../../../Modules/Media/Files' . $path + ); + } + } + + $this->createModelRelation( + $request->header->account, + $collection->id, + $ref->id, + CollectionMapper::class, + 'sources', + '', + $request->getOrigin() + ); + } + } + } + + /** + * Validate vehicle create request + * + * @param RequestAbstract $request Request + * + * @return array Returns the validation array of the request + * + * @since 1.0.0 + */ + private function validateVehicleCreate(RequestAbstract $request) : array + { + $val = []; + if (($val['name'] = !$request->hasData('name'))) { + return $val; + } + + return []; + } + + /** + * Api method to create vehicle attribute + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return void + * + * @api + * + * @since 1.0.0 + */ + 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->header->status = RequestStatusCode::R_400; + + return; + } + + $attribute = $this->createVehicleAttributeFromRequest($request); + $this->createModel($request->header->account, $attribute, VehicleAttributeMapper::class, 'attribute', $request->getOrigin()); + + $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Attribute', 'Attribute successfully created', $attribute); + } + + /** + * Method to create vehicle attribute from request. + * + * @param RequestAbstract $request Request + * + * @return Attribute + * + * @since 1.0.0 + */ + private function createVehicleAttributeFromRequest(RequestAbstract $request) : Attribute + { + $attribute = new Attribute(); + $attribute->ref = (int) $request->getData('vehicle'); + $attribute->type = new NullAttributeType((int) $request->getData('type')); + + if ($request->hasData('value')) { + $attribute->value = new NullAttributeValue((int) $request->getData('value')); + } else { + $newRequest = clone $request; + $newRequest->setData('value', $request->getData('custom'), true); + + $value = $this->createAttributeValueFromRequest($newRequest); + + $attribute->value = $value; + } + + return $attribute; + } + + /** + * Validate vehicle attribute create request + * + * @param RequestAbstract $request Request + * + * @return array + * + * @since 1.0.0 + */ + private function validateVehicleAttributeCreate(RequestAbstract $request) : array + { + $val = []; + if (($val['type'] = !$request->hasData('type')) + || ($val['value'] = (!$request->hasData('value') && !$request->hasData('custom'))) + || ($val['vehicle'] = !$request->hasData('vehicle')) + ) { + return $val; + } + + return []; + } + + /** + * Api method to create vehicle attribute + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return void + * + * @api + * + * @since 1.0.0 + */ + 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->header->status = RequestStatusCode::R_400; + + return; + } + + $old = VehicleAttributeMapper::get() + ->with('type') + ->with('type/defaults') + ->with('value') + ->where('id', (int) $request->getData('id')) + ->execute(); + + $new = $this->updateVehicleAttributeFromRequest($request, $old->deepClone()); + $this->updateModel($request->header->account, $old, $new, VehicleAttributeMapper::class, 'attribute', $request->getOrigin()); + + if ($new->value->getValue() !== $old->value->getValue()) { + $this->updateModel($request->header->account, $old->value, $new->value, VehicleAttributeValueMapper::class, 'attribute_value', $request->getOrigin()); + } + + $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Attribute', 'Attribute successfully updated', $new); + } + + /** + * Method to create vehicle attribute from request. + * + * @param RequestAbstract $request Request + * + * @return Attribute + * + * @since 1.0.0 + */ + private function updateVehicleAttributeFromRequest(RequestAbstract $request, Attribute $attribute) : Attribute + { + if ($attribute->type->custom) { + if ($request->hasData('value')) { + // @question: we are overwriting the old value, could there be a use case where we want to create a new value and keep the old one? + $attribute->value->setValue($request->getData('value'), $attribute->type->datatype); + } + } else { + if ($request->hasData('value')) { + // @todo: fix by only accepting the value id to be used + // this is a workaround for now because the front end doesn't allow to dynamically show default values. + $value = $attribute->type->getDefaultByValue($request->getData('value')); + + if ($value->id !== 0) { + $attribute->value = $attribute->type->getDefaultByValue($request->getData('value')); + } + } + } + + return $attribute; + } + + /** + * Validate vehicle attribute create request + * + * @param RequestAbstract $request Request + * + * @return array + * + * @since 1.0.0 + */ + private function validateVehicleAttributeUpdate(RequestAbstract $request) : array + { + $val = []; + if (($val['id'] = !$request->hasData('id')) + ) { + 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 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->header->status = RequestStatusCode::R_400; + + return; + } + + $attrL11n = $this->createVehicleAttributeTypeL11nFromRequest($request); + $this->createModel($request->header->account, $attrL11n, VehicleAttributeTypeL11nMapper::class, 'attr_type_l11n', $request->getOrigin()); + $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Localization', 'Localization successfully created', $attrL11n); + } + + /** + * Method to create vehicle attribute l11n from request. + * + * @param RequestAbstract $request Request + * + * @return BaseStringL11n + * + * @since 1.0.0 + */ + private function createVehicleAttributeTypeL11nFromRequest(RequestAbstract $request) : BaseStringL11n + { + $attrL11n = new BaseStringL11n(); + $attrL11n->ref = $request->getDataInt('type') ?? 0; + $attrL11n->setLanguage( + $request->getDataString('language') ?? $request->getLanguage() + ); + $attrL11n->content = $request->getDataString('title') ?? ''; + + return $attrL11n; + } + + /** + * Validate vehicle attribute l11n create request + * + * @param RequestAbstract $request Request + * + * @return array + * + * @since 1.0.0 + */ + private function validateVehicleAttributeTypeL11nCreate(RequestAbstract $request) : array + { + $val = []; + if (($val['title'] = !$request->hasData('title')) + || ($val['type'] = !$request->hasData('type')) + ) { + return $val; + } + + return []; + } + + /** + * Api method to create vehicle attribute type + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return void + * + * @api + * + * @since 1.0.0 + */ + 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->header->status = RequestStatusCode::R_400; + + return; + } + + $attrType = $this->createAttributeTypeFromRequest($request); + $this->createModel($request->header->account, $attrType, VehicleAttributeTypeMapper::class, 'attr_type', $request->getOrigin()); + + $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Attribute type', 'Attribute type successfully created', $attrType); + } + + /** + * Method to create vehicle attribute from request. + * + * @param RequestAbstract $request Request + * + * @return AttributeType + * + * @since 1.0.0 + */ + private function createAttributeTypeFromRequest(RequestAbstract $request) : AttributeType + { + $attrType = new AttributeType($request->getDataString('name') ?? ''); + $attrType->datatype = $request->getDataInt('datatype') ?? 0; + $attrType->custom = $request->getDataBool('custom') ?? false; + $attrType->isRequired = (bool) ($request->getData('is_required') ?? false); + $attrType->validationPattern = $request->getDataString('validation_pattern') ?? ''; + $attrType->setL11n($request->getDataString('title') ?? '', $request->getDataString('language') ?? ISO639x1Enum::_EN); + $attrType->setFields($request->getDataInt('fields') ?? 0); + + return $attrType; + } + + /** + * Validate vehicle attribute create request + * + * @param RequestAbstract $request Request + * + * @return array + * + * @since 1.0.0 + */ + private function validateVehicleAttributeTypeCreate(RequestAbstract $request) : array + { + $val = []; + if (($val['title'] = !$request->hasData('title')) + || ($val['name'] = !$request->hasData('name')) + ) { + return $val; + } + + return []; + } + + /** + * Api method to create vehicle attribute value + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return void + * + * @api + * + * @since 1.0.0 + */ + 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->header->status = RequestStatusCode::R_400; + + return; + } + + $attrValue = $this->createAttributeValueFromRequest($request); + $this->createModel($request->header->account, $attrValue, VehicleAttributeValueMapper::class, 'attr_value', $request->getOrigin()); + + if ($attrValue->isDefault) { + $this->createModelRelation( + $request->header->account, + (int) $request->getData('type'), + $attrValue->id, + VehicleAttributeTypeMapper::class, 'defaults', '', $request->getOrigin() + ); + } + + $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Attribute value', 'Attribute value successfully created', $attrValue); + } + + /** + * Method to create vehicle attribute value from request. + * + * @param RequestAbstract $request Request + * + * @return AttributeValue + * + * @since 1.0.0 + */ + private function createAttributeValueFromRequest(RequestAbstract $request) : AttributeValue + { + /** @var AttributeType $type */ + $type = VehicleAttributeTypeMapper::get() + ->where('id', $request->getDataInt('type') ?? 0) + ->execute(); + + $attrValue = new AttributeValue(); + $attrValue->isDefault = $request->getDataBool('default') ?? false; + $attrValue->setValue($request->getData('value'), $type->datatype); + + if ($request->hasData('title')) { + $attrValue->setL11n($request->getDataString('title') ?? '', $request->getDataString('language') ?? ISO639x1Enum::_EN); + } + + return $attrValue; + } + + /** + * Validate vehicle attribute value create request + * + * @param RequestAbstract $request Request + * + * @return array + * + * @since 1.0.0 + */ + private function validateVehicleAttributeValueCreate(RequestAbstract $request) : array + { + $val = []; + if (($val['type'] = !$request->hasData('type')) + || ($val['value'] = !$request->hasData('value')) + ) { + 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 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->header->status = RequestStatusCode::R_400; + + return; + } + + $attrL11n = $this->createAttributeValueL11nFromRequest($request); + $this->createModel($request->header->account, $attrL11n, VehicleAttributeValueL11nMapper::class, 'attr_value_l11n', $request->getOrigin()); + $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Localization', 'Localization successfully created', $attrL11n); + } + + /** + * Method to create vehicle attribute l11n from request. + * + * @param RequestAbstract $request Request + * + * @return BaseStringL11n + * + * @since 1.0.0 + */ + private function createAttributeValueL11nFromRequest(RequestAbstract $request) : BaseStringL11n + { + $attrL11n = new BaseStringL11n(); + $attrL11n->ref = $request->getDataInt('value') ?? 0; + $attrL11n->setLanguage( + $request->getDataString('language') ?? $request->getLanguage() + ); + $attrL11n->content = $request->getDataString('title') ?? ''; + + return $attrL11n; + } + + /** + * Validate vehicle attribute l11n create request + * + * @param RequestAbstract $request Request + * + * @return array + * + * @since 1.0.0 + */ + private function validateVehicleAttributeValueL11nCreate(RequestAbstract $request) : array + { + $val = []; + if (($val['title'] = !$request->hasData('title')) + || ($val['value'] = !$request->hasData('value')) + ) { + return $val; + } + + return []; + } + + /** + * Api method to handle api vehicle attributes + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return void + * + * @api + * + * @since 1.0.0 + */ + 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->header->status = RequestStatusCode::R_400; + + return; + } + + $attrL11n = $this->createAttributeValueL11nFromRequest($request); + $this->createModel($request->header->account, $attrL11n, VehicleAttributeValueL11nMapper::class, 'attr_value_l11n', $request->getOrigin()); + $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Localization', 'Localization successfully created', $attrL11n); + } + + /** + * Api method to create a bill + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return void + * + * @api + * + * @since 1.0.0 + */ + 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->header->status = RequestStatusCode::R_400; + + return; + } + + /** @var \Modules\FleetManagement\Models\Vehicle $vehicle */ + $vehicle = VehicleMapper::get()->where('id', (int) $request->getData('vehicle'))->execute(); + $path = $this->createVehicleDir($vehicle); + + $uploaded = []; + if (!empty($uploadedFiles = $request->getFiles())) { + $uploaded = $this->app->moduleManager->get('Media')->uploadFiles( + names: [], + fileNames: [], + files: $uploadedFiles, + account: $request->header->account, + basePath: __DIR__ . '/../../../Modules/Media/Files' . $path, + virtualPath: $path, + pathSettings: PathSettings::FILE_PATH, + hasAccountRelation: false, + readContent: (bool) ($request->getData('parse_content') ?? false) + ); + + $collection = null; + foreach ($uploaded as $media) { + $this->createModelRelation( + $request->header->account, + $vehicle->id, + $media->id, + VehicleMapper::class, + 'media', + '', + $request->getOrigin() + ); + + if ($request->hasData('type')) { + $this->createModelRelation( + $request->header->account, + $media->id, + $request->getDataInt('type'), + MediaMapper::class, + 'types', + '', + $request->getOrigin() + ); + } + + if ($collection === null) { + $collection = MediaMapper::getParentCollection($path)->limit(1)->execute(); + + if ($collection->id === 0) { + $collection = $this->app->moduleManager->get('Media')->createRecursiveMediaCollection( + $path, + $request->header->account, + __DIR__ . '/../../../Modules/Media/Files' . $path, + ); + } + } + + $this->createModelRelation( + $request->header->account, + $collection->id, + $media->id, + CollectionMapper::class, + 'sources', + '', + $request->getOrigin() + ); + } + } + + if (!empty($mediaFiles = $request->getDataJson('media'))) { + foreach ($mediaFiles as $media) { + $this->createModelRelation( + $request->header->account, + $vehicle->id, + (int) $media, + VehicleMapper::class, + 'media', + '', + $request->getOrigin() + ); + } + } + + $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Media', 'Media added to bill.', [ + 'upload' => $uploaded, + 'media' => $mediaFiles, + ]); + } + + /** + * Create media directory path + * + * @param Vehicle $vehicle Vehicle + * + * @return string + * + * @since 1.0.0 + */ + private function createVehicleDir(Vehicle $vehicle) : string + { + return '/Modules/FleetManagement/Vehicle/' + . $this->app->unitId . '/' + . $vehicle->createdAt->format('Y/m/d') . '/' + . $vehicle->id; + } + + /** + * Method to validate bill creation from request + * + * @param RequestAbstract $request Request + * + * @return array + * + * @since 1.0.0 + */ + private function validateMediaAddToVehicle(RequestAbstract $request) : array + { + $val = []; + if (($val['media'] = (!$request->hasData('media') && empty($request->getFiles()))) + || ($val['vehicle'] = !$request->hasData('vehicle')) + ) { + return $val; + } + + return []; + } } diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 37ab768..3405264 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -14,6 +14,11 @@ declare(strict_types=1); namespace Modules\FleetManagement\Controller; +use phpOMS\Contract\RenderableInterface; +use phpOMS\Message\RequestAbstract; +use phpOMS\Message\ResponseAbstract; +use phpOMS\Views\View; + /** * FleetManagement class. * @@ -25,5 +30,47 @@ namespace Modules\FleetManagement\Controller; */ final class BackendController extends Controller { + /** + * Routing end-point for application behaviour. + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return RenderableInterface Returns a renderable object + * + * @since 1.0.0 + * @codeCoverageIgnore + */ + public function viewFleetManagementVehicleList(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface + { + $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)); + + return $view; + } + + /** + * Routing end-point for application behaviour. + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return RenderableInterface Returns a renderable object + * + * @since 1.0.0 + * @codeCoverageIgnore + */ + public function viewFleetManagementVehicleProfile(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface + { + $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)); + + return $view; + } } diff --git a/Models/Cost.php b/Models/Cost.php new file mode 100644 index 0000000..6dfcead --- /dev/null +++ b/Models/Cost.php @@ -0,0 +1,48 @@ + $this->id, + ]; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() : mixed + { + return $this->toArray(); + } +} diff --git a/Models/CostType.php b/Models/CostType.php new file mode 100644 index 0000000..4306174 --- /dev/null +++ b/Models/CostType.php @@ -0,0 +1,48 @@ + $this->id, + ]; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() : mixed + { + return $this->toArray(); + } +} diff --git a/Models/FuelType.php b/Models/FuelType.php new file mode 100644 index 0000000..2c7c5e2 --- /dev/null +++ b/Models/FuelType.php @@ -0,0 +1,121 @@ +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(); + } +} diff --git a/Models/FuelTypeL11nMapper.php b/Models/FuelTypeL11nMapper.php new file mode 100644 index 0000000..0b76458 --- /dev/null +++ b/Models/FuelTypeL11nMapper.php @@ -0,0 +1,69 @@ + + */ +final class FuelTypeL11nMapper extends DataMapperFactory +{ + /** + * Columns. + * + * @var array + * @since 1.0.0 + */ + public const COLUMNS = [ + 'fleetmgmt_fuel_type_l11n_id' => ['name' => 'fleetmgmt_fuel_type_l11n_id', 'type' => 'int', 'internal' => 'id'], + 'fleetmgmt_fuel_type_l11n_title' => ['name' => 'fleetmgmt_fuel_type_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true], + 'fleetmgmt_fuel_type_l11n_type' => ['name' => 'fleetmgmt_fuel_type_l11n_type', 'type' => 'int', 'internal' => 'ref'], + 'fleetmgmt_fuel_type_l11n_lang' => ['name' => 'fleetmgmt_fuel_type_l11n_lang', 'type' => 'string', 'internal' => 'language'], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + public const TABLE = 'fleetmgmt_fuel_type_l11n'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + public const PRIMARYFIELD = 'fleetmgmt_fuel_type_l11n_id'; + + /** + * Model to use by the mapper. + * + * @var class-string + * @since 1.0.0 + */ + public const MODEL = BaseStringL11n::class; +} diff --git a/Models/FuelTypeMapper.php b/Models/FuelTypeMapper.php new file mode 100644 index 0000000..10c16f0 --- /dev/null +++ b/Models/FuelTypeMapper.php @@ -0,0 +1,82 @@ + + */ +final class FuelTypeMapper extends DataMapperFactory +{ + /** + * Columns. + * + * @var array + * @since 1.0.0 + */ + 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], + ]; + + /** + * Has many relation. + * + * @var array + * @since 1.0.0 + */ + public const HAS_MANY = [ + 'l11n' => [ + 'mapper' => FuelTypeL11nMapper::class, + 'table' => 'fleetmgmt_fuel_type_l11n', + 'self' => 'fleetmgmt_fuel_type_l11n_type', + 'column' => 'content', + 'external' => null, + ], + ]; + + /** + * Model to use by the mapper. + * + * @var class-string + * @since 1.0.0 + */ + public const MODEL = FuelType::class; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + public const TABLE = 'fleetmgmt_fuel_type'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + public const PRIMARYFIELD = 'fleetmgmt_fuel_type_id'; +} diff --git a/Models/Inspection.php b/Models/Inspection.php new file mode 100644 index 0000000..e69de29 diff --git a/Models/InspectionMapper_.php b/Models/InspectionMapper_.php new file mode 100644 index 0000000..e69de29 diff --git a/Models/NullFuelType.php b/Models/NullFuelType.php new file mode 100644 index 0000000..9502384 --- /dev/null +++ b/Models/NullFuelType.php @@ -0,0 +1,46 @@ +id = $id; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() : mixed + { + return ['id' => $this->id]; + } +} diff --git a/Models/NullInspection.php b/Models/NullInspection.php new file mode 100644 index 0000000..e69de29 diff --git a/Models/NullVehicle.php b/Models/NullVehicle.php new file mode 100644 index 0000000..41270a4 --- /dev/null +++ b/Models/NullVehicle.php @@ -0,0 +1,46 @@ +id = $id; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() : mixed + { + return ['id' => $this->id]; + } +} diff --git a/Models/NullVehicleType.php b/Models/NullVehicleType.php new file mode 100644 index 0000000..cee550b --- /dev/null +++ b/Models/NullVehicleType.php @@ -0,0 +1,46 @@ +id = $id; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() : mixed + { + return ['id' => $this->id]; + } +} diff --git a/Models/Vehicle.php b/Models/Vehicle.php new file mode 100644 index 0000000..e108627 --- /dev/null +++ b/Models/Vehicle.php @@ -0,0 +1,81 @@ +createdAt = new \DateTimeImmutable('now'); + $this->type = new VehicleType(); + $this->fuelType = new FuelType(); + } + + /** + * {@inheritdoc} + */ + public function toArray() : array + { + return [ + 'id' => $this->id, + ]; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() : mixed + { + return $this->toArray(); + } +} diff --git a/Models/VehicleAttributeMapper.php b/Models/VehicleAttributeMapper.php new file mode 100644 index 0000000..fe17883 --- /dev/null +++ b/Models/VehicleAttributeMapper.php @@ -0,0 +1,86 @@ + + */ +final class VehicleAttributeMapper extends DataMapperFactory +{ + /** + * Columns. + * + * @var array + * @since 1.0.0 + */ + public const COLUMNS = [ + 'fleetmgmt_vehicle_attr_id' => ['name' => 'fleetmgmt_vehicle_attr_id', 'type' => 'int', 'internal' => 'id'], + 'fleetmgmt_vehicle_attr_item' => ['name' => 'fleetmgmt_vehicle_attr_item', 'type' => 'int', 'internal' => 'ref'], + 'fleetmgmt_vehicle_attr_type' => ['name' => 'fleetmgmt_vehicle_attr_type', 'type' => 'int', 'internal' => 'type'], + 'fleetmgmt_vehicle_attr_value' => ['name' => 'fleetmgmt_vehicle_attr_value', 'type' => 'int', 'internal' => 'value'], + ]; + + /** + * Has one relation. + * + * @var array + * @since 1.0.0 + */ + public const OWNS_ONE = [ + 'type' => [ + 'mapper' => VehicleAttributeTypeMapper::class, + 'external' => 'fleetmgmt_vehicle_attr_type', + ], + 'value' => [ + 'mapper' => VehicleAttributeValueMapper::class, + 'external' => 'fleetmgmt_vehicle_attr_value', + ], + ]; + + /** + * Model to use by the mapper. + * + * @var class-string + * @since 1.0.0 + */ + public const MODEL = Attribute::class; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + public const TABLE = 'fleetmgmt_vehicle_attr'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + public const PRIMARYFIELD = 'fleetmgmt_vehicle_attr_id'; +} diff --git a/Models/VehicleAttributeTypeL11nMapper.php b/Models/VehicleAttributeTypeL11nMapper.php new file mode 100644 index 0000000..b4afaaa --- /dev/null +++ b/Models/VehicleAttributeTypeL11nMapper.php @@ -0,0 +1,69 @@ + + */ +final class VehicleAttributeTypeL11nMapper extends DataMapperFactory +{ + /** + * Columns. + * + * @var array + * @since 1.0.0 + */ + public const COLUMNS = [ + 'fleetmgmt_attr_type_l11n_id' => ['name' => 'fleetmgmt_attr_type_l11n_id', 'type' => 'int', 'internal' => 'id'], + 'fleetmgmt_attr_type_l11n_title' => ['name' => 'fleetmgmt_attr_type_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true], + 'fleetmgmt_attr_type_l11n_type' => ['name' => 'fleetmgmt_attr_type_l11n_type', 'type' => 'int', 'internal' => 'ref'], + 'fleetmgmt_attr_type_l11n_lang' => ['name' => 'fleetmgmt_attr_type_l11n_lang', 'type' => 'string', 'internal' => 'language'], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + public const TABLE = 'fleetmgmt_attr_type_l11n'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + public const PRIMARYFIELD = 'fleetmgmt_attr_type_l11n_id'; + + /** + * Model to use by the mapper. + * + * @var class-string + * @since 1.0.0 + */ + public const MODEL = BaseStringL11n::class; +} diff --git a/Models/VehicleAttributeTypeMapper.php b/Models/VehicleAttributeTypeMapper.php new file mode 100644 index 0000000..7f55e37 --- /dev/null +++ b/Models/VehicleAttributeTypeMapper.php @@ -0,0 +1,94 @@ + + */ +final class VehicleAttributeTypeMapper extends DataMapperFactory +{ + /** + * Columns. + * + * @var array + * @since 1.0.0 + */ + public const COLUMNS = [ + 'fleetmgmt_attr_type_id' => ['name' => 'fleetmgmt_attr_type_id', 'type' => 'int', 'internal' => 'id'], + 'fleetmgmt_attr_type_name' => ['name' => 'fleetmgmt_attr_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true], + 'fleetmgmt_attr_type_datatype' => ['name' => 'fleetmgmt_attr_type_datatype', 'type' => 'int', 'internal' => 'datatype'], + 'fleetmgmt_attr_type_fields' => ['name' => 'fleetmgmt_attr_type_fields', 'type' => 'int', 'internal' => 'fields'], + 'fleetmgmt_attr_type_custom' => ['name' => 'fleetmgmt_attr_type_custom', 'type' => 'bool', 'internal' => 'custom'], + 'fleetmgmt_attr_type_pattern' => ['name' => 'fleetmgmt_attr_type_pattern', 'type' => 'string', 'internal' => 'validationPattern'], + 'fleetmgmt_attr_type_required' => ['name' => 'fleetmgmt_attr_type_required', 'type' => 'bool', 'internal' => 'isRequired'], + ]; + + /** + * Has many relation. + * + * @var array + * @since 1.0.0 + */ + public const HAS_MANY = [ + 'l11n' => [ + 'mapper' => VehicleAttributeTypeL11nMapper::class, + 'table' => 'fleetmgmt_attr_type_l11n', + 'self' => 'fleetmgmt_attr_type_l11n_type', + 'column' => 'content', + 'external' => null, + ], + 'defaults' => [ + 'mapper' => VehicleAttributeValueMapper::class, + 'table' => 'fleetmgmt_vehicle_attr_default', + 'self' => 'fleetmgmt_vehicle_attr_default_type', + 'external' => 'fleetmgmt_vehicle_attr_default_value', + ], + ]; + + /** + * Model to use by the mapper. + * + * @var class-string + * @since 1.0.0 + */ + public const MODEL = AttributeType::class; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + public const TABLE = 'fleetmgmt_attr_type'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + public const PRIMARYFIELD = 'fleetmgmt_attr_type_id'; +} diff --git a/Models/VehicleAttributeValueL11nMapper.php b/Models/VehicleAttributeValueL11nMapper.php new file mode 100644 index 0000000..7ddf880 --- /dev/null +++ b/Models/VehicleAttributeValueL11nMapper.php @@ -0,0 +1,69 @@ + + */ +final class VehicleAttributeValueL11nMapper extends DataMapperFactory +{ + /** + * Columns. + * + * @var array + * @since 1.0.0 + */ + public const COLUMNS = [ + 'fleetmgmt_attr_value_l11n_id' => ['name' => 'fleetmgmt_attr_value_l11n_id', 'type' => 'int', 'internal' => 'id'], + 'fleetmgmt_attr_value_l11n_title' => ['name' => 'fleetmgmt_attr_value_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true], + 'fleetmgmt_attr_value_l11n_value' => ['name' => 'fleetmgmt_attr_value_l11n_value', 'type' => 'int', 'internal' => 'ref'], + 'fleetmgmt_attr_value_l11n_lang' => ['name' => 'fleetmgmt_attr_value_l11n_lang', 'type' => 'string', 'internal' => 'language'], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + public const TABLE = 'fleetmgmt_attr_value_l11n'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + public const PRIMARYFIELD = 'fleetmgmt_attr_value_l11n_id'; + + /** + * Model to use by the mapper. + * + * @var class-string + * @since 1.0.0 + */ + public const MODEL = BaseStringL11n::class; +} diff --git a/Models/VehicleAttributeValueMapper.php b/Models/VehicleAttributeValueMapper.php new file mode 100644 index 0000000..6191dff --- /dev/null +++ b/Models/VehicleAttributeValueMapper.php @@ -0,0 +1,89 @@ + + */ +final class VehicleAttributeValueMapper extends DataMapperFactory +{ + /** + * Columns. + * + * @var array + * @since 1.0.0 + */ + public const COLUMNS = [ + 'fleetmgmt_attr_value_id' => ['name' => 'fleetmgmt_attr_value_id', 'type' => 'int', 'internal' => 'id'], + 'fleetmgmt_attr_value_default' => ['name' => 'fleetmgmt_attr_value_default', 'type' => 'bool', 'internal' => 'isDefault'], + 'fleetmgmt_attr_value_valueStr' => ['name' => 'fleetmgmt_attr_value_valueStr', 'type' => 'string', 'internal' => 'valueStr'], + 'fleetmgmt_attr_value_valueInt' => ['name' => 'fleetmgmt_attr_value_valueInt', 'type' => 'int', 'internal' => 'valueInt'], + 'fleetmgmt_attr_value_valueDec' => ['name' => 'fleetmgmt_attr_value_valueDec', 'type' => 'float', 'internal' => 'valueDec'], + 'fleetmgmt_attr_value_valueDat' => ['name' => 'fleetmgmt_attr_value_valueDat', 'type' => 'DateTime', 'internal' => 'valueDat'], + 'fleetmgmt_attr_value_unit' => ['name' => 'fleetmgmt_attr_value_unit', 'type' => 'string', 'internal' => 'unit'], + 'fleetmgmt_attr_value_deptype' => ['name' => 'fleetmgmt_attr_value_deptype', 'type' => 'int', 'internal' => 'dependingAttributeType'], + 'fleetmgmt_attr_value_depvalue' => ['name' => 'fleetmgmt_attr_value_depvalue', 'type' => 'int', 'internal' => 'dependingAttributeValue'], + ]; + + /** + * Has many relation. + * + * @var array + * @since 1.0.0 + */ + public const HAS_MANY = [ + 'l11n' => [ + 'mapper' => VehicleAttributeValueL11nMapper::class, + 'table' => 'fleetmgmt_attr_value_l11n', + 'self' => 'fleetmgmt_attr_value_l11n_value', + 'external' => null, + ], + ]; + + /** + * Model to use by the mapper. + * + * @var class-string + * @since 1.0.0 + */ + public const MODEL = AttributeValue::class; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + public const TABLE = 'fleetmgmt_attr_value'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + public const PRIMARYFIELD = 'fleetmgmt_attr_value_id'; +} diff --git a/Models/VehicleMapper.php b/Models/VehicleMapper.php new file mode 100644 index 0000000..b8f697f --- /dev/null +++ b/Models/VehicleMapper.php @@ -0,0 +1,110 @@ + + */ +final class VehicleMapper extends DataMapperFactory +{ + /** + * Columns. + * + * @var array + * @since 1.0.0 + */ + public const COLUMNS = [ + 'fleetmgmt_vehicle_id' => ['name' => 'fleetmgmt_vehicle_id', 'type' => 'int', 'internal' => 'id'], + 'fleetmgmt_vehicle_name' => ['name' => 'fleetmgmt_vehicle_name', 'type' => 'string', 'internal' => 'name'], + 'fleetmgmt_vehicle_status' => ['name' => 'fleetmgmt_vehicle_status', 'type' => 'int', 'internal' => 'status'], + 'fleetmgmt_vehicle_info' => ['name' => 'fleetmgmt_vehicle_info', 'type' => 'string', 'internal' => 'info'], + 'fleetmgmt_vehicle_unit' => ['name' => 'fleetmgmt_vehicle_unit', 'type' => 'int', 'internal' => 'unit'], + 'fleetmgmt_vehicle_responsible' => ['name' => 'fleetmgmt_vehicle_responsible', 'type' => 'int', 'internal' => 'responsible'], + 'fleetmgmt_vehicle_created_at' => ['name' => 'fleetmgmt_vehicle_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true], + ]; + + /** + * Has many relation. + * + * @var array + * @since 1.0.0 + */ + public const HAS_MANY = [ + 'media' => [ + 'mapper' => MediaMapper::class, + 'table' => 'fleetmgmt_vehicle_media', + 'external' => 'fleetmgmt_vehicle_media_media', + 'self' => 'fleetmgmt_vehicle_media_vehicle', + ], + 'attributes' => [ + 'mapper' => VehicleAttributeMapper::class, + 'table' => 'fleetmgmt_vehicle_attr', + 'self' => 'fleetmgmt_vehicle_attr_item', + 'external' => null, + ], + ]; + + /** + * Has one relation. + * + * @var array + * @since 1.0.0 + */ + public const OWNS_ONE = [ + 'type' => [ + 'mapper' => VehicleTypeMapper::class, + 'external' => 'fleetmgmt_vehicle_type', + ], + 'fuelType' => [ + 'mapper' => FuelTypeMapper::class, + 'external' => 'fleetmgmt_vehicle_fuel', + ], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + public const TABLE = 'fleetmgmt_vehicle'; + + /** + * Created at. + * + * @var string + * @since 1.0.0 + */ + public const CREATED_AT = 'fleetmgmt_vehicle_created_at'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + public const PRIMARYFIELD = 'fleetmgmt_vehicle_id'; +} diff --git a/Models/VehicleStatus.php b/Models/VehicleStatus.php new file mode 100644 index 0000000..2adc3d9 --- /dev/null +++ b/Models/VehicleStatus.php @@ -0,0 +1,36 @@ +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(); + } +} diff --git a/Models/VehicleTypeL11nMapper.php b/Models/VehicleTypeL11nMapper.php new file mode 100644 index 0000000..87ef2c8 --- /dev/null +++ b/Models/VehicleTypeL11nMapper.php @@ -0,0 +1,69 @@ + + */ +final class VehicleTypeL11nMapper extends DataMapperFactory +{ + /** + * Columns. + * + * @var array + * @since 1.0.0 + */ + public const COLUMNS = [ + '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'], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + public const TABLE = 'fleetmgmt_vehicle_type_l11n'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + public const PRIMARYFIELD = 'fleetmgmt_vehicle_type_l11n_id'; + + /** + * Model to use by the mapper. + * + * @var class-string + * @since 1.0.0 + */ + public const MODEL = BaseStringL11n::class; +} diff --git a/Models/VehicleTypeMapper.php b/Models/VehicleTypeMapper.php new file mode 100644 index 0000000..b188470 --- /dev/null +++ b/Models/VehicleTypeMapper.php @@ -0,0 +1,82 @@ + + */ +final class VehicleTypeMapper extends DataMapperFactory +{ + /** + * Columns. + * + * @var array + * @since 1.0.0 + */ + 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], + ]; + + /** + * Has many relation. + * + * @var array + * @since 1.0.0 + */ + public const HAS_MANY = [ + 'l11n' => [ + 'mapper' => VehicleTypeL11nMapper::class, + 'table' => 'fleetmgmt_vehicle_type_l11n', + 'self' => 'fleetmgmt_vehicle_type_l11n_type', + 'column' => 'content', + 'external' => null, + ], + ]; + + /** + * Model to use by the mapper. + * + * @var class-string + * @since 1.0.0 + */ + public const MODEL = VehicleType::class; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + public const TABLE = 'fleetmgmt_vehicle_type'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + public const PRIMARYFIELD = 'fleetmgmt_vehicle_type_id'; +} diff --git a/Theme/Backend/Lang/Navigation.en.lang.php b/Theme/Backend/Lang/Navigation.en.lang.php index 89165a9..bd7015c 100755 --- a/Theme/Backend/Lang/Navigation.en.lang.php +++ b/Theme/Backend/Lang/Navigation.en.lang.php @@ -13,7 +13,6 @@ declare(strict_types=1); return ['Navigation' => [ - 'Client' => 'Client', - 'Region' => 'Region', - 'SalesRep' => 'SalesRep', + 'FleetManagement' => 'Fleet Management', + 'Vehicles' => 'Vehicles', ]]; diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php index 99b60d7..8734b98 100755 --- a/Theme/Backend/Lang/en.lang.php +++ b/Theme/Backend/Lang/en.lang.php @@ -12,116 +12,6 @@ */ declare(strict_types=1); -return ['ClientManagement' => [ - 'Accounting' => 'Accounting', - 'Addition' => 'Addition', - 'Address' => 'Address', - 'Addresses' => 'Addresses', - 'Africa' => 'Africa', - 'AllCustomers' => 'All Customers', - 'America' => 'America', - 'Analyse' => 'Analyse', - 'AreaManager' => 'Area Manager', - 'Articlegroup' => 'Articlegroup', - 'Articles' => 'Articles', - 'Asia' => 'Asia', - 'Attribute' => 'Attribute', - 'Attributes' => 'Attributes', - 'Balance' => 'Balance', - 'BaseTime' => 'Base time', - 'Bills' => 'Bills', - 'Bonus' => 'Bonus', - 'Business' => 'Business', - 'CIS' => 'CIS', - 'CLV' => 'CLV', - 'Calendar' => 'Calendar', - 'City' => 'City', - 'Client' => 'Client', - 'ClientID' => 'Client Id', - 'Clients' => 'Clients', - 'ComparisonTime' => 'Comparison time', - 'Contact' => 'Contact', - 'Country' => 'Country', - 'Created' => 'Created', - 'CreatedAt' => 'Created at', - 'CreditRating' => 'Credit Rating', - 'Creditcard' => 'Creditcard', - 'Customers' => 'Customers', - 'DSO' => 'DSO', - 'Date' => 'Date', - 'Default' => 'Default', - 'Delivery' => 'Delivery', - 'Discount' => 'Discount', - 'DiscountBonus' => 'Discount bonus', - 'DiscountP' => 'Discount %', - 'Documents' => 'Documents', - 'Due' => 'Due', - 'Email' => 'Email', - 'Europe' => 'Europe', - 'Fax' => 'Fax', - 'Files' => 'Files', - 'Filter' => 'Filter', - 'Freightage' => 'Freightage', - 'Group' => 'Group', - 'ID' => 'ID', - 'Info' => 'Info', - 'Invoice' => 'Invoice', - 'Invoices' => 'Invoices', - 'IsDefault' => 'Is default?', - 'Items' => 'Items', - 'LastContact' => 'Last Contact', - 'LastOrder' => 'Last Order', - 'Log' => 'Log', - 'Logs' => 'Logs', - 'LostCustomers' => 'Lost customers', - 'MRR' => 'MRR', - 'MTDSales' => 'MTD Sales', - 'Margin' => 'Margin', - 'Messages' => 'Messages', - 'Modified' => 'Modified', - 'Modules' => 'Modules', - 'Name' => 'Name', - 'Name1' => 'Name1', - 'Name2' => 'Name2', - 'Name3' => 'Name3', - 'Net' => 'Net', - 'NewCustomers' => 'New customers', - 'Notes' => 'Notes', - 'Number' => 'Number', - 'Office' => 'Office', - 'Other' => 'Other', - 'Payment' => 'Payment', - 'PaymentTerm' => 'Payment Term', - 'Permission' => 'Permission', - 'Phone' => 'Phone', - 'Postal' => 'Postal', - 'Price' => 'Price', - 'Prices' => 'Prices', - 'Private' => 'Private', - 'Productgroup' => 'Productgroup', - 'Profile' => 'Profile', - 'Profit' => 'Profit', - 'Purchase' => 'Purchase', - 'Quantity' => 'Quantity', - 'RecentInvoices' => 'Recent Invoices', - 'Region' => 'Region', - 'Rep' => 'Rep', - 'Retention' => 'Retention', - 'Sales' => 'Sales', - 'Segment' => 'Segment', - 'Segments' => 'Segments', - 'Subtype' => 'Subtype', - 'Support' => 'Support', - 'Tags' => 'Tags', - 'Title' => 'Title', - 'Total' => 'Total', - 'TotalPrice' => 'Total price', - 'Type' => 'Type', - 'UnitPrice' => 'Unit price', - 'Value' => 'Value', - 'Website' => 'Website', - 'Wire' => 'Wire', - 'YTDSales' => 'YTD Sales', - 'Zip' => 'Zip', - 'IMG_alt_map' => 'Map', +return ['FleetManagement' => [ + 'Vehicle' => 'Vehicle', ]]; diff --git a/Theme/Backend/vehicle-list.tpl.php b/Theme/Backend/vehicle-list.tpl.php index 2adf467..407fe37 100755 --- a/Theme/Backend/vehicle-list.tpl.php +++ b/Theme/Backend/vehicle-list.tpl.php @@ -17,13 +17,13 @@ use Modules\Media\Models\NullMedia; use phpOMS\Uri\UriFactory; /** @var \phpOMS\Views\View $this */ -$clients = $this->getData('client'); +$vehicles = $this->getData('vehicles') ?? []; echo $this->getData('nav')->render(); ?>
-
getHtml('Clients'); ?>
+
getHtml('Vehicles'); ?>
@@ -41,7 +41,7 @@ echo $this->getData('nav')->render(); ?> - - $value) : ++$count; - $url = UriFactory::build('{/base}/sales/client/profile?{?}&id=' . $value->id); - $image = $value->getFileByTypeName('client_profile_image'); + $value) : ++$count; + $url = UriFactory::build('{/base}/sales/vehicle/profile?{?}&id=' . $value->id); + $image = $value->getFileByTypeName('vehicle_profile_image'); ?> -
getHtml('Name'); ?> + getHtml('Status'); ?> getHtml('City'); ?> + getHtml('Name'); ?> getHtml('Zip'); ?> + getHtml('Type'); ?> getHtml('Address'); ?> - - - - getHtml('Country'); ?> - - -
<?= $this->getHtml('IMG_alt_client'); ?><?= $this->getHtml('IMG_alt_vehicle'); ?> diff --git a/Theme/Backend/vehicle-profile.tpl.php b/Theme/Backend/vehicle-profile.tpl.php index ab6a5c0..502d02b 100755 --- a/Theme/Backend/vehicle-profile.tpl.php +++ b/Theme/Backend/vehicle-profile.tpl.php @@ -12,6 +12,7 @@ */ declare(strict_types=1); +use Modules\FleetManagement\Models\NullVehicle; use Modules\Profile\Models\ContactType; use phpOMS\Uri\UriFactory; @@ -19,15 +20,11 @@ $countryCodes = \phpOMS\Localization\ISO3166TwoEnum::getConstants(); $countries = \phpOMS\Localization\ISO3166NameEnum::getConstants(); /** - * @var \Modules\ClientManagement\Models\Client $client + * @var \Modules\FleetManagement\Models\Vehicle $vehicle */ -$client = $this->getData('client'); -$notes = $client->getNotes(); +$vehicle = $this->getData('vehicle') ?? new NullVehicle(); $files = $client->getFiles(); -$newestInvoices = $this->getData('newestInvoices') ?? []; -$monthlySalesCosts = $this->getData('monthlySalesCosts') ?? []; - /** * @var \phpOMS\Views\View $this */ @@ -37,582 +34,83 @@ echo $this->getData('nav')->render();
request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>>
-
+
-
-
- -
-
-
-
-
-
-
-
-
-
-
- -
-
-
+
+ + +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
-
- getHtml('Contact'); ?> - -
-
- -
-
-
-
-
-
-
-
+
+
+
+
-
- getHtml('Address'); ?> - - - - - -
-
- - mainAddress->addition)) : ?> -
-
- -
-
-
-
-
-
-
-
-
- mainAddress->getCountry()) . '.svg')) : ?> - <?= $this->getHtml('IMG_alt_map'); ?> - -
-
-
- -
-
- -
-
-
-
-
-
-
-
- -
getHtml('YTDSales'); ?>: - -
getHtml('MTDSales'); ?>: - -
getHtml('CLV'); ?>: - -
getHtml('MRR'); ?>: - -
-
-
-
- -
-
-
- -
getHtml('LastContact'); ?>: - -
getHtml('LastOrder'); ?>: - -
getHtml('Created'); ?>: - -
getHtml('Modified'); ?>: - -
-
-
-
- -
-
-
- -
getHtml('DSO'); ?>: - -
getHtml('Due'); ?>: - -
getHtml('Balance'); ?>: - -
getHtml('CreditRating'); ?>: - -
-
-
-
-
- -
-
-
-
getHtml('Notes'); ?>
-
- - - - - id); - ?> - -
getHtml('Title'); ?> - getHtml('CreatedAt'); ?> -
title; ?> - createdAt->format('Y-m-d'); ?> - -
-
-
-
- -
-
-
getHtml('Documents'); ?>
-
- - - - - id); - ?> - -
getHtml('Title'); ?> - - getHtml('CreatedAt'); ?> -
name; ?> - extension; ?> - createdAt->format('Y-m-d'); ?> - -
-
-
-
-
- -
-
-
-
getHtml('RecentInvoices'); ?>
- - - - - id); - ?> - -
getHtml('Number'); ?> - getHtml('Type'); ?> - getHtml('Name'); ?> - getHtml('Net'); ?> - getHtml('Date'); ?> -
getNumber(); ?> - type->getL11n(); ?> - billTo; ?> - netSales->getCurrency(); ?> - createdAt->format('Y-m-d'); ?> - -
-
-
-
- -
-
-
-
getHtml('Segments'); ?>
-
-
-
- -
-
-
getHtml('Sales'); ?>
-
- - - ], - "datasets": [ - { - "label": "getHtml('Margin'); ?>", - "type": "line", - "data": [ - - - ], - "yAxisID": "axis-2", - "fill": false, - "borderColor": "rgb(255, 99, 132)", - "backgroundColor": "rgb(255, 99, 132)" - }, - { - "label": "getHtml('Sales'); ?>", - "type": "bar", - "data": [ - - - ], - "yAxisID": "axis-1", - "backgroundColor": "rgb(54, 162, 235)" - } - ] - }, - "options": { - "scales": { - "yAxes": [ - { - "id": "axis-1", - "display": true, - "position": "left" - }, - { - "id": "axis-2", - "display": true, - "position": "right", - "scaleLabel": { - "display": true, - "labelString": "getHtml('Margin'); ?> %" - }, - "gridLines": { - "display": false - }, - "beginAtZero": true, - "ticks": { - "min": 0, - "max": 100, - "stepSize": 10 - } - } - ] - } - } - }'> -
-
-
-
-
-
-
- request->uri->fragment === 'c-tab-3' ? ' checked' : ''; ?>> -
-
-
-
-

getHtml('Address'); ?>

-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-

getHtml('Contact'); ?>

-
-
- -
-
-
-
-
-
-
-
-
-
-
-
+
+
+
- request->uri->fragment === 'c-tab-5' ? ' checked' : ''; ?>> -
-
-
-
-

getHtml('Payment'); ?>

-
-
- -
-
-
-
-
-
-
-
-
- -
-
-
-

getHtml('PaymentTerm'); ?>

-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- request->uri->fragment === 'c-tab-6' ? ' checked' : ''; ?>> -
-
-
-
-

getHtml('Price'); ?>

-
-
- - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- request->uri->fragment === 'c-tab-7' ? ' checked' : ''; ?>> -
-
-
-
-

getHtml('AreaManager'); ?>

-
-
- - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- request->uri->fragment === 'c-tab-8' ? ' checked' : ''; ?>> -
-
- request->uri->fragment === 'c-tab-9' ? ' checked' : ''; ?>> -
- -
- request->uri->fragment === 'c-tab-9' ? ' checked' : ''; ?>> -
- -
- request->uri->fragment === 'c-tab-10' ? ' checked' : ''; ?>> -
-
-
- l11nManager, $this->request, $this->response); - $footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig'); - $footerView->setPages(20); - $footerView->setPage(1); - ?> -
- - - - - - - - -
getHtml('Logs'); ?>
IP - getHtml('ID', '0', '0'); ?> - getHtml('Name'); ?> - getHtml('Log'); ?> - getHtml('Date'); ?> -
-
printHtml($this->request->getOrigin()); ?> - printHtml((string) $this->request->header->account); ?> - printHtml((string) $this->request->header->account); ?> - Creating customer - printHtml((new \DateTime('now'))->format('Y-m-d H:i:s')); ?> -
-
-
-
-
-
+
\ No newline at end of file