Пример #1
0
 public function autofindAction()
 {
     //если идет запрос типа
     if ($this->getRequest()->getParam('id')) {
         $id = $this->getRequest()->getParam('id');
     } else {
         echo json_encode('NULL');
         //передаем id клиенту
         die;
     }
     $device = new Application_Model_DbTable_Devices();
     $device_data = $device->getDevice($id);
     $adress = 'Ukraine+' . Application_Model_Decoder::translit($device_data['city']) . '+' . Application_Model_Decoder::translit($device_data['adress']);
     $position = file_get_contents("https://maps.googleapis.com/maps/api/geocode/json?address={$adress}&key=AIzaSyAoQKZO_RC6V2FUsSISFhE72Sx5A6YQoCI");
     //$position = header( "Location: https://maps.googleapis.com/maps/api/geocode/json?address=$adress&key=AIzaSyAoQKZO_RC6V2FUsSISFhE72Sx5A6YQoCI" );
     //var_dump($position);die;
     $position = json_decode($position, true);
     $position = array('lat' => "{$position['results'][0]["geometry"]["location"]['lat']}", 'lng' => "{$position['results'][0]["geometry"]["location"]['lng']}");
     echo json_encode($position);
     die;
 }
Пример #2
0
 public function deleteAction()
 {
     // action body
     $form = new Application_Form_DeleteDevice();
     $form->submit->setLabel('Удалить');
     $form->cancel->setLabel('Отмена');
     $this->view->form = $form;
     $id = $this->getParam('id');
     //если идет запрос POST
     if ($this->getRequest()->isPost()) {
         //если подтверждаем удаление
         if ($this->getRequest()->getPost('submit')) {
             $device = new Application_Model_DbTable_Devices();
             $device->deleteDevice($id);
             $this->_helper->redirector('index');
         } else {
             //если отменяем удаление
             if ($this->getRequest()->getPost('cancel')) {
                 $this->_helper->redirector('index');
             }
         }
     } else {
         //выводим дополнительные данные
         $device = new Application_Model_DbTable_Devices();
         $this->view->device = $device->getDevice($id);
     }
 }