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: findPetitionnaire.php 5710 2016-01-05 17:41:54Z jymadier $ |
7 |
|
|
*/ |
8 |
|
|
|
9 |
|
|
require_once "../obj/utils.class.php"; |
10 |
|
|
$f = new utils("nohtml"); |
11 |
|
|
$f->isAccredited(array("demande","demande_modifier","demande_ajouter"), "OR"); |
12 |
|
|
//Récupération des valeurs envoyées |
13 |
|
|
$f->set_submitted_value(); |
14 |
|
|
$f->disableLog(); |
15 |
|
|
|
16 |
|
|
// Donnees |
17 |
|
|
$par_nom = ($f->get_submitted_post_value("particulier_nom") != null) ? $f->get_submitted_post_value("particulier_nom") : ""; |
18 |
fmichon |
3892 |
$par_nom = str_replace('*', '', $par_nom); |
19 |
|
|
|
20 |
mbroquet |
3730 |
$par_prenom = ($f->get_submitted_post_value("particulier_prenom'") != null) ? $f->get_submitted_post_value("particulier_prenom'") : ""; |
21 |
fmichon |
3892 |
$par_prenom = str_replace('*', '', $par_prenom); |
22 |
|
|
|
23 |
mbroquet |
3730 |
$mor_denomination = ($f->get_submitted_post_value("personne_morale_denomination") != null) ? $f->get_submitted_post_value("personne_morale_denomination") : ""; |
24 |
fmichon |
3892 |
$mor_denomination = str_replace('*', '', $mor_denomination); |
25 |
|
|
|
26 |
mbroquet |
3730 |
$mor_nom = ($f->get_submitted_post_value("mor_nom") != null) ? $f->get_submitted_post_value("mor_nom") : ""; |
27 |
fmichon |
3892 |
$mor_nom = str_replace('*', '', $mor_nom); |
28 |
|
|
|
29 |
mbroquet |
3730 |
$om_collectivite = ($f->get_submitted_post_value("om_collectivite") != null) ? $f->get_submitted_post_value("om_collectivite") : $_SESSION['collectivite']; |
30 |
|
|
$listData = ""; |
31 |
|
|
|
32 |
|
|
$requete = "frequent is TRUE AND |
33 |
|
|
type_demandeur = 'petitionnaire' AND"; |
34 |
|
|
if($par_nom != "") { |
35 |
|
|
$requete .= " upper(particulier_nom) LIKE upper('%$par_nom%')"; |
36 |
|
|
$requete .= " AND"; |
37 |
|
|
} |
38 |
|
|
if($par_prenom != "") { |
39 |
|
|
$requete .= " upper(particulier_prenom) LIKE upper('%$par_prenom%')"; |
40 |
|
|
$requete .= " AND"; |
41 |
|
|
} |
42 |
|
|
|
43 |
|
|
if($mor_denomination != "") { |
44 |
|
|
$requete .= " upper(personne_morale_denomination) LIKE upper('%$mor_denomination%')"; |
45 |
|
|
$requete .= " AND"; |
46 |
|
|
} |
47 |
|
|
|
48 |
|
|
if($mor_nom != "") { |
49 |
|
|
$requete .= " upper(personne_morale_nom) LIKE upper('%$mor_nom%')"; |
50 |
|
|
$requete .= " AND"; |
51 |
|
|
} |
52 |
|
|
|
53 |
|
|
// Ajoute une condition sur la collectivité de l'utilisateur, ou celle de niveau 2 |
54 |
|
|
$requete .= " (om_collectivite = ".$om_collectivite; |
55 |
|
|
$requete .= " OR om_collectivite = ( |
56 |
|
|
SELECT om_collectivite from ".DB_PREFIXE."om_collectivite |
57 |
|
|
WHERE niveau='2' |
58 |
|
|
))"; |
59 |
|
|
$requete .= " AND"; |
60 |
|
|
|
61 |
|
|
$requete = substr($requete, 0, (strlen($requete)-4)); |
62 |
|
|
|
63 |
|
|
$sql = |
64 |
|
|
"SELECT |
65 |
|
|
demandeur as value,". |
66 |
|
|
"trim(concat(particulier_nom,' ', particulier_prenom, ' ', ". |
67 |
|
|
"personne_morale_raison_sociale, ' ', personne_morale_denomination,". |
68 |
|
|
"' ', personne_morale_nom, ' ', personne_morale_siret, ' ', ". |
69 |
|
|
"personne_morale_nom, ' ', personne_morale_prenom, ' ',". |
70 |
|
|
" code_postal, ' ', localite)) as content ". |
71 |
|
|
"FROM ".DB_PREFIXE."demandeur WHERE ".$requete; |
72 |
|
|
|
73 |
|
|
$res = $f->db->query($sql); |
74 |
|
|
$f->isDatabaseError($res); |
75 |
|
|
$listData=array(); |
76 |
|
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
77 |
|
|
$listData[] = $row; |
78 |
|
|
} |
79 |
|
|
|
80 |
|
|
echo json_encode($listData); |
81 |
|
|
|
82 |
|
|
?> |