Beispiel #1
0
     for ($i = 1; $i <= 16; $i++) {
         if ($i < 10) {
             $nb = '0' . $i;
         } else {
             $nb = $i;
         }
         echo '<option value="MARSEILLE ' . $nb . '">MARSEILLE ' . $nb . '</option>';
     }
 } else {
     try {
         if (Tools::getValue('id_shop')) {
             $tntWebService = new TntWebService(Tools::safeOutput(Tools::getValue('id_shop')));
         } else {
             $tntWebService = new TntWebService();
         }
         $cities = $tntWebService->getCity($postal);
     } catch (SoapFault $e) {
         $erreur = $e->faultstring;
     } catch (Exception $e) {
         $erreur = "Problem : follow failed";
     }
     if (!isset($erreur)) {
         if (isset($cities->City) && is_array($cities->City)) {
             foreach ($cities->City as $v) {
                 echo '<option value="' . $v->name . '">' . $v->name . '</option>';
             }
         } else {
             if (isset($cities->City)) {
                 echo '<option value="' . $cities->City->name . '">' . $cities->City->name . '</option>';
             } else {
                 echo '<option value="">Aucune ville</option>';
 public function hookextraCarrier($params)
 {
     if (!$this->active) {
         return;
     }
     if (!Configuration::get('TNT_CARRIER_LOGIN') || !Configuration::get('TNT_CARRIER_PASSWORD') || !Configuration::get('TNT_CARRIER_NUMBER_ACCOUNT')) {
         return;
     }
     global $smarty;
     $id_cart = $params['cart']->id;
     $city = $this->putCityInNormeTnt($params['address']->city);
     $postal_code = $params['address']->postcode;
     if (serviceCache::getError($id_cart)) {
         $smarty->assign('error', $this->l('The postal Code entered does not correspond to the city.') . '<br/>' . $this->l('Please confirm the city below :'));
         $smarty->assign('postalCode', $postal_code);
         $postal = $postal_code;
         $cities = array();
         if ($postal == '75000') {
             for ($i = 1; $i <= 20; $i++) {
                 if ($i < 10) {
                     $nb = '0' . $i;
                 } else {
                     $nb = $i;
                 }
                 $cities[] = "PARIS " . $nb;
             }
         } else {
             if ($postal == '69000') {
                 for ($i = 1; $i < 10; $i++) {
                     $cities[] = "LYON " . $i;
                 }
             } else {
                 if ($postal == '13000') {
                     for ($i = 1; $i <= 16; $i++) {
                         if ($i < 10) {
                             $nb = '0' . $i;
                         } else {
                             $nb = $i;
                         }
                         $cities[] = "MARSEILLE " . $nb;
                     }
                 } else {
                     try {
                         $tntWebService = new TntWebService();
                         $city = $tntWebService->getCity($postal);
                     } catch (SoapFault $e) {
                         $erreur = $e->faultstring;
                     } catch (Exception $e) {
                         $erreur = "Problem : follow failed";
                     }
                     if (!isset($erreur) && isset($city->City)) {
                         if (is_array($city->City)) {
                             foreach ($city->City as $v) {
                                 $cities[] = $v->name;
                             }
                         } else {
                             $cities[] = $city->City->name;
                         }
                     }
                 }
             }
         }
         $link = new Link();
         $redirect = $link->getPageLink('order.php?step=2');
         $smarty->assign('redirect', $redirect);
         if (!sizeof($cities)) {
             $smarty->assign('cityError', $this->l('your shipping address zipcode is not correct.'));
         }
         $smarty->assign('cities', $cities);
     }
     $services = Db::getInstance()->ExecuteS('SELECT `id_carrier`, `option` FROM `' . _DB_PREFIX_ . 'tnt_carrier_option`');
     $dueDate = serviceCache::getDueDate($id_cart, $services);
     $smarty->assign('id_cart', $id_cart);
     $smarty->assign('tnt_token', Configuration::get('TNT_CARRIER_TOKEN'));
     $smarty->assign('version', _PS_VERSION_);
     $smarty->assign('services', $services);
     $smarty->assign('dueDate', $dueDate);
     if (_PS_VERSION_ >= 1.5) {
         $this->context->controller->addJS('http://maps.google.com/maps/api/js?sensor=true');
         $this->context->controller->addJS($this->_path . 'js/relais.js');
         $this->context->controller->addJS($this->_path . 'js/jquery-ui-1.8.10.custom.min.js');
     }
     return $this->display(__FILE__, 'tpl/relaisColis.tpl');
 }