1 |
<?php |
2 |
/** |
3 |
* Ce script a pour objet de recuperer la liste des quartiers d'un arrondissement |
4 |
* |
5 |
* @package openfoncier |
6 |
* @version SVN : $Id$ |
7 |
*/ |
8 |
|
9 |
require_once "../obj/utils.class.php"; |
10 |
|
11 |
// Identifiant de l'arrondissement |
12 |
(isset($_GET['idx']) ? $idx = $_GET['idx'] : $idx = ""); |
13 |
(isset($_GET['tableName']) ? $tableName = $_GET['tableName'] : $tableName = ""); |
14 |
(isset($_GET['linkedField']) ? $linkedField = $_GET['linkedField'] : $linkedField = ""); |
15 |
(isset($_GET['nature']) ? $nature = $_GET['nature'] : $nature = ""); |
16 |
$f = new utils("nohtml"); |
17 |
$f->isAccredited(array("demande","demande_modifier","demande_ajouter"), "OR"); |
18 |
$f->disableLog(); |
19 |
|
20 |
$sql = |
21 |
"SELECT |
22 |
$tableName, libelle |
23 |
FROM |
24 |
".DB_PREFIXE."$tableName"; |
25 |
|
26 |
if ( isset($idx) && $idx !== '' && $idx !== '*' && is_numeric($idx)){ |
27 |
|
28 |
/*Requête qui récupère les quartiers en fonction de leur arrondissement*/ |
29 |
$sql .= |
30 |
" WHERE |
31 |
$linkedField = $idx "; |
32 |
if($nature != "") { |
33 |
$sql .= "AND demande_nature = 2 "; |
34 |
} else { |
35 |
$sql .= "AND demande_nature = 1 "; |
36 |
} |
37 |
$sql .= "ORDER BY |
38 |
libelle |
39 |
"; |
40 |
} |
41 |
|
42 |
$res = $f->db->query($sql); |
43 |
$f->isDatabaseError($res); |
44 |
|
45 |
$listData = ""; |
46 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
47 |
|
48 |
$listData .= $row[$tableName]."_".$row['libelle'].";"; |
49 |
} |
50 |
|
51 |
echo json_encode($listData); |
52 |
|
53 |
?> |