1 |
gmalvolti |
12203 |
<?php |
2 |
|
|
//$Id$ |
3 |
|
|
//gen openMairie le 01/06/2022 12:32 |
4 |
|
|
|
5 |
|
|
require_once "../gen/obj/dossier_operateur.class.php"; |
6 |
|
|
|
7 |
|
|
class dossier_operateur extends dossier_operateur_gen { |
8 |
gmalvolti |
12208 |
|
9 |
gmalvolti |
12237 |
// Permet de stocker le tableau du om_parametre param_operateur. |
10 |
gmalvolti |
12208 |
private $param_operateur; |
11 |
|
|
|
12 |
gmalvolti |
12203 |
/** |
13 |
|
|
* Définition des actions disponibles sur la classe. |
14 |
|
|
* |
15 |
|
|
* @return void |
16 |
|
|
*/ |
17 |
|
|
function init_class_actions() { |
18 |
|
|
|
19 |
|
|
// On récupère les actions génériques définies dans la méthode |
20 |
|
|
// d'initialisation de la classe parente |
21 |
|
|
parent::init_class_actions(); |
22 |
|
|
|
23 |
|
|
// ACTION - 001 - modifier |
24 |
|
|
// Modification du libellé de l'action "modifier" |
25 |
|
|
$this->class_actions[1]["portlet"]["libelle"] = _("Modifier"); |
26 |
|
|
$this->class_actions[1]["condition"] = array("is_editable"); |
27 |
|
|
|
28 |
|
|
// ACTION - 002 - supprimer |
29 |
|
|
// Modification de la condition d'affichage de l'action "supprimer" |
30 |
gmalvolti |
12237 |
// Ne doit pas être affichée. |
31 |
gmalvolti |
12203 |
$this->class_actions[2]["condition"] = array("is_deletable"); |
32 |
|
|
|
33 |
gmalvolti |
12237 |
$this->class_actions[5] = array( |
34 |
|
|
"identifier" => "reinitialiser", |
35 |
|
|
"portlet" => array( |
36 |
|
|
"type" => "action-direct-with-confirmation", |
37 |
cgarcin |
12326 |
"libelle" => __("Réinitialiser"), |
38 |
gmalvolti |
12237 |
"class" => "reinitialiser-16" |
39 |
|
|
), |
40 |
|
|
"method" => "reinitialiser", |
41 |
|
|
"permission_suffix" => "reinitialiser", |
42 |
|
|
"view" => "formulaire", |
43 |
gmalvolti |
12313 |
"condition" => array('is_reinitialisable', 'is_param_operateur_etat_setted'), |
44 |
gmalvolti |
12237 |
); |
45 |
|
|
|
46 |
|
|
$this->class_actions[6] = array( |
47 |
|
|
"identifier" => "valider", |
48 |
|
|
"portlet" => array( |
49 |
|
|
"type" => "action-direct-with-confirmation", |
50 |
cgarcin |
12326 |
"libelle" => __("Valider l'opérateur"), |
51 |
gmalvolti |
12237 |
"class" => "valider-16" |
52 |
|
|
), |
53 |
|
|
"method" => "valider", |
54 |
|
|
"permission_suffix" => "valider", |
55 |
|
|
"view" => "formulaire", |
56 |
|
|
"condition" => array('is_validable'), |
57 |
|
|
); |
58 |
|
|
|
59 |
gmalvolti |
12203 |
// ACTION - 10 - Recherche operateur |
60 |
|
|
// Ce bouton est affiché seulement si le DA lié a déjà une clé d'accès |
61 |
|
|
$this->class_actions[10] = array( |
62 |
|
|
"identifier" => "recherche_operateur", |
63 |
|
|
"portlet" => array( |
64 |
|
|
"type" => "action-direct", |
65 |
cgarcin |
12326 |
"libelle" => __("Rechercher l'opérateur"), |
66 |
gmalvolti |
12203 |
"class" => "recherche_operateur-16" |
67 |
|
|
), |
68 |
|
|
"method" => "recherche_operateur", |
69 |
|
|
"permission_suffix" => "recherche_operateur", |
70 |
|
|
"view" => "formulaire", |
71 |
gmalvolti |
12300 |
"condition" => array('is_recherche_operateur_available', 'is_param_operateur_etat_setted' ), |
72 |
gmalvolti |
12203 |
); |
73 |
|
|
} |
74 |
|
|
|
75 |
gmalvolti |
12237 |
/** |
76 |
|
|
* |
77 |
|
|
* @return array |
78 |
|
|
*/ |
79 |
|
|
function get_var_sql_forminc__champs() { |
80 |
gmalvolti |
12248 |
$champs = array( |
81 |
gmalvolti |
12237 |
"dossier_operateur", |
82 |
|
|
"operateur_designation_initialisee", |
83 |
|
|
"operateur_detecte_inrap", |
84 |
|
|
"operateur_detecte_collterr", |
85 |
|
|
"operateur_collterr_type_agrement", |
86 |
gmalvolti |
12248 |
"'' as operateur_message_kpark", |
87 |
gmalvolti |
12237 |
"operateur_amenagement_pers_publique", |
88 |
|
|
"operateur_pers_publique_amenageur", |
89 |
|
|
"operateur_collterr_kpark_avis", |
90 |
gmalvolti |
12248 |
"'' as message_consultation_amenageur", |
91 |
gmalvolti |
12237 |
"operateur_personne_publique", |
92 |
gmalvolti |
12248 |
"'' as message_consultation_tiers", |
93 |
gmalvolti |
12237 |
"operateur_personne_publique_avis", |
94 |
|
|
"operateur_kpark_type_operateur", |
95 |
|
|
"operateur_kpark_evenement", |
96 |
gmalvolti |
12381 |
"operateur_selectionne", |
97 |
gmalvolti |
12237 |
"operateur_designe", |
98 |
|
|
"operateur_kpark_libelle", |
99 |
|
|
"operateur_valide", |
100 |
|
|
"operateur_designe_historique", |
101 |
|
|
"dossier_instruction", |
102 |
|
|
"'' as tab_avis", |
103 |
|
|
"'' as tab_avis_maj", |
104 |
|
|
); |
105 |
gmalvolti |
12300 |
|
106 |
cgarcin |
12326 |
// Récupération du paramétrage stocké dans operateur_detecte_collterr à l'aide |
107 |
|
|
// de l'identifiant du dossier_operateur. |
108 |
|
|
// Ensuite, ce tableau est utilisé pour définir combien d'opérateur ont des |
109 |
|
|
// avis et combien de champs tab_avis doivent être affiché. |
110 |
gmalvolti |
12300 |
if (! empty($this->f->get_submitted_get_value('idx')) |
111 |
|
|
&& $this->f->get_submitted_get_value('obj') == 'dossier_operateur') { |
112 |
gmalvolti |
12254 |
$sql = sprintf( |
113 |
|
|
'SELECT |
114 |
|
|
operateur_detecte_collterr |
115 |
|
|
FROM |
116 |
|
|
%1$sdossier_operateur |
117 |
|
|
WHERE |
118 |
|
|
dossier_operateur = %2$s', |
119 |
|
|
DB_PREFIXE, |
120 |
|
|
$this->f->get_submitted_get_value('idx') |
121 |
|
|
); |
122 |
gmalvolti |
12248 |
|
123 |
gmalvolti |
12254 |
$result = $this->f->get_one_result_from_db_query($sql); |
124 |
|
|
$tab_collterr = json_decode($result['result']); |
125 |
|
|
if (! empty($tab_collterr)) { |
126 |
cgarcin |
12326 |
for ($i=0; $i < count($tab_collterr); $i++) { |
127 |
gmalvolti |
12254 |
$champs[] = "'' as tab_avis_".$i; |
128 |
|
|
} |
129 |
gmalvolti |
12248 |
} |
130 |
|
|
} |
131 |
|
|
return $champs; |
132 |
gmalvolti |
12237 |
} |
133 |
|
|
|
134 |
gmalvolti |
12278 |
/** |
135 |
|
|
* Surcharge permettant de ne pas afficher le fil d'Ariane dans |
136 |
|
|
* l'overlay de notification des demandeurs. |
137 |
cgarcin |
12326 |
* |
138 |
|
|
* @param todo non utilisé |
139 |
gmalvolti |
12278 |
*/ |
140 |
|
|
function getSubFormTitle($ent) { |
141 |
|
|
return __("Désignation de l'opérateur"); |
142 |
|
|
} |
143 |
gmalvolti |
12237 |
|
144 |
gmalvolti |
12300 |
/** |
145 |
cgarcin |
12326 |
* Permet de savoir si l'état du dossier correspond a un des états paramétré |
146 |
|
|
* dans le paramètre param_operateur. |
147 |
|
|
* |
148 |
gmalvolti |
12300 |
* @return bool true|false |
149 |
|
|
*/ |
150 |
|
|
function is_param_operateur_etat_setted() { |
151 |
cgarcin |
12326 |
// Récupère le paramètre et le dossier d'instruction (DI), vérifie si des états on été |
152 |
|
|
// paramétré dans param_operateur et si c'est le cas vérifie si l'état du DI |
153 |
|
|
// correspond |
154 |
gmalvolti |
12300 |
$param_operateur = $this->f->get_option_param_operateur(); |
155 |
|
|
$inst_dossier = $this->f->get_inst__om_dbform(array( |
156 |
|
|
"obj" => "dossier", |
157 |
|
|
"idx" => $this->getVal('dossier_instruction'), |
158 |
|
|
)); |
159 |
|
|
if (is_object($param_operateur) === true && property_exists($param_operateur, 'etat') === true) { |
160 |
|
|
if (in_array($inst_dossier->getVal('etat'), $param_operateur->etat) === true) { |
161 |
|
|
return true; |
162 |
|
|
} |
163 |
|
|
} |
164 |
|
|
return false; |
165 |
|
|
} |
166 |
gmalvolti |
12278 |
|
167 |
gmalvolti |
12300 |
|
168 |
gmalvolti |
12237 |
/** |
169 |
|
|
* Permet de retourner le paramètre param_operateur. |
170 |
cgarcin |
12326 |
* |
171 |
gmalvolti |
12237 |
* @return array |
172 |
|
|
*/ |
173 |
gmalvolti |
12208 |
function get_param_operateur() { |
174 |
cgarcin |
12326 |
// Fait appel à la méthode utils->get_option_param_operateur() et renvoie |
175 |
|
|
// le résultat si le paralétrage n'a pas déjà été récupéré. |
176 |
gmalvolti |
12208 |
if (is_null($this->param_operateur)) { |
177 |
|
|
$this->param_operateur = $this->f->get_option_param_operateur(); |
178 |
|
|
} |
179 |
|
|
return $this->param_operateur; |
180 |
|
|
} |
181 |
gmalvolti |
12203 |
|
182 |
gmalvolti |
12237 |
/** |
183 |
cgarcin |
12326 |
* Renvoie sous la forme d'une chaîne de caractère le sql |
184 |
|
|
* permettant de récupérer la liste des tiers consulté avec |
185 |
|
|
* leur id et leur libellé |
186 |
gmalvolti |
12237 |
* |
187 |
|
|
* @return string |
188 |
|
|
*/ |
189 |
|
|
function get_var_sql_forminc__sql_operateur_designe() { |
190 |
cgarcin |
12326 |
return "SELECT |
191 |
|
|
tiers_consulte.tiers_consulte, |
192 |
|
|
CONCAT_WS( |
193 |
|
|
' - ', |
194 |
|
|
tiers_consulte.abrege, |
195 |
|
|
tiers_consulte.libelle |
196 |
|
|
) as libelle |
197 |
|
|
FROM |
198 |
|
|
".DB_PREFIXE."tiers_consulte |
199 |
|
|
ORDER BY |
200 |
|
|
tiers_consulte.libelle ASC"; |
201 |
gmalvolti |
12237 |
} |
202 |
|
|
|
203 |
|
|
/** |
204 |
cgarcin |
12326 |
* Renvoie sous la forme d'une chaîne de caractère le sql |
205 |
|
|
* permettant de récupérer l'id et le libellé d'un tiers consulté |
206 |
|
|
* a l'aide de son id |
207 |
|
|
* |
208 |
gmalvolti |
12237 |
* @return string |
209 |
|
|
*/ |
210 |
|
|
function get_var_sql_forminc__sql_operateur_designe_by_id() { |
211 |
cgarcin |
12326 |
return "SELECT |
212 |
|
|
tiers_consulte.tiers_consulte, |
213 |
|
|
CONCAT_WS( |
214 |
|
|
' - ', |
215 |
|
|
tiers_consulte.abrege, |
216 |
|
|
tiers_consulte.libelle |
217 |
|
|
) as libelle |
218 |
|
|
FROM |
219 |
|
|
".DB_PREFIXE."tiers_consulte |
220 |
|
|
WHERE |
221 |
|
|
tiers_consulte = <idx>"; |
222 |
gmalvolti |
12237 |
} |
223 |
|
|
|
224 |
|
|
/** |
225 |
gmalvolti |
12381 |
* Renvoie sous la forme d'une chaîne de caractère le sql |
226 |
|
|
* permettant de récupérer la liste des tiers consulté avec |
227 |
|
|
* leur id et leur libellé |
228 |
|
|
* |
229 |
|
|
* @return string |
230 |
|
|
*/ |
231 |
|
|
function get_var_sql_forminc__sql_operateur_selectionne() { |
232 |
|
|
return "SELECT |
233 |
|
|
tiers_consulte.tiers_consulte, |
234 |
|
|
CONCAT_WS( |
235 |
|
|
' - ', |
236 |
|
|
tiers_consulte.abrege, |
237 |
|
|
tiers_consulte.libelle |
238 |
|
|
) as libelle |
239 |
|
|
FROM |
240 |
|
|
".DB_PREFIXE."tiers_consulte |
241 |
|
|
ORDER BY |
242 |
|
|
tiers_consulte.libelle ASC"; |
243 |
|
|
} |
244 |
|
|
|
245 |
|
|
/** |
246 |
|
|
* Renvoie sous la forme d'une chaîne de caractère le sql |
247 |
|
|
* permettant de récupérer l'id et le libellé d'un tiers consulté |
248 |
|
|
* a l'aide de son id |
249 |
|
|
* |
250 |
|
|
* @return string |
251 |
|
|
*/ |
252 |
|
|
function get_var_sql_forminc__sql_operateur_selectionne_by_id() { |
253 |
|
|
return "SELECT |
254 |
|
|
tiers_consulte.tiers_consulte, |
255 |
|
|
CONCAT_WS( |
256 |
|
|
' - ', |
257 |
|
|
tiers_consulte.abrege, |
258 |
|
|
tiers_consulte.libelle |
259 |
|
|
) as libelle |
260 |
|
|
FROM |
261 |
|
|
".DB_PREFIXE."tiers_consulte |
262 |
|
|
WHERE |
263 |
|
|
tiers_consulte = <idx>"; |
264 |
|
|
} |
265 |
|
|
|
266 |
|
|
/** |
267 |
cgarcin |
12326 |
* Renvoie sous forme d'une chaine de caractére la requête sql |
268 |
|
|
* permettant de récupérer la liste de tous les tiers appartenant |
269 |
|
|
* aux catégories renseigné dans la partie categorie_tiers_amenageur_public |
270 |
|
|
* du paramètre param_operateur. |
271 |
gmalvolti |
12284 |
* |
272 |
|
|
* @return string |
273 |
|
|
*/ |
274 |
|
|
function get_var_sql_forminc__sql_operateur_personne_publique() { |
275 |
|
|
$param_operateur = $this->get_param_operateur(); |
276 |
|
|
|
277 |
cgarcin |
12326 |
return "SELECT |
278 |
|
|
tiers_consulte.tiers_consulte, |
279 |
|
|
tiers_consulte.libelle |
280 |
|
|
FROM |
281 |
|
|
".DB_PREFIXE."tiers_consulte |
282 |
|
|
WHERE |
283 |
|
|
categorie_tiers_consulte IN (". |
284 |
|
|
implode(',', $param_operateur->categorie_tiers_amenageur_public). |
285 |
|
|
") |
286 |
|
|
ORDER BY |
287 |
|
|
tiers_consulte.libelle ASC"; |
288 |
gmalvolti |
12284 |
} |
289 |
|
|
|
290 |
|
|
/** |
291 |
cgarcin |
12326 |
* Renvoie sous forme d'une chaine de caractére la requête sql |
292 |
|
|
* permettant de récupérer un tiers consulté et son libellé à partir |
293 |
|
|
* de son id. |
294 |
gmalvolti |
12284 |
* |
295 |
|
|
* @return string |
296 |
|
|
*/ |
297 |
|
|
function get_var_sql_forminc__sql_operateur_personne_publique_by_id() { |
298 |
cgarcin |
12326 |
return "SELECT |
299 |
|
|
tiers_consulte.tiers_consulte, |
300 |
|
|
tiers_consulte.libelle |
301 |
|
|
FROM |
302 |
|
|
".DB_PREFIXE."tiers_consulte |
303 |
|
|
WHERE |
304 |
|
|
tiers_consulte = <idx>"; |
305 |
gmalvolti |
12284 |
} |
306 |
|
|
|
307 |
|
|
/** |
308 |
gmalvolti |
12237 |
* Permet d'initialiser la recherche d'un opérateur. |
309 |
|
|
* Si un cas remplit toutes les conditions alors on affiche l'opérateur trouvé. |
310 |
cgarcin |
12326 |
* |
311 |
gmalvolti |
12237 |
* @return bool true|false |
312 |
|
|
*/ |
313 |
gmalvolti |
12203 |
function recherche_operateur() { |
314 |
gmalvolti |
12208 |
$this->begin_treatment(__METHOD__); |
315 |
gmalvolti |
12218 |
|
316 |
|
|
if ($this->verif_param_operateur() == false) { |
317 |
|
|
return $this->end_treatment(__METHOD__, false); |
318 |
|
|
} |
319 |
|
|
|
320 |
gmalvolti |
12208 |
$param_operateur = $this->get_param_operateur(); |
321 |
|
|
|
322 |
|
|
// Initialisation des tableaux |
323 |
|
|
$tiers_consulte_irap = array(); |
324 |
|
|
$categorie_tiers_irap = array(); |
325 |
|
|
$habilitations_operateurs_inrap = array(); |
326 |
|
|
|
327 |
|
|
// On vérifie que les attributs sont présent dans le paramètre |
328 |
|
|
if (is_object($param_operateur) |
329 |
|
|
&& property_exists($param_operateur, 'categorie_tiers_inrap') |
330 |
gmalvolti |
12218 |
&& property_exists($param_operateur, 'type_habilitations_operateurs_inrap')) { |
331 |
gmalvolti |
12208 |
|
332 |
|
|
$categorie_tiers_irap = $param_operateur->categorie_tiers_inrap; |
333 |
gmalvolti |
12218 |
$type_habilitations_operateurs_inrap = $param_operateur->type_habilitations_operateurs_inrap; |
334 |
gmalvolti |
12208 |
} |
335 |
|
|
|
336 |
gmalvolti |
12254 |
$inst_dossier_instruction = $this->f->get_inst__om_dbform(array( |
337 |
|
|
"obj" => "dossier_instruction", |
338 |
|
|
"idx" => $this->getVal('dossier_instruction'), |
339 |
|
|
)); |
340 |
|
|
|
341 |
gmalvolti |
12208 |
// Construction de la requête permettant de sélectionner le tiers consulté INRAP |
342 |
|
|
$query_tiers_consulte_irap = sprintf(' |
343 |
|
|
SELECT |
344 |
|
|
tiers_consulte.tiers_consulte |
345 |
|
|
FROM |
346 |
|
|
%1$stiers_consulte |
347 |
gmalvolti |
12278 |
INNER JOIN %1$scategorie_tiers_consulte |
348 |
gmalvolti |
12208 |
ON tiers_consulte.categorie_tiers_consulte = categorie_tiers_consulte.categorie_tiers_consulte |
349 |
|
|
AND (categorie_tiers_consulte.om_validite_debut IS NULL |
350 |
|
|
OR categorie_tiers_consulte.om_validite_debut <= CURRENT_DATE) |
351 |
|
|
AND (categorie_tiers_consulte.om_validite_fin IS NULL |
352 |
|
|
OR categorie_tiers_consulte.om_validite_fin > CURRENT_DATE) |
353 |
gmalvolti |
12278 |
INNER JOIN %1$shabilitation_tiers_consulte |
354 |
gmalvolti |
12208 |
ON habilitation_tiers_consulte.tiers_consulte = tiers_consulte.tiers_consulte |
355 |
|
|
AND (habilitation_tiers_consulte.om_validite_debut IS NULL |
356 |
|
|
OR habilitation_tiers_consulte.om_validite_debut <= CURRENT_DATE) |
357 |
|
|
AND (habilitation_tiers_consulte.om_validite_fin IS NULL |
358 |
|
|
OR habilitation_tiers_consulte.om_validite_fin > CURRENT_DATE) |
359 |
gmalvolti |
12278 |
INNER JOIN %1$stype_habilitation_tiers_consulte |
360 |
gmalvolti |
12218 |
ON habilitation_tiers_consulte.type_habilitation_tiers_consulte = type_habilitation_tiers_consulte.type_habilitation_tiers_consulte |
361 |
|
|
AND (type_habilitation_tiers_consulte.om_validite_debut IS NULL |
362 |
|
|
OR type_habilitation_tiers_consulte.om_validite_debut <= CURRENT_DATE) |
363 |
|
|
AND (type_habilitation_tiers_consulte.om_validite_fin IS NULL |
364 |
|
|
OR type_habilitation_tiers_consulte.om_validite_fin > CURRENT_DATE) |
365 |
gmalvolti |
12278 |
INNER JOIN %1$sdossier |
366 |
|
|
ON dossier.dossier =\'%4$s\' |
367 |
|
|
LEFT JOIN %1$scommune |
368 |
|
|
ON commune.commune = dossier.commune |
369 |
|
|
|
370 |
gmalvolti |
12254 |
LEFT JOIN %1$slien_habilitation_tiers_consulte_commune |
371 |
|
|
ON lien_habilitation_tiers_consulte_commune.habilitation_tiers_consulte = habilitation_tiers_consulte.habilitation_tiers_consulte |
372 |
gmalvolti |
12278 |
AND lien_habilitation_tiers_consulte_commune.commune = commune.commune |
373 |
|
|
|
374 |
|
|
LEFT JOIN %1$slien_habilitation_tiers_consulte_departement |
375 |
|
|
ON lien_habilitation_tiers_consulte_departement.habilitation_tiers_consulte = habilitation_tiers_consulte.habilitation_tiers_consulte |
376 |
|
|
|
377 |
|
|
LEFT JOIN %1$sdepartement |
378 |
|
|
ON departement.departement = lien_habilitation_tiers_consulte_departement.departement |
379 |
gmalvolti |
12208 |
WHERE |
380 |
gmalvolti |
12218 |
tiers_consulte.categorie_tiers_consulte IN (%2$s) |
381 |
gmalvolti |
12254 |
AND habilitation_tiers_consulte.type_habilitation_tiers_consulte IN (%3$s) |
382 |
gmalvolti |
12278 |
AND (departement.dep = commune.dep OR lien_habilitation_tiers_consulte_commune.commune = dossier.commune); |
383 |
gmalvolti |
12208 |
', |
384 |
|
|
DB_PREFIXE, |
385 |
|
|
implode(',', $categorie_tiers_irap), |
386 |
gmalvolti |
12254 |
implode(',', $type_habilitations_operateurs_inrap), |
387 |
gmalvolti |
12278 |
$this->getVal('dossier_instruction') |
388 |
gmalvolti |
12208 |
); |
389 |
|
|
// Tableau comportant la clé 'result' qui contient l'identifiant du tiers consulté INRAP |
390 |
|
|
$tiers_consulte_irap = $this->f->get_one_result_from_db_query($query_tiers_consulte_irap); |
391 |
|
|
|
392 |
gmalvolti |
12254 |
if (empty($tiers_consulte_irap['result'])) { |
393 |
|
|
$this->correct = false; |
394 |
|
|
$this->addToMessage(__("Aucun opérateur INRAP détecté.")); |
395 |
|
|
return $this->end_treatment(__METHOD__, false); |
396 |
|
|
} |
397 |
|
|
|
398 |
gmalvolti |
12208 |
// Initialisation des tableaux pour la récupération des tiers consultés collterr |
399 |
gmalvolti |
12218 |
$tiers_consulte_collterr = array(); |
400 |
gmalvolti |
12208 |
$categorie_tiers_collterr = array(); |
401 |
gmalvolti |
12218 |
$type_habilitations_operateurs_diag_kpark = array(); |
402 |
|
|
$type_habilitations_operateurs_diag_toutdiag = array(); |
403 |
gmalvolti |
12208 |
|
404 |
|
|
if (is_object($param_operateur) |
405 |
|
|
&& property_exists($param_operateur, 'categorie_tiers_collterr') |
406 |
gmalvolti |
12218 |
&& property_exists($param_operateur, 'type_habilitations_operateurs_diag_kpark') |
407 |
|
|
&& property_exists($param_operateur, 'type_habilitations_operateurs_diag_toutdiag')) { |
408 |
gmalvolti |
12208 |
|
409 |
|
|
$categorie_tiers_collterr = $param_operateur->categorie_tiers_collterr; |
410 |
gmalvolti |
12218 |
$type_habilitations_operateurs_diag_kpark = $param_operateur->type_habilitations_operateurs_diag_kpark; |
411 |
|
|
$type_habilitations_operateurs_diag_toutdiag = $param_operateur->type_habilitations_operateurs_diag_toutdiag; |
412 |
gmalvolti |
12208 |
} |
413 |
|
|
|
414 |
gmalvolti |
12218 |
// Récupération des opérateurs cas par cas |
415 |
|
|
$query_tiers_consulte_collterr_kpark = sprintf( |
416 |
gmalvolti |
12248 |
'SELECT |
417 |
|
|
tiers_consulte.tiers_consulte as identifiant, |
418 |
gmalvolti |
12218 |
tiers_consulte.libelle, |
419 |
|
|
%1$s as habilitation, |
420 |
gmalvolti |
12254 |
CASE |
421 |
|
|
WHEN lien_habilitation_tiers_consulte_commune.commune IS NOT NULL |
422 |
|
|
THEN commune.com |
423 |
|
|
|
424 |
|
|
WHEN lien_habilitation_tiers_consulte_departement.departement IS NOT NULL |
425 |
|
|
THEN departement.dep |
426 |
|
|
ELSE NULL |
427 |
gmalvolti |
12278 |
END as localisation, |
428 |
gmalvolti |
12218 |
%2$s as consultation, |
429 |
gmalvolti |
12237 |
NULL as tab_avis |
430 |
gmalvolti |
12208 |
FROM |
431 |
gmalvolti |
12218 |
%3$stiers_consulte |
432 |
gmalvolti |
12208 |
INNER JOIN openads.categorie_tiers_consulte |
433 |
|
|
ON tiers_consulte.categorie_tiers_consulte = categorie_tiers_consulte.categorie_tiers_consulte |
434 |
|
|
AND (categorie_tiers_consulte.om_validite_debut IS NULL |
435 |
|
|
OR categorie_tiers_consulte.om_validite_debut <= CURRENT_DATE) |
436 |
|
|
AND (categorie_tiers_consulte.om_validite_fin IS NULL |
437 |
|
|
OR categorie_tiers_consulte.om_validite_fin > CURRENT_DATE) |
438 |
|
|
INNER JOIN openads.habilitation_tiers_consulte |
439 |
|
|
ON habilitation_tiers_consulte.tiers_consulte = tiers_consulte.tiers_consulte |
440 |
|
|
AND (habilitation_tiers_consulte.om_validite_debut IS NULL |
441 |
|
|
OR habilitation_tiers_consulte.om_validite_debut <= CURRENT_DATE) |
442 |
|
|
AND (habilitation_tiers_consulte.om_validite_fin IS NULL |
443 |
|
|
OR habilitation_tiers_consulte.om_validite_fin > CURRENT_DATE) |
444 |
gmalvolti |
12218 |
INNER JOIN openads.type_habilitation_tiers_consulte |
445 |
|
|
ON habilitation_tiers_consulte.type_habilitation_tiers_consulte = type_habilitation_tiers_consulte.type_habilitation_tiers_consulte |
446 |
|
|
AND (type_habilitation_tiers_consulte.om_validite_debut IS NULL |
447 |
|
|
OR type_habilitation_tiers_consulte.om_validite_debut <= CURRENT_DATE) |
448 |
|
|
AND (type_habilitation_tiers_consulte.om_validite_fin IS NULL |
449 |
|
|
OR type_habilitation_tiers_consulte.om_validite_fin > CURRENT_DATE) |
450 |
gmalvolti |
12278 |
INNER JOIN openads.dossier |
451 |
|
|
ON dossier.dossier =\'%6$s\' |
452 |
|
|
LEFT JOIN %3$scommune |
453 |
|
|
ON commune.commune = dossier.commune |
454 |
|
|
|
455 |
gmalvolti |
12254 |
LEFT JOIN %3$slien_habilitation_tiers_consulte_commune |
456 |
|
|
ON lien_habilitation_tiers_consulte_commune.habilitation_tiers_consulte = habilitation_tiers_consulte.habilitation_tiers_consulte |
457 |
gmalvolti |
12278 |
|
458 |
gmalvolti |
12254 |
LEFT JOIN %3$slien_habilitation_tiers_consulte_departement |
459 |
|
|
ON lien_habilitation_tiers_consulte_departement.habilitation_tiers_consulte = habilitation_tiers_consulte.habilitation_tiers_consulte |
460 |
gmalvolti |
12278 |
|
461 |
|
|
LEFT JOIN %3$sdepartement |
462 |
gmalvolti |
12254 |
ON departement.departement = lien_habilitation_tiers_consulte_departement.departement |
463 |
gmalvolti |
12208 |
WHERE |
464 |
gmalvolti |
12218 |
tiers_consulte.categorie_tiers_consulte IN (%4$s) |
465 |
gmalvolti |
12254 |
AND habilitation_tiers_consulte.type_habilitation_tiers_consulte IN (%5$s) |
466 |
gmalvolti |
12278 |
AND (departement.dep = commune.dep OR lien_habilitation_tiers_consulte_commune.commune = dossier.commune);', |
467 |
gmalvolti |
12218 |
"'".__("Au cas par cas")."'", |
468 |
|
|
"'".__("Consultation obligatoire")."'", |
469 |
gmalvolti |
12208 |
DB_PREFIXE, |
470 |
|
|
implode(',', $categorie_tiers_collterr), |
471 |
gmalvolti |
12254 |
implode(',', $type_habilitations_operateurs_diag_kpark), |
472 |
gmalvolti |
12278 |
$this->getVal('dossier_instruction') |
473 |
gmalvolti |
12208 |
); |
474 |
|
|
|
475 |
gmalvolti |
12218 |
$tiers_consulte_collterr_kpark = $this->f->get_all_results_from_db_query($query_tiers_consulte_collterr_kpark); |
476 |
gmalvolti |
12208 |
|
477 |
gmalvolti |
12218 |
// Récupération des opérateurs tout diag |
478 |
|
|
$query_tiers_consulte_collterr_toutdiag = sprintf( |
479 |
gmalvolti |
12248 |
'SELECT |
480 |
|
|
tiers_consulte.tiers_consulte as identifiant, |
481 |
gmalvolti |
12218 |
tiers_consulte.libelle, |
482 |
|
|
%1$s as habilitation, |
483 |
gmalvolti |
12254 |
CASE |
484 |
|
|
WHEN lien_habilitation_tiers_consulte_commune.commune IS NOT NULL |
485 |
|
|
THEN commune.com |
486 |
|
|
|
487 |
|
|
WHEN lien_habilitation_tiers_consulte_departement.departement IS NOT NULL |
488 |
|
|
THEN departement.dep |
489 |
|
|
ELSE NULL |
490 |
gmalvolti |
12278 |
END as localisation, |
491 |
gmalvolti |
12218 |
NULL as consultation, |
492 |
gmalvolti |
12237 |
\'no_select\' as tab_avis |
493 |
gmalvolti |
12218 |
FROM |
494 |
|
|
%2$stiers_consulte |
495 |
gmalvolti |
12254 |
INNER JOIN %2$scategorie_tiers_consulte |
496 |
gmalvolti |
12218 |
ON tiers_consulte.categorie_tiers_consulte = categorie_tiers_consulte.categorie_tiers_consulte |
497 |
|
|
AND (categorie_tiers_consulte.om_validite_debut IS NULL |
498 |
|
|
OR categorie_tiers_consulte.om_validite_debut <= CURRENT_DATE) |
499 |
|
|
AND (categorie_tiers_consulte.om_validite_fin IS NULL |
500 |
|
|
OR categorie_tiers_consulte.om_validite_fin > CURRENT_DATE) |
501 |
gmalvolti |
12254 |
INNER JOIN %2$shabilitation_tiers_consulte |
502 |
gmalvolti |
12218 |
ON habilitation_tiers_consulte.tiers_consulte = tiers_consulte.tiers_consulte |
503 |
|
|
AND (habilitation_tiers_consulte.om_validite_debut IS NULL |
504 |
|
|
OR habilitation_tiers_consulte.om_validite_debut <= CURRENT_DATE) |
505 |
|
|
AND (habilitation_tiers_consulte.om_validite_fin IS NULL |
506 |
|
|
OR habilitation_tiers_consulte.om_validite_fin > CURRENT_DATE) |
507 |
gmalvolti |
12254 |
INNER JOIN %2$stype_habilitation_tiers_consulte |
508 |
gmalvolti |
12218 |
ON habilitation_tiers_consulte.type_habilitation_tiers_consulte = type_habilitation_tiers_consulte.type_habilitation_tiers_consulte |
509 |
|
|
AND (type_habilitation_tiers_consulte.om_validite_debut IS NULL |
510 |
|
|
OR type_habilitation_tiers_consulte.om_validite_debut <= CURRENT_DATE) |
511 |
|
|
AND (type_habilitation_tiers_consulte.om_validite_fin IS NULL |
512 |
|
|
OR type_habilitation_tiers_consulte.om_validite_fin > CURRENT_DATE) |
513 |
gmalvolti |
12278 |
INNER JOIN openads.dossier |
514 |
|
|
ON dossier.dossier =\'%5$s\' |
515 |
|
|
LEFT JOIN %2$scommune |
516 |
|
|
ON commune.commune = dossier.commune |
517 |
|
|
|
518 |
gmalvolti |
12254 |
LEFT JOIN %2$slien_habilitation_tiers_consulte_commune |
519 |
|
|
ON lien_habilitation_tiers_consulte_commune.habilitation_tiers_consulte = habilitation_tiers_consulte.habilitation_tiers_consulte |
520 |
gmalvolti |
12278 |
AND lien_habilitation_tiers_consulte_commune.commune = commune.commune |
521 |
|
|
|
522 |
gmalvolti |
12254 |
LEFT JOIN %2$slien_habilitation_tiers_consulte_departement |
523 |
|
|
ON lien_habilitation_tiers_consulte_departement.habilitation_tiers_consulte = habilitation_tiers_consulte.habilitation_tiers_consulte |
524 |
gmalvolti |
12278 |
|
525 |
|
|
LEFT JOIN %2$sdepartement |
526 |
gmalvolti |
12254 |
ON departement.departement = lien_habilitation_tiers_consulte_departement.departement |
527 |
gmalvolti |
12218 |
WHERE |
528 |
|
|
tiers_consulte.categorie_tiers_consulte IN (%3$s) |
529 |
gmalvolti |
12254 |
AND habilitation_tiers_consulte.type_habilitation_tiers_consulte IN (%4$s) |
530 |
gmalvolti |
12278 |
AND (departement.dep = commune.dep OR lien_habilitation_tiers_consulte_commune.commune = dossier.commune);', |
531 |
gmalvolti |
12218 |
"'".__("Tous diag")."'", |
532 |
|
|
DB_PREFIXE, |
533 |
|
|
implode(',', $categorie_tiers_collterr), |
534 |
gmalvolti |
12254 |
implode(',', $type_habilitations_operateurs_diag_toutdiag), |
535 |
gmalvolti |
12278 |
$this->getVal('dossier_instruction') |
536 |
gmalvolti |
12218 |
); |
537 |
gmalvolti |
12208 |
|
538 |
gmalvolti |
12218 |
// Tableau tout diag |
539 |
|
|
$tiers_consulte_collterr_toutdiag = $this->f->get_all_results_from_db_query($query_tiers_consulte_collterr_toutdiag); |
540 |
|
|
|
541 |
|
|
$this->addToLog('query collterr tout diag: '.var_export($query_tiers_consulte_collterr_toutdiag,true), DEBUG_MODE); |
542 |
|
|
$this->addToLog('collterr tout diag: '.var_export($tiers_consulte_collterr_toutdiag, true), DEBUG_MODE); |
543 |
|
|
|
544 |
gmalvolti |
12237 |
// Si il n'y a pas de kpark alors le champ operateur_collterr_type_agrement a pour valeur 'toutdiag' |
545 |
|
|
if (! empty($tiers_consulte_collterr_toutdiag['result'])) { |
546 |
|
|
$valF['operateur_collterr_type_agrement'] = 'tout_diag'; |
547 |
|
|
} |
548 |
gmalvolti |
12299 |
if (! empty($tiers_consulte_collterr_kpark['result'])) { |
549 |
|
|
$valF['operateur_collterr_type_agrement'] = 'kpark'; |
550 |
|
|
} |
551 |
gmalvolti |
12218 |
|
552 |
|
|
// On fusionne les deux tableaux |
553 |
|
|
$tiers_consulte_collterr = array_merge_recursive($tiers_consulte_collterr_toutdiag['result'], $tiers_consulte_collterr_kpark['result']); |
554 |
|
|
$this->addToLog('collterr all: '.var_export($tiers_consulte_collterr, true), DEBUG_MODE); |
555 |
|
|
|
556 |
|
|
// On convertit en json |
557 |
|
|
if (empty($tiers_consulte_collterr) === false) { |
558 |
|
|
$tiers_consulte_collterr = json_encode($tiers_consulte_collterr); |
559 |
|
|
} |
560 |
|
|
|
561 |
|
|
$this->addToLog('json collterr: '.var_export($tiers_consulte_collterr, true), DEBUG_MODE); |
562 |
|
|
|
563 |
|
|
//Mise à jour des champs suite à la recherche d'opérateurs |
564 |
gmalvolti |
12237 |
$valF['operateur_detecte_inrap'] = $tiers_consulte_irap['result']; |
565 |
|
|
$valF['operateur_detecte_collterr'] = empty($tiers_consulte_collterr) ? NULL : $tiers_consulte_collterr; |
566 |
|
|
$valF['operateur_designation_initialisee'] = 't'; |
567 |
gmalvolti |
12208 |
|
568 |
gmalvolti |
12237 |
$this->addToLog('modifier : '.var_export($valF, true), DEBUG_MODE); |
569 |
gmalvolti |
12208 |
$res = $this->f->db->autoExecute( |
570 |
|
|
DB_PREFIXE.$this->table, |
571 |
|
|
$valF, |
572 |
|
|
DB_AUTOQUERY_UPDATE, |
573 |
|
|
$this->clePrimaire."=".$this->getVal($this->clePrimaire) |
574 |
|
|
); |
575 |
|
|
// |
576 |
|
|
$this->addToLog( |
577 |
|
|
__METHOD__." : db->autoExecute(\"".DB_PREFIXE.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getVal('dossier_operateur')."\")", |
578 |
|
|
DEBUG_MODE |
579 |
|
|
); |
580 |
|
|
|
581 |
|
|
if ($this->f->isDatabaseError($res, true)) { |
582 |
|
|
// Appel de la methode de recuperation des erreurs |
583 |
|
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
584 |
|
|
$this->correct = false; |
585 |
|
|
// Termine le traitement |
586 |
|
|
return $this->end_treatment(__METHOD__, false); |
587 |
|
|
} |
588 |
|
|
|
589 |
gmalvolti |
12218 |
$this->check_all_cases(); |
590 |
gmalvolti |
12208 |
// Voir plus tard pour aménageur |
591 |
|
|
// && property_exists($param_operateur, 'categorie_tiers_amenageur_public') |
592 |
|
|
// $categorie_tiers_amenageur_public = $param_operateur->categorie_tiers_inrap; |
593 |
|
|
|
594 |
gmalvolti |
12237 |
$this->addToLog('msg : '.var_export($this->msg, true), DEBUG_MODE); |
595 |
|
|
// On enlève les messages en trop |
596 |
|
|
$this->msg = ''; |
597 |
|
|
$this->addToMessage(__("Recherche effectuée.")); |
598 |
gmalvolti |
12218 |
return $this->end_treatment(__METHOD__, true); |
599 |
|
|
} |
600 |
|
|
|
601 |
gmalvolti |
12237 |
/** |
602 |
|
|
* Vérifie que les attributs libelle et type_operateur sont bien présents |
603 |
|
|
* pour chaque cas. |
604 |
|
|
* Si ce n'est pas le cas retourne un message d'erreur. |
605 |
cgarcin |
12326 |
* |
606 |
gmalvolti |
12237 |
* @return bool true|false |
607 |
|
|
*/ |
608 |
gmalvolti |
12218 |
function verif_param_operateur() { |
609 |
|
|
$param_operateur = $this->get_param_operateur(); |
610 |
gmalvolti |
12208 |
foreach ($param_operateur->cas as $cas) { |
611 |
gmalvolti |
12237 |
if (! is_object($cas) || ! isset($cas->libelle) || ! isset($cas->type_operateur)) { |
612 |
gmalvolti |
12208 |
$this->correct = false; |
613 |
|
|
$this->addToMessage(__("Le paramétrage est incorrect. Contactez votre administrateur")); |
614 |
gmalvolti |
12218 |
return false; |
615 |
gmalvolti |
12208 |
} |
616 |
|
|
} |
617 |
gmalvolti |
12218 |
return true; |
618 |
|
|
} |
619 |
gmalvolti |
12208 |
|
620 |
gmalvolti |
12237 |
/** |
621 |
|
|
* Permet de boucler sur tous les cas présent dans le paramètre |
622 |
|
|
* param_operateur afin de trouver un cas ou les conditions sont toutes remplis |
623 |
cgarcin |
12326 |
* |
624 |
gmalvolti |
12237 |
* @return bool true|false |
625 |
|
|
*/ |
626 |
gmalvolti |
12218 |
function check_all_cases() { |
627 |
|
|
$param_operateur = $this->get_param_operateur(); |
628 |
|
|
|
629 |
|
|
// Pour récupérer les informations mises à jours dans la recherche |
630 |
|
|
// il faut récupérer les valeurs depuis une nouvelle instance de l'objet |
631 |
|
|
$inst_dossier_operateur = $this->f->get_inst__om_dbform(array( |
632 |
|
|
"obj" => "dossier_operateur", |
633 |
|
|
"idx" => $this->getVal('dossier_operateur'), |
634 |
|
|
)); |
635 |
|
|
|
636 |
gmalvolti |
12288 |
// Permet de déterminer si un opérateur collterr peut être désigné |
637 |
gmalvolti |
12381 |
$tab_collterr = $this->get_operateur_selectionne(json_decode($inst_dossier_operateur->getVal('operateur_detecte_collterr'))); |
638 |
gmalvolti |
12288 |
|
639 |
gmalvolti |
12218 |
// $this->addToLog('collterr dossier getval : '.var_export($this->valF['operateur_detecte_collterr'], true), DEBUG_MODE); |
640 |
gmalvolti |
12237 |
// $this->addToLog('collterr dossier getval : '.var_export($inst_dossier_operateur->getVal('operateur_detecte_collterr'), true), DEBUG_MODE); |
641 |
gmalvolti |
12218 |
|
642 |
|
|
// Initialisation des paramètres du dossier |
643 |
|
|
$param_dossier = array( |
644 |
|
|
'P1' => $inst_dossier_operateur->getVal('operateur_detecte_inrap'), |
645 |
|
|
'P2' => $inst_dossier_operateur->getVal('operateur_detecte_collterr') == NULL ? NULL : 'collterr', |
646 |
|
|
'P3' => $inst_dossier_operateur->getVal('operateur_collterr_type_agrement'), |
647 |
gmalvolti |
12248 |
'P4' => NULL, |
648 |
gmalvolti |
12284 |
'P5' => NULL, |
649 |
gmalvolti |
12288 |
'P6' => $this->gestion_des_avis_collterr_kpark(json_decode($inst_dossier_operateur->getVal('operateur_detecte_collterr'))), |
650 |
gmalvolti |
12218 |
'P7' => $inst_dossier_operateur->getVal('operateur_personne_publique_avis'), |
651 |
|
|
); |
652 |
|
|
|
653 |
gmalvolti |
12248 |
if ($inst_dossier_operateur->getVal('operateur_amenagement_pers_publique') == 't') { |
654 |
|
|
$param_dossier['P4'] = true; |
655 |
|
|
} else if ($inst_dossier_operateur->getVal('operateur_amenagement_pers_publique') == 'f') { |
656 |
|
|
$param_dossier['P4'] = false; |
657 |
|
|
} |
658 |
|
|
|
659 |
gmalvolti |
12284 |
if ($inst_dossier_operateur->getVal('operateur_pers_publique_amenageur') == 't') { |
660 |
|
|
$param_dossier['P5'] = true; |
661 |
|
|
} else if ($inst_dossier_operateur->getVal('operateur_pers_publique_amenageur') == 'f') { |
662 |
|
|
$param_dossier['P5'] = false; |
663 |
|
|
} |
664 |
|
|
|
665 |
gmalvolti |
12218 |
foreach ($param_operateur->cas as $cas) { |
666 |
|
|
|
667 |
|
|
$parametres_param_operateur = $cas->parametre; |
668 |
|
|
// $this->addToLog('tab parametre : '.var_export($parametres_param_operateur, true), DEBUG_MODE); |
669 |
|
|
$tab_result_cas = array(); |
670 |
|
|
$tab_result_cas['libelle'] = $cas->libelle; |
671 |
|
|
$tab_result_cas['type_operateur'] = $cas->type_operateur; |
672 |
gmalvolti |
12248 |
$tab_result_cas['evenement'] = property_exists($cas, 'evenement') === true ? $cas->evenement : NULL; |
673 |
gmalvolti |
12218 |
foreach ($parametres_param_operateur as $key => $parametre) { |
674 |
|
|
|
675 |
|
|
// $this->addToLog('$key : '.var_export($key, true), DEBUG_MODE); |
676 |
|
|
// $this->addToLog('tab parametre iteration : '.var_export($parametre, true), DEBUG_MODE); |
677 |
|
|
// $this->addToLog('tab param_dossier : '.var_export($param_dossier[$key], true), DEBUG_MODE); |
678 |
|
|
if (array_key_exists($key, $param_dossier) |
679 |
gmalvolti |
12248 |
&& $parametre === $param_dossier[$key]) { |
680 |
gmalvolti |
12218 |
$tab_result_cas[$key] = true; |
681 |
|
|
} else { |
682 |
|
|
$tab_result_cas[$key] = false; |
683 |
|
|
} |
684 |
|
|
} |
685 |
|
|
$this->addToLog('tab result : '.var_export($tab_result_cas, true), DEBUG_MODE); |
686 |
|
|
$this->addToLog('tab result : '.var_export(in_array(false, $tab_result_cas), true), DEBUG_MODE); |
687 |
|
|
if (in_array(false, $tab_result_cas)) { |
688 |
|
|
$tab_result_cas = array( |
689 |
|
|
'libelle' => null, |
690 |
|
|
'type_operateur' => null, |
691 |
|
|
'evenement' => null |
692 |
|
|
); |
693 |
|
|
continue; |
694 |
|
|
} else { |
695 |
|
|
break; |
696 |
|
|
} |
697 |
|
|
} |
698 |
|
|
|
699 |
|
|
$this->addToLog('array : '.var_export($tab_result_cas, true), DEBUG_MODE); |
700 |
|
|
// $this->addToLog('array : '.var_export(isset($tab_result_cas), true), DEBUG_MODE); |
701 |
|
|
// $this->addToLog('array : '.var_export(in_array(false, $tab_result_cas), true), DEBUG_MODE); |
702 |
|
|
// $this->addToLog('array : '.var_export($tab_result_cas, true), DEBUG_MODE); |
703 |
gmalvolti |
12237 |
// $this->addToLog('array : '.var_export($tab_result_cas['libelle'], true), DEBUG_MODE); |
704 |
|
|
// $this->addToLog('array : '.var_export($tab_result_cas['type_operateur'], true), DEBUG_MODE); |
705 |
gmalvolti |
12218 |
|
706 |
gmalvolti |
12288 |
$valF['operateur_kpark_libelle'] = $tab_result_cas['libelle']; |
707 |
|
|
$valF['operateur_kpark_type_operateur'] = $tab_result_cas['type_operateur']; |
708 |
|
|
$valF['operateur_kpark_evenement'] = $tab_result_cas['evenement']; |
709 |
gmalvolti |
12381 |
$valF['operateur_collterr_kpark_avis'] = $param_dossier['P6']; |
710 |
|
|
$valF['operateur_selectionne'] = NULL; |
711 |
gmalvolti |
12218 |
|
712 |
gmalvolti |
12288 |
if (is_null($tab_result_cas['libelle']) === false |
713 |
|
|
&& is_null($tab_result_cas['type_operateur']) === false) { |
714 |
|
|
if ($tab_result_cas['type_operateur'] === 'inrap') { |
715 |
gmalvolti |
12381 |
$valF['operateur_selectionne'] = $inst_dossier_operateur->getVal('operateur_detecte_inrap'); |
716 |
gmalvolti |
12237 |
} |
717 |
gmalvolti |
12218 |
|
718 |
gmalvolti |
12288 |
if ($tab_result_cas['type_operateur'] === 'collterr') { |
719 |
gmalvolti |
12381 |
$valF['operateur_selectionne'] = $tab_collterr['identifiant']; |
720 |
gmalvolti |
12218 |
} |
721 |
gmalvolti |
12288 |
} |
722 |
|
|
$res = $this->f->db->autoExecute( |
723 |
|
|
DB_PREFIXE.$this->table, |
724 |
|
|
$valF, |
725 |
|
|
DB_AUTOQUERY_UPDATE, |
726 |
|
|
$this->clePrimaire."=".$this->getVal($this->clePrimaire) |
727 |
|
|
); |
728 |
|
|
// |
729 |
|
|
$this->addToLog( |
730 |
|
|
__METHOD__." : db->autoExecute(\"".DB_PREFIXE.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getVal('dossier_operateur')."\")", |
731 |
|
|
DEBUG_MODE |
732 |
|
|
); |
733 |
gmalvolti |
12237 |
|
734 |
gmalvolti |
12288 |
if ($this->f->isDatabaseError($res, true)) { |
735 |
|
|
// Appel de la methode de recuperation des erreurs |
736 |
|
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
737 |
|
|
$this->correct = false; |
738 |
|
|
// Termine le traitement |
739 |
|
|
return false; |
740 |
gmalvolti |
12218 |
} |
741 |
|
|
|
742 |
gmalvolti |
12288 |
// Ajouter la partie sur l'ajout de l'instruction à partir de $tab_result_cas['evenement'] |
743 |
|
|
|
744 |
gmalvolti |
12218 |
return true; |
745 |
gmalvolti |
12203 |
} |
746 |
|
|
|
747 |
gmalvolti |
12381 |
function get_operateur_selectionne($tab_collterr) { |
748 |
gmalvolti |
12288 |
|
749 |
|
|
$tab_collterr_avis = array(); |
750 |
gmalvolti |
12299 |
if (! empty($tab_collterr)) { |
751 |
gmalvolti |
12288 |
|
752 |
gmalvolti |
12299 |
// On récupère toutes les valeurs de tab_avis différent de no_select |
753 |
|
|
foreach ($tab_collterr as $key => $value) { |
754 |
|
|
// Si il y a au moins un opérateur cas par cas |
755 |
|
|
if ($this->getVal('operateur_collterr_type_agrement') == 'kpark') { |
756 |
|
|
if ($value->tab_avis != 'no_select') { |
757 |
gmalvolti |
12288 |
|
758 |
gmalvolti |
12299 |
$tab_collterr_avis[] = array( |
759 |
|
|
'identifiant' => $value->identifiant, |
760 |
|
|
'com_ou_dep' => strlen($value->localisation) <=3 ? 'dep' : 'com', |
761 |
|
|
'avis' => $value->tab_avis, |
762 |
|
|
); |
763 |
|
|
$this->addToLog('get operateur collterr: '.var_export($key, true).' '.var_export($value, true), DEBUG_MODE); |
764 |
|
|
$this->addToLog('obj tab_avis: '.var_export($value->tab_avis, true), DEBUG_MODE); |
765 |
|
|
} |
766 |
gmalvolti |
12288 |
} |
767 |
|
|
|
768 |
gmalvolti |
12299 |
if ($this->getVal('operateur_collterr_type_agrement') == 'tout_diag') { |
769 |
|
|
if ($value->tab_avis == 'no_select') { |
770 |
gmalvolti |
12288 |
|
771 |
gmalvolti |
12299 |
$tab_collterr_avis[] = array( |
772 |
|
|
'identifiant' => $value->identifiant, |
773 |
|
|
'com_ou_dep' => strlen($value->localisation) <=3 ? 'dep' : 'com', |
774 |
|
|
'avis' => $value->tab_avis, |
775 |
|
|
); |
776 |
|
|
$this->addToLog('get operateur collterr: '.var_export($key, true).' '.var_export($value, true), DEBUG_MODE); |
777 |
|
|
$this->addToLog('obj tab_avis: '.var_export($value->tab_avis, true), DEBUG_MODE); |
778 |
|
|
} |
779 |
|
|
} |
780 |
gmalvolti |
12288 |
} |
781 |
gmalvolti |
12284 |
} |
782 |
gmalvolti |
12288 |
$data_selected = array(); |
783 |
|
|
foreach ($tab_collterr_avis as $value) { |
784 |
|
|
$this->addToLog('in array: '.var_export(in_array('com', $value), true), DEBUG_MODE); |
785 |
|
|
if (in_array('com', $value) && ($value['avis'] == 'F' || $value['avis'] == 'no_select')) { |
786 |
|
|
$data_selected = $value; |
787 |
|
|
} |
788 |
|
|
if (! in_array('com', $data_selected) && ($value['avis'] == 'F' || $value['avis'] == 'no_select')) { |
789 |
|
|
$data_selected = $value; |
790 |
|
|
} |
791 |
|
|
} |
792 |
|
|
|
793 |
|
|
$this->addToLog('tab_avis: '.var_export($tab_collterr_avis, true), DEBUG_MODE); |
794 |
|
|
$this->addToLog('data_selected: '.var_export($data_selected, true), DEBUG_MODE); |
795 |
|
|
return $data_selected; |
796 |
gmalvolti |
12284 |
} |
797 |
|
|
|
798 |
gmalvolti |
12288 |
function gestion_des_avis_collterr_kpark($tab_collterr) { |
799 |
|
|
$avis_collterr = ''; |
800 |
|
|
$tab_collterr_avis = array(); |
801 |
|
|
$is_all_avis = true; |
802 |
|
|
if ($this->getVal('operateur_collterr_type_agrement') == 'kpark') { |
803 |
|
|
foreach ($tab_collterr as $key => $value) { |
804 |
|
|
// Si il y a au moins un opérateur cas par cas |
805 |
|
|
if ($value->tab_avis != 'no_select') { |
806 |
|
|
|
807 |
|
|
$tab_collterr_avis[] = array( |
808 |
|
|
'identifiant' => $value->identifiant, |
809 |
|
|
'com_ou_dep' => strlen($value->localisation) <=3 ? 'dep' : 'com', |
810 |
|
|
'avis' => $value->tab_avis, |
811 |
|
|
); |
812 |
|
|
|
813 |
|
|
if ($value->tab_avis == '') { |
814 |
|
|
$is_all_avis = false; |
815 |
|
|
} |
816 |
|
|
|
817 |
|
|
$this->addToLog('get operateur collterr: '.var_export($key, true).' '.var_export($value, true), DEBUG_MODE); |
818 |
|
|
$this->addToLog('obj tab_avis: '.var_export($value->tab_avis, true), DEBUG_MODE); |
819 |
|
|
} |
820 |
|
|
} |
821 |
|
|
|
822 |
|
|
$data_selected = array(); |
823 |
|
|
|
824 |
|
|
foreach ($tab_collterr_avis as $value) { |
825 |
|
|
|
826 |
|
|
if ($is_all_avis == false) { |
827 |
|
|
if (in_array('com', $value) && $value['avis'] == 'F') { |
828 |
|
|
$data_selected = $value; |
829 |
|
|
break; |
830 |
|
|
} |
831 |
|
|
} |
832 |
|
|
|
833 |
|
|
$this->addToLog('in array: '.var_export(in_array('com', $value), true), DEBUG_MODE); |
834 |
|
|
if (in_array('com', $value)) { |
835 |
|
|
$data_selected = $value; |
836 |
|
|
} |
837 |
|
|
if (! in_array('com', $data_selected)) { |
838 |
|
|
$data_selected = $value; |
839 |
|
|
} |
840 |
|
|
} |
841 |
gmalvolti |
12299 |
$avis_collterr = $data_selected['avis']; |
842 |
gmalvolti |
12288 |
} |
843 |
|
|
return $avis_collterr; |
844 |
|
|
} |
845 |
|
|
|
846 |
gmalvolti |
12237 |
/** |
847 |
|
|
* Methode setTaille |
848 |
|
|
*/ |
849 |
|
|
function setTaille(&$form, $maj) { |
850 |
|
|
parent::setTaille($form, $maj); |
851 |
|
|
$form->setTaille("tab_avis_maj", 20); |
852 |
|
|
} |
853 |
|
|
|
854 |
|
|
/** |
855 |
|
|
* Methode setMax |
856 |
|
|
*/ |
857 |
|
|
function setMax(&$form, $maj) { |
858 |
|
|
parent::setMax($form, $maj); |
859 |
|
|
$form->setMax("tab_avis_maj", 20); |
860 |
|
|
} |
861 |
|
|
|
862 |
|
|
/** |
863 |
cgarcin |
12326 |
* Permet de vérifier si l'action de modification doit être affichée. |
864 |
|
|
* La modification est possible si il la designation de l'operateur |
865 |
|
|
* a été initialisé, si la liste des tiers consultés Collectivités Territoriales |
866 |
|
|
* n'est pas vide. |
867 |
|
|
* |
868 |
gmalvolti |
12237 |
* @return bool true|false |
869 |
|
|
*/ |
870 |
gmalvolti |
12203 |
function is_editable() { |
871 |
gmalvolti |
12218 |
if ($this->getVal('operateur_designation_initialisee') == 't' |
872 |
gmalvolti |
12248 |
&& $this->getVal('operateur_valide') == 'f' |
873 |
|
|
&& ! empty($this->getVal('operateur_detecte_collterr'))) { |
874 |
gmalvolti |
12208 |
|
875 |
|
|
return true; |
876 |
|
|
} |
877 |
|
|
return false; |
878 |
gmalvolti |
12203 |
} |
879 |
|
|
|
880 |
gmalvolti |
12237 |
/** |
881 |
|
|
* Permet de vérifier si l'action de réinitialisation doit être affichée |
882 |
cgarcin |
12326 |
* C'est le cas a partir du moment ou on initialise la designation de |
883 |
|
|
* l'operateur. |
884 |
|
|
* |
885 |
gmalvolti |
12237 |
* @return bool true|false |
886 |
|
|
*/ |
887 |
|
|
function is_reinitialisable() { |
888 |
gmalvolti |
12208 |
if ($this->getVal('operateur_designation_initialisee') == 't') { |
889 |
|
|
return true; |
890 |
|
|
} |
891 |
|
|
return false; |
892 |
|
|
} |
893 |
|
|
|
894 |
gmalvolti |
12237 |
/** |
895 |
|
|
* Permet de vérifier si l'action de validation de l'opérateur doit être affichée |
896 |
cgarcin |
12326 |
* L'operateur peut être valide si un opérateur est designé mais pas validé. |
897 |
|
|
* |
898 |
gmalvolti |
12237 |
* @return bool true|false |
899 |
|
|
*/ |
900 |
|
|
function is_validable() { |
901 |
gmalvolti |
12381 |
if (! empty($this->getVal('operateur_selectionne')) |
902 |
gmalvolti |
12248 |
&& $this->getVal('operateur_valide') == 'f') { |
903 |
gmalvolti |
12237 |
return true; |
904 |
|
|
} |
905 |
|
|
return false; |
906 |
|
|
} |
907 |
|
|
|
908 |
|
|
/** |
909 |
|
|
* L'action de suppression ne doit pas être présente dans ce formulaire. |
910 |
|
|
* |
911 |
|
|
* @return bool false |
912 |
|
|
*/ |
913 |
|
|
function is_deletable() { |
914 |
|
|
return false; |
915 |
|
|
} |
916 |
|
|
|
917 |
|
|
/** |
918 |
|
|
* Permet de vérifier que l'action de recherche d'un opérateur est affichable. |
919 |
cgarcin |
12326 |
* C'est le cas lorsque la designation de l'opérateur n'a pas été initialisée. |
920 |
gmalvolti |
12237 |
* @return bool true|false |
921 |
|
|
*/ |
922 |
|
|
function is_recherche_operateur_available() { |
923 |
|
|
if ($this->getVal('operateur_designation_initialisee') == 'f') { |
924 |
|
|
return true; |
925 |
|
|
} |
926 |
|
|
return false; |
927 |
|
|
} |
928 |
|
|
|
929 |
|
|
/** |
930 |
|
|
* Permet de remettre tous les champs à leur valeur par défaut, |
931 |
|
|
* excepté pour le dossier d'instruction lié, l'historique des opérateurs |
932 |
|
|
* désignés et l'identifiant de la table dossier_operateur |
933 |
|
|
* |
934 |
|
|
* @return bool true|false |
935 |
|
|
*/ |
936 |
|
|
function reinitialiser() { |
937 |
|
|
$this->begin_treatment(__METHOD__); |
938 |
|
|
// mise à jour des champs |
939 |
|
|
$valF = array(); |
940 |
|
|
|
941 |
|
|
// Il faut traiter tous les champs de l'objet |
942 |
|
|
foreach($this->champs as $identifiant => $champ) { |
943 |
gmalvolti |
12248 |
$valF[$champ] = NULL; |
944 |
gmalvolti |
12237 |
} |
945 |
|
|
|
946 |
cgarcin |
12326 |
// Récupère la liste des tiers consulté des collectivités territoriales et remet |
947 |
|
|
// leur avis à 0 |
948 |
gmalvolti |
12248 |
$tab_collterr = json_decode($this->getVal('operateur_detecte_collterr')); |
949 |
|
|
if (! empty($tab_collterr)) { |
950 |
|
|
for ($i=0; $i<count($tab_collterr); $i++) { |
951 |
|
|
unset($valF["tab_avis_".$i]); |
952 |
|
|
} |
953 |
|
|
} |
954 |
cgarcin |
12326 |
// Réinitialise les valeur du formulaire ? |
955 |
gmalvolti |
12237 |
unset($valF['tab_avis']); |
956 |
|
|
unset($valF['tab_avis_maj']); |
957 |
gmalvolti |
12248 |
unset($valF['operateur_message_kpark']); |
958 |
|
|
unset($valF['message_consultation_amenageur']); |
959 |
|
|
unset($valF['message_consultation_tiers']); |
960 |
gmalvolti |
12237 |
$valF['operateur_designation_initialisee'] = false; |
961 |
gmalvolti |
12248 |
$valF['operateur_valide'] = 'f'; |
962 |
gmalvolti |
12237 |
$valF['dossier_instruction'] = $this->getVal('dossier_instruction'); |
963 |
|
|
$valF['dossier_operateur'] = $this->getVal('dossier_operateur'); |
964 |
|
|
$valF['operateur_designe_historique'] = $this->getVal('operateur_designe_historique'); |
965 |
cgarcin |
12326 |
// Met a jour les valeurs dans la Base de Données. En cas d'erreur |
966 |
gmalvolti |
12237 |
$res = $this->f->db->autoExecute( |
967 |
|
|
DB_PREFIXE.$this->table, |
968 |
|
|
$valF, |
969 |
|
|
DB_AUTOQUERY_UPDATE, |
970 |
|
|
$this->clePrimaire."=".$this->getVal($this->clePrimaire) |
971 |
|
|
); |
972 |
|
|
// |
973 |
|
|
$this->addToLog( |
974 |
|
|
__METHOD__." : db->autoExecute(\"".DB_PREFIXE.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getVal('dossier_operateur')."\")", |
975 |
|
|
DEBUG_MODE |
976 |
|
|
); |
977 |
|
|
|
978 |
|
|
if ($this->f->isDatabaseError($res, true)) { |
979 |
|
|
// Appel de la methode de recuperation des erreurs |
980 |
|
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
981 |
|
|
$this->correct = false; |
982 |
|
|
// Termine le traitement |
983 |
|
|
return false; |
984 |
|
|
} |
985 |
|
|
|
986 |
|
|
$this->addToMessage(__("Réinitialisation effectuée.")); |
987 |
|
|
return $this->end_treatment(__METHOD__, true); |
988 |
|
|
} |
989 |
|
|
|
990 |
|
|
/** |
991 |
|
|
* Permet de valider l'opérateur désigné et de mettre à jour l'historique |
992 |
|
|
* des opérateurs désignés. |
993 |
|
|
* |
994 |
|
|
* @return bool true|false |
995 |
|
|
*/ |
996 |
|
|
function valider() { |
997 |
|
|
$this->begin_treatment(__METHOD__); |
998 |
|
|
|
999 |
gmalvolti |
12299 |
// On vérifie que l'évènement existe avant de modifier l'opérateur |
1000 |
gmalvolti |
12381 |
// On gère l'ajout de l'evènement paramétré si il y en a un |
1001 |
gmalvolti |
12299 |
if (! empty($this->getVal('operateur_kpark_evenement'))){ |
1002 |
|
|
$sql_check_evenement_exists = sprintf( |
1003 |
|
|
'SELECT |
1004 |
|
|
* |
1005 |
|
|
FROM |
1006 |
|
|
%1$sevenement |
1007 |
|
|
WHERE |
1008 |
|
|
evenement=%2$s', |
1009 |
|
|
DB_PREFIXE, |
1010 |
|
|
$this->getVal('operateur_kpark_evenement') |
1011 |
|
|
); |
1012 |
|
|
$res_check = $this->f->get_one_result_from_db_query($sql_check_evenement_exists); |
1013 |
|
|
if (empty($res_check['result'])) { |
1014 |
|
|
$this->correct = false ; |
1015 |
|
|
$this->msg = ''; |
1016 |
|
|
$this->addToMessage(__("L'événement paramétré n'existe pas. Vérifiez le paramétrage")); |
1017 |
|
|
return $this->end_treatment(__METHOD__, false); |
1018 |
|
|
} |
1019 |
|
|
|
1020 |
|
|
if (! empty($res_check['result'])) { |
1021 |
|
|
$new_instruction = $this->f->get_inst__om_dbform(array( |
1022 |
|
|
"obj" => "instruction", |
1023 |
|
|
"idx" => "]", |
1024 |
|
|
)); |
1025 |
|
|
|
1026 |
|
|
// Création d'un tableau avec la liste des champs de l'instruction |
1027 |
|
|
foreach($new_instruction->champs as $champ) { |
1028 |
|
|
$valNewInstr[$champ] = ""; |
1029 |
|
|
} |
1030 |
|
|
// Définition des valeurs de la nouvelle instruction |
1031 |
|
|
$valNewInstr["evenement"] = $this->getVal('operateur_kpark_evenement'); |
1032 |
|
|
$valNewInstr["dossier"] = $this->getVal('dossier_instruction'); |
1033 |
|
|
$valNewInstr["date_evenement"] = $this->f->formatDate(date('Y-m-d')); |
1034 |
|
|
$new_instruction->setParameter("maj", 0); |
1035 |
|
|
$retour = $new_instruction->ajouter($valNewInstr); |
1036 |
|
|
|
1037 |
|
|
//Si une erreur s'est produite et qu'il s'agit d'un problème |
1038 |
|
|
//de restriction |
1039 |
|
|
if ($retour == false && $new_instruction->restriction_valid){ |
1040 |
|
|
$this->correct = false ; |
1041 |
|
|
$this->msg .= $new_instruction->msg; |
1042 |
|
|
return $this->end_treatment(__METHOD__, false); |
1043 |
|
|
} |
1044 |
|
|
} |
1045 |
|
|
} |
1046 |
|
|
|
1047 |
gmalvolti |
12381 |
$operateur_designe_libelle_query = str_replace('<idx>', $this->getVal('operateur_selectionne'), $this->get_var_sql_forminc__sql_operateur_designe_by_id()); |
1048 |
|
|
|
1049 |
|
|
$res = $this->f->get_all_results_from_db_query($operateur_designe_libelle_query); |
1050 |
|
|
|
1051 |
|
|
// Préparation de l'ajout de l'opérateur désigné |
1052 |
|
|
$valF = array(); |
1053 |
|
|
|
1054 |
|
|
// Pour appeler la fonction modifier il faut traiter tous les champs de l'objet |
1055 |
|
|
foreach($this->champs as $identifiant => $champ) { |
1056 |
|
|
$valF[$champ] = $this->val[$identifiant]; |
1057 |
|
|
} |
1058 |
|
|
// On fait ensuite nos modifications spécifiques |
1059 |
|
|
$valF['operateur_valide'] = 't'; |
1060 |
|
|
$valF['operateur_designe'] = $this->getVal('operateur_selectionne'); |
1061 |
|
|
|
1062 |
|
|
$dossier_operateur_historique_json = $this->getVal('operateur_designe_historique'); |
1063 |
|
|
$dossier_operateur_historique = array(); |
1064 |
|
|
if (! empty($dossier_operateur_historique_json)) { |
1065 |
|
|
$dossier_operateur_historique = json_decode(str_replace("'", '"', $dossier_operateur_historique_json)); |
1066 |
|
|
} |
1067 |
|
|
|
1068 |
|
|
$dossier_operateur_historique[] = array( |
1069 |
|
|
'entry_date' => date('d/m/Y H:i:s'), |
1070 |
|
|
'operateur' => $res['result'][0]['libelle'], |
1071 |
|
|
'login' => $_SESSION['login'], |
1072 |
|
|
); |
1073 |
|
|
|
1074 |
|
|
$valF['operateur_designe_historique'] = json_encode($dossier_operateur_historique); |
1075 |
|
|
|
1076 |
gmalvolti |
12248 |
$ret = $this->modifier($valF); |
1077 |
|
|
|
1078 |
|
|
if ($ret === false) { |
1079 |
|
|
$this->correct = false; |
1080 |
|
|
$this->addToMessage(__("Une erreur est survenue lors de la mise à jour des champs.")); |
1081 |
|
|
// Termine le traitement |
1082 |
|
|
return $this->end_treatment(__METHOD__, false); |
1083 |
|
|
} |
1084 |
|
|
|
1085 |
gmalvolti |
12237 |
$this->addToMessage(__("Validation effectuée.")); |
1086 |
|
|
return $this->end_treatment(__METHOD__, true); |
1087 |
|
|
} |
1088 |
|
|
|
1089 |
gmalvolti |
12203 |
function setType(&$form,$maj) { |
1090 |
|
|
parent::setType($form,$maj); |
1091 |
|
|
|
1092 |
gmalvolti |
12208 |
foreach ($this->champs as $champ) { |
1093 |
|
|
$form->setType($champ,'hidden'); |
1094 |
|
|
} |
1095 |
gmalvolti |
12218 |
$form->setType('operateur_detecte_inrap','selecthiddenstatic'); |
1096 |
|
|
$form->setType('operateur_detecte_collterr','hiddenstatic'); |
1097 |
|
|
|
1098 |
gmalvolti |
12381 |
// Ces champs sont cachés en javascript |
1099 |
|
|
// $form->setType('operateur_amenagement_pers_publique','select'); |
1100 |
|
|
|
1101 |
|
|
if ($this->getVal('operateur_amenagement_pers_publique') == 't') { |
1102 |
|
|
$form->setType('operateur_pers_publique_amenageur','selecthiddenstatic'); |
1103 |
|
|
$form->setType('operateur_personne_publique_avis','selecthiddenstatic'); |
1104 |
|
|
|
1105 |
|
|
if ($this->getVal('operateur_pers_publique_amenageur') == 'f') { |
1106 |
|
|
$form->setType('message_consultation_amenageur','hiddenstatic'); |
1107 |
|
|
$form->setType('message_consultation_tiers','hiddenstatic'); |
1108 |
|
|
$form->setType('operateur_personne_publique','selecthiddenstatic'); |
1109 |
|
|
} |
1110 |
|
|
} |
1111 |
|
|
|
1112 |
|
|
if ($maj<=2) { |
1113 |
|
|
$form->setType('operateur_personne_publique','select'); |
1114 |
|
|
$form->setType('operateur_pers_publique_amenageur','select'); |
1115 |
|
|
$form->setType('operateur_personne_publique_avis','select'); |
1116 |
|
|
} |
1117 |
|
|
$form->setType('message_consultation_amenageur','hiddenstatic'); |
1118 |
|
|
$form->setType('message_consultation_tiers','hiddenstatic'); |
1119 |
|
|
|
1120 |
gmalvolti |
12248 |
if ($this->getVal('operateur_collterr_type_agrement') == 'kpark') { |
1121 |
|
|
$form->setType('operateur_message_kpark','hiddenstatic'); |
1122 |
|
|
} |
1123 |
gmalvolti |
12237 |
|
1124 |
gmalvolti |
12381 |
if (empty($this->getVal('operateur_selectionne')) === false) { |
1125 |
|
|
$form->setType('operateur_selectionne','selecthiddenstatic'); |
1126 |
gmalvolti |
12237 |
$form->setType('operateur_kpark_libelle','hiddenstatic'); |
1127 |
gmalvolti |
12381 |
|
1128 |
|
|
if (empty($this->getVal('operateur_designe')) === false) { |
1129 |
|
|
$form->setType('operateur_selectionne','hidden'); |
1130 |
|
|
$form->setType('operateur_designe','selecthiddenstatic'); |
1131 |
|
|
} |
1132 |
gmalvolti |
12218 |
} |
1133 |
gmalvolti |
12237 |
|
1134 |
gmalvolti |
12248 |
if (empty($this->getVal('operateur_designe_historique')) === false) { |
1135 |
|
|
$form->setType('operateur_designe_historique','jsontotab'); |
1136 |
|
|
} |
1137 |
|
|
|
1138 |
|
|
// $form->setType('tab_avis','selecthiddenstatic'); |
1139 |
gmalvolti |
12237 |
if ($this->getVal('operateur_designation_initialisee') == 't') { |
1140 |
|
|
if (empty($this->getVal('operateur_detecte_collterr')) === false) { |
1141 |
|
|
$form->setType('operateur_detecte_collterr','tab_custom'); |
1142 |
|
|
|
1143 |
gmalvolti |
12248 |
$tab_collterr = json_decode($this->getVal('operateur_detecte_collterr')); |
1144 |
|
|
if (! empty($tab_collterr)) { |
1145 |
|
|
for ($i=0; $i<count($tab_collterr); $i++) { |
1146 |
|
|
if ($tab_collterr[$i]->tab_avis !== 'no_select') { |
1147 |
|
|
$form->setType("tab_avis_".$i, 'selecthiddenstatic'); |
1148 |
|
|
} |
1149 |
|
|
} |
1150 |
|
|
} |
1151 |
gmalvolti |
12237 |
$form->setType('tab_avis','selecthiddenstatic'); |
1152 |
|
|
if ($maj < 2) { |
1153 |
|
|
$form->setType('tab_avis','select'); |
1154 |
gmalvolti |
12248 |
if (! empty($tab_collterr)) { |
1155 |
|
|
for ($i=0; $i<count($tab_collterr); $i++) { |
1156 |
|
|
if ($tab_collterr[$i]->tab_avis !== 'no_select') { |
1157 |
|
|
$form->setType("tab_avis_".$i, 'select'); |
1158 |
|
|
} |
1159 |
|
|
} |
1160 |
|
|
} |
1161 |
gmalvolti |
12237 |
} |
1162 |
|
|
} |
1163 |
|
|
|
1164 |
gmalvolti |
12248 |
if (!empty($this->getVal('operateur_detecte_inrap')) |
1165 |
|
|
&& !empty($this->getVal('operateur_detecte_collterr'))) { |
1166 |
gmalvolti |
12237 |
$form->setType('operateur_amenagement_pers_publique','selecthiddenstatic'); |
1167 |
gmalvolti |
12248 |
if ($maj < 2) { |
1168 |
|
|
$form->setType('operateur_amenagement_pers_publique','select'); |
1169 |
|
|
$form->setType('operateur_designe_historique','hidden'); |
1170 |
|
|
} |
1171 |
gmalvolti |
12237 |
} |
1172 |
gmalvolti |
12381 |
} |
1173 |
|
|
} |
1174 |
gmalvolti |
12237 |
|
1175 |
gmalvolti |
12381 |
function setOnchange(&$form, $maj) { |
1176 |
|
|
parent::setOnchange($form, $maj); |
1177 |
gmalvolti |
12237 |
|
1178 |
gmalvolti |
12381 |
if ($maj <= 2) { |
1179 |
|
|
// Ajout la fonction permettant d'afficher/cacher les champs |
1180 |
|
|
// dans le formulaire de modification |
1181 |
|
|
$form->setOnchange('operateur_amenagement_pers_publique', "switch_operateur_amenagement_pers_public($(this).val())"); |
1182 |
gmalvolti |
12237 |
} |
1183 |
gmalvolti |
12203 |
} |
1184 |
|
|
|
1185 |
|
|
function setLayout(&$form, $maj) { |
1186 |
gmalvolti |
12218 |
//Champs sur lequel s'ouvre le fieldset |
1187 |
gmalvolti |
12288 |
$form->setBloc('operateur_detecte_inrap','D',"", 'col_10'); |
1188 |
gmalvolti |
12218 |
$form->setFieldset('operateur_detecte_inrap','D',__('Opérateurs')); |
1189 |
gmalvolti |
12203 |
|
1190 |
gmalvolti |
12218 |
//Champs sur lequel se ferme le fieldset |
1191 |
gmalvolti |
12248 |
$form->setFieldset('operateur_message_kpark','F',''); |
1192 |
|
|
$form->setBloc('operateur_message_kpark','F'); |
1193 |
gmalvolti |
12218 |
|
1194 |
|
|
|
1195 |
gmalvolti |
12248 |
if (!empty($this->getVal('operateur_detecte_inrap')) |
1196 |
|
|
&& !empty($this->getVal('operateur_detecte_collterr'))) { |
1197 |
gmalvolti |
12288 |
$form->setBloc('operateur_amenagement_pers_publique','DF',"", "col_10"); |
1198 |
gmalvolti |
12248 |
$form->setFieldset('operateur_amenagement_pers_publique','DF',__('Aménagement')); |
1199 |
|
|
} |
1200 |
|
|
|
1201 |
|
|
//Champs sur lequel s'ouvre le fieldset |
1202 |
|
|
$form->setBloc('operateur_pers_publique_amenageur','D',"", "col_10"); |
1203 |
|
|
$form->setFieldset('operateur_pers_publique_amenageur','D',__("Consultation de l'aménageur")); |
1204 |
|
|
//Champs sur lequel se ferme le fieldset |
1205 |
|
|
$form->setFieldset('operateur_personne_publique_avis','F'); |
1206 |
|
|
$form->setBloc('operateur_personne_publique_avis','F',""); |
1207 |
|
|
|
1208 |
gmalvolti |
12381 |
// Si le champ operateur_selectionne n'est pas vide |
1209 |
|
|
if (! empty($this->getVal('operateur_selectionne'))) { |
1210 |
gmalvolti |
12288 |
//Champs sur lequel s'ouvre le fieldset |
1211 |
gmalvolti |
12381 |
$form->setBloc('operateur_selectionne','D',"", "col_10"); |
1212 |
|
|
$form->setFieldset('operateur_selectionne','D',__('Opérateur désigné')); |
1213 |
gmalvolti |
12288 |
//Champs sur lequel se ferme le fieldset |
1214 |
|
|
$form->setFieldset('operateur_kpark_libelle','F'); |
1215 |
|
|
$form->setBloc('operateur_kpark_libelle','F',""); |
1216 |
|
|
} |
1217 |
|
|
$form->setBloc('operateur_designe_historique','DF',"" , "col_10"); |
1218 |
gmalvolti |
12248 |
$form->setFieldset('operateur_designe_historique','DF',__('Historique')); |
1219 |
gmalvolti |
12203 |
} |
1220 |
|
|
|
1221 |
gmalvolti |
12208 |
function setLib(&$form, $maj) { |
1222 |
|
|
$form->setLib('operateur_detecte_inrap', __('INRAP')); |
1223 |
|
|
$form->setLib('operateur_detecte_collterr', __('Opérateur')); |
1224 |
gmalvolti |
12237 |
$form->setLib('operateur_designe', ''); |
1225 |
gmalvolti |
12381 |
$form->setLib('operateur_selectionne', ''); |
1226 |
gmalvolti |
12237 |
$form->setLib('operateur_kpark_libelle', ''); |
1227 |
gmalvolti |
12248 |
$form->setLib('operateur_message_kpark', ''); |
1228 |
gmalvolti |
12237 |
$form->setLib('operateur_amenagement_pers_publique', |
1229 |
|
|
__("L'aménagement est-il réalisé par ou pour une personne publique (R523-28) ?")); |
1230 |
gmalvolti |
12248 |
$form->setLib('operateur_pers_publique_amenageur', |
1231 |
|
|
__("La personne publique \"article R523-28\" est-elle l'aménageur du projet ?")); |
1232 |
|
|
$form->setLib('message_consultation_amenageur', ''); |
1233 |
|
|
$form->setLib('message_consultation_tiers', ''); |
1234 |
|
|
$form->setLib('operateur_personne_publique', __("Tiers aménageur")); |
1235 |
|
|
$form->setLib('operateur_personne_publique_avis', __("Avis rendu")); |
1236 |
gmalvolti |
12381 |
// valeur utilisé seulement pour traduire la colonne tab_avis avec poedit |
1237 |
|
|
$tab_avis = __('tab_avis'); |
1238 |
gmalvolti |
12208 |
} |
1239 |
gmalvolti |
12203 |
|
1240 |
gmalvolti |
12208 |
|
1241 |
gmalvolti |
12203 |
/** |
1242 |
|
|
* SETTER_FORM - setValsousformulaire (setVal). |
1243 |
|
|
* |
1244 |
|
|
* @return void |
1245 |
|
|
*/ |
1246 |
|
|
function setValsousformulaire(&$form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire, &$dnu1 = null, $dnu2 = null) { |
1247 |
|
|
// parent::setValsousformulaire($form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire); |
1248 |
|
|
// |
1249 |
|
|
$this->retourformulaire = $retourformulaire; |
1250 |
|
|
// |
1251 |
|
|
if ($validation == 0) { |
1252 |
|
|
// Si on est dans le dossier |
1253 |
|
|
if ($this->getParameter("retourformulaire") == "dossier" |
1254 |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction") { |
1255 |
|
|
// |
1256 |
|
|
$form->setVal("dossier_instruction", $this->getParameter("idxformulaire")); |
1257 |
|
|
} |
1258 |
|
|
} |
1259 |
gmalvolti |
12218 |
|
1260 |
gmalvolti |
12237 |
if ($this->getVal('operateur_detecte_collterr') == NULL |
1261 |
|
|
&& $this->getVal('operateur_designation_initialisee') == 't') { |
1262 |
|
|
$form->setVal('operateur_detecte_collterr', __("Aucun opérateur détecté.")); |
1263 |
|
|
} |
1264 |
gmalvolti |
12248 |
|
1265 |
|
|
if ($this->getVal('operateur_collterr_type_agrement') == 'kpark') { |
1266 |
|
|
$form->setVal('operateur_message_kpark', __("Vous devez consulter les opérateurs au cas par cas depuis l'onglet Consultation")); |
1267 |
|
|
} |
1268 |
|
|
|
1269 |
gmalvolti |
12381 |
// Affiché ou caché en JS |
1270 |
|
|
$form->setVal('message_consultation_amenageur', __("Vous devez consulter l'aménageur depuis l'onglet Consultation.")); |
1271 |
|
|
$form->setVal('message_consultation_tiers', __("Vous devez consulter le tiers sélectionné.")); |
1272 |
gmalvolti |
12203 |
} |
1273 |
|
|
|
1274 |
gmalvolti |
12300 |
function setvalF($val = array()) { |
1275 |
|
|
parent::setvalF($val); |
1276 |
|
|
// En fonction de la valeur sélectionné il faut vider certains champs |
1277 |
|
|
if ($val['operateur_amenagement_pers_publique'] == 'f') { |
1278 |
|
|
$this->valF['operateur_pers_publique_amenageur'] = NULL; |
1279 |
|
|
$this->valF['operateur_personne_publique_avis'] = NULL; |
1280 |
|
|
$this->valF['operateur_personne_publique'] = NULL; |
1281 |
|
|
} |
1282 |
|
|
|
1283 |
|
|
if ($val['operateur_pers_publique_amenageur'] == 't') { |
1284 |
|
|
$this->valF['operateur_personne_publique'] = NULL; |
1285 |
|
|
} |
1286 |
|
|
} |
1287 |
|
|
|
1288 |
gmalvolti |
12237 |
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
1289 |
|
|
parent::setSelect($form, $maj); |
1290 |
gmalvolti |
12381 |
|
1291 |
|
|
// Contient l'option '' qui est masquée en JS |
1292 |
|
|
$contenu_operateur_pers_publique_amenageur =array(); |
1293 |
|
|
$contenu_operateur_pers_publique_amenageur[0][0]=''; |
1294 |
|
|
$contenu_operateur_pers_publique_amenageur[1][0]=''; |
1295 |
|
|
$contenu_operateur_pers_publique_amenageur[0][1]="f"; |
1296 |
|
|
$contenu_operateur_pers_publique_amenageur[1][1]=__('Non'); |
1297 |
|
|
$contenu_operateur_pers_publique_amenageur[0][2]="t"; |
1298 |
|
|
$contenu_operateur_pers_publique_amenageur[1][2]=__('Oui'); |
1299 |
|
|
$form->setSelect("operateur_pers_publique_amenageur", $contenu_operateur_pers_publique_amenageur); |
1300 |
|
|
|
1301 |
gmalvolti |
12237 |
$contenu_operateur_amenagement_pers_publique =array(); |
1302 |
|
|
$contenu_operateur_amenagement_pers_publique[0][0]="f"; |
1303 |
|
|
$contenu_operateur_amenagement_pers_publique[1][0]=__('Non'); |
1304 |
|
|
$contenu_operateur_amenagement_pers_publique[0][1]="t"; |
1305 |
|
|
$contenu_operateur_amenagement_pers_publique[1][1]=__('Oui'); |
1306 |
|
|
$form->setSelect("operateur_amenagement_pers_publique", $contenu_operateur_amenagement_pers_publique); |
1307 |
gmalvolti |
12203 |
|
1308 |
gmalvolti |
12237 |
$contenu_tab_avis =array(); |
1309 |
gmalvolti |
12248 |
$contenu_tab_avis[0][0]=""; |
1310 |
gmalvolti |
12237 |
$contenu_tab_avis[1][0]=__('Sélectionner un avis'); |
1311 |
|
|
$contenu_tab_avis[0][1]="F"; |
1312 |
|
|
$contenu_tab_avis[1][1]=__('Favorable'); |
1313 |
|
|
$contenu_tab_avis[0][2]="D"; |
1314 |
|
|
$contenu_tab_avis[1][2]=__('Défavorable'); |
1315 |
|
|
$contenu_tab_avis[0][3]="T"; |
1316 |
|
|
$contenu_tab_avis[1][3]=__('Tacite'); |
1317 |
|
|
$form->setSelect("tab_avis", $contenu_tab_avis); |
1318 |
gmalvolti |
12248 |
|
1319 |
|
|
$tab_collterr = json_decode($this->getVal('operateur_detecte_collterr')); |
1320 |
|
|
if (! empty($tab_collterr)) { |
1321 |
|
|
for ($i=0; $i<count($tab_collterr); $i++) { |
1322 |
|
|
if ($tab_collterr[$i]->tab_avis !== 'no_select') { |
1323 |
|
|
$form->setSelect("tab_avis_".$i, $contenu_tab_avis); |
1324 |
|
|
} |
1325 |
|
|
} |
1326 |
|
|
} |
1327 |
|
|
|
1328 |
|
|
$form->setSelect("operateur_personne_publique_avis", $contenu_tab_avis); |
1329 |
gmalvolti |
12237 |
} |
1330 |
|
|
|
1331 |
|
|
|
1332 |
gmalvolti |
12203 |
/** |
1333 |
|
|
* Surcharge du bouton retour afin de retourner sur le dossier d'instruction selon de cas |
1334 |
|
|
*/ |
1335 |
|
|
function retoursousformulaire($idxformulaire = NULL, $retourformulaire = NULL, $val = NULL, |
1336 |
|
|
$objsf = NULL, $premiersf = NULL, $tricolsf = NULL, $validation = NULL, |
1337 |
|
|
$idx = NULL, $maj = NULL, $retour = NULL) { |
1338 |
|
|
|
1339 |
|
|
$visualisation = $this->getParameter('visualisation'); |
1340 |
|
|
|
1341 |
|
|
if ( $visualisation == "" ){ |
1342 |
|
|
|
1343 |
|
|
// Ajout et consultation, retour dossier |
1344 |
|
|
if ( ( $maj == 0 && $validation == 0 ) || |
1345 |
|
|
( $maj == 3 && $validation == 0 ) || |
1346 |
|
|
( $maj == 0 && $validation == 1 ) && $retourformulaire == "dossier_instruction" ){ |
1347 |
|
|
|
1348 |
|
|
echo "\n<a class=\"retour\" "; |
1349 |
|
|
echo "href=\"#\" "; |
1350 |
|
|
echo "onclick=\"redirectPortletAction(1,'main');\" "; |
1351 |
|
|
echo ">"; |
1352 |
|
|
echo _("Retour"); |
1353 |
|
|
echo "</a>\n"; |
1354 |
|
|
} |
1355 |
|
|
//Sinon affiche un retour normal |
1356 |
|
|
else{ |
1357 |
|
|
|
1358 |
|
|
parent::retoursousformulaire($idxformulaire, $retourformulaire, $val, |
1359 |
|
|
$objsf, $premiersf, $tricolsf, $validation, |
1360 |
|
|
$idx, $maj, $retour); |
1361 |
|
|
} |
1362 |
|
|
} |
1363 |
|
|
} |
1364 |
gmalvolti |
12237 |
|
1365 |
|
|
function update_tab_collterr() { |
1366 |
gmalvolti |
12248 |
//$this->addToLog("maj operateur collterr : ".var_export($tab_avis, true), DEBUG_MODE); |
1367 |
|
|
if (empty($this->getVal('operateur_detecte_collterr'))) { |
1368 |
|
|
return true; |
1369 |
|
|
} |
1370 |
|
|
|
1371 |
gmalvolti |
12237 |
$operateurs_collterr = json_decode($this->getVal('operateur_detecte_collterr')); |
1372 |
|
|
$tab_avis = json_decode($_POST['tab_avis_maj']); |
1373 |
|
|
|
1374 |
gmalvolti |
12248 |
//$this->addToLog("maj operateur collterr : ".var_export($tab_avis, true), DEBUG_MODE); |
1375 |
gmalvolti |
12237 |
foreach ($operateurs_collterr as $key => $value) { |
1376 |
|
|
if ($tab_avis[$key] !== NULL) { |
1377 |
|
|
$operateurs_collterr[$key]->tab_avis = $tab_avis[$key]; |
1378 |
gmalvolti |
12248 |
$valF['tab_avis_'.$key] = $tab_avis[$key]; |
1379 |
gmalvolti |
12237 |
} |
1380 |
|
|
} |
1381 |
|
|
|
1382 |
|
|
$valF = array(); |
1383 |
|
|
$valF['operateur_detecte_collterr'] = json_encode($operateurs_collterr); |
1384 |
|
|
|
1385 |
|
|
$this->addToLog("maj operateur collterr : ".var_export($operateurs_collterr, true), DEBUG_MODE); |
1386 |
|
|
|
1387 |
|
|
$res = $this->f->db->autoExecute( |
1388 |
|
|
DB_PREFIXE.$this->table, |
1389 |
|
|
$valF, |
1390 |
|
|
DB_AUTOQUERY_UPDATE, |
1391 |
|
|
$this->clePrimaire."=".$this->getVal($this->clePrimaire) |
1392 |
|
|
); |
1393 |
|
|
// |
1394 |
|
|
$this->addToLog( |
1395 |
|
|
__METHOD__." : db->autoExecute(\"".DB_PREFIXE.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getVal('dossier_operateur')."\")", |
1396 |
|
|
DEBUG_MODE |
1397 |
|
|
); |
1398 |
|
|
|
1399 |
|
|
if ($this->f->isDatabaseError($res, true)) { |
1400 |
|
|
// Appel de la methode de recuperation des erreurs |
1401 |
|
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
1402 |
|
|
$this->correct = false; |
1403 |
|
|
// Termine le traitement |
1404 |
|
|
return false; |
1405 |
|
|
} |
1406 |
|
|
|
1407 |
|
|
return true; |
1408 |
|
|
} |
1409 |
|
|
|
1410 |
|
|
|
1411 |
|
|
/** |
1412 |
|
|
* Permet de modifier l'affichage des boutons dans le sousformulaire. |
1413 |
|
|
* @param string $datasubmit Données a transmettre |
1414 |
|
|
* @param integer $maj Mode du formulaire |
1415 |
|
|
* @param array $val Valeur du formulaire |
1416 |
|
|
*/ |
1417 |
|
|
function boutonsousformulaire($datasubmit, $maj, $val = null) { |
1418 |
|
|
|
1419 |
|
|
(isset($_GET['obj']) ? $obj = $this->f->get_submitted_get_value('obj') : $obj = ""); |
1420 |
|
|
($this->f->get_submitted_get_value('idxformulaire') !== null ? $id_dossier_operateur = |
1421 |
|
|
$this->f->get_submitted_get_value('idxformulaire') : $id_dossier_operateur = ""); |
1422 |
|
|
// |
1423 |
|
|
if (!$this->correct) { |
1424 |
|
|
// Action par défaut |
1425 |
|
|
$onclick = "affichersform('".$this->get_absolute_class_name()."', |
1426 |
|
|
'$datasubmit', this.form);return false;"; |
1427 |
|
|
// |
1428 |
|
|
switch ($maj) { |
1429 |
|
|
case 0: |
1430 |
|
|
$bouton = _("Ajouter"); |
1431 |
|
|
break; |
1432 |
|
|
case 1: |
1433 |
|
|
$bouton = _("Modifier"); |
1434 |
|
|
// Action en mode ajouter |
1435 |
|
|
$onclick = "get_avis_from_operateur_kpark(".$this->get_absolute_class_name().",".str_replace('"', "'", $this->getVal('operateur_detecte_collterr')).");return"; |
1436 |
|
|
break; |
1437 |
|
|
case 2: |
1438 |
|
|
$bouton = _("Supprimer"); |
1439 |
|
|
break; |
1440 |
|
|
} |
1441 |
|
|
// |
1442 |
|
|
$params = array( |
1443 |
|
|
"value" => $bouton, |
1444 |
|
|
"onclick" => $onclick, |
1445 |
|
|
); |
1446 |
|
|
// |
1447 |
|
|
$this->f->layout->display_form_button($params); |
1448 |
|
|
} |
1449 |
|
|
} |
1450 |
|
|
|
1451 |
|
|
/** |
1452 |
|
|
* TRIGGER - triggermodifierapres. |
1453 |
|
|
* |
1454 |
|
|
* @return boolean |
1455 |
|
|
*/ |
1456 |
|
|
function triggermodifierapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
1457 |
|
|
// $this->addToLog('POST triggermodifierapres '.var_export($this->f->get_submitted_post_value(), true)); |
1458 |
|
|
$this->update_tab_collterr(); |
1459 |
|
|
$this->check_all_cases(); |
1460 |
|
|
} |
1461 |
gmalvolti |
12203 |
} |