1 |
fraynaud |
3 |
<?php |
2 |
|
|
//$Id$ |
3 |
|
|
//gen openMairie le 10/02/2011 20:32 |
4 |
|
|
require_once ("../gen/obj/consultation.class.php"); |
5 |
mlimic |
843 |
require_once("../services/outgoing/messageenqueuer.php"); |
6 |
fraynaud |
3 |
|
7 |
|
|
class consultation extends consultation_gen { |
8 |
nhaye |
601 |
|
9 |
nhaye |
1917 |
var $abstract_type = array( |
10 |
|
|
"fichier" => "file", |
11 |
|
|
); |
12 |
|
|
|
13 |
nhaye |
1935 |
var $metadata = array( |
14 |
nhaye |
1938 |
"om_fichier_consultation" => array( |
15 |
nhaye |
1935 |
"dossier" => "getDossier", |
16 |
softime |
2016 |
"dossier_version" => "getDossierVersion", |
17 |
softime |
2025 |
"numDemandeAutor" => "getNumDemandeAutor", |
18 |
|
|
"anneemoisDemandeAutor" => "getAnneemoisDemandeAutor", |
19 |
|
|
"typeInstruction" => "getTypeInstruction", |
20 |
|
|
"statutAutorisation" => "getStatutAutorisation", |
21 |
|
|
"typeAutorisation" => "getTypeAutorisation", |
22 |
|
|
"dateEvenementDocument" => "getDateEvenementDocument", |
23 |
softime |
2016 |
"groupeInstruction" => 'getGroupeInstruction', |
24 |
softime |
2025 |
"title" => 'getTitle', |
25 |
nhaye |
1935 |
), |
26 |
softime |
2002 |
"fichier" => array( |
27 |
nhaye |
3023 |
"filename" => "getFichierFilename", |
28 |
softime |
2002 |
"dossier" => "getDossier", |
29 |
softime |
2016 |
"dossier_version" => "getDossierVersion", |
30 |
softime |
2025 |
"numDemandeAutor" => "getNumDemandeAutor", |
31 |
|
|
"anneemoisDemandeAutor" => "getAnneemoisDemandeAutor", |
32 |
|
|
"typeInstruction" => "getTypeInstruction", |
33 |
|
|
"statutAutorisation" => "getStatutAutorisation", |
34 |
|
|
"typeAutorisation" => "getTypeAutorisation", |
35 |
|
|
"dateEvenementDocument" => "getDateEvenementDocument", |
36 |
softime |
2016 |
"groupeInstruction" => 'getGroupeInstruction', |
37 |
softime |
2025 |
"title" => 'getTitle', |
38 |
softime |
2002 |
), |
39 |
nhaye |
1935 |
); |
40 |
|
|
|
41 |
nhaye |
3395 |
/** |
42 |
|
|
* Les nouvelles actions sont activées sur cet objet. |
43 |
|
|
* |
44 |
|
|
* @var boolean |
45 |
|
|
*/ |
46 |
|
|
var $activate_class_action; |
47 |
|
|
|
48 |
|
|
/** |
49 |
|
|
* Cette variable permet de stocker le résultat de la méthode |
50 |
|
|
* getDivisionFromDossier() afin de ne pas effectuer le recalcul à chacun de |
51 |
|
|
* ces appels. |
52 |
|
|
* @var string Code de la division du dossier en cours |
53 |
|
|
*/ |
54 |
|
|
var $_division_from_dossier = NULL; |
55 |
|
|
|
56 |
|
|
/** |
57 |
|
|
* Constructeur. |
58 |
|
|
* |
59 |
|
|
* @param integer $id identifiant de l'enregistrement |
60 |
|
|
* @param database $db handler de la base de données |
61 |
|
|
* @param boolean $debug debug |
62 |
|
|
*/ |
63 |
|
|
function consultation($id, &$db, $debug) { |
64 |
|
|
//On active les nouvelles actions |
65 |
|
|
$this->activate_class_action = true; |
66 |
|
|
$this->constructeur($id, $db, $debug); |
67 |
fraynaud |
20 |
}// fin constructeur |
68 |
fmichon |
943 |
|
69 |
nhaye |
3395 |
/** |
70 |
|
|
* Définition des actions disponibles sur la classe. |
71 |
|
|
* |
72 |
|
|
* @return void |
73 |
|
|
*/ |
74 |
|
|
function init_class_actions() { |
75 |
|
|
|
76 |
|
|
parent::init_class_actions(); |
77 |
fmichon |
943 |
|
78 |
nhaye |
3395 |
// ACTION - 001 - modifier |
79 |
|
|
// |
80 |
|
|
$this->class_actions[1]["condition"] = array("show_consultation_finaliser_portlet_action", |
81 |
|
|
"is_dossier_instruction_not_closed"); |
82 |
|
|
|
83 |
|
|
// ACTION - 002 - supprimer |
84 |
|
|
// |
85 |
|
|
$this->class_actions[2]["condition"] = array("show_consultation_finaliser_portlet_action", |
86 |
|
|
"is_dossier_instruction_not_closed"); |
87 |
|
|
$this->class_actions[2]["permission_suffix"] = "supprimer"; |
88 |
|
|
|
89 |
|
|
// ACTION - 040 - valider |
90 |
|
|
// Pour qu'un cadre valide l'analyse |
91 |
|
|
$this->class_actions[40] = array( |
92 |
|
|
"identifier" => "ajout_multiple", |
93 |
|
|
"view" => "view_ajout_multiple", |
94 |
|
|
"method" => "ajouter_multiple", |
95 |
|
|
"button" => "valider", |
96 |
|
|
"permission_suffix" => "ajouter", |
97 |
|
|
"condition" => array("is_instructeur_from_division"), |
98 |
|
|
); |
99 |
|
|
// ACTION - 050 - marquer_comme_lu |
100 |
|
|
// Pour qu'un cadre valide l'analyse |
101 |
|
|
$this->class_actions[50] = array( |
102 |
|
|
"identifier" => "marquer_comme_lu", |
103 |
|
|
"portlet" => array( |
104 |
|
|
"type" => "action-direct", |
105 |
|
|
"libelle" => _("Marquer comme lu"), |
106 |
|
|
"order" => 50, |
107 |
|
|
"class" => "lu-16", |
108 |
|
|
), |
109 |
|
|
"view" => "formulaire", |
110 |
|
|
"method" => "marquer_comme_lu", |
111 |
|
|
"permission_suffix" => "modifier_lu", |
112 |
|
|
"condition" => array("is_instructeur_from_division", |
113 |
|
|
"show_marquer_comme_lu_portlet_action"), |
114 |
|
|
); |
115 |
|
|
// ACTION - 060 - finaliser |
116 |
|
|
// Pour qu'un cadre valide l'analyse |
117 |
|
|
$this->class_actions[60] = array( |
118 |
|
|
"identifier" => "finalise", |
119 |
|
|
"portlet" => array( |
120 |
|
|
"type" => "action-direct", |
121 |
|
|
"libelle" => _("Finaliser le document"), |
122 |
|
|
"order" => 60, |
123 |
|
|
"class" => "finalise", |
124 |
|
|
), |
125 |
|
|
"view" => "formulaire", |
126 |
|
|
"method" => "finalize", |
127 |
|
|
"permission_suffix" => "finaliser", |
128 |
|
|
"condition" => array("is_instructeur_from_division", |
129 |
|
|
"show_consultation_finaliser_portlet_action", |
130 |
|
|
"is_dossier_instruction_not_closed"), |
131 |
|
|
); |
132 |
|
|
|
133 |
|
|
// ACTION - 070 - unfinaliser |
134 |
|
|
// Pour qu'un cadre valide l'analyse |
135 |
|
|
$this->class_actions[70] = array( |
136 |
|
|
"identifier" => "unfinalise", |
137 |
|
|
"portlet" => array( |
138 |
|
|
"type" => "action-direct", |
139 |
|
|
"libelle" => _("Reprendre la redaction du document"), |
140 |
|
|
"order" => 70, |
141 |
|
|
"class" => "definalise", |
142 |
|
|
), |
143 |
|
|
"view" => "formulaire", |
144 |
|
|
"method" => "unfinalize", |
145 |
|
|
"permission_suffix" => "definaliser", |
146 |
|
|
"condition" => array("is_instructeur_from_division", |
147 |
|
|
"show_unfinalize_portlet_action", |
148 |
|
|
"is_dossier_instruction_not_closed"), |
149 |
|
|
); |
150 |
|
|
|
151 |
|
|
// ACTION - 080 - consulter_pdf |
152 |
|
|
// Pour qu'un cadre valide l'analyse |
153 |
|
|
$this->class_actions[80] = array( |
154 |
|
|
"identifier" => "consulter_pdf", |
155 |
|
|
"portlet" => array( |
156 |
|
|
"type" => "action-blank", |
157 |
|
|
"libelle" => _("Editer la consultation PDF"), |
158 |
|
|
"order" => 45, |
159 |
|
|
"class" => "pdf-16", |
160 |
|
|
), |
161 |
|
|
"view" => "view_consulter_pdf", |
162 |
|
|
"condition" => array("is_instructeur_from_division"), |
163 |
|
|
"permission_suffix" => "consulter", |
164 |
|
|
); |
165 |
|
|
|
166 |
|
|
|
167 |
|
|
// ACTION - 100 - retour_consultation |
168 |
|
|
// Lors de la saisie de retour d'avis par le profil suivi des dates |
169 |
|
|
$this->class_actions[100] = array( |
170 |
|
|
"identifier" => "retour_consultation", |
171 |
|
|
"view" => "formulaire", |
172 |
|
|
"method" => "modifier", |
173 |
|
|
"button" => _("Modifier"), |
174 |
|
|
"permission_suffix" => "modifier", |
175 |
|
|
"condition" => array("is_suivi_retours_de_consultation"), |
176 |
|
|
|
177 |
|
|
); |
178 |
|
|
|
179 |
|
|
} |
180 |
|
|
|
181 |
fmichon |
943 |
/** |
182 |
nhaye |
3395 |
* Défini si l'utilisateur est un intructeur qui en correspond à la division |
183 |
|
|
* du dossier. |
184 |
|
|
* |
185 |
|
|
* @return boolean true si correspond false sinon |
186 |
fmichon |
943 |
*/ |
187 |
nhaye |
3395 |
function is_instructeur_from_division() { |
188 |
|
|
|
189 |
fmichon |
943 |
if ($this->f->isUserInstructeur() |
190 |
|
|
&& isset($this->f->om_utilisateur["division"]) |
191 |
|
|
&& $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier()) { |
192 |
|
|
// |
193 |
nhaye |
3395 |
return false; |
194 |
fmichon |
943 |
} |
195 |
nhaye |
3395 |
return true; |
196 |
|
|
} |
197 |
|
|
|
198 |
|
|
/** |
199 |
|
|
* Défini si l'utilisateur est de la cellule suivi. |
200 |
|
|
* |
201 |
|
|
* @return boolean true si correspond false sinon |
202 |
|
|
*/ |
203 |
|
|
function is_suivi_retours_de_consultation() { |
204 |
|
|
|
205 |
|
|
return $this->f->isAccredited("suivi_retours_de_consultation"); |
206 |
|
|
} |
207 |
|
|
|
208 |
|
|
/** |
209 |
|
|
* Si le champ lu est à true l'action "Marquer comme lu" n'est pas affichée |
210 |
|
|
* |
211 |
|
|
* @return boolean true sinon lu false sinon |
212 |
|
|
*/ |
213 |
|
|
function show_marquer_comme_lu_portlet_action() { |
214 |
|
|
if (isset($this->val[array_search("lu", $this->champs)]) |
215 |
fmichon |
943 |
&& $this->val[array_search("lu", $this->champs)]== "t") { |
216 |
nhaye |
3395 |
return false; |
217 |
fmichon |
943 |
} |
218 |
nhaye |
3395 |
return true; |
219 |
|
|
} |
220 |
|
|
|
221 |
|
|
/** |
222 |
|
|
* Si le document est finalisé l'action "finaliser" n'est pas affichée |
223 |
|
|
* |
224 |
|
|
* @return boolean true sinon lu false sinon |
225 |
|
|
*/ |
226 |
|
|
function show_consultation_finaliser_portlet_action() { |
227 |
|
|
if ($this->is_document_finalized("om_final_consultation")) { |
228 |
|
|
return false; |
229 |
vpihour |
1974 |
} |
230 |
nhaye |
3395 |
return true; |
231 |
|
|
} |
232 |
|
|
|
233 |
|
|
/** |
234 |
|
|
* Retourne is_document_finalized("om_final_consultation") |
235 |
|
|
* |
236 |
|
|
* @return boolean true si finalisé false sinon |
237 |
|
|
*/ |
238 |
|
|
function show_unfinalize_portlet_action() { |
239 |
|
|
return $this->is_document_finalized("om_final_consultation"); |
240 |
|
|
} |
241 |
|
|
|
242 |
|
|
/** |
243 |
|
|
* Permet de savoir si le document passé en paramètre est finalisé |
244 |
|
|
* |
245 |
|
|
* @param string $field flag finalisé |
246 |
|
|
* |
247 |
|
|
* @return boolean true si finalisé false sinon |
248 |
|
|
*/ |
249 |
|
|
function is_document_finalized($field) { |
250 |
|
|
if($this->getVal($field) == 't') { |
251 |
|
|
return true; |
252 |
vpihour |
1974 |
} |
253 |
nhaye |
3395 |
return false; |
254 |
|
|
} |
255 |
|
|
|
256 |
|
|
/** |
257 |
|
|
* Si le dossier d'instruction auquel est rattachée la consultation est |
258 |
|
|
* cloturé, on affiche pas les liens du portlet. |
259 |
|
|
* |
260 |
|
|
* @return boolean true si non cloturé false sinon |
261 |
|
|
*/ |
262 |
|
|
function is_dossier_instruction_not_closed() { |
263 |
vpihour |
1978 |
$idxformulaire = $this->getParameter("idxformulaire"); |
264 |
|
|
$retourformulaire = $this->getParameter("retourformulaire"); |
265 |
|
|
//Si le dossier d'instruction auquel est rattachée la consultation est |
266 |
|
|
//cloturé, on affiche pas les liens du portlet |
267 |
|
|
if ( $idxformulaire != '' && |
268 |
|
|
( |
269 |
|
|
$retourformulaire == 'dossier' || |
270 |
|
|
$retourformulaire == 'dossier_instruction' || |
271 |
|
|
$retourformulaire == 'dossier_instruction_mes_encours' || |
272 |
|
|
$retourformulaire == 'dossier_instruction_tous_encours' || |
273 |
|
|
$retourformulaire == 'dossier_instruction_mes_clotures' || |
274 |
|
|
$retourformulaire == 'dossier_instruction_tous_clotures' |
275 |
|
|
)){ |
276 |
|
|
|
277 |
|
|
//On récuppère le statut du dossier d'instruction |
278 |
vpihour |
2039 |
$statut = $this->f->getStatutDossier($idxformulaire); |
279 |
vpihour |
1978 |
if ( $this->f->isUserInstructeur() && $statut == "cloture" ){ |
280 |
|
|
|
281 |
nhaye |
3395 |
return false; |
282 |
vpihour |
1978 |
} |
283 |
|
|
} |
284 |
nhaye |
3395 |
return true; |
285 |
fmichon |
943 |
} |
286 |
|
|
|
287 |
nhaye |
3395 |
// {{{ Gestion de la confidentialité des données spécifiques |
288 |
|
|
|
289 |
|
|
|
290 |
fmichon |
943 |
/** |
291 |
|
|
* Cette methode est à surcharger elle permet de tester dans chaque classe |
292 |
|
|
* des droits des droits spécifiques en fonction des données |
293 |
|
|
*/ |
294 |
|
|
function canAccess() { |
295 |
vpihour |
1978 |
|
296 |
|
|
$retourformulaire = $this->getParameter("retourformulaire"); |
297 |
|
|
// Si l'utilisateur est un instructeur et que le dossier est cloturé |
298 |
|
|
if ( $this->f->isUserInstructeur() && |
299 |
vpihour |
2039 |
$this->f->getStatutDossier($this->getParameter("idxformulaire")) == "cloture" && |
300 |
vpihour |
1978 |
( |
301 |
|
|
$retourformulaire == 'dossier' || |
302 |
|
|
$retourformulaire == 'dossier_instruction' || |
303 |
|
|
$retourformulaire == 'dossier_instruction_mes_encours' || |
304 |
|
|
$retourformulaire == 'dossier_instruction_tous_encours' || |
305 |
|
|
$retourformulaire == 'dossier_instruction_mes_clotures' || |
306 |
|
|
$retourformulaire == 'dossier_instruction_tous_clotures' |
307 |
|
|
) && |
308 |
|
|
$this->getParameter("maj") != 3) { |
309 |
|
|
|
310 |
|
|
return false; |
311 |
|
|
} |
312 |
fmichon |
943 |
// |
313 |
|
|
return true; |
314 |
|
|
} |
315 |
|
|
|
316 |
|
|
/** |
317 |
fmichon |
1908 |
* Cette méthode permet de récupérer le code de division correspondant |
318 |
|
|
* au dossier sur lequel on se trouve. |
319 |
|
|
* |
320 |
|
|
* @return string Code de la division du dossier en cours |
321 |
|
|
*/ |
322 |
fmichon |
943 |
function getDivisionFromDossier() { |
323 |
fmichon |
1908 |
|
324 |
|
|
// Cette méthode peut être appelée plusieurs fois lors d'une requête. |
325 |
|
|
// Pour éviter de refaire le traitement de recherche de la division |
326 |
|
|
// alors on vérifie si nous ne l'avons pas déjà calculé. |
327 |
|
|
if ($this->_division_from_dossier != NULL) { |
328 |
|
|
// Logger |
329 |
|
|
$this->addToLog("getDivisionFromDossier(): retour de la valeur déjà calculée - '".$this->_division_from_dossier."'", EXTRA_VERBOSE_MODE); |
330 |
|
|
// On retourne la valeur déjà calculée |
331 |
|
|
return $this->_division_from_dossier; |
332 |
|
|
} |
333 |
|
|
|
334 |
|
|
// Par défaut, on définit la valeur du dossier à NULL |
335 |
|
|
$dossier = NULL; |
336 |
|
|
// Test sur le mode et le contexte du formulaire |
337 |
nhaye |
3395 |
if (($this->getParameter("maj") == 0 or $this->getParameter("maj") == 40) |
338 |
fmichon |
1908 |
&& ($this->getParameter("retourformulaire") == "dossier" |
339 |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction" |
340 |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_encours" |
341 |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_encours" |
342 |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_clotures" |
343 |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_clotures")) { |
344 |
|
|
// Si on se trouve en mode AJOUT (seul mode où l'enregistrement |
345 |
|
|
// n'existe pas en base de données) ET que nous nous trouvons |
346 |
|
|
// dans le contexte d'un dossier d'instruction alors on récupère |
347 |
|
|
// le numéro de dossier depuis le paramètre 'idxformulaire' |
348 |
|
|
$dossier = $this->getParameter("idxformulaire"); |
349 |
fmichon |
1088 |
} else { |
350 |
fmichon |
1908 |
// Sinon on récupère le numéro de dossier dans le champs dossier de |
351 |
|
|
// l'enregistrement (en base de données) |
352 |
|
|
$dossier = $this->getVal("dossier"); |
353 |
fmichon |
943 |
} |
354 |
fmichon |
1088 |
|
355 |
fmichon |
1908 |
// On appelle la méthode de la classe utils qui renvoi le code de la |
356 |
|
|
// division d'un dossier, on la stocke pour ne pas refaire le calcul au |
357 |
|
|
// prochain appel de cette méthode |
358 |
|
|
$this->_division_from_dossier = $this->f->getDivisionFromDossier($dossier); |
359 |
|
|
// Logger |
360 |
|
|
$this->addToLog("getDivisionFromDossier(): retour de la valeur nouvellement calculée - '".$this->_division_from_dossier."'", EXTRA_VERBOSE_MODE); |
361 |
|
|
// On retourne la valeur retournée |
362 |
|
|
return $this->_division_from_dossier; |
363 |
|
|
|
364 |
fmichon |
943 |
} |
365 |
|
|
|
366 |
nhaye |
3395 |
/** |
367 |
|
|
* TREATMENT - marquer_comme_lu. |
368 |
|
|
* |
369 |
|
|
* Cette methode permet de passer la consultation en "lu" |
370 |
|
|
* |
371 |
|
|
* @return boolean true si maj effectué false sinon |
372 |
|
|
*/ |
373 |
|
|
function marquer_comme_lu() { |
374 |
|
|
if($this->getVal("lu") == 'f') { |
375 |
|
|
$this->correct = true; |
376 |
|
|
$this->valF["lu"] = true; |
377 |
|
|
|
378 |
|
|
$res = $this->f->db->autoExecute( |
379 |
|
|
DB_PREFIXE.$this->table, |
380 |
|
|
$this->valF, |
381 |
|
|
DB_AUTOQUERY_UPDATE, |
382 |
|
|
$this->clePrimaire."=".$this->getVal($this->clePrimaire) |
383 |
|
|
); |
384 |
|
|
if ($this->f->isDatabaseError($res, true)) { |
385 |
|
|
// Appel de la methode de recuperation des erreurs |
386 |
|
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
387 |
|
|
$this->correct = false; |
388 |
|
|
return false; |
389 |
|
|
} else { |
390 |
|
|
$this->addToMessage(_("Mise a jour effectue avec succes")); |
391 |
|
|
return $res; |
392 |
|
|
} |
393 |
|
|
|
394 |
|
|
} else { |
395 |
|
|
$this->addToMessage(_("Element deja marque comme lu")); |
396 |
|
|
} |
397 |
|
|
return false; |
398 |
|
|
} |
399 |
|
|
|
400 |
fmichon |
943 |
// }}} |
401 |
|
|
|
402 |
nhaye |
3395 |
/** |
403 |
|
|
* TREATMENT - ajouter_multiple. |
404 |
|
|
* |
405 |
|
|
* Cette methode permet d'ajouter plusieurs consultations. |
406 |
|
|
* |
407 |
|
|
* @return boolean true si ajouts effectués false sinon |
408 |
|
|
*/ |
409 |
|
|
function ajouter_multiple() { |
410 |
|
|
// Identifiant de l'objet metier a copier |
411 |
|
|
($this->f->get_submitted_get_value('idxformulaire') !== null ? $idx = $this->f->get_submitted_get_value('idxformulaire') : $idx = ""); |
412 |
|
|
// Nom de l'objet metier |
413 |
|
|
($this->f->get_submitted_get_value('obj') !== null ? $obj = $this->f->get_submitted_get_value('obj') : $obj = ""); |
414 |
|
|
//formulaire retour |
415 |
|
|
($this->f->get_submitted_get_value('ret') !== null ? $retourformulaire = $this->f->get_submitted_get_value('ret') : $retourformulaire = ""); |
416 |
|
|
($this->f->get_submitted_get_value('date_envoi') !== null ? $date_envoi = $this->f->get_submitted_get_value('date_envoi') : $date_envoi = ""); |
417 |
|
|
/*Récupération des données et formatage.*/ |
418 |
|
|
$donnees_temp = explode(';', $this->f->get_submitted_get_value('data')); |
419 |
|
|
for ( $i = 1 ; $i < count($donnees_temp) ; $i++ ) |
420 |
|
|
$donnees[] = explode('_', $donnees_temp[$i]); |
421 |
|
|
/* Nombre de consultations papier à générer */ |
422 |
|
|
$nbConsPap = 0; |
423 |
|
|
|
424 |
|
|
/* Ajout des données en base de données |
425 |
|
|
* 0 : l'ID du service |
426 |
|
|
* 1 : consultation papier {0,1} |
427 |
|
|
* */ |
428 |
|
|
if ( isset($donnees) && count($donnees) > 0 ) { |
429 |
|
|
|
430 |
|
|
foreach ($donnees as $value) { |
431 |
|
|
|
432 |
|
|
$sql = "SELECT delai, id |
433 |
|
|
FROM ".DB_PREFIXE."service |
434 |
|
|
LEFT JOIN ".DB_PREFIXE."om_etat |
435 |
|
|
ON service.edition = om_etat.om_etat |
436 |
|
|
WHERE service = $value[0]"; |
437 |
|
|
$res = $this->f->db->query($sql); |
438 |
|
|
// Si la récupération de la description de l'avis échoue |
439 |
|
|
if ($this->f->isDatabaseError($res, true)) { |
440 |
|
|
// Appel de la methode de recuperation des erreurs |
441 |
|
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
442 |
|
|
$this->correct = false; |
443 |
|
|
return false; |
444 |
|
|
} |
445 |
|
|
$row=& $res->fetchRow(); |
446 |
|
|
$delai = $row[0]; |
447 |
|
|
$type_edition = $row[1]; |
448 |
|
|
|
449 |
|
|
/*Calcul du delai de retour*/ |
450 |
|
|
$date_envoi_temp = $this->datePHP($date_envoi); |
451 |
|
|
$delai = $this->dateDB($this->f->mois_date($date_envoi_temp, $delai)); |
452 |
|
|
|
453 |
|
|
/*Les données à ajouter*/ |
454 |
|
|
$arrayVal = array( |
455 |
|
|
'consultation' => "]", |
456 |
|
|
'dossier' => $idx, |
457 |
|
|
'date_envoi' => $date_envoi, |
458 |
|
|
'date_retour' => NULL, |
459 |
|
|
'date_limite' => $delai, |
460 |
|
|
'service' => $value[0], |
461 |
|
|
'avis_consultation' => NULL, |
462 |
|
|
'date_reception' => NULL, |
463 |
|
|
'motivation' => "", |
464 |
|
|
'fichier' => NULL, |
465 |
|
|
'lu' => TRUE, |
466 |
|
|
'code_barres' => NULL, |
467 |
|
|
'om_final_consultation' => FALSE, |
468 |
|
|
'om_fichier_consultation' => "", |
469 |
|
|
|
470 |
|
|
); |
471 |
|
|
|
472 |
|
|
$res_ajout = $this->ajouter($arrayVal, $this->f->db, DEBUG); |
473 |
|
|
if($res_ajout != true) { |
474 |
|
|
return false; |
475 |
|
|
} |
476 |
|
|
|
477 |
|
|
/*Comptage du nombre de consultations papier demandées et récupération des ids des PDFs à éditer*/ |
478 |
|
|
if ($value[1]==1){ |
479 |
|
|
$idxConsultations[] = $this->valF['consultation']; |
480 |
|
|
$objConsultations[] = $type_edition; |
481 |
|
|
$nbConsPap++; |
482 |
|
|
} |
483 |
|
|
} |
484 |
|
|
|
485 |
|
|
/*Génération du PDF*/ |
486 |
|
|
if ( isset($idxConsultations) && count($idxConsultations) > 0 ){ |
487 |
|
|
|
488 |
|
|
$textIdsConsultations = "idx="; |
489 |
|
|
foreach ($idxConsultations as $value) { |
490 |
|
|
$textIdsConsultations .= $value.";"; |
491 |
|
|
} |
492 |
|
|
$textObjConsultations = "obj="; |
493 |
|
|
foreach ($objConsultations as $value) { |
494 |
|
|
$textObjConsultations .= $value.";"; |
495 |
|
|
} |
496 |
|
|
echo " |
497 |
|
|
<script language='javascript' type='text/javascript'> |
498 |
|
|
window.open('../pdf/pdfetat.php?output=inline&".$textObjConsultations."&".$textIdsConsultations."','_blank') |
499 |
|
|
</script> |
500 |
|
|
"; |
501 |
|
|
} |
502 |
|
|
$return_url = "../scr/soustab.php?"; |
503 |
|
|
$return_url .= "obj=consultation"; |
504 |
|
|
$return_url .= "&retourformulaire=".$this->getParameter("retourformulaire"); |
505 |
|
|
$return_url .= "&idxformulaire=".$this->getParameter("idxformulaire"); |
506 |
|
|
$return_url .= "&premier=".$this->getParameter("premiersf"); |
507 |
|
|
$return_url .= "&tricol=".$this->getParameter("tricolsf"); |
508 |
|
|
|
509 |
|
|
/*Affichage du message d'information*/ |
510 |
|
|
$this->f->displayMessage("valid", count($donnees)._(' service(s) selectionne(s) dont ').$nbConsPap._(' consultation(s) papier.')); |
511 |
|
|
|
512 |
|
|
|
513 |
|
|
return true; |
514 |
|
|
} |
515 |
|
|
} |
516 |
|
|
|
517 |
|
|
|
518 |
|
|
/** |
519 |
|
|
* VIEW - view_ajout_multiple. |
520 |
|
|
* |
521 |
|
|
* Formulaire specifique |
522 |
|
|
* |
523 |
|
|
* @return void |
524 |
|
|
*/ |
525 |
|
|
function view_ajout_multiple() { |
526 |
|
|
|
527 |
|
|
if (count($this->f->get_submitted_get_value()) > 0 |
528 |
|
|
&& $this->f->get_submitted_get_value('data') !== null |
529 |
|
|
&& $this->f->get_submitted_get_value('data') != "" ) { |
530 |
|
|
$this->f->disableLog(); |
531 |
|
|
$this->ajouter_multiple(); |
532 |
|
|
|
533 |
|
|
} else { |
534 |
|
|
|
535 |
|
|
// Vérification de l'accessibilité sur l'élément |
536 |
|
|
$this->checkAccessibility(); |
537 |
|
|
// |
538 |
|
|
$datasubmit = $this->getDataSubmitSousForm(); |
539 |
|
|
$return_url = "../scr/soustab.php?"; |
540 |
|
|
$return_url .= "obj=consultation"; |
541 |
|
|
$return_url .= "&retourformulaire=".$this->getParameter("retourformulaire"); |
542 |
|
|
$return_url .= "&idxformulaire=".$this->getParameter("idxformulaire"); |
543 |
|
|
$return_url .= "&premier=".$this->getParameter("premiersf"); |
544 |
|
|
$return_url .= "&tricol=".$this->getParameter("tricolsf"); |
545 |
|
|
// Légende du fieldset |
546 |
|
|
$title = _("Objet"); |
547 |
|
|
/*Requête qui récupère les services qui sont dans des thématiques*/ |
548 |
|
|
$sql = |
549 |
|
|
"SELECT |
550 |
|
|
ser_cat.service_categorie, ser_cat.libelle AS them_lib, |
551 |
|
|
ser.service, ser.libelle AS ser_lib, ser.consultation_papier |
552 |
|
|
FROM |
553 |
|
|
".DB_PREFIXE."lien_service_service_categorie lie, |
554 |
|
|
".DB_PREFIXE."service_categorie ser_cat, |
555 |
|
|
".DB_PREFIXE."service ser |
556 |
|
|
WHERE |
557 |
|
|
ser_cat.service_categorie = lie.service_categorie AND |
558 |
|
|
ser.service = lie.service AND |
559 |
|
|
( |
560 |
|
|
(ser.om_validite_debut IS NULL |
561 |
|
|
AND (ser.om_validite_fin IS NULL |
562 |
|
|
OR ser.om_validite_fin > CURRENT_DATE)) |
563 |
|
|
OR |
564 |
|
|
(ser.om_validite_debut <= CURRENT_DATE |
565 |
|
|
AND (ser.om_validite_fin IS NULL |
566 |
|
|
OR ser.om_validite_fin > CURRENT_DATE)) |
567 |
|
|
) |
568 |
|
|
ORDER BY them_lib, ser_lib |
569 |
|
|
"; |
570 |
|
|
|
571 |
|
|
$res = $this->f->db->query($sql); |
572 |
|
|
$this->f->addToLog( |
573 |
|
|
"app/consultation_multiple.php: db->query(\"".$sql."\")", VERBOSE_MODE |
574 |
|
|
); |
575 |
|
|
$this->f->isDatabaseError($res); |
576 |
|
|
|
577 |
|
|
$temp_ser_cat = 0; |
578 |
|
|
$liste_gauche = ""; |
579 |
|
|
|
580 |
|
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
581 |
|
|
$name = $row['service_categorie'].'_'. |
582 |
|
|
$row['service'].'_'. |
583 |
|
|
(($row['consultation_papier'] == '' || $row['consultation_papier'] == 'f' ) ? '0' : '1' ).'_'; |
584 |
|
|
// On change de thématique, donc rajoute le nom de la thématique |
585 |
|
|
if ( $temp_ser_cat != $row['service_categorie'] ){ |
586 |
|
|
|
587 |
|
|
$temp_ser_cat = $row['service_categorie']; |
588 |
|
|
$liste_gauche .= ' |
589 |
|
|
<div id="them_'.$row['service_categorie'].'" class="liste_gauche_them" >'. |
590 |
|
|
$row['them_lib']. |
591 |
|
|
'</div> |
592 |
|
|
<div |
593 |
|
|
class="liste_gauche_service t'.$name.'" |
594 |
|
|
id="t'.$name.'" > |
595 |
|
|
'.$row['ser_lib'].' |
596 |
|
|
<input class="t'.$name.'" type="checkbox" '.(($row['consultation_papier'] == '' || $row['consultation_papier'] == 'f' ) ? '' : 'checked="checked"' ).'/> |
597 |
|
|
</div> |
598 |
|
|
'; |
599 |
|
|
} |
600 |
|
|
|
601 |
|
|
/*On est dans la même thématique*/ |
602 |
|
|
else { |
603 |
|
|
|
604 |
|
|
$liste_gauche .= ' |
605 |
|
|
<div |
606 |
|
|
class="liste_gauche_service t'.$name.'" |
607 |
|
|
id="t'.$name.'" > |
608 |
|
|
'.$row['ser_lib'].' |
609 |
|
|
<input class="t'.$name.'" type="checkbox" '.(($row['consultation_papier'] == '' || $row['consultation_papier'] == 'f' ) ? '' : 'checked="checked"' ).'/> |
610 |
|
|
</div> |
611 |
|
|
'; |
612 |
|
|
} |
613 |
|
|
|
614 |
|
|
} |
615 |
|
|
|
616 |
|
|
/*Requête qui récupère les services qui ne sont pas dans une thématique*/ |
617 |
|
|
$sql = |
618 |
nhaye |
3414 |
"SELECT service.service, service.libelle, service.consultation_papier |
619 |
nhaye |
3395 |
FROM ".DB_PREFIXE."service |
620 |
|
|
WHERE service NOT IN |
621 |
|
|
( |
622 |
|
|
SELECT service |
623 |
|
|
FROM ".DB_PREFIXE."lien_service_service_categorie |
624 |
|
|
) |
625 |
|
|
AND |
626 |
|
|
( |
627 |
|
|
om_validite_fin <= CURRENT_DATE OR |
628 |
|
|
om_validite_fin IS NULL |
629 |
|
|
) |
630 |
|
|
"; |
631 |
|
|
|
632 |
|
|
$res = $this->f->db->query($sql); |
633 |
|
|
$this->f->isDatabaseError($res); |
634 |
|
|
|
635 |
|
|
if ($res->numrows() > 0) { |
636 |
|
|
$liste_gauche .= ' |
637 |
|
|
<div id="them_0" class="liste_gauche_them">Autres</div>'; |
638 |
|
|
} |
639 |
|
|
|
640 |
|
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
641 |
|
|
|
642 |
|
|
/*Ajout de tous les services qui n'ont pas de thématique*/ |
643 |
|
|
$name = '0_'. |
644 |
|
|
$row['service'].'_'. |
645 |
|
|
(($row['consultation_papier'] == '' || $row['consultation_papier'] == 'f' ) ? '0' : '1' ).'_'; |
646 |
|
|
$liste_gauche .= ' |
647 |
|
|
<div |
648 |
|
|
class="liste_gauche_service t'.$name.'" |
649 |
|
|
id="t'.$name.'" > |
650 |
|
|
'.$row['libelle'].' |
651 |
|
|
<input class="t'.$name.'" type="checkbox" '.(($row['consultation_papier'] == '' || $row['consultation_papier'] == 'f' ) ? '' : 'checked="checked"' ).'/> |
652 |
|
|
</div> |
653 |
|
|
'; |
654 |
|
|
} |
655 |
|
|
|
656 |
|
|
/*Affichage du formulaire*/ |
657 |
|
|
echo "\n<!-- ########## START DBFORM ########## -->\n"; |
658 |
|
|
echo "<form"; |
659 |
|
|
echo " method=\"post\""; |
660 |
|
|
echo " name=\"f2\""; |
661 |
|
|
echo " action=\"\""; |
662 |
|
|
echo " id=\"form_val\""; |
663 |
|
|
//echo " onsubmit=\"ajaxIt('consultation', '');return false;\""; |
664 |
|
|
|
665 |
|
|
//echo " onsubmit=\"affichersform('".$this->getParameter("objsf")."', '".$datasubmit."', this);\""; |
666 |
|
|
echo ">\n"; |
667 |
|
|
echo '<div class="formEntete ui-corner-all">'; |
668 |
|
|
echo "<div>"; |
669 |
|
|
echo '<div class="bloc">'; |
670 |
|
|
echo "<fieldset class='cadre ui-corner-all ui-widget-content'>\n"; |
671 |
|
|
echo "\t<legend class='ui-corner-all ui-widget-content ui-state-active'>". |
672 |
|
|
_("Consultation par thematique ")."</legend>"; |
673 |
|
|
echo "<div class='fieldsetContent' style='width:100%'>"; |
674 |
|
|
echo '<div class="field-ser-them field-type-hiddenstatic">'; |
675 |
|
|
echo '<div class="form-libelle">'; |
676 |
|
|
echo '<label class="libelle-dossier" for="dossier">'; |
677 |
|
|
echo _('dossier'); |
678 |
|
|
echo '<span class="not-null-tag">*</span>'; |
679 |
|
|
echo '</label>'; |
680 |
|
|
echo '</div>'; |
681 |
|
|
echo '<div class="form-content">'; |
682 |
|
|
echo '<input class="champFormulaire" type="hidden" value="'.$this->getParameter("idxformulaire").'" name="dossier"/>'; |
683 |
|
|
echo $this->getParameter("idxformulaire"); |
684 |
|
|
echo '</div>'; |
685 |
|
|
echo '</div>'; |
686 |
|
|
/*Code du nouveau champ*/ |
687 |
|
|
echo '<div class="field-ser-them ser-them">'; |
688 |
|
|
echo '<div class="list-ser-them">'; |
689 |
|
|
echo $liste_gauche; |
690 |
|
|
echo '</div>'; |
691 |
|
|
echo '<div class="button-ser-them">'; |
692 |
|
|
echo '<ul>'; |
693 |
|
|
echo '<li>'; |
694 |
|
|
echo '<input type="button" value="'._("Ajouter").' >>" id="add-ser-them"/>'; |
695 |
|
|
echo '</li>'; |
696 |
|
|
echo '<li>'; |
697 |
|
|
echo '<input type="button" value="<< '._("Supprimer").'" id="del-ser-them"/>'; |
698 |
|
|
echo '</li>'; |
699 |
|
|
echo '</ul>'; |
700 |
|
|
echo '</div>'; |
701 |
|
|
echo '<div class="list-sel-ser-them">'; |
702 |
|
|
echo '<div class=\'row row_title\'>'; |
703 |
|
|
echo '<div class=\'cell1 liste_droite_title list-sel-ser-them-title\'>'._('Service a consulter').'</div>'; |
704 |
|
|
echo '<div class=\'cell2 liste_droite_title list-sel-ser-them-title\'>'._('Version papier').'</div>'; |
705 |
|
|
echo '</div>'; |
706 |
|
|
echo '</div>'; |
707 |
|
|
echo '</div>'; |
708 |
|
|
/* -- FIN --*/ |
709 |
|
|
echo '<div class="field-ser-them field-type-date2">'; |
710 |
|
|
echo '<div class="form-libelle">'; |
711 |
|
|
echo '<label class="libelle-date_envoi" for="date_envoi">'; |
712 |
|
|
echo _('date_envoi'); |
713 |
|
|
echo '<span class="not-null-tag">*</span>'; |
714 |
|
|
echo '</label>'; |
715 |
|
|
echo '</div>'; |
716 |
|
|
echo '<div class="form-content">'; |
717 |
|
|
echo '<input id="date_envoi" class="champFormulaire datepicker" |
718 |
|
|
type="text" onkeyup="" onchange="fdate(this)" |
719 |
|
|
maxlength="10" size="12" value="'.date("d/m/Y").'" |
720 |
|
|
name="date_envoi">'; |
721 |
|
|
echo '</div>'; |
722 |
|
|
echo '</div>'; |
723 |
|
|
echo "</div>"; |
724 |
|
|
echo "</fieldset>"; |
725 |
|
|
echo '</div>'; |
726 |
|
|
echo '</div>'; |
727 |
|
|
echo '</div>'; |
728 |
|
|
echo '<div class="formControls">'; |
729 |
|
|
|
730 |
|
|
echo '<div class="formControls">'; |
731 |
|
|
echo "<input class=\"om-button ui-button ui-widget ui-state-default ui-corner-all\" |
732 |
|
|
type=\"button\" |
733 |
|
|
|
734 |
|
|
value=\"Ajouter le(s) enregistrement(s) de la table : 'Consultation'\" |
735 |
|
|
id=\"button_val\">"; |
736 |
|
|
$this->retoursousformulaire( |
737 |
|
|
$this->getParameter("idxformulaire"), |
738 |
|
|
$this->getParameter("retourformulaire"), |
739 |
|
|
null, |
740 |
|
|
$this->getParameter("objsf"), |
741 |
|
|
$this->getParameter("premiersf"), |
742 |
|
|
$this->getParameter("tricolsf"), |
743 |
|
|
$this->getParameter("validation"), |
744 |
|
|
$this->getParameter("idx"), |
745 |
|
|
$this->getParameter("maj"), |
746 |
|
|
$this->getParameter("retour") |
747 |
|
|
); |
748 |
|
|
echo '</div>'; |
749 |
|
|
echo '</div>'; |
750 |
|
|
echo '</form>'; |
751 |
|
|
|
752 |
|
|
echo " |
753 |
|
|
<script language='javascript' type='text/javascript'> |
754 |
|
|
$(function(){ |
755 |
|
|
changeActionVal(''); |
756 |
|
|
/* |
757 |
|
|
Sélectionne tous les services d'un thème au clique sur celui ci. |
758 |
|
|
*/ |
759 |
|
|
$('.liste_gauche_them').click( |
760 |
|
|
function(){ |
761 |
|
|
|
762 |
|
|
var id = $(this).attr('id').split('_')[1]; |
763 |
|
|
var numSer = 0; |
764 |
|
|
var numSerWithClass = 0; |
765 |
|
|
|
766 |
|
|
$('.list-ser-them div').each( |
767 |
|
|
function() { |
768 |
|
|
|
769 |
|
|
if ( $(this).attr('id').indexOf('them') == -1 && |
770 |
|
|
$(this).attr('id').indexOf(id) == 1 && |
771 |
|
|
$(this).hasClass('liste_gauche_service_selected') ) |
772 |
|
|
|
773 |
|
|
numSerWithClass++; |
774 |
|
|
|
775 |
|
|
if ( $(this).attr('id').indexOf('them') == -1 && |
776 |
|
|
$(this).attr('id').indexOf(id) == 1 ) |
777 |
|
|
|
778 |
|
|
numSer++; |
779 |
|
|
} |
780 |
|
|
); |
781 |
|
|
|
782 |
|
|
if ( numSerWithClass < numSer && numSerWithClass >= 0 ){ |
783 |
|
|
|
784 |
|
|
$('.list-ser-them div').each( |
785 |
|
|
function() { |
786 |
|
|
|
787 |
|
|
if ( $(this).attr('id').indexOf('them') == -1 && |
788 |
|
|
$(this).attr('id').indexOf(id) == 1 && |
789 |
|
|
!$(this).hasClass('liste_gauche_service_selected') ) |
790 |
|
|
|
791 |
|
|
$(this).addClass('liste_gauche_service_selected'); |
792 |
|
|
} |
793 |
|
|
); |
794 |
|
|
} |
795 |
|
|
|
796 |
|
|
else { |
797 |
|
|
|
798 |
|
|
$('.list-ser-them div').each( |
799 |
|
|
function() { |
800 |
|
|
|
801 |
|
|
if ( $(this).attr('id').indexOf('them') == -1 && |
802 |
|
|
$(this).attr('id').indexOf(id) == 1 && |
803 |
|
|
$(this).hasClass('liste_gauche_service_selected') ) |
804 |
|
|
|
805 |
|
|
$(this).removeClass('liste_gauche_service_selected'); |
806 |
|
|
} |
807 |
|
|
); |
808 |
|
|
} |
809 |
|
|
} |
810 |
|
|
); |
811 |
|
|
|
812 |
|
|
/* |
813 |
|
|
Change la class CSS d'un service sur lequel on clique dans la liste de gauche. |
814 |
|
|
*/ |
815 |
|
|
$('.liste_gauche_service').click( |
816 |
|
|
function(){ |
817 |
|
|
$(this).toggleClass('liste_gauche_service_selected'); |
818 |
|
|
} |
819 |
|
|
); |
820 |
|
|
|
821 |
|
|
/* |
822 |
|
|
Change la class CSS d'un service sur lequel on clique dans la liste de droite. |
823 |
|
|
*/ |
824 |
|
|
$('.field-ser-them').on( |
825 |
|
|
'click', |
826 |
|
|
'.cell1', |
827 |
|
|
function(){ |
828 |
|
|
if ( !$(this).hasClass('liste_droite_title') ) |
829 |
|
|
$(this).parent().toggleClass('liste_droite_service_selected'); |
830 |
|
|
} |
831 |
|
|
); |
832 |
|
|
|
833 |
|
|
$('.liste_droite_service input[type=checkbox]').live( |
834 |
|
|
'click', |
835 |
|
|
'input[type=checkbox]', |
836 |
|
|
function(){ |
837 |
|
|
|
838 |
|
|
old_id = $(this).attr('class'); |
839 |
|
|
|
840 |
|
|
tab_don = old_id.split('_'); |
841 |
|
|
|
842 |
|
|
new_id = tab_don[0] + '_' + tab_don[1] + '_' + ((tab_don[2] == 0 ) ? 1 : 0 ) + '_'; |
843 |
|
|
|
844 |
|
|
changeOneData( ';' + tab_don[1] + '_' + tab_don[2], ';' + tab_don[1] + '_' + ((tab_don[2] == 0) ? 1 : 0) ); |
845 |
|
|
$('div[class=\"' + old_id + '\"]').attr('class', new_id); |
846 |
|
|
$(this).attr('class', new_id); |
847 |
|
|
|
848 |
|
|
} |
849 |
|
|
); |
850 |
|
|
|
851 |
|
|
$('#date_envoi').change( |
852 |
|
|
function (){ |
853 |
|
|
|
854 |
|
|
var listServ = new Array(); |
855 |
|
|
var data = ''; |
856 |
|
|
|
857 |
|
|
$('.liste_gauche_service_selected').each( |
858 |
|
|
function(i) { |
859 |
|
|
|
860 |
|
|
var name = $(this).attr('name'); |
861 |
|
|
|
862 |
|
|
if ( listServ.length > 0 && listServ.indexOf(name.split('_')[1]) != -1 ) |
863 |
|
|
return; |
864 |
|
|
listServ[i] = name.split('_')[1]; |
865 |
|
|
data += ';' + name.split('_')[1] + '_' + name.split('_')[2] ; |
866 |
|
|
|
867 |
|
|
} |
868 |
|
|
); |
869 |
|
|
|
870 |
|
|
changeActionVal(data); |
871 |
|
|
} |
872 |
|
|
); |
873 |
|
|
|
874 |
|
|
/* |
875 |
|
|
Passe les services sélectionnés dans la liste de gauche dans celle de droite. |
876 |
|
|
*/ |
877 |
|
|
$('#add-ser-them').click( |
878 |
|
|
function() { |
879 |
|
|
|
880 |
|
|
changeDataLeftColumn(); |
881 |
|
|
} |
882 |
|
|
); |
883 |
|
|
|
884 |
|
|
/* |
885 |
|
|
Passe les services sélectionnés dans la liste de droite dans celle de gauche. |
886 |
|
|
*/ |
887 |
|
|
$('#del-ser-them').click( |
888 |
|
|
function() { |
889 |
|
|
|
890 |
|
|
var data = ''; |
891 |
|
|
|
892 |
|
|
//Supprime les éléments de la liste de droite |
893 |
|
|
$('.liste_droite_service_selected').each( |
894 |
|
|
function() { |
895 |
|
|
|
896 |
|
|
var name = $('#'+ $(this).attr('id') + ' .cell1 div').attr('name'); |
897 |
|
|
|
898 |
|
|
manageListServ('.list-ser-them div', name, 1); |
899 |
|
|
|
900 |
|
|
$(this).remove(); |
901 |
|
|
} |
902 |
|
|
); |
903 |
|
|
|
904 |
|
|
//Change les valeurs qui vont être renvoyées à la validation du formulaire |
905 |
|
|
$('.liste_droite_service').each( |
906 |
|
|
function(){ |
907 |
|
|
|
908 |
|
|
var name = $('#'+ $(this).attr('id') + ' .cell1 div').attr('name'); |
909 |
|
|
data += ';' + name.split('_')[1] + '_' + name.split('_')[2] ; |
910 |
|
|
} |
911 |
|
|
); |
912 |
|
|
|
913 |
|
|
changeActionVal(data); |
914 |
|
|
} |
915 |
|
|
); |
916 |
|
|
}); |
917 |
|
|
|
918 |
|
|
/* |
919 |
|
|
Vérifie que l'objet n'est pas une thématique et que son identifiant correspond. |
920 |
|
|
*/ |
921 |
|
|
function isNotthemIsOneServ( objet, id ){ |
922 |
|
|
return ( $(objet).attr('id').indexOf('them') == -1 && |
923 |
|
|
$(objet).attr('id').indexOf('_' + id.split('_')[1] + '_') != -1 ); |
924 |
|
|
} |
925 |
|
|
|
926 |
|
|
/* |
927 |
|
|
Affiche ou cache un élément qui n'est pas une thématique et dont son identifiant correspond. |
928 |
|
|
*/ |
929 |
|
|
function manageListServ( objet , name, type){ |
930 |
|
|
|
931 |
|
|
$(objet).each( |
932 |
|
|
function() { |
933 |
|
|
|
934 |
|
|
if ( isNotthemIsOneServ(this, name) ){ |
935 |
|
|
if ( type == 0 ) |
936 |
|
|
|
937 |
|
|
$(this).hide() ; |
938 |
|
|
|
939 |
|
|
else { |
940 |
|
|
|
941 |
|
|
if ( $(this).hasClass('liste_gauche_service_selected') ) |
942 |
|
|
|
943 |
|
|
$(this).toggleClass('liste_gauche_service_selected'); |
944 |
|
|
|
945 |
|
|
$(this).show() ; |
946 |
|
|
|
947 |
|
|
} |
948 |
|
|
} |
949 |
|
|
} |
950 |
|
|
); |
951 |
|
|
} |
952 |
|
|
|
953 |
|
|
/* |
954 |
|
|
Change les actions qui sont réalisées lors de la soumission du formulaire |
955 |
|
|
*/ |
956 |
|
|
function changeActionVal(data){ |
957 |
|
|
date = $('#date_envoi').val(); |
958 |
|
|
|
959 |
|
|
|
960 |
|
|
|
961 |
|
|
$('#button_val').attr( |
962 |
|
|
'onclick', |
963 |
|
|
'if ( $(\'.liste_gauche_service_selected\').length > 0 && $(\'#date_envoi\').val() != \'\' ) { messageIt(\'consultation\', \'".html_entity_decode($datasubmit)."&data='+data+'&date_envoi='+date+'\',true);' + |
964 |
|
|
'messageIt(\'consultation\', \'".html_entity_decode($return_url)."\',false);} else alert(\'Veuillez choisir au moins un service et une date d envoi\');' |
965 |
|
|
|
966 |
|
|
); |
967 |
|
|
|
968 |
|
|
} |
969 |
|
|
|
970 |
|
|
/* |
971 |
|
|
Change les actions qui sont réalisées lors de la soumission du formulaire |
972 |
|
|
*/ |
973 |
|
|
function changeOneData( oldData, newData) { |
974 |
|
|
|
975 |
|
|
date = $('#date_envoi').val(); |
976 |
|
|
|
977 |
|
|
$('#button_val').attr( |
978 |
|
|
'onclick', |
979 |
|
|
$('#button_val').attr('onclick').replace(oldData,newData) |
980 |
|
|
); |
981 |
|
|
|
982 |
|
|
} |
983 |
|
|
|
984 |
|
|
function changeDataLeftColumn(){ |
985 |
|
|
|
986 |
|
|
$('.list-sel-ser-them').empty(); |
987 |
|
|
$('.list-sel-ser-them').html( |
988 |
|
|
'<div class=\"row row_title\">' + |
989 |
|
|
'<div class=\"cell1 liste_droite_title list-sel-ser-them-title\">"._("Service a consulter")."</div>' + |
990 |
|
|
'<div class=\"cell2 liste_droite_title list-sel-ser-them-title\">"._("Version papier")."</div>' + |
991 |
|
|
'</div>' |
992 |
|
|
); |
993 |
|
|
|
994 |
|
|
var listServ = new Array(); |
995 |
|
|
var data = ''; |
996 |
|
|
|
997 |
|
|
$('.liste_gauche_service_selected').each( |
998 |
|
|
function(i) { |
999 |
|
|
|
1000 |
|
|
var id = $(this).attr('id'); |
1001 |
|
|
|
1002 |
|
|
if ( $.inArray(id.split('_')[1], listServ) != -1 ) |
1003 |
|
|
return; |
1004 |
|
|
|
1005 |
|
|
data += ';' + id.split('_')[1] + '_' + id.split('_')[2] ; |
1006 |
|
|
listServ[i] = id.split('_')[1]; |
1007 |
|
|
|
1008 |
|
|
$('.list-sel-ser-them').append( |
1009 |
|
|
'<div id=\'s' + i + '\' class=\'row liste_droite_service\'>'+ |
1010 |
|
|
'<div class=\'cell1\'>'+ |
1011 |
|
|
'<div class=\'' + $(this).attr('id') + '\' name=\'' + $(this).attr('id') + '\'>'+ |
1012 |
|
|
$(this).html().split('<')[0]+ |
1013 |
|
|
'</div>'+ |
1014 |
|
|
'</div>' + |
1015 |
|
|
'<div class=\'cell2\'>'+ |
1016 |
|
|
'<div>'+ |
1017 |
|
|
'<input class=\'' + $(this).attr('id') + '\''+$(this).html().split('<input')[1]+ |
1018 |
|
|
'</div>'+ |
1019 |
|
|
'</div>'+ |
1020 |
|
|
'</div>' |
1021 |
|
|
); |
1022 |
|
|
|
1023 |
|
|
$(this).hide(); |
1024 |
|
|
|
1025 |
|
|
manageListServ('.list-ser-them div', id, 0); |
1026 |
|
|
|
1027 |
|
|
} |
1028 |
|
|
); |
1029 |
|
|
changeActionVal(data); |
1030 |
|
|
} |
1031 |
|
|
</script>"; |
1032 |
|
|
} |
1033 |
|
|
|
1034 |
|
|
} |
1035 |
|
|
|
1036 |
fraynaud |
20 |
function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire){ |
1037 |
nhaye |
1683 |
// ajout du retourformulaire aux attributs de l'objet |
1038 |
|
|
$this->retourformulaire = $retourformulaire; |
1039 |
fraynaud |
20 |
if ($validation==0) { |
1040 |
nhaye |
3395 |
if ($maj == 0 or $maj == 40){ |
1041 |
nhaye |
569 |
$form->setVal("dossier", $idxformulaire); |
1042 |
|
|
$form->setVal("date_envoi",date('d/m/Y')); |
1043 |
fraynaud |
20 |
} |
1044 |
nhaye |
3395 |
if($maj == 1 or $maj == 90 or $maj == 100) { |
1045 |
nhaye |
594 |
if($this->f->isAccredited('consultation_retour_avis_suivi') OR |
1046 |
|
|
$this->f->isAccredited('consultation_retour_avis_service')) { |
1047 |
|
|
$form->setVal("date_retour",date('d/m/Y')); |
1048 |
|
|
} |
1049 |
nhaye |
587 |
} |
1050 |
fraynaud |
20 |
} |
1051 |
|
|
} |
1052 |
nhaye |
587 |
|
1053 |
nhaye |
3414 |
function setVal(&$form, $maj, $validation) { |
1054 |
nhaye |
3395 |
if($maj == 1 or $maj == 90 or $maj == 100) { |
1055 |
nhaye |
587 |
$form->setVal("date_retour",date('d/m/Y')); |
1056 |
|
|
} |
1057 |
|
|
} |
1058 |
fraynaud |
20 |
|
1059 |
nhaye |
561 |
function setvalF($val) { |
1060 |
fmichon |
1730 |
// |
1061 |
nhaye |
561 |
parent::setValF($val); |
1062 |
fmichon |
1730 |
// |
1063 |
nhaye |
3395 |
if ($this->getParameter('maj') == 0 or $this->getParameter('maj') == 40) { |
1064 |
fmichon |
1730 |
// |
1065 |
|
|
if (isset($this->valF["date_envoi"])) { |
1066 |
|
|
$this->valF["date_reception"] = $this->valF["date_envoi"]; |
1067 |
|
|
} |
1068 |
|
|
// |
1069 |
fmichon |
1172 |
$this->valF["lu"] = true; |
1070 |
nhaye |
587 |
} |
1071 |
nhaye |
598 |
|
1072 |
nhaye |
561 |
// Si un retour d'avis est modifie on passe "lu" a false |
1073 |
nhaye |
3395 |
if(($this->getParameter('maj')==90 or $this->getParameter('maj')==100 ) and ( |
1074 |
nhaye |
598 |
$this->val[array_search("avis_consultation",$this->champs)] != $val["avis_consultation"] OR |
1075 |
|
|
$this->val[array_search("date_retour",$this->champs)] != $val["date_retour"] OR |
1076 |
|
|
$this->val[array_search("motivation",$this->champs)] != $val["motivation"] OR |
1077 |
nhaye |
674 |
$this->val[array_search("fichier",$this->champs)] != $val["fichier"]) |
1078 |
nhaye |
598 |
) { |
1079 |
|
|
$this->valF["lu"]=false; |
1080 |
nhaye |
561 |
} |
1081 |
nhaye |
675 |
} |
1082 |
fmichon |
1730 |
|
1083 |
|
|
function setLib(&$form, $maj) { |
1084 |
|
|
// |
1085 |
|
|
parent::setLib($form, $maj); |
1086 |
|
|
// |
1087 |
|
|
$form->setLib($this->clePrimaire, _("id")); |
1088 |
|
|
} |
1089 |
|
|
|
1090 |
fraynaud |
20 |
function setType(&$form,$maj) { |
1091 |
fmichon |
671 |
// Appel du parent |
1092 |
nhaye |
459 |
parent::setType($form,$maj); |
1093 |
softime |
2112 |
$form->setType('dossier', 'hidden'); |
1094 |
fmichon |
671 |
// MODE - AJOUTER |
1095 |
|
|
if ($maj == 0) { |
1096 |
|
|
// On cache alors tous les champs que nous ne voulons pas voir |
1097 |
|
|
// apparaître dans le formulaire d'ajout (principalement les |
1098 |
|
|
// informations sur le retour d'avis) |
1099 |
nmeucci |
2857 |
$form->setType('date_retour', 'hiddendate'); |
1100 |
|
|
$form->setType('date_reception', 'hiddendate'); |
1101 |
|
|
$form->setType('date_limite', 'hiddendate'); |
1102 |
fmichon |
671 |
$form->setType('avis_consultation', 'hidden'); |
1103 |
|
|
$form->setType('motivation', 'hidden'); |
1104 |
|
|
$form->setType('fichier', 'hidden'); |
1105 |
|
|
$form->setType('lu', 'hidden'); |
1106 |
|
|
// On permet la modification de certains champs |
1107 |
softime |
2112 |
$form->setType('dossier_libelle', 'hiddenstatic'); |
1108 |
fmichon |
671 |
$form->setType('service', 'select'); |
1109 |
|
|
$form->setType('date_envoi', 'date2'); |
1110 |
|
|
} |
1111 |
|
|
// MODE - MODIFIER |
1112 |
|
|
if ($maj == 1) { |
1113 |
|
|
|
1114 |
|
|
// On affiche en statique les informations qui ne sont plus |
1115 |
|
|
// modifiables |
1116 |
softime |
2112 |
$form->setType('dossier_libelle', 'hiddenstatic'); |
1117 |
fmichon |
671 |
$form->setType('date_envoi', 'hiddenstaticdate'); |
1118 |
|
|
$form->setType('date_limite', 'hiddenstaticdate'); |
1119 |
|
|
$form->setType('service', 'selecthiddenstatic'); |
1120 |
|
|
|
1121 |
|
|
// La date de réception ne peut être modifiée que par un |
1122 |
|
|
// utilisateur en ayant spécifiquement la permission |
1123 |
|
|
if($this->f->isAccredited('consultation_modifier_date_reception')) { |
1124 |
|
|
$form->setType('date_reception', 'date2'); |
1125 |
|
|
} else { |
1126 |
|
|
$form->setType('date_reception', 'hiddenstaticdate'); |
1127 |
|
|
} |
1128 |
|
|
|
1129 |
|
|
// Le marqueur lu/non lu ne peut être modifié que par un |
1130 |
|
|
// utilisateur en ayant spécifiquement la permission |
1131 |
|
|
if ($this->f->isAccredited('consultation_modifier_lu')) { |
1132 |
|
|
$form->setType('lu', 'checkbox'); |
1133 |
|
|
} else { |
1134 |
|
|
$form->setType('lu', 'hidden'); |
1135 |
|
|
} |
1136 |
|
|
|
1137 |
|
|
// Gestion du type du widget sur le champ fichier |
1138 |
nhaye |
1683 |
if($this->getVal("fichier") == "" OR |
1139 |
fmichon |
671 |
$this->f->isAccredited('consultation_modifier_fichier')) { |
1140 |
|
|
// Si il n'y a jamais eu de fichier enregistré ou que |
1141 |
|
|
// l'utilisateur a spécifiquement les droits pour modifier |
1142 |
|
|
// un fichier déjà enregistré alors on positionne un type |
1143 |
|
|
// de widget modifiable |
1144 |
nmeucci |
2972 |
if ($this->retourformulaire == "demande_avis_encours" |
1145 |
|
|
|| $this->retourformulaire == "dossier_qualifier" |
1146 |
|
|
|| $this->retourformulaire == "dossier" |
1147 |
|
|
|| $this->retourformulaire == "dossier_instruction" |
1148 |
|
|
|| $this->retourformulaire == "dossier_instruction_mes_encours" |
1149 |
|
|
|| $this->retourformulaire == "dossier_instruction_tous_encours" |
1150 |
|
|
|| $this->retourformulaire == "dossier_instruction_mes_clotures" |
1151 |
|
|
|| $this->retourformulaire == "dossier_instruction_tous_clotures") { |
1152 |
nhaye |
1683 |
$form->setType('fichier', 'upload2'); |
1153 |
|
|
} else { |
1154 |
|
|
$form->setType('fichier', 'upload'); |
1155 |
|
|
} |
1156 |
fmichon |
671 |
} else { |
1157 |
|
|
// Si non on affiche uniquement le nom du fichier |
1158 |
nhaye |
1683 |
$form->setType('fichier', 'file'); |
1159 |
fmichon |
671 |
} |
1160 |
|
|
|
1161 |
fraynaud |
20 |
} |
1162 |
nhaye |
1895 |
// Mode supprimer |
1163 |
|
|
if ($maj == 2) { |
1164 |
|
|
$form->setType('fichier', 'filestatic'); |
1165 |
|
|
} |
1166 |
nhaye |
674 |
// MODE - CONSULTER |
1167 |
|
|
if ( $maj == 3 ) { |
1168 |
nhaye |
1683 |
$form->setType('fichier', 'file'); |
1169 |
nhaye |
674 |
} |
1170 |
nhaye |
3395 |
// Mode - retour d'avis |
1171 |
|
|
// Modification layout : écran de retour d'avis permettant |
1172 |
|
|
// uniquement la saisie des trois champs : avis, motivation et fichier |
1173 |
|
|
if ( $maj == 90 ) { |
1174 |
|
|
|
1175 |
|
|
$form->setType("consultation", "hiddenstatic"); |
1176 |
|
|
if ($this->is_in_context_of_foreign_key("avis_consultation", $this->retourformulaire)) { |
1177 |
|
|
$form->setType("avis_consultation", "selecthiddenstatic"); |
1178 |
|
|
} else { |
1179 |
|
|
$form->setType("avis_consultation", "select"); |
1180 |
|
|
} |
1181 |
|
|
$form->setType("motivation", "textarea"); |
1182 |
|
|
$form->setType('fichier', 'upload2'); |
1183 |
|
|
|
1184 |
|
|
// On cache alors tous les champs que nous ne voulons pas voir |
1185 |
|
|
$form->setType('dossier_libelle', 'hidden'); |
1186 |
|
|
$form->setType('service', 'hidden'); |
1187 |
|
|
$form->setType('date_envoi', 'hiddendate'); |
1188 |
|
|
$form->setType('date_retour', 'hiddendate'); |
1189 |
|
|
$form->setType('date_reception', 'hiddendate'); |
1190 |
|
|
$form->setType('date_limite', 'hiddendate'); |
1191 |
|
|
$form->setType('lu', 'hidden'); |
1192 |
|
|
|
1193 |
|
|
} |
1194 |
|
|
|
1195 |
|
|
// MODE - retour de consultation par suivi des date |
1196 |
|
|
if ($maj == 100) { |
1197 |
|
|
$form->setType("consultation", "hiddenstatic"); |
1198 |
|
|
$form->setType('dossier_libelle', 'hiddenstatic'); |
1199 |
|
|
$form->setType('date_envoi', 'hiddenstaticdate'); |
1200 |
|
|
$form->setType('date_limite', 'hiddenstaticdate'); |
1201 |
|
|
$form->setType('date_reception', 'hiddenstaticdate'); |
1202 |
|
|
$form->setType('service', 'selecthiddenstatic'); |
1203 |
|
|
$form->setType('date_retour', 'date'); |
1204 |
|
|
$form->setType('lu', 'hidden'); |
1205 |
|
|
$form->setType("avis_consultation", "select"); |
1206 |
|
|
$form->setType("motivation", "textarea"); |
1207 |
|
|
$form->setType('fichier', 'upload'); |
1208 |
|
|
|
1209 |
|
|
} |
1210 |
fmichon |
671 |
//// On cache la clé primaire |
1211 |
|
|
//$form->setType('consultation', 'hidden'); |
1212 |
fmichon |
1730 |
// |
1213 |
|
|
if ($this->getParameter("retourformulaire") == "dossier" |
1214 |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction" |
1215 |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_encours" |
1216 |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_encours" |
1217 |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_clotures" |
1218 |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_clotures") { |
1219 |
|
|
// |
1220 |
softime |
2112 |
$form->setType('dossier_libelle', 'hidden'); |
1221 |
fmichon |
1730 |
} |
1222 |
vpihour |
1784 |
|
1223 |
|
|
$form->setType('code_barres', 'hidden'); |
1224 |
vpihour |
1899 |
|
1225 |
|
|
//Cache les champs pour la finalisation |
1226 |
|
|
$form->setType('om_fichier_consultation', 'hidden'); |
1227 |
|
|
$form->setType('om_final_consultation', 'hidden'); |
1228 |
nhaye |
3395 |
|
1229 |
|
|
if($maj == 50 or $maj == 60 or $maj == 70) { |
1230 |
|
|
foreach ($this->champs as $value) { |
1231 |
|
|
$form->setType($value, 'hidden'); |
1232 |
|
|
} |
1233 |
|
|
} |
1234 |
fraynaud |
20 |
} |
1235 |
|
|
|
1236 |
fmichon |
1170 |
// Cette méthode permet de calculer la date limite en fonction de la date |
1237 |
|
|
// de réception et du délai de consultation du service consulté |
1238 |
|
|
function calculDateLimite() { |
1239 |
fraynaud |
20 |
// mise a jour instruction avec evenement [return delay] |
1240 |
fmichon |
1170 |
if ($this->valF["date_reception"] != "") { |
1241 |
|
|
// |
1242 |
|
|
$sql = " select delai from ".DB_PREFIXE."service "; |
1243 |
|
|
$sql .= " where service='".$this->valF["service"]."' "; |
1244 |
|
|
// |
1245 |
|
|
$delai = $this->db->getOne($sql); |
1246 |
|
|
$this->addToLog("triggerajouter(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
1247 |
|
|
// |
1248 |
softime |
2771 |
$this->valF["date_limite"] = $this->f->mois_date($this->valF["date_reception"], $delai); |
1249 |
fmichon |
1170 |
// |
1250 |
nhaye |
532 |
$this->addToMessage(_("delai")." ". |
1251 |
fraynaud |
41 |
_("retour")." ".$delai." "._("mois")." -> ". |
1252 |
fmichon |
1170 |
_("retour")." ".date("d/m/Y", strtotime($this->valF["date_limite"]))); |
1253 |
fraynaud |
41 |
} |
1254 |
fraynaud |
20 |
} |
1255 |
fmichon |
1170 |
|
1256 |
|
|
// TRIGGER AVANT MODIFICATION DE DONNEES |
1257 |
|
|
// trigger before modification data |
1258 |
|
|
function triggerajouter($id,&$db,$val,$DEBUG) { |
1259 |
|
|
// |
1260 |
|
|
$this->calculDateLimite(); |
1261 |
vpihour |
1784 |
|
1262 |
|
|
// Identifiant du type de courrier |
1263 |
|
|
$idTypeCourrier = '12'; |
1264 |
|
|
$idCourrier = str_pad($this->valF["consultation"], 10, "0", STR_PAD_LEFT); |
1265 |
|
|
// Code barres |
1266 |
|
|
$this->valF["code_barres"] = $idTypeCourrier . $idCourrier; |
1267 |
fmichon |
1170 |
} |
1268 |
|
|
|
1269 |
|
|
// |
1270 |
|
|
function triggermodifier($id,&$db,$val,$DEBUG) { |
1271 |
|
|
// |
1272 |
|
|
$this->calculDateLimite(); |
1273 |
|
|
} |
1274 |
|
|
|
1275 |
|
|
// |
1276 |
nhaye |
532 |
function triggerajouterapres($id,&$db,$val,$DEBUG) { |
1277 |
|
|
|
1278 |
|
|
// Verification de la demande de notif par mail |
1279 |
fmichon |
1168 |
$sql= "SELECT abrege, libelle, notification_email, email FROM ".DB_PREFIXE. |
1280 |
nhaye |
532 |
"service WHERE service ='".$this->valF['service']."'"; |
1281 |
|
|
$res=$db->query($sql); |
1282 |
|
|
$notif = $res->fetchrow(DB_FETCHMODE_ASSOC); |
1283 |
|
|
if (database :: isError($sql))die($res->getMessage()."erreur ".$sql); |
1284 |
|
|
if ($notif['notification_email']=='t') { |
1285 |
|
|
|
1286 |
|
|
// Recuperation des infos du dossier |
1287 |
softime |
2081 |
$sql= "SELECT dossier, terrain_adresse_voie_numero, terrain_adresse_voie, terrain_adresse_code_postal, terrain_adresse_localite |
1288 |
nhaye |
532 |
FROM ".DB_PREFIXE."dossier WHERE dossier ='".$this->valF['dossier']."'"; |
1289 |
|
|
$res=$db->query($sql); |
1290 |
|
|
$dossier = $res->fetchrow(DB_FETCHMODE_ASSOC); |
1291 |
|
|
|
1292 |
|
|
// Definition des parametres d'envoi du mail |
1293 |
|
|
$title=_("Consultation de services : dossier no")." ".$dossier['dossier']; |
1294 |
|
|
$corps=_("Votre service est consulte concernant le dossier no")." ".$dossier['dossier']."<br/>". |
1295 |
softime |
2081 |
_("Il concerne le terrain situe a l'adresse :")." ".$dossier['terrain_adresse_voie_numero']. |
1296 |
|
|
" ".$dossier['terrain_adresse_voie']." ".$dossier['terrain_adresse_code_postal']." ".$dossier['terrain_adresse_localite']."<br/>". |
1297 |
fmichon |
668 |
_("Vous pouvez y acceder et rendre votre avis a l'adresse")." <a href='".$this->f->getParameter('services_consultes_lien_interne'). |
1298 |
vpihour |
3141 |
// On ajoute l'idx, s'il y a besoin |
1299 |
|
|
((substr($this->f->getParameter('services_consultes_lien_interne'), -5)=="&idx=")?$this->valF['consultation']:"")."'>". |
1300 |
fmichon |
668 |
_("Lien interne (services VDM)")."</a> "._("ou")." <a href='".$this->f->getParameter('services_consultes_lien_externe'). |
1301 |
vpihour |
3141 |
// On ajoute l'idx, s'il y a besoin |
1302 |
|
|
((substr($this->f->getParameter('services_consultes_lien_externe'), -5)=="&idx=")?$this->valF['consultation']:"")."'>". |
1303 |
nhaye |
532 |
_("Lien externe (hors VDM)")."</a>"; |
1304 |
|
|
// Envoi du mail avec message de retour |
1305 |
softime |
2084 |
if($this->f->sendMail(iconv("UTF-8", "CP1252", $title), iconv("UTF-8", "CP1252", $corps), iconv("UTF-8", "CP1252", $notif['email']))) { |
1306 |
fmichon |
1168 |
$this->addToMessage(_("Envoi d'un mail de notification au service")." \"(".$notif['abrege'].") ".$notif["libelle"]."\""); |
1307 |
nhaye |
532 |
} else { |
1308 |
|
|
$this->addToMessage(_("L'envoi du mail de notification a echoue")); |
1309 |
|
|
} |
1310 |
|
|
} |
1311 |
|
|
|
1312 |
fmichon |
1005 |
|
1313 |
|
|
// verification si envoi vers ERP est active |
1314 |
vpihour |
3126 |
if ($this->f->getParameter('option_erp') === 'true') { |
1315 |
fmichon |
1005 |
// s'il s'agit de la consultation ERP Secu, ERP Accessibilite, ou |
1316 |
|
|
// deenvoie un |
1317 |
|
|
// message a ERP |
1318 |
|
|
$dossier_erp = $this->getFromDB("SELECT erp FROM ".DB_PREFIXE. |
1319 |
|
|
"dossier WHERE dossier = '" .$this->valF['dossier'] . "'"); |
1320 |
nhaye |
1140 |
$dossier_nature = $this->getFromDB("SELECT dossier_autorisation_type_detaille.code FROM ".DB_PREFIXE. |
1321 |
|
|
"dossier |
1322 |
|
|
INNER JOIN ".DB_PREFIXE."dossier_autorisation |
1323 |
|
|
ON dossier.dossier_autorisation=dossier_autorisation.dossier_autorisation |
1324 |
|
|
INNER JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille |
1325 |
|
|
ON dossier_autorisation.dossier_autorisation_type_detaille |
1326 |
|
|
= dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
1327 |
|
|
WHERE dossier = '" . $this->valF['dossier'] . "'"); |
1328 |
fmichon |
1005 |
if ($dossier_erp == 't' |
1329 |
|
|
&& substr($dossier_nature, 0, 2) == $this->f->getParameter('erp_dossier_nature_pc')) { |
1330 |
|
|
// envoi du message "Demande d'instruction d'un dossier PC pour un ERP" |
1331 |
|
|
if (($this->valF['service'] == $this->f->getParameter('erp_service_accessibilite') |
1332 |
|
|
|| $this->valF['service'] == $this->f->getParameter('erp_service_securite'))) { |
1333 |
|
|
$msgenque = new MessageEnqueuer(); |
1334 |
|
|
$msgenque->setDossierInstructionIdentifier($this->valF['dossier']); |
1335 |
|
|
$msgenque->setConsultationIdentifier($this->valF['consultation']); |
1336 |
vpihour |
2842 |
$return = $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_INSTRUCTION_PC); |
1337 |
|
|
//Si une erreur s'est produite on arrête le traitement et on |
1338 |
|
|
//retourne une erreur |
1339 |
|
|
if ($return !== 0){ |
1340 |
|
|
|
1341 |
|
|
$this->addToMessage(_("Une erreur s'est produite lors de ". |
1342 |
|
|
"l'envoi du message au referentiel ERP. Merci de ". |
1343 |
|
|
"contacter votre administrateur")); |
1344 |
|
|
//On ne valide pas le formulaire |
1345 |
vpihour |
2877 |
$this->addToMessage("<br/>"._("SAISIE NON ENREGISTREE")."<br/>"); |
1346 |
|
|
$this->correct = false; |
1347 |
|
|
return false; |
1348 |
vpihour |
2842 |
} |
1349 |
|
|
else { |
1350 |
|
|
$this->addToMessage(_("Le message a ete transmis au ". |
1351 |
|
|
"referentiel ERP.")); |
1352 |
|
|
} |
1353 |
fmichon |
1005 |
} |
1354 |
|
|
|
1355 |
|
|
// envoi du message "Consultation ERP pour conformite" en cas de creation de la |
1356 |
|
|
// consultation du service ERP Conformite |
1357 |
|
|
if ($this->valF['service'] == $this->f->getParameter('erp_service_conformite')) { |
1358 |
|
|
$msgenque = new MessageEnqueuer(); |
1359 |
|
|
$msgenque->setDossierInstructionIdentifier($this->valF['dossier']); |
1360 |
|
|
$msgenque->setConsultationIdentifier($this->valF['consultation']); |
1361 |
vpihour |
2842 |
$return = $msgenque->enqueueMessage($msgenque::$ERP_CONSULTATION_CONFORMITE); |
1362 |
|
|
//Si une erreur s'est produite on arrête le traitement et on |
1363 |
|
|
//retourne une erreur |
1364 |
|
|
if ($return !== 0){ |
1365 |
|
|
|
1366 |
|
|
$this->addToMessage(_("Une erreur s'est produite lors de ". |
1367 |
|
|
"l'envoi du message au referentiel ERP. Merci de ". |
1368 |
|
|
"contacter votre administrateur")); |
1369 |
|
|
//On ne valide pas le formulaire |
1370 |
vpihour |
2877 |
$this->addToMessage("<br/>"._("SAISIE NON ENREGISTREE")."<br/>"); |
1371 |
|
|
$this->correct = false; |
1372 |
|
|
return false; |
1373 |
vpihour |
2842 |
} |
1374 |
|
|
else { |
1375 |
|
|
$this->addToMessage(_("Le message a ete transmis au ". |
1376 |
|
|
"referentiel ERP.")); |
1377 |
|
|
} |
1378 |
fmichon |
1005 |
} |
1379 |
mlimic |
936 |
} |
1380 |
vpihour |
3126 |
} // fin de if($this->f->getParameter('option_erp') === 'true') |
1381 |
vpihour |
1930 |
|
1382 |
|
|
// Finalisation du document |
1383 |
nhaye |
3395 |
$this->finaliserAjouter($id); |
1384 |
nhaye |
532 |
} |
1385 |
mlimic |
843 |
|
1386 |
mlimic |
936 |
/** |
1387 |
|
|
* Fait une requette sql pour extraire la valeur d'un champ, et retourne |
1388 |
|
|
* cette valeur |
1389 |
|
|
* @param string $sql La requete sql a executer |
1390 |
|
|
* @return La valeur du champs cherche, sinon NULL. En cas d'erreur de la BD |
1391 |
|
|
* l'execution s'arrete. |
1392 |
|
|
*/ |
1393 |
|
|
function getFromDB($sql) { |
1394 |
|
|
//$sql = "SELECT libelle FROM ".DB_PREFIXE."dossier WHERE dossier = '" . $dossier . "'"; |
1395 |
|
|
$res = $this->db->limitquery($sql, 0, 1); |
1396 |
vpihour |
1777 |
$this->f->addToLog("getDossierERPSpecification(): db->limitquery(\"". |
1397 |
mlimic |
936 |
str_replace(",",", ",$sql)."\", 0, 1);", VERBOSE_MODE); |
1398 |
|
|
// Si une erreur survient on die |
1399 |
|
|
if (database::isError($res, true)) { |
1400 |
|
|
// Appel de la methode de recuperation des erreurs |
1401 |
|
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), 'instruction'); |
1402 |
|
|
} |
1403 |
|
|
// retourne la nature du dossier |
1404 |
|
|
while ($row =& $res->fetchRow()) { |
1405 |
|
|
return $row[0]; |
1406 |
|
|
} |
1407 |
|
|
// la nature n'etait pas trouve, ce qui ne devrait pas se passer |
1408 |
|
|
return NULL; |
1409 |
|
|
|
1410 |
|
|
} |
1411 |
|
|
|
1412 |
fraynaud |
20 |
// ============================================= |
1413 |
vpihour |
497 |
// Ajout du fielset |
1414 |
|
|
// Add fieldset |
1415 |
|
|
// ============================================= |
1416 |
nhaye |
569 |
function setLayout(&$form, $maj){ |
1417 |
fmichon |
671 |
|
1418 |
|
|
// Modification layout : écran de retour d'avis permettant |
1419 |
|
|
// uniquement la saisie des trois champs : avis, motivation et fichier |
1420 |
|
|
if ($this->f->isAccredited('consultation_consulter_autre_que_retour_avis')) { |
1421 |
|
|
|
1422 |
nhaye |
569 |
//Champs sur lequel s'ouvre le fieldset |
1423 |
|
|
$form->setBloc('dossier','D',""); |
1424 |
|
|
$form->setFieldset('dossier','D',_('Consultation')); |
1425 |
|
|
|
1426 |
|
|
//Champs sur lequel se ferme le fieldset |
1427 |
|
|
$form->setFieldset('date_envoi','F',''); |
1428 |
|
|
$form->setBloc('date_envoi','F'); |
1429 |
fmichon |
671 |
|
1430 |
nhaye |
569 |
} |
1431 |
fmichon |
671 |
|
1432 |
|
|
// MODE - autre que AJOUTER alors on affiche un fieldset retour |
1433 |
|
|
// d'avis |
1434 |
|
|
if ($maj != 0) { |
1435 |
|
|
|
1436 |
nhaye |
569 |
//Champs sur lequel s'ouvre le fieldset |
1437 |
|
|
$form->setBloc('date_reception','D',""); |
1438 |
|
|
$form->setFieldset('date_reception','D',_('Retour d\'avis')); |
1439 |
fmichon |
671 |
|
1440 |
nhaye |
569 |
//Champs sur lequel se ferme le fieldset |
1441 |
|
|
$form->setFieldset('lu','F',''); |
1442 |
|
|
$form->setBloc('lu','F'); |
1443 |
fmichon |
671 |
|
1444 |
nhaye |
569 |
} |
1445 |
|
|
} |
1446 |
nhaye |
595 |
|
1447 |
|
|
/** Surcharge de la methode retour afin de retourner sur la page de saisie de |
1448 |
|
|
* code barre si besoin |
1449 |
|
|
**/ |
1450 |
|
|
function retour($premier = 0, $recherche = "", $tricol = "") { |
1451 |
|
|
$params ="obj=".get_class($this); |
1452 |
|
|
if($this->getParameter("retour")=="form") { |
1453 |
|
|
$params .= "&idx=".$this->getParameter("idx"); |
1454 |
|
|
$params .= "&action=3"; |
1455 |
|
|
} |
1456 |
|
|
$params .= "&premier=".$this->getParameter("premier"); |
1457 |
|
|
$params .= "&tricol=".$this->getParameter("tricol"); |
1458 |
|
|
$params .= "&recherche=".$this->getParameter("recherche"); |
1459 |
|
|
$params .= "&selectioncol=".$this->getParameter("selectioncol"); |
1460 |
|
|
$params .= "&advs_id=".$this->getParameter("advs_id"); |
1461 |
|
|
$params .= "&valide=".$this->getParameter("valide"); |
1462 |
|
|
echo "\n<a class=\"retour\" "; |
1463 |
|
|
echo "href=\""; |
1464 |
|
|
// |
1465 |
|
|
|
1466 |
|
|
if($this->getParameter("retour")=="form" AND !($this->getParameter("validation")>0 AND $this->getParameter("maj")==2 AND $this->correct)) { |
1467 |
|
|
echo "form.php?".$params; |
1468 |
fmichon |
1666 |
} elseif($this->getParameter("retour")=="suivi_retours_de_consultation") { |
1469 |
|
|
echo "../app/suivi_retours_de_consultation.php"; |
1470 |
nhaye |
595 |
} else { |
1471 |
|
|
echo "tab.php?".$params; |
1472 |
|
|
} |
1473 |
|
|
// |
1474 |
|
|
echo "\""; |
1475 |
|
|
echo ">"; |
1476 |
|
|
// |
1477 |
|
|
echo _("Retour"); |
1478 |
|
|
// |
1479 |
|
|
echo "</a>\n"; |
1480 |
|
|
} |
1481 |
fmichon |
938 |
|
1482 |
|
|
/** |
1483 |
nhaye |
802 |
* Surcharge du bouton retour pour popup |
1484 |
|
|
*/ |
1485 |
|
|
function retoursousformulaire($idxformulaire, $retourformulaire, $val, |
1486 |
|
|
$objsf, $premiersf, $tricolsf, $validation, |
1487 |
|
|
$idx, $maj, $retour) { |
1488 |
|
|
if($retourformulaire === "demande_avis_encours") { |
1489 |
|
|
echo "\n<a class=\"retour\" "; |
1490 |
|
|
echo "href=\""; |
1491 |
|
|
echo "#"; |
1492 |
|
|
echo "\" "; |
1493 |
|
|
echo ">"; |
1494 |
|
|
// |
1495 |
|
|
echo _("Retour"); |
1496 |
|
|
// |
1497 |
|
|
echo "</a>\n"; |
1498 |
|
|
} else { |
1499 |
|
|
parent::retoursousformulaire($idxformulaire, $retourformulaire, $val, |
1500 |
|
|
$objsf, $premiersf, $tricolsf, $validation, |
1501 |
|
|
$idx, $maj, $retour); |
1502 |
|
|
} |
1503 |
|
|
} |
1504 |
vpihour |
1784 |
|
1505 |
vpihour |
1881 |
/** |
1506 |
|
|
* Ajout des contraintes spécifiques pour l'ajout d'un fichier en retour de |
1507 |
|
|
* consultation |
1508 |
|
|
*/ |
1509 |
|
|
function setSelect(&$form, $maj,&$db,$debug) { |
1510 |
fmichon |
3172 |
if(file_exists ("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc.php")) |
1511 |
|
|
include ("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc.php"); |
1512 |
|
|
elseif(file_exists ("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc")) |
1513 |
|
|
include ("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc"); |
1514 |
atreal |
2731 |
|
1515 |
|
|
// avis_consultation |
1516 |
|
|
$this->init_select($form, $db, $maj, $debug, "avis_consultation", |
1517 |
|
|
$sql_avis_consultation, $sql_avis_consultation_by_id, true); |
1518 |
|
|
|
1519 |
|
|
// service |
1520 |
|
|
$this->init_select($form, $db, $maj, $debug, "service", |
1521 |
|
|
$sql_service, $sql_service_by_id, true); |
1522 |
|
|
|
1523 |
vpihour |
1881 |
//Seulement dans le cas d'un retour d'avis |
1524 |
nhaye |
3414 |
if($this->retourformulaire == "demande_avis_encours" or $this->getParameter("maj") == 100 or $this->getParameter("maj") == 90) { |
1525 |
nhaye |
3395 |
// avis_consultation |
1526 |
|
|
$this->init_select($form, $db, 1, $debug, "avis_consultation", |
1527 |
|
|
$sql_avis_consultation, $sql_avis_consultation_by_id, true); |
1528 |
vpihour |
1881 |
|
1529 |
|
|
//Tableau des contraintes spécifiques |
1530 |
|
|
$params = array( |
1531 |
|
|
"constraint" => array( |
1532 |
|
|
"size_max" => 2, |
1533 |
|
|
"extension" => ".pdf" |
1534 |
|
|
), |
1535 |
|
|
); |
1536 |
|
|
|
1537 |
|
|
$form->setSelect("fichier", $params); |
1538 |
|
|
} |
1539 |
|
|
} |
1540 |
vpihour |
2603 |
|
1541 |
vpihour |
1930 |
/** |
1542 |
nhaye |
3395 |
* Finalisation du document lors de l'ajout d'une consultation. |
1543 |
|
|
* |
1544 |
|
|
* @param integer $id indentifiant de l'objet |
1545 |
vpihour |
1930 |
*/ |
1546 |
nhaye |
3395 |
function finaliserAjouter($id){ |
1547 |
vpihour |
1930 |
|
1548 |
nhaye |
3395 |
$uid = $this->file_finalizing($id); |
1549 |
vpihour |
1930 |
|
1550 |
|
|
//Mise à jour des données |
1551 |
vpihour |
2789 |
if ( $uid != '' && $uid != 'OP_FAILURE' ){ |
1552 |
vpihour |
1930 |
// Logger |
1553 |
|
|
$this->addToLog("finaliserAjouter() - begin", EXTRA_VERBOSE_MODE); |
1554 |
|
|
|
1555 |
|
|
$valF = array( |
1556 |
nhaye |
3395 |
"om_final_consultation"=> true, |
1557 |
|
|
"om_fichier_consultation"=>$uid |
1558 |
|
|
); |
1559 |
vpihour |
1930 |
|
1560 |
|
|
// Execution de la requête de modification des donnees de l'attribut |
1561 |
|
|
// valF de l'objet dans l'attribut table de l'objet |
1562 |
|
|
$res = $this->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
1563 |
nhaye |
3395 |
DB_AUTOQUERY_UPDATE, $this->getCle($id)); |
1564 |
|
|
$this->addToLog( |
1565 |
|
|
"finaliserAjouter() : db->autoExecute(\"".DB_PREFIXE.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($id)."\")", |
1566 |
|
|
VERBOSE_MODE |
1567 |
|
|
); |
1568 |
vpihour |
1930 |
// Si une erreur survient |
1569 |
nhaye |
3395 |
if (database::isError($res, true)) { |
1570 |
|
|
$this->correct = false; |
1571 |
vpihour |
1930 |
// Appel de la methode de recuperation des erreurs |
1572 |
|
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
1573 |
nhaye |
3395 |
return false; |
1574 |
vpihour |
1930 |
} else { |
1575 |
|
|
// Log |
1576 |
|
|
$this->addToLog(_("Requete executee"), VERBOSE_MODE); |
1577 |
|
|
// Log |
1578 |
nhaye |
3395 |
$message = _("Enregistrement")." ".$id." "; |
1579 |
vpihour |
1930 |
$message .= _("de la table")." \"".$this->table."\" "; |
1580 |
|
|
$message .= "[ ".$this->db->affectedRows()." "; |
1581 |
|
|
$message .= _("enregistrement(s) mis a jour")." ]"; |
1582 |
|
|
$this->addToLog($message, VERBOSE_MODE); |
1583 |
|
|
} |
1584 |
|
|
} |
1585 |
|
|
} |
1586 |
nhaye |
1935 |
|
1587 |
vpihour |
2603 |
/** |
1588 |
nhaye |
3395 |
* Finalisation du fichier. |
1589 |
|
|
* |
1590 |
|
|
* @param integer $id indentifiant de l'objet |
1591 |
|
|
* |
1592 |
|
|
* @return string uid du fichier finalisé |
1593 |
vpihour |
2603 |
*/ |
1594 |
nhaye |
3395 |
function file_finalizing($id){ |
1595 |
nhaye |
3415 |
$pdf = $this->generate_pdf_consultation(); |
1596 |
nhaye |
1935 |
|
1597 |
nhaye |
3395 |
if(isset($this->valF["om_final_consultation"])) { |
1598 |
|
|
$finalized = $this->valF["om_final_consultation"]; |
1599 |
|
|
} else { |
1600 |
|
|
$finalized = $this->getVal("om_final_consultation"); |
1601 |
vpihour |
3027 |
} |
1602 |
nhaye |
3395 |
|
1603 |
|
|
// Métadonnées du document |
1604 |
|
|
$metadata = array( |
1605 |
nhaye |
3415 |
'filename' => $pdf["filename"], |
1606 |
nhaye |
3395 |
'mimetype' => 'application/pdf', |
1607 |
nhaye |
3415 |
'size' => strlen($pdf["pdf_output"]) |
1608 |
nhaye |
3395 |
); |
1609 |
|
|
|
1610 |
|
|
// Récupération des métadonnées calculées après validation |
1611 |
|
|
$spe_metadata = $this->getMetadata("om_fichier_consultation"); |
1612 |
|
|
|
1613 |
|
|
$metadata = array_merge($metadata, $spe_metadata); |
1614 |
|
|
|
1615 |
|
|
// Si le document a déjà été finalisé |
1616 |
|
|
if ( $finalized != '' ){ |
1617 |
|
|
|
1618 |
|
|
// Met à jour le document mais pas son uid |
1619 |
|
|
$uid = $this->f->storage->update( |
1620 |
nhaye |
3415 |
$this->getVal("om_fichier_consultation"), $pdf["pdf_output"], $metadata); |
1621 |
nhaye |
3395 |
} |
1622 |
|
|
// Sinon, ajoute le document et récupère son uid |
1623 |
vpihour |
3027 |
else { |
1624 |
nhaye |
3395 |
|
1625 |
|
|
// Stockage du PDF |
1626 |
|
|
$uid = $this->f->storage->create($pdf_output, $metadata); |
1627 |
vpihour |
3027 |
} |
1628 |
vpihour |
2603 |
|
1629 |
nhaye |
3395 |
return $uid; |
1630 |
vpihour |
2603 |
|
1631 |
nhaye |
3395 |
} |
1632 |
vpihour |
2603 |
|
1633 |
|
|
|
1634 |
nhaye |
3395 |
/** |
1635 |
|
|
* TREATMENT - finalize. |
1636 |
|
|
* |
1637 |
|
|
* Permet de finaliser un enregistrement |
1638 |
|
|
* |
1639 |
|
|
* @param array $val valeurs soumises par le formulaire |
1640 |
|
|
* @param null $dnu1 @deprecated Ancienne ressource de base de données. |
1641 |
|
|
* @param null $dnu2 @deprecated Ancien marqueur de débogage. |
1642 |
|
|
* |
1643 |
|
|
* @return boolean |
1644 |
|
|
*/ |
1645 |
|
|
function finalize($val = array(), &$dnu1 = null, $dnu2 = null) { |
1646 |
vpihour |
2603 |
|
1647 |
nhaye |
3395 |
// |
1648 |
|
|
return $this->manage_finalizing("finalize", $val); |
1649 |
|
|
} |
1650 |
vpihour |
2603 |
|
1651 |
nhaye |
3395 |
/** |
1652 |
|
|
* TREATMENT - unfinalize. |
1653 |
|
|
* |
1654 |
|
|
* Permet de definaliser un enregistrement |
1655 |
|
|
* |
1656 |
|
|
* @param array $val valeurs soumises par le formulaire |
1657 |
|
|
* @param null $dnu1 @deprecated Ancienne ressource de base de données. |
1658 |
|
|
* @param null $dnu2 @deprecated Ancien marqueur de débogage. |
1659 |
|
|
* |
1660 |
|
|
* @return boolean |
1661 |
|
|
*/ |
1662 |
|
|
function unfinalize($val = array(), &$dnu1 = null, $dnu2 = null) { |
1663 |
vpihour |
2603 |
|
1664 |
nhaye |
3395 |
// |
1665 |
|
|
return $this->manage_finalizing("unfinalize", $val); |
1666 |
|
|
} |
1667 |
|
|
|
1668 |
|
|
|
1669 |
|
|
/** |
1670 |
|
|
* Finalisation des documents. |
1671 |
|
|
* |
1672 |
|
|
* @param string $mode finalize/unfinalize |
1673 |
|
|
* @param array $val valeurs soumises par le formulaire |
1674 |
|
|
*/ |
1675 |
|
|
function manage_finalizing($mode = null, $val = array()) { |
1676 |
|
|
|
1677 |
|
|
// Recuperation de la valeur de la cle primaire de l'objet |
1678 |
|
|
$id = $this->getVal($this->clePrimaire); |
1679 |
|
|
|
1680 |
|
|
// Si on finalise le document |
1681 |
|
|
if ($mode == "finalize") { |
1682 |
|
|
// Finalisation du fichier |
1683 |
|
|
$uid = $this->file_finalizing($id); |
1684 |
vpihour |
2603 |
} |
1685 |
|
|
// |
1686 |
|
|
else { |
1687 |
|
|
|
1688 |
|
|
//Récupération de l'uid du document finalisé |
1689 |
|
|
$uid = $this->getVal("om_fichier_consultation"); |
1690 |
|
|
|
1691 |
|
|
//On dé-finalise avant de finaliser |
1692 |
|
|
if ( $uid == '' || $uid == 'OP_FAILURE' ){ |
1693 |
nhaye |
3395 |
$this->correct = false; |
1694 |
|
|
$this->msg=""; |
1695 |
|
|
$this->addToMessage(_("Finalisation non enregistree")); |
1696 |
|
|
$this->addToLog( |
1697 |
|
|
_("Finalisation non enregistree")." - ". |
1698 |
|
|
_("id consultation")." = ".$id." - ". |
1699 |
|
|
_("uid fichier")." = ".$uid |
1700 |
|
|
); |
1701 |
|
|
return false; |
1702 |
vpihour |
2603 |
} |
1703 |
|
|
} |
1704 |
|
|
|
1705 |
|
|
//Mise à jour des données |
1706 |
vpihour |
2789 |
if ($uid != '' && $uid != 'OP_FAILURE') { |
1707 |
vpihour |
2603 |
|
1708 |
|
|
// Logger |
1709 |
|
|
$this->addToLog("finaliser() - begin", EXTRA_VERBOSE_MODE); |
1710 |
|
|
|
1711 |
|
|
foreach ($this->champs as $key => $value) { |
1712 |
|
|
// |
1713 |
|
|
$val[$value] = $this->val[$key]; |
1714 |
|
|
} |
1715 |
|
|
|
1716 |
|
|
$this->setvalF($val); |
1717 |
|
|
|
1718 |
|
|
// Verification de la validite des donnees |
1719 |
|
|
$this->verifier($this->val, $this->db, DEBUG); |
1720 |
|
|
// Verification du verrou |
1721 |
|
|
$this->testverrou(); |
1722 |
|
|
// Si les verifications precedentes sont correctes, on procede a |
1723 |
|
|
// la modification, sinon on ne fait rien et on retourne une erreur |
1724 |
|
|
if ($this->correct) { |
1725 |
|
|
|
1726 |
|
|
// Execution du trigger 'before' specifique au MODE 'update' |
1727 |
|
|
$this->triggermodifier( $id, $this->db, $this->val, DEBUG); |
1728 |
|
|
|
1729 |
|
|
// |
1730 |
|
|
$valF = ''; |
1731 |
nhaye |
3395 |
if($mode=="finalize") { |
1732 |
|
|
$valF["om_final_consultation"] = true; |
1733 |
|
|
} else { |
1734 |
|
|
$valF["om_final_consultation"] = false; |
1735 |
|
|
} |
1736 |
vpihour |
2603 |
$valF["om_fichier_consultation"] = $uid; |
1737 |
|
|
|
1738 |
|
|
// Execution de la requête de modification des donnees de l'attribut |
1739 |
|
|
// valF de l'objet dans l'attribut table de l'objet |
1740 |
|
|
$res = $this->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
1741 |
|
|
DB_AUTOQUERY_UPDATE, $this->getCle($id)); |
1742 |
nhaye |
3395 |
$this->addToLog( |
1743 |
|
|
"finaliser() : db->autoExecute(\"".DB_PREFIXE.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($id)."\")", |
1744 |
|
|
VERBOSE_MODE |
1745 |
|
|
); |
1746 |
vpihour |
2603 |
|
1747 |
|
|
// Si une erreur survient |
1748 |
nhaye |
3395 |
if (database::isError($res, true)) { |
1749 |
vpihour |
2603 |
|
1750 |
|
|
// Appel de la methode de recuperation des erreurs |
1751 |
|
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
1752 |
nhaye |
3395 |
$this->correct = false; |
1753 |
|
|
return false; |
1754 |
vpihour |
2603 |
} else { |
1755 |
|
|
|
1756 |
|
|
// Log |
1757 |
|
|
$this->addToLog(_("Requete executee"), VERBOSE_MODE); |
1758 |
|
|
// Log |
1759 |
|
|
$message = _("Enregistrement")." ".$id." "; |
1760 |
|
|
$message .= _("de la table")." \"".$this->table."\" "; |
1761 |
|
|
$message .= "[ ".$this->db->affectedRows()." "; |
1762 |
|
|
$message .= _("enregistrement(s) mis a jour")." ]"; |
1763 |
|
|
$this->addToLog($message, VERBOSE_MODE); |
1764 |
|
|
// Mise en place du verrou pour ne pas finaliser plusieurs fois |
1765 |
|
|
// le meme document |
1766 |
|
|
$this->verrouille(); |
1767 |
|
|
// Execution du trigger 'after' specifique au MODE 'update' |
1768 |
|
|
$this->triggermodifierapres($id, $this->db, $this->val, DEBUG); |
1769 |
nhaye |
3395 |
|
1770 |
|
|
if($mode == "finalize") { |
1771 |
|
|
$etat = _('finalisation'); |
1772 |
|
|
} else { |
1773 |
|
|
$etat = _('definalisation'); |
1774 |
|
|
} |
1775 |
|
|
$this->msg=""; |
1776 |
|
|
$this->addToMessage(sprintf(_("La %s du document s'est effectuee avec succes."), $etat)); |
1777 |
|
|
return true; |
1778 |
vpihour |
2603 |
} |
1779 |
|
|
// |
1780 |
|
|
} else { |
1781 |
nhaye |
3395 |
$this->correct = false; |
1782 |
|
|
$this->msg=""; |
1783 |
vpihour |
2603 |
// Message d'echec (saut d'une ligne supplementaire avant le |
1784 |
|
|
// message pour qu'il soit mis en evidence) |
1785 |
nhaye |
3395 |
$this->addToMessage(_("Finalisation non enregistree")); |
1786 |
nhaye |
3021 |
$this->addToLog( |
1787 |
|
|
_("Finalisation non enregistree")." - ". |
1788 |
vpihour |
3027 |
_("id consultation")." = ".$id." - ". |
1789 |
nhaye |
3021 |
_("uid fichier")." = ".$uid |
1790 |
|
|
); |
1791 |
nhaye |
3395 |
return false; |
1792 |
vpihour |
2603 |
} |
1793 |
|
|
} |
1794 |
|
|
// Si le document n'a pas été stocké |
1795 |
|
|
else{ |
1796 |
nhaye |
3395 |
$this->correct = false; |
1797 |
|
|
$this->msg=""; |
1798 |
|
|
$this->addToMessage(_("Finalisation non enregistree")); |
1799 |
nhaye |
3021 |
$this->addToLog( |
1800 |
|
|
_("Finalisation non enregistree")." - ". |
1801 |
vpihour |
3027 |
_("id consultation")." = ".$id." - ". |
1802 |
nhaye |
3021 |
_("uid fichier")." = ".$uid |
1803 |
|
|
); |
1804 |
nhaye |
3395 |
return false; |
1805 |
vpihour |
2603 |
} |
1806 |
|
|
} |
1807 |
|
|
|
1808 |
nhaye |
3023 |
/** |
1809 |
nhaye |
3395 |
* Permet de récupérer l'édition de la consultation. |
1810 |
|
|
* |
1811 |
|
|
* @param string $output type de sortie |
1812 |
|
|
* |
1813 |
|
|
* @return string si le type de sortie est string, le contenu du pdf est retourné. |
1814 |
|
|
*/ |
1815 |
nhaye |
3415 |
function generate_pdf_consultation() { |
1816 |
nhaye |
3395 |
if(isset($this->valF[$this->clePrimaire])) { |
1817 |
|
|
$id = $this->valF[$this->clePrimaire]; |
1818 |
|
|
} else { |
1819 |
|
|
$id = $this->getVal($this->clePrimaire); |
1820 |
|
|
} |
1821 |
|
|
|
1822 |
|
|
// Requête qui récupère le type de consultation |
1823 |
|
|
$sql = " SELECT id "; |
1824 |
|
|
$sql .= " FROM ".DB_PREFIXE."service "; |
1825 |
|
|
$sql .= " LEFT JOIN ".DB_PREFIXE."om_etat "; |
1826 |
|
|
$sql .= " ON service.edition = om_etat.om_etat "; |
1827 |
|
|
$sql .= " WHERE service=("; |
1828 |
|
|
$sql .= " SELECT service "; |
1829 |
|
|
$sql .= " FROM ".DB_PREFIXE."consultation "; |
1830 |
|
|
$sql .= " WHERE consultation=".$id.""; |
1831 |
|
|
$sql .= ") "; |
1832 |
|
|
$obj = $this->f->db->getone($sql); |
1833 |
|
|
$this->f->addTolog( |
1834 |
|
|
__FILE__." - ".__METHOD__." : db->getone(\"".$sql."\");", |
1835 |
|
|
VERBOSE_MODE |
1836 |
|
|
); |
1837 |
|
|
if($this->f->isDatabaseError($obj, true)) { |
1838 |
|
|
$this->addToMessage(_("Aucun document genere.")); |
1839 |
|
|
$this->addToMessage(_("Finalisation non enregistree")); |
1840 |
|
|
return false; |
1841 |
|
|
} |
1842 |
|
|
|
1843 |
nhaye |
3415 |
$pdf_output = $this->compute_pdf_output("etat", $obj, null, $id); |
1844 |
nhaye |
3395 |
|
1845 |
nhaye |
3415 |
return $pdf_output; |
1846 |
nhaye |
3395 |
} |
1847 |
|
|
|
1848 |
|
|
function view_consulter_pdf(){ |
1849 |
|
|
if($this->getVal("om_final_consultation") == 't') { |
1850 |
|
|
$lien = '../spg/file.php?obj=consultation&'. |
1851 |
|
|
'champ=om_fichier_consultation&id='.$this->getVal($this->clePrimaire); |
1852 |
|
|
header("Location: ".$lien); |
1853 |
|
|
} else { |
1854 |
nhaye |
3415 |
|
1855 |
|
|
$output = $this->generate_pdf_consultation(); |
1856 |
|
|
$this->expose_pdf_output($output["pdf_output"], $output["filename"]); |
1857 |
nhaye |
3395 |
} |
1858 |
|
|
exit(); |
1859 |
|
|
} |
1860 |
|
|
/** |
1861 |
nhaye |
3023 |
* Création du nom de fichier |
1862 |
|
|
* @return string numéro de dossier d'instruction |
1863 |
|
|
*/ |
1864 |
|
|
protected function getFichierFilename() { |
1865 |
|
|
return "consultation_avis_".$this->valF[$this->clePrimaire].".pdf"; |
1866 |
|
|
} |
1867 |
vpihour |
2603 |
|
1868 |
nhaye |
1935 |
/** |
1869 |
|
|
* Récupération du numéro de dossier d'instruction à ajouter aux métadonnées |
1870 |
nhaye |
1949 |
* @return string numéro de dossier d'instruction |
1871 |
nhaye |
1935 |
*/ |
1872 |
|
|
protected function getDossier() { |
1873 |
|
|
if(empty($this->specificMetadata)) { |
1874 |
|
|
$this->getSpecificMetadata(); |
1875 |
|
|
} |
1876 |
|
|
return $this->specificMetadata->dossier; |
1877 |
|
|
} |
1878 |
|
|
/** |
1879 |
softime |
2016 |
* Récupération la version du dossier d'instruction à ajouter aux métadonnées |
1880 |
|
|
* @return int Version |
1881 |
|
|
*/ |
1882 |
|
|
protected function getDossierVersion() { |
1883 |
|
|
if(empty($this->specificMetadata)) { |
1884 |
|
|
$this->getSpecificMetadata(); |
1885 |
|
|
} |
1886 |
|
|
return $this->specificMetadata->version; |
1887 |
|
|
} |
1888 |
|
|
/** |
1889 |
nhaye |
1935 |
* Récupération du numéro de dossier d'autorisation à ajouter aux métadonnées |
1890 |
nhaye |
1949 |
* @return string numéro de dossier d'autorisation |
1891 |
nhaye |
1935 |
*/ |
1892 |
softime |
2025 |
protected function getNumDemandeAutor() { |
1893 |
nhaye |
1935 |
if(empty($this->specificMetadata)) { |
1894 |
|
|
$this->getSpecificMetadata(); |
1895 |
|
|
} |
1896 |
|
|
return $this->specificMetadata->dossier_autorisation; |
1897 |
|
|
} |
1898 |
|
|
/** |
1899 |
|
|
* Récupération de la date de demande initiale du dossier à ajouter aux métadonnées |
1900 |
nhaye |
1949 |
* @return date demande initiale |
1901 |
nhaye |
1935 |
*/ |
1902 |
softime |
2025 |
protected function getAnneemoisDemandeAutor() { |
1903 |
nhaye |
1935 |
if(empty($this->specificMetadata)) { |
1904 |
|
|
$this->getSpecificMetadata(); |
1905 |
|
|
} |
1906 |
|
|
return $this->specificMetadata->date_demande_initiale; |
1907 |
|
|
} |
1908 |
|
|
/** |
1909 |
|
|
* Récupération du type de dossier d'instruction à ajouter aux métadonnées |
1910 |
nhaye |
1949 |
* @return string type de dossier d'instruction |
1911 |
nhaye |
1935 |
*/ |
1912 |
softime |
2025 |
protected function getTypeInstruction() { |
1913 |
nhaye |
1935 |
if(empty($this->specificMetadata)) { |
1914 |
|
|
$this->getSpecificMetadata(); |
1915 |
|
|
} |
1916 |
|
|
return $this->specificMetadata->dossier_instruction_type; |
1917 |
|
|
} |
1918 |
|
|
/** |
1919 |
|
|
* Récupération du statut du dossier d'autorisation à ajouter aux métadonnées |
1920 |
nhaye |
1949 |
* @return string avis |
1921 |
nhaye |
1935 |
*/ |
1922 |
softime |
2025 |
protected function getStatutAutorisation() { |
1923 |
nhaye |
1935 |
if(empty($this->specificMetadata)) { |
1924 |
|
|
$this->getSpecificMetadata(); |
1925 |
|
|
} |
1926 |
|
|
return $this->specificMetadata->statut; |
1927 |
|
|
} |
1928 |
|
|
/** |
1929 |
|
|
* Récupération du type de dossier d'autorisation à ajouter aux métadonnées |
1930 |
nhaye |
1949 |
* @return string type d'autorisation |
1931 |
nhaye |
1935 |
*/ |
1932 |
softime |
2025 |
protected function getTypeAutorisation() { |
1933 |
nhaye |
1935 |
if(empty($this->specificMetadata)) { |
1934 |
|
|
$this->getSpecificMetadata(); |
1935 |
|
|
} |
1936 |
|
|
return $this->specificMetadata->dossier_autorisation_type; |
1937 |
|
|
} |
1938 |
|
|
/** |
1939 |
|
|
* Récupération de la date d'ajout de document à ajouter aux métadonnées |
1940 |
nhaye |
1949 |
* @return date de l'évènement |
1941 |
nhaye |
1935 |
*/ |
1942 |
softime |
2025 |
protected function getDateEvenementDocument() { |
1943 |
softime |
2046 |
return date("Y-m-d"); |
1944 |
nhaye |
1935 |
} |
1945 |
|
|
/** |
1946 |
|
|
* Récupération du groupe d'instruction à ajouter aux métadonnées |
1947 |
|
|
* @return string Groupe d'instruction |
1948 |
|
|
*/ |
1949 |
|
|
protected function getGroupeInstruction() { |
1950 |
|
|
if(empty($this->specificMetadata)) { |
1951 |
|
|
$this->getSpecificMetadata(); |
1952 |
|
|
} |
1953 |
|
|
return $this->specificMetadata->groupe_instruction; |
1954 |
|
|
} |
1955 |
softime |
2002 |
/** |
1956 |
|
|
* Récupération du type de document à ajouter aux métadonnées |
1957 |
|
|
* @return string Type de document |
1958 |
|
|
*/ |
1959 |
softime |
2025 |
protected function getTitle() { |
1960 |
softime |
2002 |
if ($this->retourformulaire == "demande_avis_encours") { |
1961 |
|
|
return 'Retour de consultation'; |
1962 |
|
|
} else { |
1963 |
|
|
return 'Demande de consultation'; |
1964 |
|
|
} |
1965 |
|
|
} |
1966 |
nhaye |
1935 |
|
1967 |
|
|
/** |
1968 |
|
|
* Cette méthode permet de stocker en attribut toutes les métadonnées |
1969 |
|
|
* nécessaire à l'ajout d'un document. |
1970 |
|
|
*/ |
1971 |
|
|
public function getSpecificMetadata() { |
1972 |
|
|
if (isset($this->valF["dossier"]) AND $this->valF["dossier"] != "") { |
1973 |
|
|
$dossier = $this->valF["dossier"]; |
1974 |
|
|
} else { |
1975 |
|
|
$dossier = $this->getVal("dossier"); |
1976 |
|
|
} |
1977 |
|
|
//Requête pour récupérer les informations essentiels sur le dossier d'instruction |
1978 |
|
|
$sql = "SELECT dossier.dossier as dossier, |
1979 |
|
|
dossier_autorisation.dossier_autorisation as dossier_autorisation, |
1980 |
|
|
to_char(dossier.date_demande, 'YYYY/MM') as date_demande_initiale, |
1981 |
|
|
dossier_instruction_type.code as dossier_instruction_type, |
1982 |
|
|
etat_dossier_autorisation.libelle as statut, |
1983 |
|
|
dossier_autorisation_type.code as dossier_autorisation_type, |
1984 |
|
|
groupe.code as groupe_instruction |
1985 |
|
|
FROM ".DB_PREFIXE."dossier |
1986 |
|
|
LEFT JOIN ".DB_PREFIXE."dossier_instruction_type |
1987 |
|
|
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
1988 |
|
|
LEFT JOIN ".DB_PREFIXE."dossier_autorisation |
1989 |
|
|
ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
1990 |
|
|
LEFT JOIN ".DB_PREFIXE."etat_dossier_autorisation |
1991 |
|
|
ON dossier_autorisation.etat_dossier_autorisation = etat_dossier_autorisation.etat_dossier_autorisation |
1992 |
|
|
LEFT JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille |
1993 |
|
|
ON dossier_autorisation.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
1994 |
|
|
LEFT JOIN ".DB_PREFIXE."dossier_autorisation_type |
1995 |
|
|
ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
1996 |
|
|
LEFT JOIN ".DB_PREFIXE."groupe |
1997 |
|
|
ON dossier_autorisation_type.groupe = groupe.groupe |
1998 |
|
|
WHERE dossier.dossier = '".$dossier."'"; |
1999 |
|
|
$res = $this->db->query($sql); |
2000 |
|
|
$this->f->addToLog("obj/document_numerise.class.php : db->query(".$sql.")", VERBOSE_MODE); |
2001 |
|
|
if ( database::isError($res)){ |
2002 |
|
|
die(); |
2003 |
|
|
} |
2004 |
|
|
|
2005 |
|
|
//Le résultat est récupéré dans un objet |
2006 |
|
|
$row =& $res->fetchRow(DB_FETCHMODE_OBJECT); |
2007 |
|
|
|
2008 |
|
|
//Si il y a un résultat |
2009 |
|
|
if ($row !== null) { |
2010 |
vpihour |
2119 |
|
2011 |
|
|
//Génération du numéro de version |
2012 |
|
|
$sql = "SELECT |
2013 |
|
|
count(*) |
2014 |
|
|
FROM |
2015 |
|
|
".DB_PREFIXE."dossier |
2016 |
|
|
LEFT JOIN |
2017 |
|
|
".DB_PREFIXE."dossier_autorisation |
2018 |
|
|
ON |
2019 |
|
|
dossier_autorisation.dossier_autorisation = dossier.dossier_autorisation |
2020 |
|
|
LEFT JOIN |
2021 |
|
|
".DB_PREFIXE."dossier_instruction_type |
2022 |
|
|
ON |
2023 |
|
|
dossier_instruction_type.dossier_instruction_type = dossier.dossier_instruction_type |
2024 |
|
|
WHERE |
2025 |
softime |
2120 |
dossier_autorisation.dossier_autorisation = '".$row->dossier_autorisation."' |
2026 |
vpihour |
2119 |
AND |
2027 |
softime |
2120 |
dossier_instruction_type.code = '".$row->dossier_instruction_type."'"; |
2028 |
|
|
$row->version = $this->db->getOne($sql); |
2029 |
vpihour |
2119 |
$this->f->addToLog("getInfosForFoldername(): db->getOne(\"".$sql."\")", VERBOSE_MODE); |
2030 |
softime |
2120 |
if ( database::isError($row->version)){ |
2031 |
|
|
$this->f->addToError("", $row->version, $row->version); |
2032 |
vpihour |
2119 |
return false; |
2033 |
|
|
} |
2034 |
|
|
|
2035 |
|
|
//Formatage du numéro de version |
2036 |
softime |
2120 |
$row->version = str_pad($row->version, 2, "0", STR_PAD_LEFT); |
2037 |
nhaye |
1935 |
|
2038 |
|
|
//Alors on créé l'objet dossier_instruction |
2039 |
|
|
$this->specificMetadata = $row; |
2040 |
|
|
|
2041 |
|
|
} |
2042 |
|
|
} |
2043 |
softime |
2112 |
|
2044 |
fraynaud |
3 |
}// fin classe |
2045 |
vpihour |
2603 |
?> |