Exemple #1
0
 /**
  * @param null $name
  * @param null $postcode
  * @return array
  */
 public function getCities($name = null, $postcode = null)
 {
     $cities = array();
     if (isset($this->resultLogin)) {
         if ($postcode) {
             require_once __DIR__ . '/lib/speedy-eps-lib/ver01/ParamFilterSite.class.php';
             $paramFilterSite = new \ParamFilterSite();
             $paramFilterSite->setPostCode($postcode);
             $paramFilterSite->setName($name);
             $listSitesEx = $this->facade->listSitesEx($paramFilterSite);
             $listSites = array();
             /* @var \ResultSiteEx $result */
             foreach ($listSitesEx as $result) {
                 if ($result->isExactMatch()) {
                     $listSites[] = $result->getSite();
                 }
             }
         } else {
             $listSites = $this->facade->listSites(null, $name);
         }
         if ($listSites) {
             /* @var \ResultSite $city */
             foreach ($listSites as $city) {
                 $cities[] = array('id' => $city->getId(), 'label' => $city->getType() . ' ' . $city->getName() . ' (' . $city->getPostCode() . '), общ. ' . $city->getMunicipality() . ', обл. ' . $city->getRegion(), 'value' => $city->getType() . ' ' . $city->getName() . ' (' . $city->getPostCode() . '), общ. ' . $city->getMunicipality() . ', обл. ' . $city->getRegion(), 'postcode' => $city->getPostCode(), 'nomenclature' => $city->getAddrNomen()->getValue());
             }
         }
     }
     return $cities;
 }
 var_dump($senderClientData);
 // Идентификатор на населеното място на подателя
 $senderSiteId = $senderClientData->getAddress()->getSiteId();
 echo "<br><br><br><br>";
 echo "Идентификатор на населено място на подателя (от номенклатурата на Speedy):<br>";
 echo "--------------------------------------------------------------------------<br>";
 echo "" . $senderSiteId . "<br>";
 // Определяме населеното място на получателя
 echo "<br><br><br><br>";
 echo "--------------------------------------------------------------------------------------------------<br>";
 echo "Извличане на населени места на получателя по тип и име (от номенклатурата на Speedy) [listSitesEx]<br>";
 echo "--------------------------------------------------------------------------------------------------<br>";
 echo "Параметри:<br>";
 $paramFilterSite = new ParamFilterSite();
 $paramFilterSite->setType($recieverData->address->siteType);
 $paramFilterSite->setName($recieverData->address->siteName);
 var_dump($paramFilterSite);
 $arrResultSiteEx = $eps->listSitesEx($paramFilterSite);
 var_dump($arrResultSiteEx);
 if (count($arrResultSiteEx) == 0) {
     // Населеното място на получателя не е намерено
     throw new ClientException("Населеното място на получателя не е намерено.");
 } else {
     if (count($arrResultSiteEx) == 1) {
         // Населеното място на получателя е намерено и еднозначно определено
         echo "<br>";
         echo "Намерено е точно едно възможно населено място на получателя с посочения критерий.<br>";
         $resultSiteEx = $arrResultSiteEx[0];
     } else {
         // Намерени са няколко населени места с това име. Потребителят e необходимо да избере от списъка
         echo "<br>";
Exemple #3
0
 /** Returns cities
  * @param null $name
  * @param null $postcode
  * @return array
  */
 public function getCities($name = null, $postcode = null)
 {
     $this->_error = '';
     $cities = array();
     if (isset($this->resultLogin)) {
         try {
             if ($postcode) {
                 require_once __DIR__ . '/lib/speedy-eps-lib/ver01/ParamFilterSite.class.php';
                 $paramFilterSite = new \ParamFilterSite();
                 $paramFilterSite->setPostCode($postcode);
                 $paramFilterSite->setName($name);
                 $listSitesEx = $this->ePSFacade->listSitesEx($paramFilterSite);
                 $listSites = array();
                 foreach ($listSitesEx as $result) {
                     if ($result->isExactMatch()) {
                         $listSites[] = $result->getSite();
                     }
                 }
             } else {
                 $listSites = $this->ePSFacade->listSites(null, $name);
             }
             if ($listSites) {
                 foreach ($listSites as $city) {
                     $cities[] = array('id' => $city->getId(), 'label' => $city->getType() . ' ' . $city->getName() . ' (' . $city->getPostCode() . '), общ. ' . $city->getMunicipality() . ', обл. ' . $city->getRegion(), 'value' => $city->getType() . ' ' . $city->getName() . ' (' . $city->getPostCode() . '), общ. ' . $city->getMunicipality() . ', обл. ' . $city->getRegion(), 'postcode' => $city->getPostCode(), 'nomenclature' => $city->getAddrNomen()->getValue());
                 }
             }
         } catch (\Exception $e) {
             $this->_error = $e->getMessage();
             $this->log->addError('Speedy :: getCities :: ' . $e->getMessage());
         }
     }
     return $cities;
 }