/** The constructor * @access public * @param array $options * @return void */ public function __construct(array $options = null) { $finds = new Findspots(); $schema = $finds->info(); $fields = array_flip($schema['cols']); $remove = array('updated', 'created', 'updatedBy', 'createdBy', 'institution', 'findID', 'address', 'fourFigure', 'gridlen', 'postcode', 'easting', 'northing', 'declong', 'declat', 'fourFigureLat', 'fourFigureLon', 'woeid', 'geonamesID', 'osmNode', 'elevation', 'geohash', 'country', 'map25k', 'map10k', 'soiltype', 'smrref', 'otherref', 'id', 'accuracy', 'secuid', 'old_occupierid', 'occupier', 'old_findspotid', 'date'); foreach ($remove as $rem) { unset($fields[$rem]); } $labels = array('gridrefcert' => 'Grid reference certainty', 'gridref' => 'Grid reference', 'knownas' => 'Known as', 'disccircum' => 'Discovery circumstances', 'gridrefsrc' => 'Grid reference source', 'landusevalue' => 'Land use value', 'landusecode' => 'Land use code', 'depthdiscovery' => 'Depth of discovery', 'Highsensitivity' => 'High sensitivity'); parent::__construct($options); $this->setName('configureFindSpotCopy'); $elements = array(); foreach (array_keys($fields) as $field) { $label = $field; $field = new Zend_Form_Element_Checkbox($field); if (array_key_exists($label, $labels)) { $clean = ucfirst($labels[$label]); } else { $clean = ucfirst($label); } $field->setLabel($clean)->setRequired(false)->addValidator('NotEmpty', 'boolean'); $elements[] = $field; $this->addElement($field); } $this->addDisplayGroup($elements, 'details'); //Submit button $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel('Submit find spot configuration'); $this->addElement($submit); $this->details->setLegend('Choose fields: '); parent::init(); }
/** Clone the options and add to form * @access public * @return \Pas_Controller_Action_Helper_FindspotFormOptions */ 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 (array_key_exists('countyID', $data) && !is_null($data['countyID'])) { $districts = new OsDistricts(); $district = $districts->getDistrictsToCountyList($data['countyID']); if ($district) { $this->_view->form->districtID->addMultiOptions(array(null => 'Choose district', 'Available districts' => $district)); } if (array_key_exists('districtID', $data) && !is_null($data['districtID'])) { $parishes = new OsParishes(); $parishes = $parishes->getParishesToDistrictList($data['districtID']); $this->_view->form->parishID->addMultiOptions(array(null => 'Choose parish', 'Available parishes' => $parishes)); } if (array_key_exists('countyID', $data) && !is_null($data['countyID'])) { $cnts = new OsCounties(); $region_list = $cnts->getCountyToRegionList($data['countyID']); $this->_view->form->regionID->addMultiOptions(array(null => 'Choose region', 'Available regions' => $region_list)); } } if (array_key_exists('landusevalue', $data)) { $landcodes = new Landuses(); $landusecode_options = $landcodes->getLandusesChildList($data['landusevalue']); $this->_view->form->landusecode->addMultiOptions(array(null => 'Choose code', 'Available landuses' => $landusecode_options)); } if (array_key_exists('landowner', $data)) { $finders = new People(); $finders = $finders->getName($data['landowner']); foreach ($finders as $finder) { $this->_view->form->landownername->setValue($finder['term']); } } return $this; }
public function updatehoardsAction() { $findspots = $this->_findspots; $records = $findspots->getNewData('IARCH'); foreach ($records as $data) { echo 'Updating ' . $data['id'] . '<br/>'; $newData = $this->_findspots->updateAndProcessGrids($data); $where = array(); $where[] = $this->_findspots->getAdapter()->quoteInto('id = ?', $newData['id']); $this->_findspots->update($newData, $where); Zend_Debug::dump($data); usleep(2000); } echo 'Done'; }
public function objectmapAction() { $period = $this->_getParam('period'); $objecttype = $this->_getParam('objecttype'); $limit = $this->_getParam('limit'); $mapdata = new Findspots(); $mapdatas = $mapdata->getFindspotDataMappingObjects($period, $objecttype, $limit); $dom = new DOMDocument("1.0"); $node = $dom->createElement("markers"); $parnode = $dom->appendChild($node); foreach ($mapdatas as $mapdata) { $node = $dom->createElement("marker"); $newnode = $parnode->appendChild($node); $newnode->setAttribute("name", $mapdata['old_findID']); $newnode->setAttribute("broadperiod", $mapdata['broadperiod']); $newnode->setAttribute("lat", $mapdata['declat']); $newnode->setAttribute("lng", $mapdata['declong']); $newnode->setAttribute("type", $mapdata['objecttype']); } echo $dom->saveXML(); }
/** Action for deleting findspot * */ public function deleteAction() { if ($this->_getParam('id', false)) { if ($this->_request->isPost()) { $id = (int) $this->_request->getPost('id'); $findID = (int) $this->_request->getPost('findID'); $del = $this->_request->getPost('del'); if ($del == 'Yes' && $id > 0) { $this->_findspots = new Findspots(); $where = 'id = ' . $id; $this->_helper->solrUpdater->update('beowulf', $findID); $this->_flashMessenger->addMessage('Findspot deleted.'); } $this->_redirect(self::REDIRECT . 'record/id/' . $findID); } else { $id = (int) $this->_request->getParam('id'); if ($id > 0) { $findspots = new Findspots(); $this->view->findspot = $findspots->getFindtoFindspotDelete($this->_getParam('id')); } } } else { throw new Pas_Exception_Param($this->_missingParameter, 500); } }
/** Display a report in pdf format */ public function reportAction() { if ($this->_getParam('id', false)) { $this->view->recordID = $this->_getParam('id'); $id = $this->_getParam('id'); $finds = new Finds(); $findsdata = $finds->getIndividualFind($id, $this->getRole()); if (count($findsdata)) { $this->view->finds = $findsdata; } else { throw new Pas_Exception_NotAuthorised('You are not authorised to view this record'); } $findsdata = new Finds(); $this->view->findsdata = $findsdata->getFindData($id); $this->view->findsmaterial = $findsdata->getFindMaterials($id); $this->view->temporals = $findsdata->getFindTemporalData($id); $this->view->peoples = $findsdata->getPersonalData($id); $rallyfind = new Rallies(); $this->view->rallyfind = $rallyfind->getFindRallyNames($id); $coins = new Coins(); $this->view->coins = $coins->getCoinData($id); $thumbs = new Slides(); $this->view->thumbs = $thumbs->getThumbnails($id); $refs = new Publications(); $this->view->refs = $refs->getReferences($id); $findspotsdata = new Findspots(); $this->view->findspots = $findspotsdata->getFindSpotData($id); } else { throw new Pas_Exception_Param($this->_missingParameter, 500); } }
/** Delete a record */ public function deleteAction() { if ($this->_request->isPost()) { $id = (int) $this->_request->getPost('id'); $del = $this->_request->getPost('del'); if ($del == 'Yes' && $id > 0) { $where = $this->_finds->getAdapter()->quoteInto('id = ?', $id); $this->_finds->delete($where); $findID = $this->_request->getPost('findID'); $findspots = new Findspots(); $whereFindspots = array(); $whereFindspots[] = $this->_finds->getAdapter()->quoteInto('findID = ?', $findID); $this->_flashMessenger->addMessage('Record deleted!'); $findspots->delete($whereFindspots); $this->_helper->solrUpdater->deleteById('beowulf', $id); $this->_redirect(self::REDIRECT); } $this->_flashMessenger->addMessage('No changes made!'); $this->_redirect('database/artefacts/record/id/' . $id); } else { $id = (int) $this->_request->getParam('id'); if ($id > 0) { $this->view->find = $this->_finds->fetchRow('id=' . $id); } } }