diff --git a/Admin/Install/Media.install.json b/Admin/Install/Media.install.json
index a930b65..d1e52de 100755
--- a/Admin/Install/Media.install.json
+++ b/Admin/Install/Media.install.json
@@ -6,6 +6,13 @@
"virtualPath": "/Modules",
"user": 1
},
+ {
+ "type": "collection",
+ "create_directory": true,
+ "name": "Clients",
+ "virtualPath": "/Modules/ClientManagement",
+ "user": 1
+ },
{
"type": "type",
"name": "client_profile_image",
diff --git a/Admin/Install/attributes.json b/Admin/Install/attributes.json
index bc5bb08..6fe98d6 100755
--- a/Admin/Install/attributes.json
+++ b/Admin/Install/attributes.json
@@ -245,7 +245,7 @@
{ "value": "FI" },
{ "value": "FR" },
{ "value": "DE" },
- { "value": "DE_0" },
+ { "value": "DE_S" },
{ "value": "GR" },
{ "value": "HU" },
{ "value": "IE" },
@@ -264,6 +264,7 @@
{ "value": "SE" },
{ "value": "GB" },
{ "value": "INT" },
+ { "value": "EU_S" },
{ "value": "EU" }
]
},
diff --git a/Admin/Routes/Web/Api.php b/Admin/Routes/Web/Api.php
index f9bafbc..ee1dcfe 100644
--- a/Admin/Routes/Web/Api.php
+++ b/Admin/Routes/Web/Api.php
@@ -22,6 +22,7 @@ return [
[
'dest' => '\Modules\ClientManagement\Controller\ApiController:apiClientFind',
'verb' => RouteVerb::GET,
+ 'csrf' => true,
'permission' => [
'module' => ApiController::NAME,
'type' => PermissionType::READ,
@@ -33,6 +34,7 @@ return [
[
'dest' => '\Modules\ClientManagement\Controller\ApiAttributeController:apiClientAttributeCreate',
'verb' => RouteVerb::PUT,
+ 'csrf' => true,
'permission' => [
'module' => ApiController::NAME,
'type' => PermissionType::READ,
@@ -42,6 +44,7 @@ return [
[
'dest' => '\Modules\ClientManagement\Controller\ApiAttributeController:apiClientAttributeUpdate',
'verb' => RouteVerb::SET,
+ 'csrf' => true,
'permission' => [
'module' => ApiController::NAME,
'type' => PermissionType::READ,
@@ -53,6 +56,7 @@ return [
[
'dest' => '\Modules\ClientManagement\Controller\ApiAttributeController:apiClientAttributeTypeCreate',
'verb' => RouteVerb::PUT,
+ 'csrf' => true,
'permission' => [
'module' => ApiController::NAME,
'type' => PermissionType::READ,
@@ -62,6 +66,7 @@ return [
[
'dest' => '\Modules\ClientManagement\Controller\ApiAttributeController:apiClientAttributeTypeUpdate',
'verb' => RouteVerb::SET,
+ 'csrf' => true,
'permission' => [
'module' => ApiController::NAME,
'type' => PermissionType::READ,
@@ -73,6 +78,7 @@ return [
[
'dest' => '\Modules\ClientManagement\Controller\ApiAttributeController:apiClientAttributeTypeL11nCreate',
'verb' => RouteVerb::PUT,
+ 'csrf' => true,
'permission' => [
'module' => ApiController::NAME,
'type' => PermissionType::READ,
@@ -82,6 +88,7 @@ return [
[
'dest' => '\Modules\ClientManagement\Controller\ApiAttributeController:apiClientAttributeTypeL11nUpdate',
'verb' => RouteVerb::SET,
+ 'csrf' => true,
'permission' => [
'module' => ApiController::NAME,
'type' => PermissionType::READ,
@@ -93,6 +100,7 @@ return [
[
'dest' => '\Modules\ClientManagement\Controller\ApiAttributeController:apiClientAttributeValueCreate',
'verb' => RouteVerb::PUT,
+ 'csrf' => true,
'permission' => [
'module' => ApiController::NAME,
'type' => PermissionType::READ,
@@ -102,6 +110,7 @@ return [
[
'dest' => '\Modules\ClientManagement\Controller\ApiAttributeController:apiClientAttributeValueUpdate',
'verb' => RouteVerb::SET,
+ 'csrf' => true,
'permission' => [
'module' => ApiController::NAME,
'type' => PermissionType::READ,
@@ -109,10 +118,11 @@ return [
],
],
],
- '^.*/client/attribute/value$' => [
+ '^.*/client/attribute/value/l11n$' => [
[
'dest' => '\Modules\ClientManagement\Controller\ApiAttributeController:apiClientAttributeValueL11nCreate',
'verb' => RouteVerb::PUT,
+ 'csrf' => true,
'permission' => [
'module' => ApiController::NAME,
'type' => PermissionType::READ,
@@ -122,6 +132,7 @@ return [
[
'dest' => '\Modules\ClientManagement\Controller\ApiAttributeController:apiClientAttributeValueL11nUpdate',
'verb' => RouteVerb::SET,
+ 'csrf' => true,
'permission' => [
'module' => ApiController::NAME,
'type' => PermissionType::READ,
@@ -133,6 +144,7 @@ return [
[
'dest' => '\Modules\ClientManagement\Controller\ApiController:apiClientL11nCreate',
'verb' => RouteVerb::PUT,
+ 'csrf' => true,
'permission' => [
'module' => ApiController::NAME,
'type' => PermissionType::READ,
@@ -142,6 +154,7 @@ return [
[
'dest' => '\Modules\ClientManagement\Controller\ApiController:apiClientL11nUpdate',
'verb' => RouteVerb::SET,
+ 'csrf' => true,
'permission' => [
'module' => ApiController::NAME,
'type' => PermissionType::READ,
@@ -153,6 +166,7 @@ return [
[
'dest' => '\Modules\ClientManagement\Controller\ApiController:apiClientL11nTypeCreate',
'verb' => RouteVerb::PUT,
+ 'csrf' => true,
'permission' => [
'module' => ApiController::NAME,
'type' => PermissionType::READ,
@@ -162,6 +176,7 @@ return [
[
'dest' => '\Modules\ClientManagement\Controller\ApiController:apiClientL11nTypeUpdate',
'verb' => RouteVerb::SET,
+ 'csrf' => true,
'permission' => [
'module' => ApiController::NAME,
'type' => PermissionType::READ,
diff --git a/Admin/Routes/Web/Backend.php b/Admin/Routes/Web/Backend.php
index 0fd52eb..455e618 100755
--- a/Admin/Routes/Web/Backend.php
+++ b/Admin/Routes/Web/Backend.php
@@ -25,18 +25,51 @@ return [
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
- 'state' => PermissionCategory::CLIENT,
+ 'state' => PermissionCategory::ATTRIBUTE,
],
],
],
- '^.*/sales/client/attribute/type(\?.*$|$)' => [
+ '^.*/sales/client/attribute/type/view(\?.*$|$)' => [
[
'dest' => '\Modules\ClientManagement\Controller\BackendController:viewClientManagementAttributeType',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
- 'state' => PermissionCategory::CLIENT,
+ 'state' => PermissionCategory::ATTRIBUTE,
+ ],
+ ],
+ ],
+ '^.*/sales/client/attribute/type/create(\?.*$|$)' => [
+ [
+ 'dest' => '\Modules\ClientManagement\Controller\BackendController:viewClientManagementAttributeType',
+ 'verb' => RouteVerb::GET,
+ 'permission' => [
+ 'module' => BackendController::NAME,
+ 'type' => PermissionType::CREATE,
+ 'state' => PermissionCategory::ATTRIBUTE,
+ ],
+ ],
+ ],
+ '^.*/sales/client/attribute/value/view(\?.*$|$)' => [
+ [
+ 'dest' => '\Modules\ClientManagement\Controller\BackendController:viewClientManagementAttributeValue',
+ 'verb' => RouteVerb::GET,
+ 'permission' => [
+ 'module' => BackendController::NAME,
+ 'type' => PermissionType::READ,
+ 'state' => PermissionCategory::ATTRIBUTE,
+ ],
+ ],
+ ],
+ '^.*/sales/client/attribute/value/create(\?.*$|$)' => [
+ [
+ 'dest' => '\Modules\ClientManagement\Controller\BackendController:viewClientManagementAttributeValueCreate',
+ 'verb' => RouteVerb::GET,
+ 'permission' => [
+ 'module' => BackendController::NAME,
+ 'type' => PermissionType::CREATE,
+ 'state' => PermissionCategory::ATTRIBUTE,
],
],
],
diff --git a/Controller.js b/Controller.js
index a32a1b8..c19b9d8 100755
--- a/Controller.js
+++ b/Controller.js
@@ -48,6 +48,7 @@ omsApp.Modules.ClientManagement = class {
const self = this;
const data = JSON.parse(chart.getAttribute('data-chart'));
+ /** global: Chart */
const myChart = new Chart(chart.getContext('2d'), data);
};
@@ -60,6 +61,7 @@ omsApp.Modules.ClientManagement = class {
return;
}
+ /** global: OpenLayers */
const mapObj = new OpenLayers.Map(map.getAttribute('id'), {
controls: [
new OpenLayers.Control.Navigation(
diff --git a/Controller/ApiController.php b/Controller/ApiController.php
index ee67591..2b4f9dc 100755
--- a/Controller/ApiController.php
+++ b/Controller/ApiController.php
@@ -27,6 +27,8 @@ use Modules\ClientManagement\Models\ClientL11nTypeMapper;
use Modules\ClientManagement\Models\ClientMapper;
use Modules\ClientManagement\Models\PermissionCategory;
use Modules\ClientManagement\Models\SettingsEnum;
+use Modules\Media\Models\Collection;
+use Modules\Media\Models\CollectionMapper;
use Modules\Media\Models\MediaMapper;
use Modules\Media\Models\PathSettings;
use Modules\Organization\Models\UnitMapper;
@@ -239,6 +241,10 @@ final class ApiController extends Controller
$request->getOrigin()
);
+ // Create media dir
+ // @todo should this collection get added to the parent collection?
+ $this->createMediaDirForClient($client->id, $request->header->account);
+
// Create stock
if ($this->app->moduleManager->isActive('WarehouseManagement')) {
$internalResponse = new HttpResponse();
@@ -276,6 +282,29 @@ final class ApiController extends Controller
$this->createStandardCreateResponse($request, $response, $client);
}
+ /**
+ * Create directory for an account
+ *
+ * @param int $id Item number
+ * @param int $createdBy Creator of the directory
+ *
+ * @return Collection
+ *
+ * @since 1.0.0
+ */
+ private function createMediaDirForClient(int $id, int $createdBy) : Collection
+ {
+ $collection = new Collection();
+ $collection->name = $id;
+ $collection->setVirtualPath('/Modules/ClientManagement/Clients');
+ $collection->setPath('/Modules/Media/Files/Modules/ClientManagement/Clients/' . $id);
+ $collection->createdBy = new NullAccount($createdBy);
+
+ CollectionMapper::create()->execute($collection);
+
+ return $collection;
+ }
+
/**
* Create client segmentation.
*
@@ -600,8 +629,8 @@ final class ApiController extends Controller
fileNames: $request->getDataList('filenames'),
files: $uploadedFiles,
account: $request->header->account,
- basePath: __DIR__ . '/../../../Modules/Media/Files/Modules/ClientManagement/' . ($request->getData('client') ?? '0'),
- virtualPath: '/Modules/ClientManagement/' . ($request->getData('client') ?? '0'),
+ basePath: __DIR__ . '/../../../Modules/Media/Files/Modules/ClientManagement/Clients/' . ($request->getData('client') ?? '0'),
+ virtualPath: '/Modules/ClientManagement/Clients/' . ($request->getData('client') ?? '0'),
pathSettings: PathSettings::FILE_PATH
);
@@ -650,7 +679,7 @@ final class ApiController extends Controller
*/
public function apiNoteCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
- $request->setData('virtualpath', '/Modules/ClientManagement/' . ((int) $request->getData('id')), true);
+ $request->setData('virtualpath', '/Modules/ClientManagement/Clients/' . ((int) $request->getData('id')), true);
$this->app->moduleManager->get('Editor')->apiEditorCreate($request, $response, $data);
$responseData = $response->getDataArray($request->uri->__toString());
diff --git a/Controller/BackendController.php b/Controller/BackendController.php
index c369c66..f13e07a 100755
--- a/Controller/BackendController.php
+++ b/Controller/BackendController.php
@@ -62,17 +62,15 @@ final class BackendController extends Controller
*/
public function viewClientManagementAttributeTypeList(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
- $view = new View($this->app->l11nManager, $request, $response);
- $view->setTemplate('/Modules/ClientManagement/Theme/Backend/attribute-type-list');
- $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1004801001, $request, $response);
+ $view = new \Modules\Attribute\Theme\Backend\Components\AttributeTypeListView($this->app->l11nManager, $request, $response);
+ $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1003101001, $request, $response);
- /** @var \Modules\Attribute\Models\AttributeType[] $attributes */
- $attributes = ClientAttributeTypeMapper::getAll()
+ $view->attributes = ClientAttributeTypeMapper::getAll()
->with('l11n')
->where('l11n/language', $response->header->l11n->language)
->execute();
- $view->data['attributes'] = $attributes;
+ $view->path = 'sales/client';
return $view;
}
@@ -93,7 +91,7 @@ final class BackendController extends Controller
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/ClientManagement/Theme/Backend/attribute-value-list');
- $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1004801001, $request, $response);
+ $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1003101001, $request, $response);
/** @var \Modules\Attribute\Models\AttributeValue[] $attributes */
$attributes = ClientAttributeValueMapper::getAll()
@@ -120,23 +118,55 @@ final class BackendController extends Controller
*/
public function viewClientManagementAttributeType(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
- $view = new View($this->app->l11nManager, $request, $response);
- $view->setTemplate('/Modules/ClientManagement/Theme/Backend/attribute-type');
- $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1004801001, $request, $response);
+ $view = new \Modules\Attribute\Theme\Backend\Components\AttributeTypeView($this->app->l11nManager, $request, $response);
+ $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1003101001, $request, $response);
- /** @var \Modules\Attribute\Models\AttributeType $attribute */
- $attribute = ClientAttributeTypeMapper::get()
+ $view->attribute = ClientAttributeTypeMapper::get()
->with('l11n')
+ ->with('defaults')
+ ->with('defaults/l11n')
->where('id', (int) $request->getData('id'))
->where('l11n/language', $response->header->l11n->language)
+ ->where('defaults/l11n/language', [$response->header->l11n->language, null])
->execute();
- $l11ns = ClientAttributeTypeL11nMapper::getAll()
- ->where('ref', $attribute->id)
+ $view->l11ns = ClientAttributeTypeL11nMapper::getAll()
+ ->where('ref', $view->attribute->id)
->execute();
- $view->data['attribute'] = $attribute;
- $view->data['l11ns'] = $l11ns;
+ $view->path = 'sales/client';
+
+ 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 viewClientManagementAttributeValue(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
+ {
+ $view = new \Modules\Attribute\Theme\Backend\Components\AttributeValueView($this->app->l11nManager, $request, $response);
+ $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1003101001, $request, $response);
+
+ $view->attribute = ClientAttributeValueMapper::get()
+ ->with('l11n')
+ ->where('id', (int) $request->getData('id'))
+ ->where('l11n/language', [$response->header->l11n->language, null])
+ ->execute();
+
+ $view->l11ns = ClientAttributeValueL11nMapper::getAll()
+ ->where('ref', $view->attribute->id)
+ ->execute();
+
+ // @todo Also find the ItemAttributeType
return $view;
}
diff --git a/Models/PermissionCategory.php b/Models/PermissionCategory.php
index 053ff93..ede6926 100755
--- a/Models/PermissionCategory.php
+++ b/Models/PermissionCategory.php
@@ -32,5 +32,7 @@ abstract class PermissionCategory extends Enum
public const CLIENT_NOTE = 3;
+ public const ATTRIBUTE = 4;
+
public const CLIENT_LOG = 101;
}
diff --git a/Theme/Backend/attribute-type-list.tpl.php b/Theme/Backend/attribute-type-list.tpl.php
deleted file mode 100644
index 3844e0d..0000000
--- a/Theme/Backend/attribute-type-list.tpl.php
+++ /dev/null
@@ -1,71 +0,0 @@
-data['attributes'];
-
-echo $this->data['nav']->render(); ?>
-
-
-
-
- = $this->getHtml('AttributeTypes'); ?>download
-
-
-
-
diff --git a/Theme/Backend/attribute-type.tpl.php b/Theme/Backend/attribute-type.tpl.php
deleted file mode 100755
index c6c3533..0000000
--- a/Theme/Backend/attribute-type.tpl.php
+++ /dev/null
@@ -1,98 +0,0 @@
-data['attribute'];
-$l11ns = $this->data['l11ns'];
-
-echo $this->data['nav']->render(); ?>
-
-
-
-
- = $this->getHtml('Attribute', 'Attribute', 'Backend'); ?>
-
-
-
- = $this->getHtml('ID', '0', '0'); ?>
-
-
-
-
- = $this->getHtml('Name', 'Attribute', 'Backend'); ?>
-
-
-
-
- = $this->getHtml('Datatype', 'Attribute', 'Backend'); ?>
-
- $type) : ?>
- datatype ? ' selected' : ''; ?>>= $this->printHtml($key); ?>
-
-
-
-
-
- = $this->getHtml('Pattern', 'Attribute', 'Backend'); ?>
-
-
-
-
-
- isRequired ? ' checked' : ''; ?>>
-
- = $this->getHtml('IsRequired', 'Attribute', 'Backend'); ?>
-
-
-
-
-
- custom ? ' checked' : ''; ?>>
-
- = $this->getHtml('CustomValue', 'Attribute', 'Backend'); ?>
-
-
-
-
-
-
-
-
-
= $this->getHtml('Language', '0', '0'); ?>download
-
-
-
-
-
- = $this->getHtml('Language', '0', '0'); ?>
- = $this->getHtml('Title', 'Attribute', 'Backend'); ?>
-
- $value) : ++$c; ?>
-
- close
- settings
- = ISO639Enum::getByName('_' . \strtoupper($value->language)); ?>
- = $value->content; ?>
-
-
- = $this->getHtml('Empty', '0', '0'); ?>
-
-
-
-
-
diff --git a/Theme/Backend/client-create.tpl.php b/Theme/Backend/client-create.tpl.php
index 274bd4a..73172b4 100755
--- a/Theme/Backend/client-create.tpl.php
+++ b/Theme/Backend/client-create.tpl.php
@@ -44,11 +44,11 @@ echo $this->data['nav']->render(); ?>
= $this->getHtml('ID', '0', '0'); ?>
book
= $this->getHtml('Name1'); ?>
-
+
= $this->getHtml('Name2'); ?>
-
+
= $this->getHtml('Name3'); ?>
-
+
@@ -134,15 +134,15 @@ echo $this->data['nav']->render(); ?>
@@ -231,17 +231,17 @@ echo $this->data['nav']->render(); ?>
diff --git a/Theme/Backend/client-view.tpl.php b/Theme/Backend/client-view.tpl.php
index dc3d129..ae696ed 100644
--- a/Theme/Backend/client-view.tpl.php
+++ b/Theme/Backend/client-view.tpl.php
@@ -25,6 +25,7 @@ use phpOMS\Localization\ISO4217CharEnum;
use phpOMS\Localization\ISO639Enum;
use phpOMS\Localization\RegionEnum;
use phpOMS\Message\Http\HttpHeader;
+use phpOMS\Stdlib\Base\FloatInt;
use phpOMS\Stdlib\Base\SmartDateTime;
use phpOMS\Uri\UriFactory;
@@ -373,7 +374,7 @@ echo $this->data['nav']->render();
= $invoice->type->getL11n(); ?>
= $invoice->billTo; ?>
= $this->getCurrency($invoice->netSales, symbol: ''); ?>
- = $invoice->createdAt->format('Y-m-d'); ?>
+ = $invoice->performanceDate->format('Y-m-d'); ?>
= $this->getHtml('Empty', '0', '0'); ?>
@@ -388,11 +389,65 @@ echo $this->data['nav']->render();
data['hasBilling']) :
$monthlySalesCosts = SalesBillMapper::getClientMonthlySalesCosts($client->id, (new SmartDateTime('now'))->createModify(-1), new SmartDateTime('now'));
?>
+
+ id, 'segment', 'en', (new SmartDateTime('now'))->createModify(-1), new SmartDateTime('now')); ?>
= $this->getHtml('Segments'); ?>
-
+
+
+
+ = '"' . \implode('", "', $temp) . '"'; ?>
+ ],
+ "datasets": [
+ {
+ "label": "= $this->getHtml('Sales'); ?>",
+ "type": "bar",
+ "data": [
+
+ = \implode(',', $temp); ?>
+ ],
+ "yAxisID": "axis1",
+ "backgroundColor": "rgb(54, 162, 235)"
+ }
+ ]
+ },
+ "options": {
+ "responsive": true,
+ "scales": {
+ "axis1": {
+ "id": "axis1",
+ "display": true,
+ "position": "left",
+ "ticks": {
+ "precision": 0
+ }
+ }
+ },
+ "plugins": {
+ "legend": {
+ "display": false
+ }
+ }
+ }
+ }'>
+
+
@@ -400,6 +455,7 @@ echo $this->data['nav']->render();
= $this->getHtml('Sales'); ?>
+
render();
= \implode(',', $temp); ?>
@@ -453,7 +509,10 @@ echo $this->data['nav']->render();
"axis1": {
"id": "axis1",
"display": true,
- "position": "left"
+ "position": "left",
+ "ticks": {
+ "precision": 0
+ }
},
"axis2": {
"id": "axis2",
@@ -476,11 +535,13 @@ echo $this->data['nav']->render();
}
}
}'>
+
+
@@ -521,27 +582,27 @@ echo $this->data['nav']->render();