Skip to content

Commit

Permalink
template fixes + bug fixes + style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Eichhorn committed Apr 2, 2024
1 parent d364e7c commit 9963f7b
Show file tree
Hide file tree
Showing 8 changed files with 203 additions and 78 deletions.
4 changes: 2 additions & 2 deletions Admin/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ private static function createItems(ApplicationAbstract $app, array $items) : ar
$module2 = $app->moduleManager->get('ItemManagement', 'ApiAttribute');

/** @var \Modules\Attribute\Models\AttributeType[] $attributeTypes */
$attributeTypes = ItemAttributeTypeMapper::getAll()->with('defaults')->execute();
$attributeTypes = ItemAttributeTypeMapper::getAll()->with('defaults')->executeGetArray();

/** @var \phpOMS\Localization\BaseStringL11nType[] $l11nTypes */
$l11nTypes = ItemL11nTypeMapper::getAll()->execute();
$l11nTypes = ItemL11nTypeMapper::getAll()->executeGetArray();

// Change indexing for easier search later on.
foreach ($attributeTypes as $e) {
Expand Down
11 changes: 11 additions & 0 deletions Admin/Routes/Web/Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,15 @@
],
],
],
'^/item/material/create(\?.*$|$)' => [
[
'dest' => '\Modules\ItemManagement\Controller\BackendController:viewItemMaterialCreate',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::CREATE,
'state' => PermissionCategory::MATERIAL,
],
],
],
];
16 changes: 8 additions & 8 deletions Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function apiItemFind(RequestAbstract $request, ResponseAbstract $response
->where('language', $response->header->l11n->language)
->where('content', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE')
->limit($request->getDataInt('limit') ?? 50)
->execute();
->executeGetArray();

if (empty($l11n)) {
/** @var BaseStringL11n[] $l11n */
Expand All @@ -102,7 +102,7 @@ public function apiItemFind(RequestAbstract $request, ResponseAbstract $response
->where('language', $response->header->l11n->language)
->where('content', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE')
->limit($request->getDataInt('limit') ?? 50)
->execute();
->executeGetArray();
}

if (empty($l11n)) {
Expand All @@ -115,7 +115,7 @@ public function apiItemFind(RequestAbstract $request, ResponseAbstract $response
->where('language', $response->header->l11n->language)
->where('content', '%' . $search . '%', 'LIKE')
->limit($request->getDataInt('limit') ?? 50)
->execute();
->executeGetArray();

if (!empty($l11n)) {
break;
Expand All @@ -131,7 +131,7 @@ public function apiItemFind(RequestAbstract $request, ResponseAbstract $response
->where('language', $response->header->l11n->language)
->where('content', '%' . $search . '%', 'LIKE')
->limit($request->getDataInt('limit') ?? 50)
->execute();
->executeGetArray();

if (!empty($l11n)) {
break;
Expand All @@ -153,7 +153,7 @@ public function apiItemFind(RequestAbstract $request, ResponseAbstract $response
->where('l11n/type/title', ['name1', 'name2'], 'IN')
->where('l11n/language', $request->header->l11n->language)
->where('id', $itemIds, 'IN')
->execute();
->executeGetArray();
}

$response->header->set('Content-Type', MimeType::M_JSON, true);
Expand Down Expand Up @@ -256,7 +256,7 @@ public function apiItemCreate(RequestAbstract $request, ResponseAbstract $respon
/** @var \Modules\Attribute\Models\AttributeType[] $types */
$types = ItemAttributeTypeMapper::getAll()
->where('name', ['default_sales_container', 'default_purchase_container'], 'IN')
->execute();
->executeGetArray();

$primaryContainer = \reset($item->container);
if ($primaryContainer !== false) {
Expand Down Expand Up @@ -379,7 +379,7 @@ private function createItemSegmentation(RequestAbstract $request, ResponseAbstra
/** @var \Modules\Attribute\Models\AttributeType[] $types */
$types = ItemAttributeTypeMapper::getAll()
->where('name', \array_keys($segmentation), 'IN')
->execute();
->executeGetArray();

foreach ($types as $type) {
$internalResponse = clone $response;
Expand All @@ -397,7 +397,7 @@ private function createItemSegmentation(RequestAbstract $request, ResponseAbstra
/**
* Create directory for an account
*
* @param int $id Item number
* @param int $id Item number
* @param int $createdBy Creator of the directory
*
* @return Collection
Expand Down
119 changes: 98 additions & 21 deletions Controller/BackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

namespace Modules\ItemManagement\Controller;

use Modules\Attribute\Models\NullAttributeType;
use Modules\Attribute\Models\NullAttributeValue;
use Modules\Auditor\Models\AuditMapper;
use Modules\ClientManagement\Models\Attribute\ClientAttributeTypeMapper;
use Modules\ClientManagement\Models\Attribute\ClientAttributeValueL11nMapper;
Expand Down Expand Up @@ -73,13 +75,13 @@ final class BackendController extends Controller
*/
public function viewItemManagementAttributeTypeList(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$view = new \Modules\Attribute\Theme\Backend\Components\AttributeTypeListView($this->app->l11nManager, $request, $response);
$view = new \Modules\Attribute\Theme\Backend\Components\AttributeTypeListView($this->app->l11nManager, $request, $response);
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1004802001, $request, $response);

$view->attributes = ItemAttributeTypeMapper::getAll()
->with('l11n')
->where('l11n/language', $response->header->l11n->language)
->execute();
->executeGetArray();

$view->path = 'item';

Expand All @@ -100,7 +102,7 @@ public function viewItemManagementAttributeTypeList(RequestAbstract $request, Re
*/
public function viewItemManagementAttributeType(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$view = new \Modules\Attribute\Theme\Backend\Components\AttributeTypeView($this->app->l11nManager, $request, $response);
$view = new \Modules\Attribute\Theme\Backend\Components\AttributeTypeView($this->app->l11nManager, $request, $response);
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1004802001, $request, $response);

$view->attribute = ItemAttributeTypeMapper::get()
Expand All @@ -114,7 +116,7 @@ public function viewItemManagementAttributeType(RequestAbstract $request, Respon

$view->l11ns = ItemAttributeTypeL11nMapper::getAll()
->where('ref', $view->attribute->id)
->execute();
->executeGetArray();

$view->path = 'item';

Expand All @@ -135,9 +137,11 @@ public function viewItemManagementAttributeType(RequestAbstract $request, Respon
*/
public function viewItemManagementAttributeValue(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$view = new \Modules\Attribute\Theme\Backend\Components\AttributeValueView($this->app->l11nManager, $request, $response);
$view = new \Modules\Attribute\Theme\Backend\Components\AttributeValueView($this->app->l11nManager, $request, $response);
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1004802001, $request, $response);

$view->type = ItemAttributeTypeMapper::get()->where('id', (int) $request->getData('type'))->execute();

$view->attribute = ItemAttributeValueMapper::get()
->with('l11n')
->where('id', (int) $request->getData('id'))
Expand All @@ -146,7 +150,7 @@ public function viewItemManagementAttributeValue(RequestAbstract $request, Respo

$view->l11ns = ItemAttributeValueL11nMapper::getAll()
->where('ref', $view->attribute->id)
->execute();
->executeGetArray();

// @todo Also find the ItemAttributeType

Expand Down Expand Up @@ -183,7 +187,7 @@ public function viewItemManagementItemList(RequestAbstract $request, ResponseAbs
->where('files/types/name', 'item_profile_image')
->where('unit', $this->app->unitId)
->limit(50)
->execute();
->executeGetArray();

$view->data['items'] = $items;

Expand Down Expand Up @@ -275,7 +279,11 @@ public function viewItemManagementProductionList(RequestAbstract $request, Respo
*/
public function viewItemManagementItemCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
return $this->viewItemManagementItem($request, $response, $data);
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/ItemManagement/Theme/Backend/item-view');
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1004803001, $request, $response);

return $view;
}

/**
Expand Down Expand Up @@ -460,20 +468,20 @@ public function viewItemManagementItem(RequestAbstract $request, ResponseAbstrac
$view->data['l11nView'] = new \Web\Backend\Views\L11nView($this->app->l11nManager, $request, $response);

$view->data['l11nTypes'] = ItemL11nTypeMapper::getAll()
->execute();
->executeGetArray();

$view->data['l11nValues'] = ItemL11nMapper::getAll()
->with('type')
->where('ref', $view->data['item']->id)
->execute();
->executeGetArray();

$view->data['attributeTypes'] = ItemAttributeTypeMapper::getAll()
->with('l11n')
->where('l11n/language', $response->header->l11n->language)
->execute();
->executeGetArray();

$view->data['units'] = UnitMapper::getAll()
->execute();
->executeGetArray();

$view->data['hasBilling'] = $this->app->moduleManager->isActive('Billing');

Expand All @@ -483,7 +491,7 @@ public function viewItemManagementItem(RequestAbstract $request, ResponseAbstrac
->with('supplier/account')
->where('item', $view->data['item']->id)
->where('client', null)
->execute()
->executeGetArray()
: [];

/** @var \Modules\Attribute\Models\AttributeType[] $tmp */
Expand All @@ -498,7 +506,7 @@ public function viewItemManagementItem(RequestAbstract $request, ResponseAbstrac
->where('defaults/l11n', (new Where($this->app->dbPool->get()))
->where(ItemAttributeValueL11nMapper::getColumnByMember('ref') ?? '', '=', null)
->orWhere(ItemAttributeValueL11nMapper::getColumnByMember('language') ?? '', '=', $response->header->l11n->language))
->execute();
->executeGetArray();

$defaultAttributeTypes = [];
foreach ($tmp as $t) {
Expand All @@ -515,7 +523,7 @@ public function viewItemManagementItem(RequestAbstract $request, ResponseAbstrac
->where('defaults/l11n', (new Where($this->app->dbPool->get()))
->where(ClientAttributeValueL11nMapper::getColumnByMember('ref') ?? '', '=', null)
->orWhere(ClientAttributeValueL11nMapper::getColumnByMember('language') ?? '', '=', $response->header->l11n->language))
->execute();
->executeGetArray();

$clientSegmentationTypes = [];
foreach ($tmp as $t) {
Expand All @@ -538,7 +546,7 @@ public function viewItemManagementItem(RequestAbstract $request, ResponseAbstrac
->where('type', StringUtils::intHash(ItemMapper::class))
->where('module', 'ItemManagement')
->where('ref', (string) $view->data['item']->id)
->execute();
->executeGetArray();
}

$view->data['logs'] = $logs;
Expand All @@ -549,7 +557,7 @@ public function viewItemManagementItem(RequestAbstract $request, ResponseAbstrac
->with('types')
->join('id', ItemMapper::class, 'files') // id = media id, files = item relations
->on('id', $view->data['item']->id, relation: 'files') // id = item id
->execute();
->executeGetArray();

$view->data['media-upload'] = new \Modules\Media\Theme\Backend\Components\Upload\BaseView($this->app->l11nManager, $request, $response);
$view->data['note'] = new \Modules\Editor\Theme\Backend\Components\Note\BaseView($this->app->l11nManager, $request, $response);
Expand Down Expand Up @@ -820,7 +828,7 @@ public function viewItemMaterialList(RequestAbstract $request, ResponseAbstract
$view->data['types'] = MaterialTypeMapper::getAll()
->with('l11n')
->where('l11n/language', $response->header->l11n->language)
->execute();
->executeGetArray();

return $view;
}
Expand Down Expand Up @@ -849,15 +857,84 @@ public function viewItemMaterialView(RequestAbstract $request, ResponseAbstract
->where('l11n/language', $response->header->l11n->language)
->execute();

$view->data['l11nView'] = new \Web\Backend\Views\L11nView($this->app->l11nManager, $request, $response);

/** @var \phpOMS\Localization\BaseStringL11n[] $l11nValues */
$l11nValues = MaterialTypeL11nMapper::getAll()
->where('ref', $view->data['type']->id)
->execute();
->executeGetArray();

$view->data['l11nView'] = new \Web\Backend\Views\L11nView($this->app->l11nManager, $request, $response);
$view->data['l11nValues'] = $l11nValues;

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 viewItemMaterialCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/ItemManagement/Theme/Backend/material-view');
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1004802001, $request, $response);

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 viewItemManagementAttributeTypeCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$view = new \Modules\Attribute\Theme\Backend\Components\AttributeTypeView($this->app->l11nManager, $request, $response);
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1004802001, $request, $response);

$view->attribute = new NullAttributeType();

$view->path = 'item';

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 viewItemManagementAttributeValueCreate(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(1004802001, $request, $response);

$view->type = ItemAttributeTypeMapper::get()->where('id', (int) $request->getData('type'))->execute();
$view->attribute = new NullAttributeValue();

$view->path = 'item';

return $view;
}
}
8 changes: 6 additions & 2 deletions Theme/Backend/Lang/de.lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
'Text' => 'Text',
'TimeUnit' => 'Zeiteinheit',
'Title' => 'Titel',
'Defaults' => 'Standard',
'Defaults' => 'Standard',
'TopCustomers' => 'Top Kunden',
'Tracking' => 'Verfolgung',
'TradingUnit' => 'Handelseinheit',
Expand All @@ -151,12 +151,16 @@
'LeadTime' => 'Lieferzeit',
'UnitQuantity' => 'Einheitsmenge',
'UnitPrice' => 'Einheitspreis',
'Suppliers' => 'Lieferanten',
'Suppliers' => 'Lieferanten',
'CostCenter' => 'Kostenstelle',
'CostObject' => 'Kostenträger',
'DefaultStock' => 'Standard Lager',
'DefaultStockLocation' => 'Standard Lagerplatz',
'Inventory' => 'Bestandsführung',
'Identifier' => 'Identifizierung',
'Stocktaking' => 'Inventur',
':status-1' => 'Aktiv',
':status-2' => 'Entwurf',
':status-3' => 'Inaktiv',
':status-4' => 'Eingestellt',
]];
6 changes: 5 additions & 1 deletion Theme/Backend/Lang/en.lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
'Text' => 'Text',
'TimeUnit' => 'Unit of time',
'Title' => 'Title',
'Defaults' => 'Defaults',
'Defaults' => 'Defaults',
'TopCustomers' => 'Top Customers',
'Tracking' => 'Tracking',
'TradingUnit' => 'Trading Unit',
Expand Down Expand Up @@ -159,4 +159,8 @@
'Inventory' => 'Inventory',
'Identifier' => 'Identifier',
'Stocktaking' => 'Stocktaking',
':status-1' => 'Active',
':status-2' => 'Draft',
':status-3' => 'Inactive',
':status-4' => 'Discontinued',
]];
Loading

0 comments on commit 9963f7b

Please sign in to comment.