diff --git a/Admin/Install/db.json b/Admin/Install/db.json index 26bef02..610bc60 100755 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -258,6 +258,11 @@ "type": "TINYINT(1)", "null": false }, + "investmgmt_attr_type_repeatable": { + "name": "investmgmt_attr_type_repeatable", + "type": "TINYINT(1)", + "null": false + }, "investmgmt_attr_type_required": { "description": "Every item must have this attribute type if set to true.", "name": "investmgmt_attr_type_required", diff --git a/Controller/ApiAttributeController.php b/Controller/ApiAttributeController.php index e25d875..e888406 100644 --- a/Controller/ApiAttributeController.php +++ b/Controller/ApiAttributeController.php @@ -61,7 +61,23 @@ final class ApiAttributeController extends Controller return; } - $type = InvestmentObjectAttributeTypeMapper::get()->with('defaults')->where('id', (int) $request->getData('type'))->execute(); + $type = InvestmentObjectAttributeTypeMapper::get()->with('defaults')->where('id', (int) $request->getData('type'))->execute(); + + if (!$type->repeatable) { + $attr = InvestmentObjectAttributeMapper::count() + ->with('type') + ->where('type/id', (int) $request->getData('type')) + ->where('ref', (int) $request->getData('ref')) + ->execute(); + + if ($attr > 0) { + $response->header->status = RequestStatusCode::R_409; + $this->createInvalidCreateResponse($request, $response, $val); + + return; + } + } + $attribute = $this->createAttributeFromRequest($request, $type); $this->createModel($request->header->account, $attribute, InvestmentObjectAttributeMapper::class, 'attribute', $request->getOrigin()); $this->createStandardCreateResponse($request, $response, $attribute); diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 8ad8713..6b17ca8 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -96,12 +96,10 @@ final class BackendController extends Controller $view->data['object'] = $object; /** @var \Model\Setting $settings */ - $settings = $this->app->appSettings->get(null, [ - SettingsEnum::DEFAULT_LOCALIZATION, - ]); + $settings = $this->app->appSettings->get(null, SettingsEnum::DEFAULT_LOCALIZATION); $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(); + $view->data['attributeView']->data['default_localization'] = LocalizationMapper::get()->where('id', (int) $settings->id)->execute(); $view->data['media-upload'] = new \Modules\Media\Theme\Backend\Components\Upload\BaseView($this->app->l11nManager, $request, $response); @@ -129,11 +127,11 @@ final class BackendController extends Controller $investment = InvestmentMapper::get() ->with('notes') ->with('files') - ->with('supplier') - ->with('supplier/account') - ->with('item') ->with('createdBy') ->with('options') + ->with('options/supplier') + ->with('options/supplier/account') + ->with('options/item') ->with('options/files') ->with('options/notes') ->with('options/amountGroups') @@ -144,18 +142,16 @@ final class BackendController extends Controller ->with('options/attributes/type/l11n') ->with('options/attributes/value') ->where('id', (int) $request->getData('id')) - ->where('options/attributes/type/l11n/language', $response->header->l11n->language) + //->where('options/attributes/type/l11n/language', $response->header->l11n->language) ->execute(); $view->data['investment'] = $investment; /** @var \Model\Setting $settings */ - $settings = $this->app->appSettings->get(null, [ - SettingsEnum::DEFAULT_LOCALIZATION, - ]); + $settings = $this->app->appSettings->get(null, SettingsEnum::DEFAULT_LOCALIZATION); $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(); + $view->data['attributeView']->data['default_localization'] = LocalizationMapper::get()->where('id', (int) $settings->id)->execute(); $investmentTypes = InvestmentTypeMapper::getAll() ->with('l11n') diff --git a/Models/Attribute/InvestmentObjectAttributeTypeMapper.php b/Models/Attribute/InvestmentObjectAttributeTypeMapper.php index 00eef59..ecf8c78 100644 --- a/Models/Attribute/InvestmentObjectAttributeTypeMapper.php +++ b/Models/Attribute/InvestmentObjectAttributeTypeMapper.php @@ -42,6 +42,7 @@ final class InvestmentObjectAttributeTypeMapper extends DataMapperFactory 'investmgmt_attr_type_datatype' => ['name' => 'investmgmt_attr_type_datatype', 'type' => 'int', 'internal' => 'datatype'], 'investmgmt_attr_type_fields' => ['name' => 'investmgmt_attr_type_fields', 'type' => 'int', 'internal' => 'fields'], 'investmgmt_attr_type_custom' => ['name' => 'investmgmt_attr_type_custom', 'type' => 'bool', 'internal' => 'custom'], + 'investmgmt_attr_type_repeatable' => ['name' => 'investmgmt_attr_type_repeatable', 'type' => 'bool', 'internal' => 'repeatable'], 'investmgmt_attr_type_pattern' => ['name' => 'investmgmt_attr_type_pattern', 'type' => 'string', 'internal' => 'validationPattern'], 'investmgmt_attr_type_required' => ['name' => 'investmgmt_attr_type_required', 'type' => 'bool', 'internal' => 'isRequired'], ]; diff --git a/Models/InvestmentObjectMapper.php b/Models/InvestmentObjectMapper.php index f10c557..2fe84b7 100644 --- a/Models/InvestmentObjectMapper.php +++ b/Models/InvestmentObjectMapper.php @@ -97,7 +97,7 @@ final class InvestmentObjectMapper extends DataMapperFactory 'attributes' => [ 'mapper' => InvestmentObjectAttributeMapper::class, 'table' => 'investmgmt_option_attr', - 'self' => 'investmgmt_option_attr_item', + 'self' => 'investmgmt_option_attr_type', 'external' => null, ], ]; diff --git a/Theme/Backend/Lang/ar.lang.php b/Theme/Backend/Lang/ar.lang.php index 2be2299..336ab69 100644 --- a/Theme/Backend/Lang/ar.lang.php +++ b/Theme/Backend/Lang/ar.lang.php @@ -13,10 +13,6 @@ declare(strict_types=1); return ['InvestmentManagement' => [ - ':status1' => '', - ':status2' => '', - ':status3' => '', - ':status4' => '', 'Creator' => '', 'Investment' => '', 'Investments' => '', diff --git a/Theme/Backend/Lang/cs.lang.php b/Theme/Backend/Lang/cs.lang.php index 2be2299..336ab69 100644 --- a/Theme/Backend/Lang/cs.lang.php +++ b/Theme/Backend/Lang/cs.lang.php @@ -13,10 +13,6 @@ declare(strict_types=1); return ['InvestmentManagement' => [ - ':status1' => '', - ':status2' => '', - ':status3' => '', - ':status4' => '', 'Creator' => '', 'Investment' => '', 'Investments' => '', diff --git a/Theme/Backend/Lang/da.lang.php b/Theme/Backend/Lang/da.lang.php index 2be2299..336ab69 100644 --- a/Theme/Backend/Lang/da.lang.php +++ b/Theme/Backend/Lang/da.lang.php @@ -13,10 +13,6 @@ declare(strict_types=1); return ['InvestmentManagement' => [ - ':status1' => '', - ':status2' => '', - ':status3' => '', - ':status4' => '', 'Creator' => '', 'Investment' => '', 'Investments' => '', diff --git a/Theme/Backend/Lang/el.lang.php b/Theme/Backend/Lang/el.lang.php index 2be2299..336ab69 100644 --- a/Theme/Backend/Lang/el.lang.php +++ b/Theme/Backend/Lang/el.lang.php @@ -13,10 +13,6 @@ declare(strict_types=1); return ['InvestmentManagement' => [ - ':status1' => '', - ':status2' => '', - ':status3' => '', - ':status4' => '', 'Creator' => '', 'Investment' => '', 'Investments' => '', diff --git a/Theme/Backend/Lang/es.lang.php b/Theme/Backend/Lang/es.lang.php index 2be2299..336ab69 100644 --- a/Theme/Backend/Lang/es.lang.php +++ b/Theme/Backend/Lang/es.lang.php @@ -13,10 +13,6 @@ declare(strict_types=1); return ['InvestmentManagement' => [ - ':status1' => '', - ':status2' => '', - ':status3' => '', - ':status4' => '', 'Creator' => '', 'Investment' => '', 'Investments' => '', diff --git a/Theme/Backend/Lang/fi.lang.php b/Theme/Backend/Lang/fi.lang.php index 2be2299..336ab69 100644 --- a/Theme/Backend/Lang/fi.lang.php +++ b/Theme/Backend/Lang/fi.lang.php @@ -13,10 +13,6 @@ declare(strict_types=1); return ['InvestmentManagement' => [ - ':status1' => '', - ':status2' => '', - ':status3' => '', - ':status4' => '', 'Creator' => '', 'Investment' => '', 'Investments' => '', diff --git a/Theme/Backend/Lang/fr.lang.php b/Theme/Backend/Lang/fr.lang.php index 2be2299..336ab69 100644 --- a/Theme/Backend/Lang/fr.lang.php +++ b/Theme/Backend/Lang/fr.lang.php @@ -13,10 +13,6 @@ declare(strict_types=1); return ['InvestmentManagement' => [ - ':status1' => '', - ':status2' => '', - ':status3' => '', - ':status4' => '', 'Creator' => '', 'Investment' => '', 'Investments' => '', diff --git a/Theme/Backend/Lang/hu.lang.php b/Theme/Backend/Lang/hu.lang.php index 2be2299..336ab69 100644 --- a/Theme/Backend/Lang/hu.lang.php +++ b/Theme/Backend/Lang/hu.lang.php @@ -13,10 +13,6 @@ declare(strict_types=1); return ['InvestmentManagement' => [ - ':status1' => '', - ':status2' => '', - ':status3' => '', - ':status4' => '', 'Creator' => '', 'Investment' => '', 'Investments' => '', diff --git a/Theme/Backend/Lang/it.lang.php b/Theme/Backend/Lang/it.lang.php index 2be2299..336ab69 100644 --- a/Theme/Backend/Lang/it.lang.php +++ b/Theme/Backend/Lang/it.lang.php @@ -13,10 +13,6 @@ declare(strict_types=1); return ['InvestmentManagement' => [ - ':status1' => '', - ':status2' => '', - ':status3' => '', - ':status4' => '', 'Creator' => '', 'Investment' => '', 'Investments' => '', diff --git a/Theme/Backend/Lang/ja.lang.php b/Theme/Backend/Lang/ja.lang.php index 2be2299..336ab69 100644 --- a/Theme/Backend/Lang/ja.lang.php +++ b/Theme/Backend/Lang/ja.lang.php @@ -13,10 +13,6 @@ declare(strict_types=1); return ['InvestmentManagement' => [ - ':status1' => '', - ':status2' => '', - ':status3' => '', - ':status4' => '', 'Creator' => '', 'Investment' => '', 'Investments' => '', diff --git a/Theme/Backend/Lang/ko.lang.php b/Theme/Backend/Lang/ko.lang.php index 2be2299..336ab69 100644 --- a/Theme/Backend/Lang/ko.lang.php +++ b/Theme/Backend/Lang/ko.lang.php @@ -13,10 +13,6 @@ declare(strict_types=1); return ['InvestmentManagement' => [ - ':status1' => '', - ':status2' => '', - ':status3' => '', - ':status4' => '', 'Creator' => '', 'Investment' => '', 'Investments' => '', diff --git a/Theme/Backend/Lang/no.lang.php b/Theme/Backend/Lang/no.lang.php index 2be2299..336ab69 100644 --- a/Theme/Backend/Lang/no.lang.php +++ b/Theme/Backend/Lang/no.lang.php @@ -13,10 +13,6 @@ declare(strict_types=1); return ['InvestmentManagement' => [ - ':status1' => '', - ':status2' => '', - ':status3' => '', - ':status4' => '', 'Creator' => '', 'Investment' => '', 'Investments' => '', diff --git a/Theme/Backend/Lang/pl.lang.php b/Theme/Backend/Lang/pl.lang.php index 2be2299..336ab69 100644 --- a/Theme/Backend/Lang/pl.lang.php +++ b/Theme/Backend/Lang/pl.lang.php @@ -13,10 +13,6 @@ declare(strict_types=1); return ['InvestmentManagement' => [ - ':status1' => '', - ':status2' => '', - ':status3' => '', - ':status4' => '', 'Creator' => '', 'Investment' => '', 'Investments' => '', diff --git a/Theme/Backend/Lang/pt.lang.php b/Theme/Backend/Lang/pt.lang.php index 2be2299..336ab69 100644 --- a/Theme/Backend/Lang/pt.lang.php +++ b/Theme/Backend/Lang/pt.lang.php @@ -13,10 +13,6 @@ declare(strict_types=1); return ['InvestmentManagement' => [ - ':status1' => '', - ':status2' => '', - ':status3' => '', - ':status4' => '', 'Creator' => '', 'Investment' => '', 'Investments' => '', diff --git a/Theme/Backend/Lang/ru.lang.php b/Theme/Backend/Lang/ru.lang.php index 2be2299..336ab69 100644 --- a/Theme/Backend/Lang/ru.lang.php +++ b/Theme/Backend/Lang/ru.lang.php @@ -13,10 +13,6 @@ declare(strict_types=1); return ['InvestmentManagement' => [ - ':status1' => '', - ':status2' => '', - ':status3' => '', - ':status4' => '', 'Creator' => '', 'Investment' => '', 'Investments' => '', diff --git a/Theme/Backend/Lang/sv.lang.php b/Theme/Backend/Lang/sv.lang.php index 2be2299..336ab69 100644 --- a/Theme/Backend/Lang/sv.lang.php +++ b/Theme/Backend/Lang/sv.lang.php @@ -13,10 +13,6 @@ declare(strict_types=1); return ['InvestmentManagement' => [ - ':status1' => '', - ':status2' => '', - ':status3' => '', - ':status4' => '', 'Creator' => '', 'Investment' => '', 'Investments' => '', diff --git a/Theme/Backend/Lang/th.lang.php b/Theme/Backend/Lang/th.lang.php index 2be2299..336ab69 100644 --- a/Theme/Backend/Lang/th.lang.php +++ b/Theme/Backend/Lang/th.lang.php @@ -13,10 +13,6 @@ declare(strict_types=1); return ['InvestmentManagement' => [ - ':status1' => '', - ':status2' => '', - ':status3' => '', - ':status4' => '', 'Creator' => '', 'Investment' => '', 'Investments' => '', diff --git a/Theme/Backend/Lang/tr.lang.php b/Theme/Backend/Lang/tr.lang.php index 2be2299..336ab69 100644 --- a/Theme/Backend/Lang/tr.lang.php +++ b/Theme/Backend/Lang/tr.lang.php @@ -13,10 +13,6 @@ declare(strict_types=1); return ['InvestmentManagement' => [ - ':status1' => '', - ':status2' => '', - ':status3' => '', - ':status4' => '', 'Creator' => '', 'Investment' => '', 'Investments' => '', diff --git a/Theme/Backend/Lang/uk.lang.php b/Theme/Backend/Lang/uk.lang.php index 2be2299..336ab69 100644 --- a/Theme/Backend/Lang/uk.lang.php +++ b/Theme/Backend/Lang/uk.lang.php @@ -13,10 +13,6 @@ declare(strict_types=1); return ['InvestmentManagement' => [ - ':status1' => '', - ':status2' => '', - ':status3' => '', - ':status4' => '', 'Creator' => '', 'Investment' => '', 'Investments' => '', diff --git a/Theme/Backend/Lang/zh.lang.php b/Theme/Backend/Lang/zh.lang.php index 2be2299..336ab69 100644 --- a/Theme/Backend/Lang/zh.lang.php +++ b/Theme/Backend/Lang/zh.lang.php @@ -13,10 +13,6 @@ declare(strict_types=1); return ['InvestmentManagement' => [ - ':status1' => '', - ':status2' => '', - ':status3' => '', - ':status4' => '', 'Creator' => '', 'Investment' => '', 'Investments' => '',