template fixes + bug fixes + style fixes

This commit is contained in:
Dennis Eichhorn 2024-04-02 21:40:47 +00:00
parent d364e7c680
commit 9963f7bff0
8 changed files with 203 additions and 78 deletions

View File

@ -134,10 +134,10 @@ final class Installer extends InstallerAbstract
$module2 = $app->moduleManager->get('ItemManagement', 'ApiAttribute'); $module2 = $app->moduleManager->get('ItemManagement', 'ApiAttribute');
/** @var \Modules\Attribute\Models\AttributeType[] $attributeTypes */ /** @var \Modules\Attribute\Models\AttributeType[] $attributeTypes */
$attributeTypes = ItemAttributeTypeMapper::getAll()->with('defaults')->execute(); $attributeTypes = ItemAttributeTypeMapper::getAll()->with('defaults')->executeGetArray();
/** @var \phpOMS\Localization\BaseStringL11nType[] $l11nTypes */ /** @var \phpOMS\Localization\BaseStringL11nType[] $l11nTypes */
$l11nTypes = ItemL11nTypeMapper::getAll()->execute(); $l11nTypes = ItemL11nTypeMapper::getAll()->executeGetArray();
// Change indexing for easier search later on. // Change indexing for easier search later on.
foreach ($attributeTypes as $e) { foreach ($attributeTypes as $e) {

View File

@ -276,4 +276,15 @@ return [
], ],
], ],
], ],
'^/item/material/create(\?.*$|$)' => [
[
'dest' => '\Modules\ItemManagement\Controller\BackendController:viewItemMaterialCreate',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::CREATE,
'state' => PermissionCategory::MATERIAL,
],
],
],
]; ];

View File

@ -92,7 +92,7 @@ final class ApiController extends Controller
->where('language', $response->header->l11n->language) ->where('language', $response->header->l11n->language)
->where('content', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE') ->where('content', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE')
->limit($request->getDataInt('limit') ?? 50) ->limit($request->getDataInt('limit') ?? 50)
->execute(); ->executeGetArray();
if (empty($l11n)) { if (empty($l11n)) {
/** @var BaseStringL11n[] $l11n */ /** @var BaseStringL11n[] $l11n */
@ -102,7 +102,7 @@ final class ApiController extends Controller
->where('language', $response->header->l11n->language) ->where('language', $response->header->l11n->language)
->where('content', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE') ->where('content', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE')
->limit($request->getDataInt('limit') ?? 50) ->limit($request->getDataInt('limit') ?? 50)
->execute(); ->executeGetArray();
} }
if (empty($l11n)) { if (empty($l11n)) {
@ -115,7 +115,7 @@ final class ApiController extends Controller
->where('language', $response->header->l11n->language) ->where('language', $response->header->l11n->language)
->where('content', '%' . $search . '%', 'LIKE') ->where('content', '%' . $search . '%', 'LIKE')
->limit($request->getDataInt('limit') ?? 50) ->limit($request->getDataInt('limit') ?? 50)
->execute(); ->executeGetArray();
if (!empty($l11n)) { if (!empty($l11n)) {
break; break;
@ -131,7 +131,7 @@ final class ApiController extends Controller
->where('language', $response->header->l11n->language) ->where('language', $response->header->l11n->language)
->where('content', '%' . $search . '%', 'LIKE') ->where('content', '%' . $search . '%', 'LIKE')
->limit($request->getDataInt('limit') ?? 50) ->limit($request->getDataInt('limit') ?? 50)
->execute(); ->executeGetArray();
if (!empty($l11n)) { if (!empty($l11n)) {
break; break;
@ -153,7 +153,7 @@ final class ApiController extends Controller
->where('l11n/type/title', ['name1', 'name2'], 'IN') ->where('l11n/type/title', ['name1', 'name2'], 'IN')
->where('l11n/language', $request->header->l11n->language) ->where('l11n/language', $request->header->l11n->language)
->where('id', $itemIds, 'IN') ->where('id', $itemIds, 'IN')
->execute(); ->executeGetArray();
} }
$response->header->set('Content-Type', MimeType::M_JSON, true); $response->header->set('Content-Type', MimeType::M_JSON, true);
@ -256,7 +256,7 @@ final class ApiController extends Controller
/** @var \Modules\Attribute\Models\AttributeType[] $types */ /** @var \Modules\Attribute\Models\AttributeType[] $types */
$types = ItemAttributeTypeMapper::getAll() $types = ItemAttributeTypeMapper::getAll()
->where('name', ['default_sales_container', 'default_purchase_container'], 'IN') ->where('name', ['default_sales_container', 'default_purchase_container'], 'IN')
->execute(); ->executeGetArray();
$primaryContainer = \reset($item->container); $primaryContainer = \reset($item->container);
if ($primaryContainer !== false) { if ($primaryContainer !== false) {
@ -379,7 +379,7 @@ final class ApiController extends Controller
/** @var \Modules\Attribute\Models\AttributeType[] $types */ /** @var \Modules\Attribute\Models\AttributeType[] $types */
$types = ItemAttributeTypeMapper::getAll() $types = ItemAttributeTypeMapper::getAll()
->where('name', \array_keys($segmentation), 'IN') ->where('name', \array_keys($segmentation), 'IN')
->execute(); ->executeGetArray();
foreach ($types as $type) { foreach ($types as $type) {
$internalResponse = clone $response; $internalResponse = clone $response;
@ -397,7 +397,7 @@ final class ApiController extends Controller
/** /**
* Create directory for an account * Create directory for an account
* *
* @param int $id Item number * @param int $id Item number
* @param int $createdBy Creator of the directory * @param int $createdBy Creator of the directory
* *
* @return Collection * @return Collection

View File

@ -14,6 +14,8 @@ declare(strict_types=1);
namespace Modules\ItemManagement\Controller; namespace Modules\ItemManagement\Controller;
use Modules\Attribute\Models\NullAttributeType;
use Modules\Attribute\Models\NullAttributeValue;
use Modules\Auditor\Models\AuditMapper; use Modules\Auditor\Models\AuditMapper;
use Modules\ClientManagement\Models\Attribute\ClientAttributeTypeMapper; use Modules\ClientManagement\Models\Attribute\ClientAttributeTypeMapper;
use Modules\ClientManagement\Models\Attribute\ClientAttributeValueL11nMapper; use Modules\ClientManagement\Models\Attribute\ClientAttributeValueL11nMapper;
@ -73,13 +75,13 @@ final class BackendController extends Controller
*/ */
public function viewItemManagementAttributeTypeList(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface 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->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1004802001, $request, $response);
$view->attributes = ItemAttributeTypeMapper::getAll() $view->attributes = ItemAttributeTypeMapper::getAll()
->with('l11n') ->with('l11n')
->where('l11n/language', $response->header->l11n->language) ->where('l11n/language', $response->header->l11n->language)
->execute(); ->executeGetArray();
$view->path = 'item'; $view->path = 'item';
@ -100,7 +102,7 @@ final class BackendController extends Controller
*/ */
public function viewItemManagementAttributeType(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface 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->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1004802001, $request, $response);
$view->attribute = ItemAttributeTypeMapper::get() $view->attribute = ItemAttributeTypeMapper::get()
@ -114,7 +116,7 @@ final class BackendController extends Controller
$view->l11ns = ItemAttributeTypeL11nMapper::getAll() $view->l11ns = ItemAttributeTypeL11nMapper::getAll()
->where('ref', $view->attribute->id) ->where('ref', $view->attribute->id)
->execute(); ->executeGetArray();
$view->path = 'item'; $view->path = 'item';
@ -135,9 +137,11 @@ final class BackendController extends Controller
*/ */
public function viewItemManagementAttributeValue(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface 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->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() $view->attribute = ItemAttributeValueMapper::get()
->with('l11n') ->with('l11n')
->where('id', (int) $request->getData('id')) ->where('id', (int) $request->getData('id'))
@ -146,7 +150,7 @@ final class BackendController extends Controller
$view->l11ns = ItemAttributeValueL11nMapper::getAll() $view->l11ns = ItemAttributeValueL11nMapper::getAll()
->where('ref', $view->attribute->id) ->where('ref', $view->attribute->id)
->execute(); ->executeGetArray();
// @todo Also find the ItemAttributeType // @todo Also find the ItemAttributeType
@ -183,7 +187,7 @@ final class BackendController extends Controller
->where('files/types/name', 'item_profile_image') ->where('files/types/name', 'item_profile_image')
->where('unit', $this->app->unitId) ->where('unit', $this->app->unitId)
->limit(50) ->limit(50)
->execute(); ->executeGetArray();
$view->data['items'] = $items; $view->data['items'] = $items;
@ -275,7 +279,11 @@ final class BackendController extends Controller
*/ */
public function viewItemManagementItemCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface 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;
} }
/** /**
@ -460,20 +468,20 @@ final class BackendController extends Controller
$view->data['l11nView'] = new \Web\Backend\Views\L11nView($this->app->l11nManager, $request, $response); $view->data['l11nView'] = new \Web\Backend\Views\L11nView($this->app->l11nManager, $request, $response);
$view->data['l11nTypes'] = ItemL11nTypeMapper::getAll() $view->data['l11nTypes'] = ItemL11nTypeMapper::getAll()
->execute(); ->executeGetArray();
$view->data['l11nValues'] = ItemL11nMapper::getAll() $view->data['l11nValues'] = ItemL11nMapper::getAll()
->with('type') ->with('type')
->where('ref', $view->data['item']->id) ->where('ref', $view->data['item']->id)
->execute(); ->executeGetArray();
$view->data['attributeTypes'] = ItemAttributeTypeMapper::getAll() $view->data['attributeTypes'] = ItemAttributeTypeMapper::getAll()
->with('l11n') ->with('l11n')
->where('l11n/language', $response->header->l11n->language) ->where('l11n/language', $response->header->l11n->language)
->execute(); ->executeGetArray();
$view->data['units'] = UnitMapper::getAll() $view->data['units'] = UnitMapper::getAll()
->execute(); ->executeGetArray();
$view->data['hasBilling'] = $this->app->moduleManager->isActive('Billing'); $view->data['hasBilling'] = $this->app->moduleManager->isActive('Billing');
@ -483,7 +491,7 @@ final class BackendController extends Controller
->with('supplier/account') ->with('supplier/account')
->where('item', $view->data['item']->id) ->where('item', $view->data['item']->id)
->where('client', null) ->where('client', null)
->execute() ->executeGetArray()
: []; : [];
/** @var \Modules\Attribute\Models\AttributeType[] $tmp */ /** @var \Modules\Attribute\Models\AttributeType[] $tmp */
@ -498,7 +506,7 @@ final class BackendController extends Controller
->where('defaults/l11n', (new Where($this->app->dbPool->get())) ->where('defaults/l11n', (new Where($this->app->dbPool->get()))
->where(ItemAttributeValueL11nMapper::getColumnByMember('ref') ?? '', '=', null) ->where(ItemAttributeValueL11nMapper::getColumnByMember('ref') ?? '', '=', null)
->orWhere(ItemAttributeValueL11nMapper::getColumnByMember('language') ?? '', '=', $response->header->l11n->language)) ->orWhere(ItemAttributeValueL11nMapper::getColumnByMember('language') ?? '', '=', $response->header->l11n->language))
->execute(); ->executeGetArray();
$defaultAttributeTypes = []; $defaultAttributeTypes = [];
foreach ($tmp as $t) { foreach ($tmp as $t) {
@ -515,7 +523,7 @@ final class BackendController extends Controller
->where('defaults/l11n', (new Where($this->app->dbPool->get())) ->where('defaults/l11n', (new Where($this->app->dbPool->get()))
->where(ClientAttributeValueL11nMapper::getColumnByMember('ref') ?? '', '=', null) ->where(ClientAttributeValueL11nMapper::getColumnByMember('ref') ?? '', '=', null)
->orWhere(ClientAttributeValueL11nMapper::getColumnByMember('language') ?? '', '=', $response->header->l11n->language)) ->orWhere(ClientAttributeValueL11nMapper::getColumnByMember('language') ?? '', '=', $response->header->l11n->language))
->execute(); ->executeGetArray();
$clientSegmentationTypes = []; $clientSegmentationTypes = [];
foreach ($tmp as $t) { foreach ($tmp as $t) {
@ -538,7 +546,7 @@ final class BackendController extends Controller
->where('type', StringUtils::intHash(ItemMapper::class)) ->where('type', StringUtils::intHash(ItemMapper::class))
->where('module', 'ItemManagement') ->where('module', 'ItemManagement')
->where('ref', (string) $view->data['item']->id) ->where('ref', (string) $view->data['item']->id)
->execute(); ->executeGetArray();
} }
$view->data['logs'] = $logs; $view->data['logs'] = $logs;
@ -549,7 +557,7 @@ final class BackendController extends Controller
->with('types') ->with('types')
->join('id', ItemMapper::class, 'files') // id = media id, files = item relations ->join('id', ItemMapper::class, 'files') // id = media id, files = item relations
->on('id', $view->data['item']->id, relation: 'files') // id = item id ->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['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); $view->data['note'] = new \Modules\Editor\Theme\Backend\Components\Note\BaseView($this->app->l11nManager, $request, $response);
@ -820,7 +828,7 @@ final class BackendController extends Controller
$view->data['types'] = MaterialTypeMapper::getAll() $view->data['types'] = MaterialTypeMapper::getAll()
->with('l11n') ->with('l11n')
->where('l11n/language', $response->header->l11n->language) ->where('l11n/language', $response->header->l11n->language)
->execute(); ->executeGetArray();
return $view; return $view;
} }
@ -849,15 +857,84 @@ final class BackendController extends Controller
->where('l11n/language', $response->header->l11n->language) ->where('l11n/language', $response->header->l11n->language)
->execute(); ->execute();
$view->data['l11nView'] = new \Web\Backend\Views\L11nView($this->app->l11nManager, $request, $response);
/** @var \phpOMS\Localization\BaseStringL11n[] $l11nValues */ /** @var \phpOMS\Localization\BaseStringL11n[] $l11nValues */
$l11nValues = MaterialTypeL11nMapper::getAll() $l11nValues = MaterialTypeL11nMapper::getAll()
->where('ref', $view->data['type']->id) ->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; $view->data['l11nValues'] = $l11nValues;
return $view; 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;
}
} }

View File

@ -124,7 +124,7 @@ return ['ItemManagement' => [
'Text' => 'Text', 'Text' => 'Text',
'TimeUnit' => 'Zeiteinheit', 'TimeUnit' => 'Zeiteinheit',
'Title' => 'Titel', 'Title' => 'Titel',
'Defaults' => 'Standard', 'Defaults' => 'Standard',
'TopCustomers' => 'Top Kunden', 'TopCustomers' => 'Top Kunden',
'Tracking' => 'Verfolgung', 'Tracking' => 'Verfolgung',
'TradingUnit' => 'Handelseinheit', 'TradingUnit' => 'Handelseinheit',
@ -151,7 +151,7 @@ return ['ItemManagement' => [
'LeadTime' => 'Lieferzeit', 'LeadTime' => 'Lieferzeit',
'UnitQuantity' => 'Einheitsmenge', 'UnitQuantity' => 'Einheitsmenge',
'UnitPrice' => 'Einheitspreis', 'UnitPrice' => 'Einheitspreis',
'Suppliers' => 'Lieferanten', 'Suppliers' => 'Lieferanten',
'CostCenter' => 'Kostenstelle', 'CostCenter' => 'Kostenstelle',
'CostObject' => 'Kostenträger', 'CostObject' => 'Kostenträger',
'DefaultStock' => 'Standard Lager', 'DefaultStock' => 'Standard Lager',
@ -159,4 +159,8 @@ return ['ItemManagement' => [
'Inventory' => 'Bestandsführung', 'Inventory' => 'Bestandsführung',
'Identifier' => 'Identifizierung', 'Identifier' => 'Identifizierung',
'Stocktaking' => 'Inventur', 'Stocktaking' => 'Inventur',
':status-1' => 'Aktiv',
':status-2' => 'Entwurf',
':status-3' => 'Inaktiv',
':status-4' => 'Eingestellt',
]]; ]];

View File

@ -125,7 +125,7 @@ return ['ItemManagement' => [
'Text' => 'Text', 'Text' => 'Text',
'TimeUnit' => 'Unit of time', 'TimeUnit' => 'Unit of time',
'Title' => 'Title', 'Title' => 'Title',
'Defaults' => 'Defaults', 'Defaults' => 'Defaults',
'TopCustomers' => 'Top Customers', 'TopCustomers' => 'Top Customers',
'Tracking' => 'Tracking', 'Tracking' => 'Tracking',
'TradingUnit' => 'Trading Unit', 'TradingUnit' => 'Trading Unit',
@ -159,4 +159,8 @@ return ['ItemManagement' => [
'Inventory' => 'Inventory', 'Inventory' => 'Inventory',
'Identifier' => 'Identifier', 'Identifier' => 'Identifier',
'Stocktaking' => 'Stocktaking', 'Stocktaking' => 'Stocktaking',
':status-1' => 'Active',
':status-2' => 'Draft',
':status-3' => 'Inactive',
':status-4' => 'Discontinued',
]]; ]];

View File

@ -12,13 +12,13 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
use Modules\Billing\Models\BillTransferType;
use Modules\Billing\Models\Price\PriceType; use Modules\Billing\Models\Price\PriceType;
use Modules\Billing\Models\SalesBillMapper; use Modules\Billing\Models\SalesBillMapper;
use Modules\ItemManagement\Models\ItemStatus;
use Modules\ItemManagement\Models\NullItem;
use Modules\Media\Models\NullMedia; use Modules\Media\Models\NullMedia;
use Modules\WarehouseManagement\Models\StockLocationMapper; use Modules\WarehouseManagement\Models\StockLocationMapper;
use Modules\WarehouseManagement\Models\StockMapper; use Modules\WarehouseManagement\Models\StockMapper;
use phpOMS\DataStorage\Database\Query\OrderType;
use phpOMS\Localization\ISO3166CharEnum; use phpOMS\Localization\ISO3166CharEnum;
use phpOMS\Localization\ISO3166NameEnum; use phpOMS\Localization\ISO3166NameEnum;
use phpOMS\Localization\ISO4217CharEnum; use phpOMS\Localization\ISO4217CharEnum;
@ -31,29 +31,27 @@ use phpOMS\Stdlib\Base\SmartDateTime;
use phpOMS\Uri\UriFactory; use phpOMS\Uri\UriFactory;
/** @var \Modules\ItemManagement\Models\Item $item */ /** @var \Modules\ItemManagement\Models\Item $item */
$item = $this->data['item']; $item = $this->data['item'] ?? new NullItem();
$isNew = $item->id === 0;
$logs = $this->data['logs'] ?? []; $logs = $this->data['logs'] ?? [];
$notes = $item->notes;
$files = $item->files;
$itemImage = $this->getData('itemImage') ?? new NullMedia(); $itemImage = $this->getData('itemImage') ?? new NullMedia();
$allInvoices = $this->data['allInvoices'] ?? []; $allInvoices = $this->data['allInvoices'] ?? [];
$topCustomers = $this->getData('topCustomers') ?? [[], []]; $topCustomers = $this->getData('topCustomers') ?? [[], []];
$attributeView = $this->data['attributeView'];
$l11nView = $this->data['l11nView'];
$languages = ISO639Enum::getConstants();
$languages = ISO639Enum::getConstants();
$regions = RegionEnum::getConstants(); $regions = RegionEnum::getConstants();
$countries = ISO3166CharEnum::getConstants(); $countries = ISO3166CharEnum::getConstants();
$currencies = ISO4217CharEnum::getConstants(); $currencies = ISO4217CharEnum::getConstants();
$itemStatus = ItemStatus::getConstants();
echo $this->data['nav']->render(); echo $this->data['nav']->render();
?> ?>
<div class="tabview tab-2"> <div class="tabview tab-2">
<?php if (!$isNew) : ?>
<div class="box"> <div class="box">
<ul class="tab-links"> <ul class="tab-links">
<li><label for="c-tab-1"><?= $this->getHtml('Profile'); ?></label> <li><label for="c-tab-1"><?= $this->getHtml('Profile'); ?></label>
@ -72,10 +70,11 @@ echo $this->data['nav']->render();
<?php if (!empty($logs)) : ?><li><label for="c-tab-15"><?= $this->getHtml('Logs'); ?></label><?php endif; ?> <?php if (!empty($logs)) : ?><li><label for="c-tab-15"><?= $this->getHtml('Logs'); ?></label><?php endif; ?>
</ul> </ul>
</div> </div>
<?php endif; ?>
<div class="tab-content"> <div class="tab-content">
<input type="radio" id="c-tab-1" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>> <input type="radio" id="c-tab-1" name="tabular-2"<?= $isNew || $this->request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>>
<div class="tab"> <div class="tab">
<?php if (!empty($notes) && ($warning = $item->getEditorDocByTypeName('item_backend_warning'))->id !== 0) : ?> <?php if (!empty($item->notes) && ($warning = $item->getEditorDocByTypeName('item_backend_warning'))->id !== 0) : ?>
<!-- If note warning exists --> <!-- If note warning exists -->
<div class="row"> <div class="row">
<div class="col-xs-12"> <div class="col-xs-12">
@ -89,24 +88,44 @@ echo $this->data['nav']->render();
<div class="row"> <div class="row">
<div class="col-xs-12 col-lg-3 last-lg"> <div class="col-xs-12 col-lg-3 last-lg">
<section class="portlet"> <section class="portlet">
<form> <form id="itemForm" method="<?= $isNew ? 'PUT' : 'POST'; ?>" action="<?= UriFactory::build('{/api}item?csrf={$CSRF}'); ?>">
<div class="portlet-body"> <div class="portlet-body">
<table class="layout wf-100"> <div class="form-group">
<tr><td><label for="iId"><?= $this->getHtml('ID', '0', '0'); ?></label> <?= $this->getHtml('ID', '0', '0'); ?></label>
<tr><td><span class="input"><button type="button" formaction=""><i class="g-icon">book</i></button><input type="text" id="iId" min="1" name="id" value="<?= $this->printHtml($item->number); ?>" disabled></span> <span class="input"><button type="button" formaction=""><i class="g-icon">book</i></button><input type="text" id="iId" min="1" name="id" value="<?= $this->printHtml($item->number); ?>"<?= $isNew ? ' required' : ' disabled'; ?>></span>
<tr><td><label for="iName1"><?= $this->getHtml('Name1'); ?></label> </div>
<tr><td><input type="text" id="iName1" name="name1" value="<?= $this->printHtml($item->getL11n('name1')->content); ?>" spellcheck="false" required>
<tr><td><label for="iName2"><?= $this->getHtml('Name2'); ?></label> <div class="form-group">
<tr><td><input type="text" id="iName2" name="name2" value="<?= $this->printHtml($item->getL11n('name2')->content); ?>" spellcheck="false"> <label for="iStatus"><?= $this->getHtml('Status'); ?></label>
</table> <select id="iStatus" name="status">
<?php foreach ($itemStatus as $status) : ?>
<option value="<?= $status; ?>"<?= $item->status === $status ? ' selected': ''; ?>><?= $this->getHtml(':status-' . $status); ?>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label for="iName1"><?= $this->getHtml('Name1'); ?></label>
<input type="text" id="iName1" name="name1" value="<?= $this->printHtml($item->getL11n('name1')->content); ?>" spellcheck="false" required>
</div>
<div class="form-group">
<label for="iName2"><?= $this->getHtml('Name2'); ?></label>
<input type="text" id="iName2" name="name2" value="<?= $this->printHtml($item->getL11n('name2')->content); ?>" spellcheck="false">
</div>
</div> </div>
<div class="portlet-foot"> <div class="portlet-foot">
<input type="submit" value="<?= $this->getHtml('Save', '0', '0'); ?>" name="save-item"> <?php if ($isNew) : ?>
<input class="right-xs cancel" type="submit" value="<?= $this->getHtml('Delete', '0', '0'); ?>" name="delete-item"> <input type="submit" value="<?= $this->getHtml('Create', '0', '0'); ?>" name="create-item">
<?php else : ?>
<input type="submit" value="<?= $this->getHtml('Save', '0', '0'); ?>" name="save-item">
<input class="cancel end-xs" type="submit" value="<?= $this->getHtml('Delete', '0', '0'); ?>" name="delete-item">
<?php endif; ?>
</div> </div>
</form> </form>
</section> </section>
<?php if (!$isNew) : ?>
<section class="portlet"> <section class="portlet">
<div class="portlet-body"> <div class="portlet-body">
<img alt="<?= $this->printHtml($itemImage->name); ?>" width="100%" loading="lazy" class="item-image" <img alt="<?= $this->printHtml($itemImage->name); ?>" width="100%" loading="lazy" class="item-image"
@ -121,9 +140,12 @@ echo $this->data['nav']->render();
<textarea class="undecorated"></textarea> <textarea class="undecorated"></textarea>
</div> </div>
</section> </section>
<?php endif; ?>
</div> </div>
<?php if (!$isNew) : ?>
<div class="col-xs-12 col-lg-9 plain-grid"> <div class="col-xs-12 col-lg-9 plain-grid">
<?php if ($this->data['hasBilling']) : ?> <?php if ($this->data['hasBilling'] ?? false) : ?>
<div class="row"> <div class="row">
<div class="col-xs-12 col-lg-4"> <div class="col-xs-12 col-lg-4">
<section class="portlet hl-7"> <section class="portlet hl-7">
@ -192,7 +214,7 @@ echo $this->data['nav']->render();
<tbody> <tbody>
<?php <?php
$count = 0; $count = 0;
foreach ($notes as $note) : foreach ($item->notes as $note) :
++$count; ++$count;
$url = UriFactory::build('{/base}/editor/view?{?}&id=' . $note->id); $url = UriFactory::build('{/base}/editor/view?{?}&id=' . $note->id);
?> ?>
@ -224,7 +246,7 @@ echo $this->data['nav']->render();
<tbody> <tbody>
<?php <?php
$count = 0; $count = 0;
foreach ($files as $file) : foreach ($item->files as $file) :
++$count; ++$count;
$url = UriFactory::build('{/base}/media/view?{?}&id=' . $file->id); $url = UriFactory::build('{/base}/media/view?{?}&id=' . $file->id);
?> ?>
@ -242,7 +264,7 @@ echo $this->data['nav']->render();
</div> </div>
</div> </div>
<?php if ($this->data['hasBilling']) : ?> <?php if ($this->data['hasBilling'] ?? false) : ?>
<div class="row"> <div class="row">
<div class="col-xs-12"> <div class="col-xs-12">
<section class="portlet"> <section class="portlet">
@ -265,12 +287,13 @@ echo $this->data['nav']->render();
/** @var \Modules\Billing\Models\Bill $invoice */ /** @var \Modules\Billing\Models\Bill $invoice */
foreach ($newestInvoices as $invoice) : foreach ($newestInvoices as $invoice) :
++$count; ++$count;
$url = UriFactory::build('{/base}/sales/bill?{?}&id=' . $invoice->id); $url = UriFactory::build('{/base}/sales/bill/view?{?}&id=' . $invoice->id);
$clientUrl = UriFactory::build('{/base}/sales/client/view?{?}&id=' . $invoice->client->id);
?> ?>
<tr data-href="<?= $url; ?>"> <tr data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><?= $this->printHtml($invoice->getNumber()); ?></a> <td><a href="<?= $url; ?>"><?= $this->printHtml($invoice->getNumber()); ?></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($invoice->type->getL11n()); ?></a> <td><a href="<?= $url; ?>"><?= $this->printHtml($invoice->type->getL11n()); ?></a>
<td><a class="content" href="<?= UriFactory::build('{/base}/sales/client/view?{?}&id=' . $invoice->client->id); ?>"><?= $this->printHtml($invoice->billTo); ?></a> <td><a class="content" href="<?= $clientUrl; ?>"><?= $this->printHtml($invoice->billTo); ?></a>
<td><a href="<?= $url; ?>"><?= $this->getCurrency($invoice->netSales, symbol: ''); ?></a> <td><a href="<?= $url; ?>"><?= $this->getCurrency($invoice->netSales, symbol: ''); ?></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($invoice->performanceDate->format('Y-m-d')); ?></a> <td><a href="<?= $url; ?>"><?= $this->printHtml($invoice->performanceDate->format('Y-m-d')); ?></a>
<?php endforeach; ?> <?php endforeach; ?>
@ -284,7 +307,7 @@ echo $this->data['nav']->render();
</div> </div>
<?php endif; ?> <?php endif; ?>
<?php if ($this->data['hasBilling']) : <?php if ($this->data['hasBilling'] ?? false) :
$topCustomers = SalesBillMapper::getItemTopClients($item->id, (new SmartDateTime('now'))->createModify(-1), new SmartDateTime('now'), 5); $topCustomers = SalesBillMapper::getItemTopClients($item->id, (new SmartDateTime('now'))->createModify(-1), new SmartDateTime('now'), 5);
?> ?>
<div class="row"> <div class="row">
@ -467,12 +490,15 @@ echo $this->data['nav']->render();
</div> </div>
<?php endif; ?> <?php endif; ?>
</div> </div>
<?php endif; ?>
</div> </div>
</div> </div>
<?php if (!$isNew) : ?>
<input type="radio" id="c-tab-2" name="tabular-2" checked> <input type="radio" id="c-tab-2" name="tabular-2" checked>
<div class="tab"> <div class="tab">
<div class="row"> <div class="row">
<?= $l11nView->render( <?= $this->data['l11nView']->render(
$this->data['l11nValues'], $this->data['l11nValues'],
$this->data['l11nTypes'] ?? [], $this->data['l11nTypes'] ?? [],
'{/api}item/l11n?csrf={$CSRF}' '{/api}item/l11n?csrf={$CSRF}'
@ -484,7 +510,7 @@ echo $this->data['nav']->render();
<input type="radio" id="c-tab-3" name="tabular-2" checked> <input type="radio" id="c-tab-3" name="tabular-2" checked>
<div class="tab"> <div class="tab">
<div class="row"> <div class="row">
<?= $attributeView->render( <?= $this->data['attributeView']->render(
$item->attributes, $item->attributes,
$this->data['attributeTypes'] ?? [], $this->data['attributeTypes'] ?? [],
$this->data['units'] ?? [], $this->data['units'] ?? [],
@ -1266,7 +1292,7 @@ echo $this->data['nav']->render();
$costcenters = \Modules\Accounting\Models\CostCenterMapper::getAll() $costcenters = \Modules\Accounting\Models\CostCenterMapper::getAll()
->with('l11n') ->with('l11n')
->where('l11n/language', $this->response->header->l11n->language) ->where('l11n/language', $this->response->header->l11n->language)
->execute(); ->executeGetArray();
foreach ($costcenters as $cc) : ?> foreach ($costcenters as $cc) : ?>
<option value="<?= $cc->id; ?>"><?= $this->printHtml($cc->code . ' ' . $cc->getL11n()); ?> <option value="<?= $cc->id; ?>"><?= $this->printHtml($cc->code . ' ' . $cc->getL11n()); ?>
<?php endforeach; ?> <?php endforeach; ?>
@ -1281,7 +1307,7 @@ echo $this->data['nav']->render();
$costobjects = \Modules\Accounting\Models\CostObjectMapper::getAll() $costobjects = \Modules\Accounting\Models\CostObjectMapper::getAll()
->with('l11n') ->with('l11n')
->where('l11n/language', $this->response->header->l11n->language) ->where('l11n/language', $this->response->header->l11n->language)
->execute(); ->executeGetArray();
foreach ($costobjects as $co) : ?> foreach ($costobjects as $co) : ?>
<option value="<?= $co->id; ?>"><?= $this->printHtml($co->code . ' ' . $co->getL11n()); ?> <option value="<?= $co->id; ?>"><?= $this->printHtml($co->code . ' ' . $co->getL11n()); ?>
<?php endforeach; ?> <?php endforeach; ?>
@ -1310,7 +1336,7 @@ echo $this->data['nav']->render();
<label for="iItemStockDefault"><?= $this->getHtml('DefaultStock'); ?></label> <label for="iItemStockDefault"><?= $this->getHtml('DefaultStock'); ?></label>
<select id="iItemStockDefault" name="stockdefaultstock"> <select id="iItemStockDefault" name="stockdefaultstock">
<?php <?php
$stocks = StockMapper::getAll()->execute(); $stocks = StockMapper::getAll()->executeGetArray();
foreach ($stocks as $stock) : foreach ($stocks as $stock) :
?> ?>
<option value="<?= $stock->id; ?>"><?= $this->printHtml($stock->name); ?> <option value="<?= $stock->id; ?>"><?= $this->printHtml($stock->name); ?>
@ -1322,7 +1348,7 @@ echo $this->data['nav']->render();
<label for="iItemStockLocation"><?= $this->getHtml('DefaultStockLocation'); ?></label> <label for="iItemStockLocation"><?= $this->getHtml('DefaultStockLocation'); ?></label>
<select id="iItemStockLocation" name="stockdefaultlocation"> <select id="iItemStockLocation" name="stockdefaultlocation">
<?php <?php
$stocks = StockLocationMapper::getAll()->execute(); $stocks = StockLocationMapper::getAll()->executeGetArray();
foreach ($stocks as $stock) : foreach ($stocks as $stock) :
?> ?>
<option value="<?= $stock->id; ?>"><?= $this->printHtml($stock->name); ?> <option value="<?= $stock->id; ?>"><?= $this->printHtml($stock->name); ?>
@ -1409,12 +1435,13 @@ echo $this->data['nav']->render();
/** @var \Modules\Billing\Models\Bill $invoice */ /** @var \Modules\Billing\Models\Bill $invoice */
foreach ($allInvoices as $invoice) : foreach ($allInvoices as $invoice) :
++$count; ++$count;
$url = UriFactory::build('{/base}/sales/bill?{?}&id=' . $invoice->id); $url = UriFactory::build('{/base}/sales/bill/view?{?}&id=' . $invoice->id);
$clientUrl = UriFactory::build('{/base}/sales/client/view?{?}&id=' . $invoice->client->id);
?> ?>
<tr data-href="<?= $url; ?>"> <tr data-href="<?= $url; ?>">
<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 class="content" href="<?= $clientUrl; ?>"><?= $invoice->billTo; ?></a>
<td><a href="<?= $url; ?>"><?= $this->getCurrency($invoice->netSales, symbol: ''); ?></a> <td><a href="<?= $url; ?>"><?= $this->getCurrency($invoice->netSales, symbol: ''); ?></a>
<td><a href="<?= $url; ?>"><?= $invoice->performanceDate->format('Y-m-d'); ?></a> <td><a href="<?= $url; ?>"><?= $invoice->performanceDate->format('Y-m-d'); ?></a>
<td><a href="<?= $url; ?>"><?= $invoice->createdAt->format('Y-m-d'); ?></a> <td><a href="<?= $url; ?>"><?= $invoice->createdAt->format('Y-m-d'); ?></a>
@ -1492,5 +1519,6 @@ echo $this->data['nav']->render();
</div> </div>
</div> </div>
<?php endif; ?> <?php endif; ?>
<?php endif; ?>
</div> </div>
</div> </div>

View File

@ -16,8 +16,7 @@ use phpOMS\Localization\NullBaseStringL11nType;
use phpOMS\Uri\UriFactory; use phpOMS\Uri\UriFactory;
/** @var \phpOMS\Localization\BaseStringL11nType */ /** @var \phpOMS\Localization\BaseStringL11nType */
$type = $this->data['type'] ?? new NullBaseStringL11nType(); $type = $this->data['type'] ?? new NullBaseStringL11nType();
$isNew = $type->id === 0; $isNew = $type->id === 0;
/** @var \phpOMS\Views\View $this */ /** @var \phpOMS\Views\View $this */
@ -47,6 +46,7 @@ echo $this->data['nav']->render(); ?>
</div> </div>
</div> </div>
<?php if (!$isNew) : ?>
<div class="row"> <div class="row">
<?= $this->data['l11nView']->render( <?= $this->data['l11nView']->render(
$this->data['l11nValues'], $this->data['l11nValues'],
@ -54,4 +54,5 @@ echo $this->data['nav']->render(); ?>
'{/api}item/material/l11n?csrf={$CSRF}' '{/api}item/material/l11n?csrf={$CSRF}'
); );
?> ?>
</div> </div>
<?php endif; ?>