/** Index page for smrs */ public function indexAction() { $monumentName = $this->_getParam('monumentName'); $county = $this->_getParam('county'); $district = $this->_getParam('district'); $parish = $this->_getParam('parish'); $page = $this->_getParam('page'); $smrs = new ScheduledMonuments(); $this->view->smrs = $smrs->getSmrs($page, $county, $district, $parish, $monumentName); $form = new SAMFilterForm(); $this->view->form = $form; if (!is_null($county)) { $districts = new Places(); $district_list = $districts->getDistrictList($county); $form->district->addMultiOptions(array(NULL => NULL, 'Choose district' => $district_list)); if (!is_null($district)) { $parish_list = $districts->getParishList($district); $form->parish->addMultiOptions(array(NULL => NULL, 'Choose parish' => $parish_list)); } } $form->monumentName->setValue($monumentName); $form->district->setValue($district); $form->parish->setValue($parish); $form->county->setValue($county); if ($this->_request->isPost() && !is_null($this->_getParam('submit'))) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { $params = array_filter($formData); unset($params['submit']); unset($params['action']); unset($params['controller']); unset($params['module']); unset($params['page']); unset($params['csrf']); $where = array(); foreach ($params as $key => $value) { if (!is_null($value)) { $where[] = $key . '/' . urlencode(strip_tags($value)); } } $whereString = implode('/', $where); $query = $whereString; $this->_redirect(self::REDIRECT . 'index/' . $query . '/'); } else { $form->populate($formData); } } }
public function optionsAddClone() { $findspots = new Findspots(); $findspot = $findspots->getLastRecord($this->_getIdentity()); $data = $findspot[0]; $this->_view->form->populate($data); Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger')->addMessage('Your last record data has been cloned'); if (!is_null($data['county'])) { $districts = new Places(); $district = $districts->getDistrictList($data['county']); if ($district) { $this->_view->form->district->addMultiOptions(array(NULL => 'Choose district', 'Available districts' => $district)); } if (!is_null($data['district'])) { $parishes = $districts->getParishList($data['district']); $this->_view->form->parish->addMultiOptions(array(NULL => 'Choose parish', 'Available parishes' => $parishes)); } if (!is_null($data['county'])) { $cnts = new Counties(); $region_list = $cnts->getRegionsList($data['county']); $this->_view->form->regionID->addMultiOptions(array(NULL => 'Choose region', 'Available regions' => $region_list)); } } if (!is_null($data['landusevalue'])) { $landcodes = new Landuses(); $landusecode_options = $landcodes->getLandusesChildList($data['landusevalue']); $this->_view->form->landusecode->addMultiOptions(array(NULL => 'Choose code', 'Available landuses' => $landusecode_options)); } if (!is_null($findspot['landowner'])) { $finders = new Peoples(); $finders = $finders->getName($findspot['landowner']); foreach ($finders as $finder) { $form->landownername->setValue($finder['term']); } } }
/** Edit crime details * @todo messy rewrite */ public function editAction() { if ($this->_getParam('id', false)) { $form = new HeritageCrimeForm(); $form->submit->setLabel('Update crime'); $this->view->form = $form; if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { $ngr = $form->getValue('gridref'); if (!is_null($ngr) || $ngr != "") { $results = $this->GridCalc($ngr); $fourFigure = $this->FourFigure($ngr); $place = new Pas_Service_Geo_Geoplanet($this->_appid); $findelevation = $place->getElevation(NULL, $results['Latitude'], $results['Longitude']); $findwoeid = $place->reverseGeoCode($results['Latitude'], $results['Longitude']); $elevation = $findelevation['elevation']; $woeid = $findwoeid['woeid']; } else { $elevation = NULL; $woeid = NULL; } $updateData = array('subject' => $form->getValue('subject'), 'reporterID' => $form->getValue('reporterID'), 'incidentDate' => $form->getValue('incidentDate'), 'crimeType' => $form->getValue('crimeType'), 'gridref' => $form->getValue('gridref'), 'latitude' => $results['Latitude'], 'longitude' => $results['Longitude'], 'easting' => $results['Easting'], 'northing' => $results['Northing'], 'map10k' => $results['Tenk'], 'map25k' => $results['2pt5K'], 'fourFigure' => $fourFigure, 'description' => $form->getValue('description'), 'updated' => $this->getTimeForForms(), 'updatedBy' => $this->getIdentityForForms(), 'woeid' => $woeid, 'elevation' => $elevation, 'samID' => $form->getValue('samID'), 'evaluation' => $form->getValue('evaluation'), 'reliability' => $form->getValue('reliability'), 'county' => $form->getValue('county'), 'district' => $form->getValue('district'), 'parish' => $form->getValue('parish'), 'intellEvaluation' => $form->getValue('intellEvaluation'), 'reportSubject' => $form->getValue('reportSubject'), 'subjectDetails' => $form->getValue('subjectDetails'), 'reportingPerson' => $form->getValue('reportingPerson')); foreach ($updateData as $key => $value) { if (is_null($value) || $value == "") { $updateData[$key] = NULL; } } $where = array(); $where[] = $this->_crimes->getAdapter()->quoteInto('id = ?', $this->_getParam('id')); $this->_crimes->update($updateData, $where); $returnID = $this->_getParam('id'); $this->_flashMessenger->addMessage('Crime details updated!'); $this->_redirect(self::REDIRECT . 'crime/id/' . $returnID); } else { $id = (int) $this->_request->getParam('id', 0); if ($id > 0) { $crime = $this->_crimes->getCrime($this->_getParam('id')); if (!is_null($crime['0']['county'])) { $districts = new Places(); $district_list = $districts->getDistrictList($crime['0']['county']); $form->district->addMultiOptions(array(NULL => 'Choose district', 'Available districts' => $district_list)); if (!is_null($crime['0']['district'])) { $parish_list = $districts->getParishList($crime['0']['district']); $form->parish->addMultiOptions(array(NULL => 'Choose parish', 'Available parishes' => $parish_list)); } } $form->populate($formData); } } } else { $id = (int) $this->_request->getParam('id', 0); if ($id > 0) { $crime = $this->_crimes->getCrime($this->_getParam('id')); if (!is_null($crime['0']['county'])) { $districts = new Places(); $district_list = $districts->getDistrictList($crime['0']['county']); $form->district->addMultiOptions(array(NULL => 'Choose district', 'Available districts' => $district_list)); if (!is_null($crime['0']['district'])) { $parish_list = $districts->getParishList($crime['0']['district']); $form->parish->addMultiOptions(array(NULL => 'Choose parish', 'Available parishes' => $parish_list)); } } $form->populate($crime['0']); } } } else { throw new Exception($this->_missingParameter); } }
/** Edit individual rally details */ public function editAction() { if ($this->_getParam('id', false)) { $form = new RallyForm(); $form->submit->setLabel('Update details'); $this->view->form = $form; if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { $results = $this->GridCalc($form->getValue('gridref')); $fourFigure = $this->FourFigure($form->getValue('gridref')); $updateData = array('rally_name' => $form->getValue('rally_name'), 'organiser' => $form->getValue('organiser'), 'county' => $form->getValue('county'), 'district' => $form->getValue('district'), 'parish' => $form->getValue('parish'), 'gridref' => $form->getValue('gridref'), 'easting' => $results['Easting'], 'northing' => $results['Northing'], 'latitude' => $results['Latitude'], 'longitude' => $results['Longitude'], 'map10k' => $results['Tenk'], 'map25k' => $results['2pt5K'], 'fourFigure' => $fourFigure, 'comments' => $form->getValue('comments'), 'record_method' => $form->getValue('record_method'), 'date_from' => $form->getValue('date_from'), 'date_to' => $form->getValue('date_to'), 'updated' => $this->getTimeForForms(), 'updatedBy' => $this->getIdentityForForms()); $where = array(); $where[] = $this->_rallies->getAdapter()->quoteInto('id = ?', $this->_getParam('id')); $update = $this->_rallies->update($updateData, $where); $this->_cache->remove('rallydd'); $this->_flashMessenger->addMessage('Rally information updated!'); $this->_redirect(self::URL . 'rally/id/' . $this->_getParam('id')); } else { if (!is_null($formData['district'])) { $districts = new Places(); $district_list = $districts->getDistrictList($formData['county']); $form->district->addMultiOptions(array(NULL => NULL, 'Choose district' => $district_list)); $parish_list = $districts->getParishList($formData['district']); $form->parish->addMultiOptions(array(NULL => NULL, 'Choose parish' => $parish_list)); } $form->populate($formData); } } else { // find id is expected in $params['id'] $id = (int) $this->_request->getParam('id', 0); if ($id > 0) { $rallies = new Rallies(); $rally = $rallies->fetchRow('id=' . $id); if (count($rally)) { $form->populate($rally->toArray()); } else { throw new Exception($this->_nothingFound); } if (!is_null($rally['district'])) { $districts = new Places(); $district_list = $districts->getDistrictList($rally['county']); $form->district->addMultiOptions(array(NULL => NULL, 'Choose district' => $district_list)); $parish_list = $districts->getParishList($rally['district']); $form->parish->addMultiOptions(array(NULL => NULL, 'Choose parish' => $parish_list)); } if (!is_null($rally['organiser'])) { $organisers = new Peoples(); $organisers = $organisers->getName($rally['organiser']); foreach ($organisers as $organiser) { $form->organisername->setValue($organiser['term']); } } } } } else { throw new Exception($this->_missingParameter); } }