1 |
vpihour |
2113 |
<?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: findPetitionnaire.php 1515 2013-03-19 18:53:12Z fmichon $ |
7 |
|
|
*/ |
8 |
|
|
|
9 |
|
|
require_once "../obj/utils.class.php"; |
10 |
|
|
|
11 |
|
|
// Donnees |
12 |
|
|
$nom = (isset($_POST['nom']) ? $_POST['nom'] : "" ); |
13 |
|
|
$prenom = (isset($_POST['prenom']) ? $_POST['prenom'] : "" ); |
14 |
|
|
$listData = ""; |
15 |
|
|
|
16 |
|
|
$f = new utils("nohtml"); |
17 |
|
|
$f->isAccredited(array("donnees_techniques","donnees_techniques_modifier","donnees_techniques_ajouter"), "OR"); |
18 |
|
|
|
19 |
|
|
$f->disableLog(); |
20 |
|
|
|
21 |
|
|
$requete = "frequent is TRUE AND"; |
22 |
|
|
if($nom != "") { |
23 |
|
|
$requete .= " upper(nom) LIKE upper('%$nom%')"; |
24 |
|
|
$requete .= " AND"; |
25 |
|
|
} |
26 |
|
|
if($prenom != "") { |
27 |
|
|
$requete .= " upper(prenom) LIKE upper('%$prenom%')"; |
28 |
|
|
$requete .= " AND"; |
29 |
|
|
} |
30 |
|
|
|
31 |
|
|
$requete = substr($requete, 0, (strlen($requete)-4)); |
32 |
|
|
|
33 |
|
|
$sql = |
34 |
|
|
"SELECT |
35 |
|
|
architecte as value,". |
36 |
|
|
"trim(concat(nom,' ', prenom, ' ', ". |
37 |
|
|
" cp, ' ', ville)) as content ". |
38 |
|
|
"FROM ".DB_PREFIXE."architecte WHERE ".$requete; |
39 |
|
|
|
40 |
|
|
$res = $f->db->query($sql); |
41 |
|
|
$f->isDatabaseError($res); |
42 |
|
|
$listData=array(); |
43 |
|
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
44 |
|
|
$listData[] = $row; |
45 |
|
|
} |
46 |
|
|
|
47 |
|
|
echo json_encode($listData); |
48 |
|
|
|
49 |
|
|
?> |