app->l11nManager, $request, $response); } /** * 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 viewSupportList(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface { $head = $response->data['Content']->head; $head->addAsset(AssetType::CSS, 'Modules/Tasks/Theme/Backend/css/styles.css?v=1.0.0'); $view = new View($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/Support/Theme/Backend/support-list'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1002901101, $request, $response); $mapperQuery = TicketMapper::getAll() ->with('task') ->with('task/createdBy') ->with('task/for') ->with('task/taskElements') ->with('task/taskElements/accRelation') ->with('task/taskElements/accRelation/relation') ->with('app') ->limit(25); if ($request->getData('ptype') === 'p') { $mapperQuery->where('id', $request->getDataInt('id') ?? 0, '<'); } elseif ($request->getData('ptype') === 'n') { $mapperQuery->where('id', $request->getDataInt('id') ?? 0, '>'); } else { $mapperQuery->where('id', 0, '>'); } $view->data['tickets'] = $mapperQuery->execute(); $view->data['stats'] = TicketMapper::getStatOverview($request->header->account); 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 viewSupportTicket(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface { $view = new TicketView($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/Support/Theme/Backend/support-ticket'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1002901101, $request, $response); $mapperQuery = TicketMapper::get() ->with('task') ->with('task/createdBy') ->with('task/tags') ->with('task/tags/title') ->with('ticketElements') ->with('ticketElements/taskElement') ->with('ticketElements/taskElement/createdBy') ->with('ticketElements/taskElement/media') ->with('attributes') ->with('task/for') ->with('app') ->where('task/tags/title/language', $request->header->l11n->language); /** @var \Modules\Support\Models\Ticket */ $view->data['ticket'] = $request->hasData('for') ? $mapperQuery->where('task', (int) $request->getData('for'))->execute() : $mapperQuery->where('id', (int) $request->getData('id'))->execute(); /** @var \Model\Setting $profileImage */ $profileImage = $this->app->appSettings->get(names: ProfileSettingsEnum::DEFAULT_PROFILE_IMAGE, module: 'Profile'); /** @var \Modules\Media\Models\Media $image */ $image = MediaMapper::get()->where('id', (int) $profileImage->content)->execute(); $view->defaultProfileImage = $image; $accGrpSelector = new \Modules\Profile\Theme\Backend\Components\AccountGroupSelector\BaseView($this->app->l11nManager, $request, $response); $view->data['accGrpSelector'] = $accGrpSelector; $editor = new \Modules\Editor\Theme\Backend\Components\Editor\BaseView($this->app->l11nManager, $request, $response); $view->data['editor'] = $editor; $view->data['tickets'] = TicketMapper::getAll() ->with('task') ->where('task/for', $view->data['ticket']->task->for->id) ->sort('createdAt', OrderType::DESC) ->offset(1) ->limit(5) ->execute(); $dt = new \DateTime(); $view->data['hasContractManagement'] = $this->app->moduleManager->isActive('ContractManagement'); if ($view->data['hasContractManagement']) { $view->data['contracts'] = \Modules\ContractManagement\Models\ContractMapper::getAll() ->where('account', $view->data['ticket']->task->for->id) ->where('end', $dt, '>=') // @todo consider to also allow $end === null ->sort('createdAt', OrderType::DESC) ->limit(5) ->execute(); } else { $view->data['contracts'] = []; } 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 viewSupportCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface { $view = new View($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/Support/Theme/Backend/ticket-create'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1002901101, $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 viewSupportAnalysis(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface { $view = new View($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/Support/Theme/Backend/support-analysis'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1002901101, $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 viewSupportSettings(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface { $view = new View($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/Support/Theme/Backend/support-settings'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1002901101, $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 viewPrivateSupportDashboard(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface { $head = $response->data['Content']->head; $head->addAsset(AssetType::CSS, 'Modules/Tasks/Theme/Backend/css/styles.css?v=1.0.0'); $view = new View($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/Support/Theme/Backend/user-support-dashboard'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1002901101, $request, $response); // @todo Use ticket implementation "getAnyRelatedToUser($request->header->account) $mapperQuery = TicketMapper::getAnyRelatedToUser($request->header->account) ->with('task') ->with('task/createdBy') ->with('task/for') ->with('task/taskElements') ->with('task/taskElements/accRelation') ->with('task/taskElements/accRelation/relation') ->with('app') ->sort('task/createdAt', OrderType::DESC) ->limit(25); if ($request->getData('ptype') === 'p') { $mapperQuery->where('id', $request->getDataInt('id') ?? 0, '<'); } elseif ($request->getData('ptype') === 'n') { $mapperQuery->where('id', $request->getDataInt('id') ?? 0, '>'); } else { $mapperQuery->where('id', 0, '>'); } $view->data['tickets'] = $mapperQuery->execute(); $openQuery = new Builder($this->app->dbPool->get(), true); $openQuery->innerJoin(TaskMapper::TABLE, TaskMapper::TABLE . '_d2_task') ->on(TicketMapper::TABLE . '_d1.support_ticket_task', '=', TaskMapper::TABLE . '_d2_task.task_id') ->innerJoin(TaskElementMapper::TABLE) ->on(TaskMapper::TABLE . '_d2_task.' . TaskMapper::PRIMARYFIELD, '=', TaskElementMapper::TABLE . '.task_element_task') ->innerJoin(AccountRelationMapper::TABLE) ->on(TaskElementMapper::TABLE . '.' . TaskElementMapper::PRIMARYFIELD, '=', AccountRelationMapper::TABLE . '.task_account_task_element') ->andWhere(AccountRelationMapper::TABLE . '.task_account_account', '=', $request->header->account); /** @var \Modules\Tasks\Models\Task[] $open */ $open = TicketMapper::getAll() ->with('task') ->with('task/createdBy') ->where('task/type', TaskType::TEMPLATE, '!=') ->where('task/status', TaskStatus::OPEN) ->sort('task/createdAt', OrderType::DESC) ->query($openQuery) ->execute(); $view->data['open'] = $open; return $view; } /** * Method which generates the module profile view. * * @param RequestAbstract $request Request * @param ResponseAbstract $response Response * @param array $data Generic data * * @return RenderableInterface Response can be rendered * * @since 1.0.0 */ public function viewModuleSettings(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface { $view = new View($this->app->l11nManager, $request, $response); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1000105001, $request, $response); $id = $request->getDataString('id') ?? ''; $settings = SettingMapper::getAll()->where('module', $id)->execute(); $view->data['settings'] = $settings; /** @var \Modules\Support\Models\SupportApp[] $applications */ $applications = SupportAppMapper::getAll()->execute(); $view->data['applications'] = $applications; $view->setTemplate('/Modules/' . static::NAME . '/Admin/Settings/Theme/Backend/settings'); return $view; } }