Merge pull request #1 from Karaka-Management/develop

Merge
This commit is contained in:
Dennis Eichhorn 2023-09-30 02:02:32 +02:00 committed by GitHub
commit e38cc53fdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
73 changed files with 12001 additions and 1 deletions

35
.github/dev_bug_report.md vendored Executable file
View File

@ -0,0 +1,35 @@
---
name: Dev Bug Report
about: Create a report to help us improve
title: ''
labels: stat_backlog, type_bug
assignees: ''
---
# Bug Description
A clear and concise description of what the bug is.
# How to Reproduce
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
## Minimal Code Example
```
// your code ...
```
# Expected Behavior
A clear and concise description of what you expected to happen.
# Screenshots
If applicable, add screenshots to help explain your problem.
# Additional Information
Add any other context about the problem here.

18
.github/dev_feature_request.md vendored Executable file
View File

@ -0,0 +1,18 @@
---
name: Dev Feature Request
about: Suggest an idea for this project
title: ''
labels: stat_backlog, type_feature
assignees: ''
---
# What is the feature you request
* A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
* A clear and concise description of what you want to happen.
# Alternatives
A clear and concise description of any alternative solutions or features you've considered.
# Additional Information
Add any other context or screenshots about the feature request here.

40
.github/user_bug_report.md vendored Executable file
View File

@ -0,0 +1,40 @@
---
name: User Bug Report
about: Create a report to help us improve
title: ''
labels: stat_backlog, type_bug
assignees: ''
---
# Bug Description
A clear and concise description of what the bug is.
# How to Reproduce
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
# Expected Behavior
A clear and concise description of what you expected to happen.
# Screenshots
If applicable, add screenshots to help explain your problem.
# System Information
- System: [e.g. PC or iPhone11, ...]
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- KarakaVersion [e.g. 22]
# Additional Information
Add any other context about the problem here.

21
.github/user_feature_request.md vendored Executable file
View File

@ -0,0 +1,21 @@
---
name: User Feature Request
about: Suggest an idea for this project
title: ''
labels: stat_backlog, type_feature
assignees: ''
---
# What is the feature you request
* A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
* A clear and concise description of what you want to happen.
# Alternatives
A clear and concise description of any alternative solutions or features you've considered.
# Additional Information
Add any other context or screenshots about the feature request here.

13
.github/workflows/greetings.yml vendored Executable file
View File

@ -0,0 +1,13 @@
name: Greetings
on: [pull_request, issues]
jobs:
greeting:
runs-on: ubuntu-latest
steps:
- uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: 'Thank you for createing this issue. We will check it as soon as possible.'
pr-message: 'Thank you for your pull request. We will check it as soon as possible.'

10
.github/workflows/image.yml vendored Executable file
View File

@ -0,0 +1,10 @@
name: Image optimization
on: [push, pull_request]
jobs:
general_image_workflow:
uses: Karaka-Management/Karaka/.github/workflows/image.yml@develop
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_PAT: ${{ secrets.GH_PAT }}

20
.github/workflows/main.yml vendored Executable file
View File

@ -0,0 +1,20 @@
name: CI
on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop
schedule:
- cron: '0 0 1,15 * *'
jobs:
general_module_workflow:
uses: Karaka-Management/Karaka/.github/workflows/php_template.yml@develop
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_PAT: ${{ secrets.GH_PAT }}

15
.gitignore vendored Executable file
View File

@ -0,0 +1,15 @@
Build
*.cache
.directory
Vagrantfile
vendor
bower_components
node_modules
*.log
.vagrant
.vscode
.sass-cache
cache
Cache
Libraries
.idea

View 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": "EquipmentManagement",
"virtualPath": "/Modules",
"user": 1
},
{
"type": "collection",
"create_directory": true,
"name": "Equipment",
"virtualPath": "/Modules/EquipmentManagement",
"user": 1
}
]

43
Admin/Install/Media.php Executable file
View File

@ -0,0 +1,43 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement\Admin\Install
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Admin\Install;
use phpOMS\Application\ApplicationAbstract;
/**
* Media class.
*
* @package Modules\EquipmentManagement\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']);
}
}

View File

@ -0,0 +1,156 @@
[
{
"id": 1008401001,
"pid": "/",
"type": 2,
"subtype": 0,
"name": "EquipmentManagement",
"uri": null,
"target": "self",
"icon": "fa fa-wrench",
"order": 80,
"from": "EquipmentManagement",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 0,
"children": [
{
"id": 1008402001,
"pid": "/",
"type": 2,
"subtype": 1,
"name": "Equipments",
"uri": "{/base}/equipment/list",
"target": "self",
"icon": null,
"order": 1,
"from": "EquipmentManagement",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1008401001,
"children": [
{
"id": 1008402101,
"pid": "/equipment",
"type": 3,
"subtype": 1,
"name": "List",
"uri": "{/base}/equipment/list",
"target": "self",
"icon": null,
"order": 1,
"from": "EquipmentManagement",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1008402001,
"children": []
},
{
"id": 1008402201,
"pid": "/equipment",
"type": 3,
"subtype": 1,
"name": "Create",
"uri": "{/base}/equipment/create?{?}",
"target": "self",
"icon": null,
"order": 1,
"from": "EquipmentManagement",
"permission": { "permission": 4, "category": null, "element": null },
"parent": 1008402001,
"children": []
}
]
},
{
"id": 1008404001,
"pid": "/",
"type": 2,
"subtype": 1,
"name": "Inspections",
"uri": "{/base}/equipment/inspection/list",
"target": "self",
"icon": null,
"order": 1,
"from": "EquipmentManagement",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1008401001,
"children": [
{
"id": 1008404101,
"pid": "/equipment/inspection",
"type": 3,
"subtype": 1,
"name": "List",
"uri": "{/base}/equipment/inspection/list",
"target": "self",
"icon": null,
"order": 1,
"from": "EquipmentManagement",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1008404001,
"children": []
},
{
"id": 1008404201,
"pid": "/equipment/inspection",
"type": 3,
"subtype": 1,
"name": "EquipmentInspectionTypes",
"uri": "{/base}/equipment/inspection/type/list?{?}",
"target": "self",
"icon": null,
"order": 5,
"from": "EquipmentManagement",
"permission": { "permission": 4, "category": null, "element": null },
"parent": 1008404001,
"children": []
}
]
},
{
"id": 1008405001,
"pid": "/",
"type": 2,
"subtype": 1,
"name": "EquipmentAttributes",
"uri": "{/base}/equipment/attribute/type/list?{?}",
"target": "self",
"icon": null,
"order": 5,
"from": "EquipmentManagement",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1008401001,
"children": [
{
"id": 1008405101,
"pid": "/equipment/attribute",
"type": 3,
"subtype": 1,
"name": "Types",
"uri": "{/base}/equipment/attribute/type/list?{?}",
"target": "self",
"icon": null,
"order": 15,
"from": "EquipmentManagement",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1008405001,
"children": []
},
{
"id": 1008405201,
"pid": "/equipment/attribute",
"type": 3,
"subtype": 1,
"name": "Values",
"uri": "{/base}/equipment/attribute/value/list?{?}",
"target": "self",
"icon": null,
"order": 15,
"from": "EquipmentManagement",
"permission": { "permission": 2, "category": null, "element": null },
"parent": 1008405001,
"children": []
}
]
}
]
}
]

43
Admin/Install/Navigation.php Executable file
View File

@ -0,0 +1,43 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement\Admin\Install
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Admin\Install;
use phpOMS\Application\ApplicationAbstract;
/**
* Navigation class.
*
* @package Modules\EquipmentManagement\Admin\Install
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
class Navigation
{
/**
* Install navigation 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\Navigation\Admin\Installer::installExternal($app, ['path' => __DIR__ . '/Navigation.install.json']);
}
}

22
Admin/Install/attributes.json Executable file
View File

@ -0,0 +1,22 @@
[
{
"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
}
]
}
]

526
Admin/Install/db.json Executable file
View File

@ -0,0 +1,526 @@
{
"equipmgmt_equipment_type": {
"name": "equipmgmt_equipment_type",
"fields": {
"equipmgmt_equipment_type_id": {
"name": "equipmgmt_equipment_type_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"equipmgmt_equipment_type_name": {
"name": "equipmgmt_equipment_type_name",
"type": "VARCHAR(255)",
"null": false
}
}
},
"equipmgmt_equipment_type_l11n": {
"name": "equipmgmt_equipment_type_l11n",
"fields": {
"equipmgmt_equipment_type_l11n_id": {
"name": "equipmgmt_equipment_type_l11n_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"equipmgmt_equipment_type_l11n_title": {
"name": "equipmgmt_equipment_type_l11n_title",
"type": "VARCHAR(255)",
"null": false
},
"equipmgmt_equipment_type_l11n_type": {
"name": "equipmgmt_equipment_type_l11n_type",
"type": "INT(11)",
"null": false,
"foreignTable": "equipmgmt_equipment_type",
"foreignKey": "equipmgmt_equipment_type_id"
},
"equipmgmt_equipment_type_l11n_lang": {
"name": "equipmgmt_equipment_type_l11n_lang",
"type": "VARCHAR(2)",
"null": false,
"foreignTable": "language",
"foreignKey": "language_639_1"
}
}
},
"equipmgmt_inspection_type": {
"name": "equipmgmt_inspection_type",
"fields": {
"equipmgmt_inspection_type_id": {
"name": "equipmgmt_inspection_type_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"equipmgmt_inspection_type_name": {
"name": "equipmgmt_inspection_type_name",
"type": "VARCHAR(255)",
"null": false
}
}
},
"equipmgmt_inspection_type_l11n": {
"name": "equipmgmt_inspection_type_l11n",
"fields": {
"equipmgmt_inspection_type_l11n_id": {
"name": "equipmgmt_inspection_type_l11n_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"equipmgmt_inspection_type_l11n_title": {
"name": "equipmgmt_inspection_type_l11n_title",
"type": "VARCHAR(255)",
"null": false
},
"equipmgmt_inspection_type_l11n_type": {
"name": "equipmgmt_inspection_type_l11n_type",
"type": "INT(11)",
"null": false,
"foreignTable": "equipmgmt_inspection_type",
"foreignKey": "equipmgmt_inspection_type_id"
},
"equipmgmt_inspection_type_l11n_lang": {
"name": "equipmgmt_inspection_type_l11n_lang",
"type": "VARCHAR(2)",
"null": false,
"foreignTable": "language",
"foreignKey": "language_639_1"
}
}
},
"equipmgmt_equipment": {
"name": "equipmgmt_equipment",
"fields": {
"equipmgmt_equipment_id": {
"name": "equipmgmt_equipment_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"equipmgmt_equipment_name": {
"name": "equipmgmt_equipment_name",
"type": "VARCHAR(255)",
"null": false
},
"equipmgmt_equipment_status": {
"name": "equipmgmt_equipment_status",
"type": "TINYINT",
"null": false
},
"equipmgmt_equipment_type": {
"name": "equipmgmt_equipment_type",
"type": "INT",
"foreignTable": "equipmgmt_equipment_type",
"foreignKey": "equipmgmt_equipment_type_id"
},
"equipmgmt_equipment_info": {
"name": "equipmgmt_equipment_info",
"type": "TEXT",
"null": false
},
"equipmgmt_equipment_created_at": {
"name": "equipmgmt_equipment_created_at",
"type": "DATETIME",
"null": false
},
"equipmgmt_equipment_responsible": {
"name": "equipmgmt_equipment_responsible",
"type": "INT",
"null": true,
"default": true,
"foreignTable": "account",
"foreignKey": "account_id"
},
"equipmgmt_equipment_unit": {
"name": "equipmgmt_equipment_unit",
"type": "INT",
"default": null,
"null": true,
"foreignTable": "unit",
"foreignKey": "unit_id"
}
}
},
"equipmgmt_equipment_inspection": {
"name": "equipmgmt_equipment_inspection",
"fields": {
"equipmgmt_equipment_inspection_id": {
"name": "equipmgmt_equipment_inspection_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"equipmgmt_equipment_inspection_description": {
"name": "equipmgmt_equipment_inspection_description",
"type": "TEXT",
"null": false
},
"equipmgmt_equipment_inspection_status": {
"name": "equipmgmt_equipment_inspection_status",
"type": "TINYINT(1)",
"null": false
},
"equipmgmt_equipment_inspection_interval": {
"name": "equipmgmt_equipment_inspection_interval",
"type": "INT",
"null": false
},
"equipmgmt_equipment_inspection_next": {
"name": "equipmgmt_equipment_inspection_next",
"type": "DATETIME",
"null": true,
"default": null
},
"equipmgmt_equipment_inspection_date": {
"name": "equipmgmt_equipment_inspection_date",
"type": "DATETIME",
"null": true,
"default": null
},
"equipmgmt_equipment_inspection_type": {
"name": "equipmgmt_equipment_inspection_type",
"type": "INT",
"null": false,
"foreignTable": "equipmgmt_inspection_type",
"foreignKey": "equipmgmt_inspection_type_id"
},
"equipmgmt_equipment_inspection_equipment": {
"name": "equipmgmt_equipment_inspection_equipment",
"type": "INT",
"null": false,
"foreignTable": "equipmgmt_equipment",
"foreignKey": "equipmgmt_equipment_id"
}
}
},
"equipmgmt_equipment_usage": {
"name": "equipmgmt_equipment_usage",
"fields": {
"equipmgmt_equipment_usage_id": {
"name": "equipmgmt_equipment_usage_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"equipmgmt_equipment_usage_type": {
"name": "equipmgmt_equipment_usage_type",
"type": "INT",
"null": false
},
"equipmgmt_equipment_usage_account": {
"name": "equipmgmt_equipment_usage_account",
"type": "INT",
"null": false,
"foreignTable": "account",
"foreignKey": "account_id"
},
"equipmgmt_equipment_usage_start": {
"name": "equipmgmt_equipment_usage_start",
"type": "DATETIME",
"null": false
},
"equipmgmt_equipment_usage_end": {
"name": "equipmgmt_equipment_usage_end",
"type": "DATETIME",
"null": true,
"default": null
},
"equipmgmt_equipment_usage_distance": {
"name": "equipmgmt_equipment_usage_distance",
"type": "INT",
"null": false
}
}
},
"equipmgmt_attr_type": {
"name": "equipmgmt_attr_type",
"fields": {
"equipmgmt_attr_type_id": {
"name": "equipmgmt_attr_type_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"equipmgmt_attr_type_name": {
"name": "equipmgmt_attr_type_name",
"type": "VARCHAR(255)",
"null": false,
"unique": true
},
"equipmgmt_attr_type_datatype": {
"name": "equipmgmt_attr_type_datatype",
"type": "INT(11)",
"null": false
},
"equipmgmt_attr_type_fields": {
"name": "equipmgmt_attr_type_fields",
"type": "INT(11)",
"null": false
},
"equipmgmt_attr_type_custom": {
"name": "equipmgmt_attr_type_custom",
"type": "TINYINT(1)",
"null": false
},
"equipmgmt_attr_type_required": {
"description": "Every equipment must have this attribute type if set to true.",
"name": "equipmgmt_attr_type_required",
"type": "TINYINT(1)",
"null": false
},
"equipmgmt_attr_type_pattern": {
"description": "This is a regex validation pattern.",
"name": "equipmgmt_attr_type_pattern",
"type": "VARCHAR(255)",
"null": false
}
}
},
"equipmgmt_attr_type_l11n": {
"name": "equipmgmt_attr_type_l11n",
"fields": {
"equipmgmt_attr_type_l11n_id": {
"name": "equipmgmt_attr_type_l11n_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"equipmgmt_attr_type_l11n_title": {
"name": "equipmgmt_attr_type_l11n_title",
"type": "VARCHAR(255)",
"null": false
},
"equipmgmt_attr_type_l11n_type": {
"name": "equipmgmt_attr_type_l11n_type",
"type": "INT(11)",
"null": false,
"foreignTable": "equipmgmt_attr_type",
"foreignKey": "equipmgmt_attr_type_id"
},
"equipmgmt_attr_type_l11n_lang": {
"name": "equipmgmt_attr_type_l11n_lang",
"type": "VARCHAR(2)",
"null": false,
"foreignTable": "language",
"foreignKey": "language_639_1"
}
}
},
"equipmgmt_attr_value": {
"name": "equipmgmt_attr_value",
"fields": {
"equipmgmt_attr_value_id": {
"name": "equipmgmt_attr_value_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"equipmgmt_attr_value_default": {
"name": "equipmgmt_attr_value_default",
"type": "TINYINT(1)",
"null": false
},
"equipmgmt_attr_value_valueStr": {
"name": "equipmgmt_attr_value_valueStr",
"type": "VARCHAR(255)",
"null": true,
"default": null
},
"equipmgmt_attr_value_valueInt": {
"name": "equipmgmt_attr_value_valueInt",
"type": "INT(11)",
"null": true,
"default": null
},
"equipmgmt_attr_value_valueDec": {
"name": "equipmgmt_attr_value_valueDec",
"type": "DECIMAL(19,5)",
"null": true,
"default": null
},
"equipmgmt_attr_value_valueDat": {
"name": "equipmgmt_attr_value_valueDat",
"type": "DATETIME",
"null": true,
"default": null
},
"equipmgmt_attr_value_unit": {
"name": "equipmgmt_attr_value_unit",
"type": "VARCHAR(255)",
"null": false
},
"equipmgmt_attr_value_deptype": {
"name": "equipmgmt_attr_value_deptype",
"type": "INT(11)",
"null": true,
"default": null,
"foreignTable": "equipmgmt_attr_type",
"foreignKey": "equipmgmt_attr_type_id"
},
"equipmgmt_attr_value_depvalue": {
"name": "equipmgmt_attr_value_depvalue",
"type": "INT(11)",
"null": true,
"default": null,
"foreignTable": "equipmgmt_attr_value",
"foreignKey": "equipmgmt_attr_value_id"
}
}
},
"equipmgmt_attr_value_l11n": {
"name": "equipmgmt_attr_value_l11n",
"fields": {
"equipmgmt_attr_value_l11n_id": {
"name": "equipmgmt_attr_value_l11n_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"equipmgmt_attr_value_l11n_title": {
"name": "equipmgmt_attr_value_l11n_title",
"type": "VARCHAR(255)",
"null": false
},
"equipmgmt_attr_value_l11n_value": {
"name": "equipmgmt_attr_value_l11n_value",
"type": "INT(11)",
"null": false,
"foreignTable": "equipmgmt_attr_value",
"foreignKey": "equipmgmt_attr_value_id"
},
"equipmgmt_attr_value_l11n_lang": {
"name": "equipmgmt_attr_value_l11n_lang",
"type": "VARCHAR(2)",
"null": false,
"foreignTable": "language",
"foreignKey": "language_639_1"
}
}
},
"equipmgmt_equipment_attr_default": {
"name": "equipmgmt_equipment_attr_default",
"fields": {
"equipmgmt_equipment_attr_default_id": {
"name": "equipmgmt_equipment_attr_default_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"equipmgmt_equipment_attr_default_type": {
"name": "equipmgmt_equipment_attr_default_type",
"type": "INT(11)",
"null": false,
"foreignTable": "equipmgmt_attr_type",
"foreignKey": "equipmgmt_attr_type_id"
},
"equipmgmt_equipment_attr_default_value": {
"name": "equipmgmt_equipment_attr_default_value",
"type": "INT(11)",
"null": false,
"foreignTable": "equipmgmt_attr_value",
"foreignKey": "equipmgmt_attr_value_id"
}
}
},
"equipmgmt_equipment_attr": {
"name": "equipmgmt_equipment_attr",
"fields": {
"equipmgmt_equipment_attr_id": {
"name": "equipmgmt_equipment_attr_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"equipmgmt_equipment_attr_equipment": {
"name": "equipmgmt_equipment_attr_equipment",
"type": "INT(11)",
"null": false,
"foreignTable": "equipmgmt_equipment",
"foreignKey": "equipmgmt_equipment_id"
},
"equipmgmt_equipment_attr_type": {
"name": "equipmgmt_equipment_attr_type",
"type": "INT(11)",
"null": false,
"foreignTable": "equipmgmt_attr_type",
"foreignKey": "equipmgmt_attr_type_id"
},
"equipmgmt_equipment_attr_value": {
"name": "equipmgmt_equipment_attr_value",
"type": "INT(11)",
"null": true,
"default": null,
"foreignTable": "equipmgmt_attr_value",
"foreignKey": "equipmgmt_attr_value_id"
}
}
},
"equipmgmt_equipment_media": {
"name": "equipmgmt_equipment_media",
"fields": {
"equipmgmt_equipment_media_id": {
"name": "equipmgmt_equipment_media_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"equipmgmt_equipment_media_equipment": {
"name": "equipmgmt_equipment_media_equipment",
"type": "INT",
"null": false,
"foreignTable": "equipmgmt_equipment",
"foreignKey": "equipmgmt_equipment_id"
},
"equipmgmt_equipment_media_media": {
"name": "equipmgmt_equipment_media_media",
"type": "INT",
"null": false,
"foreignTable": "media",
"foreignKey": "media_id"
}
}
},
"equipmgmt_equipment_note": {
"name": "equipmgmt_equipment_note",
"fields": {
"equipmgmt_equipment_note_id": {
"name": "equipmgmt_equipment_note_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"equipmgmt_equipment_note_equipment": {
"name": "equipmgmt_equipment_note_equipment",
"type": "INT",
"null": false,
"foreignTable": "equipmgmt_equipment",
"foreignKey": "equipmgmt_equipment_id"
},
"equipmgmt_equipment_note_doc": {
"name": "equipmgmt_equipment_note_doc",
"type": "INT",
"null": false,
"foreignTable": "editor_doc",
"foreignKey": "editor_doc_id"
}
}
}
}

View File

@ -0,0 +1,30 @@
[
{
"name": "scale",
"l11n": {
"en": "Scale",
"de": "Waage"
}
},
{
"name": "ladder",
"l11n": {
"en": "Ladder",
"de": "Leiter"
}
},
{
"name": "drill",
"l11n": {
"en": "Drill",
"de": "Bohrer"
}
},
{
"name": "saw",
"l11n": {
"en": "Saw",
"de": "Säge"
}
}
]

View File

@ -0,0 +1,9 @@
[
{
"name": "tuv",
"l11n": {
"en": "TUV",
"de": "TUV"
}
}
]

342
Admin/Installer.php Executable file
View File

@ -0,0 +1,342 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement\Admin
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\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.
*
* @package Modules\EquipmentManagement\Admin
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
final class Installer extends InstallerAbstract
{
/**
* Path of the file
*
* @var string
* @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);
/* Equipment types */
$fileContent = \file_get_contents(__DIR__ . '/Install/equipmenttype.json');
if ($fileContent === false) {
return;
}
/** @var array $types */
$types = \json_decode($fileContent, true);
$equipmentTypes = self::createEquipmentTypes($app, $types);
/* Inspection types */
$fileContent = \file_get_contents(__DIR__ . '/Install/inspectiontype.json');
if ($fileContent === false) {
return;
}
/** @var array $types */
$types = \json_decode($fileContent, true);
$inspectionTypes = self::createInspectionTypes($app, $types);
}
/**
* Install equipment type
*
* @param ApplicationAbstract $app Application
* @param array $types Attribute definition
*
* @return array
*
* @since 1.0.0
*/
private static function createEquipmentTypes(ApplicationAbstract $app, array $types) : array
{
/** @var array<string, array> $equipmentTypes */
$equipmentTypes = [];
/** @var \Modules\EquipmentManagement\Controller\ApiEquipmentTypeController $module */
$module = $app->moduleManager->getModuleInstance('EquipmentManagement', 'ApiEquipmentType');
/** @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->apiEquipmentTypeCreate($request, $response);
$responseData = $response->get('');
if (!\is_array($responseData)) {
continue;
}
$equipmentTypes[$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', $equipmentTypes[$type['name']]['id']);
$module->apiEquipmentTypeL11nCreate($request, $response);
}
}
return $equipmentTypes;
}
/**
* 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\EquipmentManagement\Controller\ApiInspectionTypeController $module */
$module = $app->moduleManager->getModuleInstance('EquipmentManagement', '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->get('');
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\EquipmentManagement\Controller\ApiEquipmentAttributeController $module */
$module = $app->moduleManager->getModuleInstance('EquipmentManagement', 'ApiEquipmentAttribute');
/** @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->apiEquipmentAttributeTypeCreate($request, $response);
$responseData = $response->get('');
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->apiEquipmentAttributeTypeL11nCreate($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\EquipmentManagement\Controller\ApiEquipmentAttributeController $module */
$module = $app->moduleManager->getModuleInstance('EquipmentManagement', 'ApiEquipmentAttribute');
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->apiEquipmentAttributeValueCreate($request, $response);
$responseData = $response->get('');
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->apiEquipmentAttributeValueL11nCreate($request, $response);
}
}
}
return $itemAttrValue;
}
}

74
Admin/Routes/Web/Api.php Executable file
View File

@ -0,0 +1,74 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
use Modules\EquipmentManagement\Controller\Controller;
use Modules\EquipmentManagement\Models\PermissionCategory;
use phpOMS\Account\PermissionType;
use phpOMS\Router\RouteVerb;
return [
'^.*/equipment/find.*$' => [
[
'dest' => '\Modules\EquipmentManagement\Controller\ApiEquipmentController:apiEquipmentFind',
'verb' => RouteVerb::GET,
'permission' => [
'module' => Controller::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::EQUIPMENT,
],
],
],
'^.*/equipment/attribute.*$' => [
[
'dest' => '\Modules\EquipmentManagement\Controller\ApiEquipmentAttributeController:apiEquipmentAttributeCreate',
'verb' => RouteVerb::PUT,
'permission' => [
'module' => Controller::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::EQUIPMENT,
],
],
[
'dest' => '\Modules\EquipmentManagement\Controller\ApiEquipmentAttributeController:apiEquipmentAttributeUpdate',
'verb' => RouteVerb::SET,
'permission' => [
'module' => Controller::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::EQUIPMENT,
],
],
],
'^.*/equipment/note.*$' => [
[
'dest' => '\Modules\EquipmentManagement\Controller\ApiEquipmentController:apiNoteCreate',
'verb' => RouteVerb::PUT,
'permission' => [
'module' => Controller::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::EQUIPMENT,
],
],
[
'dest' => '\Modules\EquipmentManagement\Controller\ApiEquipmentController:apiNoteUpdate',
'verb' => RouteVerb::SET,
'permission' => [
'module' => Controller::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::EQUIPMENT,
],
],
],
];

111
Admin/Routes/Web/Backend.php Executable file
View File

@ -0,0 +1,111 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
use Modules\EquipmentManagement\Controller\BackendController;
use Modules\EquipmentManagement\Models\PermissionCategory;
use phpOMS\Account\PermissionType;
use phpOMS\Router\RouteVerb;
return [
'^.*/equipment/attribute/type/list.*$' => [
[
'dest' => '\Modules\EquipmentManagement\Controller\BackendController:viewEquipmentManagementAttributeTypeList',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::EQUIPMENT,
],
],
],
'^.*/equipment/attribute/type\?.*$' => [
[
'dest' => '\Modules\EquipmentManagement\Controller\BackendController:viewEquipmentManagementAttributeType',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::EQUIPMENT,
],
],
],
'^.*/equipment/list.*$' => [
[
'dest' => '\Modules\EquipmentManagement\Controller\BackendController:viewEquipmentManagementEquipmentList',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::EQUIPMENT,
],
],
],
'^.*/equipment/create.*$' => [
[
'dest' => '\Modules\EquipmentManagement\Controller\BackendController:viewEquipmentManagementEquipmentCreate',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::CREATE,
'state' => PermissionCategory::EQUIPMENT,
],
],
],
'^.*/equipment/profile.*$' => [
[
'dest' => '\Modules\EquipmentManagement\Controller\BackendController:viewEquipmentManagementEquipmentProfile',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::EQUIPMENT,
],
],
],
'^.*/equipment/inspection/list.*$' => [
[
'dest' => '\Modules\EquipmentManagement\Controller\BackendController:viewEquipmentManagementEquipmentList',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::EQUIPMENT,
],
],
],
'^.*/equipment/inspection/create.*$' => [
[
'dest' => '\Modules\EquipmentManagement\Controller\BackendController:viewEquipmentManagementEquipmentCreate',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::CREATE,
'state' => PermissionCategory::EQUIPMENT,
],
],
],
'^.*/equipment/inspection/profile.*$' => [
[
'dest' => '\Modules\EquipmentManagement\Controller\BackendController:viewEquipmentManagementEquipmentProfile',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::EQUIPMENT,
],
],
],
];

36
Admin/Status.php Executable file
View File

@ -0,0 +1,36 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement\Admin
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Admin;
use phpOMS\Module\StatusAbstract;
/**
* Status class.
*
* @package Modules\EquipmentManagement\Admin
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
final class Status extends StatusAbstract
{
/**
* Path of the file
*
* @var string
* @since 1.0.0
*/
public const PATH = __DIR__;
}

36
Admin/Uninstaller.php Executable file
View File

@ -0,0 +1,36 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement\Admin
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Admin;
use phpOMS\Module\UninstallerAbstract;
/**
* Uninstaller class.
*
* @package Modules\EquipmentManagement\Admin
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
final class Uninstaller extends UninstallerAbstract
{
/**
* Path of the file
*
* @var string
* @since 1.0.0
*/
public const PATH = __DIR__;
}

36
Admin/Updater.php Executable file
View File

@ -0,0 +1,36 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement\Admin
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Admin;
use phpOMS\Module\UpdaterAbstract;
/**
* Updater class.
*
* @package Modules\EquipmentManagement\Admin
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
final class Updater extends UpdaterAbstract
{
/**
* Path of the file
*
* @var string
* @since 1.0.0
*/
public const PATH = __DIR__;
}

0
Controller.js Executable file
View File

View File

@ -0,0 +1,523 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Controller;
use Modules\Attribute\Models\Attribute;
use Modules\Attribute\Models\AttributeType;
use Modules\Attribute\Models\AttributeValue;
use Modules\EquipmentManagement\Models\Attribute\EquipmentAttributeMapper;
use Modules\EquipmentManagement\Models\Attribute\EquipmentAttributeTypeL11nMapper;
use Modules\EquipmentManagement\Models\Attribute\EquipmentAttributeTypeMapper;
use Modules\EquipmentManagement\Models\Attribute\EquipmentAttributeValueL11nMapper;
use Modules\EquipmentManagement\Models\Attribute\EquipmentAttributeValueMapper;
use phpOMS\Localization\BaseStringL11n;
use phpOMS\Message\Http\RequestStatusCode;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
/**
* EquipmentManagement class.
*
* @package Modules\EquipmentManagement
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
final class ApiEquipmentAttributeController 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 apiEquipmentAttributeCreate(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;
}
$attribute = $this->createAttributeFromRequest($request);
$this->createModel($request->header->account, $attribute, EquipmentAttributeMapper::class, 'attribute', $request->getOrigin());
$this->createStandardCreateResponse($request, $response, $attribute);
}
/**
* Api method to create equipment attribute l11n
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiEquipmentAttributeTypeL11nCreate(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, EquipmentAttributeTypeL11nMapper::class, 'attr_type_l11n', $request->getOrigin());
$this->createStandardCreateResponse($request, $response, $attrL11n);
}
/**
* Api method to create equipment attribute type
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiEquipmentAttributeTypeCreate(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, EquipmentAttributeTypeMapper::class, 'attr_type', $request->getOrigin());
$this->createStandardCreateResponse($request, $response, $attrType);
}
/**
* Api method to create equipment attribute value
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiEquipmentAttributeValueCreate(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 = EquipmentAttributeTypeMapper::get()
->where('id', $request->getDataInt('type') ?? 0)
->execute();
$attrValue = $this->createAttributeValueFromRequest($request, $type);
$this->createModel($request->header->account, $attrValue, EquipmentAttributeValueMapper::class, 'attr_value', $request->getOrigin());
if ($attrValue->isDefault) {
$this->createModelRelation(
$request->header->account,
(int) $request->getData('type'),
$attrValue->id,
EquipmentAttributeTypeMapper::class, 'defaults', '', $request->getOrigin()
);
}
$this->createStandardCreateResponse($request, $response, $attrValue);
}
/**
* Api method to create equipment attribute l11n
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiEquipmentAttributeValueL11nCreate(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, EquipmentAttributeValueL11nMapper::class, 'attr_value_l11n', $request->getOrigin());
$this->createStandardCreateResponse($request, $response, $attrL11n);
}
/**
* Api method to update EquipmentAttribute
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiEquipmentAttributeUpdate(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 = EquipmentAttributeMapper::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, EquipmentAttributeMapper::class, 'equipment_attribute', $request->getOrigin());
if ($new->value->getValue() !== $old->value->getValue()
&& $new->type->custom
) {
$this->updateModel($request->header->account, $old->value, $new->value, EquipmentAttributeValueMapper::class, 'attribute_value', $request->getOrigin());
}
$this->createStandardUpdateResponse($request, $response, $new);
}
/**
* Api method to delete EquipmentAttribute
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiEquipmentAttributeDelete(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;
}
$equipmentAttribute = EquipmentAttributeMapper::get()
->with('type')
->where('id', (int) $request->getData('id'))
->execute();
if ($equipmentAttribute->type->isRequired) {
$this->createInvalidDeleteResponse($request, $response, []);
return;
}
$this->deleteModel($request->header->account, $equipmentAttribute, EquipmentAttributeMapper::class, 'equipment_attribute', $request->getOrigin());
$this->createStandardDeleteResponse($request, $response, $equipmentAttribute);
}
/**
* Api method to update EquipmentAttributeTypeL11n
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiEquipmentAttributeTypeL11nUpdate(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 = EquipmentAttributeTypeL11nMapper::get()->where('id', (int) $request->getData('id'))->execute();
$new = $this->updateAttributeTypeL11nFromRequest($request, clone $old);
$this->updateModel($request->header->account, $old, $new, EquipmentAttributeTypeL11nMapper::class, 'equipment_attribute_type_l11n', $request->getOrigin());
$this->createStandardUpdateResponse($request, $response, $new);
}
/**
* Api method to delete EquipmentAttributeTypeL11n
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiEquipmentAttributeTypeL11nDelete(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 $equipmentAttributeTypeL11n */
$equipmentAttributeTypeL11n = EquipmentAttributeTypeL11nMapper::get()->where('id', (int) $request->getData('id'))->execute();
$this->deleteModel($request->header->account, $equipmentAttributeTypeL11n, EquipmentAttributeTypeL11nMapper::class, 'equipment_attribute_type_l11n', $request->getOrigin());
$this->createStandardDeleteResponse($request, $response, $equipmentAttributeTypeL11n);
}
/**
* Api method to update EquipmentAttributeType
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiEquipmentAttributeTypeUpdate(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 = EquipmentAttributeTypeMapper::get()->where('id', (int) $request->getData('id'))->execute();
$new = $this->updateAttributeTypeFromRequest($request, clone $old);
$this->updateModel($request->header->account, $old, $new, EquipmentAttributeTypeMapper::class, 'equipment_attribute_type', $request->getOrigin());
$this->createStandardUpdateResponse($request, $response, $new);
}
/**
* Api method to delete EquipmentAttributeType
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @todo: implement
*
* @since 1.0.0
*/
public function apiEquipmentAttributeTypeDelete(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 $equipmentAttributeType */
$equipmentAttributeType = EquipmentAttributeTypeMapper::get()->where('id', (int) $request->getData('id'))->execute();
$this->deleteModel($request->header->account, $equipmentAttributeType, EquipmentAttributeTypeMapper::class, 'equipment_attribute_type', $request->getOrigin());
$this->createStandardDeleteResponse($request, $response, $equipmentAttributeType);
}
/**
* Api method to update EquipmentAttributeValue
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiEquipmentAttributeValueUpdate(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 = EquipmentAttributeValueMapper::get()->where('id', (int) $request->getData('id'))->execute();
/** @var \Modules\Attribute\Models\Attribute $attr */
$attr = EquipmentAttributeMapper::get()
->with('type')
->where('id', $request->getDataInt('attribute') ?? 0)
->execute();
$new = $this->updateAttributeValueFromRequest($request, clone $old, $attr);
$this->updateModel($request->header->account, $old, $new, EquipmentAttributeValueMapper::class, 'equipment_attribute_value', $request->getOrigin());
$this->createStandardUpdateResponse($request, $response, $new);
}
/**
* Api method to delete EquipmentAttributeValue
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiEquipmentAttributeValueDelete(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\EquipmentManagement\Models\EquipmentAttributeValue $equipmentAttributeValue */
// $equipmentAttributeValue = EquipmentAttributeValueMapper::get()->where('id', (int) $request->getData('id'))->execute();
// $this->deleteModel($request->header->account, $equipmentAttributeValue, EquipmentAttributeValueMapper::class, 'equipment_attribute_value', $request->getOrigin());
// $this->createStandardDeleteResponse($request, $response, $equipmentAttributeValue);
}
/**
* Api method to update EquipmentAttributeValueL11n
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiEquipmentAttributeValueL11nUpdate(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 = EquipmentAttributeValueL11nMapper::get()->where('id', (int) $request->getData('id'));
$new = $this->updateAttributeValueL11nFromRequest($request, clone $old);
$this->updateModel($request->header->account, $old, $new, EquipmentAttributeValueL11nMapper::class, 'equipment_attribute_value_l11n', $request->getOrigin());
$this->createStandardUpdateResponse($request, $response, $new);
}
/**
* Api method to delete EquipmentAttributeValueL11n
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiEquipmentAttributeValueL11nDelete(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 $equipmentAttributeValueL11n */
$equipmentAttributeValueL11n = EquipmentAttributeValueL11nMapper::get()->where('id', (int) $request->getData('id'))->execute();
$this->deleteModel($request->header->account, $equipmentAttributeValueL11n, EquipmentAttributeValueL11nMapper::class, 'equipment_attribute_value_l11n', $request->getOrigin());
$this->createStandardDeleteResponse($request, $response, $equipmentAttributeValueL11n);
}
}

View File

@ -0,0 +1,614 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Controller;
use Modules\Admin\Models\NullAccount;
use Modules\EquipmentManagement\Models\Equipment;
use Modules\EquipmentManagement\Models\EquipmentMapper;
use Modules\EquipmentManagement\Models\EquipmentStatus;
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\Localization\NullBaseStringL11nType;
use phpOMS\Message\Http\RequestStatusCode;
use phpOMS\Message\NotificationLevel;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
/**
* EquipmentManagement class.
*
* @package Modules\EquipmentManagement
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
final class ApiEquipmentController extends Controller
{
/**
* Api method to create a equipment
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiEquipmentCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateEquipmentCreate($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidCreateResponse($request, $response, $val);
return;
}
/** @var Equipment $equipment */
$equipment = $this->createEquipmentFromRequest($request);
$this->createModel($request->header->account, $equipment, EquipmentMapper::class, 'equipment', $request->getOrigin());
if (!empty($request->files)
|| !empty($request->getDataJson('media'))
) {
$this->createEquipmentMedia($equipment, $request);
}
$this->createStandardCreateResponse($request, $response, $equipment);
}
/**
* Method to create equipment from request.
*
* @param RequestAbstract $request Request
*
* @return Equipment Returns the created equipment from the request
*
* @since 1.0.0
*/
public function createEquipmentFromRequest(RequestAbstract $request) : Equipment
{
$equipment = new Equipment();
$equipment->name = $request->getDataString('name') ?? '';
$equipment->info = $request->getDataString('info') ?? '';
$equipment->type = new NullBaseStringL11nType((int) ($request->getDataInt('type') ?? 0));
$equipment->status = $request->getDataInt('status') ?? EquipmentStatus::INACTIVE;
$equipment->unit = $request->getDataInt('unit') ?? $this->app->unitId;
return $equipment;
}
/**
* Create media files for equipment
*
* @param Equipment $equipment Equipment
* @param RequestAbstract $request Request incl. media do upload
*
* @return void
*
* @since 1.0.0
*/
private function createEquipmentMedia(Equipment $equipment, RequestAbstract $request) : void
{
$path = $this->createEquipmentDir($equipment);
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,
$equipment->id,
$media->id,
EquipmentMapper::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,
$equipment->id,
$media->id,
EquipmentMapper::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 equipment create request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool> Returns the validation array of the request
*
* @since 1.0.0
*/
private function validateEquipmentCreate(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 apiMediaAddToEquipment(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateMediaAddToEquipment($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidAddResponse($request, $response, $val);
return;
}
/** @var \Modules\EquipmentManagement\Models\Equipment $equipment */
$equipment = EquipmentMapper::get()->where('id', (int) $request->getData('equipment'))->execute();
$path = $this->createEquipmentDir($equipment);
$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,
$equipment->id,
$media->id,
EquipmentMapper::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,
$equipment->id,
(int) $media,
EquipmentMapper::class,
'files',
'',
$request->getOrigin()
);
}
}
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Media', 'Media added to equipment.', [
'upload' => $uploaded,
'media' => $mediaFiles,
]);
}
/**
* Create media directory path
*
* @param Equipment $equipment Equipment
*
* @return string
*
* @since 1.0.0
*/
private function createEquipmentDir(Equipment $equipment) : string
{
return '/Modules/EquipmentManagement/Equipment/'
. $this->app->unitId . '/'
. $equipment->id;
}
/**
* Method to validate bill creation from request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @since 1.0.0
*/
private function validateMediaAddToEquipment(RequestAbstract $request) : array
{
$val = [];
if (($val['media'] = (!$request->hasData('media') && empty($request->files)))
|| ($val['equipment'] = !$request->hasData('equipment'))
) {
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/EquipmentManagement/Equipment/' . $request->getData('id'), true);
$this->app->moduleManager->get('Editor', 'Api')->apiEditorCreate($request, $response, $data);
if ($response->header->status !== RequestStatusCode::R_200) {
return;
}
$responseData = $response->get($request->uri->__toString());
if (!\is_array($responseData)) {
return;
}
$model = $responseData['response'];
$this->createModelRelation($request->header->account, (int) $request->getData('id'), $model->id, EquipmentMapper::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 Equipment
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiEquipmentFind(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
}
/**
* Api method to update Equipment
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiEquipmentUpdate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateEquipmentUpdate($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidUpdateResponse($request, $response, $val);
return;
}
/** @var \Modules\EquipmentManagement\Models\Equipment $old */
$old = EquipmentMapper::get()->where('id', (int) $request->getData('id'))->execute();
$new = $this->updateEquipmentFromRequest($request, clone $old);
$this->updateModel($request->header->account, $old, $new, EquipmentMapper::class, 'equipment', $request->getOrigin());
$this->createStandardUpdateResponse($request, $response, $new);
}
/**
* Method to update Equipment from request.
*
* @param RequestAbstract $request Request
* @param Equipment $new Model to modify
*
* @return Equipment
*
* @todo: implement
*
* @since 1.0.0
*/
public function updateEquipmentFromRequest(RequestAbstract $request, Equipment $new) : Equipment
{
$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 Equipment update request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @todo: implement
*
* @since 1.0.0
*/
private function validateEquipmentUpdate(RequestAbstract $request) : array
{
$val = [];
if (($val['id'] = !$request->hasData('id'))) {
return $val;
}
return [];
}
/**
* Api method to delete Equipment
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiEquipmentDelete(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateEquipmentDelete($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidDeleteResponse($request, $response, $val);
return;
}
/** @var \Modules\EquipmentManagement\Models\Equipment $equipment */
$equipment = EquipmentMapper::get()->where('id', (int) $request->getData('id'))->execute();
$this->deleteModel($request->header->account, $equipment, EquipmentMapper::class, 'equipment', $request->getOrigin());
$this->createStandardDeleteResponse($request, $response, $equipment);
}
/**
* Validate Equipment delete request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @todo: implement
*
* @since 1.0.0
*/
private function validateEquipmentDelete(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
{
// @todo: check permissions
$this->app->moduleManager->get('Editor', 'Api')->apiEditorDocUpdate($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
{
// @todo: check permissions
$this->app->moduleManager->get('Editor', 'Api')->apiEditorDocDelete($request, $response, $data);
}
}

View File

@ -0,0 +1,403 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Controller;
use Modules\EquipmentManagement\Models\EquipmentTypeL11nMapper;
use Modules\EquipmentManagement\Models\EquipmentTypeMapper;
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;
/**
* EquipmentManagement class.
*
* @package Modules\EquipmentManagement
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
final class ApiEquipmentTypeController 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 apiEquipmentTypeCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateEquipmentTypeCreate($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidCreateResponse($request, $response, $val);
return;
}
$equipmentType = $this->createEquipmentTypeFromRequest($request);
$this->createModel($request->header->account, $equipmentType, EquipmentTypeMapper::class, 'equipment_type', $request->getOrigin());
$this->createStandardCreateResponse($request, $response, $equipmentType);
}
/**
* Method to create item attribute from request.
*
* @param RequestAbstract $request Request
*
* @return BaseStringL11nType
*
* @since 1.0.0
*/
private function createEquipmentTypeFromRequest(RequestAbstract $request) : BaseStringL11nType
{
$equipmentType = new BaseStringL11nType();
$equipmentType->setL11n($request->getDataString('title') ?? '', $request->getDataString('language') ?? ISO639x1Enum::_EN);
$equipmentType->title = $request->getDataString('name') ?? '';
return $equipmentType;
}
/**
* Validate item attribute create request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @since 1.0.0
*/
private function validateEquipmentTypeCreate(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 apiEquipmentTypeL11nCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateEquipmentTypeL11nCreate($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidCreateResponse($request, $response, $val);
return;
}
$equipmentTypeL11n = $this->createEquipmentTypeL11nFromRequest($request);
$this->createModel($request->header->account, $equipmentTypeL11n, EquipmentTypeL11nMapper::class, 'equipment_type_l11n', $request->getOrigin());
$this->createStandardCreateResponse($request, $response, $equipmentTypeL11n);
}
/**
* Method to create item attribute l11n from request.
*
* @param RequestAbstract $request Request
*
* @return BaseStringL11n
*
* @since 1.0.0
*/
private function createEquipmentTypeL11nFromRequest(RequestAbstract $request) : BaseStringL11n
{
$equipmentTypeL11n = new BaseStringL11n();
$equipmentTypeL11n->ref = $request->getDataInt('type') ?? 0;
$equipmentTypeL11n->setLanguage(
$request->getDataString('language') ?? $request->header->l11n->language
);
$equipmentTypeL11n->content = $request->getDataString('title') ?? '';
return $equipmentTypeL11n;
}
/**
* Validate item attribute l11n create request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @since 1.0.0
*/
private function validateEquipmentTypeL11nCreate(RequestAbstract $request) : array
{
$val = [];
if (($val['title'] = !$request->hasData('title'))
|| ($val['type'] = !$request->hasData('type'))
) {
return $val;
}
return [];
}
/**
* Api method to update EquipmentType
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiEquipmentTypeUpdate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateEquipmentTypeUpdate($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidUpdateResponse($request, $response, $val);
return;
}
/** @var BaseStringL11nType $old */
$old = EquipmentTypeMapper::get()->where('id', (int) $request->getData('id'));
$new = $this->updateEquipmentTypeFromRequest($request, clone $old);
$this->updateModel($request->header->account, $old, $new, EquipmentTypeMapper::class, 'equipment_type', $request->getOrigin());
$this->createStandardUpdateResponse($request, $response, $new);
}
/**
* Method to update EquipmentType from request.
*
* @param RequestAbstract $request Request
* @param BaseStringL11nType $new Model to modify
*
* @return BaseStringL11nType
*
* @todo: implement
*
* @since 1.0.0
*/
public function updateEquipmentTypeFromRequest(RequestAbstract $request, BaseStringL11nType $new) : BaseStringL11nType
{
$new->title = $request->getDataString('name') ?? $new->title;
return $new;
}
/**
* Validate EquipmentType update request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @todo: implement
*
* @since 1.0.0
*/
private function validateEquipmentTypeUpdate(RequestAbstract $request) : array
{
$val = [];
if (($val['id'] = !$request->hasData('id'))) {
return $val;
}
return [];
}
/**
* Api method to delete EquipmentType
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiEquipmentTypeDelete(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateEquipmentTypeDelete($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidDeleteResponse($request, $response, $val);
return;
}
/** @var BaseStringL11nType $equipmentType */
$equipmentType = EquipmentTypeMapper::get()->where('id', (int) $request->getData('id'))->execute();
$this->deleteModel($request->header->account, $equipmentType, EquipmentTypeMapper::class, 'equipment_type', $request->getOrigin());
$this->createStandardDeleteResponse($request, $response, $equipmentType);
}
/**
* Validate EquipmentType delete request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @since 1.0.0
*/
private function validateEquipmentTypeDelete(RequestAbstract $request) : array
{
$val = [];
if (($val['id'] = !$request->hasData('id'))) {
return $val;
}
return [];
}
/**
* Api method to update EquipmentTypeL11n
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiEquipmentTypeL11nUpdate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateEquipmentTypeL11nUpdate($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidUpdateResponse($request, $response, $val);
return;
}
/** @var BaseStringL11n $old */
$old = EquipmentTypeL11nMapper::get()->where('id', (int) $request->getData('id'));
$new = $this->updateEquipmentTypeL11nFromRequest($request, clone $old);
$this->updateModel($request->header->account, $old, $new, EquipmentTypeL11nMapper::class, 'equipment_type_l11n', $request->getOrigin());
$this->createStandardUpdateResponse($request, $response, $new);
}
/**
* Method to update EquipmentTypeL11n from request.
*
* @param RequestAbstract $request Request
* @param BaseStringL11n $new Model to modify
*
* @return BaseStringL11n
*
* @since 1.0.0
*/
public function updateEquipmentTypeL11nFromRequest(RequestAbstract $request, BaseStringL11n $new) : BaseStringL11n
{
$new->setLanguage(
$request->getDataString('language') ?? $new->language
);
$new->content = $request->getDataString('title') ?? $new->content;
return $new;
}
/**
* Validate EquipmentTypeL11n update request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @since 1.0.0
*/
private function validateEquipmentTypeL11nUpdate(RequestAbstract $request) : array
{
$val = [];
if (($val['id'] = !$request->hasData('id'))) {
return $val;
}
return [];
}
/**
* Api method to delete EquipmentTypeL11n
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiEquipmentTypeL11nDelete(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateEquipmentTypeL11nDelete($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidDeleteResponse($request, $response, $val);
return;
}
/** @var BaseStringL11n $equipmentTypeL11n */
$equipmentTypeL11n = EquipmentTypeL11nMapper::get()->where('id', (int) $request->getData('id'))->execute();
$this->deleteModel($request->header->account, $equipmentTypeL11n, EquipmentTypeL11nMapper::class, 'equipment_type_l11n', $request->getOrigin());
$this->createStandardDeleteResponse($request, $response, $equipmentTypeL11n);
}
/**
* Validate EquipmentTypeL11n delete request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @since 1.0.0
*/
private function validateEquipmentTypeL11nDelete(RequestAbstract $request) : array
{
$val = [];
if (($val['id'] = !$request->hasData('id'))) {
return $val;
}
return [];
}
}

View File

@ -0,0 +1,403 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Controller;
use Modules\EquipmentManagement\Models\InspectionTypeL11nMapper;
use Modules\EquipmentManagement\Models\InspectionTypeMapper;
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;
/**
* EquipmentManagement class.
*
* @package Modules\EquipmentManagement
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
final class ApiInspectionTypeController 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 apiInspectionTypeCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateInspectionTypeCreate($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidCreateResponse($request, $response, $val);
return;
}
$equipmentType = $this->createInspectionTypeFromRequest($request);
$this->createModel($request->header->account, $equipmentType, InspectionTypeMapper::class, 'equipment_type', $request->getOrigin());
$this->createStandardCreateResponse($request, $response, $equipmentType);
}
/**
* Method to create item attribute from request.
*
* @param RequestAbstract $request Request
*
* @return BaseStringL11nType
*
* @since 1.0.0
*/
private function createInspectionTypeFromRequest(RequestAbstract $request) : BaseStringL11nType
{
$equipmentType = new BaseStringL11nType();
$equipmentType->setL11n($request->getDataString('title') ?? '', $request->getDataString('language') ?? ISO639x1Enum::_EN);
$equipmentType->title = $request->getDataString('name') ?? '';
return $equipmentType;
}
/**
* Validate item attribute create request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @since 1.0.0
*/
private function validateInspectionTypeCreate(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 apiInspectionTypeL11nCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateInspectionTypeL11nCreate($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidCreateResponse($request, $response, $val);
return;
}
$equipmentTypeL11n = $this->createInspectionTypeL11nFromRequest($request);
$this->createModel($request->header->account, $equipmentTypeL11n, InspectionTypeL11nMapper::class, 'equipment_type_l11n', $request->getOrigin());
$this->createStandardCreateResponse($request, $response, $equipmentTypeL11n);
}
/**
* Method to create item attribute l11n from request.
*
* @param RequestAbstract $request Request
*
* @return BaseStringL11n
*
* @since 1.0.0
*/
private function createInspectionTypeL11nFromRequest(RequestAbstract $request) : BaseStringL11n
{
$equipmentTypeL11n = new BaseStringL11n();
$equipmentTypeL11n->ref = $request->getDataInt('type') ?? 0;
$equipmentTypeL11n->setLanguage(
$request->getDataString('language') ?? $request->header->l11n->language
);
$equipmentTypeL11n->content = $request->getDataString('title') ?? '';
return $equipmentTypeL11n;
}
/**
* Validate item attribute l11n create request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @since 1.0.0
*/
private function validateInspectionTypeL11nCreate(RequestAbstract $request) : array
{
$val = [];
if (($val['title'] = !$request->hasData('title'))
|| ($val['type'] = !$request->hasData('type'))
) {
return $val;
}
return [];
}
/**
* Api method to update InspectionType
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiInspectionTypeUpdate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateInspectionTypeUpdate($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidUpdateResponse($request, $response, $val);
return;
}
/** @var BaseStringL11nType $old */
$old = InspectionTypeMapper::get()->where('id', (int) $request->getData('id'));
$new = $this->updateInspectionTypeFromRequest($request, clone $old);
$this->updateModel($request->header->account, $old, $new, InspectionTypeMapper::class, 'equipment_type', $request->getOrigin());
$this->createStandardUpdateResponse($request, $response, $new);
}
/**
* Method to update InspectionType from request.
*
* @param RequestAbstract $request Request
* @param BaseStringL11nType $new Model to modify
*
* @return BaseStringL11nType
*
* @todo: implement
*
* @since 1.0.0
*/
public function updateInspectionTypeFromRequest(RequestAbstract $request, BaseStringL11nType $new) : BaseStringL11nType
{
$new->title = $request->getDataString('name') ?? $new->title;
return $new;
}
/**
* Validate InspectionType update request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @todo: implement
*
* @since 1.0.0
*/
private function validateInspectionTypeUpdate(RequestAbstract $request) : array
{
$val = [];
if (($val['id'] = !$request->hasData('id'))) {
return $val;
}
return [];
}
/**
* Api method to delete InspectionType
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiInspectionTypeDelete(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateInspectionTypeDelete($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidDeleteResponse($request, $response, $val);
return;
}
/** @var BaseStringL11nType $equipmentType */
$equipmentType = InspectionTypeMapper::get()->where('id', (int) $request->getData('id'))->execute();
$this->deleteModel($request->header->account, $equipmentType, InspectionTypeMapper::class, 'equipment_type', $request->getOrigin());
$this->createStandardDeleteResponse($request, $response, $equipmentType);
}
/**
* Validate InspectionType delete request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @since 1.0.0
*/
private function validateInspectionTypeDelete(RequestAbstract $request) : array
{
$val = [];
if (($val['id'] = !$request->hasData('id'))) {
return $val;
}
return [];
}
/**
* Api method to update InspectionTypeL11n
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiInspectionTypeL11nUpdate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateInspectionTypeL11nUpdate($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidUpdateResponse($request, $response, $val);
return;
}
/** @var BaseStringL11n $old */
$old = InspectionTypeL11nMapper::get()->where('id', (int) $request->getData('id'));
$new = $this->updateInspectionTypeL11nFromRequest($request, clone $old);
$this->updateModel($request->header->account, $old, $new, InspectionTypeL11nMapper::class, 'equipment_type_l11n', $request->getOrigin());
$this->createStandardUpdateResponse($request, $response, $new);
}
/**
* Method to update InspectionTypeL11n from request.
*
* @param RequestAbstract $request Request
* @param BaseStringL11n $new Model to modify
*
* @return BaseStringL11n
*
* @since 1.0.0
*/
public function updateInspectionTypeL11nFromRequest(RequestAbstract $request, BaseStringL11n $new) : BaseStringL11n
{
$new->setLanguage(
$request->getDataString('language') ?? $new->language
);
$new->content = $request->getDataString('title') ?? $new->content;
return $new;
}
/**
* Validate InspectionTypeL11n update request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @since 1.0.0
*/
private function validateInspectionTypeL11nUpdate(RequestAbstract $request) : array
{
$val = [];
if (($val['id'] = !$request->hasData('id'))) {
return $val;
}
return [];
}
/**
* Api method to delete InspectionTypeL11n
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiInspectionTypeL11nDelete(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateInspectionTypeL11nDelete($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidDeleteResponse($request, $response, $val);
return;
}
/** @var BaseStringL11n $equipmentTypeL11n */
$equipmentTypeL11n = InspectionTypeL11nMapper::get()->where('id', (int) $request->getData('id'))->execute();
$this->deleteModel($request->header->account, $equipmentTypeL11n, InspectionTypeL11nMapper::class, 'equipment_type_l11n', $request->getOrigin());
$this->createStandardDeleteResponse($request, $response, $equipmentTypeL11n);
}
/**
* Validate InspectionTypeL11n delete request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @since 1.0.0
*/
private function validateInspectionTypeL11nDelete(RequestAbstract $request) : array
{
$val = [];
if (($val['id'] = !$request->hasData('id'))) {
return $val;
}
return [];
}
}

257
Controller/BackendController.php Executable file
View File

@ -0,0 +1,257 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Controller;
use Modules\Admin\Models\LocalizationMapper;
use Modules\Admin\Models\SettingsEnum;
use Modules\EquipmentManagement\Models\Attribute\EquipmentAttributeTypeL11nMapper;
use Modules\EquipmentManagement\Models\Attribute\EquipmentAttributeTypeMapper;
use Modules\EquipmentManagement\Models\EquipmentMapper;
use Modules\EquipmentManagement\Models\EquipmentTypeMapper;
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;
/**
* EquipmentManagement class.
*
* @package Modules\EquipmentManagement
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
* @codeCoverageIgnore
*/
final class BackendController extends Controller
{
/**
* Routing end-point for application behaviour.
*
* @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 viewEquipmentManagementAttributeTypeList(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/EquipmentManagement/Theme/Backend/attribute-type-list');
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1003503001, $request, $response);
/** @var \Modules\Attribute\Models\AttributeType[] $attributes */
$attributes = EquipmentAttributeTypeMapper::getAll()
->with('l11n')
->where('l11n/language', $response->header->l11n->language)
->execute();
$view->data['attributes'] = $attributes;
return $view;
}
/**
* Routing end-point for application behaviour.
*
* @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 viewEquipmentManagementEquipmentList(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/EquipmentManagement/Theme/Backend/equipment-list');
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1008402001, $request, $response);
$list = EquipmentMapper::getAll()
->with('type')
->with('type/l11n')
->where('type/l11n/language', $response->header->l11n->language)
->sort('id', 'DESC')
->execute();
$view->data['equipments'] = $list;
return $view;
}
/**
* Routing end-point for application behaviour.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewEquipmentManagementAttributeType(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/EquipmentManagement/Theme/Backend/attribute-type');
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1004801001, $request, $response);
/** @var \Modules\Attribute\Models\AttributeType $attribute */
$attribute = EquipmentAttributeTypeMapper::get()
->with('l11n')
->where('id', (int) $request->getData('id'))
->where('l11n/language', $response->header->l11n->language)
->execute();
$l11ns = EquipmentAttributeTypeL11nMapper::getAll()
->where('ref', $attribute->id)
->execute();
$view->data['attribute'] = $attribute;
$view->data['l11ns'] = $l11ns;
return $view;
}
/**
* Routing end-point for application behaviour.
*
* @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 viewEquipmentManagementEquipmentCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/EquipmentManagement/Theme/Backend/equipment-profile');
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1008402001, $request, $response);
/** @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['equipment-notes'] = new \Modules\Editor\Theme\Backend\Components\Compound\BaseView($this->app->l11nManager, $request, $response);
return $view;
}
/**
* Routing end-point for application behaviour.
*
* @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 viewEquipmentManagementEquipmentProfile(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/EquipmentManagement/Theme/Backend/equipment-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.
$equipment = EquipmentMapper::get()
->with('attributes')
->with('attributes/type')
->with('attributes/value')
->with('attributes/type/l11n')
->with('files')
->with('files/types')
->with('type')
->with('type/l11n')
->with('fuelType')
->with('fuelType/l11n')
->where('id', (int) $request->getData('id'))
->where('type/l11n/language', $response->header->l11n->language)
->where('fuelType/l11n/language', $response->header->l11n->language)
->where('attributes/type/l11n/language', $response->header->l11n->language)
->execute();
$view->data['equipment'] = $equipment;
$query = new Builder($this->app->dbPool->get());
$results = $query->selectAs(EquipmentMapper::HAS_MANY['files']['external'], 'file')
->from(EquipmentMapper::TABLE)
->leftJoin(EquipmentMapper::HAS_MANY['files']['table'])
->on(EquipmentMapper::HAS_MANY['files']['table'] . '.' . EquipmentMapper::HAS_MANY['files']['self'], '=', EquipmentMapper::TABLE . '.' . EquipmentMapper::PRIMARYFIELD)
->leftJoin(MediaMapper::TABLE)
->on(EquipmentMapper::HAS_MANY['files']['table'] . '.' . EquipmentMapper::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(EquipmentMapper::HAS_MANY['files']['self'], '=', $equipment->id)
->where(MediaTypeMapper::TABLE . '.' . MediaTypeMapper::getColumnByMember('name'), '=', 'equipment_profile_image');
$equipmentImage = MediaMapper::get()
->with('types')
->where('id', $results)
->limit(1)
->execute();
$view->data['equipmentImage'] = $equipmentImage;
$equipmentTypes = EquipmentTypeMapper::getAll()
->with('l11n')
->where('l11n/language', $response->header->l11n->language)
->execute();
$view->data['types'] = $equipmentTypes;
$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['equipment-notes'] = new \Modules\Editor\Theme\Backend\Components\Compound\BaseView($this->app->l11nManager, $request, $response);
return $view;
}
}

76
Controller/Controller.php Executable file
View File

@ -0,0 +1,76 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Controller;
use phpOMS\Module\ModuleAbstract;
/**
* EquipmentManagement class.
*
* @package Modules\EquipmentManagement
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
class Controller extends ModuleAbstract
{
/**
* Module path.
*
* @var string
* @since 1.0.0
*/
public const PATH = __DIR__ . '/../';
/**
* Module version.
*
* @var string
* @since 1.0.0
*/
public const VERSION = '1.0.0';
/**
* Module name.
*
* @var string
* @since 1.0.0
*/
public const NAME = 'EquipmentManagement';
/**
* Module id.
*
* @var int
* @since 1.0.0
*/
public const ID = 1008400000;
/**
* Providing.
*
* @var string[]
* @since 1.0.0
*/
public static array $providing = [];
/**
* Dependencies.
*
* @var string[]
* @since 1.0.0
*/
public static array $dependencies = [];
}

3
Docs/Dev/en/SUMMARY.md Executable file
View File

@ -0,0 +1,3 @@
# Developer Content
* [Structure]({%}&page=Dev/structure)

5
Docs/Dev/en/structure.md Executable file
View File

@ -0,0 +1,5 @@
# Structure
## ER
![ER](Modules/ClientManagement/Docs/Dev/img/er.png)

BIN
Docs/Dev/img/er.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 KiB

49
ICAL.txt Executable file
View File

@ -0,0 +1,49 @@
# Individual Contributor License Agreement ("CLA") 1.0
Thank you for your interest in Karaka-Management (the "Company"). In order to clarify the intellectual property license granted with Contributions from any person or entity, the Company must provide a Contributor License Agreement ("CLA") on file that has been made available to each Contributor. This license is for your protection as a Contributor as well as the protection of the Company and its users; it does not change your rights to use your own Contributions for any other purpose.
By contributing to the Company You accept and agree to the following terms and conditions for Your present and future Contributions submitted to the Company. In return, the Company shall not use Your Contributions in a way that is contrary to the public benefit or inconsistent with its bylaws in effect at the time of the Contribution. Except for the license granted herein to the Company and recipients of software distributed by the Company, You reserve all right, title, and interest in and to Your Contributions.
## Definitions
**"You" (or "Your")**
"You" (or "Your") shall mean the copyright owner or legal entity authorized by the copyright owner that is making this Agreement with the Company. For legal entities, the entity making a Contribution and all other entities that control, are controlled by, or are under common control with that entity are considered to be a single Contributor. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
**"Contribution"**
"Contribution" shall mean any original work of authorship, including any modifications or additions to an existing work, that is intentionally submitted by You to the Company for inclusion in, or documentation of, any of the products owned or managed by the Company (the "Work"). This includes but is not limited to technical material, techniques, articles, sketches, drawings, images, models, inventions, know-how, processes, apparatus, equipment, algorithms, software programs, software source documents, and formula related to the current, future and proposed products and services regarding the Company". For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Company or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Company for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by You as "Not a Contribution."
## Grant of Copyright License
Subject to the terms and conditions of this Agreement, You hereby grant to the Company and to recipients of software distributed by the Company a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sub license, and distribute Your Contributions and such derivative works.
## Grant of Patent License
Subject to the terms and conditions of this Agreement, You hereby grant to the Company and to recipients of software distributed by the Company a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by You that are necessarily infringed by Your Contribution(s) alone or by combination of Your Contribution(s) with the Work to which such Contribution(s) was submitted. If any entity institutes patent litigation against You or any other entity (including a cross-claim or counterclaim in a lawsuit) alleging that your Contribution, or the Work to which you have contributed, constitutes direct or contributory patent infringement, then any patent licenses granted to that entity under this Agreement for that Contribution or Work shall terminate as of the date such litigation is filed.
## Authorization
You represent that you are legally entitled to grant the above license. If your employer(s) has rights to intellectual property that you create that includes your Contributions, you represent that you have received permission to make Contributions on behalf of that employer, that your employer has waived such rights for your Contributions to the Company, or that your employer has executed a separate Corporate CLA with the Company.
You represent that each of Your Contributions is Your original creation (see "Third-party Contribution" for submissions on behalf of others). You represent that Your Contribution submissions include complete details of any third-party license or other restriction (including, but not limited to, related patents and trademarks) of which you are personally aware and which are associated with any part of Your Contributions.
## Support
You are not expected to provide support for Your Contributions, except to the extent You desire to provide support. You may provide support for free, for a fee, or not at all. Unless required by applicable law or agreed to in writing, You provide Your Contributions on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON- INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
## Third-party Contribution
Should You wish to submit work that is not Your original creation, You may submit it to the Company separately from any Contribution, identifying the complete details of its source and of any license or other restriction (including, but not limited to, related patents, trademarks, and license agreements) of which you are personally aware, and conspicuously marking the work as "Submitted on behalf of a third-party: [named here]".
## Survival
This Agreement shall govern all communications between the parties. You understand that this Agreement stays active even if the connection with You gets terminated unless the project the Company gets officially canceled by the project manager "Dennis Eichhorn".
## Governing Law and Jurisdiction
This Agreement shall be governed exclusively by German law. The courts of Hessen, Germany shall have exclusive jurisdiction.
## Entire Agreement
This agreement constitutes the entire agreement and supersedes all prior or contemporaneous oral or written agreements concerning such Contribution. This agreement may only be changed by mutual agreement of authorized representatives of the parties in writing. You agree to notify the Company of any facts or circumstances of which you become aware that would make these representations inaccurate in any respect.

View File

@ -0,0 +1,86 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement\Models\Attribute
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Models\Attribute;
use Modules\Attribute\Models\Attribute;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
/**
* Fleet mapper class.
*
* @package Modules\EquipmentManagement\Models\Attribute
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*
* @template T of Attribute
* @extends DataMapperFactory<T>
*/
final class EquipmentAttributeMapper 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 = [
'equipmgmt_equipment_attr_id' => ['name' => 'equipmgmt_equipment_attr_id', 'type' => 'int', 'internal' => 'id'],
'equipmgmt_equipment_attr_equipment' => ['name' => 'equipmgmt_equipment_attr_equipment', 'type' => 'int', 'internal' => 'ref'],
'equipmgmt_equipment_attr_type' => ['name' => 'equipmgmt_equipment_attr_type', 'type' => 'int', 'internal' => 'type'],
'equipmgmt_equipment_attr_value' => ['name' => 'equipmgmt_equipment_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' => EquipmentAttributeTypeMapper::class,
'external' => 'equipmgmt_equipment_attr_type',
],
'value' => [
'mapper' => EquipmentAttributeValueMapper::class,
'external' => 'equipmgmt_equipment_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 = 'equipmgmt_equipment_attr';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
public const PRIMARYFIELD = 'equipmgmt_equipment_attr_id';
}

View File

@ -0,0 +1,69 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement\Models\Attribute
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Models\Attribute;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
use phpOMS\Localization\BaseStringL11n;
/**
* Equipment mapper class.
*
* @package Modules\EquipmentManagement\Models\Attribute
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*
* @template T of BaseStringL11n
* @extends DataMapperFactory<T>
*/
final class EquipmentAttributeTypeL11nMapper 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 = [
'equipmgmt_attr_type_l11n_id' => ['name' => 'equipmgmt_attr_type_l11n_id', 'type' => 'int', 'internal' => 'id'],
'equipmgmt_attr_type_l11n_title' => ['name' => 'equipmgmt_attr_type_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true],
'equipmgmt_attr_type_l11n_type' => ['name' => 'equipmgmt_attr_type_l11n_type', 'type' => 'int', 'internal' => 'ref'],
'equipmgmt_attr_type_l11n_lang' => ['name' => 'equipmgmt_attr_type_l11n_lang', 'type' => 'string', 'internal' => 'language'],
];
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
public const TABLE = 'equipmgmt_attr_type_l11n';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
public const PRIMARYFIELD = 'equipmgmt_attr_type_l11n_id';
/**
* Model to use by the mapper.
*
* @var class-string<T>
* @since 1.0.0
*/
public const MODEL = BaseStringL11n::class;
}

View File

@ -0,0 +1,94 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement\Models\Attribute
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Models\Attribute;
use Modules\Attribute\Models\AttributeType;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
/**
* Equipment mapper class.
*
* @package Modules\EquipmentManagement\Models\Attribute
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*
* @template T of AttributeType
* @extends DataMapperFactory<T>
*/
final class EquipmentAttributeTypeMapper 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 = [
'equipmgmt_attr_type_id' => ['name' => 'equipmgmt_attr_type_id', 'type' => 'int', 'internal' => 'id'],
'equipmgmt_attr_type_name' => ['name' => 'equipmgmt_attr_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
'equipmgmt_attr_type_datatype' => ['name' => 'equipmgmt_attr_type_datatype', 'type' => 'int', 'internal' => 'datatype'],
'equipmgmt_attr_type_fields' => ['name' => 'equipmgmt_attr_type_fields', 'type' => 'int', 'internal' => 'fields'],
'equipmgmt_attr_type_custom' => ['name' => 'equipmgmt_attr_type_custom', 'type' => 'bool', 'internal' => 'custom'],
'equipmgmt_attr_type_pattern' => ['name' => 'equipmgmt_attr_type_pattern', 'type' => 'string', 'internal' => 'validationPattern'],
'equipmgmt_attr_type_required' => ['name' => 'equipmgmt_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' => EquipmentAttributeTypeL11nMapper::class,
'table' => 'equipmgmt_attr_type_l11n',
'self' => 'equipmgmt_attr_type_l11n_type',
'column' => 'content',
'external' => null,
],
'defaults' => [
'mapper' => EquipmentAttributeValueMapper::class,
'table' => 'equipmgmt_equipment_attr_default',
'self' => 'equipmgmt_equipment_attr_default_type',
'external' => 'equipmgmt_equipment_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 = 'equipmgmt_attr_type';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
public const PRIMARYFIELD = 'equipmgmt_attr_type_id';
}

View File

@ -0,0 +1,69 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement\Models\Attribute
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Models\Attribute;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
use phpOMS\Localization\BaseStringL11n;
/**
* Equipment mapper class.
*
* @package Modules\EquipmentManagement\Models\Attribute
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*
* @template T of BaseStringL11n
* @extends DataMapperFactory<T>
*/
final class EquipmentAttributeValueL11nMapper 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 = [
'equipmgmt_attr_value_l11n_id' => ['name' => 'equipmgmt_attr_value_l11n_id', 'type' => 'int', 'internal' => 'id'],
'equipmgmt_attr_value_l11n_title' => ['name' => 'equipmgmt_attr_value_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true],
'equipmgmt_attr_value_l11n_value' => ['name' => 'equipmgmt_attr_value_l11n_value', 'type' => 'int', 'internal' => 'ref'],
'equipmgmt_attr_value_l11n_lang' => ['name' => 'equipmgmt_attr_value_l11n_lang', 'type' => 'string', 'internal' => 'language'],
];
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
public const TABLE = 'equipmgmt_attr_value_l11n';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
public const PRIMARYFIELD = 'equipmgmt_attr_value_l11n_id';
/**
* Model to use by the mapper.
*
* @var class-string<T>
* @since 1.0.0
*/
public const MODEL = BaseStringL11n::class;
}

View File

@ -0,0 +1,89 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement\Models\Attribute
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Models\Attribute;
use Modules\Attribute\Models\AttributeValue;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
/**
* Equipment mapper class.
*
* @package Modules\EquipmentManagement\Models\Attribute
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*
* @template T of AttributeValue
* @extends DataMapperFactory<T>
*/
final class EquipmentAttributeValueMapper 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 = [
'equipmgmt_attr_value_id' => ['name' => 'equipmgmt_attr_value_id', 'type' => 'int', 'internal' => 'id'],
'equipmgmt_attr_value_default' => ['name' => 'equipmgmt_attr_value_default', 'type' => 'bool', 'internal' => 'isDefault'],
'equipmgmt_attr_value_valueStr' => ['name' => 'equipmgmt_attr_value_valueStr', 'type' => 'string', 'internal' => 'valueStr'],
'equipmgmt_attr_value_valueInt' => ['name' => 'equipmgmt_attr_value_valueInt', 'type' => 'int', 'internal' => 'valueInt'],
'equipmgmt_attr_value_valueDec' => ['name' => 'equipmgmt_attr_value_valueDec', 'type' => 'float', 'internal' => 'valueDec'],
'equipmgmt_attr_value_valueDat' => ['name' => 'equipmgmt_attr_value_valueDat', 'type' => 'DateTime', 'internal' => 'valueDat'],
'equipmgmt_attr_value_unit' => ['name' => 'equipmgmt_attr_value_unit', 'type' => 'string', 'internal' => 'unit'],
'equipmgmt_attr_value_deptype' => ['name' => 'equipmgmt_attr_value_deptype', 'type' => 'int', 'internal' => 'dependingAttributeType'],
'equipmgmt_attr_value_depvalue' => ['name' => 'equipmgmt_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' => EquipmentAttributeValueL11nMapper::class,
'table' => 'equipmgmt_attr_value_l11n',
'self' => 'equipmgmt_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 = 'equipmgmt_attr_value';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
public const PRIMARYFIELD = 'equipmgmt_attr_value_id';
}

48
Models/Cost.php Executable file
View File

@ -0,0 +1,48 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Models;
/**
* class.
*
* @package Modules\Attribute\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
class Cost implements \JsonSerializable
{
public int $id = 0;
public string $name = '';
/**
* {@inheritdoc}
*/
public function toArray() : array
{
return [
'id' => $this->id,
];
}
/**
* {@inheritdoc}
*/
public function jsonSerialize() : mixed
{
return $this->toArray();
}
}

48
Models/CostType.php Executable file
View File

@ -0,0 +1,48 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Models;
/**
* class.
*
* @package Modules\Attribute\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
class CostType implements \JsonSerializable
{
public int $id = 0;
public string $name = '';
/**
* {@inheritdoc}
*/
public function toArray() : array
{
return [
'id' => $this->id,
];
}
/**
* {@inheritdoc}
*/
public function jsonSerialize() : mixed
{
return $this->toArray();
}
}

83
Models/Equipment.php Executable file
View File

@ -0,0 +1,83 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Models;
use phpOMS\Localization\BaseStringL11nType;
/**
* Equipment class.
*
* @package Modules\Attribute\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
class Equipment implements \JsonSerializable
{
public int $id = 0;
public string $name = '';
public int $status = EquipmentStatus::ACTIVE;
public BaseStringL11nType $type;
public string $info = '';
public array $drivers = [];
public array $inspections = [];
public array $milage = [];
public int $unit = 0;
public ?int $responsible = null;
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;
}

115
Models/EquipmentMapper.php Executable file
View File

@ -0,0 +1,115 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Models;
use Modules\Editor\Models\EditorDocMapper;
use Modules\EquipmentManagement\Models\Attribute\EquipmentAttributeMapper;
use Modules\Media\Models\MediaMapper;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
/**
* Mapper class.
*
* @package Modules\EquipmentManagement\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*
* @template T of Equipment
* @extends DataMapperFactory<T>
*/
final class EquipmentMapper 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 = [
'equipmgmt_equipment_id' => ['name' => 'equipmgmt_equipment_id', 'type' => 'int', 'internal' => 'id'],
'equipmgmt_equipment_name' => ['name' => 'equipmgmt_equipment_name', 'type' => 'string', 'internal' => 'name'],
'equipmgmt_equipment_status' => ['name' => 'equipmgmt_equipment_status', 'type' => 'int', 'internal' => 'status'],
'equipmgmt_equipment_info' => ['name' => 'equipmgmt_equipment_info', 'type' => 'string', 'internal' => 'info'],
'equipmgmt_equipment_unit' => ['name' => 'equipmgmt_equipment_unit', 'type' => 'int', 'internal' => 'unit'],
'equipmgmt_equipment_type' => ['name' => 'equipmgmt_equipment_type', 'type' => 'int', 'internal' => 'type'],
'equipmgmt_equipment_responsible' => ['name' => 'equipmgmt_equipment_responsible', 'type' => 'int', 'internal' => 'responsible'],
'equipmgmt_equipment_created_at' => ['name' => 'equipmgmt_equipment_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' => 'equipmgmt_equipment_media',
'external' => 'equipmgmt_equipment_media_media',
'self' => 'equipmgmt_equipment_media_equipment',
],
'attributes' => [
'mapper' => EquipmentAttributeMapper::class,
'table' => 'equipmgmt_equipment_attr',
'self' => 'equipmgmt_equipment_attr_equipment',
'external' => null,
],
'notes' => [
'mapper' => EditorDocMapper::class, /* mapper of the related object */
'table' => 'equipmgmt_equipment_note', /* table of the related object, null if no relation table is used (many->1) */
'external' => 'equipmgmt_equipment_note_doc',
'self' => 'equipmgmt_equipment_note_equipment',
],
];
/**
* 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' => EquipmentTypeMapper::class,
'external' => 'equipmgmt_equipment_type',
],
];
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
public const TABLE = 'equipmgmt_equipment';
/**
* Created at.
*
* @var string
* @since 1.0.0
*/
public const CREATED_AT = 'equipmgmt_equipment_created_at';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
public const PRIMARYFIELD = 'equipmgmt_equipment_id';
}

38
Models/EquipmentStatus.php Executable file
View File

@ -0,0 +1,38 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Models;
use phpOMS\Stdlib\Base\Enum;
/**
* Equipment status enum.
*
* @package Modules\EquipmentManagement\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
abstract class EquipmentStatus extends Enum
{
public const ACTIVE = 1;
public const INACTIVE = 2;
public const DAMAGED = 3;
public const OUT_OF_ORDER = 4;
public const MAINTENANCE = 5;
}

View File

@ -0,0 +1,69 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Models;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
use phpOMS\Localization\BaseStringL11n;
/**
* mapper class.
*
* @package Modules\EquipmentManagement\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*
* @template T of BaseStringL11n
* @extends DataMapperFactory<T>
*/
final class EquipmentTypeL11nMapper 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 = [
'equipmgmt_equipment_type_l11n_id' => ['name' => 'equipmgmt_equipment_type_l11n_id', 'type' => 'int', 'internal' => 'id'],
'equipmgmt_equipment_type_l11n_title' => ['name' => 'equipmgmt_equipment_type_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true],
'equipmgmt_equipment_type_l11n_type' => ['name' => 'equipmgmt_equipment_type_l11n_type', 'type' => 'int', 'internal' => 'ref'],
'equipmgmt_equipment_type_l11n_lang' => ['name' => 'equipmgmt_equipment_type_l11n_lang', 'type' => 'string', 'internal' => 'language'],
];
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
public const TABLE = 'equipmgmt_equipment_type_l11n';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
public const PRIMARYFIELD = 'equipmgmt_equipment_type_l11n_id';
/**
* Model to use by the mapper.
*
* @var class-string<T>
* @since 1.0.0
*/
public const MODEL = BaseStringL11n::class;
}

84
Models/EquipmentTypeMapper.php Executable file
View File

@ -0,0 +1,84 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Models;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
use phpOMS\Localization\BaseStringL11nType;
/**
* Item mapper class.
*
* @package Modules\EquipmentManagement\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*
* @template T of BaseStringL11nType
* @extends DataMapperFactory<T>
*/
final class EquipmentTypeMapper 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 = [
'equipmgmt_equipment_type_id' => ['name' => 'equipmgmt_equipment_type_id', 'type' => 'int', 'internal' => 'id'],
'equipmgmt_equipment_type_name' => ['name' => 'equipmgmt_equipment_type_name', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true],
];
/**
* Has many relation.
*
* @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
* @since 1.0.0
*/
public const HAS_MANY = [
'l11n' => [
'mapper' => EquipmentTypeL11nMapper::class,
'table' => 'equipmgmt_equipment_type_l11n',
'self' => 'equipmgmt_equipment_type_l11n_type',
'column' => 'content',
'external' => null,
],
];
/**
* Model to use by the mapper.
*
* @var class-string<T>
* @since 1.0.0
*/
public const MODEL = BaseStringL11nType::class;
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
public const TABLE = 'equipmgmt_equipment_type';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
public const PRIMARYFIELD = 'equipmgmt_equipment_type_id';
}

90
Models/Inspection.php Executable file
View File

@ -0,0 +1,90 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Models;
use Modules\Admin\Models\Account;
use phpOMS\Localization\BaseStringL11nType;
/**
* Inspection class.
*
* @package Modules\Attribute\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
class Inspection implements \JsonSerializable
{
public int $id = 0;
public string $description = '';
public BaseStringL11nType $type;
public int $status = InspectionStatus::TODO;
// Automatically get's filled from the previous inspection if available
// Alternatively define default interval from inspection type?
public ?\DateTime $next = null;
public ?\DateTime $date = null;
/**
* Inspection duration in hours
*/
public int $duration = 0;
/**
* Inspection interval in months
*
* @var int
* @since 1.0.0
*/
public int $interval = 0;
public int $reference = 0;
public ?Account $responsible = null;
/**
* Constructor
*
* @since 1.0.0
*/
public function __construct()
{
$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;
}

85
Models/InspectionMapper.php Executable file
View File

@ -0,0 +1,85 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Models;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
/**
* mapper class.
*
* @package Modules\EquipmentManagement\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*
* @template T of Inspection
* @extends DataMapperFactory<T>
*/
final class InspectionMapper extends DataMapperFactory
{
/**
* Columns.
*
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
public const COLUMNS = [
'equipmgmt_equipment_inspection_id' => ['name' => 'equipmgmt_equipment_inspection_id', 'type' => 'int', 'internal' => 'id'],
'equipmgmt_equipment_inspection_equipment' => ['name' => 'equipmgmt_equipment_inspection_equipment', 'type' => 'int', 'internal' => 'reference'],
'equipmgmt_equipment_inspection_description' => ['name' => 'equipmgmt_equipment_inspection_description', 'type' => 'string', 'internal' => 'description'],
'equipmgmt_equipment_inspection_status' => ['name' => 'equipmgmt_equipment_inspection_status', 'type' => 'int', 'internal' => 'status'],
'equipmgmt_equipment_inspection_interval' => ['name' => 'equipmgmt_equipment_inspection_interval', 'type' => 'int', 'internal' => 'interval'],
'equipmgmt_equipment_inspection_next' => ['name' => 'equipmgmt_equipment_inspection_next', 'type' => 'DateTime', 'internal' => 'next'],
'equipmgmt_equipment_inspection_date' => ['name' => 'equipmgmt_equipment_inspection_date', 'type' => 'DateTime', 'internal' => 'date'],
'equipmgmt_equipment_inspection_type' => ['name' => 'equipmgmt_equipment_inspection_type', 'type' => 'int', 'internal' => 'type'],
];
/**
* Has one relation.
*
* @var array<string, array{mapper:class-string, external:string, by?:string, column?:string, conditional?:bool}>
* @since 1.0.0
*/
public const OWNS_ONE = [
'type' => [
'mapper' => InspectionTypeMapper::class,
'external' => 'equipmgmt_equipment_type',
],
];
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
public const TABLE = 'equipmgmt_equipment_inspection';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
public const PRIMARYFIELD = 'equipmgmt_equipment_inspection_id';
/**
* Model to use by the mapper.
*
* @var class-string<T>
* @since 1.0.0
*/
public const MODEL = Inspection::class;
}

36
Models/InspectionStatus.php Executable file
View File

@ -0,0 +1,36 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Models;
use phpOMS\Stdlib\Base\Enum;
/**
* Inspection status enum.
*
* @package Modules\EquipmentManagement\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
abstract class InspectionStatus extends Enum
{
public const DONE = 1;
public const PASSED = 2;
public const ONGOING = 4;
public const TODO = 5;
}

View File

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

83
Models/InspectionTypeMapper.php Executable file
View File

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

47
Models/NullEquipment.php Executable file
View File

@ -0,0 +1,47 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Models;
/**
* Null model
*
* @package Modules\EquipmentManagement\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
final class NullEquipment extends Equipment
{
/**
* 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];
}
}

46
Models/NullInspection.php Executable file
View File

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

38
Models/PermissionCategory.php Executable file
View File

@ -0,0 +1,38 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Models;
use phpOMS\Stdlib\Base\Enum;
/**
* Permision state enum.
*
* @package Modules\EquipmentManagement\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
abstract class PermissionCategory extends Enum
{
public const EQUIPMENT = 1;
public const EQUIPMENT_TYPE = 3;
public const EQUIPMENT_INSPECTION_TYPE = 4;
public const EQUIPMENT_INSPECTION = 5;
public const EQUIPMENT_ATTRIBUTE_TYPE = 6;
}

2
README.md Normal file → Executable file
View File

@ -1 +1 @@
# oms-FleetManagement
# oms-EquipmentManagement

View File

@ -0,0 +1,21 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\Localization
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
return ['Navigation' => [
'EquipmentManagement' => 'Equipment Management',
'Equipments' => 'Equipments',
'Inspections' => 'Inspektionen',
'EquipmentInspectionTypes' => 'Equipment Inspektionstypen',
'EquipmentAttributes' => 'Equipment Attribute',
]];

View File

@ -0,0 +1,21 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\Localization
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
return ['Navigation' => [
'EquipmentManagement' => 'Equipment Management',
'Equipments' => 'Equipments',
'Inspections' => 'Inspections',
'EquipmentInspectionTypes' => 'Equipment Inspection Types',
'EquipmentAttributes' => 'Equipment Attributes',
]];

42
Theme/Backend/Lang/de.lang.php Executable file
View File

@ -0,0 +1,42 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\Localization
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
return ['EquipmentManagement' => [
'Equipment' => 'Equipment',
'Equipments' => 'Equipment',
'Status' => 'Status',
'Name' => 'Name',
'Type' => 'Typ',
'Make' => 'Marke',
'Model' => 'Modell',
'Start' => 'Start',
'End' => 'Ende',
'Profile' => 'Profile',
'Attributes' => 'Attribute',
'Files' => 'Dateien',
'Notes' => 'Notizen',
'Costs' => 'Kosten',
'Inspections' => 'Inspectionen',
'Ein' => 'Ein',
'History' => 'Historie',
'Upcoming' => 'Upcoming',
'Responsible' => 'Verantwortlich',
'Date' => 'Datum',
'PurchasePrice' => 'Kaufpreis',
'LeasingFee' => 'Leasingkosten',
':status1' => 'Aktiv',
':status2' => 'Inaktiv',
':status3' => 'Beschädigt',
':status4' => 'Außer Betrieb',
]];

42
Theme/Backend/Lang/en.lang.php Executable file
View File

@ -0,0 +1,42 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\Localization
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
return ['EquipmentManagement' => [
'Equipment' => 'Equipment',
'Equipments' => 'Equipments',
'Status' => 'Status',
'Name' => 'Name',
'Type' => 'Type',
'Make' => 'Make',
'Model' => 'Model',
'Start' => 'Start',
'End' => 'End',
'Profile' => 'Profile',
'Attributes' => 'Attributes',
'Files' => 'Files',
'Notes' => 'Notes',
'Costs' => 'Costs',
'Inspections' => 'Inspections',
'Ein' => 'Ein',
'History' => 'History',
'Upcoming' => 'Upcoming',
'Responsible' => 'Responsible',
'Date' => 'Date',
'PurchasePrice' => 'Purchase Price',
'LeasingFee' => 'Leasing Fee',
':status1' => 'Active',
':status2' => 'Inactive',
':status3' => 'Damaged',
':status4' => 'Out of order',
]];

View 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="lni lni-download download btn end-xs"></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 fa fa-chevron-up"></i>
</label>
<label for="iAttributeTypeList-sort-2">
<input type="radio" name="iAttributeTypeList-sort" id="iAttributeTypeList-sort-2">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></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 fa fa-chevron-up"></i>
</label>
<label for="iAttributeTypeList-sort-3">
<input type="radio" name="iAttributeTypeList-sort" id="iAttributeTypeList-sort-3">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<tbody>
<?php
$count = 0;
foreach ($attributes as $key => $value) : ++$count;
$url = UriFactory::build('{/base}/fleet/equipment/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>

View File

@ -0,0 +1,98 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\Tasks
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
use Modules\Attribute\Models\AttributeValueType;
use phpOMS\Localization\ISO639Enum;
$types = AttributeValueType::getConstants();
$attribute = $this->data['attribute'];
$l11ns = $this->data['l11ns'];
echo $this->data['nav']->render(); ?>
<div class="row">
<div class="col-md-6 col-xs-12">
<section id="task" class="portlet">
<div class="portlet-head"><?= $this->getHtml('Attribute', 'Attribute', 'Backend'); ?></div>
<div class="portlet-body">
<div class="form-group">
<label for="iId"><?= $this->getHtml('ID', '0', '0'); ?></label>
<input type="text" value="<?= $this->printHtml((string) $attribute->id); ?>" disabled>
</div>
<div class="form-group">
<label for="iName"><?= $this->getHtml('Name', 'Attribute', 'Backend'); ?></label>
<input id="iNAme" type="text" value="<?= $this->printHtml($attribute->name); ?>" disabled>
</div>
<div class="form-group">
<label for="iType"><?= $this->getHtml('Datatype', 'Attribute', 'Backend'); ?></label>
<select id="iType" name="type" disabled>
<?php foreach ($types as $key => $type) : ?>
<option value="<?= $type; ?>"<?= $type === $attribute->datatype ? ' selected' : ''; ?>><?= $this->printHtml($key); ?>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label for="iPattern"><?= $this->getHtml('Pattern', 'Attribute', 'Backend'); ?></label>
<input id="iPattern" type="text" value="<?= $this->printHtml($attribute->validationPAttern); ?>">
</div>
<div class="form-group">
<label class="checkbox" for="iRequired">
<input id="iRequired" type="checkbox" name="required" value="1"<?= $attribute->isRequired ? ' checked' : ''; ?>>
<span class="checkmark"></span>
<?= $this->getHtml('IsRequired', 'Attribute', 'Backend'); ?>
</label>
</div>
<div class="form-group">
<label class="checkbox" for="iCustom">
<input id="iCustom" type="checkbox" name="custom" value="1" <?= $attribute->custom ? ' checked' : ''; ?>>
<span class="checkmark"></span>
<?= $this->getHtml('CustomValue', 'Attribute', 'Backend'); ?>
</label>
</div>
</div>
</section>
</div>
<div class="col-xs-12 col-md-6">
<div class="portlet">
<div class="portlet-head"><?= $this->getHtml('Language', '0', '0'); ?><i class="lni lni-download download btn end-xs"></i></div>
<table class="default">
<thead>
<tr>
<td>
<td>
<td><?= $this->getHtml('Language', '0', '0'); ?>
<td class="wf-100"><?= $this->getHtml('Title', 'Attribute', 'Backend'); ?>
<tbody>
<?php $c = 0; foreach ($l11ns as $key => $value) : ++$c; ?>
<tr>
<td><a href="#"><i class="fa fa-times"></i></a>
<td><a href="#"><i class="fa fa-cogs"></i></a>
<td><?= ISO639Enum::getByName('_' . \strtoupper($value->getLanguage())); ?>
<td><?= $value->content; ?>
<?php endforeach; ?>
<?php if ($c === 0) : ?>
<tr><td colspan="3" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</div>
</div>
</div>

View File

@ -0,0 +1,100 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\EquipmentManagement
* @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 */
$equipments = $this->data['equipments'] ?? [];
echo $this->data['nav']->render(); ?>
<div class="row">
<div class="col-xs-12">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Equipments'); ?><i class="lni lni-download download btn end-xs"></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 fa fa-chevron-up"></i>
</label>
<label for="iSalesClientList-sort-2">
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-2">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></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 fa fa-chevron-up"></i>
</label>
<label for="iSalesClientList-sort-4">
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-4">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></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 fa fa-chevron-up"></i>
</label>
<label for="iSalesClientList-sort-6">
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-6">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></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 fa fa-chevron-up"></i>
</label>
<label for="iSalesClientList-sort-8">
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-8">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<tbody>
<?php
$count = 0;
foreach ($equipments as $key => $value) :
++$count;
$url = UriFactory::build('{/base}/equipment/equipment/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>

View File

@ -0,0 +1,217 @@
<?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\EquipmentManagement\Models\EquipmentStatus;
use Modules\EquipmentManagement\Models\NullEquipment;
use Modules\Media\Models\NullMedia;
use phpOMS\Uri\UriFactory;
$countryCodes = \phpOMS\Localization\ISO3166TwoEnum::getConstants();
$countries = \phpOMS\Localization\ISO3166NameEnum::getConstants();
$equipmentStatus = EquipmentStatus::getConstants();
/**
* @var \Modules\EquipmentManagement\Models\Equipment $equipment
*/
$equipment = $this->data['equipment'] ?? new NullEquipment();
$files = $equipment->files;
$equipmentImage = $this->data['equipmentImage'] ?? new NullMedia();
$equipmentTypes = $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="iEquipmentEquipmentProfileName"><?= $this->getHtml('Name'); ?></label>
<input type="text" id="iEquipmentEquipmentProfileName" name="name" value="<?= $this->printHtml($equipment->name); ?>">
</div>
<div class="form-group">
<label for="iEquipmentDriver"><?= $this->getHtml('Driver'); ?></label>
<input type="text" id="iEquipmentDriver" name="driver" value="" disabled>
</div>
<div class="form-group">
<label for="iEquipmentEin"><?= $this->getHtml('EIN'); ?></label>
<input type="text" id="iEquipmentEin" name="vin" value="<?= $this->printHtml($equipment->getAttribute('vin')->value->getValue()); ?>">
</div>
<div class="form-group">
<label for="iEquipmentStatus"><?= $this->getHtml('Status'); ?></label>
<select id="iEquipmentStatus" name="equipment_status">
<?php foreach ($equipmentStatus as $status) : ?>
<option value="<?= $status; ?>"<?= $status === $equipment->status ? ' selected' : ''; ?>><?= $this->getHtml(':status' . $status); ?>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label for="iEquipmentEnd"><?= $this->getHtml('Type'); ?></label>
<select id="iEquipmentEnd" name="equipment_type">
<?php foreach ($equipmentTypes as $type) : ?>
<option value="<?= $type->id; ?>"<?= $equipment->type->id === $type->id ? ' selected' : ''; ?>><?= $this->printHtml($type->getL11n()); ?>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label for="iEquipmentMake"><?= $this->getHtml('Make'); ?></label>
<input type="text" id="iEquipmentMake" name="make" value="<?= $this->printHtml($equipment->getAttribute('maker')->value->getValue()); ?>">
</div>
<div class="form-group">
<label for="iEquipmentModel"><?= $this->getHtml('Model'); ?></label>
<input type="text" id="iEquipmentModel" name="equipment_model" value="<?= $this->printHtml($equipment->getAttribute('equipment_model')->value->getValue()); ?>">
</div>
<div class="form-group">
<label for="iEquipmentStart"><?= $this->getHtml('Start'); ?></label>
<input type="datetime-local" id="iEquipmentStart" name="ownership_start" value="<?= $equipment->getAttribute('ownership_start')->value->getValue()?->format('Y-m-d\TH:i') ?? $equipment->createdAt->format('Y-m-d\TH:i'); ?>">
</div>
<div class="form-group">
<label for="iEquipmentEnd"><?= $this->getHtml('End'); ?></label>
<input type="datetime-local" id="iEquipmentEnd" name="ownership_end" value="<?= $equipment->getAttribute('ownership_end')->value->getValue()?->format('Y-m-d\TH:i'); ?>">
</div>
<div class="form-group">
<label for="iEquipmentPrice"><?= $this->getHtml('PurchasePrice'); ?></label>
<input type="number" step="0.01" id="iEquipmentPrice" name="purchase_price" value="<?= $this->printHtml($equipment->getAttribute('purchase_price')->value->getValue()); ?>">
</div>
<div class="form-group">
<label for="iEquipmentPrice"><?= $this->getHtml('LeasingFee'); ?></label>
<input type="number" step="0.01" id="iEquipmentPrice" name="leasing_fee" value="<?= $this->printHtml($equipment->getAttribute('leasing_fee')->value->getValue()); ?>">
</div>
</div>
<div class="portlet-foot">
<?php if ($equipment->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="<?= $equipmentImage->id === 0
? 'Web/Backend/img/logo_grey.png'
: UriFactory::build($equipmentImage->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(
$equipment->attributes,
$this->data['attributeTypes'] ?? [],
$this->data['units'] ?? [],
'{/api}fleet/equipment/attribute'
);
?>
</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('equipment-file', 'files', '', $equipment->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['equipment-notes']->render('equipment-notes', '', $equipment->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('{/app}/fleet/inspection/create?equipment=' . $equipment->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">
<thead>
<tr>
<td><?= $this->getHtml('Date'); ?>
<td class="wf-100"><?= $this->getHtml('Type'); ?>
<td><?= $this->getHtml('Responsible'); ?>
<tbody>
<tr>
<td>
<td>
<td>
</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">
<thead>
<tr>
<td><?= $this->getHtml('Date'); ?>
<td class="wf-100"><?= $this->getHtml('Type'); ?>
<td><?= $this->getHtml('Responsible'); ?>
<tbody>
<tr>
<td>
<td>
<td>
</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>

23
composer.json Executable file
View File

@ -0,0 +1,23 @@
{
"name": "karaka/module",
"description": "Module for Jingga.",
"authors": [
{
"name": "Dennis Eichhorn",
"email": "spl1nes.com@googlemail.com"
}
],
"require-dev": {
"phpunit/phpunit": ">=9.4",
"friendsofphp/php-cs-fixer": ">=3.8",
"squizlabs/php_codesniffer": ">=3.6",
"phpmd/phpmd": ">=2.9",
"phpstan/phpstan": ">=1.8.6",
"phan/phan": ">=3.2.6",
"phploc/phploc": ">=7.0",
"phpmetrics/phpmetrics": ">=2.8",
"rector/rector": ">=0.18.0"
},
"minimum-stability": "dev",
"prefer-stable": true
}

4856
composer.lock generated Executable file

File diff suppressed because it is too large Load Diff

49
info.json Executable file
View File

@ -0,0 +1,49 @@
{
"name": {
"id": 1008400000,
"internal": "EquipmentManagement",
"external": "Equipment Management"
},
"category": "Equipment",
"version": "1.0.0",
"requirements": {
"phpOMS": "1.0.0",
"phpOMS-db": "1.0.0"
},
"creator": {
"name": "Jingga",
"website": "jingga.app"
},
"description": "The buisness module.",
"directory": "EquipmentManagement",
"dependencies": {
"Admin": "1.0.0",
"Profile": "1.0.0",
"Media": "1.0.0",
"Editor": "1.0.0"
},
"providing": {
"Navigation": "*",
"Media": "*"
},
"load": [
{
"pid": [
"/equipment"
],
"type": 4,
"for": 0,
"from": "EquipmentManagement",
"file": "EquipmentManagement"
},
{
"pid": [
"/"
],
"type": 5,
"from": "EquipmentManagement",
"for": "Navigation",
"file": "Navigation"
}
]
}

27
tests/Admin/AdminTest.php Executable file
View File

@ -0,0 +1,27 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\tests\Admin;
/**
* @internal
*/
final class AdminTest extends \PHPUnit\Framework\TestCase
{
protected const NAME = 'EquipmentManagement';
protected const URI_LOAD = 'http://127.0.0.1/en/backend/equipment';
use \tests\Modules\ModuleTestTrait;
}

111
tests/Autoloader.php Executable file
View File

@ -0,0 +1,111 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules/tests
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\tests;
\spl_autoload_register('\Modules\EquipmentManagement\tests\Autoloader::defaultAutoloader');
/**
* Autoloader class.
*
* @package tests
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
final class Autoloader
{
/**
* Base paths for autoloading
*
* @var string[]
* @since 1.0.0
*/
private static $paths = [
__DIR__ . '/../',
__DIR__ . '/../MainRepository/',
__DIR__ . '/../../',
];
/**
* Constructor.
*
* @since 1.0.0
* @codeCoverageIgnore
*/
private function __construct()
{
}
/**
* Add base path for autoloading
*
* @param string $path Absolute base path with / at the end
*
* @return void
*
* @since 1.0.0
*/
public static function addPath(string $path) : void
{
self::$paths[] = \rtrim($path, '/\\') . '/';
}
/**
* Loading classes by namespace + class name.
*
* @param string $class Class path
*
* @example Autoloader::defaultAutoloader('\phpOMS\Autoloader') // void
*
* @return void
*
* @since 1.0.0
*/
public static function defaultAutoloader(string $class) : void
{
$class = \ltrim($class, '\\');
$class = \strtr($class, '_\\', '//');
if (\stripos($class, 'Web/Backend') !== false || \stripos($class, 'Web/Api') !== false) {
$class = \is_dir(__DIR__ . '/Web') ? $class : \str_replace('Web/', 'Karaka/Web/', $class);
}
$class2 = $class;
$class3 = $class;
$pos = \stripos($class, '/');
if ($pos !== false) {
$class3 = \substr($class, $pos + 1);
$pos = \stripos($class, '/', $pos + 1);
if ($pos !== false) {
$class2 = \substr($class, $pos + 1);
}
}
foreach (self::$paths as $path) {
if (($file = \realpath($path . $class2 . '.php')) !== false && \stripos($file, $class3) !== false) {
include_once $file;
return;
} elseif (\is_file($file = $path . $class . '.php')) {
include_once $file;
return;
}
}
}
}

490
tests/Bootstrap.php Executable file
View File

@ -0,0 +1,490 @@
<?php
declare(strict_types=1);
\ini_set('memory_limit', '2048M');
\ini_set('display_errors', '1');
\ini_set('display_startup_errors', '1');
\error_reporting(\E_ALL);
\setlocale(\LC_ALL, 'en_US.UTF-8');
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/Autoloader.php';
use phpOMS\DataStorage\Database\DatabasePool;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
use phpOMS\DataStorage\Session\HttpSession;
use phpOMS\Log\FileLogger;
$IS_GITHUB = false;
$temp = \array_keys($_SERVER);
foreach ($temp as $key) {
if (\is_string($key) && \stripos(\strtolower($key), 'github') !== false) {
$IS_GITHUB = true;
break;
}
}
if (!$IS_GITHUB) {
foreach ($_SERVER as $value) {
if (\is_string($value) && \stripos(\strtolower($value), 'github') !== false) {
$IS_GITHUB = true;
break;
}
}
}
$temp = \array_keys(\getenv());
if (!$IS_GITHUB) {
foreach ($temp as $key) {
if (\is_string($key) && \stripos(\strtolower($key), 'github') !== false) {
$IS_GITHUB = true;
break;
}
}
}
$temp = \array_values(\getenv());
if (!$IS_GITHUB) {
foreach ($temp as $value) {
if (\is_string($value) && \stripos(\strtolower($value), 'github') !== false) {
$IS_GITHUB = true;
break;
}
}
}
$GLOBALS['is_github'] = $IS_GITHUB;
// Initialize file logger with correct path
$tmp = FileLogger::getInstance(__DIR__ . '/../Logs');
$CONFIG = [
'db' => [
'core' => [
'masters' => [
'admin' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
'login' => 'root', /* db login name */
'password' => 'root', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'insert' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
'login' => 'root', /* db login name */
'password' => 'root', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'select' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
'login' => 'root', /* db login name */
'password' => 'root', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'update' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
'login' => 'root', /* db login name */
'password' => 'root', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'delete' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
'login' => 'root', /* db login name */
'password' => 'root', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'schema' => [
'db' => 'mysql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '3306', /* db host port */
'login' => 'root', /* db login name */
'password' => 'root', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
],
'postgresql' => [
'admin' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
'login' => 'postgres', /* db login name */
'password' => 'root', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'insert' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
'login' => 'postgres', /* db login name */
'password' => 'root', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'select' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
'login' => 'postgres', /* db login name */
'password' => 'root', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'update' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
'login' => 'postgres', /* db login name */
'password' => 'root', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'delete' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
'login' => 'postgres', /* db login name */
'password' => 'root', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'schema' => [
'db' => 'pgsql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '5432', /* db host port */
'login' => 'postgres', /* db login name */
'password' => 'root', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
],
'sqlite' => [
'admin' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'insert' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'select' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'update' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'delete' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'schema' => [
'db' => 'sqlite', /* db type */
'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
],
'mssql' => [
'admin' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
'login' => 'sa', /* db login name */
'password' => 'c0MplicatedP@ssword', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'insert' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
'login' => 'sa', /* db login name */
'password' => 'c0MplicatedP@ssword', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'select' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
'login' => 'sa', /* db login name */
'password' => 'c0MplicatedP@ssword', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'update' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
'login' => 'sa', /* db login name */
'password' => 'c0MplicatedP@ssword', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'delete' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
'login' => 'sa', /* db login name */
'password' => 'c0MplicatedP@ssword', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
'schema' => [
'db' => 'mssql', /* db type */
'host' => '127.0.0.1', /* db host address */
'port' => '1433', /* db host port */
'login' => 'sa', /* db login name */
'password' => 'c0MplicatedP@ssword', /* db login password */
'database' => 'oms', /* db name */
'weight' => 1000, /* db table prefix */
'datetimeformat' => 'Y-m-d H:i:s',
],
],
],
],
'cache' => [
'redis' => [
'db' => 1,
'host' => '127.0.0.1',
'port' => 6379,
],
'memcached' => [
'host' => '127.0.0.1',
'port' => 11211,
],
],
'mail' => [
'imap' => [
'host' => '127.0.0.1',
'port' => 143,
'ssl' => false,
'user' => 'test',
'password' => '123456',
],
'pop3' => [
'host' => '127.0.0.1',
'port' => 25,
'ssl' => false,
'user' => 'test',
'password' => '123456',
],
],
'log' => [
'file' => [
'path' => __DIR__ . '/Logs',
],
],
'page' => [
'root' => '/',
'https' => false,
],
'app' => [
'path' => __DIR__,
'default' => [
'app' => 'Backend',
'id' => 'backend',
'lang' => 'en',
'theme' => 'Backend',
'org' => 1,
],
'domains' => [
'127.0.0.1' => [
'app' => 'Backend',
'id' => 'backend',
'lang' => 'en',
'theme' => 'Backend',
'org' => 1,
],
],
],
'socket' => [
'master' => [
'host' => '127.0.0.1',
'limit' => 300,
'port' => 4310,
],
],
'language' => [
'en',
],
'apis' => [
],
];
// Reset database
if (\defined('RESET') && RESET === '1') {
if (\extension_loaded('pdo_mysql')) {
try {
$db = new \PDO('mysql:host=' .
$CONFIG['db']['core']['masters']['admin']['host'],
$CONFIG['db']['core']['masters']['admin']['login'],
$CONFIG['db']['core']['masters']['admin']['password']
);
$db->exec('DROP DATABASE IF EXISTS ' . $CONFIG['db']['core']['masters']['admin']['database']);
$db->exec('CREATE DATABASE IF NOT EXISTS ' . $CONFIG['db']['core']['masters']['admin']['database']);
$db = null;
} catch (\Throwable $_) {
echo "\nCouldn't connect to MYSQL DB\n";
}
}
if (\extension_loaded('pdo_pgsql')) {
try {
$db = new \PDO('pgsql:host=' .
$CONFIG['db']['core']['postgresql']['admin']['host'],
$CONFIG['db']['core']['postgresql']['admin']['login'],
$CONFIG['db']['core']['postgresql']['admin']['password']
);
$db->exec('DROP DATABASE IF EXISTS ' . $CONFIG['db']['core']['postgresql']['admin']['database']);
$db->exec('CREATE DATABASE ' . $CONFIG['db']['core']['postgresql']['admin']['database']);
$db = null;
} catch (\Throwable $_) {
echo "\nCouldn't connect to POSTGRESQL DB\n";
}
}
if (\extension_loaded('pdo_sqlsrv')) {
try {
$db = new \PDO('sqlsrv:Server=' .
$CONFIG['db']['core']['mssql']['admin']['host'],
$CONFIG['db']['core']['mssql']['admin']['login'],
$CONFIG['db']['core']['mssql']['admin']['password']
);
$db->exec('DROP DATABASE IF EXISTS ' . $CONFIG['db']['core']['mssql']['admin']['database']);
$db->exec('CREATE DATABASE ' . $CONFIG['db']['core']['mssql']['admin']['database']);
$db = null;
} catch (\Throwable $_) {
echo "\nCouldn't connect to MSSQL DB\n";
}
}
}
$httpSession = new HttpSession();
$GLOBALS['session'] = $httpSession;
$GLOBALS['dbpool'] = new DatabasePool();
$GLOBALS['dbpool']->create('admin', $CONFIG['db']['core']['masters']['admin']);
$GLOBALS['dbpool']->create('select', $CONFIG['db']['core']['masters']['select']);
$GLOBALS['dbpool']->create('insert', $CONFIG['db']['core']['masters']['insert']);
$GLOBALS['dbpool']->create('update', $CONFIG['db']['core']['masters']['update']);
$GLOBALS['dbpool']->create('delete', $CONFIG['db']['core']['masters']['delete']);
$GLOBALS['dbpool']->create('schema', $CONFIG['db']['core']['masters']['schema']);
DataMapperFactory::db($GLOBALS['dbpool']->get());
$GLOBALS['frameworkpath'] = '/phpOMS/';
function phpServe() : void
{
// OS detection
$isWindows = \stristr(\php_uname('s'), 'Windows') !== false;
// Command that starts the built-in web server
if ($isWindows) {
$command = \sprintf(
'wmic process call create "php -S %s:%d -t %s" | find "ProcessId"',
WEB_SERVER_HOST,
WEB_SERVER_PORT,
__DIR__ . '/../' . WEB_SERVER_DOCROOT
);
$killCommand = 'taskkill /f /pid ';
} else {
$command = \sprintf(
'php -S %s:%d -t %s >/dev/null 2>&1 & echo $!',
WEB_SERVER_HOST,
WEB_SERVER_PORT,
WEB_SERVER_DOCROOT
);
$killCommand = 'kill ';
}
// Execute the command and store the process ID
$output = [];
echo 'Starting server...' . \PHP_EOL;
echo \sprintf(' Current directory: %s', \getcwd()) . \PHP_EOL;
echo \sprintf(' %s', $command);
\exec($command, $output);
// Get PID
if ($isWindows) {
$pid = \explode('=', $output[0]);
$pid = \str_replace(' ', '', $pid[1]);
$pid = \str_replace(';', '', $pid);
} else {
$pid = (int) $output[0];
}
// Log
echo \sprintf(
' %s - Web server started on %s:%d with PID %d',
\date('r'),
WEB_SERVER_HOST,
WEB_SERVER_PORT,
$pid
) . \PHP_EOL;
// Kill the web server when the process ends
\register_shutdown_function(function() use ($killCommand, $pid) : void {
echo \PHP_EOL . 'Stopping server...' . \PHP_EOL;
echo \sprintf(' %s - Killing process with ID %d', \date('r'), $pid) . \PHP_EOL;
\exec($killCommand . $pid);
});
}
try {
\phpServe();
} catch(\Throwable $t) {
echo $t->getMessage();
}

View File

@ -0,0 +1,220 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\tests\Controller\Api;
use phpOMS\Localization\ISO3166TwoEnum;
use phpOMS\Localization\ISO639x1Enum;
use phpOMS\Message\Http\HttpRequest;
use phpOMS\Message\Http\HttpResponse;
use phpOMS\Message\Http\RequestStatusCode;
use phpOMS\Uri\HttpUri;
trait ApiControllerAttributeTrait
{
/**
* @covers Modules\EquipmentManagement\Controller\ApiEquipmentAttributeController
* @group module
*/
public function testApiEquipmentAttributeTypeCreate() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request->header->account = 1;
$request->setData('name', 'test_attribute');
$request->setData('title', 'EN:1');
$request->setData('language', ISO639x1Enum::_EN);
$this->attrModule->apiEquipmentAttributeTypeCreate($request, $response);
self::assertGreaterThan(0, $response->get('')['response']->id);
}
/**
* @covers Modules\EquipmentManagement\Controller\ApiEquipmentAttributeController
* @group module
*/
public function testApiEquipmentAttributeTypeL11nCreate() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request->header->account = 1;
$request->setData('title', 'DE:2');
$request->setData('type', '1');
$request->setData('language', ISO639x1Enum::_DE);
$this->attrModule->apiEquipmentAttributeTypeL11nCreate($request, $response);
self::assertGreaterThan(0, $response->get('')['response']->id);
}
/**
* @covers Modules\EquipmentManagement\Controller\ApiEquipmentAttributeController
* @group module
*/
public function testApiEquipmentAttributeValueIntCreate() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request->header->account = 1;
$request->setData('default', '1');
$request->setData('type', '1');
$request->setData('value', '1');
$request->setData('language', ISO639x1Enum::_DE);
$request->setData('country', ISO3166TwoEnum::_DEU);
$this->attrModule->apiEquipmentAttributeValueCreate($request, $response);
self::assertGreaterThan(0, $response->get('')['response']->id);
}
/**
* @covers Modules\EquipmentManagement\Controller\ApiEquipmentAttributeController
* @group module
*/
public function testApiEquipmentAttributeValueStrCreate() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request->header->account = 1;
$request->setData('type', '1');
$request->setData('value', '1');
$request->setData('language', ISO639x1Enum::_DE);
$request->setData('country', ISO3166TwoEnum::_DEU);
$this->attrModule->apiEquipmentAttributeValueCreate($request, $response);
self::assertGreaterThan(0, $response->get('')['response']->id);
}
/**
* @covers Modules\EquipmentManagement\Controller\ApiEquipmentAttributeController
* @group module
*/
public function testApiEquipmentAttributeValueFloatCreate() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request->header->account = 1;
$request->setData('type', '1');
$request->setData('value', '1.1');
$request->setData('language', ISO639x1Enum::_DE);
$request->setData('country', ISO3166TwoEnum::_DEU);
$this->attrModule->apiEquipmentAttributeValueCreate($request, $response);
self::assertGreaterThan(0, $response->get('')['response']->id);
}
/**
* @covers Modules\EquipmentManagement\Controller\ApiEquipmentAttributeController
* @group module
*/
public function testApiEquipmentAttributeValueDatCreate() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request->header->account = 1;
$request->setData('type', '1');
$request->setData('value', '2020-08-02');
$request->setData('language', ISO639x1Enum::_DE);
$request->setData('country', ISO3166TwoEnum::_DEU);
$this->attrModule->apiEquipmentAttributeValueCreate($request, $response);
self::assertGreaterThan(0, $response->get('')['response']->id);
}
/**
* @covers Modules\EquipmentManagement\Controller\ApiEquipmentAttributeController
* @group module
*/
public function testApiEquipmentAttributeCreate() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request->header->account = 1;
$request->setData('ref', '1');
$request->setData('value', '1');
$request->setData('type', '1');
$this->attrModule->apiEquipmentAttributeCreate($request, $response);
self::assertGreaterThan(0, $response->get('')['response']->id);
}
/**
* @covers Modules\EquipmentManagement\Controller\ApiEquipmentAttributeController
* @group module
*/
public function testApiEquipmentAttributeValueCreateInvalidData() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request->header->account = 1;
$request->setData('invalid', '1');
$this->attrModule->apiEquipmentAttributeValueCreate($request, $response);
self::assertEquals(RequestStatusCode::R_400, $response->header->status);
}
/**
* @covers Modules\EquipmentManagement\Controller\ApiEquipmentAttributeController
* @group module
*/
public function testApiEquipmentAttributeTypeCreateInvalidData() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request->header->account = 1;
$request->setData('invalid', '1');
$this->attrModule->apiEquipmentAttributeTypeCreate($request, $response);
self::assertEquals(RequestStatusCode::R_400, $response->header->status);
}
/**
* @covers Modules\EquipmentManagement\Controller\ApiEquipmentAttributeController
* @group module
*/
public function testApiEquipmentAttributeTypeL11nCreateInvalidData() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request->header->account = 1;
$request->setData('invalid', '1');
$this->attrModule->apiEquipmentAttributeTypeL11nCreate($request, $response);
self::assertEquals(RequestStatusCode::R_400, $response->header->status);
}
/**
* @covers Modules\EquipmentManagement\Controller\ApiEquipmentAttributeController
* @group module
*/
public function testApiEquipmentAttributeCreateInvalidData() : void
{
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request->header->account = 1;
$request->setData('invalid', '1');
$this->attrModule->apiEquipmentAttributeCreate($request, $response);
self::assertEquals(RequestStatusCode::R_400, $response->header->status);
}
}

View File

@ -0,0 +1,50 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\tests\Controller\Api;
use Modules\EquipmentManagement\Models\EquipmentTypeMapper;
use phpOMS\Message\Http\HttpRequest;
use phpOMS\Message\Http\HttpResponse;
use phpOMS\Message\Http\RequestStatusCode;
use phpOMS\Uri\HttpUri;
use phpOMS\Utils\TestUtils;
use phpOMS\Utils\RnG\Text;
trait ApiControllerEquipmentTrait
{
/**
* @covers Modules\EquipmentManagement\Controller\ApiEquipmentController
* @group module
*/
public function testApiEquipmentCreate() : void
{
$equipmentType = EquipmentTypeMapper::getAll()->execute();
$equipmentTypeCount = \count($equipmentType);
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$LOREM = \array_slice(Text::LOREM_IPSUM, 0, 25);
$LOREM_COUNT = \count($LOREM) - 1;
$request->header->account = 1;
$request->setData('name', \ucfirst(Text::LOREM_IPSUM[\mt_rand(0, $LOREM_COUNT - 1)]));
$request->setData('type', \mt_rand(1, $equipmentTypeCount));
$request->setData('status', 1);
$this->module->apiEquipmentCreate($request, $response);
self::assertGreaterThan(0, $response->get('')['response']->id);
}
}

View File

@ -0,0 +1,99 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\tests\Controller;
use Model\CoreSettings;
use Modules\Admin\Models\AccountPermission;
use Modules\EquipmentManagement\tests\Controller\Api\ApiControllerAttributeTrait;
use Modules\EquipmentManagement\tests\Controller\Api\ApiControllerEquipmentTrait;
use phpOMS\Account\Account;
use phpOMS\Account\AccountManager;
use phpOMS\Account\PermissionType;
use phpOMS\Application\ApplicationAbstract;
use phpOMS\DataStorage\Session\HttpSession;
use phpOMS\Dispatcher\Dispatcher;
use phpOMS\Event\EventManager;
use phpOMS\Localization\L11nManager;
use phpOMS\Module\ModuleAbstract;
use phpOMS\Module\ModuleManager;
use phpOMS\Router\WebRouter;
use phpOMS\Utils\TestUtils;
/**
* @testdox Modules\EquipmentManagement\tests\Controller\ApiControllerTest: EquipmentManagement api controller
*
* @internal
*/
final class ApiControllerTest extends \PHPUnit\Framework\TestCase
{
protected ApplicationAbstract $app;
/**
* @var \Modules\EquipmentManagement\Controller\ApiController
*/
protected ModuleAbstract $module;
protected ModuleAbstract $attrModule;
/**
* {@inheritdoc}
*/
protected function setUp() : void
{
$this->app = new class() extends ApplicationAbstract
{
protected string $appName = 'Api';
};
$this->app->dbPool = $GLOBALS['dbpool'];
$this->app->unitId = 1;
$this->app->accountManager = new AccountManager($GLOBALS['session']);
$this->app->appSettings = new CoreSettings();
$this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../../Modules/');
$this->app->dispatcher = new Dispatcher($this->app);
$this->app->eventManager = new EventManager($this->app->dispatcher);
$this->app->eventManager->importFromFile(__DIR__ . '/../../../../Web/Api/Hooks.php');
$this->app->sessionManager = new HttpSession(36000);
$this->app->l11nManager = new L11nManager();
$account = new Account();
TestUtils::setMember($account, 'id', 1);
$permission = new AccountPermission();
$permission->unit = 1;
$permission->app = 2;
$permission->setPermission(
PermissionType::READ
| PermissionType::CREATE
| PermissionType::MODIFY
| PermissionType::DELETE
| PermissionType::PERMISSION
);
$account->addPermission($permission);
$this->app->accountManager->add($account);
$this->app->router = new WebRouter();
$this->module = $this->app->moduleManager->get('EquipmentManagement', 'ApiEquipment');
$this->attrModule = $this->app->moduleManager->get('EquipmentManagement', 'ApiEquipmentAttribute');
TestUtils::setMember($this->module, 'app', $this->app);
TestUtils::setMember($this->attrModule, 'app', $this->app);
}
use ApiControllerEquipmentTrait;
use ApiControllerAttributeTrait;
}

20
tests/Models/Vehicle.php Executable file
View File

@ -0,0 +1,20 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\ClientManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\EquipmentManagement\Models;
class Equipment
{
public int $id = 0;
}

58
tests/phpunit_default.xml Executable file
View File

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="Bootstrap.php" colors="true" columns="120" stopOnError="true" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" beStrictAboutTestsThatDoNotTestAnything="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage includeUncoveredFiles="true" processUncoveredFiles="false">
<include>
<directory suffix=".php">../</directory>
</include>
<exclude>
<directory>../vendor*</directory>
<directory>../MainRepository*</directory>
<directory>../Admin/Install/Application*</directory>
<directory>../phpOMS*</directory>
<directory>../tests*</directory>
<directory>../*/tests*</directory>
<directory>../**/tests*</directory>
<directory>*/tests*</directory>
<directory suffix="tpl.php">../*</directory>
<directory suffix="lang.php">../*</directory>
<directory suffix="Test.php">../*</directory>
<directory suffix="Routes.php">../*</directory>
<directory suffix="Hooks.php">../*</directory>
<directory>../**/test*</directory>
<directory>../**/Theme*</directory>
<directory>../**/Admin/Routes*</directory>
<directory>../**/Admin/Hooks*</directory>
<directory>../**/Admin/Install*</directory>
<directory>../Media/Files*</directory>
</exclude>
<report>
<clover outputFile="coverage.xml"/>
<html outputDirectory="../tests" lowUpperBound="75" highLowerBound="95"/>
</report>
</coverage>
<testsuites>
<testsuite name="Install">
<directory>../MainRepository/Install/tests*</directory>
</testsuite>
<testsuite name="Module">
<directory>../tests*</directory>
</testsuite>
</testsuites>
<groups>
<exclude>
<group>volume</group>
<group>maybe</group>
</exclude>
</groups>
<logging>
<junit outputFile="../tests/junit_php.xml"/>
<testdoxHtml outputFile="../tests/index.html"/>
<testdoxText outputFile="../tests/testdox.txt"/>
</logging>
<php>
<const name="WEB_SERVER_HOST" value="localhost"/>
<const name="WEB_SERVER_PORT" value="1234"/>
<const name="WEB_SERVER_DOCROOT" value="./Karaka"/>
<const name="RESET" value="1"/>
</php>
</phpunit>