From dc59b704ebeb5ca82079b0100caea540b1ed3d19 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 17 Apr 2024 17:45:07 +0000 Subject: [PATCH] fix templates --- Admin/Install/db.json | 13 ++- Admin/Routes/Web/Backend.php | 12 +-- Controller/BackendController.php | 54 ++++++++++- Models/Machine.php | 45 +++++++++ Models/MachineMapper.php | 84 ++++++++++++++++ Models/NullMachine.php | 47 +++++++++ Models/NullProduction.php | 28 ++++++ Models/Production.php | 54 +++++++++++ Models/ProductionStatus.php | 36 +++++++ Theme/Backend/Lang/de.lang.php | 8 ++ Theme/Backend/Lang/en.lang.php | 9 ++ Theme/Backend/machine-list.tpl.php | 87 +++++++++++++++++ Theme/Backend/machine-view.tpl.php | 124 ++++++++++++++++++++++++ Theme/Backend/production-create.tpl.php | 18 ---- Theme/Backend/production-list.tpl.php | 19 ++-- Theme/Backend/production-view.tpl.php | 108 +++++++++++++++++++++ 16 files changed, 706 insertions(+), 40 deletions(-) create mode 100644 Models/Machine.php create mode 100644 Models/MachineMapper.php create mode 100644 Models/NullMachine.php create mode 100644 Models/NullProduction.php create mode 100644 Models/Production.php create mode 100644 Models/ProductionStatus.php create mode 100644 Theme/Backend/machine-list.tpl.php create mode 100644 Theme/Backend/machine-view.tpl.php delete mode 100644 Theme/Backend/production-create.tpl.php create mode 100644 Theme/Backend/production-view.tpl.php diff --git a/Admin/Install/db.json b/Admin/Install/db.json index 36c72c9..12332d8 100644 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -12,12 +12,21 @@ "production_machine_capacity": { "name": "production_machine_capacity", "type": "BIGINT", + "null": true, + "default": null + }, + "production_machine_unitmeasure": { + "name": "production_machine_unitmeasure", + "type": "VARCHAR(16)", "null": false }, "production_machine_unit": { "name": "production_machine_unit", - "type": "VARCHAR(16)", - "null": false + "type": "INT", + "null": true, + "default": null, + "foreignTable": "unit", + "foreignKey": "unit_id" }, "production_machine_equipment": { "name": "production_machine_equipment", diff --git a/Admin/Routes/Web/Backend.php b/Admin/Routes/Web/Backend.php index 4599fec..f1f130c 100644 --- a/Admin/Routes/Web/Backend.php +++ b/Admin/Routes/Web/Backend.php @@ -68,19 +68,19 @@ return [ ], '^/production/machine/view(\?.*$|$)' => [ [ - 'dest' => '\Modules\Production\Controller\BackendController:viewProductionMachineCreate', + 'dest' => '\Modules\Production\Controller\BackendController:viewProductionMachineView', 'verb' => RouteVerb::GET, 'active' => true, 'permission' => [ 'module' => BackendController::MODULE_NAME, - 'type' => PermissionType::CREATE, + 'type' => PermissionType::READ, 'state' => PermissionState::MACHINE, ], ], ], '^/production/recipe/list(\?.*$|$)' => [ [ - 'dest' => '\Modules\Production\Controller\BackendController:viewProductionMachineList', + 'dest' => '\Modules\Production\Controller\BackendController:viewProductionRecipeList', 'verb' => RouteVerb::GET, 'active' => true, 'permission' => [ @@ -92,7 +92,7 @@ return [ ], '^/production/recipe/create(\?.*$|$)' => [ [ - 'dest' => '\Modules\Production\Controller\BackendController:viewProductionMachineCreate', + 'dest' => '\Modules\Production\Controller\BackendController:viewProductionRecipeCreate', 'verb' => RouteVerb::GET, 'active' => true, 'permission' => [ @@ -104,12 +104,12 @@ return [ ], '^/production/recipe/view(\?.*$|$)' => [ [ - 'dest' => '\Modules\Production\Controller\BackendController:viewProductionMachineCreate', + 'dest' => '\Modules\Production\Controller\BackendController:viewProductionRecipeView', 'verb' => RouteVerb::GET, 'active' => true, 'permission' => [ 'module' => BackendController::MODULE_NAME, - 'type' => PermissionType::CREATE, + 'type' => PermissionType::READ, 'state' => PermissionState::RECIPE, ], ], diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 9bbbd9e..61da468 100644 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -14,6 +14,7 @@ declare(strict_types=1); namespace Modules\Production\Controller; +use Modules\Production\Models\MachineMapper; use phpOMS\Contract\RenderableInterface; use phpOMS\Message\RequestAbstract; use phpOMS\Message\ResponseAbstract; @@ -68,6 +69,57 @@ final class BackendController extends Controller $view->setTemplate('/Modules/Production/Theme/Backend/machine-list'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1004303001, $request, $response); + $view->data['machines'] = MachineMapper::getAll() + ->with('equipment') + ->executeGetArray(); + + return $view; + } + + /** + * Routing end-point for application behavior. + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param array $data Generic data + * + * @return RenderableInterface + * + * @since 1.0.0 + * @codeCoverageIgnore + */ + public function viewProductionMachineView(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface + { + $view = new View($this->app->l11nManager, $request, $response); + $view->setTemplate('/Modules/Production/Theme/Backend/machine-view'); + $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1004303001, $request, $response); + + $view->data['machine'] = MachineMapper::get() + ->with('equipment') + ->where('id', (int) $request->getData('id')) + ->execute(); + + return $view; + } + + /** + * Routing end-point for application behavior. + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param array $data Generic data + * + * @return RenderableInterface + * + * @since 1.0.0 + * @codeCoverageIgnore + */ + public function viewProductionMachineCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface + { + $view = new View($this->app->l11nManager, $request, $response); + $view->setTemplate('/Modules/Production/Theme/Backend/machine-view'); + $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1004303001, $request, $response); + return $view; } @@ -86,7 +138,7 @@ final class BackendController extends Controller public function viewProductionCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface { $view = new View($this->app->l11nManager, $request, $response); - $view->setTemplate('/Modules/Production/Theme/Backend/production-create'); + $view->setTemplate('/Modules/Production/Theme/Backend/production-view'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1004303001, $request, $response); return $view; diff --git a/Models/Machine.php b/Models/Machine.php new file mode 100644 index 0000000..0c2d6e1 --- /dev/null +++ b/Models/Machine.php @@ -0,0 +1,45 @@ +equipment = new NullEquipment(); + } +} diff --git a/Models/MachineMapper.php b/Models/MachineMapper.php new file mode 100644 index 0000000..894062f --- /dev/null +++ b/Models/MachineMapper.php @@ -0,0 +1,84 @@ + + */ +final class MachineMapper extends DataMapperFactory +{ + /** + * Columns. + * + * @var array + * @since 1.0.0 + */ + public const COLUMNS = [ + 'production_machine_id' => ['name' => 'production_machine_id', 'type' => 'int', 'internal' => 'id'], + 'production_machine_capacity' => ['name' => 'production_machine_capacity', 'type' => 'int', 'internal' => 'capacity'], + 'production_machine_equipment' => ['name' => 'production_machine_equipment', 'type' => 'int', 'internal' => 'equipment'], + 'production_machine_unitmeasure' => ['name' => 'production_machine_unitmeasure', 'type' => 'string', 'internal' => 'unitOfMeasure'], + 'production_machine_unit' => ['name' => 'production_machine_unit', 'type' => 'int', 'internal' => 'unit'], + 'production_machine_created_at' => ['name' => 'production_machine_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true], + ]; + + /** + * Has one relation. + * + * @var array + * @since 1.0.0 + */ + public const OWNS_ONE = [ + 'equipment' => [ + 'mapper' => EquipmentMapper::class, + 'external' => 'production_machine_equipment', + ], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + public const TABLE = 'production_machine'; + + /** + * Created at. + * + * @var string + * @since 1.0.0 + */ + public const CREATED_AT = 'production_machine_created_at'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + public const PRIMARYFIELD = 'production_machine_id'; +} diff --git a/Models/NullMachine.php b/Models/NullMachine.php new file mode 100644 index 0000000..6e596fc --- /dev/null +++ b/Models/NullMachine.php @@ -0,0 +1,47 @@ +id = $id; + parent::__construct(); + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() : mixed + { + return ['id' => $this->id]; + } +} diff --git a/Models/NullProduction.php b/Models/NullProduction.php new file mode 100644 index 0000000..178f463 --- /dev/null +++ b/Models/NullProduction.php @@ -0,0 +1,28 @@ +createdAt = new \DateTimeImmutable('now'); + $this->item = new NullItem(); + } +} diff --git a/Models/ProductionStatus.php b/Models/ProductionStatus.php new file mode 100644 index 0000000..009a988 --- /dev/null +++ b/Models/ProductionStatus.php @@ -0,0 +1,36 @@ + [ 'Due' => 'Fällig', 'For' => 'Für', 'Name' => 'Name', + 'Items' => 'Artikel', 'Ordered' => 'Bestellt', 'Orderer' => 'Besteller', 'Process' => 'Prozess', 'Product' => 'Product', 'Productions' => 'Produktionen', 'Quantity' => 'Menge', + 'Machines' => 'Maschinen', + 'Machine' => 'Maschine', 'Start' => 'Start', 'Status' => 'Status', + 'Number' => 'Nummer', + 'Item' => 'Artikel', + 'ExpectedEnd' => 'Erwartete Fertigstellung', + 'Bill' => 'Beleg', + 'Production' => 'Produktion', ]]; diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php index 6ffe4b1..a81c07b 100644 --- a/Theme/Backend/Lang/en.lang.php +++ b/Theme/Backend/Lang/en.lang.php @@ -17,12 +17,21 @@ return ['Production' => [ 'Due' => 'Due', 'For' => 'For', 'Name' => 'Name', + 'Items' => 'Items', + 'Item' => 'Item', 'Ordered' => 'Ordered', 'Orderer' => 'Orderer', 'Process' => 'Process', 'Product' => 'Product', 'Productions' => 'Productions', + 'Production' => 'Production', 'Quantity' => 'Quantity', 'Start' => 'Start', + 'Machines' => 'Machines', + 'Machine' => 'Machine', 'Status' => 'Status', + 'Number' => 'Number', + 'Item' => 'Item', + 'ExpectedEnd' => 'Expected End', + 'Bill' => 'Bill', ]]; diff --git a/Theme/Backend/machine-list.tpl.php b/Theme/Backend/machine-list.tpl.php new file mode 100644 index 0000000..9283ffb --- /dev/null +++ b/Theme/Backend/machine-list.tpl.php @@ -0,0 +1,87 @@ +data['machines'] ?? []; + +echo $this->data['nav']->render(); ?> +
+
+
+
getHtml('Machines'); ?>download
+
+ + + + + $value) : + ++$count; + $url = UriFactory::build('{/base}/production/machine/view?{?}&id=' . $value->equipment->id); + ?> + +
+ getHtml('ID', '0', '0'); ?> + + + + getHtml('Status'); ?> + + + + getHtml('Name'); ?> + + + +
+ equipment->id; ?> + getHtml(':status' . $value->equipment->status); ?> + printHtml($value->equipment->name); ?> + + +
getHtml('Empty', '0', '0'); ?> + +
+
+
+
+
diff --git a/Theme/Backend/machine-view.tpl.php b/Theme/Backend/machine-view.tpl.php new file mode 100644 index 0000000..44ff93d --- /dev/null +++ b/Theme/Backend/machine-view.tpl.php @@ -0,0 +1,124 @@ +data['machine'] ?? new NullMachine(); +$machineImage = $this->data['machineImage'] ?? new NullMedia(); +$isNew = $machine->id === 0; + +$equipmentStatus = EquipmentStatus::getConstants(); + +/** + * @var \phpOMS\Views\View $this + */ +echo $this->data['nav']->render(); +?> +
+ +
+ +
+ +
+ request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>> +
+
+
+
+
getHtml('Machine'); ?>
+
+
+ + +
+ +
+ + +
+ +
+ + > +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+
+ equipment->id === 0) : ?> + + + + +
+
+
+ +
+
+
+ +
+
+
+
+
+ + + request->uri->fragment === 'c-tab-2' ? ' checked' : ''; ?>> +
+ +
+ +
+
\ No newline at end of file diff --git a/Theme/Backend/production-create.tpl.php b/Theme/Backend/production-create.tpl.php deleted file mode 100644 index 1a528aa..0000000 --- a/Theme/Backend/production-create.tpl.php +++ /dev/null @@ -1,18 +0,0 @@ -l11nManager, $this->request, $this->response); -$footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig'); - -$footerView->setPages(25); -$footerView->setPage(1); -$footerView->setResults(1); - echo $this->data['nav']->render(); ?>
@@ -35,25 +28,25 @@ echo $this->data['nav']->render(); ?> getHtml('Status'); ?> getHtml('ID', '0', '0'); ?> - getHtml('ID', '0', '0'); ?> getHtml('Article'); ?> getHtml('Quantity'); ?> getHtml('Start'); ?> getHtml('Due'); ?> getHtml('Done'); ?> - $value) : ++$c; - $url = \phpOMS\Uri\UriFactory::build('{/prefix}business/department/view?{?}&id=' . $value->id); ?> + $value) : ++$c; + $url = \phpOMS\Uri\UriFactory::build('{/prefix}/production/machine/view?{?}&id=' . $value->id); ?> id; ?> printHtml($value->getName()); ?> printHtml($value->getParent()); ?> printHtml($value->getUnit()); ?> - - + + getHtml('Empty', '0', '0'); ?> - +
diff --git a/Theme/Backend/production-view.tpl.php b/Theme/Backend/production-view.tpl.php new file mode 100644 index 0000000..f15e5f0 --- /dev/null +++ b/Theme/Backend/production-view.tpl.php @@ -0,0 +1,108 @@ +data['production'] ?? new NullProduction(); +$isNew = $production->id === 0; + +echo $this->data['nav']->render(); ?> +
+ +
+ +
+ +
+ request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>> +
+ +
+
+ +
+
+
+ + +
+
+
+ +
+
+ + +
+
+
getHtml('Production'); ?>
+
+
+ + +
+ + +
+ + +
+ + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+
+ + + + + +
+
+
+
+
+
+
+
\ No newline at end of file