diff --git a/Admin/Install/Navigation.install.json b/Admin/Install/Navigation.install.json index 8d24ce7..80f682a 100755 --- a/Admin/Install/Navigation.install.json +++ b/Admin/Install/Navigation.install.json @@ -58,6 +58,37 @@ "from": "InvestmentManagement", "permission": { "permission": 2, "category": null, "element": null }, "parent": 1003401001, - "children": [] + "children": [ + { + "id": 1007104001, + "pid": "/private/investment", + "type": 3, + "subtype": 1, + "name": "List", + "uri": "{/base}/private/investment/list?{?}", + "target": "self", + "icon": null, + "order": 1, + "from": "InvestmentManagement", + "permission": { "permission": 2, "type": null, "element": null }, + "parent": 1007103001, + "children": [] + }, + { + "id": 1007104002, + "pid": "/private/investment", + "type": 3, + "subtype": 1, + "name": "Create", + "uri": "{/base}/private/investment/create?{?}", + "target": "self", + "icon": null, + "order": 5, + "from": "InvestmentManagement", + "permission": { "permission": 2, "type": null, "element": null }, + "parent": 1007103001, + "children": [] + } + ] } ] diff --git a/Admin/Routes/Web/Backend.php b/Admin/Routes/Web/Backend.php index fc0c3f1..6b22e93 100755 --- a/Admin/Routes/Web/Backend.php +++ b/Admin/Routes/Web/Backend.php @@ -64,7 +64,7 @@ return [ '^/private/investment/list(\?.*$|$)' => [ [ - 'dest' => '\Modules\InvestmentManagement\Controller\BackendController:viewInvestmentList', + 'dest' => '\Modules\InvestmentManagement\Controller\BackendController:viewInvestmentPrivateList', 'verb' => RouteVerb::GET, 'permission' => [ 'module' => BackendController::MODULE_NAME, @@ -73,6 +73,17 @@ return [ ], ], ], + '^/private/investment/create(\?.*$|$)' => [ + [ + 'dest' => '\Modules\InvestmentManagement\Controller\BackendController:viewInvestmentPrivateCreate', + 'verb' => RouteVerb::GET, + 'permission' => [ + 'module' => BackendController::MODULE_NAME, + 'type' => PermissionType::CREATE, + 'state' => PermissionCategory::INVESTMENT, + ], + ], + ], '^/private/investment/view(\?.*$|$)' => [ [ 'dest' => '\Modules\InvestmentManagement\Controller\BackendController:viewInvestmentView', diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 5ec591d..afde7a8 100644 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -487,7 +487,7 @@ final class ApiController extends Controller // @todo reconsider the following lines. This seems rather complicated. if ($request->hasData('amount')) { /** @var BaseStringL11nType[] $types */ - $types = AmountTypeMapper::getAll()->execute(); + $types = AmountTypeMapper::getAll()->executeGetArray(); foreach ($types as $type) { if ($type->title === 'costs') { diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 5fda687..b519372 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -15,6 +15,7 @@ declare(strict_types=1); namespace Modules\InvestmentManagement\Controller; use Modules\InvestmentManagement\Models\InvestmentMapper; +use Modules\InvestmentManagement\Models\InvestmentObjectMapper; use Modules\InvestmentManagement\Models\InvestmentTypeMapper; use Modules\Organization\Models\UnitMapper; use phpOMS\Contract\RenderableInterface; @@ -53,13 +54,62 @@ final class BackendController extends Controller $list = InvestmentMapper::getAll() ->with('createdBy') ->sort('id', 'DESC') - ->execute(); + ->executeGetArray(); $view->data['investments'] = $list; 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 viewInvestmentPrivateList(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface + { + $view = new View($this->app->l11nManager, $request, $response); + $view->setTemplate('/Modules/InvestmentManagement/Theme/Backend/investment-list'); + $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1007103001, $request, $response); + + $list = InvestmentMapper::getAll() + ->with('createdBy') + ->sort('id', 'DESC') + ->executeGetArray(); + + $view->data['investments'] = $list; + + 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 viewInvestmentPrivateCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface + { + $view = new View($this->app->l11nManager, $request, $response); + $view->setTemplate('/Modules/InvestmentManagement/Theme/Backend/investment-view'); + $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1007103001, $request, $response); + + return $view; + } + /** * Routing end-point for application behavior. * @@ -104,17 +154,13 @@ final class BackendController extends Controller $view->data['attributeView'] = new \Modules\Attribute\Theme\Backend\Components\AttributeView($this->app->l11nManager, $request, $response); $view->data['attributeView']->data['default_localization'] = $this->app->l11nServer; - $investmentTypes = InvestmentTypeMapper::getAll() + $view->data['types'] = InvestmentTypeMapper::getAll() ->with('l11n') ->where('l11n/language', $response->header->l11n->language) - ->execute(); + ->executeGetArray(); - $view->data['types'] = $investmentTypes; - - $units = UnitMapper::getAll() - ->execute(); - - $view->data['units'] = $units; + $view->data['units'] = UnitMapper::getAll() + ->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); @@ -137,7 +183,7 @@ final class BackendController extends Controller public function viewInvestmentCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface { $view = new View($this->app->l11nManager, $request, $response); - $view->setTemplate('/Modules/InvestmentManagement/Theme/Backend/investment-create'); + $view->setTemplate('/Modules/InvestmentManagement/Theme/Backend/investment-view'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1007101001, $request, $response); return $view; @@ -182,6 +228,31 @@ final class BackendController extends Controller $view->setTemplate('/Modules/InvestmentManagement/Theme/Backend/investment-option-view'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1007101001, $request, $response); + $view->data['option'] = InvestmentObjectMapper::get() + ->with('supplier') + ->with('supplier/account') + ->with('item') + ->with('files') + ->with('notes') + ->with('amountGroups') + ->with('amountGroups/type') + ->with('amountGroups/amounts') + ->with('attributes') + ->with('attributes/type') + ->with('attributes/type/l11n') + ->with('attributes/value') + ->where('id', (int) $request->getData('id')) + ->execute(); + + $view->data['attributeView'] = new \Modules\Attribute\Theme\Backend\Components\AttributeView($this->app->l11nManager, $request, $response); + $view->data['attributeView']->data['default_localization'] = $this->app->l11nServer; + + $view->data['units'] = UnitMapper::getAll() + ->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); + return $view; } } diff --git a/Models/Investment.php b/Models/Investment.php index b7c3648..8a4720e 100644 --- a/Models/Investment.php +++ b/Models/Investment.php @@ -64,7 +64,7 @@ class Investment { $this->createdBy = new NullAccount(); $this->createdAt = new \DateTimeImmutable('now'); - $this->performanceDate = new \DateTime('now'); + $this->performanceDate = (new \DateTime('now'))->modify('+7 days'); } use \Modules\Media\Models\MediaListTrait; diff --git a/Models/NullInvestment.php b/Models/NullInvestment.php index 0b562d7..3c34812 100644 --- a/Models/NullInvestment.php +++ b/Models/NullInvestment.php @@ -34,6 +34,7 @@ final class NullInvestment extends Investment public function __construct(int $id = 0) { $this->id = $id; + parent::__construct(); } /** diff --git a/Models/NullInvestmentObject.php b/Models/NullInvestmentObject.php new file mode 100644 index 0000000..e6be77d --- /dev/null +++ b/Models/NullInvestmentObject.php @@ -0,0 +1,46 @@ +id = $id; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() : mixed + { + return ['id' => $this->id]; + } +} diff --git a/Theme/Backend/investment-option-view.tpl.php b/Theme/Backend/investment-option-view.tpl.php index 3ba1d8f..5f5bc2a 100644 --- a/Theme/Backend/investment-option-view.tpl.php +++ b/Theme/Backend/investment-option-view.tpl.php @@ -12,111 +12,136 @@ */ declare(strict_types=1); +use Modules\InvestmentManagement\Models\NullInvestmentObject; use phpOMS\Uri\UriFactory; /** @var \phpOMS\Views\View $this */ +$option = $this->data['option'] ?? new NullInvestmentObject(); + +$isNew = $option->id === 0; ?>
- getHtml('Back', '0', '0'); ?> -
- -
-
-
-
getHtml('Option'); ?>
-
-
- - -
- -
- - -
- -
- - -
- -
- - - -
- -
- - - - - attributes as $attribute) : ?> - -
getHtml('Attributes'); ?> -
- - attributes)) : ?> -
getHtml('Empty', '0', '0'); ?> - -
-
- -
- - - - - amountGroups as $group) : ?> - -
getHtml('Amounts'); ?> -
getCurrency($group->sum(), '', 'medium'); ?> - - files)) : ?> -
getHtml('Empty', '0', '0'); ?> - -
-
- -
- - - - - files as $file) : ?> - -
getHtml('Files'); ?> -
- - files)) : ?> -
getHtml('Empty', '0', '0'); ?> - -
-
- -
- - - - - notes as $note) : ?> - -
getHtml('Notes'); ?> -
- - notes)) : ?> -
getHtml('Empty', '0', '0'); ?> - -
-
-
- -
+ -
\ No newline at end of file +
+
+ +
+ +
+ +
+ request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>> +
+
+
+
+
+
getHtml('Option'); ?>
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+ +
+ +
+
+
+ +
+ + +
+ + +
+ + + +
+ +
+
+ + + + + +
+
+
+
+
+
+ + request->uri->fragment === 'c-tab-2' ? ' checked' : ''; ?>> +
+
+ data['attributeView']->render( + $option->attributes, + $this->data['attributeTypes'] ?? [], + $this->data['units'] ?? [], + '{/api}finance/investment/option/attribute?csrf={$CSRF}', + $option->id + ); + ?> +
+
+ + + + request->uri->fragment === 'c-tab-4' ? ' checked' : ''; ?>> +
+ data['note']->render('option-note', 'notes', $option->notes); ?> +
+ + request->uri->fragment === 'c-tab-5' ? ' checked' : ''; ?>> +
+ data['media-upload']->render('option-file', 'files', '', $option->files); ?> +
+
+
diff --git a/Theme/Backend/investment-view.tpl.php b/Theme/Backend/investment-view.tpl.php index 5f742ab..5fdf974 100644 --- a/Theme/Backend/investment-view.tpl.php +++ b/Theme/Backend/investment-view.tpl.php @@ -13,30 +13,37 @@ declare(strict_types=1); use Modules\InvestmentManagement\Models\InvestmentStatus; +use Modules\InvestmentManagement\Models\NullInvestment; use phpOMS\Uri\UriFactory; /** @var \phpOMS\Views\View $this */ -$investment = $this->data['investment'] ?? null; +$investment = $this->data['investment'] ?? new NullInvestment(); $investmentStatus = InvestmentStatus::getConstants(); $files = $investment->files; $investmentTypes = $this->data['types'] ?? []; +$isNew = $investment->id === 0; + echo $this->data['nav']->render(); ?>
+
+
- request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>> + request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>>
+
getHtml('Investment'); ?>
@@ -79,9 +86,11 @@ echo $this->data['nav']->render(); ?>
+
+
@@ -115,9 +124,11 @@ echo $this->data['nav']->render(); ?>
+
+ request->uri->fragment === 'c-tab-2' ? ' checked' : ''; ?>>
data['media-upload']->render('investment-file', 'files', '', $investment->files); ?> @@ -245,6 +256,6 @@ echo $this->data['nav']->render(); ?>
- +