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 |
softime |
7996 |
$par_nom = html_entity_decode($par_nom, ENT_QUOTES); |
20 |
nmeucci |
4512 |
$par_nom = $f->db->escapeSimple($par_nom); |
21 |
fmichon |
3892 |
|
22 |
softime |
7685 |
$par_prenom = ($f->get_submitted_post_value("particulier_prenom") != null) ? $f->get_submitted_post_value("particulier_prenom") : ""; |
23 |
fmichon |
3892 |
$par_prenom = str_replace('*', '', $par_prenom); |
24 |
softime |
7996 |
$par_prenom = html_entity_decode($par_prenom, ENT_QUOTES); |
25 |
nmeucci |
4512 |
$par_prenom = $f->db->escapeSimple($par_prenom); |
26 |
fmichon |
3892 |
|
27 |
softime |
7685 |
$mor_raison_sociale = ($f->get_submitted_post_value("personne_morale_raison_sociale") != null) ? $f->get_submitted_post_value("personne_morale_raison_sociale") : ""; |
28 |
|
|
$mor_raison_sociale = str_replace('*', '', $mor_raison_sociale); |
29 |
softime |
7996 |
$mor_raison_sociale = html_entity_decode($mor_raison_sociale, ENT_QUOTES); |
30 |
softime |
7685 |
$mor_raison_sociale = $f->db->escapeSimple($mor_raison_sociale); |
31 |
|
|
|
32 |
mbroquet |
3730 |
$mor_denomination = ($f->get_submitted_post_value("personne_morale_denomination") != null) ? $f->get_submitted_post_value("personne_morale_denomination") : ""; |
33 |
fmichon |
3892 |
$mor_denomination = str_replace('*', '', $mor_denomination); |
34 |
softime |
7996 |
$mor_denomination = html_entity_decode($mor_denomination, ENT_QUOTES); |
35 |
nmeucci |
4512 |
$mor_denomination = $f->db->escapeSimple($mor_denomination); |
36 |
fmichon |
3892 |
|
37 |
softime |
7685 |
$mor_siret = ($f->get_submitted_post_value("personne_morale_siret") != null) ? $f->get_submitted_post_value("personne_morale_siret") : ""; |
38 |
|
|
$mor_siret = str_replace('*', '', $mor_siret); |
39 |
softime |
7996 |
$mor_siret = html_entity_decode($mor_siret, ENT_QUOTES); |
40 |
softime |
7685 |
$mor_siret = $f->db->escapeSimple($mor_siret); |
41 |
|
|
|
42 |
|
|
$mor_cat_juridique = ($f->get_submitted_post_value("personne_morale_categorie_juridique") != null) ? $f->get_submitted_post_value("personne_morale_categorie_juridique") : ""; |
43 |
|
|
$mor_cat_juridique = str_replace('*', '', $mor_cat_juridique); |
44 |
softime |
7996 |
$mor_cat_juridique = html_entity_decode($mor_cat_juridique, ENT_QUOTES); |
45 |
softime |
7685 |
$mor_cat_juridique = $f->db->escapeSimple($mor_cat_juridique); |
46 |
|
|
|
47 |
|
|
$mor_nom = ($f->get_submitted_post_value("personne_morale_nom") != null) ? $f->get_submitted_post_value("personne_morale_nom") : ""; |
48 |
fmichon |
3892 |
$mor_nom = str_replace('*', '', $mor_nom); |
49 |
softime |
7996 |
$mor_nom = html_entity_decode($mor_nom, ENT_QUOTES); |
50 |
nmeucci |
4512 |
$mor_nom = $f->db->escapeSimple($mor_nom); |
51 |
fmichon |
3892 |
|
52 |
softime |
7685 |
$mor_prenom = ($f->get_submitted_post_value("personne_morale_prenom") != null) ? $f->get_submitted_post_value("personne_morale_prenom") : ""; |
53 |
|
|
$mor_prenom = str_replace('*', '', $mor_prenom); |
54 |
softime |
7996 |
$mor_prenom = html_entity_decode($mor_prenom, ENT_QUOTES); |
55 |
softime |
7685 |
$mor_prenom = $f->db->escapeSimple($mor_prenom); |
56 |
|
|
|
57 |
mbroquet |
3730 |
$om_collectivite = ($f->get_submitted_post_value("om_collectivite") != null) ? $f->get_submitted_post_value("om_collectivite") : $_SESSION['collectivite']; |
58 |
|
|
$listData = ""; |
59 |
|
|
|
60 |
softime |
15835 |
$qres = $f->get_all_results_from_db_query( |
61 |
|
|
sprintf( |
62 |
|
|
'SELECT |
63 |
|
|
demandeur AS value, |
64 |
|
|
TRIM(CONCAT_WS( |
65 |
|
|
\' \', |
66 |
|
|
particulier_nom, |
67 |
|
|
particulier_prenom, |
68 |
|
|
personne_morale_raison_sociale, |
69 |
|
|
personne_morale_denomination, |
70 |
|
|
personne_morale_categorie_juridique, |
71 |
|
|
personne_morale_siret, |
72 |
|
|
personne_morale_nom, |
73 |
|
|
personne_morale_prenom, |
74 |
|
|
code_postal, |
75 |
|
|
localite |
76 |
|
|
)) AS content |
77 |
|
|
FROM |
78 |
|
|
%sdemandeur |
79 |
|
|
WHERE |
80 |
|
|
frequent IS TRUE |
81 |
|
|
AND type_demandeur = \'petitionnaire\' |
82 |
|
|
%2$s |
83 |
|
|
%3$s |
84 |
|
|
%4$s |
85 |
|
|
%5$s |
86 |
|
|
%6$s |
87 |
|
|
%7$s |
88 |
|
|
%8$s |
89 |
|
|
%9$s |
90 |
|
|
AND (om_collectivite = %10$d |
91 |
|
|
OR om_collectivite = ( |
92 |
|
|
SELECT om_collectivite |
93 |
|
|
FROM %1$som_collectivite |
94 |
|
|
WHERE niveau = \'2\'))', |
95 |
|
|
DB_PREFIXE, |
96 |
|
|
$par_nom != "" ? "AND particulier_nom ILIKE '%$par_nom%'" : '', |
97 |
|
|
$par_prenom != "" ? "AND particulier_prenom ILIKE '%$par_prenom%'" : '', |
98 |
|
|
$mor_raison_sociale != "" ? "AND personne_morale_raison_sociale ILIKE '%$mor_raison_sociale%'" : '', |
99 |
|
|
$mor_denomination != "" ? "AND personne_morale_denomination ILIKE '%$mor_denomination%'" : '', |
100 |
|
|
$mor_siret != "" ? "AND personne_morale_siret ILIKE '%$mor_siret%'" : '', |
101 |
|
|
$mor_cat_juridique != "" ? "AND personne_morale_categorie_juridique ILIKE '%$mor_cat_juridique%'" : '', |
102 |
|
|
$mor_nom != "" ? "AND personne_morale_nom ILIKE '%$mor_nom%'" : '', |
103 |
|
|
$mor_prenom != "" ? "AND personne_morale_prenom ILIKE '%$mor_prenom%'" : '', |
104 |
|
|
$om_collectivite |
105 |
|
|
), |
106 |
|
|
array( |
107 |
|
|
'origin' => 'app/findPetitionnaire.php' |
108 |
|
|
) |
109 |
|
|
); |
110 |
mbroquet |
3730 |
|
111 |
softime |
15835 |
$listData = array(); |
112 |
|
|
foreach ($qres['result'] as $row) { |
113 |
mbroquet |
3730 |
$listData[] = $row; |
114 |
|
|
} |
115 |
|
|
|
116 |
|
|
echo json_encode($listData); |
117 |
|
|
|
118 |
|
|
?> |