alpha_full/pages/panier/mondialRelay/WSI4_PointRelais_Recherche copie.php
2026-04-06 22:58:51 +02:00

184 lines
7.4 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
$nomFicAppelant = basename(__FILE__);
// https://api.mondialrelay.com/Web_Services.asmx?op=WSI2_TracingColisDetaille
// Cet exemple de code effectue une recherche des Points Relais® en 24R dans un rayon de 20Km
// autour du code postal 75010 en France dont la nature dactivité peut être définie.
require_once ('nusoap-0.9.6/lib/nusoap.php');
// Paramètres de tests :
// • Enseigne : BDTEST13
// • Clé Privée : PrivateK
// Recupérer les identifiants
include ("psk.mondialRelay.php");
$client = new nusoap_client("http://api.mondialrelay.com/Web_Services.asmx?WSDL", true);
$client->soap_defencoding = 'utf-8';
// param SOAP
$params = array(
'Enseigne' => $MR_WebSiteId,
'Pays' => "FR",
'NumPointRelais' => "",
'Ville' => $_SESSION['villeLiv'],
'CP' => $_SESSION['codePostLiv'],
'Latitude' => "",
'Longitude' => "",
'Taille' => "",
'Poids' => "",
'Action' => "",
'DelaiEnvoi' => "0",
'RayonRecherche' => "20",
'TypeActivite' => "",
'NACE' => "",
'NombreResultats' => "20",
);
// On génère la clé de sécurité de l'appel
$code = implode("", $params);
$code .= $MR_WebSiteKey;
$params["Security"] = strtoupper(md5($code));
// l'appel SOAP
$result = $client->call(
'WSI4_PointRelais_Recherche',
$params,
'https://api.mondialrelay.com/',
'https://api.mondialrelay.com/WSI4_PointRelais_Recherche'
);
// On vérifie qu'il n'y a pas eu d'erreur
if ($client->fault) {
echo '<h2>Fault (Expect - The request contains an invalid SOAP body)</h2><pre>';
print_r($result);
echo '</pre>';
}
else {
$err = $client->getError();
if ($err) {echo '<h2>Error</h2><pre>' . $err . '</pre>'; }
}
// print_r($result);
$PRelais=$result;
$myVar="";
// flag traduction EDT
$myVar='<div class="msgPanier" style="background:lightblue; text-align:center; text-decoration:underline; grid-column:1 / span 2; display:block; max-width:100%; margin:auto; border-radius:12px; padding:15px; "> Liste des points relais à 20km </div>';
$a=0;
foreach($PRelais as $key => $value) {
// print_r($value);
foreach( (array)$value as $key2 => $value2) {
// print_r($value2);
foreach( (array)$value2 as $key3 => $value3) {
// var_dump($value3);
foreach( (array)$value3 as $key4 => $value4) {
// Champs parasite en debut qui a pour valeur $value4[0]=0. Les champs que l'on veut eux on vide.
// var_dump($value3[0]);
if (isset($value3[0]['Num'])) {
$a=$a+1;
if ($a==3)$a=1;
$myVar .= '<div id="zoneMR" style="grid-column:' .$a. '; padding:8px; display:flex; text-align:left; width:98%; height:98%; border:1px solid grey; border-radius:3px; margin:5px; " >';
foreach( (array)$value4 as $key5 => $value5) {
$trouve=false;
$myVar .= '<span style="padding:left:0; " >';
if ($key5=='Num') {$Num=$value5; }
if ($key5=='URL_Photo') {$URL_Photo=$key5; }
if ($key5=='Localisation1') {$Localisation1=$key5; }
if ($key5=='Latitude') {$Latitude=$key5; }
if ($key5=='Longitude') {$Longitude=$key5; }
if ($key5=='Distance') {$Distance=$key5; }
// if ($key5!==0 && $value5!=='' && $key5!=='Num' && $key5!=='Localisation1' && $key5!=='Longitude' && $key5!=='Latitude') {
if ($key5!==0 && $value5!=='') {
if (strpos( $key5, "LgAdr1")!==false) {
$myVar .= "<span class=\"libPanier\" style=\"padding:left:0; \">&bull; $value5 </span>\n<br />";
$trouve=true;
}
if ($value5=='FR') $value5='FRANCE';
// Pas besoin de libellés de champs
if (strpos( $key5, "LgAdr3")!==false || strpos( $key5, "LgAdr2")!==false || strpos( $key5, "LgAdr4")!==false|| strpos( $key5, "Pays")!==false) {
$myVar .= '<span class="champsPanier" style="padding:left:0; font-size:0.9em; " >';
$myVar .= "" .$value5. "\n<br />";
$myVar .= '</span>';
$trouve=true;
}
// CP pas de <br> : collé avec ville
if (strpos( $key5, "CP")!==false) {
$myVar .= '<span class="champsPanier" style="padding:left:0; font-size:0.9em; " >';
$myVar .= "" .$value5;
$myVar .= '</span>';
$trouve=true;
}
// Espace avant pour ville
if (strpos( $key5, "Ville")!==false) {
$myVar .= '<span class="champsPanier" style="padding:left:0; font-size:0.9em; " >';
$myVar .= " " .$value5. "\n<br />";
$myVar .= '</span>';
$trouve=true;
}
// Si horraire on affichera en 7
if (strpos( $key5, "Horaires")!==false) {
$myVar .= " ";
$trouve=true;
}
// affiche les autres champs
if ($trouve==false) {
// $myVar .= "$key5 : $value5 \n<br />";
}
// $aff=1;
}
$trouve=false;
$aff=0;
$myVar .= '</span>';
foreach( (array)$value5 as $key6 => $value6) {
if ($key6!==0 && $value6!==''&& $key6!=='string') {$myVar .= "$key6 : " .$value6. " ";}
$trouve=false;
foreach( (array)$value6 as $key7 => $value7) {
// if ($value7!=='' && $key5!=='Distance' && $key5!=='Num' && $key5!=='Localisation1' && $key5!=='Longitude' && $key5!=='Latitude' && $key5!=='Pays' && $key5!=='Ville' && $key5!=='CP' && $key5!=='LgAdr1' && $key5!=='LgAdr2' && $key5!=='LgAdr3') {
if ($value7!=='') {
$myVar .= '<span style="color:#353333; font-size :13px; " >';
if (strpos( $key5, "Horaires") !==false && $trouve==false && $value7!=0 ) {
// on enleve le mot Horraire_
$myVar .= "".substr($key5,-(strlen($key5)-9)). " : ".substr($value7,0,2). "H".substr($value7,-2);
// on a trouvé au moins 1 horraire
$trouve=true;
$aff=1;
}
else {
if ($value7!=0 && strpos( $key5, "Horaires") !==false ) {$myVar .= " - ".substr($value7,0,2). "H".substr($value7,-2);}
}
if (empty($value6) && strpos( $key5, "Horaires_Lundi") !==false ) {$myVar .= "" .$key5. " : Fermé "; }
$myVar .= '</span" >';
}
}
if ($aff==1) $myVar .= "\n<br />\n";
}
}
// Flag traduction edt
if ($Num !=0 && $key5!=='' && $value7!=='' && $value6!=='' && $value5!=='' ) {
if ($Num == $idPointRelais) {
$myVar .= ' <br /><input type="radio" onChange="majPointRelais(this.value); " name="mondialRelay" value="' .$Num. '" id="Num' .$Num. '" checked="true" ><b>&#160;Choisir ce point relais</b>';
} else {
$myVar .= ' <br /><input type="radio" onChange="majPointRelais(this.value); " name="mondialRelay" value="' .$Num. '" id="Num' .$Num. '"><b>&#160;Choisir ce point relais</b>';
}
}
$myVar .= "</div>";
}
}
}
}
}
echo '' .$myVar. '';
// echo '<div style="max-width:80%"><br><h2>Request</h2><span style="white-space: pre-wrap; word-wrap:break-word; word-break: break-all; >' . nl2br(htmlspecialchars($client->request, ENT_QUOTES)) . '</span>';
// echo '<br><h2>Request</h2><span style="white-space: pre-wrap; word-wrap:break-word; word-break: break-all; ">' . nl2br(htmlspecialchars($client->request, ENT_QUOTES)) . '</span>';
// echo '<br><h2>Response</h2><span style="white-space: pre-wrap; word-wrap:break-word; word-break: break-all; "><pre>' . nl2br(htmlspecialchars($client->response, ENT_QUOTES)) . '</pre></span>';
// echo '<br><h2>Debug</h2><span style="white-space: pre-wrap; word-wrap:break-word; word-break: break-all; "><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre></span></div>';
?>