protected function _getBuildings()
 {
     $building = new Building();
     $buildingIterator = $building->getIterator();
     $buildings = array();
     foreach ($buildingIterator as $item) {
         $buildings[$item->id] = $item->name;
     }
     return $buildings;
 }
Пример #2
0
 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);
 }