extranet/includes/saisie/searchMandataires.php

64 lines
1.6 KiB
PHP
Raw Normal View History

<?php
2010-01-22 08:58:39 +00:00
header('Content-Type: text/html; charset='.CHARSET);
2010-06-18 14:52:53 +00:00
$search = !isset($_GET['search']) ? '' : strtolower($_GET['search']);
if (!$search) return;
2010-03-16 16:06:50 +00:00
2010-06-18 14:52:53 +00:00
list($searchStr, $filtre) = explode(',', $search);
$searchStr = trim($searchStr);
2010-03-16 16:06:50 +00:00
$filtre = str_replace(' ', '', $filtre);
if( strlen($filtre) != 5 && strlen($filtre) != 2 ){
$filtre = '';
2010-03-16 16:06:50 +00:00
}
try {
2010-06-18 14:52:53 +00:00
$O = $client->searchMandataires(
$searchStr,
array('V', 'N', 'H', 'A', 'M'), //types de mandataires
$filtre);
$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-05-28 08:44:46 +00:00
$output = array();
$output[] = array(
'label' => "A l'adresse du bien vendu",
'id' => 'adresse'
);
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-05-28 08:44:46 +00:00
$output[] = array(
'label' => $item['lib'],
'id' => $item['code']
);
}
}
2010-05-28 08:44:46 +00:00
echo json_encode($output);