From 00e6c42c80cfbad09cf7b74a9f3daeff579f9e33 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 24 May 2023 18:11:37 +0000 Subject: [PATCH] bug fixes and item management improvements --- Controller.js | 23 ++++--- Controller/ApiController.php | 10 +++ Controller/BackendController.php | 6 +- Models/Client.php | 96 ++++++++++++++++++++++++++++ Theme/Backend/Lang/en.lang.php | 1 + Theme/Backend/attribute-type.tpl.php | 43 +++++++++++-- Theme/Backend/client-list.tpl.php | 5 -- Theme/Backend/client-profile.tpl.php | 67 ++++++++++--------- 8 files changed, 197 insertions(+), 54 deletions(-) diff --git a/Controller.js b/Controller.js index 23060a8..1fa8e50 100755 --- a/Controller.js +++ b/Controller.js @@ -58,9 +58,7 @@ jsOMS.Modules.ClientManagement = class { return; } - const self = this; - - map = new OpenLayers.Map(map.getAttribute('id'), { + const mapObj = new OpenLayers.Map(map.getAttribute('id'), { controls: [ new OpenLayers.Control.Navigation( { @@ -73,14 +71,19 @@ jsOMS.Modules.ClientManagement = class { ] }); - 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; + mapObj.addLayer(new OpenLayers.Layer.OSM()); - map.addLayer(mapnik); - map.setCenter(position, zoom ); + const fromProjection = new OpenLayers.Projection("EPSG:4326"); // Transform from WGS 1984 + const toProjection = new OpenLayers.Projection("EPSG:900913"); // to Spherical Mercator Projection + const position = new OpenLayers.LonLat(map.getAttribute('data-lon'), map.getAttribute('data-lat')).transform(fromProjection, toProjection); + const zoom = 12; + + const markers = new OpenLayers.Layer.Markers("Markers"); + mapObj.addLayer(markers); + + markers.addMarker(new OpenLayers.Marker(position)); + + mapObj.setCenter(position, zoom); }; }; diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 742abd0..ac48886 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -38,6 +38,7 @@ use Modules\Media\Models\MediaMapper; use Modules\Media\Models\PathSettings; use Modules\Organization\Models\UnitMapper; use phpOMS\Api\EUVAT\EUVATVies; +use phpOMS\Api\Geocoding\Nominatim; use phpOMS\Localization\BaseStringL11n; use phpOMS\Localization\BaseStringL11nType; use phpOMS\Localization\ISO3166CharEnum; @@ -229,6 +230,15 @@ final class ApiController extends Controller $addr->city = $request->getDataString('city') ?? ''; $addr->setCountry($request->getDataString('country') ?? ISO3166TwoEnum::_XXX); $addr->state = $request->getDataString('state') ?? ''; + + $geocoding = Nominatim::geocoding($addr->country, $addr->city, $addr->address); + if ($geocoding === ['lat' => 0.0, 'lon' => 0.0]) { + $geocoding = Nominatim::geocoding($addr->country, $addr->city); + } + + $addr->lat = $geocoding['lat']; + $addr->lon = $geocoding['lon']; + $client->mainAddress = $addr; $client->unit = $request->getDataInt('unit'); diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 3569f32..78be63e 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -158,12 +158,8 @@ final class BackendController extends Controller /** @var \Modules\ClientManagement\Models\Client $client */ $client = ClientMapper::getAll() ->with('account') - ->with('files') - ->with('files/type') ->with('mainAddress') - ->where('files/type/name', 'client_profile_image') ->limit(25) - ->limit(1, 'files/type') ->execute(); $view->addData('client', $client); @@ -209,7 +205,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, 'Resources/OpenLayers/OpenLayers.js'); $head->addAsset(AssetType::JSLATE, 'Modules/ClientManagement/Controller.js', ['type' => 'module']); $view = new View($this->app->l11nManager, $request, $response); diff --git a/Models/Client.php b/Models/Client.php index 0184a36..83ffaaa 100755 --- a/Models/Client.php +++ b/Models/Client.php @@ -33,20 +33,68 @@ use Modules\Profile\Models\Profile; */ class Client { + /** + * ID value. + * + * @var int + * @since 1.0.0 + */ public int $id = 0; + /** + * Number value. + * + * @var string + * @since 1.0.0 + */ public string $number = ''; + /** + * Reversed number value. + * + * @var string + * @since 1.0.0 + */ public string $numberReverse = ''; + /** + * Status value. + * + * @var int + * @since 1.0.0 + */ public int $status = ClientStatus::ACTIVE; + /** + * Type value. + * + * @var int + * @since 1.0.0 + */ public int $type = 0; + /** + * Additional information. + * + * @var string + * @since 1.0.0 + */ public string $info = ''; + /** + * Creation date and time. + * + * @var \DateTimeImmutable + * @since 1.0.0 + */ public \DateTimeImmutable $createdAt; + /** + * Account associated with the client. + * + * @var Account + * @since 1.0.0 + */ public Account $account; /** @@ -65,20 +113,68 @@ class Client */ private array $notes = []; + /** + * Contact elements. + * + * @var array + * @since 1.0.0 + */ private array $contactElements = []; + /** + * Main address. + * + * @var Address + * @since 1.0.0 + */ public Address $mainAddress; + /** + * Address. + * + * @var array + * @since 1.0.0 + */ private array $address = []; + /** + * Partners. + * + * @var array + * @since 1.0.0 + */ private array $partners = []; + /** + * Sales representative. + * + * @var Profile|null + * @since 1.0.0 + */ public ?Profile $salesRep = null; + /** + * Advertisement material. + * + * @var int + * @since 1.0.0 + */ public int $advertisementMaterial = 0; + /** + * Default delivery address. + * + * @var Address|null + * @since 1.0.0 + */ public ?Address $defaultDeliveryAddress = null; + /** + * Default invoice address. + * + * @var Address|null + * @since 1.0.0 + */ public ?Address $defaultInvoiceAddress = null; /** diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php index 86ff07f..e90838d 100755 --- a/Theme/Backend/Lang/en.lang.php +++ b/Theme/Backend/Lang/en.lang.php @@ -15,6 +15,7 @@ declare(strict_types=1); return ['ClientManagement' => [ 'AttributeTypes' => 'Attribute Types', 'Accounting' => 'Accounting', + 'Map' => 'Map', 'Addition' => 'Addition', 'Address' => 'Address', 'Addresses' => 'Addresses', diff --git a/Theme/Backend/attribute-type.tpl.php b/Theme/Backend/attribute-type.tpl.php index c84c0bd..c8306c7 100755 --- a/Theme/Backend/attribute-type.tpl.php +++ b/Theme/Backend/attribute-type.tpl.php @@ -12,8 +12,11 @@ */ declare(strict_types=1); +use Modules\Attribute\Models\AttributeValueType; use phpOMS\Localization\ISO639Enum; +$types = AttributeValueType::getConstants(); + $attribute = $this->getData('attribute'); $l11ns = $this->getData('l11ns'); @@ -22,17 +25,47 @@ echo $this->getData('nav')->render(); ?>
-
getHtml('Attribute'); ?>
+
getHtml('Attribute', 'Attribute', 'Backend'); ?>
- +
- - + + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+ +
+
@@ -47,7 +80,7 @@ echo $this->getData('nav')->render(); ?> getHtml('Language', '0', '0'); ?> - getHtml('Title'); ?> + getHtml('Title', 'Attribute', 'Backend'); ?> $value) : ++$c; ?> diff --git a/Theme/Backend/client-list.tpl.php b/Theme/Backend/client-list.tpl.php index 2c8c63a..5b2d1d0 100755 --- a/Theme/Backend/client-list.tpl.php +++ b/Theme/Backend/client-list.tpl.php @@ -28,7 +28,6 @@ echo $this->getData('nav')->render(); ?> - -
getHtml('ID', '0', '0'); ?>
<?= $this->getHtml('IMG_alt_client'); ?> printHtml($value->number); ?> printHtml($value->account->name1); ?> printHtml($value->account->name2); ?> printHtml($value->mainAddress->city); ?> diff --git a/Theme/Backend/client-profile.tpl.php b/Theme/Backend/client-profile.tpl.php index bbdcd09..925adc2 100755 --- a/Theme/Backend/client-profile.tpl.php +++ b/Theme/Backend/client-profile.tpl.php @@ -145,15 +145,25 @@ echo $this->getData('nav')->render();
-
+
+
+
+
+ <?= $this->printHtml($clientImage->name); ?> +
+
+
@@ -284,7 +294,7 @@ echo $this->getData('nav')->render(); getNumber(); ?> type->getL11n(); ?> billTo; ?> - netSales->getCurrency(); ?> + getCurrency($invoice->netSales); ?> createdAt->format('Y-m-d'); ?> @@ -329,7 +339,7 @@ echo $this->getData('nav')->render(); ?> ], - "yAxisID": "axis-2", + "yAxisID": "axis2", "fill": false, "borderColor": "rgb(255, 99, 132)", "backgroundColor": "rgb(255, 99, 132)" @@ -341,43 +351,42 @@ echo $this->getData('nav')->render(); ], - "yAxisID": "axis-1", + "yAxisID": "axis1", "backgroundColor": "rgb(54, 162, 235)" } ] }, "options": { + "responsive": true, "scales": { - "yAxes": [ - { - "id": "axis-1", + "axis1": { + "id": "axis1", + "display": true, + "position": "left" + }, + "axis2": { + "id": "axis2", + "display": true, + "position": "right", + "title": { "display": true, - "position": "left" + "text": "getHtml('Margin'); ?> %" }, - { - "id": "axis-2", - "display": true, - "position": "right", - "scaleLabel": { - "display": true, - "labelString": "getHtml('Margin'); ?> %" - }, - "gridLines": { - "display": false - }, - "beginAtZero": true, - "ticks": { - "min": 0, - "max": 100, - "stepSize": 10 - } + "grid": { + "display": false + }, + "beginAtZero": true, + "ticks": { + "min": 0, + "max": 100, + "stepSize": 10 } - ] + } } } }'>