From f3e313043bbcd19e1835f8f8d85c0d82ff55b011 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 13 Jun 2023 18:55:51 +0000 Subject: [PATCH] Quick backup before crash --- Admin/Installer.php | 16 ++++++++-------- Controller/ApiController.php | 4 ++-- Controller/BackendController.php | 11 ++++++++++- Models/Item.php | 12 ++---------- Models/ItemL11nMapper.php | 2 +- Models/ItemMapper.php | 18 ++++++++++++++---- Models/ItemPrice.php | 4 ++-- Theme/Backend/Lang/en.lang.php | 1 - 8 files changed, 39 insertions(+), 29 deletions(-) diff --git a/Admin/Installer.php b/Admin/Installer.php index be65f95..f29038f 100755 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -112,7 +112,7 @@ final class Installer extends InstallerAbstract /** @var \Modules\Attribute\Models\AttributeType[] $attributeTypes */ $attributeTypes = ItemAttributeTypeMapper::getAll()->with('defaults')->execute(); - /** @var \Modules\ItemManagement\Models\ItemL11nType[] $l11nTypes */ + /** @var \phpOMS\Localization\BaseStringL11nType[] $l11nTypes */ $l11nTypes = ItemL11nTypeMapper::getAll()->execute(); // Change indexing for easier search later on. @@ -292,10 +292,10 @@ final class Installer extends InstallerAbstract /** * Install default attribute types * - * @param ApplicationAbstract $app Application - * @param array, is_required?:bool, is_custom_allowed?:bool, validation_pattern?:string, value_type?:string, values?:array}> $attributes Attribute definition + * @param ApplicationAbstract $app Application + * @param array $attributes Attribute definition * - * @return array + * @return array * * @since 1.0.0 */ @@ -357,11 +357,11 @@ final class Installer extends InstallerAbstract /** * Create default attribute values for types * - * @param ApplicationAbstract $app Application - * @param array $itemAttrType Attribute types - * @param array, is_required?:bool, is_custom_allowed?:bool, validation_pattern?:string, value_type?:string, values?:array}> $attributes Attribute definition + * @param ApplicationAbstract $app Application + * @param array $itemAttrType Attribute types + * @param array $attributes Attribute definition * - * @return array + * @return array * * @since 1.0.0 */ diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 2104d50..90acf15 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -80,7 +80,7 @@ final class ApiController extends Controller */ public function apiItemFind(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { - /** @var \Modules\ItemManagement\Models\BaseStringL11n[] $l11n */ + /** @var BaseStringL11n[] $l11n */ $l11n = ItemL11nMapper::getAll() ->with('type') ->where('type/title', ['name1', 'name2', 'name3'], 'IN') @@ -90,7 +90,7 @@ final class ApiController extends Controller $items = []; foreach ($l11n as $item) { - $items[] = $item->item; + $items[] = $item->ref; } /** @var \Modules\ItemManagement\Models\Item[] $itemList */ diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 16b4014..6a42026 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -402,27 +402,31 @@ final class BackendController extends Controller SettingsEnum::DEFAULT_LOCALIZATION, ]); - $view->data['attributeView'] = new \Modules\Attribute\Theme\Backend\Components\AttributeView($this->app->l11nManager, $request, $response); + $view->data['attributeView'] = new \Modules\Attribute\Theme\Backend\Components\AttributeView($this->app->l11nManager, $request, $response); $view->data['attributeView']->data['defaultlocalization'] = LocalizationMapper::get()->where('id', (int) $settings->id)->execute(); $l11nTypes = ItemL11nTypeMapper::getAll() ->execute(); + $view->data['l11nTypes'] = $l11nTypes; $l11nValues = ItemL11nMapper::getAll() ->with('type') ->where('ref', $item->id) ->execute(); + $view->data['l11nValues'] = $l11nValues; $attributeTypes = ItemAttributeTypeMapper::getAll() ->with('l11n') ->where('l11n/language', $response->header->l11n->language) ->execute(); + $view->data['attributeTypes'] = $attributeTypes; $units = UnitMapper::getAll() ->execute(); + $view->data['units'] = $units; $prices = PriceMapper::getAll() @@ -430,6 +434,7 @@ final class BackendController extends Controller ->where('type', PriceType::SALES) ->where('client', null) ->execute(); + $view->data['prices'] = $prices; $audits = AuditMapper::getAll() @@ -437,6 +442,7 @@ final class BackendController extends Controller ->where('module', 'ItemManagement') ->where('ref', $item->id) ->execute(); + $view->data['audits'] = $audits; $files = MediaMapper::getAll() @@ -444,6 +450,7 @@ final class BackendController extends Controller ->join('id', ItemMapper::class, 'files') // id = media id, files = item relations ->on('id', $item->id, relation: 'files') // id = item id ->execute(); + $view->data['files'] = $files; $mediaListView = new \Modules\Media\Theme\Backend\Components\Media\ListView($this->app->l11nManager, $request, $response); @@ -679,6 +686,7 @@ final class BackendController extends Controller ///// $currentCustomersCountry = []; for ($i = 1; $i < 51; ++$i) { + /** @var string $country */ $country = ISO3166NameEnum::getRandom(); $currentCustomersCountry[\substr($country, 0, 20)] = [ 'customers' => (int) (\mt_rand(200, 400) / 12), @@ -693,6 +701,7 @@ final class BackendController extends Controller $annualCustomersCountry = []; for ($i = 1; $i < 51; ++$i) { + /** @var string $countryCode */ $countryCode = ISO3166CharEnum::getRandom(); $countryName = ISO3166NameEnum::getByName('_' . $countryCode); $annualCustomersCountry[\substr($countryName, 0, 20)] = []; diff --git a/Models/Item.php b/Models/Item.php index 3028f01..452ca3c 100755 --- a/Models/Item.php +++ b/Models/Item.php @@ -85,14 +85,6 @@ class Item implements \JsonSerializable */ public FloatInt $purchasePrice; - /** - * Notes. - * - * @var EditorDoc[] - * @since 1.0.0 - */ - private array $notes = []; - /** * Localizations. * @@ -177,7 +169,7 @@ class Item implements \JsonSerializable public function addL11n(BaseStringL11n $l11n) : void { foreach ($this->l11n as $l11n) { - if ($l11n->type->title === $l11n->type->title) { + if ($l11n->type?->title === $l11n->type?->title) { return; } } @@ -197,7 +189,7 @@ class Item implements \JsonSerializable public function getL11n(string $type = null) : BaseStringL11n { foreach ($this->l11n as $l11n) { - if ($l11n->type->title === $type) { + if ($l11n->type?->title === $type) { return $l11n; } } diff --git a/Models/ItemL11nMapper.php b/Models/ItemL11nMapper.php index 3803d28..1f5a4fe 100755 --- a/Models/ItemL11nMapper.php +++ b/Models/ItemL11nMapper.php @@ -25,7 +25,7 @@ use phpOMS\Localization\BaseStringL11n; * @link https://jingga.app * @since 1.0.0 * - * @template T of ItemL11n + * @template T of BaseStringL11n * @extends DataMapperFactory */ final class ItemL11nMapper extends DataMapperFactory diff --git a/Models/ItemMapper.php b/Models/ItemMapper.php index fb2f7c5..3c1e1a8 100755 --- a/Models/ItemMapper.php +++ b/Models/ItemMapper.php @@ -101,8 +101,18 @@ final class ItemMapper extends DataMapperFactory ], ]; - // @todo: experimental (not 100% working) - public static function getItemList(string $langugae) : array + /** + * Get the item list + * + * @param string $language Language + * + * @return array + * + * @todo: experimental (not 100% working) + * + * @since 1.0.0 + */ + public static function getItemList(string $language) : array { // items $query = <<salesPrice->setInt($res['itemmgmt_item_salesprice']); if ($media !== null) { - $item->addFile($media); + $item->files[$media->id] = $media; } $items[$item->id] = $item; @@ -166,7 +176,7 @@ final class ItemMapper extends DataMapperFactory SQL; $sth = self::$db->con->prepare($query); - $sth->execute(['lang' => $langugae]); + $sth->execute(['lang' => $language]); $l11nsResult = $sth->fetchAll(); diff --git a/Models/ItemPrice.php b/Models/ItemPrice.php index 4b2e242..07055a0 100755 --- a/Models/ItemPrice.php +++ b/Models/ItemPrice.php @@ -14,8 +14,8 @@ declare(strict_types=1); namespace Modules\ItemManagement\Models; -use phpOMS\Localization\Money; use phpOMS\Stdlib\Base\Exception\InvalidEnumValue; +use phpOMS\Stdlib\Base\FloatInt; /** * Account class. @@ -39,7 +39,7 @@ class ItemPrice implements \JsonSerializable public string $currency = ''; - public Money $price; + public FloatInt $price; public int $status = ItemPriceStatus::ACTIVE; diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php index 01a68d0..14b6eb2 100755 --- a/Theme/Backend/Lang/en.lang.php +++ b/Theme/Backend/Lang/en.lang.php @@ -34,7 +34,6 @@ return ['ItemManagement' => [ 'AvgPrice' => 'Avg. Price', 'Bills' => 'Bills', 'Bonus' => 'Bonus', - 'ClientGroup' => 'Client/Group', 'Commission' => 'Commission', 'Container' => 'Container', 'CostCenter' => 'CostCenter',