From 1387d7a849b73ea264f5cb5c213f821888c2fd3e Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 2 Apr 2024 21:40:47 +0000 Subject: [PATCH] template fixes + bug fixes + style fixes --- Admin/Install/Media/layout01.php | 38 ++++++++++++++++++------------- Controller/BackendController.php | 25 ++++++++++++-------- Theme/Backend/Lang/en.lang.php | 3 +++ Theme/Backend/layout-item.tpl.php | 10 ++++++++ Theme/Backend/layout-view.tpl.php | 14 +++++++----- 5 files changed, 59 insertions(+), 31 deletions(-) diff --git a/Admin/Install/Media/layout01.php b/Admin/Install/Media/layout01.php index 5c8e4a7..e5a9db2 100644 --- a/Admin/Install/Media/layout01.php +++ b/Admin/Install/Media/layout01.php @@ -12,10 +12,12 @@ */ declare(strict_types=1); +use Modules\Admin\Models\ContactType; use Modules\Labeling\Models\Image; use Modules\Labeling\Models\Label; use Modules\Labeling\Models\Shape; use Modules\Labeling\Models\Text; +use phpOMS\Localization\ISO3166NameEnum; use phpOMS\Utils\Barcode\Datamatrix; use phpOMS\Utils\Barcode\QR; @@ -116,7 +118,7 @@ $text->y = 610 + $margin; $l->elements[] = $text; $text = new Text(); -$text->text = 'DE'; +$text->text = $unit->mainAddress->country; $text->size = 20; $text->x = $margin + 40; $text->y = 625 + $margin; @@ -179,28 +181,28 @@ $l->elements[] = $image; // address $text = new Text(); -$text->text = 'Jingga e. K.'; +$text->text = $unit->mainAddress->name; $text->size = 30; $text->x = 150 + $margin; $text->y = 710 + $margin; $l->elements[] = $text; $text = new Text(); -$text->text = 'Kirchstr. 33'; +$text->text = $unit->mainAddress->address; $text->size = 30; $text->x = 150 + $margin; $text->y = 760 + $margin; $l->elements[] = $text; $text = new Text(); -$text->text = '61191 Rosbach'; +$text->text = $unit->mainAddress->postal . ' ' . $unit->mainAddress->city; $text->size = 30; $text->x = 150 + $margin; $text->y = 810 + $margin; $l->elements[] = $text; $text = new Text(); -$text->text = 'Germany'; +$text->text = ISO3166NameEnum::getBy2Code($unit->mainAddress->country); $text->size = 30; $text->x = 150 + $margin; $text->y = 860 + $margin; @@ -208,21 +210,21 @@ $l->elements[] = $text; // contact $text = new Text(); -$text->text = 'www.jingga.app'; +$text->text = $unit->getContactByType(ContactType::WEBSITE)->content; $text->size = 30; $text->x = 600 + $margin; $text->y = 710 + $margin; $l->elements[] = $text; $text = new Text(); -$text->text = 'info@jingga.app'; +$text->text = $unit->getContactByType(ContactType::EMAIL)->content; $text->size = 30; $text->x = 600 + $margin; $text->y = 760 + $margin; $l->elements[] = $text; $text = new Text(); -$text->text = '+49 0123 456789'; +$text->text = $unit->getContactByType(ContactType::PHONE)->content; $text->size = 30; $text->x = 600 + $margin; $text->y = 810 + $margin; @@ -245,14 +247,18 @@ $text->y = 850 + $margin; $l->elements[] = $text; // qr -$qr = new QR('https://jingga.app', 200, 200); +$website = $unit->getContactByType(ContactType::WEBSITE)->content; +$website = empty($website) ? 'https://jingga.app' : $website; +if (!empty($website)) { + $qr = new QR($website, 200, 200); -$image = new Image(); -$image->resource = $qr->get(); -$image->x = 1620 + $margin; -$image->y = 680 + $margin; -$image->width = 180; -$image->height = 180; -$l->elements[] = $image; + $image = new Image(); + $image->resource = $qr->get(); + $image->x = 1620 + $margin; + $image->y = 680 + $margin; + $image->width = 180; + $image->height = 180; + $l->elements[] = $image; +} return $l; diff --git a/Controller/BackendController.php b/Controller/BackendController.php index f5f3bb9..07383a8 100644 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -16,6 +16,7 @@ namespace Modules\Labeling\Controller; use Modules\ItemManagement\Models\ItemMapper; use Modules\Labeling\Models\LabelLayoutMapper; +use Modules\Organization\Models\UnitMapper; use phpOMS\Contract\RenderableInterface; use phpOMS\DataStorage\Database\Query\Builder; use phpOMS\Message\RequestAbstract; @@ -59,7 +60,7 @@ final class BackendController extends Controller ->with('template') ->with('template/sources') ->where('l11n/language', $response->header->l11n->language) - ->execute(); + ->executeGetArray(); $view->data['layouts'] = $layouts; @@ -94,7 +95,7 @@ final class BackendController extends Controller ->where('l11n/type/title', ['name1', 'name2'], 'IN') ->where('files/types/name', 'item_profile_image') ->limit(50) - ->execute(); + ->executeGetArray(); $view->data['items'] = $items; @@ -119,31 +120,37 @@ final class BackendController extends Controller $view->setTemplate('/Modules/Labeling/Theme/Backend/layout-item'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1005701001, $request, $response); - $item = ItemMapper::get() + $view->data['item'] = ItemMapper::get() ->with('l11n') ->with('l11n/type') + ->with('attributes') + ->with('attributes/type') + ->with('attributes/value') ->where('id', (int) $request->getData('id')) ->where('l11n/language', $response->header->l11n->language) ->where('l11n/type/title', ['name1', 'name2'], 'IN') + ->where('attributes/type/name', ['gtin', 'eu_medical_device_class', 'fda_medical_regulatory_class', 'country_of_origin'], 'IN') ->execute(); - $view->data['item'] = $item; + $view->data['unit'] = UnitMapper::get() + ->with('parent') + ->with('mainAddress') + ->with('contacts') + ->where('id', $this->app->unitId) + ->execute(); $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() + $view->data['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; + ->executeGetArray(); return $view; } diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php index 441f56b..a53d133 100644 --- a/Theme/Backend/Lang/en.lang.php +++ b/Theme/Backend/Lang/en.lang.php @@ -13,4 +13,7 @@ declare(strict_types=1); return ['Labeling' => [ + 'Layouts' => 'Layouts', + 'Layout' => 'Layout', + 'Name' => 'Name', ]]; diff --git a/Theme/Backend/layout-item.tpl.php b/Theme/Backend/layout-item.tpl.php index abe48fa..d7f4779 100644 --- a/Theme/Backend/layout-item.tpl.php +++ b/Theme/Backend/layout-item.tpl.php @@ -20,6 +20,7 @@ $media = $layout->template; $template = \reset($media->sources); $item = $this->data['item']; +$unit = $this->data['unit']; $layout = include_once $template->getAbsolutePath(); @@ -41,4 +42,13 @@ $inlineImage = 'data:' . $imageType . ';base64,' . $imageBase64; Inline Image + + \ No newline at end of file diff --git a/Theme/Backend/layout-view.tpl.php b/Theme/Backend/layout-view.tpl.php index 3ba8715..750f32d 100644 --- a/Theme/Backend/layout-view.tpl.php +++ b/Theme/Backend/layout-view.tpl.php @@ -12,10 +12,16 @@ */ declare(strict_types=1); +use Modules\ItemManagement\Models\NullItem; + echo $this->data['nav']->render(); $layout = $this->data['layout']; +// Required by label +$item = new NullItem(); +$unit = null; + $media = $layout->template; $template = \reset($media->sources); @@ -33,10 +39,6 @@ $imageType = 'image/png'; // Assuming JPEG format in this example $inlineImage = 'data:' . $imageType . ';base64,' . $imageBase64; ?> -
-
-
- Inline Image -
-
+
+
\ No newline at end of file