From b50b81bf6c6301bcb366939d2231b9d0fa560c5b Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 16 Apr 2023 01:55:34 +0200 Subject: [PATCH] fix demoSetup --- Controller.js | 60 ++++++++++++++++++---- Controller/BackendController.php | 1 + Theme/Backend/client-list.tpl.php | 8 +-- Theme/Backend/client-profile-items.tpl.php | 2 +- Theme/Backend/client-profile.tpl.php | 24 +++++---- 5 files changed, 70 insertions(+), 25 deletions(-) diff --git a/Controller.js b/Controller.js index 147206f..8361a00 100755 --- a/Controller.js +++ b/Controller.js @@ -1,10 +1,8 @@ import { Autoloader } from '../../jsOMS/Autoloader.js'; -import { NotificationMessage } from '../../jsOMS/Message/Notification/NotificationMessage.js'; -import { NotificationType } from '../../jsOMS/Message/Notification/NotificationType.js'; Autoloader.defineNamespace('jsOMS.Modules'); -jsOMS.Modules.ClientManager = class { +jsOMS.Modules.ClientManagement = class { /** * @constructor * @@ -17,24 +15,31 @@ jsOMS.Modules.ClientManager = class { bind (id) { - const e = typeof id === 'undefined' ? document.getElementsByTagName('canvas') : [document.getElementById(id)], - length = e.length; + const charts = typeof id === 'undefined' ? document.getElementsByTagName('canvas') : [document.getElementById(id)]; + let length = charts.length; for (let i = 0; i < length; ++i) { - if (e[i].getAttribute('data-chart') === null - && e[i].getAttribute('data-chart') !== 'undefined' + if (charts[i].getAttribute('data-chart') === null + && charts[i].getAttribute('data-chart') !== 'undefined' ) { continue; } - this.bindElement(e[i]); + this.bindChart(charts[i]); + } + + const maps = typeof id === 'undefined' ? document.getElementsByClassName('map') : [document.getElementById(id)]; + length = maps.length; + + for (let i = 0; i < length; ++i) { + this.bindMap(maps[i]); } }; - bindElement (chart) + bindChart (chart) { if (typeof chart === 'undefined' || !chart) { - jsOMS.Log.Logger.instance.error('Invalid chart: ' + chart, 'ClientManagementController'); + jsOMS.Log.Logger.instance.error('Invalid chart: ' + chart, 'ClientManagement'); return; } @@ -44,6 +49,39 @@ jsOMS.Modules.ClientManager = class { const myChart = new Chart(chart.getContext('2d'), data); }; + + bindMap (map) + { + if (typeof map === 'undefined' || !map) { + jsOMS.Log.Logger.instance.error('Invalid map: ' + map, 'ClientManager'); + + return; + } + + const self = this; + + map = new OpenLayers.Map(map.getAttribute('id'), { + controls: [ + new OpenLayers.Control.Navigation( + { + zoomBoxEnabled: true, + zoomWheelEnabled: false + } + ), + new OpenLayers.Control.Zoom(), + new OpenLayers.Control.Attribution() + ] + }); + + var mapnik = new OpenLayers.Layer.OSM(); + var fromProjection = new OpenLayers.Projection("EPSG:4326"); // Transform from WGS 1984 + var toProjection = new OpenLayers.Projection("EPSG:900913"); // to Spherical Mercator Projection + var position = new OpenLayers.LonLat(13.41,52.52).transform( fromProjection, toProjection); + var zoom = 15; + + map.addLayer(mapnik); + map.setCenter(position, zoom ); + }; }; -window.omsApp.moduleManager.get('ClientManager').bind(); +window.omsApp.moduleManager.get('ClientManagement').bind(); diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 28387a1..8ba826a 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -200,6 +200,7 @@ final class BackendController extends Controller $head = $response->get('Content')->getData('head'); $head->addAsset(AssetType::CSS, 'Resources/chartjs/Chartjs/chart.css'); $head->addAsset(AssetType::JSLATE, 'Resources/chartjs/Chartjs/chart.js'); + $head->addAsset(AssetType::JSLATE, 'Resources/OpenLayers/OpenLayers.light.js'); $head->addAsset(AssetType::JSLATE, 'Modules/ClientManagement/Controller.js', ['type' => 'module']); $view = new View($this->app->l11nManager, $request, $response); diff --git a/Theme/Backend/client-list.tpl.php b/Theme/Backend/client-list.tpl.php index f8205bc..886adab 100755 --- a/Theme/Backend/client-list.tpl.php +++ b/Theme/Backend/client-list.tpl.php @@ -108,11 +108,11 @@ echo $this->getData('nav')->render(); ?> ?> <?= $this->getHtml('IMG_alt_client'); ?> + src="getPath()); ?>"> printHtml($value->number); ?> - printHtml($value->profile->account->name1); ?> printHtml($value->profile->account->name2); ?> + printHtml($value->account->name1); ?> printHtml($value->account->name2); ?> printHtml($value->mainAddress->city); ?> printHtml($value->mainAddress->postal); ?> printHtml($value->mainAddress->address); ?> diff --git a/Theme/Backend/client-profile-items.tpl.php b/Theme/Backend/client-profile-items.tpl.php index bd7f5c9..f688dd7 100755 --- a/Theme/Backend/client-profile-items.tpl.php +++ b/Theme/Backend/client-profile-items.tpl.php @@ -144,7 +144,7 @@ $items = $this->getData('items') ?? []; printHtml($value->itemNumber); ?> printHtml($value->itemName); ?> - printHtml((string) $value->quantity); ?> + printHtml((string) $value->getQuantity()); ?> printHtml($value->singleSalesPriceNet->getCurrency()); ?> diff --git a/Theme/Backend/client-profile.tpl.php b/Theme/Backend/client-profile.tpl.php index 83bbab9..01cc17f 100755 --- a/Theme/Backend/client-profile.tpl.php +++ b/Theme/Backend/client-profile.tpl.php @@ -58,6 +58,15 @@ echo $this->getData('nav')->render();
+ +
@@ -95,7 +104,7 @@ echo $this->getData('nav')->render();
-
+
getHtml('Address'); ?> @@ -133,14 +142,11 @@ echo $this->getData('nav')->render(); - - mainAddress->getCountry()) . '.svg')) : ?> - <?= $this->getHtml('IMG_alt_map'); ?> - + $code2) : ?> +