1 |
mbroquet |
3730 |
<?php |
2 |
|
|
/** |
3 |
|
|
* Ce script a pour objet de recuperer la liste des pétionnaires correspondant aux critères de recherche |
4 |
|
|
* |
5 |
|
|
* @package openfoncier |
6 |
|
|
* @version SVN : $Id: findArchitecte.php 4418 2015-02-24 17:30:28Z tbenita $ |
7 |
|
|
*/ |
8 |
|
|
|
9 |
|
|
require_once "../obj/utils.class.php"; |
10 |
|
|
$f = new utils("nohtml"); |
11 |
|
|
$f->isAccredited(array("donnees_techniques","donnees_techniques_modifier","donnees_techniques_ajouter"), "OR"); |
12 |
|
|
//Récupération des valeurs envoyées |
13 |
|
|
$f->set_submitted_value(); |
14 |
|
|
// Donnees |
15 |
|
|
$nom = ($f->get_submitted_post_value("nom") != null) ? $f->get_submitted_post_value("nom") : ""; |
16 |
fmichon |
3892 |
$nom = str_replace('*', '', $nom); |
17 |
|
|
|
18 |
mbroquet |
3730 |
$prenom = ($f->get_submitted_post_value("prenom") != null) ? $f->get_submitted_post_value("prenom") : ""; |
19 |
fmichon |
3892 |
$prenom = str_replace('*', '', $prenom); |
20 |
|
|
|
21 |
mbroquet |
3730 |
$listData = ""; |
22 |
|
|
|
23 |
|
|
$f->disableLog(); |
24 |
|
|
|
25 |
|
|
$requete = "frequent is TRUE AND"; |
26 |
|
|
if($nom != "") { |
27 |
|
|
$requete .= " upper(nom) LIKE upper('%$nom%')"; |
28 |
|
|
$requete .= " AND"; |
29 |
|
|
} |
30 |
|
|
if($prenom != "") { |
31 |
|
|
$requete .= " upper(prenom) LIKE upper('%$prenom%')"; |
32 |
|
|
$requete .= " AND"; |
33 |
|
|
} |
34 |
|
|
|
35 |
|
|
$requete = substr($requete, 0, (strlen($requete)-4)); |
36 |
|
|
|
37 |
|
|
$sql = |
38 |
|
|
"SELECT |
39 |
|
|
architecte as value,". |
40 |
|
|
"trim(concat(nom,' ', prenom, ' ', ". |
41 |
|
|
" cp, ' ', ville)) as content ". |
42 |
|
|
"FROM ".DB_PREFIXE."architecte WHERE ".$requete; |
43 |
|
|
|
44 |
|
|
$res = $f->db->query($sql); |
45 |
|
|
$f->isDatabaseError($res); |
46 |
|
|
$listData=array(); |
47 |
|
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
48 |
|
|
$listData[] = $row; |
49 |
|
|
} |
50 |
|
|
|
51 |
|
|
echo json_encode($listData); |
52 |
|
|
|
53 |
|
|
?> |