bug fixes and item management improvements

This commit is contained in:
Dennis Eichhorn 2023-05-24 18:11:37 +00:00
parent 3e5edd87a5
commit 00e6c42c80
8 changed files with 197 additions and 54 deletions

View File

@ -58,9 +58,7 @@ jsOMS.Modules.ClientManagement = class {
return; return;
} }
const self = this; const mapObj = new OpenLayers.Map(map.getAttribute('id'), {
map = new OpenLayers.Map(map.getAttribute('id'), {
controls: [ controls: [
new OpenLayers.Control.Navigation( new OpenLayers.Control.Navigation(
{ {
@ -73,14 +71,19 @@ jsOMS.Modules.ClientManagement = class {
] ]
}); });
var mapnik = new OpenLayers.Layer.OSM(); mapObj.addLayer(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); const fromProjection = new OpenLayers.Projection("EPSG:4326"); // Transform from WGS 1984
map.setCenter(position, zoom ); 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);
}; };
}; };

View File

@ -38,6 +38,7 @@ use Modules\Media\Models\MediaMapper;
use Modules\Media\Models\PathSettings; use Modules\Media\Models\PathSettings;
use Modules\Organization\Models\UnitMapper; use Modules\Organization\Models\UnitMapper;
use phpOMS\Api\EUVAT\EUVATVies; use phpOMS\Api\EUVAT\EUVATVies;
use phpOMS\Api\Geocoding\Nominatim;
use phpOMS\Localization\BaseStringL11n; use phpOMS\Localization\BaseStringL11n;
use phpOMS\Localization\BaseStringL11nType; use phpOMS\Localization\BaseStringL11nType;
use phpOMS\Localization\ISO3166CharEnum; use phpOMS\Localization\ISO3166CharEnum;
@ -229,6 +230,15 @@ final class ApiController extends Controller
$addr->city = $request->getDataString('city') ?? ''; $addr->city = $request->getDataString('city') ?? '';
$addr->setCountry($request->getDataString('country') ?? ISO3166TwoEnum::_XXX); $addr->setCountry($request->getDataString('country') ?? ISO3166TwoEnum::_XXX);
$addr->state = $request->getDataString('state') ?? ''; $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->mainAddress = $addr;
$client->unit = $request->getDataInt('unit'); $client->unit = $request->getDataInt('unit');

View File

@ -158,12 +158,8 @@ final class BackendController extends Controller
/** @var \Modules\ClientManagement\Models\Client $client */ /** @var \Modules\ClientManagement\Models\Client $client */
$client = ClientMapper::getAll() $client = ClientMapper::getAll()
->with('account') ->with('account')
->with('files')
->with('files/type')
->with('mainAddress') ->with('mainAddress')
->where('files/type/name', 'client_profile_image')
->limit(25) ->limit(25)
->limit(1, 'files/type')
->execute(); ->execute();
$view->addData('client', $client); $view->addData('client', $client);
@ -209,7 +205,7 @@ final class BackendController extends Controller
$head = $response->get('Content')->getData('head'); $head = $response->get('Content')->getData('head');
$head->addAsset(AssetType::CSS, 'Resources/chartjs/Chartjs/chart.css'); $head->addAsset(AssetType::CSS, 'Resources/chartjs/Chartjs/chart.css');
$head->addAsset(AssetType::JSLATE, 'Resources/chartjs/Chartjs/chart.js'); $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']); $head->addAsset(AssetType::JSLATE, 'Modules/ClientManagement/Controller.js', ['type' => 'module']);
$view = new View($this->app->l11nManager, $request, $response); $view = new View($this->app->l11nManager, $request, $response);

View File

@ -33,20 +33,68 @@ use Modules\Profile\Models\Profile;
*/ */
class Client class Client
{ {
/**
* ID value.
*
* @var int
* @since 1.0.0
*/
public int $id = 0; public int $id = 0;
/**
* Number value.
*
* @var string
* @since 1.0.0
*/
public string $number = ''; public string $number = '';
/**
* Reversed number value.
*
* @var string
* @since 1.0.0
*/
public string $numberReverse = ''; public string $numberReverse = '';
/**
* Status value.
*
* @var int
* @since 1.0.0
*/
public int $status = ClientStatus::ACTIVE; public int $status = ClientStatus::ACTIVE;
/**
* Type value.
*
* @var int
* @since 1.0.0
*/
public int $type = 0; public int $type = 0;
/**
* Additional information.
*
* @var string
* @since 1.0.0
*/
public string $info = ''; public string $info = '';
/**
* Creation date and time.
*
* @var \DateTimeImmutable
* @since 1.0.0
*/
public \DateTimeImmutable $createdAt; public \DateTimeImmutable $createdAt;
/**
* Account associated with the client.
*
* @var Account
* @since 1.0.0
*/
public Account $account; public Account $account;
/** /**
@ -65,20 +113,68 @@ class Client
*/ */
private array $notes = []; private array $notes = [];
/**
* Contact elements.
*
* @var array
* @since 1.0.0
*/
private array $contactElements = []; private array $contactElements = [];
/**
* Main address.
*
* @var Address
* @since 1.0.0
*/
public Address $mainAddress; public Address $mainAddress;
/**
* Address.
*
* @var array
* @since 1.0.0
*/
private array $address = []; private array $address = [];
/**
* Partners.
*
* @var array
* @since 1.0.0
*/
private array $partners = []; private array $partners = [];
/**
* Sales representative.
*
* @var Profile|null
* @since 1.0.0
*/
public ?Profile $salesRep = null; public ?Profile $salesRep = null;
/**
* Advertisement material.
*
* @var int
* @since 1.0.0
*/
public int $advertisementMaterial = 0; public int $advertisementMaterial = 0;
/**
* Default delivery address.
*
* @var Address|null
* @since 1.0.0
*/
public ?Address $defaultDeliveryAddress = null; public ?Address $defaultDeliveryAddress = null;
/**
* Default invoice address.
*
* @var Address|null
* @since 1.0.0
*/
public ?Address $defaultInvoiceAddress = null; public ?Address $defaultInvoiceAddress = null;
/** /**

View File

@ -15,6 +15,7 @@ declare(strict_types=1);
return ['ClientManagement' => [ return ['ClientManagement' => [
'AttributeTypes' => 'Attribute Types', 'AttributeTypes' => 'Attribute Types',
'Accounting' => 'Accounting', 'Accounting' => 'Accounting',
'Map' => 'Map',
'Addition' => 'Addition', 'Addition' => 'Addition',
'Address' => 'Address', 'Address' => 'Address',
'Addresses' => 'Addresses', 'Addresses' => 'Addresses',

View File

@ -12,8 +12,11 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
use Modules\Attribute\Models\AttributeValueType;
use phpOMS\Localization\ISO639Enum; use phpOMS\Localization\ISO639Enum;
$types = AttributeValueType::getConstants();
$attribute = $this->getData('attribute'); $attribute = $this->getData('attribute');
$l11ns = $this->getData('l11ns'); $l11ns = $this->getData('l11ns');
@ -22,17 +25,47 @@ echo $this->getData('nav')->render(); ?>
<div class="row"> <div class="row">
<div class="col-md-6 col-xs-12"> <div class="col-md-6 col-xs-12">
<section id="task" class="portlet"> <section id="task" class="portlet">
<div class="portlet-head"><?= $this->getHtml('Attribute'); ?></div> <div class="portlet-head"><?= $this->getHtml('Attribute', 'Attribute', 'Backend'); ?></div>
<div class="portlet-body"> <div class="portlet-body">
<div class="form-group"> <div class="form-group">
<label for="iId"><?= $this->getHtml('ID'); ?></label> <label for="iId"><?= $this->getHtml('ID', '0', '0'); ?></label>
<input type="text" value="<?= $this->printHtml((string) $attribute->id); ?>" disabled> <input type="text" value="<?= $this->printHtml((string) $attribute->id); ?>" disabled>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="iName"><?= $this->getHtml('Name'); ?></label> <label for="iName"><?= $this->getHtml('Name', 'Attribute', 'Backend'); ?></label>
<input type="text" value="<?= $this->printHtml($attribute->name); ?>" disabled> <input id="iNAme" type="text" value="<?= $this->printHtml($attribute->name); ?>" disabled>
</div>
<div class="form-group">
<label for="iType"><?= $this->getHtml('Datatype', 'Attribute', 'Backend'); ?></label>
<select id="iType" name="type" disabled>
<?php foreach ($types as $key => $type) : ?>
<option value="<?= $type; ?>"<?= $type === $attribute->datatype ? ' selected' : ''; ?>><?= $this->printHtml($key); ?>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label for="iPattern"><?= $this->getHtml('Pattern', 'Attribute', 'Backend'); ?></label>
<input id="iPattern" type="text" value="<?= $this->printHtml($attribute->validationPAttern); ?>">
</div>
<div class="form-group">
<label class="checkbox" for="iRequired">
<input id="iRequired" type="checkbox" name="required" value="1"<?= $attribute->isRequired ? ' checked' : ''; ?>>
<span class="checkmark"></span>
<?= $this->getHtml('IsRequired', 'Attribute', 'Backend'); ?>
</label>
</div>
<div class="form-group">
<label class="checkbox" for="iCustom">
<input id="iCustom" type="checkbox" name="custom" value="1" <?= $attribute->custom ? ' checked' : ''; ?>>
<span class="checkmark"></span>
<?= $this->getHtml('CustomValue', 'Attribute', 'Backend'); ?>
</label>
</div> </div>
</div> </div>
</section> </section>
@ -47,7 +80,7 @@ echo $this->getData('nav')->render(); ?>
<td> <td>
<td> <td>
<td><?= $this->getHtml('Language', '0', '0'); ?> <td><?= $this->getHtml('Language', '0', '0'); ?>
<td class="wf-100"><?= $this->getHtml('Title'); ?> <td class="wf-100"><?= $this->getHtml('Title', 'Attribute', 'Backend'); ?>
<tbody> <tbody>
<?php $c = 0; foreach ($l11ns as $key => $value) : ++$c; ?> <?php $c = 0; foreach ($l11ns as $key => $value) : ++$c; ?>
<tr> <tr>

View File

@ -28,7 +28,6 @@ echo $this->getData('nav')->render(); ?>
<table id="iSalesClientList" class="default sticky"> <table id="iSalesClientList" class="default sticky">
<thead> <thead>
<tr> <tr>
<td>
<td><?= $this->getHtml('ID', '0', '0'); ?> <td><?= $this->getHtml('ID', '0', '0'); ?>
<label for="iSalesClientList-sort-1"> <label for="iSalesClientList-sort-1">
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-1"> <input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-1">
@ -107,10 +106,6 @@ echo $this->getData('nav')->render(); ?>
$image = $value->getFileByTypeName('client_profile_image'); $image = $value->getFileByTypeName('client_profile_image');
?> ?>
<tr data-href="<?= $url; ?>"> <tr data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><img alt="<?= $this->getHtml('IMG_alt_client'); ?>" width="30" loading="lazy" class="item-image"
src="<?= $image->id === 0
? 'Web/Backend/img/logo_grey.png'
: UriFactory::build('{/base}/' . $image->getPath()); ?>"></a>
<td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->number); ?></a> <td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->number); ?></a>
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->account->name1); ?> <?= $this->printHtml($value->account->name2); ?></a> <td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->account->name1); ?> <?= $this->printHtml($value->account->name2); ?></a>
<td data-label="<?= $this->getHtml('City'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->mainAddress->city); ?></a> <td data-label="<?= $this->getHtml('City'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->mainAddress->city); ?></a>

View File

@ -145,15 +145,25 @@ echo $this->getData('nav')->render();
<tr><td><input type="text" id="iName1" name="name1" value="<?= $this->printHtml($client->mainAddress->city); ?>" required> <tr><td><input type="text" id="iName1" name="name1" value="<?= $this->printHtml($client->mainAddress->city); ?>" required>
<tr><td><label for="iName1"><?= $this->getHtml('Country'); ?></label> <tr><td><label for="iName1"><?= $this->getHtml('Country'); ?></label>
<tr><td><select name="country"> <tr><td><select name="country">
<?php foreach ($countryCodes as $code3 => $code2) : ?> <?php foreach ($countryCodes as $code3 => $code2) : ?>
<option value="<?= $this->printHtml($code2); ?>"<?= $this->printHtml($code2 === $client->mainAddress->getCountry() ? ' selected' : ''); ?>><?= $this->printHtml($countries[$code3]); ?> <option value="<?= $this->printHtml($code2); ?>"<?= $this->printHtml($code2 === $client->mainAddress->getCountry() ? ' selected' : ''); ?>><?= $this->printHtml($countries[$code3]); ?>
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
<tr><td><div id="clientMap" class="map"></div> <tr><td><label for="iName1"><?= $this->getHtml('Map'); ?></label>
<tr><td><div id="clientMap" class="map" data-lat="<?= $client->mainAddress->lat; ?>" data-lon="<?= $client->mainAddress->lon; ?>"></div>
</table> </table>
</div> </div>
</section> </section>
<section class="portlet">
<div class="portlet-body">
<img alt="<?= $this->printHtml($clientImage->name); ?>" width="100%" loading="lazy" class="item-image"
src="<?= $clientImage->id === 0
? 'Web/Backend/img/logo_grey.png'
: UriFactory::build($clientImage->getPath()); ?>">
</div>
</section>
<section class="portlet highlight-4"> <section class="portlet highlight-4">
<div class="portlet-body"> <div class="portlet-body">
<textarea class="undecorated"><?= $this->printHtml($client->info); ?></textarea> <textarea class="undecorated"><?= $this->printHtml($client->info); ?></textarea>
@ -284,7 +294,7 @@ echo $this->getData('nav')->render();
<td><a href="<?= $url; ?>"><?= $invoice->getNumber(); ?></a> <td><a href="<?= $url; ?>"><?= $invoice->getNumber(); ?></a>
<td><a href="<?= $url; ?>"><?= $invoice->type->getL11n(); ?></a> <td><a href="<?= $url; ?>"><?= $invoice->type->getL11n(); ?></a>
<td><a href="<?= $url; ?>"><?= $invoice->billTo; ?></a> <td><a href="<?= $url; ?>"><?= $invoice->billTo; ?></a>
<td><a href="<?= $url; ?>"><?= $invoice->netSales->getCurrency(); ?></a> <td><a href="<?= $url; ?>"><?= $this->getCurrency($invoice->netSales); ?></a>
<td><a href="<?= $url; ?>"><?= $invoice->createdAt->format('Y-m-d'); ?></a> <td><a href="<?= $url; ?>"><?= $invoice->createdAt->format('Y-m-d'); ?></a>
<?php endforeach; ?> <?php endforeach; ?>
</table> </table>
@ -329,7 +339,7 @@ echo $this->getData('nav')->render();
?> ?>
<?= \implode(',', $temp); ?> <?= \implode(',', $temp); ?>
], ],
"yAxisID": "axis-2", "yAxisID": "axis2",
"fill": false, "fill": false,
"borderColor": "rgb(255, 99, 132)", "borderColor": "rgb(255, 99, 132)",
"backgroundColor": "rgb(255, 99, 132)" "backgroundColor": "rgb(255, 99, 132)"
@ -341,43 +351,42 @@ echo $this->getData('nav')->render();
<?php <?php
$temp = []; $temp = [];
foreach ($monthlySalesCosts as $monthly) { foreach ($monthlySalesCosts as $monthly) {
$temp[] = ((int) $monthly['net_sales']) / 1000; $temp[] = (float) (((int) $monthly['net_sales']) / 1000);
} }
?> ?>
<?= \implode(',', $temp); ?> <?= \implode(',', $temp); ?>
], ],
"yAxisID": "axis-1", "yAxisID": "axis1",
"backgroundColor": "rgb(54, 162, 235)" "backgroundColor": "rgb(54, 162, 235)"
} }
] ]
}, },
"options": { "options": {
"responsive": true,
"scales": { "scales": {
"yAxes": [ "axis1": {
{ "id": "axis1",
"id": "axis-1", "display": true,
"position": "left"
},
"axis2": {
"id": "axis2",
"display": true,
"position": "right",
"title": {
"display": true, "display": true,
"position": "left" "text": "<?= $this->getHtml('Margin'); ?> %"
}, },
{ "grid": {
"id": "axis-2", "display": false
"display": true, },
"position": "right", "beginAtZero": true,
"scaleLabel": { "ticks": {
"display": true, "min": 0,
"labelString": "<?= $this->getHtml('Margin'); ?> %" "max": 100,
}, "stepSize": 10
"gridLines": {
"display": false
},
"beginAtZero": true,
"ticks": {
"min": 0,
"max": 100,
"stepSize": 10
}
} }
] }
} }
} }
}'></canvas> }'></canvas>