extranet/www/pages_saisie/searchMandataires.php

70 lines
2.0 KiB
PHP
Raw Normal View History

<?php
2009-06-03 07:49:38 +00:00
header('Content-Type: text/html; charset=ISO-8859-1');
$q = (!$_GET["q"])? "" : strtolower($_GET["q"]);
if (!$q) return;
$firephp->log($q, 'q');
$separator = "|";
/** 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'
));
//raisonSociale adresse codePostal Ville Siege actif deb nbRep maxRep Pertinence AvecSIREN naf
try {
2009-03-30 16:27:40 +00:00
$O = $client->searchMandataires($q, array('V', 'N', 'H', 'A', 'M')); //array pour trier les types de mandataires
$tableResults = array();
$tableResults = $O['result'];
2009-07-21 15:08:08 +00:00
$firephp->log($tableResults, 'Result');
$firephp->log(count($tableResults), 'count');
2009-07-21 15:08:08 +00:00
$return = "A l'adresse du bien vendu";
$return.= $separator;
$return.= "adresse";
$return.= "\n";
print $return;
2009-07-21 15:08:08 +00:00
/*
REGEX Code Postal : ^(F-)?((2[A|B])|[0-9]{2})[0-9]{3}$
2009-07-21 15:08:08 +00:00
(?<!/BP /i) Ne pas avoir la pr<EFBFBD>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'] = $lib;
preg_match('/(?<!bp )((2[A|B])|[0-9]{2})[0-9]{3}( )/i', $lib, $matches);
$tabResults[$i]['cp'] = $matches[0];
$i++;
}
2009-07-21 15:08:08 +00:00
$firephp->log($tabResults,'tabResults');
foreach ($tabResults as $key => $row) {
$code[$key] = $row['code'];
$lib[$key] = $row['lib'];
2009-07-21 15:08:08 +00:00
$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
//Affichage des valeurs
foreach ($tabResults as $item){
2009-07-21 15:08:08 +00:00
$return = htmlspecialchars_decode($item['lib'],ENT_QUOTES);
$return.= $separator;
$return.= $item['code'];
$return.= "\n";
//Send String|Id for the autocompleter
print $return;
}
}
}catch (SoapFault $fault){
2009-07-21 15:08:08 +00:00
print 'Erreur durant la recherche';
}
?>