/** Function for adding and processing the findspot data * @access public * @param array $data */ public function addAndProcess($data) { if (is_array($data)) { foreach ($data as $k => $v) { if ($v == "") { $data[$k] = NULL; } } if (!is_null($data['gridref'])) { $data = $this->_processFindspot($data); } $findid = new Pas_Generator_FindID(); $data['old_findspotid'] = $findid->generate(); $secuid = new Pas_Generator_SecuID(); $data['secuid'] = $secuid->secuid(); if (array_key_exists('landownername', $data)) { unset($data['landownername']); } if (array_key_exists('csrf', $data)) { unset($data['csrf']); } if (empty($data['created'])) { $data['created'] = $this->timeCreation(); } if (empty($data['createdBy'])) { $data['createdBy'] = $this->userNumber(); return parent::insert($data); } else { throw new Exception('The data submitted is not an array', 500); } } }
/** Function for adding and processing the findspot data * @access public * @param array $data * @return array * @throws Exception */ public function addAndProcess(array $data) { if (is_array($data)) { foreach ($data as $k => $v) { if ($v == "") { $data[$k] = NULL; } } if (!is_null($data['gridref'])) { $data = $this->_processFindspot($data); } $findid = new Pas_Generator_FindID(); $data['old_findspotid'] = $findid->generate(); $secuid = new Pas_Generator_SecuID(); $data['secuid'] = $secuid->secuid(); //Get the label for the parish if (array_key_exists('parishID', $data) && !is_null($data['parishID'])) { $parishes = new OsParishes(); $data['parish'] = $parishes->fetchRow($parishes->select()->where('osID = ?', $data['parishID']))->label; } //Get the label for the county if (array_key_exists('countyID', $data) && !is_null($data['countyID'])) { $counties = new OsCounties(); $data['county'] = $counties->fetchRow($counties->select()->where('osID = ?', $data['countyID']))->label; } //Get the label for the district if (array_key_exists('districtID', $data) && !is_null($data['districtID'])) { $district = new OsDistricts(); $data['district'] = $district->fetchRow($district->select()->where('osID = ?', $data['districtID']))->label; } if (array_key_exists('landownername', $data)) { unset($data['landownername']); } if (array_key_exists('csrf', $data)) { unset($data['csrf']); } if (empty($data['created'])) { $data['created'] = $this->timeCreation(); } if (empty($data['createdBy'])) { $data['createdBy'] = $this->getUserNumber(); } return parent::insert($data); } else { throw new Exception('The data submitted is not an array', 500); } }