diff --git a/Admin/Install/Media/layout01.php b/Admin/Install/Media/layout01.php index e37ce6f..57b0ca4 100644 --- a/Admin/Install/Media/layout01.php +++ b/Admin/Install/Media/layout01.php @@ -56,12 +56,12 @@ $image = new Image(); $image->src = '/Modules/Labeling/Theme/icons/iso/2493.png'; $image->x = $margin - 15; $image->y = 250 + $margin - 50; -$image->x2 = $image->x + 150; -$image->y2 = 75 + $image->y; +$image->width = 150; +$image->height = 150; $l->elements[] = $image; $text = new Text(); -$text->text = '0123-4567-8910'; +$text->text = $item->number; $text->size = 40; $text->x = 150 + $margin; $text->y = 290 + $margin; @@ -72,12 +72,12 @@ $image = new Image(); $image->src = '/Modules/Labeling/Theme/icons/iso/2492.png'; $image->x = $margin - 15; $image->y = 350 + $margin - 50; -$image->x2 = $image->x + 150; -$image->y2 = 75 + $image->y; +$image->width = 150; +$image->height = 150; $l->elements[] = $image; $text = new Text(); -$text->text = '0123-4567-8910'; +$text->text = 'LOT-4567-8910'; $text->size = 40; $text->x = 150 + $margin; $text->y = 390 + $margin; @@ -88,12 +88,12 @@ $image = new Image(); $image->src = '/Modules/Labeling/Theme/icons/iso/2498.png'; $image->x = $margin - 15; $image->y = 450 + $margin - 50; -$image->x2 = $image->x + 150; -$image->y2 = 75 + $image->y; +$image->width = 150; +$image->height = 150; $l->elements[] = $image; $text = new Text(); -$text->text = '0123-4567-8910'; +$text->text = 'SN-4567-8910'; $text->size = 40; $text->x = 150 + $margin; $text->y = 490 + $margin; @@ -104,8 +104,8 @@ $image = new Image(); $image->src = '/Modules/Labeling/Theme/icons/iso/2497.png'; $image->x = $margin - 15; $image->y = 560 + $margin - 50; -$image->x2 = $image->x + 150; -$image->y2 = 75 + $image->y; +$image->width = 150; +$image->height = 150; $l->elements[] = $image; $text = new Text(); @@ -127,8 +127,8 @@ $image = new Image(); $image->src = '/Modules/Labeling/Theme/icons/iso/2607.png'; $image->x = $margin + 500; $image->y = 540 + $margin; -$image->x2 = $image->x + 100; -$image->y2 = 75 + $image->y; +$image->width = 100; +$image->height = 110; $l->elements[] = $image; $text = new Text(); @@ -145,12 +145,12 @@ $image = new Image(); $image->resource = $qr->get(); $image->x = 1000 + $margin; $image->y = 280 + $margin - 50; -$image->x2 = $image->x + 200; -$image->y2 = 75 + $image->y; +$image->width = 200; +$image->height = 200; $l->elements[] = $image; $text = new Text(); -$text->text = "(01)00000000000000\n(11)000000\n(17)000000\n(10)A000B0\n(21)0000"; +$text->text = "(01)GTIN\n(11)YYYY-MM-DD\n(17)YYYY-MM-DD\n(10)LOT-4567-8910\n(21)SN-4567-8910"; $text->size = 40; $text->x = 1230 + $margin; $text->y = 280 + $margin; @@ -173,8 +173,8 @@ $image = new Image(); $image->src = '/Modules/Labeling/Theme/icons/iso/3082.png'; $image->x = $margin - 15; $image->y = 660 + $margin; -$image->x2 = $image->x + 150; -$image->y2 = 75 + $image->y; +$image->width = 150; +$image->height = 150; $l->elements[] = $image; // address @@ -231,10 +231,10 @@ $l->elements[] = $text; // ce $image = new Image(); $image->src = '/Modules/Labeling/Theme/icons/iso/ce_mark.png'; -$image->x = 1400 + $margin; +$image->x = 1430 + $margin; $image->y = 680 + $margin; -$image->x2 = $image->x + 200; -$image->y2 = 200 + $image->y; +$image->width = 150; +$image->height = 150; $l->elements[] = $image; $text = new Text(); @@ -251,8 +251,8 @@ $image = new Image(); $image->resource = $qr->get(); $image->x = 1620 + $margin; $image->y = 680 + $margin; -$image->x2 = $image->x + 180; -$image->y2 = 180 + $image->y; +$image->width = 180; +$image->height = 180; $l->elements[] = $image; return $l; diff --git a/Admin/Routes/Web/Backend.php b/Admin/Routes/Web/Backend.php index 474fd4a..68aa339 100644 --- a/Admin/Routes/Web/Backend.php +++ b/Admin/Routes/Web/Backend.php @@ -28,6 +28,17 @@ return [ ], ], ], + '^.*/warehouse/labeling/layout\?.*$' => [ + [ + 'dest' => '\Modules\Labeling\Controller\BackendController:viewLayout', + 'verb' => RouteVerb::GET, + 'permission' => [ + 'module' => BackendController::MODULE_NAME, + 'type' => PermissionType::READ, + 'state' => PermissionState::LABEL, + ], + ], + ], '^.*/warehouse/labeling/layout/list.*$' => [ [ 'dest' => '\Modules\Labeling\Controller\BackendController:viewItemLabelList', diff --git a/Controller/BackendController.php b/Controller/BackendController.php index a25e29d..c69e369 100644 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -17,6 +17,7 @@ namespace Modules\Labeling\Controller; use Modules\ItemManagement\Models\ItemMapper; use Modules\Labeling\Models\LabelLayoutMapper; use phpOMS\Contract\RenderableInterface; +use phpOMS\DataStorage\Database\Query\Builder; use phpOMS\Message\RequestAbstract; use phpOMS\Message\ResponseAbstract; use phpOMS\Views\View; @@ -32,7 +33,7 @@ use phpOMS\Views\View; final class BackendController extends Controller { /** - * Routing end-point for application behaviour. + * Routing end-point for application behavior. * * @param RequestAbstract $request Request * @param ResponseAbstract $response Response @@ -63,7 +64,7 @@ final class BackendController extends Controller } /** - * Routing end-point for application behaviour. + * Routing end-point for application behavior. * * @param RequestAbstract $request Request * @param ResponseAbstract $response Response @@ -98,7 +99,7 @@ final class BackendController extends Controller } /** - * Routing end-point for application behaviour. + * Routing end-point for application behavior. * * @param RequestAbstract $request Request * @param ResponseAbstract $response Response @@ -125,7 +126,44 @@ final class BackendController extends Controller $view->data['item'] = $item; - /** @var \Modules\Labeling\Models\LabelLayout[] $layout */ + $query = new Builder($this->app->dbPool->get()); + $results = $query->raw('SELECT labeling_layout_item_src FROM labeling_layout_item WHERE labeling_layout_item_dst = ' . ((int) $request->getData('id'))) + ->execute() + ?->fetchAll(\PDO::FETCH_COLUMN); + + /** @var \Modules\Labeling\Models\LabelLayout[] $layouts */ + $layouts = LabelLayoutMapper::getAll() + ->with('l11n') + ->with('template') + ->with('template/sources') + ->where('l11n/language', $response->header->l11n->language) + ->where('id', $results, 'IN') + ->execute(); + + $view->data['layouts'] = $layouts; + + 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 viewLayout(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface + { + $view = new View($this->app->l11nManager, $request, $response); + $view->setTemplate('/Modules/Labeling/Theme/Backend/layout-view'); + $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1005701001, $request, $response); + + /** @var \Modules\Labeling\Models\LabelLayout[] $layouts */ $layout = LabelLayoutMapper::get() ->with('l11n') ->with('template') diff --git a/Docs/Dev/en/SUMMARY.md b/Docs/Dev/en/SUMMARY.md new file mode 100644 index 0000000..8a97952 --- /dev/null +++ b/Docs/Dev/en/SUMMARY.md @@ -0,0 +1,3 @@ +# Developer Content + +* [Structure]({%}&page=Dev/structure) diff --git a/Docs/Dev/en/structure.md b/Docs/Dev/en/structure.md new file mode 100644 index 0000000..09fa746 --- /dev/null +++ b/Docs/Dev/en/structure.md @@ -0,0 +1,5 @@ +# Structure + +## ER + + \ No newline at end of file diff --git a/Docs/Dev/img/er.png b/Docs/Dev/img/er.png new file mode 100644 index 0000000..8466f32 Binary files /dev/null and b/Docs/Dev/img/er.png differ diff --git a/Docs/introduction.md b/Docs/introduction.md new file mode 100644 index 0000000..e10b99d --- /dev/null +++ b/Docs/introduction.md @@ -0,0 +1 @@ +# Introduction diff --git a/Models/Label.php b/Models/Label.php index 047facf..23e3371 100644 --- a/Models/Label.php +++ b/Models/Label.php @@ -133,9 +133,9 @@ class Label // should crop if ($element->x1 !== 0 || $element->x2 !== 0 || $element->y1 !== 0 || $element->y2 !== 0) { $cropped = \imagecrop($in, [ - 'x' => $element->x1, - 'y' => $element->y1, - 'width' => $element->x2 === 0 ? $srcW - $element->x1 : $element->x2 - $element->x1, + 'x' => $element->x1, + 'y' => $element->y1, + 'width' => $element->x2 === 0 ? $srcW - $element->x1 : $element->x2 - $element->x1, 'height' => $element->y2 === 0 ? $srcH - $element->y1 : $element->y2 - $element->y1, ]); @@ -175,8 +175,21 @@ class Label // should resize if ($element->ratio !== 0.0 || $element->width !== 0 || $element->height !== 0) { - $ratioX = $element->ratio === 0.0 ? ($element->width - $element->x) / $srcW : $element->ratio; - $ratioY = $element->ratio === 0.0 ? ($element->height - $element->y) / $srcH : $element->ratio; + $ratioX = $element->ratio === 0.0 ? $element->width / $srcW : $element->ratio; + $ratioY = $element->ratio === 0.0 ? $element->height / $srcH : $element->ratio; + + $ratioX = \abs($ratioX); + $ratioY = \abs($ratioY); + + if ($ratioX === 0.0) { + $ratioX = $ratioY; + } + + if ($ratioY === 0.0) { + $ratioY = $ratioX; + } + + // @todo handle use original width or height but resize height or width. $newW = (int) ($srcW * $ratioX); $newH = (int) ($srcH * $ratioY); diff --git a/Models/NullLabelLayout.php b/Models/NullLabelLayout.php new file mode 100644 index 0000000..ca75cf4 --- /dev/null +++ b/Models/NullLabelLayout.php @@ -0,0 +1,46 @@ +id = $id; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() : mixed + { + return ['id' => $this->id]; + } +} diff --git a/Models/PermissionState.php b/Models/PermissionState.php index 56ff55c..8fc638c 100644 --- a/Models/PermissionState.php +++ b/Models/PermissionState.php @@ -17,7 +17,7 @@ namespace Modules\Labeling\Models; use phpOMS\Stdlib\Base\Enum; /** - * Permision state enum. + * Permission category enum. * * @package Modules\Labeling\Models * @license OMS License 2.0 diff --git a/Theme/Backend/Lang/Navigation.de.lang.php b/Theme/Backend/Lang/Navigation.de.lang.php index a68c5be..9e3382a 100644 --- a/Theme/Backend/Lang/Navigation.de.lang.php +++ b/Theme/Backend/Lang/Navigation.de.lang.php @@ -15,4 +15,6 @@ declare(strict_types=1); return ['Navigation' => [ 'Labeling' => 'Etikettierung', 'List' => 'Liste', + 'Layouts' => 'Designs', + 'Name' => 'Name', ]]; diff --git a/Theme/Backend/Lang/Navigation.en.lang.php b/Theme/Backend/Lang/Navigation.en.lang.php index b30cb23..4424c3e 100644 --- a/Theme/Backend/Lang/Navigation.en.lang.php +++ b/Theme/Backend/Lang/Navigation.en.lang.php @@ -15,4 +15,6 @@ declare(strict_types=1); return ['Navigation' => [ 'Labeling' => 'Labeling', 'List' => 'List', + 'Layouts' => 'Layouts', + 'Name' => 'Name', ]]; diff --git a/Theme/Backend/layout-list.tpl.php b/Theme/Backend/layout-list.tpl.php index e69de29..12abc53 100644 --- a/Theme/Backend/layout-list.tpl.php +++ b/Theme/Backend/layout-list.tpl.php @@ -0,0 +1,72 @@ +data['layouts'] ?? []; + +echo $this->data['nav']->render(); ?> + +