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)); }