public function testGetLocationData()
 {
     $result = AddressService::getLocationData('410 W 4th');
     $this->assertEquals('410 W 4th ST', $result['location']);
 }
 /**
  * @param REQUEST ticket_id
  * @param REQUEST location
  */
 public function changeLocation()
 {
     $ticket = $this->loadTicket($_REQUEST['ticket_id']);
     // Once the user has chosen a location, they'll pass it in here
     if (isset($_REQUEST['location']) && $_REQUEST['location']) {
         $ticket->clearAddressServiceData();
         $ticket->setLocation($_REQUEST['location']);
         $ticket->setAddressServiceData(AddressService::getLocationData($ticket->getLocation()));
         try {
             $ticket->save();
             $this->redirectToTicketView($ticket);
         } catch (\Exception $e) {
             $_SESSION['errorMessages'][] = $e;
         }
     }
     $_REQUEST['return_url'] = new Url($_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']);
     $this->template->setFilename('tickets');
     $this->template->blocks['ticket-panel'][] = new Block('locations/findLocationForm.inc', array('includeExternalResults' => true));
     $this->addStandardInfoBlocks($ticket);
 }
Exemple #3
0
 /**
  * Populates available fields from the given array
  *
  * @param array $post
  */
 public function handleUpdate($post)
 {
     // Set all the location information using any fields the user posted
     $fields = array('category_id', 'client_id', 'assignedPerson_id', 'location', 'latitude', 'longitude', 'city', 'state', 'zip');
     foreach ($fields as $field) {
         if (isset($post[$field])) {
             $set = 'set' . ucfirst($field);
             $this->{$set}($post[$field]);
         }
     }
     // If they gave us an address, and we don't have any additional info,
     // try and get the data from Master Address
     if ($this->getLocation() && (!$this->getLatitude() || !$this->getLongitude() || !$this->getCity() || !$this->getState() || !$this->getZip())) {
         $data = AddressService::getLocationData($this->getLocation());
         if ($data) {
             $this->setAddressServiceData($data);
         }
     }
 }