public static function add(ProjectEntity $project, $userId) { $currentDate = $project->getDateCreated(); $projectId = UbirimiContainer::get()['repository']->get(YongoProject::class)->add($project->getClientId(), $project->getIssueTypeSchemeId(), $project->getIssueTypeScreenSchemeId(), $project->getIssueTypeFieldConfigurationId(), $project->getWorkflowSchemeId(), $project->getPermissionSchemeId(), $project->getNotificationSchemeId(), $project->getLeadId(), $project->getName(), $project->getCode(), $project->getDescription(), $project->getProjectCategoryId(), $project->getHelpDeskEnabledFlag(), $project->getDateCreated()); UbirimiContainer::get()['repository']->get(YongoProject::class)->addDefaultUsers($project->getClientId(), $projectId, $currentDate); UbirimiContainer::get()['repository']->get(YongoProject::class)->addDefaultGroups($project->getClientId(), $projectId, $currentDate); if ($project->getHelpDeskEnabledFlag()) { UbirimiContainer::get()['repository']->get(YongoProject::class)->addDefaultInitialDataForHelpDesk($project->getClientId(), $projectId, $userId, $currentDate); } return $projectId; }
public function indexAction(Request $request, SessionInterface $session) { Util::checkUserIsLoggedInAndRedirect(); $leadUsers = $this->getRepository(UbirimiClient::class)->getUsers($session->get('client/id')); $forHelpDesk = $request->query->has('helpdesk') ? true : false; $emptyName = false; $duplicateName = false; $emptyCode = false; $duplicateCode = false; $issueTypeScheme = $this->getRepository(IssueTypeScheme::class)->getByClientId($session->get('client/id'), 'project'); $issueTypeScreenScheme = $this->getRepository(IssueTypeScreenScheme::class)->getByClientId($session->get('client/id')); $fieldConfigurationSchemes = $this->getRepository(FieldConfigurationScheme::class)->getByClient($session->get('client/id')); $workflowScheme = $this->getRepository(WorkflowScheme::class)->getMetaDataByClientId($session->get('client/id')); $permissionScheme = $this->getRepository(PermissionScheme::class)->getByClientId($session->get('client/id')); $notificationScheme = $this->getRepository(NotificationScheme::class)->getByClientId($session->get('client/id')); $projectCategories = $this->getRepository(ProjectCategory::class)->getAll($session->get('client/id')); if ($request->request->has('confirm_new_project')) { $forHelpDesk = $request->query->has('helpdesk') ? 1 : 0; $name = Util::cleanRegularInputField($request->request->get('name')); $code = strtoupper(Util::cleanRegularInputField($request->request->get('code'))); $description = Util::cleanRegularInputField($request->request->get('description')); $issueTypeSchemeId = $request->request->get('issue_type_scheme'); $issueTypeScreenSchemeId = $request->request->get('issue_type_screen_scheme'); $issueTypeFieldConfigurationSchemeId = $request->request->get('field_configuration_scheme'); $workflowSchemeId = $request->request->get('workflow_scheme'); $permissionSchemeId = $request->request->get('permission_scheme'); $notificationSchemeId = $request->request->get('notification_scheme'); $leadId = Util::cleanRegularInputField($request->request->get('lead')); $projectCategoryId = Util::cleanRegularInputField($request->request->get('project_category')); if (-1 == $projectCategoryId) { $projectCategoryId = null; } if (empty($name)) { $emptyName = true; } if (empty($code)) { $emptyCode = true; } else { $projectExists = $this->getRepository(YongoProject::class)->getByCode(mb_strtolower($code), null, $session->get('client/id')); if ($projectExists) { $duplicateCode = true; } } $projectExists = $this->getRepository(YongoProject::class)->getByName(mb_strtolower($name), null, $session->get('client/id')); if ($projectExists) { $duplicateName = true; } if (!$emptyName && !$emptyCode && !$duplicateName && !$duplicateCode) { $currentDate = Util::getServerCurrentDateTime(); $project = new ProjectEntity(); $project->setClientId($session->get('client/id')); $project->setName($name); $project->setCode($code); $project->setDescription($description); $project->setIssueTypeSchemeId($issueTypeSchemeId); $project->setIssueTypeScreenSchemeId($issueTypeScreenSchemeId); $project->setIssueTypeFieldConfigurationId($issueTypeFieldConfigurationSchemeId); $project->setWorkflowSchemeId($workflowSchemeId); $project->setPermissionSchemeId($permissionSchemeId); $project->setNotificationSchemeId($notificationSchemeId); $project->setLeadId($leadId); $project->setProjectCategoryId($projectCategoryId); $project->setHelpDeskDeskEnabledFlag($forHelpDesk); $project->setDateCreated($currentDate); $projectId = UbirimiContainer::get()['project']->add($project, $session->get('user/id')); $session->set('selected_project_id', $projectId); $this->getLogger()->addInfo('ADD Yongo Project ' . $name, $this->getLoggerContext()); if ($forHelpDesk) { return new RedirectResponse('/helpdesk/all'); } else { return new RedirectResponse('/yongo/administration/projects'); } } } $menuSelectedCategory = 'project'; $sectionPageTitle = $session->get('client/settings/title_name') . ' / ' . SystemProduct::SYS_PRODUCT_YONGO_NAME . ' / Create Project'; return $this->render(__DIR__ . '/../../../Resources/views/administration/project/Add.php', get_defined_vars()); }