public function facilitiesAction() { try { require_once 'models/table/Facility.php'; $facilityTable = new Facility(); $select = $facilityTable->select()->from('facility', array('*'))->setIntegrityCheck(false); $rowRay = $facilityTable->fetchAll($select)->toArray(); $sorted = array(); foreach ($rowRay as $row) { $sorted[$row['id']] = $row; } /* $sorted = $facilityTable->_fill_lookup($sorted, 'location_city', 'city_id', 'city_name'); $sorted = $facilityTable->_fill_lookup($sorted, 'location_district', 'district_id', 'district_name'); $sorted = $facilityTable->_fill_lookup($sorted, 'location_province', 'province_id', 'province_name'); */ $locations = Location::getAll(); foreach ($sorted as $id => $row) { $city_info = Location::getCityInfo($row['location_id'], $this->setting('num_location_tiers'), $locations); if (count($city_info)) { if ($city_info[0]) { $sorted[$id]['city_name'] = $city_info[0]; } if ($city_info[1]) { $sorted[$id]['province_name'] = $locations[$city_info[1]]['name']; } if ($city_info[2]) { $sorted[$id]['district_name'] = $locations[$city_info[2]]['name']; } if ($city_info[3]) { $sorted[$id]['region_c_name'] = $locations[$city_info[3]]['name']; } if ($city_info[4]) { $sorted[$id]['region_d_name'] = $locations[$city_info[4]]['name']; } if ($city_info[5]) { $sorted[$id]['region_e_name'] = $locations[$city_info[5]]['name']; } if ($city_info[6]) { $sorted[$id]['region_f_name'] = $locations[$city_info[6]]['name']; } if ($city_info[7]) { $sorted[$id]['region_g_name'] = $locations[$city_info[7]]['name']; } if ($city_info[8]) { $sorted[$id]['region_h_name'] = $locations[$city_info[8]]['name']; } if ($city_info[9]) { $sorted[$id]['region_i_name'] = $locations[$city_info[9]]['name']; } } unset($sorted[$id]['location_id']); } $sorted = $facilityTable->_fill_lookup($sorted, 'facility_type_option', 'type_option_id', 'facility_type_phrase'); $sorted = $facilityTable->_fill_lookup($sorted, 'facility_sponsor_option', 'sponsor_option_id', 'facility_sponsor_phrase'); if ($this->getSanParam('outputType') == 'csv') { $this->sendData($this->reportHeaders(false, $sorted)); } $this->view->assign('data', $sorted); } catch (Exception $e) { echo $e->getMessage(); error_log($e->getMessage()); } }