/** Retrieval of findspots data row for cloning record * @param integer $userid * @return array $data * @todo add caching */ public function getLastRecord($userid) { $fieldList = new CopyFindSpot(); //Get field list from model $fields = $fieldList->getConfig(); $finds = $this->getAdapter(); $select = $finds->select()->from($this->_name, $fields)->where('findspots.createdBy = ?', (int) $userid)->order('findspots.id DESC')->limit(1); return $finds->fetchAll($select); }
/** Set up and configure which findspot fields to copy when copying record * @access public * @return void */ public function findspotAction() { $form = new ConfigureFindSpotCopyForm(); $this->view->form = $form; $copyFindSpot = new CopyFindSpot(); $current = $copyFindSpot->getConfig(); $values = array(); foreach ($current as $cur) { $values[$cur] = 1; } $form->populate($values); if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { $copyFindSpot->updateConfig($form->getValues()); $this->getFlash()->addMessage('Copy last record fields for findspot table updated'); $this->redirect('/users/configuration/'); } else { $form->populate($values); } } }