app->l11nManager, $request, $response); $view->setTemplate('/Modules/ClientManagement/Theme/Backend/attribute-type-list'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1004801001, $request, $response); /** @var \Modules\Attribute\Models\AttributeType[] $attributes */ $attributes = ClientAttributeTypeMapper::getAll() ->with('l11n') ->where('l11n/language', $response->header->l11n->language) ->execute(); $view->data['attributes'] = $attributes; 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 viewClientManagementAttributeValues(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface { $view = new View($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/ClientManagement/Theme/Backend/attribute-value-list'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1004801001, $request, $response); /** @var \Modules\Attribute\Models\AttributeValue[] $attributes */ $attributes = ClientAttributeValueMapper::getAll() ->with('l11n') ->where('l11n/language', $response->header->l11n->language) ->execute(); $view->data['attributes'] = $attributes; 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 viewClientManagementAttributeType(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface { $view = new View($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/ClientManagement/Theme/Backend/attribute-type'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1004801001, $request, $response); /** @var \Modules\Attribute\Models\AttributeType $attribute */ $attribute = ClientAttributeTypeMapper::get() ->with('l11n') ->where('id', (int) $request->getData('id')) ->where('l11n/language', $response->header->l11n->language) ->execute(); $l11ns = ClientAttributeTypeL11nMapper::getAll() ->where('ref', $attribute->id) ->execute(); $view->data['attribute'] = $attribute; $view->data['l11ns'] = $l11ns; 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 viewClientManagementClientList(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface { $view = new View($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/ClientManagement/Theme/Backend/client-list'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1003102001, $request, $response); /** @var \Modules\ClientManagement\Models\Client $client */ $client = ClientMapper::getAll() ->with('account') ->with('mainAddress') ->limit(25) ->execute(); $view->data['client'] = $client; 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 viewClientManagementClientCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface { $view = new View($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/ClientManagement/Theme/Backend/client-create'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1003102001, $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 viewClientManagementClientProfile(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface { $head = $response->data['Content']->head; $nonce = $this->app->appSettings->getOption('script-nonce'); $head->addAsset(AssetType::CSS, 'Resources/chartjs/chart.css'); $head->addAsset(AssetType::JSLATE, 'Resources/chartjs/chart.js', ['nonce' => $nonce]); $head->addAsset(AssetType::JSLATE, 'Resources/OpenLayers/OpenLayers.js', ['nonce' => $nonce]); $head->addAsset(AssetType::JSLATE, 'Modules/ClientManagement/Controller.js', ['nonce' => $nonce, 'type' => 'module']); $view = new View($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/ClientManagement/Theme/Backend/client-profile'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1003102001, $request, $response); /** @var \Modules\ClientManagement\Models\Client $client */ $client = ClientMapper::get() ->with('account') ->with('contactElements') ->with('mainAddress') ->with('files')->limit(5, 'files')->sort('files/id', OrderType::DESC) ->with('notes')->limit(5, 'notes')->sort('notes/id', OrderType::DESC) ->with('attributes') ->with('attributes/type') ->with('attributes/type/l11n') ->with('attributes/value') ->where('id', (int) $request->getData('id')) ->execute(); $view->data['client'] = $client; /** @var \Model\Setting $settings */ $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(); /** @var \Modules\Attribute\Models\AttributeType[] $attributeTypes */ $attributeTypes = ClientAttributeTypeMapper::getAll() ->with('l11n') ->where('l11n/language', $response->header->l11n->language) ->execute(); $view->data['attributeTypes'] = $attributeTypes; // Get item profile image // It might not be part of the 5 newest item files from above // @todo It would be nice to have something like this as a default method in the model e.g. // ItemManagement::getRelations()->with('types')->where(...); // This should return the relations and NOT the model itself $query = new Builder($this->app->dbPool->get()); $results = $query->selectAs(ClientMapper::HAS_MANY['files']['external'], 'file') ->from(ClientMapper::TABLE) ->leftJoin(ClientMapper::HAS_MANY['files']['table']) ->on(ClientMapper::HAS_MANY['files']['table'] . '.' . ClientMapper::HAS_MANY['files']['self'], '=', ClientMapper::TABLE . '.' . ClientMapper::PRIMARYFIELD) ->leftJoin(MediaMapper::TABLE) ->on(ClientMapper::HAS_MANY['files']['table'] . '.' . ClientMapper::HAS_MANY['files']['external'], '=', MediaMapper::TABLE . '.' . MediaMapper::PRIMARYFIELD) ->leftJoin(MediaMapper::HAS_MANY['types']['table']) ->on(MediaMapper::TABLE . '.' . MediaMapper::PRIMARYFIELD, '=', MediaMapper::HAS_MANY['types']['table'] . '.' . MediaMapper::HAS_MANY['types']['self']) ->leftJoin(MediaTypeMapper::TABLE) ->on(MediaMapper::HAS_MANY['types']['table'] . '.' . MediaMapper::HAS_MANY['types']['external'], '=', MediaTypeMapper::TABLE . '.' . MediaTypeMapper::PRIMARYFIELD) ->where(ClientMapper::HAS_MANY['files']['self'], '=', $client->id) ->where(MediaTypeMapper::TABLE . '.' . MediaTypeMapper::getColumnByMember('name'), '=', 'client_profile_image'); $clientImage = MediaMapper::get() ->with('types') ->where('id', $results) ->limit(1) ->execute(); $view->data['clientImage'] = $clientImage; $businessStart = UnitAttributeMapper::get() ->with('type') ->with('value') ->where('ref', $this->app->unitId) ->where('type/name', 'business_year_start') ->execute(); $view->data['business_start'] = $businessStart->id === 0 ? 1 : $businessStart->value->getValue(); /** @var \Modules\Billing\Models\Price\Price[] $prices */ $prices = PriceMapper::getAll() ->where('client', $client->id) ->where('type', PriceType::SALES) ->execute(); $view->data['prices'] = $prices; /** @var \Modules\Auditor\Models\Audit[] $audits */ $audits = AuditMapper::getAll() ->where('type', StringUtils::intHash(ClientMapper::class)) ->where('module', 'ClientManagement') ->where('ref', (string) $client->id) ->execute(); // @todo join audit with files, attributes, localization, prices, notes, ... $view->data['audits'] = $audits; /** @var \Modules\Media\Models\Media[] $files */ $files = MediaMapper::getAll() ->with('types') ->join('id', ClientMapper::class, 'files') // id = media id, files = client relations ->on('id', $client->id, relation: 'files') // id = item id ->execute(); $view->data['files'] = $files; $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['hasBilling'] = $this->app->moduleManager->isActive('Billing'); 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 viewClientManagementClientAnalysis(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface { return new View($this->app->l11nManager, $request, $response); } }