public function processReorderFilterAction() { $baseId = (int) $this->_getParam('baseId'); $from = $this->_getParam('from'); $to = $this->_getParam('to'); // utilizing the ORM in the meantime, but can be optimized $reportBase = new ReportBase(); $reportBase->reportBaseId = $baseId; $reportBase->populate(); $rows = array(); if (strlen($reportBase->filters) > 0) { $filters = unserialize($reportBase->filters); foreach ($filters as $id => $filter) { if ($from == $id) { $fromFilter = $filters[$id]; unset($filters[$id]); break; } } if (isset($fromFilter)) { $tmpFilters = array(); foreach ($filters as $id => $filter) { $tmpFilters[$id] = $filter; if ($to == $id) { $tmpFilters[$from] = $fromFilter; } } $filters = $tmpFilters; } foreach ($filters as $id => $filter) { $row = array(); $row['id'] = $filter->id; $row['data'] = array(); $row['data'][] = $filter->name; $row['data'][] = $filter->defaultValue; $row['data'][] = $filter->type; $row['data'][] = $this->_formatOptions($filter->options); $rows[] = $row; } $reportBase->filters = serialize($filters); $reportBase->persist(); } $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct(array('rows' => $rows)); }
public function getReportAction() { $baseId = (int) $this->_getParam('baseId'); $data = array('filters' => array(), 'views' => array()); $reportBase = new ReportBase(); $reportBase->reportBaseId = $baseId; $reportBase->populate(); foreach ($reportBase->reportFilters as $reportFilter) { $filter = array(); $filter['id'] = $reportFilter->id; $filter['name'] = $reportFilter->name; $filter['defaultValue'] = $reportFilter->defaultValue; $filter['type'] = $reportFilter->type; $filter['options'] = $reportFilter->options; if ($reportFilter->type == ReportBase::FILTER_TYPE_ENUM) { $enumerationClosure = new EnumerationClosure(); $filter['enums'] = array(); $paths = $enumerationClosure->generatePaths($reportFilter->enumName['id']); foreach ($paths as $id => $name) { $filter['enums'][] = array('id' => $id, 'name' => $name); } } else { if ($reportFilter->type == ReportBase::FILTER_TYPE_QUERY) { $reportQuery = new ReportQuery(); $reportQuery->reportBaseId = (int) $reportBase->reportBaseId; $reportQueryIterator = $reportQuery->getIteratorByBaseId(null, ReportQuery::TYPE_SQL); $filter['queries'] = array(); foreach ($reportQueryIterator as $query) { $filter['queries'][] = array('id' => $query->reportQueryId, 'name' => $query->displayName); } } } $data['filters'][] = $filter; } $reportView = new ReportView(); $filters = array('reportBaseId' => $reportBase->reportBaseId, 'active' => 1); $reportViewIterator = $reportView->getIteratorByFilters($filters); foreach ($reportViewIterator as $view) { $row = array(); $row['id'] = $view->reportViewId; $row['data'] = array(); $row['data'][] = $view->displayName; $row['data'][] = $view->runQueriesImmediately; $row['data'][] = strlen($view->showResultsIn) > 0 ? $view->showResultsIn : 'grid'; $data['views'][] = $row; } $this->view->filterTypes = ReportBase::getFilterTypes(); $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct($data); }
public function getReportAction() { $baseId = (int) $this->_getParam('baseId'); $data = array('filters' => array(), 'views' => array()); $reportBase = new ReportBase(); $reportBase->reportBaseId = $baseId; $reportBase->populate(); foreach ($reportBase->reportFilters as $reportFilter) { $filter = array(); $filter['id'] = $reportFilter->id; $filter['name'] = $reportFilter->name; $filter['defaultValue'] = $reportFilter->defaultValue; $filter['type'] = $reportFilter->type; $filter['options'] = $reportFilter->options; $list = null; if ($reportFilter->type == ReportBase::FILTER_TYPE_ENUM) { $enumerationClosure = new EnumerationClosure(); $filter['enums'] = array(); $paths = $enumerationClosure->generatePaths($reportFilter->enumName['id']); foreach ($paths as $id => $name) { $filter['enums'][] = array('id' => $id, 'name' => $name); } } else { if ($reportFilter->type == ReportBase::FILTER_TYPE_QUERY) { $reportQuery = new ReportQuery(); $reportQuery->reportQueryId = (int) $reportFilter->query; $reportQuery->populate(); $filter['queries'] = $reportQuery->executeQuery(); if ($reportFilter->includeBlank) { array_unshift($filter['queries'], array('id' => '', 'name' => ' ')); } } else { if ($reportFilter->type == ReportBase::FILTER_TYPE_LIST_BUILDING) { $orm = new Building(); $list = array('ormIterator' => $orm->getIterator(), 'id' => 'buildingId', 'name' => 'displayName'); } else { if ($reportFilter->type == ReportBase::FILTER_TYPE_LIST_PRACTICE) { $orm = new Practice(); $list = array('ormIterator' => $orm->getIterator(), 'id' => 'practiceId', 'name' => 'name'); } else { if ($reportFilter->type == ReportBase::FILTER_TYPE_LIST_PROVIDER) { $orm = new Provider(); $list = array('ormIterator' => $orm->getIter(), 'id' => 'personId', 'name' => 'displayName'); } else { if ($reportFilter->type == ReportBase::FILTER_TYPE_LIST_ROOM) { $orm = new Room(); $list = array('ormIterator' => $orm->getIterator(), 'id' => 'roomId', 'name' => 'displayName'); } else { if ($reportFilter->type == ReportBase::FILTER_TYPE_LIST_BUILDING_PREF || $reportFilter->type == ReportBase::FILTER_TYPE_LIST_ROOM_PREF || $reportFilter->type == ReportBase::FILTER_TYPE_LIST_PROVIDER_PREF) { $room = User::myPreferencesLocation(); $practiceId = (int) $room->building->practiceId; $buildingId = (int) $room->buildingId; if ($reportFilter->type == ReportBase::FILTER_TYPE_LIST_BUILDING_PREF) { $orm = new Building(); $orm->practiceId = $practiceId; $list = array('ormIterator' => $orm->getIteratorByPracticeId(), 'id' => 'buildingId', 'name' => 'displayName'); } else { if ($reportFilter->type == ReportBase::FILTER_TYPE_LIST_ROOM_PREF) { $orm = new Room(); $orm->buildingId = $buildingId; $list = array('ormIterator' => $orm->getIteratorByBuildingId(), 'id' => 'roomId', 'name' => 'displayName'); } else { $orm = new Provider(); $list = array('ormIterator' => $orm->getIteratorByPracticeId($practiceId), 'id' => 'personId', 'name' => 'displayName'); } } } } } } } } } if ($list !== null) { $filter['lists'] = array(); foreach ($list['ormIterator'] as $row) { $filter['lists'][] = array('id' => $row->{$list['id']}, 'name' => htmlspecialchars($row->{$list['name']})); } } $data['filters'][] = $filter; } $reportView = new ReportView(); $filters = array('reportBaseId' => $reportBase->reportBaseId, 'active' => 1); $reportViewIterator = $reportView->getIteratorByFilters($filters); foreach ($reportViewIterator as $view) { $row = array(); $row['id'] = $view->reportViewId; $row['data'] = array(); $row['data'][] = $view->displayName; $row['data'][] = $view->runQueriesImmediately; $row['data'][] = strlen($view->showResultsIn) > 0 ? $view->showResultsIn : 'grid'; $data['views'][] = $row; } $this->view->filterTypes = ReportBase::getFilterTypes(); $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct($data); }