2009-03-26 19:22:07 +00:00
|
|
|
<?php
|
2010-01-22 08:58:39 +00:00
|
|
|
header('Content-Type: text/html; charset='.CHARSET);
|
2009-03-26 19:22:07 +00:00
|
|
|
$q = (!$_GET["q"])? "" : strtolower($_GET["q"]);
|
|
|
|
if (!$q) return;
|
2010-03-16 16:06:50 +00:00
|
|
|
|
|
|
|
list($q, $filtre) = explode(',', $q);
|
|
|
|
$q = trim($q);
|
|
|
|
$filtre = str_replace(' ', '', $filtre);
|
2010-03-16 16:55:23 +00:00
|
|
|
if( strlen($filtre) != 5 && strlen($filtre) != 2 ){
|
|
|
|
$filtre = '';
|
2010-03-16 16:06:50 +00:00
|
|
|
}
|
2009-03-26 19:22:07 +00:00
|
|
|
$separator = "|";
|
2010-03-16 16:06:50 +00:00
|
|
|
// Utilisation du WS
|
|
|
|
$client = new SoapClient(null, array(
|
|
|
|
'trace' => 1,
|
|
|
|
'soap_version' => SOAP_1_1,
|
|
|
|
'location' => WEBSERVICE_URL,
|
|
|
|
'uri' => WEBSERVICE_URI,
|
|
|
|
'login' => $_SESSION['tabInfo']['login'],
|
|
|
|
'password' => $_SESSION['tabInfo']['password'],
|
|
|
|
// 'encoding' => 'UTF-8'
|
2009-03-26 19:22:07 +00:00
|
|
|
));
|
|
|
|
|
|
|
|
//raisonSociale adresse codePostal Ville Siege actif deb nbRep maxRep Pertinence AvecSIREN naf
|
|
|
|
try {
|
2010-03-16 16:06:50 +00:00
|
|
|
$O = $client->searchMandataires($q,
|
2010-03-16 16:55:23 +00:00
|
|
|
array('V', 'N', 'H', 'A', 'M'), $filtre); //types de mandataires
|
2009-03-26 19:22:07 +00:00
|
|
|
$tableResults = array();
|
|
|
|
$tableResults = $O['result'];
|
2010-03-16 16:06:50 +00:00
|
|
|
}catch (SoapFault $fault){
|
|
|
|
echo 'Erreur durant la recherche';
|
|
|
|
exit;
|
|
|
|
}
|
2009-07-21 15:08:08 +00:00
|
|
|
|
2010-03-16 16:06:50 +00:00
|
|
|
$return = "A l'adresse du bien vendu";
|
|
|
|
$return.= $separator;
|
|
|
|
$return.= "adresse";
|
|
|
|
$return.= "\n";
|
2009-07-21 15:08:08 +00:00
|
|
|
|
2010-03-16 16:06:50 +00:00
|
|
|
/*
|
|
|
|
REGEX Code Postal : ^(F-)?((2[A|B])|[0-9]{2})[0-9]{3}$
|
|
|
|
(?<!/BP /i) Ne pas avoir la présence de BP devant les 5 chiffres
|
|
|
|
*/
|
|
|
|
//Recherche des codes postaux
|
|
|
|
if( count($tableResults)>0 ){
|
|
|
|
$i=0;
|
|
|
|
foreach ($tableResults as $code=>$lib){
|
|
|
|
$tabResults[$i]['code'] = $code;
|
|
|
|
$tabResults[$i]['lib'] = htmlspecialchars_decode(
|
|
|
|
html_entity_decode($lib), ENT_QUOTES);
|
|
|
|
preg_match('/(?<!bp )((2[A|B])|[0-9]{2})[0-9]{3}( )/i', $lib, $matches);
|
|
|
|
$tabResults[$i]['cp'] = $matches[0];
|
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
foreach ($tabResults as $key => $row){
|
|
|
|
$code[$key] = $row['code'];
|
|
|
|
$lib[$key] = $row['lib'];
|
|
|
|
$cp[$key] = $row['cp'];
|
|
|
|
}
|
|
|
|
//Classement du tableau
|
|
|
|
array_multisort($cp, SORT_NUMERIC, $tabResults);
|
|
|
|
$firephp->log($tabResults,'tabResults');
|
2009-07-21 15:08:08 +00:00
|
|
|
|
|
|
|
|
2010-03-16 16:06:50 +00:00
|
|
|
//Affichage des valeurs
|
|
|
|
foreach ($tabResults as $item){
|
2010-03-16 16:55:23 +00:00
|
|
|
$return.= $item['lib'];
|
|
|
|
$return.= $separator;
|
|
|
|
$return.= $item['code'];
|
|
|
|
$return.= "\n";
|
|
|
|
//Send String|Id for the autocompleter
|
2009-03-26 19:22:07 +00:00
|
|
|
}
|
|
|
|
}
|
2010-03-16 16:55:23 +00:00
|
|
|
echo $return;
|