Example #1
0
 /**
  * admin_inetis method
  *
  * @return void
  */
 public function admin_inetis($ddv)
 {
     $search = array('iskalni_niz' => $ddv);
     $client = new SoapClient('http://ddv.inetis.com/Iskalnik.asmx?WSDL');
     $data = array();
     if (is_callable(array($client, 'Isci')) && ($result = $client->Isci($search))) {
         if (isset($result->IsciResult->anyType)) {
             $result = $result->IsciResult->anyType->enc_value;
             $street = $result->xmlNaslov;
             $zip = '';
             $city = '';
             $post_pos = mb_strrpos($street, ', ');
             if ($post_pos !== false) {
                 $zip = mb_substr($street, $post_pos + 2, 4);
                 $city = mb_substr($street, $post_pos + 6);
                 $street = mb_substr($street, 0, $post_pos);
             }
             $data = array('title' => $result->xmlNaziv, 'mat_no' => $result->xmlMaticnaStevilka, 'tax_no' => $result->xmlDavcnaStevilka, 'tax_status' => $result->xmlPlacnikDDV, 'street' => $street, 'zip' => $zip, 'city' => $city);
         } else {
             return $this->error404();
         }
     }
     $this->RequestHandler->respondAs('json');
     $this->autoRender = false;
     echo json_encode($data);
 }