/** Add an organisation
  * @access public
  * @return void
  */
 public function addAction()
 {
     $form = new OrganisationForm();
     $form->submit->setLabel('Add a new organisation');
     $this->view->form = $form;
     if ($this->_request->isPost()) {
         if ($form->isValid($this->_request->getPost())) {
             $data = $form->getValues();
             $data['secuid'] = $this->secuid();
             unset($data['contact']);
             $insert = $this->getOrganisations()->add($data);
             $this->redirect(self::REDIRECT . 'organisation/id/' . $insert);
             $this->getFlash()->addMessage('Record created!');
         } else {
             $form->populate($this->_request->getPost());
         }
     }
 }
 /** Add an organisation
  */
 public function addAction()
 {
     $form = new OrganisationForm();
     $form->submit->setLabel('Add a new organisation');
     $this->view->form = $form;
     if ($this->_request->isPost()) {
         $formData = $this->_request->getPost();
         if ($form->isValid($formData)) {
             $address = $form->getValue('address') . ',' . $form->getValue('town_city') . ',' . $form->getValue('county') . ',' . $form->getValue('postcode') . ',' . $form->getValue('country');
             $coords = $this->_geocoder->getCoordinates($address);
             if ($coords) {
                 $lat = $coords['lat'];
                 $long = $coords['lon'];
             } else {
                 $lat = NULL;
                 $lon = NULL;
             }
             $pm = new Placemaker();
             $place = $pm->get($address);
             $woeid = $place->woeid;
             $insertData['secuid'] = $this->secuid();
             $insertData['name'] = $form->getValue('name');
             $insertData['website'] = $form->getValue('website');
             $insertData['address1'] = $form->getValue('address1');
             $insertData['address2'] = $form->getValue('address2');
             $insertData['address3'] = $form->getValue('address3');
             $insertData['address'] = $form->getValue('address');
             $insertData['postcode'] = $form->getValue('postcode');
             $insertData['town_city'] = $form->getValue('town_city');
             $insertData['county'] = $form->getValue('county');
             $insertData['country'] = $form->getValue('country');
             $insertData['contactpersonID'] = $form->getValue('contactpersonID');
             $insertData['lat'] = $lat;
             $insertData['lon'] = $lon;
             $insertData['woeid'] = $woeid;
             $insertData['updated'] = $this->getTimeForForms();
             $insertData['updatedBy'] = $this->getIdentityForForms();
             foreach ($insertData as $key => $value) {
                 if (is_null($value) || $value == "") {
                     unset($insertData[$key]);
                 }
             }
             $insert = $this->_organisations->insert($insertData);
             $this->_redirect(self::REDIRECT . 'organisation/id/' . $insert);
             $this->_flashMessenger->addMessage('Record created!');
         } else {
             $form->populate($formData);
         }
     }
 }