mirror of
https://github.com/Karaka-Management/oms-AssetManagement.git
synced 2026-01-10 14:28:39 +00:00
update
This commit is contained in:
parent
41cce097c2
commit
74541d765d
30
Admin/Install/Media.install.json
Normal file
30
Admin/Install/Media.install.json
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
[
|
||||
{
|
||||
"type": "type",
|
||||
"name": "equipment_profile_image",
|
||||
"l11n": [
|
||||
{
|
||||
"title": "Profile image",
|
||||
"lang": "en"
|
||||
},
|
||||
{
|
||||
"title": "Profilbild",
|
||||
"lang": "de"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "collection",
|
||||
"create_directory": true,
|
||||
"name": "AssetManagement",
|
||||
"virtualPath": "/Modules",
|
||||
"user": 1
|
||||
},
|
||||
{
|
||||
"type": "collection",
|
||||
"create_directory": true,
|
||||
"name": "Asset",
|
||||
"virtualPath": "/Modules/AssetManagement",
|
||||
"user": 1
|
||||
}
|
||||
]
|
||||
43
Admin/Install/Media.php
Normal file
43
Admin/Install/Media.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\AssetManagement\Admin\Install
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\AssetManagement\Admin\Install;
|
||||
|
||||
use phpOMS\Application\ApplicationAbstract;
|
||||
|
||||
/**
|
||||
* Media class.
|
||||
*
|
||||
* @package Modules\AssetManagement\Admin\Install
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Media
|
||||
{
|
||||
/**
|
||||
* Install media providing
|
||||
*
|
||||
* @param ApplicationAbstract $app Application
|
||||
* @param string $path Module path
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function install(ApplicationAbstract $app, string $path) : void
|
||||
{
|
||||
\Modules\Media\Admin\Installer::installExternal($app, ['path' => __DIR__ . '/Media.install.json']);
|
||||
}
|
||||
}
|
||||
|
|
@ -27,6 +27,36 @@
|
|||
"permission": { "permission": 2, "type": null, "element": null },
|
||||
"parent": 1006601001,
|
||||
"children": []
|
||||
},
|
||||
{
|
||||
"id": 1006603001,
|
||||
"pid": "/accounting/asset",
|
||||
"type": 3,
|
||||
"subtype": 1,
|
||||
"name": "Table",
|
||||
"uri": "{/base}/accounting/asset/table",
|
||||
"target": "self",
|
||||
"icon": null,
|
||||
"order": 1,
|
||||
"from": "AssetManagement",
|
||||
"permission": { "permission": 2, "type": null, "element": null },
|
||||
"parent": 1006601001,
|
||||
"children": []
|
||||
},
|
||||
{
|
||||
"id": 1006604001,
|
||||
"pid": "/accounting/asset",
|
||||
"type": 3,
|
||||
"subtype": 1,
|
||||
"name": "Entries",
|
||||
"uri": "{/base}/accounting/asset/entry/list",
|
||||
"target": "self",
|
||||
"icon": null,
|
||||
"order": 15,
|
||||
"from": "AssetManagement",
|
||||
"permission": { "permission": 2, "type": null, "element": null },
|
||||
"parent": 1006601001,
|
||||
"children": []
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
1610
Admin/Install/assettype.json
Normal file
1610
Admin/Install/assettype.json
Normal file
File diff suppressed because it is too large
Load Diff
178
Admin/Install/attributes.json
Normal file
178
Admin/Install/attributes.json
Normal file
|
|
@ -0,0 +1,178 @@
|
|||
[
|
||||
{
|
||||
"name": "is_gauge",
|
||||
"l11n": {
|
||||
"en": "Gauge",
|
||||
"de": "Messgerät"
|
||||
},
|
||||
"value_type": 1,
|
||||
"is_custom_allowed": false,
|
||||
"validation_pattern": "",
|
||||
"is_required": false,
|
||||
"default_value": "",
|
||||
"values": [
|
||||
{
|
||||
"value": 0
|
||||
},
|
||||
{
|
||||
"value": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"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": "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": "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": "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": []
|
||||
}
|
||||
]
|
||||
400
Admin/Install/db.json
Normal file
400
Admin/Install/db.json
Normal file
|
|
@ -0,0 +1,400 @@
|
|||
{
|
||||
"assetmgmt_asset_type": {
|
||||
"name": "assetmgmt_asset_type",
|
||||
"fields": {
|
||||
"assetmgmt_asset_type_id": {
|
||||
"name": "assetmgmt_asset_type_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"assetmgmt_asset_type_name": {
|
||||
"name": "assetmgmt_asset_type_name",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"assetmgmt_asset_type_depreciation_duration": {
|
||||
"name": "assetmgmt_asset_type_depreciation_duration",
|
||||
"type": "INT",
|
||||
"null": false
|
||||
},
|
||||
"assetmgmt_asset_type_industry": {
|
||||
"name": "assetmgmt_asset_type_industry",
|
||||
"type": "INT",
|
||||
"null": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"assetmgmt_asset_type_l11n": {
|
||||
"name": "assetmgmt_asset_type_l11n",
|
||||
"fields": {
|
||||
"assetmgmt_asset_type_l11n_id": {
|
||||
"name": "assetmgmt_asset_type_l11n_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"assetmgmt_asset_type_l11n_title": {
|
||||
"name": "assetmgmt_asset_type_l11n_title",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"assetmgmt_asset_type_l11n_type": {
|
||||
"name": "assetmgmt_asset_type_l11n_type",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "assetmgmt_asset_type",
|
||||
"foreignKey": "assetmgmt_asset_type_id"
|
||||
},
|
||||
"assetmgmt_asset_type_l11n_lang": {
|
||||
"name": "assetmgmt_asset_type_l11n_lang",
|
||||
"type": "VARCHAR(2)",
|
||||
"null": false,
|
||||
"foreignTable": "language",
|
||||
"foreignKey": "language_639_1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"assetmgmt_asset": {
|
||||
"name": "assetmgmt_asset",
|
||||
"fields": {
|
||||
"assetmgmt_asset_id": {
|
||||
"name": "assetmgmt_asset_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"assetmgmt_asset_name": {
|
||||
"name": "assetmgmt_asset_name",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"assetmgmt_asset_number": {
|
||||
"name": "assetmgmt_asset_number",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"assetmgmt_asset_status": {
|
||||
"name": "assetmgmt_asset_status",
|
||||
"type": "TINYINT",
|
||||
"null": false
|
||||
},
|
||||
"assetmgmt_asset_type": {
|
||||
"name": "assetmgmt_asset_type",
|
||||
"type": "INT",
|
||||
"foreignTable": "assetmgmt_asset_type",
|
||||
"foreignKey": "assetmgmt_asset_type_id"
|
||||
},
|
||||
"assetmgmt_asset_info": {
|
||||
"name": "assetmgmt_asset_info",
|
||||
"type": "TEXT",
|
||||
"null": false
|
||||
},
|
||||
"assetmgmt_asset_created_at": {
|
||||
"name": "assetmgmt_asset_created_at",
|
||||
"type": "DATETIME",
|
||||
"null": false
|
||||
},
|
||||
"assetmgmt_asset_responsible": {
|
||||
"name": "assetmgmt_asset_responsible",
|
||||
"type": "INT",
|
||||
"null": true,
|
||||
"default": true,
|
||||
"foreignTable": "account",
|
||||
"foreignKey": "account_id"
|
||||
},
|
||||
"assetmgmt_asset_unit": {
|
||||
"name": "assetmgmt_asset_unit",
|
||||
"type": "INT",
|
||||
"default": null,
|
||||
"null": true,
|
||||
"foreignTable": "unit",
|
||||
"foreignKey": "unit_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"assetmgmt_attr_type": {
|
||||
"name": "assetmgmt_attr_type",
|
||||
"fields": {
|
||||
"assetmgmt_attr_type_id": {
|
||||
"name": "assetmgmt_attr_type_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"assetmgmt_attr_type_name": {
|
||||
"name": "assetmgmt_attr_type_name",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false,
|
||||
"unique": true
|
||||
},
|
||||
"assetmgmt_attr_type_datatype": {
|
||||
"name": "assetmgmt_attr_type_datatype",
|
||||
"type": "INT(11)",
|
||||
"null": false
|
||||
},
|
||||
"assetmgmt_attr_type_fields": {
|
||||
"name": "assetmgmt_attr_type_fields",
|
||||
"type": "INT(11)",
|
||||
"null": false
|
||||
},
|
||||
"assetmgmt_attr_type_custom": {
|
||||
"name": "assetmgmt_attr_type_custom",
|
||||
"type": "TINYINT(1)",
|
||||
"null": false
|
||||
},
|
||||
"assetmgmt_attr_type_required": {
|
||||
"description": "Every asset must have this attribute type if set to true.",
|
||||
"name": "assetmgmt_attr_type_required",
|
||||
"type": "TINYINT(1)",
|
||||
"null": false
|
||||
},
|
||||
"assetmgmt_attr_type_pattern": {
|
||||
"description": "This is a regex validation pattern.",
|
||||
"name": "assetmgmt_attr_type_pattern",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"assetmgmt_attr_type_l11n": {
|
||||
"name": "assetmgmt_attr_type_l11n",
|
||||
"fields": {
|
||||
"assetmgmt_attr_type_l11n_id": {
|
||||
"name": "assetmgmt_attr_type_l11n_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"assetmgmt_attr_type_l11n_title": {
|
||||
"name": "assetmgmt_attr_type_l11n_title",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"assetmgmt_attr_type_l11n_type": {
|
||||
"name": "assetmgmt_attr_type_l11n_type",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "assetmgmt_attr_type",
|
||||
"foreignKey": "assetmgmt_attr_type_id"
|
||||
},
|
||||
"assetmgmt_attr_type_l11n_lang": {
|
||||
"name": "assetmgmt_attr_type_l11n_lang",
|
||||
"type": "VARCHAR(2)",
|
||||
"null": false,
|
||||
"foreignTable": "language",
|
||||
"foreignKey": "language_639_1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"assetmgmt_attr_value": {
|
||||
"name": "assetmgmt_attr_value",
|
||||
"fields": {
|
||||
"assetmgmt_attr_value_id": {
|
||||
"name": "assetmgmt_attr_value_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"assetmgmt_attr_value_default": {
|
||||
"name": "assetmgmt_attr_value_default",
|
||||
"type": "TINYINT(1)",
|
||||
"null": false
|
||||
},
|
||||
"assetmgmt_attr_value_valueStr": {
|
||||
"name": "assetmgmt_attr_value_valueStr",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": true,
|
||||
"default": null
|
||||
},
|
||||
"assetmgmt_attr_value_valueInt": {
|
||||
"name": "assetmgmt_attr_value_valueInt",
|
||||
"type": "INT(11)",
|
||||
"null": true,
|
||||
"default": null
|
||||
},
|
||||
"assetmgmt_attr_value_valueDec": {
|
||||
"name": "assetmgmt_attr_value_valueDec",
|
||||
"type": "DECIMAL(19,5)",
|
||||
"null": true,
|
||||
"default": null
|
||||
},
|
||||
"assetmgmt_attr_value_valueDat": {
|
||||
"name": "assetmgmt_attr_value_valueDat",
|
||||
"type": "DATETIME",
|
||||
"null": true,
|
||||
"default": null
|
||||
},
|
||||
"assetmgmt_attr_value_unit": {
|
||||
"name": "assetmgmt_attr_value_unit",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"assetmgmt_attr_value_deptype": {
|
||||
"name": "assetmgmt_attr_value_deptype",
|
||||
"type": "INT(11)",
|
||||
"null": true,
|
||||
"default": null,
|
||||
"foreignTable": "assetmgmt_attr_type",
|
||||
"foreignKey": "assetmgmt_attr_type_id"
|
||||
},
|
||||
"assetmgmt_attr_value_depvalue": {
|
||||
"name": "assetmgmt_attr_value_depvalue",
|
||||
"type": "INT(11)",
|
||||
"null": true,
|
||||
"default": null,
|
||||
"foreignTable": "assetmgmt_attr_value",
|
||||
"foreignKey": "assetmgmt_attr_value_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"assetmgmt_attr_value_l11n": {
|
||||
"name": "assetmgmt_attr_value_l11n",
|
||||
"fields": {
|
||||
"assetmgmt_attr_value_l11n_id": {
|
||||
"name": "assetmgmt_attr_value_l11n_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"assetmgmt_attr_value_l11n_title": {
|
||||
"name": "assetmgmt_attr_value_l11n_title",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"assetmgmt_attr_value_l11n_value": {
|
||||
"name": "assetmgmt_attr_value_l11n_value",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "assetmgmt_attr_value",
|
||||
"foreignKey": "assetmgmt_attr_value_id"
|
||||
},
|
||||
"assetmgmt_attr_value_l11n_lang": {
|
||||
"name": "assetmgmt_attr_value_l11n_lang",
|
||||
"type": "VARCHAR(2)",
|
||||
"null": false,
|
||||
"foreignTable": "language",
|
||||
"foreignKey": "language_639_1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"assetmgmt_asset_attr_default": {
|
||||
"name": "assetmgmt_asset_attr_default",
|
||||
"fields": {
|
||||
"assetmgmt_asset_attr_default_id": {
|
||||
"name": "assetmgmt_asset_attr_default_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"assetmgmt_asset_attr_default_type": {
|
||||
"name": "assetmgmt_asset_attr_default_type",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "assetmgmt_attr_type",
|
||||
"foreignKey": "assetmgmt_attr_type_id"
|
||||
},
|
||||
"assetmgmt_asset_attr_default_value": {
|
||||
"name": "assetmgmt_asset_attr_default_value",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "assetmgmt_attr_value",
|
||||
"foreignKey": "assetmgmt_attr_value_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"assetmgmt_asset_attr": {
|
||||
"name": "assetmgmt_asset_attr",
|
||||
"fields": {
|
||||
"assetmgmt_asset_attr_id": {
|
||||
"name": "assetmgmt_asset_attr_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"assetmgmt_asset_attr_asset": {
|
||||
"name": "assetmgmt_asset_attr_asset",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "assetmgmt_asset",
|
||||
"foreignKey": "assetmgmt_asset_id"
|
||||
},
|
||||
"assetmgmt_asset_attr_type": {
|
||||
"name": "assetmgmt_asset_attr_type",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "assetmgmt_attr_type",
|
||||
"foreignKey": "assetmgmt_attr_type_id"
|
||||
},
|
||||
"assetmgmt_asset_attr_value": {
|
||||
"name": "assetmgmt_asset_attr_value",
|
||||
"type": "INT(11)",
|
||||
"null": true,
|
||||
"default": null,
|
||||
"foreignTable": "assetmgmt_attr_value",
|
||||
"foreignKey": "assetmgmt_attr_value_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"assetmgmt_asset_media": {
|
||||
"name": "assetmgmt_asset_media",
|
||||
"fields": {
|
||||
"assetmgmt_asset_media_id": {
|
||||
"name": "assetmgmt_asset_media_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"assetmgmt_asset_media_asset": {
|
||||
"name": "assetmgmt_asset_media_asset",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "assetmgmt_asset",
|
||||
"foreignKey": "assetmgmt_asset_id"
|
||||
},
|
||||
"assetmgmt_asset_media_media": {
|
||||
"name": "assetmgmt_asset_media_media",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "media",
|
||||
"foreignKey": "media_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"assetmgmt_asset_note": {
|
||||
"name": "assetmgmt_asset_note",
|
||||
"fields": {
|
||||
"assetmgmt_asset_note_id": {
|
||||
"name": "assetmgmt_asset_note_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"assetmgmt_asset_note_asset": {
|
||||
"name": "assetmgmt_asset_note_asset",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "assetmgmt_asset",
|
||||
"foreignKey": "assetmgmt_asset_id"
|
||||
},
|
||||
"assetmgmt_asset_note_doc": {
|
||||
"name": "assetmgmt_asset_note_doc",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "editor_doc",
|
||||
"foreignKey": "editor_doc_id"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\AssetManagement\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,297 @@ 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);
|
||||
|
||||
/* Asset types */
|
||||
$fileContent = \file_get_contents(__DIR__ . '/Install/assettype.json');
|
||||
if ($fileContent === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var array $types */
|
||||
$types = \json_decode($fileContent, true);
|
||||
$assetTypes = self::createAssetTypes($app, $types);
|
||||
}
|
||||
|
||||
/**
|
||||
* Install asset type
|
||||
*
|
||||
* @param ApplicationAbstract $app Application
|
||||
* @param array $types Attribute definition
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static function createAssetTypes(ApplicationAbstract $app, array $types) : array
|
||||
{
|
||||
/** @var array<string, array> $assetTypes */
|
||||
$assetTypes = [];
|
||||
|
||||
/** @var \Modules\AssetManagement\Controller\ApiAssetTypeController $module */
|
||||
$module = $app->moduleManager->getModuleInstance('AssetManagement', 'ApiAssetType');
|
||||
|
||||
/** @var array $type */
|
||||
foreach ($types as $type) {
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('duration', $type['duration']);
|
||||
$request->setData('industry', $type['industry']);
|
||||
$request->setData('title', \reset($type['l11n']));
|
||||
$request->setData('language', \array_keys($type['l11n'])[0] ?? 'en');
|
||||
|
||||
$module->apiAssetTypeCreate($request, $response);
|
||||
|
||||
$responseData = $response->getData('');
|
||||
if (!\is_array($responseData)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$assetType = \is_array($responseData['response'])
|
||||
? $responseData['response']
|
||||
: $responseData['response']->toArray();
|
||||
|
||||
$assetTypes[] = $assetType;
|
||||
|
||||
$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', $assetType['id']);
|
||||
|
||||
$module->apiAssetTypeL11nCreate($request, $response);
|
||||
}
|
||||
}
|
||||
|
||||
return $assetTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Install inspection type
|
||||
*
|
||||
* @param ApplicationAbstract $app Application
|
||||
* @param array $types Attribute definition
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static function createInspectionTypes(ApplicationAbstract $app, array $types) : array
|
||||
{
|
||||
/** @var array<string, array> $inspectionTypes */
|
||||
$inspectionTypes = [];
|
||||
|
||||
/** @var \Modules\AssetManagement\Controller\ApiInspectionTypeController $module */
|
||||
$module = $app->moduleManager->getModuleInstance('AssetManagement', 'ApiInspectionType');
|
||||
|
||||
/** @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->apiInspectionTypeCreate($request, $response);
|
||||
|
||||
$responseData = $response->getData('');
|
||||
if (!\is_array($responseData)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$inspectionTypes[$type['name']] = \is_array($responseData['response'])
|
||||
? $responseData['response']
|
||||
: $responseData['response']->toArray();
|
||||
|
||||
$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', $inspectionTypes[$type['name']]['id']);
|
||||
|
||||
$module->apiInspectionTypeL11nCreate($request, $response);
|
||||
}
|
||||
}
|
||||
|
||||
return $inspectionTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Install default attribute types
|
||||
*
|
||||
* @param ApplicationAbstract $app Application
|
||||
* @param array $attributes Attribute definition
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static function createAttributeTypes(ApplicationAbstract $app, array $attributes) : array
|
||||
{
|
||||
/** @var array<string, array> $itemAttrType */
|
||||
$itemAttrType = [];
|
||||
|
||||
/** @var \Modules\AssetManagement\Controller\ApiAssetAttributeController $module */
|
||||
$module = $app->moduleManager->getModuleInstance('AssetManagement', 'ApiAssetAttribute');
|
||||
|
||||
/** @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->apiAssetAttributeTypeCreate($request, $response);
|
||||
|
||||
$responseData = $response->getData('');
|
||||
if (!\is_array($responseData)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$itemAttrType[$attribute['name']] = \is_array($responseData['response'])
|
||||
? $responseData['response']
|
||||
: $responseData['response']->toArray();
|
||||
|
||||
$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->apiAssetAttributeTypeL11nCreate($request, $response);
|
||||
}
|
||||
}
|
||||
|
||||
return $itemAttrType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create default attribute values for types
|
||||
*
|
||||
* @param ApplicationAbstract $app Application
|
||||
* @param array $itemAttrType Attribute types
|
||||
* @param array<array{name:string, l11n?:array<string, string>, is_required?:bool, is_custom_allowed?:bool, validation_pattern?:string, value_type?:string, values?:array<string, mixed>}> $attributes Attribute definition
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static function createAttributeValues(ApplicationAbstract $app, array $itemAttrType, array $attributes) : array
|
||||
{
|
||||
/** @var array<string, array> $itemAttrValue */
|
||||
$itemAttrValue = [];
|
||||
|
||||
/** @var \Modules\AssetManagement\Controller\ApiAssetAttributeController $module */
|
||||
$module = $app->moduleManager->getModuleInstance('AssetManagement', 'ApiAssetAttribute');
|
||||
|
||||
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->apiAssetAttributeValueCreate($request, $response);
|
||||
|
||||
$responseData = $response->getData('');
|
||||
if (!\is_array($responseData)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$attrValue = \is_array($responseData['response'])
|
||||
? $responseData['response']
|
||||
: $responseData['response']->toArray();
|
||||
|
||||
$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->apiAssetAttributeValueL11nCreate($request, $response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $itemAttrValue;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,34 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
use Modules\AssetManagement\Controller\BackendController;
|
||||
use Modules\AssetManagement\Models\PermissionState;
|
||||
use Modules\AssetManagement\Models\PermissionCategory;
|
||||
use phpOMS\Account\PermissionType;
|
||||
use phpOMS\Router\RouteVerb;
|
||||
|
||||
return [
|
||||
'^.*/accounting/attribute/type/list.*$' => [
|
||||
[
|
||||
'dest' => '\Modules\EquipmentManagement\Controller\BackendController:viewEquipmentManagementAttributeTypeList',
|
||||
'verb' => RouteVerb::GET,
|
||||
'permission' => [
|
||||
'module' => BackendController::NAME,
|
||||
'type' => PermissionType::READ,
|
||||
'state' => PermissionCategory::ASSET,
|
||||
],
|
||||
],
|
||||
],
|
||||
'^.*/accounting/attribute/type\?.*$' => [
|
||||
[
|
||||
'dest' => '\Modules\EquipmentManagement\Controller\BackendController:viewEquipmentManagementAttributeType',
|
||||
'verb' => RouteVerb::GET,
|
||||
'permission' => [
|
||||
'module' => BackendController::NAME,
|
||||
'type' => PermissionType::READ,
|
||||
'state' => PermissionCategory::ASSET,
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
'^.*/accounting/asset/list.*$' => [
|
||||
[
|
||||
'dest' => '\Modules\AssetManagement\Controller\BackendController:viewAssetManagementList',
|
||||
|
|
@ -13,8 +36,63 @@ return [
|
|||
'permission' => [
|
||||
'module' => BackendController::MODULE_NAME,
|
||||
'type' => PermissionType::READ,
|
||||
'state' => PermissionState::ASSET,
|
||||
'state' => PermissionCategory::ASSET,
|
||||
],
|
||||
],
|
||||
],
|
||||
'^.*/accounting/asset/profile.*$' => [
|
||||
[
|
||||
'dest' => '\Modules\AssetManagement\Controller\BackendController:viewAssetManagementProfile',
|
||||
'verb' => RouteVerb::GET,
|
||||
'permission' => [
|
||||
'module' => BackendController::MODULE_NAME,
|
||||
'type' => PermissionType::READ,
|
||||
'state' => PermissionCategory::ASSET,
|
||||
],
|
||||
],
|
||||
],
|
||||
'^.*/accounting/asset/entry/list.*$' => [
|
||||
[
|
||||
'dest' => '\Modules\AssetManagement\Controller\BackendController:viewAssetManagementEntryList',
|
||||
'verb' => RouteVerb::GET,
|
||||
'permission' => [
|
||||
'module' => BackendController::MODULE_NAME,
|
||||
'type' => PermissionType::READ,
|
||||
'state' => PermissionCategory::ASSET,
|
||||
],
|
||||
],
|
||||
],
|
||||
'^.*/accounting/asset/entry/view.*$' => [
|
||||
[
|
||||
'dest' => '\Modules\AssetManagement\Controller\BackendController:viewAssetManagementEntryView',
|
||||
'verb' => RouteVerb::GET,
|
||||
'permission' => [
|
||||
'module' => BackendController::MODULE_NAME,
|
||||
'type' => PermissionType::READ,
|
||||
'state' => PermissionCategory::ASSET,
|
||||
],
|
||||
],
|
||||
],
|
||||
'^.*/accounting/asset/create.*$' => [
|
||||
[
|
||||
'dest' => '\Modules\AssetManagement\Controller\BackendController:viewAssetManagementCreate',
|
||||
'verb' => RouteVerb::GET,
|
||||
'permission' => [
|
||||
'module' => BackendController::MODULE_NAME,
|
||||
'type' => PermissionType::READ,
|
||||
'state' => PermissionCategory::ASSET,
|
||||
],
|
||||
],
|
||||
],
|
||||
'^.*/accounting/asset/table.*$' => [
|
||||
[
|
||||
'dest' => '\Modules\AssetManagement\Controller\BackendController:viewAssetManagementAssetTable',
|
||||
'verb' => RouteVerb::GET,
|
||||
'permission' => [
|
||||
'module' => BackendController::MODULE_NAME,
|
||||
'type' => PermissionType::READ,
|
||||
'state' => PermissionCategory::ASSET,
|
||||
],
|
||||
],
|
||||
]
|
||||
];
|
||||
|
|
|
|||
524
Controller/ApiAssetAttributeController.php
Normal file
524
Controller/ApiAssetAttributeController.php
Normal file
|
|
@ -0,0 +1,524 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\AssetManagement
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\AssetManagement\Controller;
|
||||
|
||||
use Modules\Attribute\Models\Attribute;
|
||||
use Modules\Attribute\Models\AttributeType;
|
||||
use Modules\Attribute\Models\AttributeValue;
|
||||
use Modules\AssetManagement\Models\Attribute\AssetAttributeMapper;
|
||||
use Modules\AssetManagement\Models\Attribute\AssetAttributeTypeL11nMapper;
|
||||
use Modules\AssetManagement\Models\Attribute\AssetAttributeTypeMapper;
|
||||
use Modules\AssetManagement\Models\Attribute\AssetAttributeValueL11nMapper;
|
||||
use Modules\AssetManagement\Models\Attribute\AssetAttributeValueMapper;
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
use phpOMS\Message\Http\RequestStatusCode;
|
||||
use phpOMS\Message\RequestAbstract;
|
||||
use phpOMS\Message\ResponseAbstract;
|
||||
|
||||
/**
|
||||
* AssetManagement class.
|
||||
*
|
||||
* @package Modules\AssetManagement
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class ApiAssetAttributeController extends Controller
|
||||
{
|
||||
use \Modules\Attribute\Controller\ApiAttributeTraitController;
|
||||
|
||||
/**
|
||||
* Api method to create item attribute
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAssetAttributeCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAttributeCreate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidCreateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$type = AssetAttributeTypeMapper::get()->with('defaults')->where('id', (int) $request->getData('type'))->execute();
|
||||
$attribute = $this->createAttributeFromRequest($request, $type);
|
||||
$this->createModel($request->header->account, $attribute, AssetAttributeMapper::class, 'attribute', $request->getOrigin());
|
||||
$this->createStandardCreateResponse($request, $response, $attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create asset attribute l11n
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAssetAttributeTypeL11nCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAttributeTypeL11nCreate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidCreateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$attrL11n = $this->createAttributeTypeL11nFromRequest($request);
|
||||
$this->createModel($request->header->account, $attrL11n, AssetAttributeTypeL11nMapper::class, 'attr_type_l11n', $request->getOrigin());
|
||||
$this->createStandardCreateResponse($request, $response, $attrL11n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create asset attribute type
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAssetAttributeTypeCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAttributeTypeCreate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidCreateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$attrType = $this->createAttributeTypeFromRequest($request);
|
||||
$this->createModel($request->header->account, $attrType, AssetAttributeTypeMapper::class, 'attr_type', $request->getOrigin());
|
||||
$this->createStandardCreateResponse($request, $response, $attrType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create asset attribute value
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAssetAttributeValueCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAttributeValueCreate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidCreateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var \Modules\Attribute\Models\AttributeType $type */
|
||||
$type = AssetAttributeTypeMapper::get()
|
||||
->where('id', $request->getDataInt('type') ?? 0)
|
||||
->execute();
|
||||
|
||||
$attrValue = $this->createAttributeValueFromRequest($request, $type);
|
||||
$this->createModel($request->header->account, $attrValue, AssetAttributeValueMapper::class, 'attr_value', $request->getOrigin());
|
||||
|
||||
if ($attrValue->isDefault) {
|
||||
$this->createModelRelation(
|
||||
$request->header->account,
|
||||
(int) $request->getData('type'),
|
||||
$attrValue->id,
|
||||
AssetAttributeTypeMapper::class, 'defaults', '', $request->getOrigin()
|
||||
);
|
||||
}
|
||||
|
||||
$this->createStandardCreateResponse($request, $response, $attrValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create asset attribute l11n
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAssetAttributeValueL11nCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAttributeValueL11nCreate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidCreateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$attrL11n = $this->createAttributeValueL11nFromRequest($request);
|
||||
$this->createModel($request->header->account, $attrL11n, AssetAttributeValueL11nMapper::class, 'attr_value_l11n', $request->getOrigin());
|
||||
$this->createStandardCreateResponse($request, $response, $attrL11n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to update AssetAttribute
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAssetAttributeUpdate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAttributeUpdate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidUpdateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var Attribute $old */
|
||||
$old = AssetAttributeMapper::get()
|
||||
->with('type')
|
||||
->with('type/defaults')
|
||||
->with('value')
|
||||
->where('id', (int) $request->getData('id'))
|
||||
->execute();
|
||||
|
||||
$new = $this->updateAttributeFromRequest($request, clone $old);
|
||||
|
||||
if ($new->id === 0) {
|
||||
// Set response header to invalid request because of invalid data
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidUpdateResponse($request, $response, $new);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->updateModel($request->header->account, $old, $new, AssetAttributeMapper::class, 'asset_attribute', $request->getOrigin());
|
||||
|
||||
if ($new->value->getValue() !== $old->value->getValue()
|
||||
&& $new->type->custom
|
||||
) {
|
||||
$this->updateModel($request->header->account, $old->value, $new->value, AssetAttributeValueMapper::class, 'attribute_value', $request->getOrigin());
|
||||
}
|
||||
|
||||
$this->createStandardUpdateResponse($request, $response, $new);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to delete AssetAttribute
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAssetAttributeDelete(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAttributeDelete($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidDeleteResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$assetAttribute = AssetAttributeMapper::get()
|
||||
->with('type')
|
||||
->where('id', (int) $request->getData('id'))
|
||||
->execute();
|
||||
|
||||
if ($assetAttribute->type->isRequired) {
|
||||
$this->createInvalidDeleteResponse($request, $response, []);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->deleteModel($request->header->account, $assetAttribute, AssetAttributeMapper::class, 'asset_attribute', $request->getOrigin());
|
||||
$this->createStandardDeleteResponse($request, $response, $assetAttribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to update AssetAttributeTypeL11n
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAssetAttributeTypeL11nUpdate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAttributeTypeL11nUpdate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidUpdateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var BaseStringL11n $old */
|
||||
$old = AssetAttributeTypeL11nMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$new = $this->updateAttributeTypeL11nFromRequest($request, clone $old);
|
||||
|
||||
$this->updateModel($request->header->account, $old, $new, AssetAttributeTypeL11nMapper::class, 'asset_attribute_type_l11n', $request->getOrigin());
|
||||
$this->createStandardUpdateResponse($request, $response, $new);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to delete AssetAttributeTypeL11n
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAssetAttributeTypeL11nDelete(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAttributeTypeL11nDelete($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidDeleteResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var BaseStringL11n $assetAttributeTypeL11n */
|
||||
$assetAttributeTypeL11n = AssetAttributeTypeL11nMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$this->deleteModel($request->header->account, $assetAttributeTypeL11n, AssetAttributeTypeL11nMapper::class, 'asset_attribute_type_l11n', $request->getOrigin());
|
||||
$this->createStandardDeleteResponse($request, $response, $assetAttributeTypeL11n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to update AssetAttributeType
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAssetAttributeTypeUpdate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAttributeTypeUpdate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidUpdateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var AttributeType $old */
|
||||
$old = AssetAttributeTypeMapper::get()->with('defaults')->where('id', (int) $request->getData('id'))->execute();
|
||||
$new = $this->updateAttributeTypeFromRequest($request, clone $old);
|
||||
|
||||
$this->updateModel($request->header->account, $old, $new, AssetAttributeTypeMapper::class, 'asset_attribute_type', $request->getOrigin());
|
||||
$this->createStandardUpdateResponse($request, $response, $new);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to delete AssetAttributeType
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @todo Implement API function
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAssetAttributeTypeDelete(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAttributeTypeDelete($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidDeleteResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var AttributeType $assetAttributeType */
|
||||
$assetAttributeType = AssetAttributeTypeMapper::get()->with('defaults')->where('id', (int) $request->getData('id'))->execute();
|
||||
$this->deleteModel($request->header->account, $assetAttributeType, AssetAttributeTypeMapper::class, 'asset_attribute_type', $request->getOrigin());
|
||||
$this->createStandardDeleteResponse($request, $response, $assetAttributeType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to update AssetAttributeValue
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAssetAttributeValueUpdate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAttributeValueUpdate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidUpdateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var AttributeValue $old */
|
||||
$old = AssetAttributeValueMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
|
||||
/** @var \Modules\Attribute\Models\Attribute $attr */
|
||||
$attr = AssetAttributeMapper::get()
|
||||
->with('type')
|
||||
->where('id', $request->getDataInt('attribute') ?? 0)
|
||||
->execute();
|
||||
|
||||
$new = $this->updateAttributeValueFromRequest($request, clone $old, $attr);
|
||||
|
||||
$this->updateModel($request->header->account, $old, $new, AssetAttributeValueMapper::class, 'asset_attribute_value', $request->getOrigin());
|
||||
$this->createStandardUpdateResponse($request, $response, $new);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to delete AssetAttributeValue
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAssetAttributeValueDelete(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
// @todo I don't think values can be deleted? Only Attributes
|
||||
// However, It should be possible to remove UNUSED default values
|
||||
// either here or other function?
|
||||
// if (!empty($val = $this->validateAttributeValueDelete($request))) {
|
||||
// $response->header->status = RequestStatusCode::R_400;
|
||||
// $this->createInvalidDeleteResponse($request, $response, $val);
|
||||
|
||||
// return;
|
||||
// }
|
||||
|
||||
// /** @var \Modules\AssetManagement\Models\AssetAttributeValue $assetAttributeValue */
|
||||
// $assetAttributeValue = AssetAttributeValueMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
// $this->deleteModel($request->header->account, $assetAttributeValue, AssetAttributeValueMapper::class, 'asset_attribute_value', $request->getOrigin());
|
||||
// $this->createStandardDeleteResponse($request, $response, $assetAttributeValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to update AssetAttributeValueL11n
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAssetAttributeValueL11nUpdate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAttributeValueL11nUpdate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidUpdateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var BaseStringL11n $old */
|
||||
$old = AssetAttributeValueL11nMapper::get()->where('id', (int) $request->getData('id'));
|
||||
$new = $this->updateAttributeValueL11nFromRequest($request, clone $old);
|
||||
|
||||
$this->updateModel($request->header->account, $old, $new, AssetAttributeValueL11nMapper::class, 'asset_attribute_value_l11n', $request->getOrigin());
|
||||
$this->createStandardUpdateResponse($request, $response, $new);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to delete AssetAttributeValueL11n
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAssetAttributeValueL11nDelete(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAttributeValueL11nDelete($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidDeleteResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var BaseStringL11n $assetAttributeValueL11n */
|
||||
$assetAttributeValueL11n = AssetAttributeValueL11nMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$this->deleteModel($request->header->account, $assetAttributeValueL11n, AssetAttributeValueL11nMapper::class, 'asset_attribute_value_l11n', $request->getOrigin());
|
||||
$this->createStandardDeleteResponse($request, $response, $assetAttributeValueL11n);
|
||||
}
|
||||
}
|
||||
634
Controller/ApiAssetController.php
Normal file
634
Controller/ApiAssetController.php
Normal file
|
|
@ -0,0 +1,634 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\AssetManagement
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\AssetManagement\Controller;
|
||||
|
||||
use Modules\Admin\Models\NullAccount;
|
||||
use Modules\AssetManagement\Models\Asset;
|
||||
use Modules\AssetManagement\Models\AssetMapper;
|
||||
use Modules\AssetManagement\Models\AssetStatus;
|
||||
use Modules\AssetManagement\Models\PermissionCategory;
|
||||
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 Modules\Media\Models\ReferenceMapper;
|
||||
use phpOMS\Account\PermissionType;
|
||||
use phpOMS\Localization\NullBaseStringL11nType;
|
||||
use phpOMS\Message\Http\RequestStatusCode;
|
||||
use phpOMS\Message\NotificationLevel;
|
||||
use phpOMS\Message\RequestAbstract;
|
||||
use phpOMS\Message\ResponseAbstract;
|
||||
|
||||
/**
|
||||
* AssetManagement class.
|
||||
*
|
||||
* @package Modules\AssetManagement
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class ApiAssetController extends Controller
|
||||
{
|
||||
/**
|
||||
* Api method to create a asset
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAssetCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAssetCreate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidCreateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var Asset $asset */
|
||||
$asset = $this->createAssetFromRequest($request);
|
||||
$this->createModel($request->header->account, $asset, AssetMapper::class, 'asset', $request->getOrigin());
|
||||
|
||||
if (!empty($request->files)
|
||||
|| !empty($request->getDataJson('media'))
|
||||
) {
|
||||
$this->createAssetMedia($asset, $request);
|
||||
}
|
||||
|
||||
$this->createStandardCreateResponse($request, $response, $asset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create asset from request.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return Asset Returns the created asset from the request
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function createAssetFromRequest(RequestAbstract $request) : Asset
|
||||
{
|
||||
$asset = new Asset();
|
||||
$asset->name = $request->getDataString('name') ?? '';
|
||||
$asset->info = $request->getDataString('info') ?? '';
|
||||
$asset->type = new NullBaseStringL11nType((int) ($request->getDataInt('type') ?? 0));
|
||||
$asset->status = $request->getDataInt('status') ?? AssetStatus::INACTIVE;
|
||||
$asset->unit = $request->getDataInt('unit') ?? $this->app->unitId;
|
||||
|
||||
return $asset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create media files for asset
|
||||
*
|
||||
* @param Asset $asset Asset
|
||||
* @param RequestAbstract $request Request incl. media do upload
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createAssetMedia(Asset $asset, RequestAbstract $request) : void
|
||||
{
|
||||
$path = $this->createAssetDir($asset);
|
||||
|
||||
if (!empty($uploadedFiles = $request->files)) {
|
||||
$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,
|
||||
$asset->id,
|
||||
$media->id,
|
||||
AssetMapper::class,
|
||||
'files',
|
||||
'',
|
||||
$request->getOrigin()
|
||||
);
|
||||
|
||||
if ($collection === null) {
|
||||
/** @var \Modules\Media\Models\Collection $collection */
|
||||
$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,
|
||||
$asset->id,
|
||||
$media->id,
|
||||
AssetMapper::class,
|
||||
'files',
|
||||
'',
|
||||
$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\Collection $collection */
|
||||
$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 asset create request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool> Returns the validation array of the request
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateAssetCreate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['name'] = !$request->hasData('name'))
|
||||
|| ($val['type'] = !$request->hasData('type'))
|
||||
) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create a bill
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiMediaAddToAsset(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateMediaAddToAsset($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidAddResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var \Modules\AssetManagement\Models\Asset $asset */
|
||||
$asset = AssetMapper::get()->where('id', (int) $request->getData('asset'))->execute();
|
||||
$path = $this->createAssetDir($asset);
|
||||
|
||||
$uploaded = [];
|
||||
if (!empty($uploadedFiles = $request->files)) {
|
||||
$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: $request->getDataBool('parse_content') ?? false
|
||||
);
|
||||
|
||||
$collection = null;
|
||||
foreach ($uploaded as $media) {
|
||||
$this->createModelRelation(
|
||||
$request->header->account,
|
||||
$asset->id,
|
||||
$media->id,
|
||||
AssetMapper::class,
|
||||
'files',
|
||||
'',
|
||||
$request->getOrigin()
|
||||
);
|
||||
|
||||
if ($request->hasData('type')) {
|
||||
$this->createModelRelation(
|
||||
$request->header->account,
|
||||
$media->id,
|
||||
$request->getDataInt('type'),
|
||||
MediaMapper::class,
|
||||
'types',
|
||||
'',
|
||||
$request->getOrigin()
|
||||
);
|
||||
}
|
||||
|
||||
if ($collection === null) {
|
||||
/** @var \Modules\Media\Models\Collection $collection */
|
||||
$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,
|
||||
$asset->id,
|
||||
(int) $media,
|
||||
AssetMapper::class,
|
||||
'files',
|
||||
'',
|
||||
$request->getOrigin()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Media', 'Media added to asset.', [
|
||||
'upload' => $uploaded,
|
||||
'media' => $mediaFiles,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create media directory path
|
||||
*
|
||||
* @param Asset $asset Asset
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createAssetDir(Asset $asset) : string
|
||||
{
|
||||
return '/Modules/AssetManagement/Asset/'
|
||||
. $this->app->unitId . '/'
|
||||
. $asset->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to validate bill creation from request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateMediaAddToAsset(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['media'] = (!$request->hasData('media') && empty($request->files)))
|
||||
|| ($val['asset'] = !$request->hasData('asset'))
|
||||
) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create notes
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiNoteCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateNoteCreate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidCreateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$request->setData('virtualpath', '/Modules/AssetManagement/Asset/' . $request->getData('id'), true);
|
||||
$this->app->moduleManager->get('Editor', 'Api')->apiEditorCreate($request, $response, $data);
|
||||
|
||||
if ($response->header->status !== RequestStatusCode::R_200) {
|
||||
return;
|
||||
}
|
||||
|
||||
$responseData = $response->getDataArray($request->uri->__toString());
|
||||
if (!\is_array($responseData)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$model = $responseData['response'];
|
||||
$this->createModelRelation($request->header->account, (int) $request->getData('id'), $model->id, AssetMapper::class, 'notes', '', $request->getOrigin());
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate item note create request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateNoteCreate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['id'] = !$request->hasData('id'))
|
||||
) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to update Asset
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAssetFind(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to update Asset
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAssetUpdate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAssetUpdate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidUpdateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var \Modules\AssetManagement\Models\Asset $old */
|
||||
$old = AssetMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$new = $this->updateAssetFromRequest($request, clone $old);
|
||||
|
||||
$this->updateModel($request->header->account, $old, $new, AssetMapper::class, 'asset', $request->getOrigin());
|
||||
$this->createStandardUpdateResponse($request, $response, $new);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to update Asset from request.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param Asset $new Model to modify
|
||||
*
|
||||
* @return Asset
|
||||
*
|
||||
* @todo Implement API update function
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function updateAssetFromRequest(RequestAbstract $request, Asset $new) : Asset
|
||||
{
|
||||
$new->name = $request->getDataString('name') ?? $new->name;
|
||||
$new->info = $request->getDataString('info') ?? $new->info;
|
||||
$new->type = $request->hasData('type') ? new NullBaseStringL11nType((int) ($request->getDataInt('type') ?? 0)) : $new->type;
|
||||
$new->status = $request->getDataInt('status') ?? $new->status;
|
||||
$new->unit = $request->getDataInt('unit') ?? $this->app->unitId;
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Asset update request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*
|
||||
* @todo Implement API validation function
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateAssetUpdate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['id'] = !$request->hasData('id'))) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to delete Asset
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAssetDelete(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAssetDelete($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidDeleteResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var \Modules\AssetManagement\Models\Asset $asset */
|
||||
$asset = AssetMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$this->deleteModel($request->header->account, $asset, AssetMapper::class, 'asset', $request->getOrigin());
|
||||
$this->createStandardDeleteResponse($request, $response, $asset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Asset delete request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*
|
||||
* @todo Implement API validation function
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateAssetDelete(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['id'] = !$request->hasData('id'))) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to update Note
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiNoteUpdate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
$accountId = $request->header->account;
|
||||
if (!$this->app->accountManager->get($accountId)->hasPermission(
|
||||
PermissionType::MODIFY, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::ASSET_NOTE, $request->getDataInt('id'))
|
||||
) {
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::HIDDEN, '', '', []);
|
||||
$response->header->status = RequestStatusCode::R_403;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->app->moduleManager->get('Editor', 'Api')->apiEditorUpdate($request, $response, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to delete Note
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiNoteDelete(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
$accountId = $request->header->account;
|
||||
if (!$this->app->accountManager->get($accountId)->hasPermission(
|
||||
PermissionType::DELETE, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::ASSET_NOTE, $request->getDataInt('id'))
|
||||
) {
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::HIDDEN, '', '', []);
|
||||
$response->header->status = RequestStatusCode::R_403;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->app->moduleManager->get('Editor', 'Api')->apiEditorDelete($request, $response, $data);
|
||||
}
|
||||
}
|
||||
405
Controller/ApiAssetTypeController.php
Normal file
405
Controller/ApiAssetTypeController.php
Normal file
|
|
@ -0,0 +1,405 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\AssetManagement
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\AssetManagement\Controller;
|
||||
|
||||
use Modules\AssetManagement\Models\AssetType;
|
||||
use Modules\AssetManagement\Models\AssetTypeL11nMapper;
|
||||
use Modules\AssetManagement\Models\AssetTypeMapper;
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
use phpOMS\Localization\BaseStringL11nType;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
use phpOMS\Message\Http\RequestStatusCode;
|
||||
use phpOMS\Message\RequestAbstract;
|
||||
use phpOMS\Message\ResponseAbstract;
|
||||
|
||||
/**
|
||||
* AssetManagement class.
|
||||
*
|
||||
* @package Modules\AssetManagement
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class ApiAssetTypeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Api method to create item attribute type
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAssetTypeCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAssetTypeCreate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidCreateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$assetType = $this->createAssetTypeFromRequest($request);
|
||||
$this->createModel($request->header->account, $assetType, AssetTypeMapper::class, 'asset_type', $request->getOrigin());
|
||||
$this->createStandardCreateResponse($request, $response, $assetType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create item attribute from request.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return AssetType
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createAssetTypeFromRequest(RequestAbstract $request) : AssetType
|
||||
{
|
||||
$assetType = new AssetType();
|
||||
$assetType->setL11n($request->getDataString('title') ?? '', $request->getDataString('language') ?? ISO639x1Enum::_EN);
|
||||
$assetType->depreciationDuration = $request->getDataInt('duration') ?? 0;
|
||||
$assetType->industry = $request->getDataInt('industry') ?? 0;
|
||||
|
||||
return $assetType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate item attribute create request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateAssetTypeCreate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['title'] = !$request->hasData('title'))
|
||||
) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create item attribute l11n
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAssetTypeL11nCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAssetTypeL11nCreate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidCreateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$assetTypeL11n = $this->createAssetTypeL11nFromRequest($request);
|
||||
$this->createModel($request->header->account, $assetTypeL11n, AssetTypeL11nMapper::class, 'asset_type_l11n', $request->getOrigin());
|
||||
$this->createStandardCreateResponse($request, $response, $assetTypeL11n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create item attribute l11n from request.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return BaseStringL11n
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createAssetTypeL11nFromRequest(RequestAbstract $request) : BaseStringL11n
|
||||
{
|
||||
$assetTypeL11n = new BaseStringL11n();
|
||||
$assetTypeL11n->ref = $request->getDataInt('type') ?? 0;
|
||||
$assetTypeL11n->setLanguage(
|
||||
$request->getDataString('language') ?? $request->header->l11n->language
|
||||
);
|
||||
$assetTypeL11n->content = $request->getDataString('title') ?? '';
|
||||
|
||||
return $assetTypeL11n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate item attribute l11n create request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateAssetTypeL11nCreate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['title'] = !$request->hasData('title'))
|
||||
|| ($val['type'] = !$request->hasData('type'))
|
||||
) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to update AssetType
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAssetTypeUpdate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAssetTypeUpdate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidUpdateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var BaseStringL11nType $old */
|
||||
$old = AssetTypeMapper::get()->where('id', (int) $request->getData('id'));
|
||||
$new = $this->updateAssetTypeFromRequest($request, clone $old);
|
||||
|
||||
$this->updateModel($request->header->account, $old, $new, AssetTypeMapper::class, 'asset_type', $request->getOrigin());
|
||||
$this->createStandardUpdateResponse($request, $response, $new);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to update AssetType from request.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param BaseStringL11nType $new Model to modify
|
||||
*
|
||||
* @return BaseStringL11nType
|
||||
*
|
||||
* @todo Implement API update function
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function updateAssetTypeFromRequest(RequestAbstract $request, BaseStringL11nType $new) : BaseStringL11nType
|
||||
{
|
||||
$new->title = $request->getDataString('name') ?? $new->title;
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate AssetType update request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*
|
||||
* @todo Implement API validation function
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateAssetTypeUpdate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['id'] = !$request->hasData('id'))) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to delete AssetType
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAssetTypeDelete(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAssetTypeDelete($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidDeleteResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var BaseStringL11nType $assetType */
|
||||
$assetType = AssetTypeMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$this->deleteModel($request->header->account, $assetType, AssetTypeMapper::class, 'asset_type', $request->getOrigin());
|
||||
$this->createStandardDeleteResponse($request, $response, $assetType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate AssetType delete request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateAssetTypeDelete(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['id'] = !$request->hasData('id'))) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to update AssetTypeL11n
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAssetTypeL11nUpdate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAssetTypeL11nUpdate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidUpdateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var BaseStringL11n $old */
|
||||
$old = AssetTypeL11nMapper::get()->where('id', (int) $request->getData('id'));
|
||||
$new = $this->updateAssetTypeL11nFromRequest($request, clone $old);
|
||||
|
||||
$this->updateModel($request->header->account, $old, $new, AssetTypeL11nMapper::class, 'asset_type_l11n', $request->getOrigin());
|
||||
$this->createStandardUpdateResponse($request, $response, $new);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to update AssetTypeL11n from request.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param BaseStringL11n $new Model to modify
|
||||
*
|
||||
* @return BaseStringL11n
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function updateAssetTypeL11nFromRequest(RequestAbstract $request, BaseStringL11n $new) : BaseStringL11n
|
||||
{
|
||||
$new->setLanguage(
|
||||
$request->getDataString('language') ?? $new->language
|
||||
);
|
||||
$new->content = $request->getDataString('title') ?? $new->content;
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate AssetTypeL11n update request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateAssetTypeL11nUpdate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['id'] = !$request->hasData('id'))) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to delete AssetTypeL11n
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAssetTypeL11nDelete(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAssetTypeL11nDelete($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidDeleteResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var BaseStringL11n $assetTypeL11n */
|
||||
$assetTypeL11n = AssetTypeL11nMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$this->deleteModel($request->header->account, $assetTypeL11n, AssetTypeL11nMapper::class, 'asset_type_l11n', $request->getOrigin());
|
||||
$this->createStandardDeleteResponse($request, $response, $assetTypeL11n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate AssetTypeL11n delete request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateAssetTypeL11nDelete(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['id'] = !$request->hasData('id'))) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,17 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\AssetManagement\Controller;
|
||||
|
||||
use Modules\Admin\Models\LocalizationMapper;
|
||||
use Modules\Admin\Models\SettingsEnum;
|
||||
use Modules\AssetManagement\Models\AssetMapper;
|
||||
use Modules\AssetManagement\Models\AssetTypeMapper;
|
||||
use Modules\AssetManagement\Models\Attribute\AssetAttributeTypeL11nMapper;
|
||||
use Modules\AssetManagement\Models\Attribute\AssetAttributeTypeMapper;
|
||||
use Modules\Media\Models\MediaMapper;
|
||||
use Modules\Media\Models\MediaTypeMapper;
|
||||
use Modules\Organization\Models\UnitMapper;
|
||||
use phpOMS\Contract\RenderableInterface;
|
||||
use phpOMS\DataStorage\Database\Query\Builder;
|
||||
use phpOMS\Message\RequestAbstract;
|
||||
use phpOMS\Message\ResponseAbstract;
|
||||
use phpOMS\Views\View;
|
||||
|
|
@ -30,7 +40,7 @@ use phpOMS\Views\View;
|
|||
final class BackendController extends Controller
|
||||
{
|
||||
/**
|
||||
* Routing end-point for application behaviour.
|
||||
* Routing end-point for application behavior.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
|
|
@ -47,6 +57,134 @@ final class BackendController extends Controller
|
|||
$view->setTemplate('/Modules/AssetManagement/Theme/Backend/asset-list');
|
||||
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1006601001, $request, $response);
|
||||
|
||||
$list = AssetMapper::getAll()
|
||||
->with('type')
|
||||
->with('type/l11n')
|
||||
->where('type/l11n/language', $response->header->l11n->language)
|
||||
->sort('id', 'DESC')
|
||||
->execute();
|
||||
|
||||
$view->data['assets'] = $list;
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Routing end-point for application behavior.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return RenderableInterface
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function viewAssetManagementAttributeType(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
|
||||
{
|
||||
$view = new View($this->app->l11nManager, $request, $response);
|
||||
$view->setTemplate('/Modules/AssetManagement/Theme/Backend/asset-profile');
|
||||
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1006601001, $request, $response);
|
||||
|
||||
/** @var \Modules\Attribute\Models\AttributeType $attribute */
|
||||
$attribute = AssetAttributeTypeMapper::get()
|
||||
->with('l11n')
|
||||
->where('id', (int) $request->getData('id'))
|
||||
->where('l11n/language', $response->header->l11n->language)
|
||||
->execute();
|
||||
|
||||
$l11ns = AssetAttributeTypeL11nMapper::getAll()
|
||||
->where('ref', $attribute->id)
|
||||
->execute();
|
||||
|
||||
$view->data['attribute'] = $attribute;
|
||||
$view->data['l11ns'] = $l11ns;
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Routing end-point for application behavior.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return RenderableInterface Returns a renderable object
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function viewAssetManagementAssetProfile(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
|
||||
{
|
||||
$view = new View($this->app->l11nManager, $request, $response);
|
||||
|
||||
$view->setTemplate('/Modules/AssetManagement/Theme/Backend/asset-profile');
|
||||
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1008402001, $request, $response);
|
||||
|
||||
// @todo This langauge filtering doesn't work. But it was working with the old mappers. Maybe there is a bug in the where() definition. Need to inspect the actual query.
|
||||
$asset = AssetMapper::get()
|
||||
->with('attributes')
|
||||
->with('attributes/type')
|
||||
->with('attributes/value')
|
||||
->with('attributes/type/l11n')
|
||||
->with('files')
|
||||
->with('files/types')
|
||||
->with('type')
|
||||
->with('type/l11n')
|
||||
->where('id', (int) $request->getData('id'))
|
||||
->where('type/l11n/language', $response->header->l11n->language)
|
||||
->where('attributes/type/l11n/language', $response->header->l11n->language)
|
||||
->execute();
|
||||
|
||||
$view->data['asset'] = $asset;
|
||||
|
||||
$query = new Builder($this->app->dbPool->get());
|
||||
$results = $query->selectAs(AssetMapper::HAS_MANY['files']['external'], 'file')
|
||||
->from(AssetMapper::TABLE)
|
||||
->leftJoin(AssetMapper::HAS_MANY['files']['table'])
|
||||
->on(AssetMapper::HAS_MANY['files']['table'] . '.' . AssetMapper::HAS_MANY['files']['self'], '=', AssetMapper::TABLE . '.' . AssetMapper::PRIMARYFIELD)
|
||||
->leftJoin(MediaMapper::TABLE)
|
||||
->on(AssetMapper::HAS_MANY['files']['table'] . '.' . AssetMapper::HAS_MANY['files']['external'], '=', MediaMapper::TABLE . '.' . MediaMapper::PRIMARYFIELD)
|
||||
->leftJoin(MediaMapper::HAS_MANY['types']['table'])
|
||||
->on(MediaMapper::TABLE . '.' . MediaMapper::PRIMARYFIELD, '=', MediaMapper::HAS_MANY['types']['table'] . '.' . MediaMapper::HAS_MANY['types']['self'])
|
||||
->leftJoin(MediaTypeMapper::TABLE)
|
||||
->on(MediaMapper::HAS_MANY['types']['table'] . '.' . MediaMapper::HAS_MANY['types']['external'], '=', MediaTypeMapper::TABLE . '.' . MediaTypeMapper::PRIMARYFIELD)
|
||||
->where(AssetMapper::HAS_MANY['files']['self'], '=', $asset->id)
|
||||
->where(MediaTypeMapper::TABLE . '.' . MediaTypeMapper::getColumnByMember('name'), '=', 'asset_profile_image');
|
||||
|
||||
$assetImage = MediaMapper::get()
|
||||
->with('types')
|
||||
->where('id', $results)
|
||||
->limit(1)
|
||||
->execute();
|
||||
|
||||
$view->data['assetImage'] = $assetImage;
|
||||
|
||||
$assetTypes = AssetTypeMapper::getAll()
|
||||
->with('l11n')
|
||||
->where('l11n/language', $response->header->l11n->language)
|
||||
->execute();
|
||||
|
||||
$view->data['types'] = $assetTypes;
|
||||
|
||||
$units = UnitMapper::getAll()
|
||||
->execute();
|
||||
|
||||
$view->data['units'] = $units;
|
||||
|
||||
/** @var \Model\Setting $settings */
|
||||
$settings = $this->app->appSettings->get(null, [
|
||||
SettingsEnum::DEFAULT_LOCALIZATION,
|
||||
]);
|
||||
|
||||
$view->data['attributeView'] = new \Modules\Attribute\Theme\Backend\Components\AttributeView($this->app->l11nManager, $request, $response);
|
||||
$view->data['attributeView']->data['defaultlocalization'] = LocalizationMapper::get()->where('id', (int) $settings->id)->execute();
|
||||
|
||||
$view->data['media-upload'] = new \Modules\Media\Theme\Backend\Components\Upload\BaseView($this->app->l11nManager, $request, $response);
|
||||
$view->data['asset-notes'] = new \Modules\Editor\Theme\Backend\Components\Compound\BaseView($this->app->l11nManager, $request, $response);
|
||||
|
||||
return $view;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
3
Docs/Dev/en/SUMMARY.md
Normal file
3
Docs/Dev/en/SUMMARY.md
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# Developer Content
|
||||
|
||||
* [Structure]({%}&page=Dev/structure)
|
||||
5
Docs/Dev/en/structure.md
Normal file
5
Docs/Dev/en/structure.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# Structure
|
||||
|
||||
## ER
|
||||
|
||||

|
||||
BIN
Docs/Dev/img/er.png
Normal file
BIN
Docs/Dev/img/er.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 52 KiB |
79
Models/Asset.php
Normal file
79
Models/Asset.php
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\AssetManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\AssetManagement\Models;
|
||||
|
||||
use phpOMS\Localization\BaseStringL11nType;
|
||||
|
||||
/**
|
||||
* Asset class.
|
||||
*
|
||||
* @package Modules\Attribute\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Asset implements \JsonSerializable
|
||||
{
|
||||
public int $id = 0;
|
||||
|
||||
public string $name = '';
|
||||
|
||||
public int $status = AssetStatus::ACTIVE;
|
||||
|
||||
public BaseStringL11nType $type;
|
||||
|
||||
public string $info = '';
|
||||
|
||||
public int $unit = 0;
|
||||
|
||||
public ?int $responsible = null;
|
||||
|
||||
public string $number = '';
|
||||
|
||||
public \DateTimeImmutable $createdAt;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->createdAt = new \DateTimeImmutable('now');
|
||||
$this->type = new BaseStringL11nType();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
|
||||
use \Modules\Media\Models\MediaListTrait;
|
||||
use \Modules\Editor\Models\EditorDocListTrait;
|
||||
use \Modules\Attribute\Models\AttributeHolderTrait;
|
||||
}
|
||||
116
Models/AssetMapper.php
Normal file
116
Models/AssetMapper.php
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\AssetManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\AssetManagement\Models;
|
||||
|
||||
use Modules\Editor\Models\EditorDocMapper;
|
||||
use Modules\AssetManagement\Models\Attribute\AssetAttributeMapper;
|
||||
use Modules\Media\Models\MediaMapper;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Mapper class.
|
||||
*
|
||||
* @package Modules\AssetManagement\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @template T of Asset
|
||||
* @extends DataMapperFactory<T>
|
||||
*/
|
||||
final class AssetMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const COLUMNS = [
|
||||
'assetmgmt_asset_id' => ['name' => 'assetmgmt_asset_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'assetmgmt_asset_name' => ['name' => 'assetmgmt_asset_name', 'type' => 'string', 'internal' => 'name'],
|
||||
'assetmgmt_asset_number' => ['name' => 'assetmgmt_asset_number', 'type' => 'string', 'internal' => 'number'],
|
||||
'assetmgmt_asset_status' => ['name' => 'assetmgmt_asset_status', 'type' => 'int', 'internal' => 'status'],
|
||||
'assetmgmt_asset_info' => ['name' => 'assetmgmt_asset_info', 'type' => 'string', 'internal' => 'info'],
|
||||
'assetmgmt_asset_unit' => ['name' => 'assetmgmt_asset_unit', 'type' => 'int', 'internal' => 'unit'],
|
||||
'assetmgmt_asset_type' => ['name' => 'assetmgmt_asset_type', 'type' => 'int', 'internal' => 'type'],
|
||||
'assetmgmt_asset_responsible' => ['name' => 'assetmgmt_asset_responsible', 'type' => 'int', 'internal' => 'responsible'],
|
||||
'assetmgmt_asset_created_at' => ['name' => 'assetmgmt_asset_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
|
||||
];
|
||||
|
||||
/**
|
||||
* Has many relation.
|
||||
*
|
||||
* @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const HAS_MANY = [
|
||||
'files' => [
|
||||
'mapper' => MediaMapper::class,
|
||||
'table' => 'assetmgmt_asset_media',
|
||||
'external' => 'assetmgmt_asset_media_media',
|
||||
'self' => 'assetmgmt_asset_media_asset',
|
||||
],
|
||||
'attributes' => [
|
||||
'mapper' => AssetAttributeMapper::class,
|
||||
'table' => 'assetmgmt_asset_attr',
|
||||
'self' => 'assetmgmt_asset_attr_asset',
|
||||
'external' => null,
|
||||
],
|
||||
'notes' => [
|
||||
'mapper' => EditorDocMapper::class, /* mapper of the related object */
|
||||
'table' => 'assetmgmt_asset_note', /* table of the related object, null if no relation table is used (many->1) */
|
||||
'external' => 'assetmgmt_asset_note_doc',
|
||||
'self' => 'assetmgmt_asset_note_asset',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Has one relation.
|
||||
*
|
||||
* @var array<string, array{mapper:class-string, external:string, by?:string, column?:string, conditional?:bool}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const OWNS_ONE = [
|
||||
'type' => [
|
||||
'mapper' => AssetTypeMapper::class,
|
||||
'external' => 'assetmgmt_asset_type',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'assetmgmt_asset';
|
||||
|
||||
/**
|
||||
* Created at.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const CREATED_AT = 'assetmgmt_asset_created_at';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD = 'assetmgmt_asset_id';
|
||||
}
|
||||
38
Models/AssetStatus.php
Normal file
38
Models/AssetStatus.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\AssetManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\AssetManagement\Models;
|
||||
|
||||
use phpOMS\Stdlib\Base\Enum;
|
||||
|
||||
/**
|
||||
* Asset status enum.
|
||||
*
|
||||
* @package Modules\AssetManagement\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract class AssetStatus extends Enum
|
||||
{
|
||||
public const ACTIVE = 1;
|
||||
|
||||
public const INACTIVE = 2;
|
||||
|
||||
public const DAMAGED = 3;
|
||||
|
||||
public const OUT_OF_ORDER = 4;
|
||||
|
||||
public const MAINTENANCE = 5;
|
||||
}
|
||||
32
Models/AssetType.php
Normal file
32
Models/AssetType.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\AssetManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\AssetManagement\Models;
|
||||
|
||||
use phpOMS\Localization\BaseStringL11nType;
|
||||
|
||||
/**
|
||||
* Asset class.
|
||||
*
|
||||
* @package Modules\Attribute\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class AssetType extends BaseStringL11nType
|
||||
{
|
||||
public int $depreciationDuration = 0;
|
||||
|
||||
public int $industry = 0;
|
||||
}
|
||||
69
Models/AssetTypeL11nMapper.php
Normal file
69
Models/AssetTypeL11nMapper.php
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\AssetManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\AssetManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
|
||||
/**
|
||||
* mapper class.
|
||||
*
|
||||
* @package Modules\AssetManagement\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @template T of BaseStringL11n
|
||||
* @extends DataMapperFactory<T>
|
||||
*/
|
||||
final class AssetTypeL11nMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const COLUMNS = [
|
||||
'assetmgmt_asset_type_l11n_id' => ['name' => 'assetmgmt_asset_type_l11n_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'assetmgmt_asset_type_l11n_title' => ['name' => 'assetmgmt_asset_type_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true],
|
||||
'assetmgmt_asset_type_l11n_type' => ['name' => 'assetmgmt_asset_type_l11n_type', 'type' => 'int', 'internal' => 'ref'],
|
||||
'assetmgmt_asset_type_l11n_lang' => ['name' => 'assetmgmt_asset_type_l11n_lang', 'type' => 'string', 'internal' => 'language'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'assetmgmt_asset_type_l11n';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD = 'assetmgmt_asset_type_l11n_id';
|
||||
|
||||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
* @var class-string<T>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const MODEL = BaseStringL11n::class;
|
||||
}
|
||||
84
Models/AssetTypeMapper.php
Normal file
84
Models/AssetTypeMapper.php
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\AssetManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\AssetManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Item mapper class.
|
||||
*
|
||||
* @package Modules\AssetManagement\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @extends DataMapperFactory<T>
|
||||
*/
|
||||
final class AssetTypeMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const COLUMNS = [
|
||||
'assetmgmt_asset_type_id' => ['name' => 'assetmgmt_asset_type_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'assetmgmt_asset_type_name' => ['name' => 'assetmgmt_asset_type_name', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true],
|
||||
'assetmgmt_asset_type_depreciation_duration' => ['name' => 'assetmgmt_asset_type_depreciation_duration', 'type' => 'int', 'internal' => 'depreciationDuration'],
|
||||
'assetmgmt_asset_type_industry' => ['name' => 'assetmgmt_asset_type_industry', 'type' => 'int', 'internal' => 'industry'],
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* Has many relation.
|
||||
*
|
||||
* @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const HAS_MANY = [
|
||||
'l11n' => [
|
||||
'mapper' => AssetTypeL11nMapper::class,
|
||||
'table' => 'assetmgmt_asset_type_l11n',
|
||||
'self' => 'assetmgmt_asset_type_l11n_type',
|
||||
'column' => 'content',
|
||||
'external' => null,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
* @var class-string<T>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const MODEL = AssetType::class;
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'assetmgmt_asset_type';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD = 'assetmgmt_asset_type_id';
|
||||
}
|
||||
86
Models/Attribute/AssetAttributeMapper.php
Normal file
86
Models/Attribute/AssetAttributeMapper.php
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\AssetManagement\Models\Attribute
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\AssetManagement\Models\Attribute;
|
||||
|
||||
use Modules\Attribute\Models\Attribute;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Fleet mapper class.
|
||||
*
|
||||
* @package Modules\AssetManagement\Models\Attribute
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @template T of Attribute
|
||||
* @extends DataMapperFactory<T>
|
||||
*/
|
||||
final class AssetAttributeMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const COLUMNS = [
|
||||
'assetmgmt_asset_attr_id' => ['name' => 'assetmgmt_asset_attr_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'assetmgmt_asset_attr_asset' => ['name' => 'assetmgmt_asset_attr_asset', 'type' => 'int', 'internal' => 'ref'],
|
||||
'assetmgmt_asset_attr_type' => ['name' => 'assetmgmt_asset_attr_type', 'type' => 'int', 'internal' => 'type'],
|
||||
'assetmgmt_asset_attr_value' => ['name' => 'assetmgmt_asset_attr_value', 'type' => 'int', 'internal' => 'value'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Has one relation.
|
||||
*
|
||||
* @var array<string, array{mapper:class-string, external:string, by?:string, column?:string, conditional?:bool}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const OWNS_ONE = [
|
||||
'type' => [
|
||||
'mapper' => AssetAttributeTypeMapper::class,
|
||||
'external' => 'assetmgmt_asset_attr_type',
|
||||
],
|
||||
'value' => [
|
||||
'mapper' => AssetAttributeValueMapper::class,
|
||||
'external' => 'assetmgmt_asset_attr_value',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
* @var class-string<T>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const MODEL = Attribute::class;
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'assetmgmt_asset_attr';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD = 'assetmgmt_asset_attr_id';
|
||||
}
|
||||
69
Models/Attribute/AssetAttributeTypeL11nMapper.php
Normal file
69
Models/Attribute/AssetAttributeTypeL11nMapper.php
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\AssetManagement\Models\Attribute
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\AssetManagement\Models\Attribute;
|
||||
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
|
||||
/**
|
||||
* Asset mapper class.
|
||||
*
|
||||
* @package Modules\AssetManagement\Models\Attribute
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @template T of BaseStringL11n
|
||||
* @extends DataMapperFactory<T>
|
||||
*/
|
||||
final class AssetAttributeTypeL11nMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const COLUMNS = [
|
||||
'assetmgmt_attr_type_l11n_id' => ['name' => 'assetmgmt_attr_type_l11n_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'assetmgmt_attr_type_l11n_title' => ['name' => 'assetmgmt_attr_type_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true],
|
||||
'assetmgmt_attr_type_l11n_type' => ['name' => 'assetmgmt_attr_type_l11n_type', 'type' => 'int', 'internal' => 'ref'],
|
||||
'assetmgmt_attr_type_l11n_lang' => ['name' => 'assetmgmt_attr_type_l11n_lang', 'type' => 'string', 'internal' => 'language'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'assetmgmt_attr_type_l11n';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD = 'assetmgmt_attr_type_l11n_id';
|
||||
|
||||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
* @var class-string<T>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const MODEL = BaseStringL11n::class;
|
||||
}
|
||||
94
Models/Attribute/AssetAttributeTypeMapper.php
Normal file
94
Models/Attribute/AssetAttributeTypeMapper.php
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\AssetManagement\Models\Attribute
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\AssetManagement\Models\Attribute;
|
||||
|
||||
use Modules\Attribute\Models\AttributeType;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Asset mapper class.
|
||||
*
|
||||
* @package Modules\AssetManagement\Models\Attribute
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @template T of AttributeType
|
||||
* @extends DataMapperFactory<T>
|
||||
*/
|
||||
final class AssetAttributeTypeMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const COLUMNS = [
|
||||
'assetmgmt_attr_type_id' => ['name' => 'assetmgmt_attr_type_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'assetmgmt_attr_type_name' => ['name' => 'assetmgmt_attr_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
|
||||
'assetmgmt_attr_type_datatype' => ['name' => 'assetmgmt_attr_type_datatype', 'type' => 'int', 'internal' => 'datatype'],
|
||||
'assetmgmt_attr_type_fields' => ['name' => 'assetmgmt_attr_type_fields', 'type' => 'int', 'internal' => 'fields'],
|
||||
'assetmgmt_attr_type_custom' => ['name' => 'assetmgmt_attr_type_custom', 'type' => 'bool', 'internal' => 'custom'],
|
||||
'assetmgmt_attr_type_pattern' => ['name' => 'assetmgmt_attr_type_pattern', 'type' => 'string', 'internal' => 'validationPattern'],
|
||||
'assetmgmt_attr_type_required' => ['name' => 'assetmgmt_attr_type_required', 'type' => 'bool', 'internal' => 'isRequired'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Has many relation.
|
||||
*
|
||||
* @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const HAS_MANY = [
|
||||
'l11n' => [
|
||||
'mapper' => AssetAttributeTypeL11nMapper::class,
|
||||
'table' => 'assetmgmt_attr_type_l11n',
|
||||
'self' => 'assetmgmt_attr_type_l11n_type',
|
||||
'column' => 'content',
|
||||
'external' => null,
|
||||
],
|
||||
'defaults' => [
|
||||
'mapper' => AssetAttributeValueMapper::class,
|
||||
'table' => 'assetmgmt_asset_attr_default',
|
||||
'self' => 'assetmgmt_asset_attr_default_type',
|
||||
'external' => 'assetmgmt_asset_attr_default_value',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
* @var class-string<T>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const MODEL = AttributeType::class;
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'assetmgmt_attr_type';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD = 'assetmgmt_attr_type_id';
|
||||
}
|
||||
69
Models/Attribute/AssetAttributeValueL11nMapper.php
Normal file
69
Models/Attribute/AssetAttributeValueL11nMapper.php
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\AssetManagement\Models\Attribute
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\AssetManagement\Models\Attribute;
|
||||
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
|
||||
/**
|
||||
* Asset mapper class.
|
||||
*
|
||||
* @package Modules\AssetManagement\Models\Attribute
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @template T of BaseStringL11n
|
||||
* @extends DataMapperFactory<T>
|
||||
*/
|
||||
final class AssetAttributeValueL11nMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const COLUMNS = [
|
||||
'assetmgmt_attr_value_l11n_id' => ['name' => 'assetmgmt_attr_value_l11n_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'assetmgmt_attr_value_l11n_title' => ['name' => 'assetmgmt_attr_value_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true],
|
||||
'assetmgmt_attr_value_l11n_value' => ['name' => 'assetmgmt_attr_value_l11n_value', 'type' => 'int', 'internal' => 'ref'],
|
||||
'assetmgmt_attr_value_l11n_lang' => ['name' => 'assetmgmt_attr_value_l11n_lang', 'type' => 'string', 'internal' => 'language'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'assetmgmt_attr_value_l11n';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD = 'assetmgmt_attr_value_l11n_id';
|
||||
|
||||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
* @var class-string<T>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const MODEL = BaseStringL11n::class;
|
||||
}
|
||||
89
Models/Attribute/AssetAttributeValueMapper.php
Normal file
89
Models/Attribute/AssetAttributeValueMapper.php
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\AssetManagement\Models\Attribute
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\AssetManagement\Models\Attribute;
|
||||
|
||||
use Modules\Attribute\Models\AttributeValue;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Asset mapper class.
|
||||
*
|
||||
* @package Modules\AssetManagement\Models\Attribute
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @template T of AttributeValue
|
||||
* @extends DataMapperFactory<T>
|
||||
*/
|
||||
final class AssetAttributeValueMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const COLUMNS = [
|
||||
'assetmgmt_attr_value_id' => ['name' => 'assetmgmt_attr_value_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'assetmgmt_attr_value_default' => ['name' => 'assetmgmt_attr_value_default', 'type' => 'bool', 'internal' => 'isDefault'],
|
||||
'assetmgmt_attr_value_valueStr' => ['name' => 'assetmgmt_attr_value_valueStr', 'type' => 'string', 'internal' => 'valueStr'],
|
||||
'assetmgmt_attr_value_valueInt' => ['name' => 'assetmgmt_attr_value_valueInt', 'type' => 'int', 'internal' => 'valueInt'],
|
||||
'assetmgmt_attr_value_valueDec' => ['name' => 'assetmgmt_attr_value_valueDec', 'type' => 'float', 'internal' => 'valueDec'],
|
||||
'assetmgmt_attr_value_valueDat' => ['name' => 'assetmgmt_attr_value_valueDat', 'type' => 'DateTime', 'internal' => 'valueDat'],
|
||||
'assetmgmt_attr_value_unit' => ['name' => 'assetmgmt_attr_value_unit', 'type' => 'string', 'internal' => 'unit'],
|
||||
'assetmgmt_attr_value_deptype' => ['name' => 'assetmgmt_attr_value_deptype', 'type' => 'int', 'internal' => 'dependingAttributeType'],
|
||||
'assetmgmt_attr_value_depvalue' => ['name' => 'assetmgmt_attr_value_depvalue', 'type' => 'int', 'internal' => 'dependingAttributeValue'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Has many relation.
|
||||
*
|
||||
* @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const HAS_MANY = [
|
||||
'l11n' => [
|
||||
'mapper' => AssetAttributeValueL11nMapper::class,
|
||||
'table' => 'assetmgmt_attr_value_l11n',
|
||||
'self' => 'assetmgmt_attr_value_l11n_value',
|
||||
'external' => null,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
* @var class-string<T>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const MODEL = AttributeValue::class;
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'assetmgmt_attr_value';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD = 'assetmgmt_attr_value_id';
|
||||
}
|
||||
47
Models/NullAsset.php
Normal file
47
Models/NullAsset.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\AssetManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\AssetManagement\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\AssetManagement\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullAsset extends Asset
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return ['id' => $this->id];
|
||||
}
|
||||
}
|
||||
47
Models/NullAssetType.php
Normal file
47
Models/NullAssetType.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\AssetManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\AssetManagement\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\AssetManagement\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullAssetType extends AssetType
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return ['id' => $this->id];
|
||||
}
|
||||
}
|
||||
|
|
@ -17,14 +17,20 @@ namespace Modules\AssetManagement\Models;
|
|||
use phpOMS\Stdlib\Base\Enum;
|
||||
|
||||
/**
|
||||
* Permision state enum.
|
||||
* Permission category enum.
|
||||
*
|
||||
* @package Modules\AssetManagement\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract class PermissionState extends Enum
|
||||
abstract class PermissionCategory extends Enum
|
||||
{
|
||||
public const ASSET = 1;
|
||||
|
||||
public const ASSET_TYPE = 3;
|
||||
|
||||
public const ASSET_ATTRIBUTE_TYPE = 6;
|
||||
|
||||
public const ASSET_NOTE = 7;
|
||||
}
|
||||
|
|
@ -15,4 +15,5 @@ declare(strict_types=1);
|
|||
return ['Navigation' => [
|
||||
'Assets' => 'Anlagegüter',
|
||||
'Dashboard' => 'Dashboard',
|
||||
'Table' => 'Tabelle',
|
||||
]];
|
||||
|
|
|
|||
|
|
@ -15,4 +15,5 @@ declare(strict_types=1);
|
|||
return ['Navigation' => [
|
||||
'Assets' => 'Assets',
|
||||
'Dashboard' => 'Dashboard',
|
||||
'Table' => 'Table',
|
||||
]];
|
||||
|
|
|
|||
|
|
@ -13,4 +13,13 @@
|
|||
declare(strict_types=1);
|
||||
|
||||
return ['AssetManagement' => [
|
||||
'Assets' => 'Assets',
|
||||
'Status' => 'Status',
|
||||
'Name' => 'Name',
|
||||
'Number' => 'Number',
|
||||
'Type' => 'Type',
|
||||
':status1' => 'Active',
|
||||
':status2' => 'Inactive',
|
||||
':status3' => 'Damaged',
|
||||
':status4' => 'Out of order',
|
||||
]];
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
|
|
@ -12,4 +13,88 @@
|
|||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
echo $this->data['nav']->render();
|
||||
use phpOMS\Uri\UriFactory;
|
||||
|
||||
/** @var \phpOMS\Views\View $this */
|
||||
$assets = $this->data['assets'] ?? [];
|
||||
|
||||
echo $this->data['nav']->render(); ?>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<section class="portlet">
|
||||
<div class="portlet-head"><?= $this->getHtml('Assets'); ?><i class="g-icon download btn end-xs">download</i></div>
|
||||
<div class="slider">
|
||||
<table id="iSalesClientList" class="default sticky">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>
|
||||
<td><?= $this->getHtml('ID', '0', '0'); ?>
|
||||
<label for="iSalesClientList-sort-1">
|
||||
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-1">
|
||||
<i class="sort-asc g-icon">expand_less</i>
|
||||
</label>
|
||||
<label for="iSalesClientList-sort-2">
|
||||
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-2">
|
||||
<i class="sort-desc g-icon">expand_more</i>
|
||||
</label>
|
||||
<label>
|
||||
<i class="filter g-icon">filter_alt</i>
|
||||
</label>
|
||||
<td><?= $this->getHtml('Status'); ?>
|
||||
<label for="iSalesClientList-sort-3">
|
||||
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-3">
|
||||
<i class="sort-asc g-icon">expand_less</i>
|
||||
</label>
|
||||
<label for="iSalesClientList-sort-4">
|
||||
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-4">
|
||||
<i class="sort-desc g-icon">expand_more</i>
|
||||
</label>
|
||||
<label>
|
||||
<i class="filter g-icon">filter_alt</i>
|
||||
</label>
|
||||
<td class="wf-100"><?= $this->getHtml('Name'); ?>
|
||||
<label for="iSalesClientList-sort-5">
|
||||
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-5">
|
||||
<i class="sort-asc g-icon">expand_less</i>
|
||||
</label>
|
||||
<label for="iSalesClientList-sort-6">
|
||||
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-6">
|
||||
<i class="sort-desc g-icon">expand_more</i>
|
||||
</label>
|
||||
<label>
|
||||
<i class="filter g-icon">filter_alt</i>
|
||||
</label>
|
||||
<td><?= $this->getHtml('Type'); ?>
|
||||
<label for="iSalesClientList-sort-7">
|
||||
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-7">
|
||||
<i class="sort-asc g-icon">expand_less</i>
|
||||
</label>
|
||||
<label for="iSalesClientList-sort-8">
|
||||
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-8">
|
||||
<i class="sort-desc g-icon">expand_more</i>
|
||||
</label>
|
||||
<label>
|
||||
<i class="filter g-icon">filter_alt</i>
|
||||
</label>
|
||||
<tbody>
|
||||
<?php
|
||||
$count = 0;
|
||||
foreach ($assets as $key => $value) :
|
||||
++$count;
|
||||
$url = UriFactory::build('{/base}/accounting/asset/profile?{?}&id=' . $value->id);
|
||||
?>
|
||||
<tr data-href="<?= $url; ?>">
|
||||
<td>
|
||||
<td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml((string) $value->id); ?></a>
|
||||
<td data-label="<?= $this->getHtml('Status'); ?>"><a href="<?= $url; ?>"><?= $this->getHtml(':status' . $value->status); ?></a>
|
||||
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->name); ?></a>
|
||||
<td data-label="<?= $this->getHtml('Type'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->type->getL11n()); ?></a>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($count === 0) : ?>
|
||||
<tr><td colspan="8" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
227
Theme/Backend/asset-profile.tpl.php
Normal file
227
Theme/Backend/asset-profile.tpl.php
Normal file
|
|
@ -0,0 +1,227 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\ClientManagement
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Modules\AssetManagement\Models\AssetStatus;
|
||||
use Modules\AssetManagement\Models\NullAsset;
|
||||
use Modules\Media\Models\NullMedia;
|
||||
use phpOMS\Uri\UriFactory;
|
||||
|
||||
$countryCodes = \phpOMS\Localization\ISO3166TwoEnum::getConstants();
|
||||
$countries = \phpOMS\Localization\ISO3166NameEnum::getConstants();
|
||||
$assetStatus = AssetStatus::getConstants();
|
||||
|
||||
/**
|
||||
* @var \Modules\AssetManagement\Models\Asset $asset
|
||||
*/
|
||||
$asset = $this->data['asset'] ?? new NullAsset();
|
||||
$files = $asset->files;
|
||||
$assetImage = $this->data['assetImage'] ?? new NullMedia();
|
||||
$assetTypes = $this->data['types'] ?? [];
|
||||
$attributeView = $this->data['attributeView'];
|
||||
|
||||
/**
|
||||
* @var \phpOMS\Views\View $this
|
||||
*/
|
||||
echo $this->data['nav']->render();
|
||||
?>
|
||||
<div class="tabview tab-2">
|
||||
<div class="box">
|
||||
<ul class="tab-links">
|
||||
<li><label for="c-tab-1"><?= $this->getHtml('Profile'); ?></label>
|
||||
<li><label for="c-tab-2"><?= $this->getHtml('Attributes'); ?></label>
|
||||
<li><label for="c-tab-3"><?= $this->getHtml('Files'); ?></label>
|
||||
<li><label for="c-tab-4"><?= $this->getHtml('Notes'); ?></label>
|
||||
<li><label for="c-tab-5"><?= $this->getHtml('Inspections'); ?></label>
|
||||
<li><label for="c-tab-8"><?= $this->getHtml('Costs'); ?></label>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="tab-content">
|
||||
<input type="radio" id="c-tab-1" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>>
|
||||
<div class="tab">
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<section class="portlet">
|
||||
<div class="portlet-head"><?= $this->getHtml('Profile'); ?></div>
|
||||
<div class="portlet-body">
|
||||
<div class="form-group">
|
||||
<label for="iAssetAssetProfileName"><?= $this->getHtml('Name'); ?></label>
|
||||
<input type="text" id="iAssetAssetProfileName" name="name" value="<?= $this->printHtml($asset->name); ?>">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="iAssetDriver"><?= $this->getHtml('Driver'); ?></label>
|
||||
<input type="text" id="iAssetDriver" name="driver" value="" disabled>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="iAssetEin"><?= $this->getHtml('EIN'); ?></label>
|
||||
<input type="text" id="iAssetEin" name="vin" value="<?= $this->printHtml($asset->getAttribute('vin')->value->getValue()); ?>">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="iAssetStatus"><?= $this->getHtml('Status'); ?></label>
|
||||
<select id="iAssetStatus" name="asset_status">
|
||||
<?php foreach ($assetStatus as $status) : ?>
|
||||
<option value="<?= $status; ?>"<?= $status === $asset->status ? ' selected' : ''; ?>><?= $this->getHtml(':status' . $status); ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="iAssetEnd"><?= $this->getHtml('Type'); ?></label>
|
||||
<select id="iAssetEnd" name="asset_type">
|
||||
<?php foreach ($assetTypes as $type) : ?>
|
||||
<option value="<?= $type->id; ?>"<?= $asset->type->id === $type->id ? ' selected' : ''; ?>><?= $this->printHtml($type->getL11n()); ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="iAssetMake"><?= $this->getHtml('Make'); ?></label>
|
||||
<input type="text" id="iAssetMake" name="make" value="<?= $this->printHtml($asset->getAttribute('maker')->value->getValue()); ?>">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="iAssetModel"><?= $this->getHtml('Model'); ?></label>
|
||||
<input type="text" id="iAssetModel" name="asset_model" value="<?= $this->printHtml($asset->getAttribute('asset_model')->value->getValue()); ?>">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="iAssetStart"><?= $this->getHtml('Start'); ?></label>
|
||||
<input type="datetime-local" id="iAssetStart" name="ownership_start" value="<?= $asset->getAttribute('ownership_start')->value->getValue()?->format('Y-m-d\TH:i') ?? $asset->createdAt->format('Y-m-d\TH:i'); ?>">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="iAssetEnd"><?= $this->getHtml('End'); ?></label>
|
||||
<input type="datetime-local" id="iAssetEnd" name="ownership_end" value="<?= $asset->getAttribute('ownership_end')->value->getValue()?->format('Y-m-d\TH:i'); ?>">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="iAssetPrice"><?= $this->getHtml('PurchasePrice'); ?></label>
|
||||
<input type="number" step="0.01" id="iAssetPrice" name="purchase_price" value="<?= $this->printHtml($asset->getAttribute('purchase_price')->value->getValue()); ?>">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="iAssetPrice"><?= $this->getHtml('LeasingFee'); ?></label>
|
||||
<input type="number" step="0.01" id="iAssetPrice" name="leasing_fee" value="<?= $this->printHtml($asset->getAttribute('leasing_fee')->value->getValue()); ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="portlet-foot">
|
||||
<?php if ($asset->id === 0) : ?>
|
||||
<input id="iCreateSubmit" type="Submit" value="<?= $this->getHtml('Create', '0', '0'); ?>">
|
||||
<?php else : ?>
|
||||
<input id="iSaveSubmit" type="Submit" value="<?= $this->getHtml('Save', '0', '0'); ?>">
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<section class="portlet">
|
||||
<div class="portlet-body">
|
||||
<img width="100%" src="<?= $assetImage->id === 0
|
||||
? 'Web/Backend/img/logo_grey.png'
|
||||
: UriFactory::build($assetImage->getPath()); ?>"></a>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="radio" id="c-tab-2" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-2' ? ' checked' : ''; ?>>
|
||||
<div class="tab">
|
||||
<div class="row">
|
||||
<?= $attributeView->render(
|
||||
$asset->attributes,
|
||||
$this->data['attributeTypes'] ?? [],
|
||||
$this->data['units'] ?? [],
|
||||
'{/api}fleet/asset/attribute',
|
||||
$asset->id
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="radio" id="c-tab-3" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-3' ? ' checked' : ''; ?>>
|
||||
<div class="tab col-simple">
|
||||
<?= $this->data['media-upload']->render('asset-file', 'files', '', $asset->files); ?>
|
||||
</div>
|
||||
|
||||
<input type="radio" id="c-tab-4" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-4' ? ' checked' : ''; ?>>
|
||||
<div class="tab">
|
||||
<?= $this->data['asset-notes']->render('asset-notes', '', $asset->notes); ?>
|
||||
</div>
|
||||
|
||||
<input type="radio" id="c-tab-5" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-5' ? ' checked' : ''; ?>>
|
||||
<div class="tab">
|
||||
<div class="row">
|
||||
<a class="button" href="<?= UriFactory::build('{/base}/fleet/inspection/create?asset=' . $asset->id); ?>"><?= $this->getHtml('Create', '0', '0'); ?></a>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<section class="portlet">
|
||||
<div class="portlet-head"><?= $this->getHtml('Upcoming'); ?></div>
|
||||
<table id="upcomingInspections" class="default sticky">
|
||||
<thead>
|
||||
<tr>
|
||||
<td><?= $this->getHtml('Date'); ?>
|
||||
<td class="wf-100"><?= $this->getHtml('Type'); ?>
|
||||
<td><?= $this->getHtml('Responsible'); ?>
|
||||
<tbody>
|
||||
<?php foreach ($this->data['inspections'] as $inspection) :
|
||||
// @todo handle old inspections in the past? maybe use a status?!
|
||||
if ($inspection->next === null) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td><?= $inspection->next->format('Y-m-d H:i'); ?>
|
||||
<td><?= $this->printHtml($inspection->type->getL11n()); ?>
|
||||
<td>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<section class="portlet">
|
||||
<div class="portlet-head"><?= $this->getHtml('History'); ?></div>
|
||||
<table id="historicInspections" class="default sticky">
|
||||
<thead>
|
||||
<tr>
|
||||
<td><?= $this->getHtml('Date'); ?>
|
||||
<td class="wf-100"><?= $this->getHtml('Type'); ?>
|
||||
<td><?= $this->getHtml('Responsible'); ?>
|
||||
<tbody>
|
||||
<?php foreach ($this->data['inspections'] as $inspection) : ?>
|
||||
<tr>
|
||||
<td><?= $inspection->date->format('Y-m-d H:i'); ?>
|
||||
<td><?= $this->printHtml($inspection->type->getL11n()); ?>
|
||||
<td>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="radio" id="c-tab-8" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-8' ? ' checked' : ''; ?>>
|
||||
<div class="tab">
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
71
Theme/Backend/attribute-type-list.tpl.php
Normal file
71
Theme/Backend/attribute-type-list.tpl.php
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\ItemManagement
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use phpOMS\Uri\UriFactory;
|
||||
|
||||
/** @var \phpOMS\Views\View $this */
|
||||
$attributes = $this->data['attributes'];
|
||||
|
||||
echo $this->data['nav']->render(); ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<section class="portlet">
|
||||
<div class="portlet-head"><?= $this->getHtml('AttributeTypes', 'Attribute', 'Backend'); ?><i class="g-icon download btn end-xs">download</i></div>
|
||||
<div class="slider">
|
||||
<table id="iAttributeTypeList" class="default sticky">
|
||||
<thead>
|
||||
<tr>
|
||||
<td><?= $this->getHtml('ID', '0', '0'); ?>
|
||||
<label for="iAttributeTypeList-sort-1">
|
||||
<input type="radio" name="iAttributeTypeList-sort" id="iAttributeTypeList-sort-1">
|
||||
<i class="sort-asc g-icon">expand_less</i>
|
||||
</label>
|
||||
<label for="iAttributeTypeList-sort-2">
|
||||
<input type="radio" name="iAttributeTypeList-sort" id="iAttributeTypeList-sort-2">
|
||||
<i class="sort-desc g-icon">expand_more</i>
|
||||
</label>
|
||||
<label>
|
||||
<i class="filter g-icon">filter_alt</i>
|
||||
</label>
|
||||
<td class="wf-100"><?= $this->getHtml('Name'); ?>
|
||||
<label for="iAttributeTypeList-sort-2">
|
||||
<input type="radio" name="iAttributeTypeList-sort" id="iAttributeTypeList-sort-2">
|
||||
<i class="sort-asc g-icon">expand_less</i>
|
||||
</label>
|
||||
<label for="iAttributeTypeList-sort-3">
|
||||
<input type="radio" name="iAttributeTypeList-sort" id="iAttributeTypeList-sort-3">
|
||||
<i class="sort-desc g-icon">expand_more</i>
|
||||
</label>
|
||||
<label>
|
||||
<i class="filter g-icon">filter_alt</i>
|
||||
</label>
|
||||
<tbody>
|
||||
<?php
|
||||
$count = 0;
|
||||
foreach ($attributes as $key => $value) : ++$count;
|
||||
$url = UriFactory::build('{/base}/accounting/asset/attribute/type?{?}&id=' . $value->id);
|
||||
?>
|
||||
<tr data-href="<?= $url; ?>">
|
||||
<td><a href="<?= $url; ?>"><?= $value->id; ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->getL11n()); ?></a>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($count === 0) : ?>
|
||||
<tr><td colspan="2" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -14,17 +14,18 @@
|
|||
"name": "Jingga",
|
||||
"website": "jingga.app"
|
||||
},
|
||||
"description": "Budget Management module.",
|
||||
"directory": "AssetManagement",
|
||||
"dependencies": {
|
||||
"Admin": "*",
|
||||
"Media": "*",
|
||||
"Finance": "*",
|
||||
"Controlling": "*",
|
||||
"EquipmentManagement": "*"
|
||||
"EquipmentManagement": "*",
|
||||
"Editor": "1.0.0"
|
||||
},
|
||||
"providing": {
|
||||
"Navigation": "*"
|
||||
"Navigation": "*",
|
||||
"Media": "*"
|
||||
},
|
||||
"load": [
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user