1 |
<?php |
2 |
//$Id: consultation.class.php 6046 2016-02-26 15:27:06Z fmichon $ |
3 |
//gen openMairie le 10/02/2011 20:32 |
4 |
require_once ("../gen/obj/consultation.class.php"); |
5 |
|
6 |
class consultation extends consultation_gen { |
7 |
|
8 |
// Champs contenant les UID des fichiers |
9 |
var $abstract_type = array( |
10 |
"fichier" => "file", |
11 |
"om_fichier_consultation" => "file", |
12 |
); |
13 |
|
14 |
var $metadata = array( |
15 |
"om_fichier_consultation" => array( |
16 |
"dossier" => "getDossier", |
17 |
"dossier_version" => "getDossierVersion", |
18 |
"numDemandeAutor" => "getNumDemandeAutor", |
19 |
"anneemoisDemandeAutor" => "getAnneemoisDemandeAutor", |
20 |
"typeInstruction" => "getTypeInstruction", |
21 |
"statutAutorisation" => "getStatutAutorisation", |
22 |
"typeAutorisation" => "getTypeAutorisation", |
23 |
"dateEvenementDocument" => "getDateEvenementDocument", |
24 |
"groupeInstruction" => 'getGroupeInstruction', |
25 |
"title" => 'getTitle', |
26 |
), |
27 |
"fichier" => array( |
28 |
"filename" => "getFichierFilename", |
29 |
"dossier" => "getDossier", |
30 |
"dossier_version" => "getDossierVersion", |
31 |
"numDemandeAutor" => "getNumDemandeAutor", |
32 |
"anneemoisDemandeAutor" => "getAnneemoisDemandeAutor", |
33 |
"typeInstruction" => "getTypeInstruction", |
34 |
"statutAutorisation" => "getStatutAutorisation", |
35 |
"typeAutorisation" => "getTypeAutorisation", |
36 |
"dateEvenementDocument" => "getDateEvenementDocument", |
37 |
"groupeInstruction" => 'getGroupeInstruction', |
38 |
"title" => 'getTitle', |
39 |
), |
40 |
); |
41 |
|
42 |
/** |
43 |
* Les nouvelles actions sont activées sur cet objet. |
44 |
* |
45 |
* @var boolean |
46 |
*/ |
47 |
var $activate_class_action; |
48 |
|
49 |
/** |
50 |
* Cette variable permet de stocker le résultat de la méthode |
51 |
* getDivisionFromDossier() afin de ne pas effectuer le recalcul à chacun de |
52 |
* ces appels. |
53 |
* @var string Code de la division du dossier en cours |
54 |
*/ |
55 |
var $_division_from_dossier = NULL; |
56 |
|
57 |
/** |
58 |
* Instance de la classe dossier |
59 |
* |
60 |
* @var mixed |
61 |
*/ |
62 |
var $inst_dossier = null; |
63 |
|
64 |
/** |
65 |
* Constructeur. |
66 |
* |
67 |
* @param integer $id identifiant de l'enregistrement |
68 |
* @param database $db handler de la base de données |
69 |
* @param boolean $debug debug |
70 |
*/ |
71 |
function consultation($id, &$db, $debug) { |
72 |
//On active les nouvelles actions |
73 |
$this->activate_class_action = true; |
74 |
$this->constructeur($id, $db, $debug); |
75 |
}// fin constructeur |
76 |
|
77 |
/** |
78 |
* Définition des actions disponibles sur la classe. |
79 |
* |
80 |
* @return void |
81 |
*/ |
82 |
function init_class_actions() { |
83 |
|
84 |
parent::init_class_actions(); |
85 |
|
86 |
// ACTION - 001 - modifier |
87 |
// |
88 |
$this->class_actions[1]["condition"] = array("show_consultation_finaliser_portlet_action", |
89 |
"is_editable"); |
90 |
|
91 |
// ACTION - 002 - supprimer |
92 |
// |
93 |
$this->class_actions[2]["condition"] = array("show_consultation_finaliser_portlet_action", |
94 |
"is_deletable"); |
95 |
|
96 |
// ACTION - 040 - ajout_multiple |
97 |
// Ajout de consultattons multiples |
98 |
$this->class_actions[40] = array( |
99 |
"identifier" => "ajout_multiple", |
100 |
"view" => "view_ajout_multiple", |
101 |
"method" => "ajouter_multiple", |
102 |
"button" => "valider", |
103 |
"permission_suffix" => "ajouter", |
104 |
"condition" => array("is_multiaddable"), |
105 |
); |
106 |
// ACTION - 050 - marquer_comme_lu |
107 |
// Pour qu'un cadre valide l'analyse |
108 |
$this->class_actions[50] = array( |
109 |
"identifier" => "marquer_comme_lu", |
110 |
"portlet" => array( |
111 |
"type" => "action-direct", |
112 |
"libelle" => _("Marquer comme lu"), |
113 |
"order" => 50, |
114 |
"class" => "lu-16", |
115 |
), |
116 |
"view" => "formulaire", |
117 |
"method" => "marquer_comme_lu", |
118 |
"permission_suffix" => "modifier_lu", |
119 |
"condition" => array("is_markable", |
120 |
"show_marquer_comme_lu_portlet_action"), |
121 |
); |
122 |
// ACTION - 060 - finaliser |
123 |
// Pour qu'un cadre valide l'analyse |
124 |
$this->class_actions[60] = array( |
125 |
"identifier" => "finalise", |
126 |
"portlet" => array( |
127 |
"type" => "action-direct", |
128 |
"libelle" => _("Finaliser le document"), |
129 |
"order" => 60, |
130 |
"class" => "finalise", |
131 |
), |
132 |
"view" => "formulaire", |
133 |
"method" => "finalize", |
134 |
"permission_suffix" => "finaliser", |
135 |
"condition" => array("show_consultation_finaliser_portlet_action", |
136 |
"is_finalizable"), |
137 |
); |
138 |
|
139 |
// ACTION - 070 - unfinaliser |
140 |
// Pour qu'un cadre valide l'analyse |
141 |
$this->class_actions[70] = array( |
142 |
"identifier" => "unfinalise", |
143 |
"portlet" => array( |
144 |
"type" => "action-direct", |
145 |
"libelle" => _("Reprendre la redaction du document"), |
146 |
"order" => 70, |
147 |
"class" => "definalise", |
148 |
), |
149 |
"view" => "formulaire", |
150 |
"method" => "unfinalize", |
151 |
"permission_suffix" => "definaliser", |
152 |
"condition" => array("show_unfinalize_portlet_action", |
153 |
"is_unfinalizable"), |
154 |
); |
155 |
|
156 |
// ACTION - 080 - consulter_pdf |
157 |
// Pour qu'un cadre valide l'analyse |
158 |
$this->class_actions[80] = array( |
159 |
"identifier" => "consulter_pdf", |
160 |
"portlet" => array( |
161 |
"type" => "action-blank", |
162 |
"libelle" => _("Editer la consultation PDF"), |
163 |
"order" => 45, |
164 |
"class" => "pdf-16", |
165 |
), |
166 |
"view" => "view_consulter_pdf", |
167 |
"permission_suffix" => "consulter", |
168 |
); |
169 |
|
170 |
// ACTION - 090 - Générer l'édition PDF d'une consultation multiple |
171 |
// |
172 |
$this->class_actions[90] = array( |
173 |
"identifier" => "generate_pdf_consultation_multiple", |
174 |
"view" => "generate_pdf_consultation_multiple", |
175 |
"permission_suffix" => "ajouter", |
176 |
); |
177 |
|
178 |
// ACTION - 100 - retour_consultation |
179 |
// Lors de la saisie de retour d'avis par le profil suivi des dates |
180 |
$this->class_actions[100] = array( |
181 |
"identifier" => "retour_consultation", |
182 |
"view" => "formulaire", |
183 |
"method" => "modifier", |
184 |
"button" => _("Modifier"), |
185 |
"permission_suffix" => "modifier", |
186 |
"condition" => array("is_suivi_retours_de_consultation"), |
187 |
|
188 |
); |
189 |
|
190 |
$this->class_actions[110] = array( |
191 |
"identifier" => "suivi_mise_a_jour_des_dates", |
192 |
"view" => "view_suivi_mise_a_jour_des_dates", |
193 |
"permission_suffix" => "suivi_mise_a_jour_des_dates", |
194 |
"condition" => array(), |
195 |
); |
196 |
|
197 |
$this->class_actions[120] = array( |
198 |
"identifier" => "suivi_retours_de_consultation", |
199 |
"view" => "view_suivi_retours_de_consultation", |
200 |
"permission_suffix" => "suivi_retours_de_consultation", |
201 |
"condition" => array(), |
202 |
); |
203 |
} |
204 |
|
205 |
/** |
206 |
* Permet de modifier le fil d'Ariane depuis l'objet pour un formulaire |
207 |
* @param string $ent Fil d'Ariane récupéréré |
208 |
* @return Fil d'Ariane |
209 |
*/ |
210 |
function getFormTitle($ent) { |
211 |
// |
212 |
if ($this->getParameter('maj') == 120) { |
213 |
// |
214 |
return _("suivi")." -> "._("demandes d'avis")." -> "._("retours de consultation"); |
215 |
} |
216 |
// |
217 |
if ($this->getParameter('maj') == 110) { |
218 |
// |
219 |
return _("suivi")." -> "._("demandes d'avis")." -> "._("mise a jour des dates"); |
220 |
} |
221 |
// |
222 |
if ($this->getParameter('maj') == 100) { |
223 |
// |
224 |
return _("suivi")." -> "._("demandes d'avis")." -> "._("retours de consultation")." -> ".$this->getVal($this->clePrimaire); |
225 |
} |
226 |
// |
227 |
return $ent; |
228 |
} |
229 |
|
230 |
|
231 |
/** |
232 |
* Ce script permet de gérer l'interface de saisie rapide des retours de |
233 |
* consultation par la cellule suivi l'aide d'un code barre. |
234 |
*/ |
235 |
function view_suivi_retours_de_consultation() { |
236 |
// |
237 |
$this->checkAccessibility(); |
238 |
/** |
239 |
* Validation du formulaire |
240 |
*/ |
241 |
// Si le formulaire a été validé |
242 |
if ($this->f->get_submitted_post_value('code_barres') !== null) { |
243 |
// Si la valeur transmise est correcte |
244 |
if ($this->f->get_submitted_post_value('code_barres') != "" |
245 |
&& is_numeric($this->f->get_submitted_post_value('code_barres'))) { |
246 |
// Vérification de l'existence de la consultation |
247 |
$sql = "SELECT consultation FROM ".DB_PREFIXE."consultation "; |
248 |
$sql .= " WHERE code_barres='".$this->f->db->escapesimple($this->f->get_submitted_post_value('code_barres'))."'"; |
249 |
$res = $this->f->db->query($sql); |
250 |
// Logger |
251 |
$this->f->addToLog( |
252 |
__METHOD__."(): db->query(\"".$sql."\")", |
253 |
VERBOSE_MODE |
254 |
); |
255 |
// Gestion des erreurs de base de données |
256 |
$this->f->isDatabaseError($res); |
257 |
// En fonction du nombre de consultations correspondantes |
258 |
// on affiche un message d"erreur ou on redirige vers le formulaire de |
259 |
// saisie du retour |
260 |
if ($res->numrows()==0) { |
261 |
// Si |
262 |
$message_class = "error"; |
263 |
$message = _("Ce code barres de consultation n'existe pas."); |
264 |
} elseif ($res->numrows() > 1) { |
265 |
// Si |
266 |
$message_class = "error"; |
267 |
$message = _("Plusieurs consultations avec ce code barres."); |
268 |
} else { |
269 |
$row =& $res->fetchRow(DB_FETCHMODE_ASSOC); |
270 |
header("Location: ../scr/form.php?obj=consultation&action=100&retour=suivi_retours_de_consultation&idx=".$row['consultation']); |
271 |
} |
272 |
} elseif ($this->f->get_submitted_post_value('code_barres')!==null && $this->f->get_submitted_post_value('code_barres') == "") { |
273 |
// Si aucune valeur n'a été saisie dans le champs consultation |
274 |
$message_class = "error"; |
275 |
$message = _("Veuiller saisir un code barres de consultation."); |
276 |
} else { |
277 |
// Si |
278 |
$message_class = "error"; |
279 |
$message = _("Cette consultation n'existe pas."); |
280 |
} |
281 |
} |
282 |
|
283 |
/** |
284 |
* Affichage des messages et du formulaire |
285 |
*/ |
286 |
// Affichage du message de validation ou d'erreur |
287 |
if (isset($message) && isset($message_class) && $message != "") { |
288 |
$this->f->displayMessage($message_class, $message); |
289 |
} |
290 |
// |
291 |
$datasubmit = $this->getDataSubmit(); |
292 |
// Inclusion de la classe de gestion des formulaires |
293 |
require_once "../obj/om_formulaire.class.php"; |
294 |
// Ouverture du formulaire |
295 |
echo "\t<form"; |
296 |
echo " method=\"post\""; |
297 |
echo " id=\"suivi_retours_de_consultation_form\""; |
298 |
echo " action=\"".$datasubmit."\""; |
299 |
echo ">\n"; |
300 |
// Paramétrage des champs du formulaire |
301 |
$champs = array("code_barres"); |
302 |
// Création d'un nouvel objet de type formulaire |
303 |
$form = new formulaire(null, 0, 0, $champs); |
304 |
// Paramétrage des champs du formulaire |
305 |
$form->setLib("code_barres", _("No de code barres de consultation")); |
306 |
$form->setType("code_barres", "text"); |
307 |
$form->setTaille("code_barres", 25); |
308 |
$form->setMax("code_barres", 25); |
309 |
// Affichage du formulaire |
310 |
$form->entete(); |
311 |
$form->afficher($champs, 0, false, false); |
312 |
$form->enpied(); |
313 |
// Affichage du bouton |
314 |
echo "\t<div class=\"formControls\">\n"; |
315 |
$this->f->layout->display_form_button(array("value" => _("Valider"))); |
316 |
echo "\t</div>\n"; |
317 |
// Fermeture du formulaire |
318 |
echo "\t</form>\n"; |
319 |
} |
320 |
|
321 |
/** |
322 |
* Ce script permet de mettre à jour les dates de suivi du traitement |
323 |
* des consultations. |
324 |
*/ |
325 |
function view_suivi_mise_a_jour_des_dates() { |
326 |
// |
327 |
$this->checkAccessibility(); |
328 |
|
329 |
// Récupération des valeur passées en POST ou GET |
330 |
$date = ""; |
331 |
if($this->f->get_submitted_post_value('date') !== null) { |
332 |
$date = $this->f->get_submitted_post_value('date'); |
333 |
} elseif($this->f->get_submitted_get_value('date') !== null) { |
334 |
$date = $this->f->get_submitted_get_value('date'); |
335 |
} |
336 |
$code_barres = ""; |
337 |
if($this->f->get_submitted_post_value('code_barres') !== null) { |
338 |
$code_barres = $this->f->get_submitted_post_value('code_barres'); |
339 |
} elseif($this->f->get_submitted_get_value('code_barres')!==null) { |
340 |
$code_barres = $this->f->get_submitted_get_value('code_barres'); |
341 |
} |
342 |
|
343 |
// Booléen permettant de définir si un enregistrement à eu lieu |
344 |
$correct = false; |
345 |
// Booléen permettant de définir si les dates peuvent êtres enregistrées |
346 |
$date_error = false; |
347 |
|
348 |
// Si le formulaire a été validé |
349 |
if ($this->f->get_submitted_post_value('validation') !== null) { |
350 |
//Tous les champs doivent obligatoirement être remplis |
351 |
if ( !empty($date) && !empty($code_barres) ){ |
352 |
|
353 |
//Vérification de l'existence de la consultation |
354 |
$sql = "SELECT consultation, type_consultation |
355 |
FROM ".DB_PREFIXE."consultation |
356 |
LEFT JOIN ".DB_PREFIXE."service |
357 |
ON service.service = consultation.service |
358 |
WHERE code_barres = '".$this->f->db->escapesimple($code_barres)."'"; |
359 |
$res = $this->f->db->query($sql); |
360 |
$this->f->addToLog("app/demandes_avis_mise_a_jour_des_dates.php : db->query(\"".$sql."\")", VERBOSE_MODE); |
361 |
$this->f->isDatabaseError($res); |
362 |
|
363 |
//Si le code barres est correct |
364 |
if($res->numrows() == 1) { |
365 |
|
366 |
//Un retour de demande d'avis ne peut être saisie que si le type de |
367 |
//consultation est "avec_avis_attendu" |
368 |
$row =& $res->fetchRow(DB_FETCHMODE_ASSOC); |
369 |
if ( strcasecmp($row['type_consultation'], "avec_avis_attendu") === 0 ){ |
370 |
|
371 |
//On met à jour la date après l'écran de vérification |
372 |
if($this->f->get_submitted_post_value("is_valid") != null and $this->f->get_submitted_post_value("is_valid") == "true") { |
373 |
require_once '../obj/consultation.class.php'; |
374 |
$consultation = new consultation($row['consultation'], $this->f->db, DEBUG); |
375 |
$consultation->setParameter("maj", 1); |
376 |
$valF = array(); |
377 |
foreach($consultation->champs as $id => $champ) { |
378 |
$valF[$champ] = $consultation->val[$id]; |
379 |
} |
380 |
|
381 |
$valF['date_reception']=$date; |
382 |
|
383 |
$consultation->modifier($valF, $this->f->db, DEBUG); |
384 |
// Vérification de la finalisation du document |
385 |
// correspondant au code barres |
386 |
if($consultation->valF["om_final_consultation"] === true) { |
387 |
$message_class = "valid"; |
388 |
$message = _("Saisie enregistree"); |
389 |
$code_barres = ""; |
390 |
} else { |
391 |
// |
392 |
$message_class = "error"; |
393 |
$message = sprintf(_("Le document correspondant au |
394 |
code barres %s n'est pas finalise, |
395 |
la date ne sera pas mise a jour."), |
396 |
$code_barres); |
397 |
} |
398 |
|
399 |
} |
400 |
//Sinon on récupère les infos du dossier pour les afficher |
401 |
else { |
402 |
// Récupération des infos du dossier |
403 |
$sqlInfo = "SELECT dossier_libelle, libelle, |
404 |
date_reception, |
405 |
TO_CHAR(date_envoi ,'DD/MM/YYYY') as date_envoi |
406 |
FROM ".DB_PREFIXE."consultation |
407 |
LEFT JOIN ".DB_PREFIXE."dossier |
408 |
ON dossier.dossier = consultation.dossier |
409 |
LEFT JOIN ".DB_PREFIXE."service |
410 |
ON service.service = consultation.service |
411 |
WHERE code_barres='".$code_barres."'"; |
412 |
$resInfo = $this->f->db->query($sqlInfo); |
413 |
$this->f->isDatabaseError($resInfo); |
414 |
$infos = $resInfo->fetchRow(DB_FETCHMODE_ASSOC); |
415 |
} |
416 |
} |
417 |
//C'est un autre type de consultation |
418 |
else{ |
419 |
$message_class = "error"; |
420 |
$message = _("Cette consultation n'a pas d'avis attendu."); |
421 |
} |
422 |
} |
423 |
else { |
424 |
$message_class = "error"; |
425 |
$message = _("Le numero saisi ne correspond a aucun code barres de consultation."); |
426 |
} |
427 |
} else { |
428 |
$message_class = "error"; |
429 |
$message = _("Tous les champs doivent etre remplis."); |
430 |
} |
431 |
} |
432 |
|
433 |
/** |
434 |
* Affichage des messages et du formulaire |
435 |
*/ |
436 |
// Affichage du message de validation ou d'erreur |
437 |
if (isset($message) && isset($message_class) && $message != "") { |
438 |
$this->f->displayMessage($message_class, $message); |
439 |
} |
440 |
// |
441 |
$datasubmit = $this->getDataSubmit(); |
442 |
// Inclusion de la classe de gestion des formulaires |
443 |
require_once "../obj/om_formulaire.class.php"; |
444 |
// Ouverture du formulaire |
445 |
printf("\t<form"); |
446 |
printf(" method=\"post\""); |
447 |
printf(" id=\"demandes_avis_mise_a_jour_des_dates_form\""); |
448 |
printf(" action=\"".$datasubmit."\""); |
449 |
printf(">\n"); |
450 |
// Paramétrage des champs du formulaire |
451 |
$champs = array("date", "code_barres"); |
452 |
if (isset($infos)) { |
453 |
array_push( |
454 |
$champs, |
455 |
"dossier_libelle", |
456 |
"service", |
457 |
"date_envoi", |
458 |
"date_reception", |
459 |
"is_valid" |
460 |
); |
461 |
} |
462 |
// Création d'un nouvel objet de type formulaire |
463 |
$form = new formulaire(null, 0, 0, $champs); |
464 |
// Paramétrage des champs du formulaire |
465 |
// Parametrage du champ date |
466 |
$form->setLib("date", _("Date")."* :"); |
467 |
if (isset($infos)) { |
468 |
$form->setType("date", "hiddenstaticdate"); |
469 |
} else { |
470 |
$form->setType("date", "date"); |
471 |
} |
472 |
$form->setVal("date", $date); |
473 |
$form->setTaille("date", 10); |
474 |
$form->setMax("date", 10); |
475 |
|
476 |
// Parametrage du champ code_barres |
477 |
$form->setLib("code_barres", _("Code barres de consultation")."* :"); |
478 |
if (isset($infos)) { |
479 |
$form->setType("code_barres", "hiddenstatic"); |
480 |
} else { |
481 |
$form->setType("code_barres", "text"); |
482 |
} |
483 |
$form->setVal("code_barres", $code_barres); |
484 |
$form->setTaille("code_barres", 20); |
485 |
$form->setMax("code_barres", 20); |
486 |
|
487 |
// Ajout des infos du dossier correspondantes à la consultation séléctionnée |
488 |
if (isset($infos)) { |
489 |
|
490 |
// Tous les champs sont défini par defaut à static |
491 |
foreach ($infos as $key => $value) { |
492 |
$form->setType($key, "static"); |
493 |
$form->setVal($key, $value); |
494 |
} |
495 |
|
496 |
// Les champs dont on vient de définir la valeur sont en gras |
497 |
$form->setBloc("date_reception", 'DF', "", 'bold'); |
498 |
|
499 |
// Parametrage du champ dossier |
500 |
$form->setLib("dossier_libelle", _("dossier_libelle")." :"); |
501 |
$form->setType("dossier_libelle", "static"); |
502 |
$form->setVal("dossier_libelle", $infos['dossier_libelle']); |
503 |
|
504 |
// Parametrage du champ service |
505 |
$form->setLib("service", _("service")." :"); |
506 |
$form->setType("service", "static"); |
507 |
$form->setVal("service", $infos['libelle']); |
508 |
|
509 |
// Parametrage des libellés d'envoi avec RAR |
510 |
$form->setLib("date_envoi", _("Envoi demande d'avis")." :"); |
511 |
$form->setLib("date_reception", _("Retour demande d'avis")." :"); |
512 |
$form->setVal("date_reception", $date); |
513 |
|
514 |
// Ajout d'un champ hidden permettant de savoir que le formulaire précédant est celui de vérification |
515 |
$form->setLib("is_valid", _("Valide")." :"); |
516 |
$form->setType("is_valid", "hidden"); |
517 |
$form->setVal("is_valid", 'true'); |
518 |
|
519 |
$form->setFieldset('dossier_libelle', 'D', _('Synthese')); |
520 |
$form->setFieldset('is_valid', 'F'); |
521 |
} |
522 |
|
523 |
|
524 |
// Création du fieldset regroupant les champs permettant la mise à jour des date |
525 |
$form->setFieldset('date', 'D', _('Mise a jour')); |
526 |
$form->setFieldset('code_barres', 'F'); |
527 |
// Affichage du formulaire |
528 |
$form->entete(); |
529 |
$form->afficher($champs, 0, false, false); |
530 |
$form->enpied(); |
531 |
// Affichage du bouton |
532 |
printf("\t<div class=\"formControls\">\n"); |
533 |
// |
534 |
if (!$date_error) { |
535 |
$this->f->layout->display_form_button( |
536 |
array("value" => _("Valider"), "name" => "validation") |
537 |
); |
538 |
} |
539 |
// Si pas sur l'écran de validation |
540 |
if (isset($infos)) { |
541 |
printf( |
542 |
'<a class="retour" href="%s&date=%s&code_barres=%s">Retour</a>', |
543 |
$datasubmit, |
544 |
$date, |
545 |
$code_barres |
546 |
); |
547 |
} |
548 |
printf("\t</div>\n"); |
549 |
// Fermeture du formulaire |
550 |
printf("\t</form>\n"); |
551 |
|
552 |
} |
553 |
|
554 |
/** |
555 |
* Défini si l'utilisateur est un intructeur qui en correspond à la division |
556 |
* du dossier. |
557 |
* |
558 |
* @return boolean true si correspond false sinon |
559 |
*/ |
560 |
function is_instructeur_from_division() { |
561 |
|
562 |
if ($this->f->isUserInstructeur() |
563 |
&& isset($this->f->om_utilisateur["division"]) |
564 |
&& $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier()) { |
565 |
// |
566 |
return false; |
567 |
} |
568 |
return true; |
569 |
} |
570 |
|
571 |
/** |
572 |
* Défini si l'utilisateur est de la cellule suivi. |
573 |
* |
574 |
* @return boolean true si correspond false sinon |
575 |
*/ |
576 |
function is_suivi_retours_de_consultation() { |
577 |
|
578 |
if($this->f->can_bypass("consultation", "modifier")){ |
579 |
return true; |
580 |
} |
581 |
|
582 |
return $this->f->isAccredited("consultation_suivi_retours_de_consultation"); |
583 |
} |
584 |
|
585 |
/** |
586 |
* Si le champ lu est à true l'action "Marquer comme lu" n'est pas affichée |
587 |
* |
588 |
* @return boolean true sinon lu false sinon |
589 |
*/ |
590 |
function show_marquer_comme_lu_portlet_action() { |
591 |
if (isset($this->val[array_search("lu", $this->champs)]) |
592 |
&& $this->val[array_search("lu", $this->champs)]== "t") { |
593 |
return false; |
594 |
} |
595 |
return true; |
596 |
} |
597 |
|
598 |
/** |
599 |
* Si le document est finalisé l'action "finaliser" n'est pas affichée |
600 |
* |
601 |
* @return boolean true sinon lu false sinon |
602 |
*/ |
603 |
function show_consultation_finaliser_portlet_action() { |
604 |
if ($this->is_document_finalized("om_final_consultation")) { |
605 |
return false; |
606 |
} |
607 |
return true; |
608 |
} |
609 |
|
610 |
/** |
611 |
* Retourne is_document_finalized("om_final_consultation") |
612 |
* |
613 |
* @return boolean true si finalisé false sinon |
614 |
*/ |
615 |
function show_unfinalize_portlet_action() { |
616 |
return $this->is_document_finalized("om_final_consultation"); |
617 |
} |
618 |
|
619 |
/** |
620 |
* Permet de savoir si le document passé en paramètre est finalisé |
621 |
* |
622 |
* @param string $field flag finalisé |
623 |
* |
624 |
* @return boolean true si finalisé false sinon |
625 |
*/ |
626 |
function is_document_finalized($field) { |
627 |
if($this->getVal($field) == 't') { |
628 |
return true; |
629 |
} |
630 |
return false; |
631 |
} |
632 |
|
633 |
/** |
634 |
* Si le dossier d'instruction auquel est rattachée la consultation est |
635 |
* cloturé, on affiche pas les liens du portlet. |
636 |
* |
637 |
* @return boolean true si non cloturé false sinon |
638 |
*/ |
639 |
function is_dossier_instruction_not_closed() { |
640 |
$idxformulaire = $this->getParameter("idxformulaire"); |
641 |
$retourformulaire = $this->getParameter("retourformulaire"); |
642 |
//Si le dossier d'instruction auquel est rattachée la consultation est |
643 |
//cloturé, on affiche pas les liens du portlet |
644 |
if ( $idxformulaire != '' && |
645 |
( |
646 |
$retourformulaire == 'dossier' || |
647 |
$retourformulaire == 'dossier_instruction' || |
648 |
$retourformulaire == 'dossier_instruction_mes_encours' || |
649 |
$retourformulaire == 'dossier_instruction_tous_encours' || |
650 |
$retourformulaire == 'dossier_instruction_mes_clotures' || |
651 |
$retourformulaire == 'dossier_instruction_tous_clotures' |
652 |
)){ |
653 |
|
654 |
//On récuppère le statut du dossier d'instruction |
655 |
$statut = $this->f->getStatutDossier($idxformulaire); |
656 |
if ( $this->f->isUserInstructeur() && $statut == "cloture" ){ |
657 |
return false; |
658 |
} |
659 |
} |
660 |
return true; |
661 |
} |
662 |
|
663 |
// {{{ Gestion de la confidentialité des données spécifiques |
664 |
|
665 |
/** |
666 |
* Cette méthode permet de récupérer le code de division correspondant |
667 |
* au dossier sur lequel on se trouve. |
668 |
* |
669 |
* @return string Code de la division du dossier en cours |
670 |
*/ |
671 |
function getDivisionFromDossier() { |
672 |
|
673 |
// Cette méthode peut être appelée plusieurs fois lors d'une requête. |
674 |
// Pour éviter de refaire le traitement de recherche de la division |
675 |
// alors on vérifie si nous ne l'avons pas déjà calculé. |
676 |
if ($this->_division_from_dossier != NULL) { |
677 |
// Logger |
678 |
$this->addToLog("getDivisionFromDossier(): retour de la valeur déjà calculée - '".$this->_division_from_dossier."'", EXTRA_VERBOSE_MODE); |
679 |
// On retourne la valeur déjà calculée |
680 |
return $this->_division_from_dossier; |
681 |
} |
682 |
|
683 |
// Par défaut, on définit la valeur du dossier à NULL |
684 |
$dossier = NULL; |
685 |
// Test sur le mode et le contexte du formulaire |
686 |
if (($this->getParameter("maj") == 0 or $this->getParameter("maj") == 40) |
687 |
&& ($this->getParameter("retourformulaire") == "dossier" |
688 |
|| $this->getParameter("retourformulaire") == "dossier_instruction" |
689 |
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_encours" |
690 |
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_encours" |
691 |
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_clotures" |
692 |
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_clotures")) { |
693 |
// Si on se trouve en mode AJOUT (seul mode où l'enregistrement |
694 |
// n'existe pas en base de données) ET que nous nous trouvons |
695 |
// dans le contexte d'un dossier d'instruction alors on récupère |
696 |
// le numéro de dossier depuis le paramètre 'idxformulaire' |
697 |
$dossier = $this->getParameter("idxformulaire"); |
698 |
} else { |
699 |
// Sinon on récupère le numéro de dossier dans le champs dossier de |
700 |
// l'enregistrement (en base de données) |
701 |
$dossier = $this->getVal("dossier"); |
702 |
} |
703 |
|
704 |
// On appelle la méthode de la classe utils qui renvoi le code de la |
705 |
// division d'un dossier, on la stocke pour ne pas refaire le calcul au |
706 |
// prochain appel de cette méthode |
707 |
$this->_division_from_dossier = $this->f->getDivisionFromDossier($dossier); |
708 |
// Logger |
709 |
$this->addToLog("getDivisionFromDossier(): retour de la valeur nouvellement calculée - '".$this->_division_from_dossier."'", EXTRA_VERBOSE_MODE); |
710 |
// On retourne la valeur retournée |
711 |
return $this->_division_from_dossier; |
712 |
|
713 |
} |
714 |
|
715 |
/** |
716 |
* |
717 |
*/ |
718 |
var $inst_service = null; |
719 |
|
720 |
/** |
721 |
* |
722 |
*/ |
723 |
function get_inst_service($service = null) { |
724 |
// |
725 |
if ($service !== null) { |
726 |
require_once "../obj/service.class.php"; |
727 |
return new service($service, $this->f->db, null); |
728 |
} |
729 |
// |
730 |
if ($this->inst_service !== null) { |
731 |
require_once "../obj/service.class.php"; |
732 |
$this->inst_service = new service($this->getVal('service'), $this->f->db, null); |
733 |
} |
734 |
return $this->inst_service; |
735 |
} |
736 |
|
737 |
/** |
738 |
* TREATMENT - marquer_comme_lu. |
739 |
* |
740 |
* Cette methode permet de passer la consultation en "lu" |
741 |
* |
742 |
* @return boolean true si maj effectué false sinon |
743 |
*/ |
744 |
function marquer_comme_lu() { |
745 |
// Cette méthode permet d'exécuter une routine en début des méthodes |
746 |
// dites de TREATMENT. |
747 |
$this->begin_treatment(__METHOD__); |
748 |
|
749 |
if($this->getVal("lu") == 'f') { |
750 |
$this->correct = true; |
751 |
$this->valF["lu"] = true; |
752 |
|
753 |
$res = $this->f->db->autoExecute( |
754 |
DB_PREFIXE.$this->table, |
755 |
$this->valF, |
756 |
DB_AUTOQUERY_UPDATE, |
757 |
$this->clePrimaire."=".$this->getVal($this->clePrimaire) |
758 |
); |
759 |
if ($this->f->isDatabaseError($res, true)) { |
760 |
// Appel de la methode de recuperation des erreurs |
761 |
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
762 |
$this->correct = false; |
763 |
// Termine le traitement |
764 |
return $this->end_treatment(__METHOD__, false); |
765 |
} else { |
766 |
$this->addToMessage(_("Mise a jour effectue avec succes")); |
767 |
return $this->end_treatment(__METHOD__, true); |
768 |
} |
769 |
|
770 |
} else { |
771 |
$this->addToMessage(_("Element deja marque comme lu")); |
772 |
} |
773 |
|
774 |
// Termine le traitement |
775 |
return $this->end_treatment(__METHOD__, false); |
776 |
} |
777 |
|
778 |
// }}} |
779 |
|
780 |
/** |
781 |
* TREATMENT - ajouter_multiple. |
782 |
* |
783 |
* Cette methode permet d'ajouter plusieurs consultations. |
784 |
* |
785 |
* @return boolean true si ajouts effectués false sinon |
786 |
*/ |
787 |
function ajouter_multiple() { |
788 |
// Cette méthode permet d'exécuter une routine en début des méthodes |
789 |
// dites de TREATMENT. |
790 |
$this->begin_treatment(__METHOD__); |
791 |
|
792 |
// Identifiant de l'objet metier a copier |
793 |
($this->f->get_submitted_get_value('idxformulaire') !== null ? $idx = $this->f->get_submitted_get_value('idxformulaire') : $idx = ""); |
794 |
// Nom de l'objet metier |
795 |
($this->f->get_submitted_get_value('obj') !== null ? $obj = $this->f->get_submitted_get_value('obj') : $obj = ""); |
796 |
//formulaire retour |
797 |
($this->f->get_submitted_get_value('ret') !== null ? $retourformulaire = $this->f->get_submitted_get_value('ret') : $retourformulaire = ""); |
798 |
($this->f->get_submitted_get_value('date_envoi') !== null ? $date_envoi = $this->f->get_submitted_get_value('date_envoi') : $date_envoi = ""); |
799 |
/*Récupération des données et formatage.*/ |
800 |
$donnees_temp = explode(';', $this->f->get_submitted_get_value('data')); |
801 |
for ( $i = 1 ; $i < count($donnees_temp) ; $i++ ) |
802 |
$donnees[] = explode('_', $donnees_temp[$i]); |
803 |
/* Nombre de consultations papier à générer */ |
804 |
$nbConsPap = 0; |
805 |
|
806 |
/* Ajout des données en base de données |
807 |
* 0 : l'ID du service |
808 |
* 1 : consultation papier {0,1} |
809 |
* */ |
810 |
if ( isset($donnees) && count($donnees) > 0 ) { |
811 |
|
812 |
foreach ($donnees as $value) { |
813 |
|
814 |
$sql = "SELECT delai, id, delai_type |
815 |
FROM ".DB_PREFIXE."service |
816 |
LEFT JOIN ".DB_PREFIXE."om_etat |
817 |
ON service.edition = om_etat.om_etat |
818 |
WHERE service = $value[0]"; |
819 |
$res = $this->f->db->query($sql); |
820 |
// Si la récupération de la description de l'avis échoue |
821 |
if ($this->f->isDatabaseError($res, true)) { |
822 |
// Appel de la methode de recuperation des erreurs |
823 |
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
824 |
$this->correct = false; |
825 |
// Termine le traitement |
826 |
$this->end_treatment(__METHOD__, false); |
827 |
} |
828 |
$row=& $res->fetchRow(); |
829 |
$delai = $row[0]; |
830 |
$type_edition = $row[1]; |
831 |
$delai_type = $row[2]; |
832 |
|
833 |
/*Calcul du delai de retour*/ |
834 |
$date_envoi_temp = $this->datePHP($date_envoi); |
835 |
$delai = $this->dateDB($this->f->mois_date($date_envoi_temp, $delai, "+", $delai_type)); |
836 |
|
837 |
/*Les données à ajouter*/ |
838 |
$arrayVal = array( |
839 |
'consultation' => "]", |
840 |
'dossier' => $idx, |
841 |
'date_envoi' => $date_envoi, |
842 |
'date_retour' => NULL, |
843 |
'date_limite' => $delai, |
844 |
'service' => $value[0], |
845 |
'avis_consultation' => NULL, |
846 |
'date_reception' => NULL, |
847 |
'motivation' => "", |
848 |
'fichier' => NULL, |
849 |
'lu' => TRUE, |
850 |
'code_barres' => NULL, |
851 |
'om_final_consultation' => false, |
852 |
'om_fichier_consultation' => '', |
853 |
'marque' => false, |
854 |
); |
855 |
|
856 |
$res_ajout = $this->ajouter($arrayVal, $this->f->db, DEBUG); |
857 |
if($res_ajout != true) { |
858 |
// Termine le traitement |
859 |
$this->end_treatment(__METHOD__, false); |
860 |
} |
861 |
|
862 |
/*Comptage du nombre de consultations papier demandées et récupération des ids des PDFs à éditer*/ |
863 |
if ($value[1]==1){ |
864 |
$idxConsultations[] = $this->valF['consultation']; |
865 |
$objConsultations[] = $type_edition; |
866 |
$nbConsPap++; |
867 |
} |
868 |
} |
869 |
|
870 |
/*Génération du PDF*/ |
871 |
if (isset($idxConsultations) && count($idxConsultations) > 0 ){ |
872 |
|
873 |
// Stockage de l'identifiant de chaque consultation dont on veut éditer la |
874 |
// version papier, séparés par un point-virgule |
875 |
$textIdsConsultations = ""; |
876 |
foreach ($idxConsultations as $value) { |
877 |
if ($textIdsConsultations != "") { |
878 |
$textIdsConsultations .= ";"; |
879 |
} |
880 |
$textIdsConsultations .= $value; |
881 |
} |
882 |
// Stockage de l'objet de chaque consultation dont on veut éditer la |
883 |
// version papier, séparés par un point-virgule |
884 |
$textObjConsultations = ""; |
885 |
foreach ($objConsultations as $value) { |
886 |
if ($textObjConsultations != "") { |
887 |
$textObjConsultations .= ";"; |
888 |
} |
889 |
$textObjConsultations .= $value; |
890 |
} |
891 |
|
892 |
// Ouverture du PDF dans une nouvelle fenêtre |
893 |
printf(" |
894 |
<script language='javascript' type='text/javascript'> |
895 |
window.open('%s','_blank') |
896 |
</script> |
897 |
", |
898 |
"../scr/form.php?obj=consultation&action=90&idx=0&textobj=".$textObjConsultations."&"."textids=".$textIdsConsultations |
899 |
); |
900 |
} |
901 |
$return_url = "../scr/soustab.php?"; |
902 |
$return_url .= "obj=consultation"; |
903 |
$return_url .= "&retourformulaire=".$this->getParameter("retourformulaire"); |
904 |
$return_url .= "&idxformulaire=".$this->getParameter("idxformulaire"); |
905 |
$return_url .= "&premier=".$this->getParameter("premiersf"); |
906 |
$return_url .= "&tricol=".$this->getParameter("tricolsf"); |
907 |
|
908 |
/*Affichage du message d'information*/ |
909 |
$this->f->displayMessage("valid", count($donnees)._(' service(s) selectionne(s) dont ').$nbConsPap._(' consultation(s) papier.')); |
910 |
|
911 |
|
912 |
// Termine le traitement |
913 |
return $this->end_treatment(__METHOD__, true); |
914 |
} |
915 |
} |
916 |
|
917 |
|
918 |
/** |
919 |
* VIEW - view_ajout_multiple. |
920 |
* |
921 |
* Formulaire specifique |
922 |
* |
923 |
* @return void |
924 |
*/ |
925 |
function view_ajout_multiple() { |
926 |
|
927 |
if (count($this->f->get_submitted_get_value()) > 0 |
928 |
&& $this->f->get_submitted_get_value('data') !== null |
929 |
&& $this->f->get_submitted_get_value('data') != "" ) { |
930 |
$this->f->disableLog(); |
931 |
$this->ajouter_multiple(); |
932 |
|
933 |
} else { |
934 |
|
935 |
// Vérification de l'accessibilité sur l'élément |
936 |
$this->checkAccessibility(); |
937 |
// |
938 |
$datasubmit = $this->getDataSubmitSousForm(); |
939 |
$return_url = "../scr/soustab.php?"; |
940 |
$return_url .= "obj=consultation"; |
941 |
$return_url .= "&retourformulaire=".$this->getParameter("retourformulaire"); |
942 |
$return_url .= "&idxformulaire=".$this->getParameter("idxformulaire"); |
943 |
$return_url .= "&premier=".$this->getParameter("premiersf"); |
944 |
$return_url .= "&tricol=".$this->getParameter("tricolsf"); |
945 |
// Légende du fieldset |
946 |
$title = _("Objet"); |
947 |
/*Requête qui récupère les services qui sont dans des thématiques*/ |
948 |
$sql = |
949 |
"SELECT |
950 |
ser_cat.service_categorie, |
951 |
ser_cat.libelle AS them_lib, |
952 |
ser.service, |
953 |
CONCAT(ser.abrege, ' - ', ser.libelle) AS ser_lib, |
954 |
ser.consultation_papier |
955 |
FROM |
956 |
".DB_PREFIXE."lien_service_service_categorie lie, |
957 |
".DB_PREFIXE."service_categorie ser_cat, |
958 |
".DB_PREFIXE."service ser |
959 |
LEFT JOIN ".DB_PREFIXE."om_collectivite |
960 |
ON ser.om_collectivite = om_collectivite.om_collectivite |
961 |
WHERE |
962 |
ser_cat.service_categorie = lie.service_categorie AND |
963 |
ser.service = lie.service AND |
964 |
( |
965 |
(ser.om_validite_debut IS NULL |
966 |
AND (ser.om_validite_fin IS NULL |
967 |
OR ser.om_validite_fin > CURRENT_DATE)) |
968 |
OR |
969 |
(ser.om_validite_debut <= CURRENT_DATE |
970 |
AND (ser.om_validite_fin IS NULL |
971 |
OR ser.om_validite_fin > CURRENT_DATE)) |
972 |
)"; |
973 |
|
974 |
// Si c'est un sous-formulaire de dossier d'instruction ou une de ses surcharges |
975 |
// mes encours, mes clôtures... |
976 |
$is_in_context_of_foreign_key = $this->is_in_context_of_foreign_key("dossier", $this->getParameter('retourformulaire')); |
977 |
if ($is_in_context_of_foreign_key == true) { |
978 |
|
979 |
// on recupère les services des multicollectivités et de celle |
980 |
// du DI |
981 |
require_once "../obj/dossier_instruction.class.php"; |
982 |
$di = new dossier_instruction($this->getParameter('idxformulaire'), $this->db, false); |
983 |
|
984 |
// |
985 |
$sql .= sprintf(" AND (om_collectivite.niveau = '2' OR ser.om_collectivite = %s) ", $di->getVal('om_collectivite')); |
986 |
} |
987 |
// |
988 |
$sql .= " ORDER BY them_lib, ser.abrege, ser.libelle"; |
989 |
|
990 |
$res = $this->f->db->query($sql); |
991 |
$this->f->addToLog( |
992 |
"app/consultation_multiple.php: db->query(\"".$sql."\")", VERBOSE_MODE |
993 |
); |
994 |
$this->f->isDatabaseError($res); |
995 |
|
996 |
$temp_ser_cat = 0; |
997 |
$liste_gauche = ""; |
998 |
|
999 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
1000 |
$name = $row['service_categorie'].'_'. |
1001 |
$row['service'].'_'. |
1002 |
(($row['consultation_papier'] == '' || $row['consultation_papier'] == 'f' ) ? '0' : '1' ).'_'; |
1003 |
// On change de thématique, donc rajoute le nom de la thématique |
1004 |
if ( $temp_ser_cat != $row['service_categorie'] ){ |
1005 |
|
1006 |
$temp_ser_cat = $row['service_categorie']; |
1007 |
$liste_gauche .= ' |
1008 |
<div id="them_'.$row['service_categorie'].'" class="liste_gauche_them" >'. |
1009 |
$row['them_lib']. |
1010 |
'</div> |
1011 |
<div |
1012 |
class="liste_gauche_service t'.$name.'" |
1013 |
id="t'.$name.'" > |
1014 |
'.$row['ser_lib'].' |
1015 |
<input class="t'.$name.'" type="checkbox" '.(($row['consultation_papier'] == '' || $row['consultation_papier'] == 'f' ) ? '' : 'checked="checked"' ).'/> |
1016 |
</div> |
1017 |
'; |
1018 |
} |
1019 |
|
1020 |
/*On est dans la même thématique*/ |
1021 |
else { |
1022 |
|
1023 |
$liste_gauche .= ' |
1024 |
<div |
1025 |
class="liste_gauche_service t'.$name.'" |
1026 |
id="t'.$name.'" > |
1027 |
'.$row['ser_lib'].' |
1028 |
<input class="t'.$name.'" type="checkbox" '.(($row['consultation_papier'] == '' || $row['consultation_papier'] == 'f' ) ? '' : 'checked="checked"' ).'/> |
1029 |
</div> |
1030 |
'; |
1031 |
} |
1032 |
|
1033 |
} |
1034 |
|
1035 |
/*Requête qui récupère les services qui ne sont pas dans une thématique*/ |
1036 |
$sql = |
1037 |
"SELECT service.service, |
1038 |
CONCAT(service.abrege, ' - ', service.libelle) AS ser_lib, |
1039 |
service.consultation_papier |
1040 |
FROM ".DB_PREFIXE."service |
1041 |
LEFT JOIN ".DB_PREFIXE."om_collectivite |
1042 |
ON service.om_collectivite = om_collectivite.om_collectivite |
1043 |
WHERE service NOT IN |
1044 |
( |
1045 |
SELECT service |
1046 |
FROM ".DB_PREFIXE."lien_service_service_categorie |
1047 |
) |
1048 |
AND |
1049 |
( |
1050 |
om_validite_fin <= CURRENT_DATE OR |
1051 |
om_validite_fin IS NULL |
1052 |
) |
1053 |
"; |
1054 |
|
1055 |
// Si c'est un sous-formulaire de dossier d'instruction ou une de ses surcharges |
1056 |
// mes encours, mes clôtures... |
1057 |
$is_in_context_of_foreign_key = $this->is_in_context_of_foreign_key("dossier", $this->getParameter('retourformulaire')); |
1058 |
if ($is_in_context_of_foreign_key == true) { |
1059 |
|
1060 |
// on recupère les services des multicollectivités et de celle |
1061 |
// du DI |
1062 |
require_once "../obj/dossier_instruction.class.php"; |
1063 |
$di = new dossier_instruction($this->getParameter('idxformulaire'), $this->db, false); |
1064 |
|
1065 |
// |
1066 |
$sql .= sprintf(" AND (om_collectivite.niveau = '2' OR service.om_collectivite = %s) ", $di->getVal('om_collectivite')); |
1067 |
} |
1068 |
|
1069 |
// Tri des services qui ne sont pas dans une thématique par ordre alphabétique |
1070 |
$sql .= " ORDER BY service.abrege, service.libelle"; |
1071 |
|
1072 |
|
1073 |
$res = $this->f->db->query($sql); |
1074 |
$this->f->isDatabaseError($res); |
1075 |
|
1076 |
if ($res->numrows() > 0) { |
1077 |
$liste_gauche .= ' |
1078 |
<div id="them_0" class="liste_gauche_them">Autres</div>'; |
1079 |
} |
1080 |
|
1081 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
1082 |
|
1083 |
/*Ajout de tous les services qui n'ont pas de thématique*/ |
1084 |
$name = '0_'. |
1085 |
$row['service'].'_'. |
1086 |
(($row['consultation_papier'] == '' || $row['consultation_papier'] == 'f' ) ? '0' : '1' ).'_'; |
1087 |
$liste_gauche .= ' |
1088 |
<div |
1089 |
class="liste_gauche_service t'.$name.'" |
1090 |
id="t'.$name.'" > |
1091 |
'.$row['ser_lib'].' |
1092 |
<input class="t'.$name.'" type="checkbox" '.(($row['consultation_papier'] == '' || $row['consultation_papier'] == 'f' ) ? '' : 'checked="checked"' ).'/> |
1093 |
</div> |
1094 |
'; |
1095 |
} |
1096 |
|
1097 |
/*Affichage du formulaire*/ |
1098 |
echo "\n<!-- ########## START DBFORM ########## -->\n"; |
1099 |
echo "<form"; |
1100 |
echo " method=\"post\""; |
1101 |
echo " name=\"f2\""; |
1102 |
echo " action=\"\""; |
1103 |
echo " id=\"form_val\""; |
1104 |
//echo " onsubmit=\"ajaxIt('consultation', '');return false;\""; |
1105 |
|
1106 |
//echo " onsubmit=\"affichersform('".$this->getParameter("objsf")."', '".$datasubmit."', this);\""; |
1107 |
echo ">\n"; |
1108 |
echo '<div class="formEntete ui-corner-all">'; |
1109 |
echo "<div>"; |
1110 |
echo '<div class="bloc">'; |
1111 |
echo "<fieldset class='cadre ui-corner-all ui-widget-content'>\n"; |
1112 |
echo "\t<legend class='ui-corner-all ui-widget-content ui-state-active'>". |
1113 |
_("Consultation par thematique ")."</legend>"; |
1114 |
echo "<div class='fieldsetContent' style='width:100%'>"; |
1115 |
echo '<div class="field-ser-them field-type-hiddenstatic">'; |
1116 |
echo '<div class="form-libelle">'; |
1117 |
echo '<label class="libelle-dossier" for="dossier">'; |
1118 |
echo _('dossier'); |
1119 |
echo '<span class="not-null-tag">*</span>'; |
1120 |
echo '</label>'; |
1121 |
echo '</div>'; |
1122 |
echo '<div class="form-content">'; |
1123 |
echo '<input class="champFormulaire" type="hidden" value="'.$this->getParameter("idxformulaire").'" name="dossier"/>'; |
1124 |
echo $this->getParameter("idxformulaire"); |
1125 |
echo '</div>'; |
1126 |
echo '</div>'; |
1127 |
/*Code du nouveau champ*/ |
1128 |
echo '<div class="field-ser-them ser-them">'; |
1129 |
echo '<div class="list-ser-them">'; |
1130 |
echo $liste_gauche; |
1131 |
echo '</div>'; |
1132 |
echo '<div class="button-ser-them">'; |
1133 |
echo '<ul>'; |
1134 |
echo '<li>'; |
1135 |
echo '<input type="button" value="'._("Ajouter").' >>" id="add-ser-them"/>'; |
1136 |
echo '</li>'; |
1137 |
echo '<li>'; |
1138 |
echo '<input type="button" value="<< '._("Supprimer").'" id="del-ser-them"/>'; |
1139 |
echo '</li>'; |
1140 |
echo '</ul>'; |
1141 |
echo '</div>'; |
1142 |
echo '<div class="list-sel-ser-them">'; |
1143 |
echo '<div class=\'row row_title\'>'; |
1144 |
echo '<div class=\'cell1 liste_droite_title list-sel-ser-them-title\'>'._('Service a consulter').'</div>'; |
1145 |
echo '<div class=\'cell2 liste_droite_title list-sel-ser-them-title\'>'._('Version papier').'</div>'; |
1146 |
echo '</div>'; |
1147 |
echo '</div>'; |
1148 |
echo '</div>'; |
1149 |
/* -- FIN --*/ |
1150 |
// Le champ de date d'envoi est visible seulement aux ayant-droits |
1151 |
if($this->f->isAccredited('consultation_saisir_date_envoi')) { |
1152 |
echo '<div class="field-ser-them field-type-date2">'; |
1153 |
} |
1154 |
else { |
1155 |
echo '<div class="field field-type-hiddendate">'; |
1156 |
} |
1157 |
echo '<div class="form-libelle">'; |
1158 |
echo '<label class="libelle-date_envoi" for="date_envoi">'; |
1159 |
echo _('date_envoi'); |
1160 |
echo '<span class="not-null-tag">*</span>'; |
1161 |
echo '</label>'; |
1162 |
echo '</div>'; |
1163 |
echo '<div class="form-content">'; |
1164 |
echo '<input id="date_envoi" class="champFormulaire datepicker" |
1165 |
type="text" onkeyup="" onchange="fdate(this);" |
1166 |
maxlength="10" size="12" value="'.date("d/m/Y").'" |
1167 |
name="date_envoi">'; |
1168 |
echo '</div>'; |
1169 |
echo '</div>'; |
1170 |
echo "</div>"; |
1171 |
echo "</fieldset>"; |
1172 |
echo '</div>'; |
1173 |
echo '</div>'; |
1174 |
echo '</div>'; |
1175 |
echo '<div class="formControls">'; |
1176 |
|
1177 |
echo '<div class="formControls">'; |
1178 |
echo "<input class=\"om-button ui-button ui-widget ui-state-default ui-corner-all\" |
1179 |
type=\"button\" |
1180 |
|
1181 |
value=\"Ajouter le(s) enregistrement(s) de la table : 'Consultation'\" |
1182 |
id=\"button_val\">"; |
1183 |
$this->retoursousformulaire( |
1184 |
$this->getParameter("idxformulaire"), |
1185 |
$this->getParameter("retourformulaire"), |
1186 |
null, |
1187 |
$this->getParameter("objsf"), |
1188 |
$this->getParameter("premiersf"), |
1189 |
$this->getParameter("tricolsf"), |
1190 |
$this->getParameter("validation"), |
1191 |
$this->getParameter("idx"), |
1192 |
$this->getParameter("maj"), |
1193 |
$this->getParameter("retour") |
1194 |
); |
1195 |
echo '</div>'; |
1196 |
echo '</div>'; |
1197 |
echo '</form>'; |
1198 |
|
1199 |
echo " |
1200 |
<script language='javascript' type='text/javascript'> |
1201 |
$(function(){ |
1202 |
changeActionVal(''); |
1203 |
/* |
1204 |
Sélectionne tous les services d'un thème au clique sur celui ci. |
1205 |
*/ |
1206 |
$('.liste_gauche_them').click( |
1207 |
function(){ |
1208 |
|
1209 |
var id = $(this).attr('id').split('_')[1]; |
1210 |
var numSer = 0; |
1211 |
var numSerWithClass = 0; |
1212 |
|
1213 |
$('.list-ser-them div').each( |
1214 |
function() { |
1215 |
|
1216 |
if ( $(this).attr('id').indexOf('them') == -1 && |
1217 |
$(this).attr('id').indexOf(id) == 1 && |
1218 |
$(this).hasClass('liste_gauche_service_selected') ) |
1219 |
|
1220 |
numSerWithClass++; |
1221 |
|
1222 |
if ( $(this).attr('id').indexOf('them') == -1 && |
1223 |
$(this).attr('id').indexOf(id) == 1 ) |
1224 |
|
1225 |
numSer++; |
1226 |
} |
1227 |
); |
1228 |
|
1229 |
if ( numSerWithClass < numSer && numSerWithClass >= 0 ){ |
1230 |
|
1231 |
$('.list-ser-them div').each( |
1232 |
function() { |
1233 |
|
1234 |
if ( $(this).attr('id').indexOf('them') == -1 && |
1235 |
$(this).attr('id').indexOf(id) == 1 && |
1236 |
!$(this).hasClass('liste_gauche_service_selected') ) |
1237 |
|
1238 |
$(this).addClass('liste_gauche_service_selected'); |
1239 |
} |
1240 |
); |
1241 |
} |
1242 |
|
1243 |
else { |
1244 |
|
1245 |
$('.list-ser-them div').each( |
1246 |
function() { |
1247 |
|
1248 |
if ( $(this).attr('id').indexOf('them') == -1 && |
1249 |
$(this).attr('id').indexOf(id) == 1 && |
1250 |
$(this).hasClass('liste_gauche_service_selected') ) |
1251 |
|
1252 |
$(this).removeClass('liste_gauche_service_selected'); |
1253 |
} |
1254 |
); |
1255 |
} |
1256 |
} |
1257 |
); |
1258 |
|
1259 |
/* |
1260 |
Change la class CSS d'un service sur lequel on clique dans la liste de gauche. |
1261 |
*/ |
1262 |
$('.liste_gauche_service').click( |
1263 |
function(){ |
1264 |
$(this).toggleClass('liste_gauche_service_selected'); |
1265 |
} |
1266 |
); |
1267 |
|
1268 |
/* |
1269 |
Change la class CSS d'un service sur lequel on clique dans la liste de droite. |
1270 |
*/ |
1271 |
$('.field-ser-them').on( |
1272 |
'click', |
1273 |
'.cell1', |
1274 |
function(){ |
1275 |
if ( !$(this).hasClass('liste_droite_title') ) |
1276 |
$(this).parent().toggleClass('liste_droite_service_selected'); |
1277 |
} |
1278 |
); |
1279 |
|
1280 |
$('.liste_droite_service input[type=checkbox]').live( |
1281 |
'click', |
1282 |
'input[type=checkbox]', |
1283 |
function(){ |
1284 |
|
1285 |
old_id = $(this).attr('class'); |
1286 |
|
1287 |
tab_don = old_id.split('_'); |
1288 |
|
1289 |
new_id = tab_don[0] + '_' + tab_don[1] + '_' + ((tab_don[2] == 0 ) ? 1 : 0 ) + '_'; |
1290 |
|
1291 |
changeOneData( ';' + tab_don[1] + '_' + tab_don[2], ';' + tab_don[1] + '_' + ((tab_don[2] == 0) ? 1 : 0) ); |
1292 |
$('div[class=\"' + old_id + '\"]').attr('class', new_id); |
1293 |
$(this).attr('class', new_id); |
1294 |
|
1295 |
} |
1296 |
); |
1297 |
|
1298 |
$('#date_envoi').change( |
1299 |
function (){ |
1300 |
|
1301 |
var listServ = new Array(); |
1302 |
var data = ''; |
1303 |
|
1304 |
$('.liste_gauche_service_selected').each( |
1305 |
function(i) { |
1306 |
|
1307 |
var id = $(this).attr('id'); |
1308 |
|
1309 |
if ( listServ.length > 0 && listServ.indexOf(id.split('_')[1]) != -1 ) |
1310 |
return; |
1311 |
listServ[i] = id.split('_')[1]; |
1312 |
data += ';' + id.split('_')[1] + '_' + id.split('_')[2] ; |
1313 |
|
1314 |
} |
1315 |
); |
1316 |
|
1317 |
changeActionVal(data); |
1318 |
} |
1319 |
); |
1320 |
|
1321 |
/* |
1322 |
Passe les services sélectionnés dans la liste de gauche dans celle de droite. |
1323 |
*/ |
1324 |
$('#add-ser-them').click( |
1325 |
function() { |
1326 |
|
1327 |
changeDataLeftColumn(); |
1328 |
} |
1329 |
); |
1330 |
|
1331 |
/* |
1332 |
Passe les services sélectionnés dans la liste de droite dans celle de gauche. |
1333 |
*/ |
1334 |
$('#del-ser-them').click( |
1335 |
function() { |
1336 |
|
1337 |
var data = ''; |
1338 |
|
1339 |
//Supprime les éléments de la liste de droite |
1340 |
$('.liste_droite_service_selected').each( |
1341 |
function() { |
1342 |
|
1343 |
var name = $('#'+ $(this).attr('id') + ' .cell1 div').attr('name'); |
1344 |
|
1345 |
manageListServ('.list-ser-them div', name, 1); |
1346 |
|
1347 |
$(this).remove(); |
1348 |
} |
1349 |
); |
1350 |
|
1351 |
//Change les valeurs qui vont être renvoyées à la validation du formulaire |
1352 |
$('.liste_droite_service').each( |
1353 |
function(){ |
1354 |
|
1355 |
var name = $('#'+ $(this).attr('id') + ' .cell1 div').attr('name'); |
1356 |
data += ';' + name.split('_')[1] + '_' + name.split('_')[2] ; |
1357 |
} |
1358 |
); |
1359 |
|
1360 |
changeActionVal(data); |
1361 |
} |
1362 |
); |
1363 |
}); |
1364 |
|
1365 |
/* |
1366 |
Vérifie que l'objet n'est pas une thématique et que son identifiant correspond. |
1367 |
*/ |
1368 |
function isNotthemIsOneServ( objet, id ){ |
1369 |
return ( $(objet).attr('id').indexOf('them') == -1 && |
1370 |
$(objet).attr('id').indexOf('_' + id.split('_')[1] + '_') != -1 ); |
1371 |
} |
1372 |
|
1373 |
/* |
1374 |
Affiche ou cache un élément qui n'est pas une thématique et dont son identifiant correspond. |
1375 |
*/ |
1376 |
function manageListServ( objet , name, type){ |
1377 |
|
1378 |
$(objet).each( |
1379 |
function() { |
1380 |
|
1381 |
if ( isNotthemIsOneServ(this, name) ){ |
1382 |
if ( type == 0 ) |
1383 |
|
1384 |
$(this).hide() ; |
1385 |
|
1386 |
else { |
1387 |
|
1388 |
if ( $(this).hasClass('liste_gauche_service_selected') ) |
1389 |
|
1390 |
$(this).toggleClass('liste_gauche_service_selected'); |
1391 |
|
1392 |
$(this).show() ; |
1393 |
|
1394 |
} |
1395 |
} |
1396 |
} |
1397 |
); |
1398 |
} |
1399 |
|
1400 |
/* |
1401 |
Change les actions qui sont réalisées lors de la soumission du formulaire |
1402 |
*/ |
1403 |
function changeActionVal(data){ |
1404 |
date = $('#date_envoi').val(); |
1405 |
|
1406 |
|
1407 |
|
1408 |
$('#button_val').attr( |
1409 |
'onclick', |
1410 |
'if ( $(\'.liste_gauche_service_selected\').length > 0 && $(\'#date_envoi\').val() != \'\' ) { messageIt(\'consultation\', \'".html_entity_decode($datasubmit)."&data='+data+'&date_envoi='+date+'\',true);' + |
1411 |
'messageIt(\'consultation\', \'".html_entity_decode($return_url)."\',false);} else alert(\'Veuillez choisir au moins un service et une date d envoi\');' |
1412 |
|
1413 |
); |
1414 |
|
1415 |
} |
1416 |
|
1417 |
/* |
1418 |
Change les actions qui sont réalisées lors de la soumission du formulaire |
1419 |
*/ |
1420 |
function changeOneData( oldData, newData) { |
1421 |
|
1422 |
date = $('#date_envoi').val(); |
1423 |
|
1424 |
$('#button_val').attr( |
1425 |
'onclick', |
1426 |
$('#button_val').attr('onclick').replace(oldData,newData) |
1427 |
); |
1428 |
|
1429 |
} |
1430 |
|
1431 |
function changeDataLeftColumn(){ |
1432 |
|
1433 |
$('.list-sel-ser-them').empty(); |
1434 |
$('.list-sel-ser-them').html( |
1435 |
'<div class=\"row row_title\">' + |
1436 |
'<div class=\"cell1 liste_droite_title list-sel-ser-them-title\">"._("Service a consulter")."</div>' + |
1437 |
'<div class=\"cell2 liste_droite_title list-sel-ser-them-title\">"._("Version papier")."</div>' + |
1438 |
'</div>' |
1439 |
); |
1440 |
|
1441 |
var listServ = new Array(); |
1442 |
var data = ''; |
1443 |
|
1444 |
$('.liste_gauche_service_selected').each( |
1445 |
function(i) { |
1446 |
|
1447 |
var id = $(this).attr('id'); |
1448 |
|
1449 |
if ( $.inArray(id.split('_')[1], listServ) != -1 ) |
1450 |
return; |
1451 |
|
1452 |
data += ';' + id.split('_')[1] + '_' + id.split('_')[2] ; |
1453 |
listServ[i] = id.split('_')[1]; |
1454 |
|
1455 |
$('.list-sel-ser-them').append( |
1456 |
'<div id=\'s' + i + '\' class=\'row liste_droite_service\'>'+ |
1457 |
'<div class=\'cell1\'>'+ |
1458 |
'<div class=\'' + $(this).attr('id') + '\' name=\'' + $(this).attr('id') + '\'>'+ |
1459 |
$(this).html().split('<')[0]+ |
1460 |
'</div>'+ |
1461 |
'</div>' + |
1462 |
'<div class=\'cell2\'>'+ |
1463 |
'<div>'+ |
1464 |
'<input class=\'' + $(this).attr('id') + '\''+$(this).html().split('<input')[1]+ |
1465 |
'</div>'+ |
1466 |
'</div>'+ |
1467 |
'</div>' |
1468 |
); |
1469 |
|
1470 |
$(this).hide(); |
1471 |
|
1472 |
manageListServ('.list-ser-them div', id, 0); |
1473 |
|
1474 |
} |
1475 |
); |
1476 |
changeActionVal(data); |
1477 |
} |
1478 |
</script>"; |
1479 |
} |
1480 |
} |
1481 |
|
1482 |
|
1483 |
/** |
1484 |
* TREATMENT - view_bordereau_envoi_maire. |
1485 |
* |
1486 |
* Génère et affiche l'édition PDF contenant une ou plusieurs consultations. |
1487 |
* |
1488 |
* @return [void] |
1489 |
*/ |
1490 |
function generate_pdf_consultation_multiple() { |
1491 |
// Vérification de l'accessibilité sur l'élément |
1492 |
$this->checkAccessibility(); |
1493 |
// Récupération de la collectivité du dossier d'instruction |
1494 |
$collectivite = $this->f->getCollectivite($this->get_dossier_collectivite()); |
1495 |
// Identifiants des consultations à afficher |
1496 |
$idsConsultations = $this->f->get_submitted_get_value('textids'); |
1497 |
// Type de chaque consultations (avec_avis_attendu, ...) |
1498 |
$objConsultations = $this->f->get_submitted_get_value('textobj'); |
1499 |
// Génération du PDF |
1500 |
$result = $this->compute_pdf_output('etat', $objConsultations, $collectivite, $idsConsultations); |
1501 |
// Affichage du PDF |
1502 |
$this->expose_pdf_output( |
1503 |
$result['pdf_output'], |
1504 |
$result['filename'] |
1505 |
); |
1506 |
} |
1507 |
|
1508 |
|
1509 |
function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire){ |
1510 |
// ajout du retourformulaire aux attributs de l'objet |
1511 |
$this->retourformulaire = $retourformulaire; |
1512 |
if ($validation==0) { |
1513 |
if ($maj == 0 or $maj == 40){ |
1514 |
$form->setVal("dossier", $idxformulaire); |
1515 |
$form->setVal("date_envoi",date('d/m/Y')); |
1516 |
} |
1517 |
if($maj == 1 or $maj == 90 or $maj == 100) { |
1518 |
if($this->f->isAccredited('consultation_retour_avis_suivi') OR |
1519 |
$this->f->isAccredited('consultation_retour_avis_service')) { |
1520 |
$form->setVal("date_retour",date('d/m/Y')); |
1521 |
} |
1522 |
} |
1523 |
} |
1524 |
} |
1525 |
|
1526 |
function setVal(&$form, $maj, $validation) { |
1527 |
if($maj == 1 or $maj == 90 or $maj == 100) { |
1528 |
$form->setVal("date_retour",date('d/m/Y')); |
1529 |
} |
1530 |
} |
1531 |
|
1532 |
function setvalF($val) { |
1533 |
// |
1534 |
parent::setValF($val); |
1535 |
// |
1536 |
if ($this->getParameter('maj') == 0 or $this->getParameter('maj') == 40) { |
1537 |
// |
1538 |
if (isset($this->valF["date_envoi"])) { |
1539 |
$this->valF["date_reception"] = $this->valF["date_envoi"]; |
1540 |
} |
1541 |
// |
1542 |
$this->valF["lu"] = true; |
1543 |
} |
1544 |
|
1545 |
// Si un retour d'avis est modifie on passe "lu" a false |
1546 |
if(($this->getParameter('maj')==90 or $this->getParameter('maj')==100 ) and ( |
1547 |
$this->val[array_search("avis_consultation",$this->champs)] != $val["avis_consultation"] OR |
1548 |
$this->val[array_search("date_retour",$this->champs)] != $val["date_retour"] OR |
1549 |
$this->val[array_search("motivation",$this->champs)] != $val["motivation"] OR |
1550 |
$this->val[array_search("fichier",$this->champs)] != $val["fichier"]) |
1551 |
) { |
1552 |
$this->valF["lu"]=false; |
1553 |
} |
1554 |
} |
1555 |
|
1556 |
function setLib(&$form, $maj) { |
1557 |
// |
1558 |
parent::setLib($form, $maj); |
1559 |
// |
1560 |
$form->setLib($this->clePrimaire, _("id")); |
1561 |
} |
1562 |
|
1563 |
function setType(&$form,$maj) { |
1564 |
// Appel du parent |
1565 |
parent::setType($form,$maj); |
1566 |
$form->setType('dossier', 'hidden'); |
1567 |
$form->setType('marque', 'hidden'); |
1568 |
// MODE - AJOUTER |
1569 |
if ($maj == 0) { |
1570 |
// On cache alors tous les champs que nous ne voulons pas voir |
1571 |
// apparaître dans le formulaire d'ajout (principalement les |
1572 |
// informations sur le retour d'avis) |
1573 |
$form->setType('date_retour', 'hiddendate'); |
1574 |
$form->setType('date_reception', 'hiddendate'); |
1575 |
$form->setType('date_limite', 'hiddendate'); |
1576 |
$form->setType('avis_consultation', 'hidden'); |
1577 |
$form->setType('motivation', 'hidden'); |
1578 |
$form->setType('fichier', 'hidden'); |
1579 |
$form->setType('lu', 'hidden'); |
1580 |
// On permet la modification de certains champs |
1581 |
$form->setType('dossier_libelle', 'hiddenstatic'); |
1582 |
$form->setType('service', 'select'); |
1583 |
// Le champ "date d'envoi" est affiché seulement si l'utilisateur a la |
1584 |
// permission |
1585 |
if($this->f->isAccredited('consultation_saisir_date_envoi')) { |
1586 |
$form->setType('date_envoi', 'date2'); |
1587 |
} |
1588 |
else { |
1589 |
$form->setType('date_envoi', 'hiddendate'); |
1590 |
} |
1591 |
} |
1592 |
// MODE - MODIFIER |
1593 |
if ($maj == 1) { |
1594 |
|
1595 |
// On affiche en statique les informations qui ne sont plus |
1596 |
// modifiables |
1597 |
$form->setType('dossier_libelle', 'hiddenstatic'); |
1598 |
$form->setType('date_envoi', 'hiddenstaticdate'); |
1599 |
$form->setType('date_limite', 'hiddenstaticdate'); |
1600 |
$form->setType('service', 'selecthiddenstatic'); |
1601 |
|
1602 |
// La date de réception ne peut être modifiée que par un |
1603 |
// utilisateur en ayant spécifiquement la permission |
1604 |
if($this->f->isAccredited('consultation_modifier_date_reception')) { |
1605 |
$form->setType('date_reception', 'date2'); |
1606 |
} else { |
1607 |
$form->setType('date_reception', 'hiddenstaticdate'); |
1608 |
} |
1609 |
|
1610 |
// Le marqueur lu/non lu ne peut être modifié que par un |
1611 |
// utilisateur en ayant spécifiquement la permission |
1612 |
if ($this->f->isAccredited('consultation_modifier_lu')) { |
1613 |
$form->setType('lu', 'checkbox'); |
1614 |
} else { |
1615 |
$form->setType('lu', 'hidden'); |
1616 |
} |
1617 |
|
1618 |
// Gestion du type du widget sur le champ fichier |
1619 |
if($this->getVal("fichier") == "" OR |
1620 |
$this->f->isAccredited('consultation_modifier_fichier')) { |
1621 |
// Si il n'y a jamais eu de fichier enregistré ou que |
1622 |
// l'utilisateur a spécifiquement les droits pour modifier |
1623 |
// un fichier déjà enregistré alors on positionne un type |
1624 |
// de widget modifiable |
1625 |
if ($this->retourformulaire == "demande_avis_encours" |
1626 |
|| $this->retourformulaire == "dossier_qualifier" |
1627 |
|| $this->retourformulaire == "dossier" |
1628 |
|| $this->retourformulaire == "dossier_instruction" |
1629 |
|| $this->retourformulaire == "dossier_instruction_mes_encours" |
1630 |
|| $this->retourformulaire == "dossier_instruction_tous_encours" |
1631 |
|| $this->retourformulaire == "dossier_instruction_mes_clotures" |
1632 |
|| $this->retourformulaire == "dossier_instruction_tous_clotures") { |
1633 |
$form->setType('fichier', 'upload2'); |
1634 |
} else { |
1635 |
$form->setType('fichier', 'upload'); |
1636 |
} |
1637 |
} else { |
1638 |
// Si non on affiche uniquement le nom du fichier |
1639 |
$form->setType('fichier', 'filestaticedit'); |
1640 |
} |
1641 |
|
1642 |
} |
1643 |
// Mode supprimer |
1644 |
if ($maj == 2) { |
1645 |
$form->setType('fichier', 'filestatic'); |
1646 |
} |
1647 |
// MODE - CONSULTER |
1648 |
if ( $maj == 3 ) { |
1649 |
$form->setType('fichier', 'file'); |
1650 |
} |
1651 |
// Mode - retour d'avis |
1652 |
// Modification layout : écran de retour d'avis permettant |
1653 |
// uniquement la saisie des trois champs : avis, motivation et fichier |
1654 |
if ( $maj == 90 ) { |
1655 |
|
1656 |
$form->setType("consultation", "hiddenstatic"); |
1657 |
if ($this->is_in_context_of_foreign_key("avis_consultation", $this->retourformulaire)) { |
1658 |
$form->setType("avis_consultation", "selecthiddenstatic"); |
1659 |
} else { |
1660 |
$form->setType("avis_consultation", "select"); |
1661 |
} |
1662 |
$form->setType("motivation", "textarea"); |
1663 |
$form->setType('fichier', 'upload2'); |
1664 |
|
1665 |
// On cache alors tous les champs que nous ne voulons pas voir |
1666 |
$form->setType('dossier_libelle', 'hidden'); |
1667 |
$form->setType('service', 'hidden'); |
1668 |
$form->setType('date_envoi', 'hiddendate'); |
1669 |
$form->setType('date_retour', 'hiddendate'); |
1670 |
$form->setType('date_reception', 'hiddendate'); |
1671 |
$form->setType('date_limite', 'hiddendate'); |
1672 |
$form->setType('lu', 'hidden'); |
1673 |
} |
1674 |
|
1675 |
// MODE - retour de consultation par suivi des date |
1676 |
if ($maj == 100) { |
1677 |
$form->setType("consultation", "hiddenstatic"); |
1678 |
$form->setType('dossier_libelle', 'hiddenstatic'); |
1679 |
$form->setType('date_envoi', 'hiddenstaticdate'); |
1680 |
$form->setType('date_limite', 'hiddenstaticdate'); |
1681 |
$form->setType('date_reception', 'hiddenstaticdate'); |
1682 |
$form->setType('service', 'selecthiddenstatic'); |
1683 |
$form->setType('date_retour', 'date'); |
1684 |
$form->setType('lu', 'hidden'); |
1685 |
$form->setType("avis_consultation", "select"); |
1686 |
$form->setType("motivation", "textarea"); |
1687 |
$form->setType('fichier', 'upload'); |
1688 |
} |
1689 |
//// On cache la clé primaire |
1690 |
//$form->setType('consultation', 'hidden'); |
1691 |
// |
1692 |
if ($this->getParameter("retourformulaire") == "dossier" |
1693 |
|| $this->getParameter("retourformulaire") == "dossier_instruction" |
1694 |
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_encours" |
1695 |
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_encours" |
1696 |
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_clotures" |
1697 |
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_clotures") { |
1698 |
// |
1699 |
$form->setType('dossier_libelle', 'hidden'); |
1700 |
} |
1701 |
|
1702 |
$form->setType('code_barres', 'hidden'); |
1703 |
|
1704 |
//Cache les champs pour la finalisation |
1705 |
$form->setType('om_fichier_consultation', 'hidden'); |
1706 |
$form->setType('om_final_consultation', 'hidden'); |
1707 |
|
1708 |
if($maj == 50 or $maj == 60 or $maj == 70) { |
1709 |
foreach ($this->champs as $value) { |
1710 |
$form->setType($value, 'hidden'); |
1711 |
} |
1712 |
} |
1713 |
} |
1714 |
|
1715 |
// Cette méthode permet de calculer la date limite en fonction de la date |
1716 |
// de réception et du délai de consultation du service consulté |
1717 |
function calculDateLimite() { |
1718 |
// mise a jour instruction avec evenement [return delay] |
1719 |
if ($this->valF["date_reception"] != "") { |
1720 |
// |
1721 |
$sql = " select delai from ".DB_PREFIXE."service "; |
1722 |
$sql .= " where service='".$this->valF["service"]."' "; |
1723 |
$delai = $this->db->getOne($sql); |
1724 |
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
1725 |
// |
1726 |
$sql = " select delai_type from ".DB_PREFIXE."service "; |
1727 |
$sql .= " where service='".$this->valF["service"]."' "; |
1728 |
$delai_type = $this->db->getOne($sql); |
1729 |
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
1730 |
// |
1731 |
$this->valF["date_limite"] = $this->f->mois_date($this->valF["date_reception"], $delai, "+", $delai_type); |
1732 |
// |
1733 |
if ($delai_type == "mois") { |
1734 |
$delai_type_trad = _("mois"); |
1735 |
} else { |
1736 |
$delai_type_trad = _("jour(s)"); |
1737 |
} |
1738 |
// |
1739 |
$this->addToMessage(_("delai")." ". |
1740 |
_("retour")." ".$delai." ".$delai_type_trad." -> ". |
1741 |
_("retour")." ".date("d/m/Y", strtotime($this->valF["date_limite"]))); |
1742 |
} |
1743 |
} |
1744 |
|
1745 |
// TRIGGER AVANT MODIFICATION DE DONNEES |
1746 |
// trigger before modification data |
1747 |
function triggerajouter($id,&$db,$val,$DEBUG) { |
1748 |
// |
1749 |
$this->calculDateLimite(); |
1750 |
|
1751 |
// Identifiant du type de courrier |
1752 |
$idTypeCourrier = '12'; |
1753 |
$idCourrier = str_pad($this->valF["consultation"], 10, "0", STR_PAD_LEFT); |
1754 |
// Code barres |
1755 |
$this->valF["code_barres"] = $idTypeCourrier . $idCourrier; |
1756 |
} |
1757 |
|
1758 |
// |
1759 |
function triggermodifier($id,&$db,$val,$DEBUG) { |
1760 |
// |
1761 |
$this->calculDateLimite(); |
1762 |
} |
1763 |
|
1764 |
// |
1765 |
function triggerajouterapres($id,&$db,$val,$DEBUG) { |
1766 |
|
1767 |
// Verification de la demande de notif par mail |
1768 |
$sql= "SELECT abrege, libelle, notification_email, email FROM ".DB_PREFIXE. |
1769 |
"service WHERE service ='".$this->valF['service']."'"; |
1770 |
$res=$db->query($sql); |
1771 |
$notif = $res->fetchrow(DB_FETCHMODE_ASSOC); |
1772 |
if (database :: isError($sql))die($res->getMessage()."erreur ".$sql); |
1773 |
if ($notif['notification_email']=='t') { |
1774 |
|
1775 |
// Recuperation des infos du dossier |
1776 |
$sql= "SELECT dossier, terrain_adresse_voie_numero, terrain_adresse_voie, terrain_adresse_code_postal, terrain_adresse_localite |
1777 |
FROM ".DB_PREFIXE."dossier WHERE dossier ='".$this->valF['dossier']."'"; |
1778 |
$res=$db->query($sql); |
1779 |
$dossier = $res->fetchrow(DB_FETCHMODE_ASSOC); |
1780 |
|
1781 |
// Definition des parametres d'envoi du mail |
1782 |
$title=_("Consultation de services : dossier no")." ".$dossier['dossier']; |
1783 |
$corps=_("Votre service est consulte concernant le dossier no")." ".$dossier['dossier']."<br/>". |
1784 |
_("Il concerne le terrain situe a l'adresse :")." ".$dossier['terrain_adresse_voie_numero']. |
1785 |
" ".$dossier['terrain_adresse_voie']." ".$dossier['terrain_adresse_code_postal']." ".$dossier['terrain_adresse_localite']."<br/>". |
1786 |
_("Vous pouvez y acceder et rendre votre avis a l'adresse")." <a href='".$this->f->getParameter('services_consultes_lien_interne'). |
1787 |
// On ajoute l'idx, s'il y a besoin |
1788 |
((substr($this->f->getParameter('services_consultes_lien_interne'), -5)=="&idx=")?$this->valF['consultation']:"")."'>". |
1789 |
_("Lien interne")."</a> "._("ou")." <a href='".$this->f->getParameter('services_consultes_lien_externe'). |
1790 |
// On ajoute l'idx, s'il y a besoin |
1791 |
((substr($this->f->getParameter('services_consultes_lien_externe'), -5)=="&idx=")?$this->valF['consultation']:"")."'>". |
1792 |
_("Lien externe")."</a>"; |
1793 |
// Envoi du mail avec message de retour |
1794 |
if($this->f->sendMail(iconv("UTF-8", "CP1252", $title), iconv("UTF-8", "CP1252", $corps), iconv("UTF-8", "CP1252", $notif['email']))) { |
1795 |
$this->addToMessage(_("Envoi d'un mail de notification au service")." \"(".$notif['abrege'].") ".$notif["libelle"]."\""); |
1796 |
} else { |
1797 |
$this->addToMessage(_("L'envoi du mail de notification a echoue")); |
1798 |
} |
1799 |
} |
1800 |
|
1801 |
/** |
1802 |
* Interface avec le référentiel ERP. |
1803 |
* |
1804 |
* (WS->ERP)[104] Demande d'instruction de dossier PC pour un ERP -> PC |
1805 |
* |
1806 |
* |
1807 |
* envoi du message "Demande d'instruction d'un dossier PC pour un ERP" |
1808 |
*/ |
1809 |
// |
1810 |
if ($this->f->is_option_referentiel_erp_enabled() === true |
1811 |
&& $this->f->getDATCode($this->valF['dossier']) == $this->f->getParameter('erp__dossier__nature__pc') |
1812 |
&& in_array($this->valF['service'], explode(";", $this->f->getParameter('erp__services__avis__pc')))) { |
1813 |
// |
1814 |
$inst_service = $this->get_inst_service($this->valF['service']); |
1815 |
// |
1816 |
$infos = array( |
1817 |
"dossier_instruction" => $this->valF['dossier'], |
1818 |
"consultation" => $this->valF['consultation'], |
1819 |
"date_envoi" => $this->valF['date_envoi'], |
1820 |
"service_abrege" => $inst_service->getVal('abrege'), |
1821 |
"service_libelle" => $inst_service->getVal('libelle'), |
1822 |
); |
1823 |
// |
1824 |
$ret = $this->f->send_message_to_referentiel_erp(104, $infos); |
1825 |
if ($ret !== true) { |
1826 |
$this->cleanMessage(); |
1827 |
$this->addToMessage(_("Une erreur s'est produite lors de la notification (104) du référentiel ERP. Contactez votre administrateur.")); |
1828 |
return false; |
1829 |
} else { |
1830 |
$this->addToMessage(_("Notification (104) du référentiel ERP OK.")); |
1831 |
} |
1832 |
} |
1833 |
|
1834 |
/** |
1835 |
* Interface avec le référentiel ERP. |
1836 |
* |
1837 |
* (WS->ERP)[106] Consultation ERP pour conformité -> PC |
1838 |
* |
1839 |
* envoi du message "Consultation ERP pour conformite" en cas de creation de la |
1840 |
* consultation du service ERP Conformite |
1841 |
*/ |
1842 |
// |
1843 |
if ($this->f->is_option_referentiel_erp_enabled() === true |
1844 |
&& $this->f->getDATCode($this->valF['dossier']) == $this->f->getParameter('erp__dossier__nature__pc') |
1845 |
&& in_array($this->valF['service'], explode(";", $this->f->getParameter('erp__services__conformite__pc')))) { |
1846 |
// |
1847 |
$inst_service = $this->get_inst_service($this->valF['service']); |
1848 |
// |
1849 |
$infos = array( |
1850 |
"dossier_instruction" => $this->valF['dossier'], |
1851 |
"consultation" => $this->valF['consultation'], |
1852 |
"date_envoi" => $this->valF['date_envoi'], |
1853 |
"service_abrege" => $inst_service->getVal('abrege'), |
1854 |
"service_libelle" => $inst_service->getVal('libelle'), |
1855 |
); |
1856 |
// |
1857 |
$ret = $this->f->send_message_to_referentiel_erp(106, $infos); |
1858 |
if ($ret !== true) { |
1859 |
$this->cleanMessage(); |
1860 |
$this->addToMessage(_("Une erreur s'est produite lors de la notification (106) du référentiel ERP. Contactez votre administrateur.")); |
1861 |
return false; |
1862 |
} else { |
1863 |
$this->addToMessage(_("Notification (106) du référentiel ERP OK.")); |
1864 |
} |
1865 |
} |
1866 |
|
1867 |
// Finalisation du document |
1868 |
$this->finaliserAjouter($id); |
1869 |
} |
1870 |
|
1871 |
/** |
1872 |
* Fait une requette sql pour extraire la valeur d'un champ, et retourne |
1873 |
* cette valeur |
1874 |
* @param string $sql La requete sql a executer |
1875 |
* @return La valeur du champs cherche, sinon NULL. En cas d'erreur de la BD |
1876 |
* l'execution s'arrete. |
1877 |
*/ |
1878 |
function getFromDB($sql) { |
1879 |
//$sql = "SELECT libelle FROM ".DB_PREFIXE."dossier WHERE dossier = '" . $dossier . "'"; |
1880 |
$res = $this->db->limitquery($sql, 0, 1); |
1881 |
$this->f->addToLog("getDossierERPSpecification(): db->limitquery(\"". |
1882 |
str_replace(",",", ",$sql)."\", 0, 1);", VERBOSE_MODE); |
1883 |
// Si une erreur survient on die |
1884 |
if (database::isError($res, true)) { |
1885 |
// Appel de la methode de recuperation des erreurs |
1886 |
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), 'instruction'); |
1887 |
} |
1888 |
// retourne la nature du dossier |
1889 |
while ($row =& $res->fetchRow()) { |
1890 |
return $row[0]; |
1891 |
} |
1892 |
// la nature n'etait pas trouve, ce qui ne devrait pas se passer |
1893 |
return NULL; |
1894 |
|
1895 |
} |
1896 |
|
1897 |
// ============================================= |
1898 |
// Ajout du fielset |
1899 |
// Add fieldset |
1900 |
// ============================================= |
1901 |
function setLayout(&$form, $maj){ |
1902 |
|
1903 |
// Modification layout : écran de retour d'avis permettant |
1904 |
// uniquement la saisie des trois champs : avis, motivation et fichier |
1905 |
if ($this->f->isAccredited('consultation_consulter_autre_que_retour_avis')) { |
1906 |
|
1907 |
//Champs sur lequel s'ouvre le fieldset |
1908 |
$form->setBloc('dossier','D',""); |
1909 |
$form->setFieldset('dossier','D',_('Consultation')); |
1910 |
|
1911 |
//Champs sur lequel se ferme le fieldset |
1912 |
$form->setFieldset('date_envoi','F',''); |
1913 |
$form->setBloc('date_envoi','F'); |
1914 |
|
1915 |
} |
1916 |
|
1917 |
// MODE - autre que AJOUTER alors on affiche un fieldset retour |
1918 |
// d'avis |
1919 |
if ($maj != 0) { |
1920 |
|
1921 |
//Champs sur lequel s'ouvre le fieldset |
1922 |
$form->setBloc('date_reception','D',""); |
1923 |
$form->setFieldset('date_reception','D',_('Retour d\'avis')); |
1924 |
|
1925 |
//Champs sur lequel se ferme le fieldset |
1926 |
$form->setFieldset('lu','F',''); |
1927 |
$form->setBloc('lu','F'); |
1928 |
|
1929 |
} |
1930 |
} |
1931 |
|
1932 |
/** Surcharge de la methode retour afin de retourner sur la page de saisie de |
1933 |
* code barre si besoin |
1934 |
**/ |
1935 |
function retour($premier = 0, $recherche = "", $tricol = "") { |
1936 |
$params ="obj=".get_class($this); |
1937 |
if($this->getParameter("retour")=="form") { |
1938 |
$params .= "&idx=".$this->getParameter("idx"); |
1939 |
$params .= "&action=3"; |
1940 |
} |
1941 |
$params .= "&premier=".$this->getParameter("premier"); |
1942 |
$params .= "&tricol=".$this->getParameter("tricol"); |
1943 |
$params .= "&recherche=".$this->getParameter("recherche"); |
1944 |
$params .= "&selectioncol=".$this->getParameter("selectioncol"); |
1945 |
$params .= "&advs_id=".$this->getParameter("advs_id"); |
1946 |
$params .= "&valide=".$this->getParameter("valide"); |
1947 |
echo "\n<a class=\"retour\" "; |
1948 |
echo "href=\""; |
1949 |
// |
1950 |
|
1951 |
if($this->getParameter("retour")=="form" AND !($this->getParameter("validation")>0 AND $this->getParameter("maj")==2 AND $this->correct)) { |
1952 |
echo "form.php?".$params; |
1953 |
} elseif($this->getParameter("retour")=="suivi_retours_de_consultation") { |
1954 |
echo "../scr/form.php?obj=consultation&idx=0&action=120"; |
1955 |
} else { |
1956 |
echo "tab.php?".$params; |
1957 |
} |
1958 |
// |
1959 |
echo "\""; |
1960 |
echo ">"; |
1961 |
// |
1962 |
echo _("Retour"); |
1963 |
// |
1964 |
echo "</a>\n"; |
1965 |
} |
1966 |
|
1967 |
/** |
1968 |
* Surcharge du bouton retour pour popup |
1969 |
*/ |
1970 |
function retoursousformulaire($idxformulaire, $retourformulaire, $val, |
1971 |
$objsf, $premiersf, $tricolsf, $validation, |
1972 |
$idx, $maj, $retour) { |
1973 |
if($retourformulaire === "demande_avis_encours") { |
1974 |
echo "\n<a class=\"retour\" "; |
1975 |
echo "href=\""; |
1976 |
echo "#"; |
1977 |
echo "\" "; |
1978 |
echo ">"; |
1979 |
// |
1980 |
echo _("Retour"); |
1981 |
// |
1982 |
echo "</a>\n"; |
1983 |
} else { |
1984 |
parent::retoursousformulaire($idxformulaire, $retourformulaire, $val, |
1985 |
$objsf, $premiersf, $tricolsf, $validation, |
1986 |
$idx, $maj, $retour); |
1987 |
} |
1988 |
} |
1989 |
|
1990 |
/** |
1991 |
* Ajout des contraintes spécifiques pour l'ajout d'un fichier en retour de |
1992 |
* consultation |
1993 |
*/ |
1994 |
function setSelect(&$form, $maj,&$db,$debug) { |
1995 |
if(file_exists ("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc.php")) |
1996 |
include ("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc.php"); |
1997 |
elseif(file_exists ("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc")) |
1998 |
include ("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc"); |
1999 |
|
2000 |
// avis_consultation |
2001 |
$this->init_select($form, $db, $maj, $debug, "avis_consultation", |
2002 |
$sql_avis_consultation, $sql_avis_consultation_by_id, true); |
2003 |
|
2004 |
// service |
2005 |
// si contexte DI, ou surcharge (mes_encours, mes_clotures...) |
2006 |
$is_in_context_of_foreign_key = $this->is_in_context_of_foreign_key("dossier", $this->getParameter('retourformulaire')); |
2007 |
if ($is_in_context_of_foreign_key == true) { |
2008 |
// on recupÚre les services des multicollectivités et de celle du DI |
2009 |
require_once "../obj/dossier_instruction.class.php"; |
2010 |
$di = new dossier_instruction($this->getParameter('idxformulaire'), $db, $debug); |
2011 |
$sql_service_by_di = str_replace('<collectivite_di>', $di->getVal("om_collectivite"), $sql_service_by_di); |
2012 |
|
2013 |
$this->init_select($form, $db, $maj, $debug, "service", |
2014 |
$sql_service_by_di, $sql_service_by_id, true); |
2015 |
} else { |
2016 |
$this->init_select($form, $db, $maj, $debug, "service", $sql_service, $sql_service_by_id, true); |
2017 |
} |
2018 |
|
2019 |
//Seulement dans le cas d'un retour d'avis |
2020 |
if($this->retourformulaire == "demande_avis_encours" or $this->getParameter("maj") == 100 or $this->getParameter("maj") == 90) { |
2021 |
// avis_consultation |
2022 |
$this->init_select($form, $db, 1, $debug, "avis_consultation", |
2023 |
$sql_avis_consultation, $sql_avis_consultation_by_id, true); |
2024 |
|
2025 |
//Tableau des contraintes spécifiques |
2026 |
$params = array( |
2027 |
"constraint" => array( |
2028 |
"size_max" => 2, |
2029 |
"extension" => ".pdf" |
2030 |
), |
2031 |
); |
2032 |
|
2033 |
$form->setSelect("fichier", $params); |
2034 |
} |
2035 |
} |
2036 |
|
2037 |
/** |
2038 |
* Finalisation du document lors de l'ajout d'une consultation. |
2039 |
* |
2040 |
* @param integer $id indentifiant de l'objet |
2041 |
*/ |
2042 |
function finaliserAjouter($id){ |
2043 |
|
2044 |
$uid = $this->file_finalizing($id); |
2045 |
|
2046 |
//Mise à jour des données |
2047 |
if ( $uid != '' && $uid != 'OP_FAILURE' ){ |
2048 |
// Logger |
2049 |
$this->addToLog("finaliserAjouter() - begin", EXTRA_VERBOSE_MODE); |
2050 |
|
2051 |
$valF = array( |
2052 |
"om_final_consultation"=> true, |
2053 |
"om_fichier_consultation"=>$uid |
2054 |
); |
2055 |
|
2056 |
// Execution de la requête de modification des donnees de l'attribut |
2057 |
// valF de l'objet dans l'attribut table de l'objet |
2058 |
$res = $this->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
2059 |
DB_AUTOQUERY_UPDATE, $this->getCle($id)); |
2060 |
$this->addToLog( |
2061 |
"finaliserAjouter() : db->autoExecute(\"".DB_PREFIXE.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($id)."\")", |
2062 |
VERBOSE_MODE |
2063 |
); |
2064 |
// Si une erreur survient |
2065 |
if (database::isError($res, true)) { |
2066 |
$this->correct = false; |
2067 |
// Appel de la methode de recuperation des erreurs |
2068 |
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
2069 |
return false; |
2070 |
} else { |
2071 |
// Log |
2072 |
$this->addToLog(_("Requete executee"), VERBOSE_MODE); |
2073 |
// Log |
2074 |
$message = _("Enregistrement")." ".$id." "; |
2075 |
$message .= _("de la table")." \"".$this->table."\" "; |
2076 |
$message .= "[ ".$this->db->affectedRows()." "; |
2077 |
$message .= _("enregistrement(s) mis a jour")." ]"; |
2078 |
$this->addToLog($message, VERBOSE_MODE); |
2079 |
} |
2080 |
} |
2081 |
} |
2082 |
|
2083 |
/** |
2084 |
* Finalisation du fichier. |
2085 |
* |
2086 |
* @param integer $id indentifiant de l'objet |
2087 |
* |
2088 |
* @return string uid du fichier finalisé |
2089 |
*/ |
2090 |
function file_finalizing($id){ |
2091 |
$pdf = $this->generate_pdf_consultation(); |
2092 |
|
2093 |
if(isset($this->valF["om_final_consultation"])) { |
2094 |
$finalized = $this->valF["om_final_consultation"]; |
2095 |
} else { |
2096 |
$finalized = $this->getVal("om_final_consultation"); |
2097 |
} |
2098 |
|
2099 |
// Métadonnées du document |
2100 |
$metadata = array( |
2101 |
'filename' => $pdf["filename"], |
2102 |
'mimetype' => 'application/pdf', |
2103 |
'size' => strlen($pdf["pdf_output"]) |
2104 |
); |
2105 |
|
2106 |
// Récupération des métadonnées calculées après validation |
2107 |
$spe_metadata = $this->getMetadata("om_fichier_consultation"); |
2108 |
|
2109 |
$metadata = array_merge($metadata, $spe_metadata); |
2110 |
|
2111 |
// Si le document a déjà été finalisé |
2112 |
if ( $finalized != '' ){ |
2113 |
|
2114 |
// Met à jour le document mais pas son uid |
2115 |
$uid = $this->f->storage->update( |
2116 |
$this->getVal("om_fichier_consultation"), $pdf["pdf_output"], $metadata); |
2117 |
} |
2118 |
// Sinon, ajoute le document et récupère son uid |
2119 |
else { |
2120 |
|
2121 |
// Stockage du PDF |
2122 |
$uid = $this->f->storage->create($pdf["pdf_output"], $metadata); |
2123 |
} |
2124 |
|
2125 |
return $uid; |
2126 |
|
2127 |
} |
2128 |
|
2129 |
|
2130 |
/** |
2131 |
* TREATMENT - finalize. |
2132 |
* |
2133 |
* Permet de finaliser un enregistrement |
2134 |
* |
2135 |
* @param array $val valeurs soumises par le formulaire |
2136 |
* @param null $dnu1 @deprecated Ancienne ressource de base de données. |
2137 |
* @param null $dnu2 @deprecated Ancien marqueur de débogage. |
2138 |
* |
2139 |
* @return boolean |
2140 |
*/ |
2141 |
function finalize($val = array(), &$dnu1 = null, $dnu2 = null) { |
2142 |
|
2143 |
// Cette méthode permet d'exécuter une routine en début des méthodes |
2144 |
// dites de TREATMENT. |
2145 |
$this->begin_treatment(__METHOD__); |
2146 |
|
2147 |
// Traitement de la finalisation |
2148 |
$ret = $this->manage_finalizing("finalize", $val); |
2149 |
|
2150 |
// Si le traitement retourne une erreur |
2151 |
if ($ret !== true) { |
2152 |
|
2153 |
// Termine le traitement |
2154 |
$this->end_treatment(__METHOD__, false); |
2155 |
} |
2156 |
|
2157 |
// Termine le traitement |
2158 |
return $this->end_treatment(__METHOD__, true); |
2159 |
} |
2160 |
|
2161 |
/** |
2162 |
* TREATMENT - unfinalize. |
2163 |
* |
2164 |
* Permet de definaliser un enregistrement |
2165 |
* |
2166 |
* @param array $val valeurs soumises par le formulaire |
2167 |
* @param null $dnu1 @deprecated Ancienne ressource de base de données. |
2168 |
* @param null $dnu2 @deprecated Ancien marqueur de débogage. |
2169 |
* |
2170 |
* @return boolean |
2171 |
*/ |
2172 |
function unfinalize($val = array(), &$dnu1 = null, $dnu2 = null) { |
2173 |
|
2174 |
// Cette méthode permet d'exécuter une routine en début des méthodes |
2175 |
// dites de TREATMENT. |
2176 |
$this->begin_treatment(__METHOD__); |
2177 |
|
2178 |
// Traitement de la finalisation |
2179 |
$ret = $this->manage_finalizing("unfinalize", $val); |
2180 |
|
2181 |
// Si le traitement retourne une erreur |
2182 |
if ($ret !== true) { |
2183 |
|
2184 |
// Termine le traitement |
2185 |
$this->end_treatment(__METHOD__, false); |
2186 |
} |
2187 |
|
2188 |
// Termine le traitement |
2189 |
return $this->end_treatment(__METHOD__, true); |
2190 |
} |
2191 |
|
2192 |
|
2193 |
/** |
2194 |
* Finalisation des documents. |
2195 |
* |
2196 |
* @param string $mode finalize/unfinalize |
2197 |
* @param array $val valeurs soumises par le formulaire |
2198 |
*/ |
2199 |
function manage_finalizing($mode = null, $val = array()) { |
2200 |
|
2201 |
// Recuperation de la valeur de la cle primaire de l'objet |
2202 |
$id = $this->getVal($this->clePrimaire); |
2203 |
|
2204 |
// Si on finalise le document |
2205 |
if ($mode == "finalize") { |
2206 |
// Finalisation du fichier |
2207 |
$uid = $this->file_finalizing($id); |
2208 |
} |
2209 |
// |
2210 |
else { |
2211 |
|
2212 |
//Récupération de l'uid du document finalisé |
2213 |
$uid = $this->getVal("om_fichier_consultation"); |
2214 |
|
2215 |
//On dé-finalise avant de finaliser |
2216 |
if ( $uid == '' || $uid == 'OP_FAILURE' ){ |
2217 |
$this->correct = false; |
2218 |
$this->msg=""; |
2219 |
$this->addToMessage(_("Finalisation non enregistree")); |
2220 |
$this->addToLog( |
2221 |
_("Finalisation non enregistree")." - ". |
2222 |
_("id consultation")." = ".$id." - ". |
2223 |
_("uid fichier")." = ".$uid |
2224 |
); |
2225 |
return false; |
2226 |
} |
2227 |
} |
2228 |
|
2229 |
//Mise à jour des données |
2230 |
if ($uid != '' && $uid != 'OP_FAILURE') { |
2231 |
|
2232 |
// Logger |
2233 |
$this->addToLog("finaliser() - begin", EXTRA_VERBOSE_MODE); |
2234 |
|
2235 |
foreach ($this->champs as $key => $value) { |
2236 |
// |
2237 |
$val[$value] = $this->val[$key]; |
2238 |
} |
2239 |
|
2240 |
$this->setvalF($val); |
2241 |
|
2242 |
// Verification de la validite des donnees |
2243 |
$this->verifier($this->val, $this->db, DEBUG); |
2244 |
// Si les verifications precedentes sont correctes, on procede a |
2245 |
// la modification, sinon on ne fait rien et on retourne une erreur |
2246 |
if ($this->correct) { |
2247 |
|
2248 |
// Execution du trigger 'before' specifique au MODE 'update' |
2249 |
$this->triggermodifier( $id, $this->db, $this->val, DEBUG); |
2250 |
|
2251 |
// |
2252 |
$valF = ''; |
2253 |
if($mode=="finalize") { |
2254 |
$valF["om_final_consultation"] = true; |
2255 |
} else { |
2256 |
$valF["om_final_consultation"] = false; |
2257 |
} |
2258 |
$valF["om_fichier_consultation"] = $uid; |
2259 |
|
2260 |
// Execution de la requête de modification des donnees de l'attribut |
2261 |
// valF de l'objet dans l'attribut table de l'objet |
2262 |
$res = $this->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
2263 |
DB_AUTOQUERY_UPDATE, $this->getCle($id)); |
2264 |
$this->addToLog( |
2265 |
"finaliser() : db->autoExecute(\"".DB_PREFIXE.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($id)."\")", |
2266 |
VERBOSE_MODE |
2267 |
); |
2268 |
|
2269 |
// Si une erreur survient |
2270 |
if (database::isError($res, true)) { |
2271 |
|
2272 |
// Appel de la methode de recuperation des erreurs |
2273 |
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
2274 |
$this->correct = false; |
2275 |
return false; |
2276 |
} else { |
2277 |
|
2278 |
// Log |
2279 |
$this->addToLog(_("Requete executee"), VERBOSE_MODE); |
2280 |
// Log |
2281 |
$message = _("Enregistrement")." ".$id." "; |
2282 |
$message .= _("de la table")." \"".$this->table."\" "; |
2283 |
$message .= "[ ".$this->db->affectedRows()." "; |
2284 |
$message .= _("enregistrement(s) mis a jour")." ]"; |
2285 |
$this->addToLog($message, VERBOSE_MODE); |
2286 |
// Execution du trigger 'after' specifique au MODE 'update' |
2287 |
$this->triggermodifierapres($id, $this->db, $this->val, DEBUG); |
2288 |
|
2289 |
if($mode == "finalize") { |
2290 |
$etat = _('finalisation'); |
2291 |
} else { |
2292 |
$etat = _('definalisation'); |
2293 |
} |
2294 |
$this->msg=""; |
2295 |
$this->addToMessage(sprintf(_("La %s du document s'est effectuee avec succes."), $etat)); |
2296 |
return true; |
2297 |
} |
2298 |
// |
2299 |
} else { |
2300 |
$this->correct = false; |
2301 |
$this->msg=""; |
2302 |
// Message d'echec (saut d'une ligne supplementaire avant le |
2303 |
// message pour qu'il soit mis en evidence) |
2304 |
$this->addToMessage(_("Finalisation non enregistree")); |
2305 |
$this->addToLog( |
2306 |
_("Finalisation non enregistree")." - ". |
2307 |
_("id consultation")." = ".$id." - ". |
2308 |
_("uid fichier")." = ".$uid |
2309 |
); |
2310 |
return false; |
2311 |
} |
2312 |
} |
2313 |
// Si le document n'a pas été stocké |
2314 |
else{ |
2315 |
$this->correct = false; |
2316 |
$this->msg=""; |
2317 |
$this->addToMessage(_("Finalisation non enregistree")); |
2318 |
$this->addToLog( |
2319 |
_("Finalisation non enregistree")." - ". |
2320 |
_("id consultation")." = ".$id." - ". |
2321 |
_("uid fichier")." = ".$uid |
2322 |
); |
2323 |
return false; |
2324 |
} |
2325 |
} |
2326 |
|
2327 |
/** |
2328 |
* Permet de récupérer l'édition de la consultation. |
2329 |
* |
2330 |
* @param string $output type de sortie |
2331 |
* |
2332 |
* @return string si le type de sortie est string, le contenu du pdf est retourné. |
2333 |
*/ |
2334 |
function generate_pdf_consultation() { |
2335 |
if(isset($this->valF[$this->clePrimaire])) { |
2336 |
$id = $this->valF[$this->clePrimaire]; |
2337 |
} else { |
2338 |
$id = $this->getVal($this->clePrimaire); |
2339 |
} |
2340 |
|
2341 |
// Requête qui récupère le type de consultation |
2342 |
$sql = " SELECT id "; |
2343 |
$sql .= " FROM ".DB_PREFIXE."service "; |
2344 |
$sql .= " LEFT JOIN ".DB_PREFIXE."om_etat "; |
2345 |
$sql .= " ON service.edition = om_etat.om_etat "; |
2346 |
$sql .= " WHERE service=("; |
2347 |
$sql .= " SELECT service "; |
2348 |
$sql .= " FROM ".DB_PREFIXE."consultation "; |
2349 |
$sql .= " WHERE consultation=".$id.""; |
2350 |
$sql .= ") "; |
2351 |
$obj = $this->f->db->getone($sql); |
2352 |
$this->f->addTolog( |
2353 |
__FILE__." - ".__METHOD__." : db->getone(\"".$sql."\");", |
2354 |
VERBOSE_MODE |
2355 |
); |
2356 |
if($this->f->isDatabaseError($obj, true)) { |
2357 |
$this->addToMessage(_("Aucun document genere.")); |
2358 |
$this->addToMessage(_("Finalisation non enregistree")); |
2359 |
return false; |
2360 |
} |
2361 |
$collectivite = $this->f->getCollectivite($this->get_dossier_collectivite()); |
2362 |
|
2363 |
$pdf_output = $this->compute_pdf_output("etat", $obj, $collectivite, $id); |
2364 |
|
2365 |
return $pdf_output; |
2366 |
} |
2367 |
|
2368 |
function get_dossier_collectivite() { |
2369 |
if(isset($this->valF["dossier"])) { |
2370 |
$dossier = $this->valF["dossier"]; |
2371 |
} else { |
2372 |
$dossier = $this->getVal("dossier"); |
2373 |
} |
2374 |
|
2375 |
$sql = "SELECT om_collectivite FROM ".DB_PREFIXE."dossier WHERE dossier.dossier='".$dossier."'"; |
2376 |
$collectivite = $this->f->db->getone($sql); |
2377 |
$this->f->addTolog( |
2378 |
__FILE__." - ".__METHOD__." : db->getone(\"".$sql."\");", |
2379 |
VERBOSE_MODE |
2380 |
); |
2381 |
if($this->f->isDatabaseError($collectivite, true)) { |
2382 |
$this->addToMessage(_("Aucun document genere.")); |
2383 |
$this->addToMessage(_("Finalisation non enregistree")); |
2384 |
return false; |
2385 |
} |
2386 |
return $collectivite; |
2387 |
} |
2388 |
|
2389 |
function view_consulter_pdf(){ |
2390 |
if($this->getVal("om_final_consultation") == 't') { |
2391 |
$lien = '../spg/file.php?obj=consultation&'. |
2392 |
'champ=om_fichier_consultation&id='.$this->getVal($this->clePrimaire); |
2393 |
header("Location: ".$lien); |
2394 |
} else { |
2395 |
|
2396 |
$output = $this->generate_pdf_consultation(); |
2397 |
$this->expose_pdf_output($output["pdf_output"], $output["filename"]); |
2398 |
} |
2399 |
exit(); |
2400 |
} |
2401 |
/** |
2402 |
* Création du nom de fichier |
2403 |
* @return string numéro de dossier d'instruction |
2404 |
*/ |
2405 |
protected function getFichierFilename() { |
2406 |
return "consultation_avis_".$this->valF[$this->clePrimaire].".pdf"; |
2407 |
} |
2408 |
|
2409 |
/** |
2410 |
* Récupération du numéro de dossier d'instruction à ajouter aux métadonnées |
2411 |
* @return string numéro de dossier d'instruction |
2412 |
*/ |
2413 |
protected function getDossier() { |
2414 |
if(empty($this->specificMetadata)) { |
2415 |
$this->getSpecificMetadata(); |
2416 |
} |
2417 |
return $this->specificMetadata->dossier; |
2418 |
} |
2419 |
/** |
2420 |
* Récupération la version du dossier d'instruction à ajouter aux métadonnées |
2421 |
* @return int Version |
2422 |
*/ |
2423 |
protected function getDossierVersion() { |
2424 |
if(empty($this->specificMetadata)) { |
2425 |
$this->getSpecificMetadata(); |
2426 |
} |
2427 |
return $this->specificMetadata->version; |
2428 |
} |
2429 |
/** |
2430 |
* Récupération du numéro de dossier d'autorisation à ajouter aux métadonnées |
2431 |
* @return string numéro de dossier d'autorisation |
2432 |
*/ |
2433 |
protected function getNumDemandeAutor() { |
2434 |
if(empty($this->specificMetadata)) { |
2435 |
$this->getSpecificMetadata(); |
2436 |
} |
2437 |
return $this->specificMetadata->dossier_autorisation; |
2438 |
} |
2439 |
/** |
2440 |
* Récupération de la date de demande initiale du dossier à ajouter aux métadonnées |
2441 |
* @return date demande initiale |
2442 |
*/ |
2443 |
protected function getAnneemoisDemandeAutor() { |
2444 |
if(empty($this->specificMetadata)) { |
2445 |
$this->getSpecificMetadata(); |
2446 |
} |
2447 |
return $this->specificMetadata->date_demande_initiale; |
2448 |
} |
2449 |
/** |
2450 |
* Récupération du type de dossier d'instruction à ajouter aux métadonnées |
2451 |
* @return string type de dossier d'instruction |
2452 |
*/ |
2453 |
protected function getTypeInstruction() { |
2454 |
if(empty($this->specificMetadata)) { |
2455 |
$this->getSpecificMetadata(); |
2456 |
} |
2457 |
return $this->specificMetadata->dossier_instruction_type; |
2458 |
} |
2459 |
/** |
2460 |
* Récupération du statut du dossier d'autorisation à ajouter aux métadonnées |
2461 |
* @return string avis |
2462 |
*/ |
2463 |
protected function getStatutAutorisation() { |
2464 |
if(empty($this->specificMetadata)) { |
2465 |
$this->getSpecificMetadata(); |
2466 |
} |
2467 |
return $this->specificMetadata->statut; |
2468 |
} |
2469 |
/** |
2470 |
* Récupération du type de dossier d'autorisation à ajouter aux métadonnées |
2471 |
* @return string type d'autorisation |
2472 |
*/ |
2473 |
protected function getTypeAutorisation() { |
2474 |
if(empty($this->specificMetadata)) { |
2475 |
$this->getSpecificMetadata(); |
2476 |
} |
2477 |
return $this->specificMetadata->dossier_autorisation_type; |
2478 |
} |
2479 |
/** |
2480 |
* Récupération de la date d'ajout de document à ajouter aux métadonnées |
2481 |
* @return date de l'évènement |
2482 |
*/ |
2483 |
protected function getDateEvenementDocument() { |
2484 |
return date("Y-m-d"); |
2485 |
} |
2486 |
/** |
2487 |
* Récupération du groupe d'instruction à ajouter aux métadonnées |
2488 |
* @return string Groupe d'instruction |
2489 |
*/ |
2490 |
protected function getGroupeInstruction() { |
2491 |
if(empty($this->specificMetadata)) { |
2492 |
$this->getSpecificMetadata(); |
2493 |
} |
2494 |
return $this->specificMetadata->groupe_instruction; |
2495 |
} |
2496 |
/** |
2497 |
* Récupération du type de document à ajouter aux métadonnées |
2498 |
* @return string Type de document |
2499 |
*/ |
2500 |
protected function getTitle() { |
2501 |
if ($this->retourformulaire == "demande_avis_encours") { |
2502 |
return 'Retour de consultation'; |
2503 |
} else { |
2504 |
return 'Demande de consultation'; |
2505 |
} |
2506 |
} |
2507 |
|
2508 |
/** |
2509 |
* Cette méthode permet de stocker en attribut toutes les métadonnées |
2510 |
* nécessaire à l'ajout d'un document. |
2511 |
*/ |
2512 |
public function getSpecificMetadata() { |
2513 |
if (isset($this->valF["dossier"]) AND $this->valF["dossier"] != "") { |
2514 |
$dossier = $this->valF["dossier"]; |
2515 |
} else { |
2516 |
$dossier = $this->getVal("dossier"); |
2517 |
} |
2518 |
//Requête pour récupérer les informations essentiels sur le dossier d'instruction |
2519 |
$sql = "SELECT dossier.dossier as dossier, |
2520 |
dossier_autorisation.dossier_autorisation as dossier_autorisation, |
2521 |
to_char(dossier.date_demande, 'YYYY/MM') as date_demande_initiale, |
2522 |
dossier_instruction_type.code as dossier_instruction_type, |
2523 |
etat_dossier_autorisation.libelle as statut, |
2524 |
dossier_autorisation_type.code as dossier_autorisation_type, |
2525 |
groupe.code as groupe_instruction |
2526 |
FROM ".DB_PREFIXE."dossier |
2527 |
LEFT JOIN ".DB_PREFIXE."dossier_instruction_type |
2528 |
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
2529 |
LEFT JOIN ".DB_PREFIXE."dossier_autorisation |
2530 |
ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
2531 |
LEFT JOIN ".DB_PREFIXE."etat_dossier_autorisation |
2532 |
ON dossier_autorisation.etat_dossier_autorisation = etat_dossier_autorisation.etat_dossier_autorisation |
2533 |
LEFT JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille |
2534 |
ON dossier_autorisation.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
2535 |
LEFT JOIN ".DB_PREFIXE."dossier_autorisation_type |
2536 |
ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
2537 |
LEFT JOIN ".DB_PREFIXE."groupe |
2538 |
ON dossier_autorisation_type.groupe = groupe.groupe |
2539 |
WHERE dossier.dossier = '".$dossier."'"; |
2540 |
$res = $this->db->query($sql); |
2541 |
$this->f->addToLog("obj/document_numerise.class.php : db->query(".$sql.")", VERBOSE_MODE); |
2542 |
if ( database::isError($res)){ |
2543 |
die(); |
2544 |
} |
2545 |
|
2546 |
//Le résultat est récupéré dans un objet |
2547 |
$row =& $res->fetchRow(DB_FETCHMODE_OBJECT); |
2548 |
|
2549 |
//Si il y a un résultat |
2550 |
if ($row !== null) { |
2551 |
|
2552 |
// Instrance de la classe dossier |
2553 |
$inst_dossier = $this->get_inst_dossier($dossier); |
2554 |
|
2555 |
// Insère l'attribut version à l'objet |
2556 |
$row->version = $inst_dossier->get_dossier_instruction_version(); |
2557 |
|
2558 |
//Alors on créé l'objet dossier_instruction |
2559 |
$this->specificMetadata = $row; |
2560 |
|
2561 |
} |
2562 |
} |
2563 |
|
2564 |
/** |
2565 |
* |
2566 |
* @return boolean |
2567 |
*/ |
2568 |
function is_instructeur(){ |
2569 |
|
2570 |
//Si l'utilisateur est un instructeur |
2571 |
if ($this->f->isUserInstructeur()){ |
2572 |
return true; |
2573 |
} |
2574 |
return false; |
2575 |
} |
2576 |
|
2577 |
function is_editable(){ |
2578 |
|
2579 |
if ($this->f->can_bypass("consultation", "modifier")){ |
2580 |
return true; |
2581 |
} |
2582 |
|
2583 |
if ($this->is_dossier_instruction_not_closed()&&$this->is_instructeur_from_division()){ |
2584 |
return true; |
2585 |
} |
2586 |
return false; |
2587 |
} |
2588 |
|
2589 |
function is_deletable(){ |
2590 |
|
2591 |
if ($this->f->can_bypass("consultation", "supprimer")){ |
2592 |
return true; |
2593 |
} |
2594 |
|
2595 |
if ($this->is_dossier_instruction_not_closed()&&$this->is_instructeur_from_division()){ |
2596 |
return true; |
2597 |
} |
2598 |
return false; |
2599 |
} |
2600 |
|
2601 |
function is_multiaddable(){ |
2602 |
|
2603 |
if ($this->f->can_bypass("consultation", "ajouter")){ |
2604 |
return true; |
2605 |
} |
2606 |
|
2607 |
if ($this->is_instructeur_from_division()){ |
2608 |
return true; |
2609 |
} |
2610 |
return false; |
2611 |
} |
2612 |
|
2613 |
function is_markable(){ |
2614 |
|
2615 |
if($this->f->can_bypass("consultation", "modifier_lu")){ |
2616 |
return true; |
2617 |
} |
2618 |
|
2619 |
if ($this->is_instructeur_from_division()){ |
2620 |
return true; |
2621 |
} |
2622 |
return false; |
2623 |
} |
2624 |
|
2625 |
function is_finalizable(){ |
2626 |
|
2627 |
if($this->f->can_bypass("consultation", "finaliser")){ |
2628 |
return true; |
2629 |
} |
2630 |
|
2631 |
if ($this->is_instructeur_from_division() && $this->is_dossier_instruction_not_closed()){ |
2632 |
return true; |
2633 |
} |
2634 |
|
2635 |
return false; |
2636 |
} |
2637 |
|
2638 |
function is_unfinalizable(){ |
2639 |
|
2640 |
if($this->f->can_bypass("consultation", "definaliser")){ |
2641 |
return true; |
2642 |
} |
2643 |
|
2644 |
if ($this->is_instructeur_from_division() && $this->is_dossier_instruction_not_closed()){ |
2645 |
return true; |
2646 |
} |
2647 |
|
2648 |
return false; |
2649 |
} |
2650 |
|
2651 |
/** |
2652 |
* Récupère l'instance du dossier d'instruction |
2653 |
* |
2654 |
* @param mixed Identifiant du dossier d'instruction |
2655 |
* |
2656 |
* @return object |
2657 |
*/ |
2658 |
function get_inst_dossier($dossier = null) { |
2659 |
// |
2660 |
return $this->get_inst_common("dossier", $dossier); |
2661 |
} |
2662 |
|
2663 |
|
2664 |
}// fin classe |
2665 |
?> |