* @copyright 2007-2015 PrestaShop SA / 2011-2015 EnvoiMoinsCher * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registred Trademark & Property of PrestaShop SA */ require_once(realpath(dirname(__FILE__) . '/../../../config/defines.inc.php')); require_once(_PS_MODULE_DIR_ . '/../config/config.inc.php'); require_once(_PS_MODULE_DIR_ . '/../init.php'); require_once(_PS_MODULE_DIR_ . '/envoimoinscher/envoimoinscher.php'); $emc = new Envoimoinscher(); $cp = isset($_REQUEST['cp']) && !empty($_REQUEST['cp']) ? $_REQUEST['cp'] : EnvoimoinscherModel::getConfig('EMC_POSTALCODE') ; $ville = isset($_REQUEST['ville']) && !empty($_REQUEST['ville'])? $_REQUEST['ville'] : EnvoimoinscherModel::getConfig('EMC_CITY') ; $country = isset($_REQUEST['country']) ? $_REQUEST['country'] : 'FR' ; $locale = isset($_REQUEST['locale']) ? $_REQUEST['locale'] : 'fr-FR' ; $langId = isset($_REQUEST['lang_id']) ? $_REQUEST['lang_id'] : '1' ; $srv = isset($_REQUEST['srv']) ? $_REQUEST['srv'] : '' ; $ope = isset($_REQUEST['ope']) ? $_REQUEST['ope'] : '' ; $inputCallBack = isset($_REQUEST['inputCallBack']) ? $_REQUEST['inputCallBack'] : '' ; $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'html' ; if (Tools::strtolower(filter_input(INPUT_SERVER, 'HTTP_X_REQUESTED_WITH')) === 'xmlhttprequest' && $type == "json") {// I'm AJAX! header("content-type:application/json"); // on recupere les services depuis le serveur envoimoinscher require_once(_PS_MODULE_DIR_ . '/envoimoinscher/Env/WebService.php'); require_once(_PS_MODULE_DIR_ . '/envoimoinscher/Env/ListPoints.php'); $login = EnvoimoinscherModel::getConfig('EMC_LOGIN'); $pass = EnvoimoinscherModel::getConfig('EMC_PASS'); $env = EnvoimoinscherModel::getConfig('EMC_ENV'); $key = EnvoimoinscherModel::getConfig('EMC_KEY_' . $env); $listPoints = new EnvListPoints(array('user' => $login, 'pass' => $pass, 'key' => $key)); $listPoints->setEnv(Tools::strtolower($env)); $listPoints->setLocale($locale); $listPoints->getListPoints( $ope, array('srv_code' =>$srv, 'ville' => $ville, 'cp' => $cp, 'pays' => $country, 'collecte' => 'dest') ); $points = $listPoints->list_points; die(Tools::jsonEncode($points)); } else { $lang = Tools::substr($locale, 0, 2); // anglais si traduction pas présente if (!in_array($lang, array('fr', 'en', 'es'))) { $lang = 'en'; } $aRelayName = array( 'CHRP' => array( 'fr' => 'Chrono Relais', 'en' => 'Chrono Relais', 'es' => 'Chrono Relais' ), 'MONR' => array( 'fr' => 'Point Relais', 'en' => 'Point Relais', 'es' => 'Punto Pack' ), 'IMXE' => array( 'fr' => 'Point Relais', 'en' => 'Point Relais', 'es' => 'Punto Pack' ), 'SOGP' => array( 'fr' => 'Relais Colis', 'en' => 'Relais Colis', 'es' => 'Relais Colis' ), 'UPSE' => array( 'fr' => 'relais Access Point', 'en' => 'Access Point', 'es' => 'Access Point' ), 'default' => array( 'fr' => 'Point Relais', 'en' => 'Relay Point', 'es' => 'Punto de recogida' ), ); $relayName = isset($aRelayName[Tools::strtoupper($ope)])? $aRelayName[$ope][$lang] : $aRelayName['default'][$lang]; // Script URL $host = __PS_BASE_URI__; $baseUrl = "/modules/envoimoinscher/ajax/choix-relais.php?"; // specifique a prestashop $requestUri = str_replace(__PS_BASE_URI__, "", $_SERVER['REQUEST_URI']); $pos = strpos($requestUri, 'choixRelais&'); if ($pos) { $host = Tools::getShopProtocol() . Tools::getHttpHost().__PS_BASE_URI__ ; $baseUrl = $host. Tools::substr($requestUri, 0, $pos) . "choixRelais&"; } // traductions $translations = array( 'choice' => array( 'fr' => 'Choix', 'en' => 'Choice', 'es' => 'Elección' ), 'monday' => array( 'fr' => 'lundi', 'en' => 'monday', 'es' => 'lunes' ), 'tuesday' => array( 'fr' => 'mardi', 'en' => 'tuesday', 'es' => 'martes' ), 'wednesday' => array( 'fr' => 'mercredi', 'en' => 'wednesday', 'es' => 'miércoles' ), 'thursday' => array( 'fr' => 'jeudi', 'en' => 'thursday', 'es' => 'jueves' ), 'friday' => array( 'fr' => 'vendredi', 'en' => 'friday', 'es' => 'viernes' ), 'saturday' => array( 'fr' => 'samedi', 'en' => 'saturday', 'es' => 'sábado' ), 'sunday' => array( 'fr' => 'dimanche', 'en' => 'sunday', 'es' => 'domingo' ), 'postal_code' => array( 'fr' => 'Code Postal', 'en' => 'Postal Code', 'es' => 'Código Postal' ), 'city' => array( 'fr' => 'Ville', 'en' => 'City', 'es' => 'Ciudad' ), 'search' => array( 'fr' => 'RECHERCHER', 'en' => 'SEARCH', 'es' => 'BUSCAR' ), 'opening' => array( 'fr' => "Horaires d'ouverture", 'en' => 'Opening hours', 'es' => 'Horario de apertura' ), 'selecting' => array( 'fr' => "JE SÉLECTIONNE", 'en' => 'SELECT THIS POINT', 'es' => 'SELECCIONAR ESTE PUNTO' ), 'choose' => array( 'fr' => "Choisir ce ".$relayName, 'en' => 'Choose this '.$relayName, 'es' => 'Elegir este '.$relayName ), 'code' => array( 'fr' => "Code du ".$relayName." :", 'en' => $relayName.' code:', 'es' => 'Código de '.$relayName.':' ), ); ?> <?php echo $translations['choice'][$lang].' '.$relayName; ?>