/** * Delete CustomField * @param array() $customFieldList * @returns boolean * @throws AdminServiceException */ public function deleteCustomField($customFieldList) { try { $reportGeneratorService = new ReportGeneratorService(); $reportGeneratorService->deleteCustomDisplayFieldList($customFieldList); return $this->customFieldsDao->deleteCustomField($customFieldList); } catch (Exception $e) { throw new AdminServiceException($e->getMessage()); } }
public function setParametersForListComponent() { $projectService = new ProjectService(); $projectId = $this->getRequest()->getParameter("projectId"); $projectName = $projectService->getProjectNameWithCustomerName($projectId); $activityId = $this->getRequest()->getParameter("activityId"); $reportGeneratorService = new ReportGeneratorService(); $activityName = $reportGeneratorService->getProjectActivityNameByActivityId($activityId); $params = array('projectName' => $projectName, 'activityName' => $activityName, 'projectDateRangeFrom' => $this->getRequest()->getParameter("from"), 'projectDateRangeTo' => $this->getRequest()->getParameter("to"), 'total' => $this->getRequest()->getParameter("total")); return $params; }
public function setParametersForListComponent() { $projectService = new ProjectService(); $projectId = $this->getRequest()->getParameter("projectId"); $userRoleManager = $this->getContext()->getUserRoleManager(); $requiredPermissions = array(BasicUserRoleManager::PERMISSION_TYPE_DATA_GROUP => array('time_project_reports' => new ResourcePermission(true, false, false, false))); $accessible = $userRoleManager->isEntityAccessible('Project', $projectId, null, array(), array(), $requiredPermissions); $activityId = $this->getRequest()->getParameter("activityId"); $activity = $projectService->getProjectActivityById($activityId); if (!$accessible || $activity->getProjectId() != $projectId) { $this->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action')); } $projectName = $projectService->getProjectNameWithCustomerName($projectId); $reportGeneratorService = new ReportGeneratorService(); $activityName = $reportGeneratorService->getProjectActivityNameByActivityId($activityId); $params = array('projectName' => $projectName, 'activityName' => $activityName, 'projectDateRangeFrom' => $this->getRequest()->getParameter("from"), 'projectDateRangeTo' => $this->getRequest()->getParameter("to"), 'total' => $this->getRequest()->getParameter("total")); return $params; }
public function execute($request) { $reportId = $request->getParameter("reportId"); $reportGeneratorService = new ReportGeneratorService(); $runtimeFilterFieldWidgetNamesAndLabelsList = $reportGeneratorService->getRuntimeFilterFieldWidgetNamesAndLabels($reportId); $this->reportName = $reportGeneratorService->getReportName($reportId); $this->runtimeFilterFieldWidgetNamesAndLabelsList = $runtimeFilterFieldWidgetNamesAndLabelsList; $selectedRuntimeFilterFieldList = $reportGeneratorService->getSelectedRuntimeFilterFields($reportId); $ohrmFormGenerator = new ohrmFormGenerator(); $this->reportForm = $ohrmFormGenerator->generateForm($runtimeFilterFieldWidgetNamesAndLabelsList); if ($request->isMethod('post')) { $this->reportForm->bind($request->getParameter($this->reportForm->getName())); if ($this->reportForm->isValid()) { $formValues = $this->reportForm->getValues(); $reportableService = new ReportableService(); $selectedFilterFieldList = $reportableService->getSelectedFilterFields($reportId, true); $runtimeWhereClause = $reportGeneratorService->generateWhereClauseConditionArray($selectedFilterFieldList, $formValues); $staticColumns = null; if ($this->hasStaticColumns()) { $staticColumns = $this->setStaticColumns($formValues); } $sql = $reportGeneratorService->generateSql($reportId, $runtimeWhereClause, $staticColumns); $this->setReportCriteriaInfoInRequest($formValues); $this->getRequest()->setParameter('sql', $sql); $this->getRequest()->setParameter('reportId', $reportId); $this->setForward(); } } }
public function execute($request) { $this->setInitialActionDetails($request); $reportId = $request->getParameter("reportId"); $backRequest = $request->getParameter("backRequest"); $reportableGeneratorService = new ReportGeneratorService(); $sql = $request->getParameter("sql"); $reportableService = new ReportableService(); $this->report = $reportableService->getReport($reportId); if (empty($this->report)) { return $this->renderText(__('Invalid Report Specified')); } $useFilterField = $this->report->getUseFilterField(); if (!$useFilterField) { $this->setCriteriaForm(); if ($request->isMethod('post')) { $this->form->bind($request->getParameter($this->form->getName())); if ($this->form->isValid()) { $reportGeneratorService = new ReportGeneratorService(); $formValues = $this->form->getValues(); $this->setReportCriteriaInfoInRequest($formValues); $sql = $reportGeneratorService->generateSqlForNotUseFilterFieldReports($reportId, $formValues); } } } else { if ($request->isMethod("get")) { $reportGeneratorService = new ReportGeneratorService(); // $selectedRuntimeFilterFieldList = $reportGeneratorService->getSelectedRuntimeFilterFields($reportId); $selectedFilterFieldList = $reportableService->getSelectedFilterFields($reportId, false); $values = $this->setValues(); // $linkedFilterFieldIdsAndFormValues = $reportGeneratorService->linkFilterFieldIdsToFormValues($selectedRuntimeFilterFieldList, $values); // $runtimeWhereClauseConditionArray = $reportGeneratorService->generateWhereClauseConditionArray($linkedFilterFieldIdsAndFormValues); $runtimeWhereClauseConditionArray = $reportGeneratorService->generateWhereClauseConditionArray($selectedFilterFieldList, $values); $sql = $reportGeneratorService->generateSql($reportId, $runtimeWhereClauseConditionArray); } } $paramArray = array(); if ($reportId == 1) { if (!isset($backRequest)) { $this->getUser()->setAttribute("reportCriteriaSql", $sql); $this->getUser()->setAttribute("parametersForListComponent", $this->setParametersForListComponent()); } if (isset($backRequest) && $this->getUser()->hasAttribute("reportCriteriaSql")) { $sql = $this->getUser()->getAttribute("reportCriteriaSql"); $paramArray = $this->getUser()->getAttribute("parametersForListComponent"); } } $params = !empty($paramArray) ? $paramArray : $this->setParametersForListComponent(); $rawDataSet = $reportableGeneratorService->generateReportDataSet($reportId, $sql); $dataSet = self::escapeData($rawDataSet); $headerGroups = $reportableGeneratorService->getHeaderGroups($reportId); $this->setConfigurationFactory(); $configurationFactory = $this->getConfFactory(); $configurationFactory->setHeaderGroups($headerGroups); if ($reportId == 3) { if (empty($dataSet[0]['employeeName']) && $dataSet[0]['totalduration'] == 0) { $dataSet = null; } } ohrmListComponent::setConfigurationFactory($configurationFactory); $this->setListHeaderPartial(); ohrmListComponent::setListData($dataSet); $this->parmetersForListComponent = $params; $this->initilizeDataRetriever($configurationFactory, $reportableGeneratorService, 'generateReportDataSet', array($reportId, $sql)); }
public function execute($request) { /* For highlighting corresponding menu item * TODO: Currently menu item is hard-coded since this action is only used by PIM Reports */ $request->setParameter('initialActionName', 'viewDefinedPredefinedReports'); $this->reportPermissions = $this->getDataGroupPermissions('pim_reports'); $this->getReportGroupAndType($request); $reportGeneratorService = new ReportGeneratorService(); $reportableService = new ReportableService(); $displayFieldGroups = $reportGeneratorService->getGroupedDisplayFieldsForReportGroup($this->reportGroup); $filterWidgets = $reportableService->getFilterFieldsForReportGroup($this->reportGroup); $reportId = $request->getParameter('reportId'); $this->reportId = $reportId; if (!empty($reportId)) { $report = $reportableService->getReport($reportId); if (empty($report)) { $this->getUser()->setFlash('templateMessage', array('warning', __('Invalid Report Specified'))); $this->redirect('core/viewDefinedPredefinedReports'); } $reportName = $reportGeneratorService->getReportName($reportId); } if ($this->reportPermissions->canRead()) { $ohrmFormGenerator = new ohrmFormGenerator(); $this->form = $ohrmFormGenerator->generatePredefinedForm($filterWidgets, $displayFieldGroups, $reportId, $reportName); $this->form->requiredFilterWidgets = $reportableService->getRequiredFilterFieldsForReportGroup($this->reportGroup); } if ($request->isMethod('post')) { if ($this->reportPermissions->canCreate() || $this->reportPermissions->canUpdate()) { $this->form->bind($request->getParameter($this->form->getName())); $selectedDisplayFieldGroups = $request->getParameter('display_groups'); $selectedDisplayFields = $request->getParameter('display_fields'); $this->form->selectedDisplayFieldGroups = $selectedDisplayFieldGroups; $this->form->selectedDisplayFields = $selectedDisplayFields; if ($this->form->isValid()) { $reportId = $this->form->getValue('report_id'); $reportName = $this->form->getValue('report_name'); $selectedFilterValues = $this->form->getSelectedFilterValues(); if (empty($reportId) && !$this->reportPermissions->canCreate() || !empty($reportId) && !$this->reportPermissions->canUpdate()) { $this->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action')); } // If report_id not available, create report if (empty($reportId)) { $report = $reportableService->saveReport($reportName, $this->reportGroup, true, $this->reportType); $reportId = $report->getReportId(); } else { $report = $reportableService->getReport($reportId); // update report name if required if ($reportName != $report->getName()) { $reportableService->updateReportName($reportId, $reportName); } } // save selected values. $reportGeneratorService->saveSelectedDisplayFieldGroups($selectedDisplayFieldGroups, $reportId); $reportGeneratorService->saveSelectedDisplayFields($selectedDisplayFields, $reportId); $reportGeneratorService->saveSelectedFilterFields($selectedFilterValues, $reportId, 'Predefined'); $this->getUser()->setFlash('success', __(TopLevelMessages::SAVE_SUCCESS)); $this->redirect('core/viewDefinedPredefinedReports'); return; } } } else { if (empty($this->reportId) && !$this->reportPermissions->canCreate() || !empty($this->reportId) && !$this->reportPermissions->canUpdate()) { $this->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action')); } // Get filters, display field groups and display fields for report if (!empty($reportId)) { $selectedDisplayFieldGroups = $reportableService->getSelectedDisplayFieldGroups($reportId); $selectedDisplayFields = $reportableService->getSelectedDisplayFields($reportId); $selectedFilterFields = $reportableService->getSelectedFilterFieldNames($reportId, "Predefined"); $this->form->updateSelectedDisplayFieldGroups($selectedDisplayFieldGroups); $this->form->updateSelectedDisplayFields($selectedDisplayFields); $this->form->updateSelectedFilterFields($selectedFilterFields); } } }
public function execute($request) { $adminMode = $this->getUser()->hasCredential(Auth::ADMIN_ROLE); if (!$adminMode) { return $this->renderText("You are not allowed to view this page!"); } $this->getReportGroupAndType($request); $reportGeneratorService = new ReportGeneratorService(); $reportableService = new ReportableService(); $displayFieldGroups = $reportGeneratorService->getGroupedDisplayFieldsForReportGroup($this->reportGroup); $filterWidgets = $reportableService->getFilterFieldsForReportGroup($this->reportGroup); $reportId = $request->getParameter('reportId'); $reportName; if (!empty($reportId)) { $report = $reportableService->getReport($reportId); if (empty($report)) { $this->getUser()->setFlash('templateMessage', array('warning', __('Invalid Report Specified'))); $this->redirect('core/viewDefinedPredefinedReports'); } $reportName = $reportGeneratorService->getReportName($reportId); } $ohrmFormGenerator = new ohrmFormGenerator(); $this->form = $ohrmFormGenerator->generatePredefinedForm($filterWidgets, $displayFieldGroups, $reportId, $reportName); $this->form->requiredFilterWidgets = $reportableService->getRequiredFilterFieldsForReportGroup($this->reportGroup); if ($request->isMethod('post')) { $this->form->bind($request->getParameter($this->form->getName())); $selectedDisplayFieldGroups = $request->getParameter('display_groups'); $selectedDisplayFields = $request->getParameter('display_fields'); $this->form->selectedDisplayFieldGroups = $selectedDisplayFieldGroups; $this->form->selectedDisplayFields = $selectedDisplayFields; if ($this->form->isValid()) { $reportId = $this->form->getValue('report_id'); $reportName = $this->form->getValue('report_name'); $selectedFilterValues = $this->form->getSelectedFilterValues(); // If report_id not available, create report if (empty($reportId)) { $report = $reportableService->saveReport($reportName, $this->reportGroup, true, $this->reportType); $reportId = $report->getReportId(); } else { $report = $reportableService->getReport($reportId); // update report name if required if ($reportName != $report->getName()) { $reportableService->updateReportName($reportId, $reportName); } } // save selected values. $reportGeneratorService->saveSelectedDisplayFieldGroups($selectedDisplayFieldGroups, $reportId); $reportGeneratorService->saveSelectedDisplayFields($selectedDisplayFields, $reportId); $reportGeneratorService->saveSelectedFilterFields($selectedFilterValues, $reportId, 'Predefined'); $this->getUser()->setFlash('templateMessage', array('success', __(TopLevelMessages::SAVE_SUCCESS))); $this->redirect('core/viewDefinedPredefinedReports'); return; } } else { // Get filters, display field groups and display fields for report if (!empty($reportId)) { $selectedDisplayFieldGroups = $reportableService->getSelectedDisplayFieldGroups($reportId); $selectedDisplayFields = $reportableService->getSelectedDisplayFields($reportId); $selectedFilterFields = $reportableService->getSelectedFilterFieldNames($reportId, "Predefined"); $this->form->updateSelectedDisplayFieldGroups($selectedDisplayFieldGroups); $this->form->updateSelectedDisplayFields($selectedDisplayFields); $this->form->updateSelectedFilterFields($selectedFilterFields); } } }
/** * Delete CustomField * @param array $customFieldIdList * @returns integer Number of records deleted * @throws DaoException * * @todo rename method as deleteCustomFields [DONE: There was no change to be done] * @todo return number of items deleted [DONE] */ public function deleteCustomFields($customFieldIdList) { $reportGeneratorService = new ReportGeneratorService(); $reportGeneratorService->deleteCustomDisplayFieldList($customFieldIdList); return $this->customFieldsDao->deleteCustomFields($customFieldIdList); }