1 |
<?php |
2 |
//$Id$ |
3 |
//gen openMairie le 14/04/2020 14:11 |
4 |
|
5 |
require_once "../gen/obj/task.class.php"; |
6 |
|
7 |
class task extends task_gen { |
8 |
|
9 |
const STATUS_DRAFT = 'draft'; |
10 |
const STATUS_NEW = 'new'; |
11 |
const STATUS_PENDING = 'pending'; |
12 |
const STATUS_DONE = 'done'; |
13 |
const STATUS_ERROR = 'error'; |
14 |
const STATUS_DEBUG = 'debug'; |
15 |
const STATUS_ARCHIVED = 'archived'; |
16 |
const STATUS_CANCELED = 'canceled'; |
17 |
|
18 |
/** |
19 |
* Liste des types de tâche concernant les services instructeurs |
20 |
*/ |
21 |
const TASK_TYPE_SI = array( |
22 |
'creation_DA', |
23 |
'creation_DI', |
24 |
'depot_DI', |
25 |
'modification_DI', |
26 |
'qualification_DI', |
27 |
'decision_DI', |
28 |
'incompletude_DI', |
29 |
'completude_DI', |
30 |
'ajout_piece', |
31 |
'add_piece', |
32 |
'creation_consultation', |
33 |
'modification_DA', |
34 |
'create_DI', |
35 |
'envoi_CL', |
36 |
'notification_recepisse', |
37 |
'notification_instruction', |
38 |
'notification_decision', |
39 |
'notification_service_consulte', |
40 |
'notification_tiers_consulte', |
41 |
); |
42 |
|
43 |
/** |
44 |
* Liste des types de tâche concernant les services consultés |
45 |
*/ |
46 |
const TASK_TYPE_SC = array( |
47 |
'create_DI_for_consultation', |
48 |
'avis_consultation', |
49 |
'pec_metier_consultation', |
50 |
'create_message', |
51 |
'notification_recepisse', |
52 |
'notification_instruction', |
53 |
'notification_decision', |
54 |
'notification_service_consulte', |
55 |
'notification_tiers_consulte', |
56 |
'prescription', |
57 |
); |
58 |
|
59 |
/** |
60 |
* Catégorie de la tâche |
61 |
*/ |
62 |
var $category = 'platau'; |
63 |
|
64 |
/** |
65 |
* Définition des actions disponibles sur la classe. |
66 |
* |
67 |
* @return void |
68 |
*/ |
69 |
public function init_class_actions() { |
70 |
parent::init_class_actions(); |
71 |
// |
72 |
$this->class_actions[998] = array( |
73 |
"identifier" => "json_data", |
74 |
"view" => "view_json_data", |
75 |
"permission_suffix" => "consulter", |
76 |
); |
77 |
$this->class_actions[997] = array( |
78 |
"identifier" => "json_data", |
79 |
"view" => "post_update_task", |
80 |
"permission_suffix" => "modifier", |
81 |
); |
82 |
$this->class_actions[996] = array( |
83 |
"identifier" => "json_data", |
84 |
"view" => "post_add_task", |
85 |
"permission_suffix" => "ajouter", |
86 |
); |
87 |
} |
88 |
|
89 |
public function setvalF($val = array()) { |
90 |
|
91 |
// // les guillets doubles sont remplacés automatiquement par des simples |
92 |
// // dans core/om_formulaire.clasS.php::recupererPostvar() |
93 |
// // voir le ticket https://dev.atreal.fr/projets/openmairie/tracker/209 |
94 |
// // ceci est un hack sale temporaire en attendant résolution du ticket |
95 |
// foreach(array('json_payload', 'timestamp_log') as $key) { |
96 |
// if (isset($val[$key]) && ! empty($val[$key]) && |
97 |
// isset($_POST[$key]) && ! empty($_POST[$key])) { |
98 |
// $submited_payload = $_POST[$key]; |
99 |
// if (! empty($submited_payload)) { |
100 |
// $new_payload = str_replace("'", '"', $val[$key]); |
101 |
// if ($new_payload == $submited_payload || |
102 |
// strpos($submited_payload, '"') === false) { |
103 |
// $val[$key] = $new_payload; |
104 |
// } |
105 |
// else { |
106 |
// $error_msg = sprintf( |
107 |
// __("La convertion des guillemets de la payload JSON '%s' ". |
108 |
// "n'est pas idempotente (courante: %s, postée: %s, convertie: %s)"), |
109 |
// $key, var_export($val[$key], true), var_export($submited_payload, true), |
110 |
// var_export($new_payload, true)); |
111 |
// $this->correct = false; |
112 |
// $this->addToMessage($error_msg); |
113 |
// $this->addToLog(__METHOD__."() erreur : $error_msg", DEBUG_MODE); |
114 |
// return false; |
115 |
// } |
116 |
// } |
117 |
// } |
118 |
// } |
119 |
|
120 |
parent::setvalF($val); |
121 |
|
122 |
// XXX Ancien code : permet de ne pas avoir d'erreru lors de la modification d'une task |
123 |
if (array_key_exists('timestamp_log', $val) === true) { |
124 |
$this->valF['timestamp_log'] = str_replace("'", '"', $val['timestamp_log']); |
125 |
} |
126 |
|
127 |
// récupération de l'ID de l'objet existant |
128 |
$id = property_exists($this, 'id') ? $this->id : null; |
129 |
if(isset($val[$this->clePrimaire])) { |
130 |
$id = $val[$this->clePrimaire]; |
131 |
} elseif(isset($this->valF[$this->clePrimaire])) { |
132 |
$id = $this->valF[$this->clePrimaire]; |
133 |
} |
134 |
|
135 |
// MODE MODIFIER |
136 |
if (! empty($id)) { |
137 |
|
138 |
// si aucune payload n'est fourni (devrait toujours être le cas) |
139 |
if (! isset($val['json_payload']) || empty($val['json_payload'])) { |
140 |
|
141 |
// récupère l'objet existant |
142 |
$existing = $this->f->findObjectById('task', $id); |
143 |
if (! empty($existing)) { |
144 |
|
145 |
// récupère la payload de l'objet |
146 |
$val['json_payload'] = $existing->getVal('json_payload'); |
147 |
$this->valF['json_payload'] = $existing->getVal('json_payload'); |
148 |
$this->f->addToLog(__METHOD__."() récupère la payload de la tâche existante ". |
149 |
"'$id': ".$existing->getVal('json_payload'), EXTRA_VERBOSE_MODE); |
150 |
} |
151 |
} |
152 |
} |
153 |
|
154 |
if (array_key_exists('category', $val) === false |
155 |
|| $this->valF['category'] === '' |
156 |
|| $this->valF['category'] === null) { |
157 |
// |
158 |
$this->valF['category'] = $this->category; |
159 |
} |
160 |
} |
161 |
|
162 |
/** |
163 |
* |
164 |
* @return array |
165 |
*/ |
166 |
function get_var_sql_forminc__champs() { |
167 |
return array( |
168 |
"task", |
169 |
"type", |
170 |
"state", |
171 |
"object_id", |
172 |
"dossier", |
173 |
"stream", |
174 |
"json_payload", |
175 |
"timestamp_log", |
176 |
"category", |
177 |
); |
178 |
} |
179 |
|
180 |
function setType(&$form, $maj) { |
181 |
parent::setType($form, $maj); |
182 |
|
183 |
// Récupération du mode de l'action |
184 |
$crud = $this->get_action_crud($maj); |
185 |
|
186 |
// ALL |
187 |
$form->setType("category", "hidden"); |
188 |
|
189 |
// MODE CREER |
190 |
if ($maj == 0 || $crud == 'create') { |
191 |
$form->setType("state", "select"); |
192 |
$form->setType("stream", "select"); |
193 |
$form->setType("json_payload", "textarea"); |
194 |
} |
195 |
// MDOE MODIFIER |
196 |
if ($maj == 1 || $crud == 'update') { |
197 |
$form->setType("state", "select"); |
198 |
$form->setType("stream", "select"); |
199 |
$form->setType("json_payload", "jsonprettyprint"); |
200 |
} |
201 |
// MODE CONSULTER |
202 |
if ($maj == 3 || $crud == 'read') { |
203 |
$form->setType('dossier', 'link'); |
204 |
$form->setType('json_payload', 'jsonprettyprint'); |
205 |
} |
206 |
|
207 |
} |
208 |
|
209 |
/** |
210 |
* |
211 |
*/ |
212 |
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
213 |
if($maj < 2) { |
214 |
|
215 |
$contenu = array(); |
216 |
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG', 'ARCHIVED', 'CANCELED') as $key) { |
217 |
$const_name = 'STATUS_'.$key; |
218 |
$const_value = constant("self::$const_name"); |
219 |
$contenu[0][] = $const_value; |
220 |
$contenu[1][] = $const_value; |
221 |
} |
222 |
|
223 |
$form->setSelect("state", $contenu); |
224 |
|
225 |
$contenu_stream =array(); |
226 |
$contenu_stream[0][0]="input"; |
227 |
$contenu_stream[1][0]=_('input'); |
228 |
$contenu_stream[0][1]="output"; |
229 |
$contenu_stream[1][1]=_('output'); |
230 |
$form->setSelect("stream", $contenu_stream); |
231 |
|
232 |
} |
233 |
|
234 |
if ($maj == 3) { |
235 |
if ($this->getVal('stream') == 'output') { |
236 |
$inst_dossier = $this->f->get_inst__om_dbform(array( |
237 |
"obj" => "dossier", |
238 |
"idx" => $form->val['dossier'], |
239 |
)); |
240 |
|
241 |
if($form->val['type'] == "creation_DA" |
242 |
|| $form->val['type'] == "modification_DA"){ |
243 |
// |
244 |
$obj_link = 'dossier_autorisation'; |
245 |
} else { |
246 |
$obj_link = 'dossier_instruction'; |
247 |
} |
248 |
|
249 |
$params = array(); |
250 |
$params['obj'] = $obj_link; |
251 |
$params['libelle'] = $inst_dossier->getVal('dossier'); |
252 |
$params['title'] = "Consulter le dossier"; |
253 |
$params['idx'] = $form->val['dossier']; |
254 |
$form->setSelect("dossier", $params); |
255 |
} |
256 |
} |
257 |
} |
258 |
|
259 |
/** |
260 |
* SETTER_FORM - setVal (setVal). |
261 |
* |
262 |
* @return void |
263 |
*/ |
264 |
function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) { |
265 |
// parent::setVal($form, $maj, $validation); |
266 |
// |
267 |
if ($this->getVal('stream') == "output") { |
268 |
$form->setVal('json_payload', $this->view_form_json(true)); |
269 |
} else { |
270 |
$form->setVal('json_payload', htmlentities($this->getVal('json_payload'))); |
271 |
} |
272 |
} |
273 |
|
274 |
function setLib(&$form, $maj) { |
275 |
parent::setLib($form, $maj); |
276 |
|
277 |
// Récupération du mode de l'action |
278 |
$crud = $this->get_action_crud($maj); |
279 |
|
280 |
// MODE different de CREER |
281 |
if ($maj != 0 || $crud != 'create') { |
282 |
$form->setLib('json_payload', ''); |
283 |
} |
284 |
} |
285 |
|
286 |
public function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
287 |
$ret = parent::verifier($val, $dnu1, $dnu2); |
288 |
|
289 |
// une tâche entrante doit avoir un type et une payload non-vide |
290 |
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
291 |
if (isset($this->valF['type']) === false) { |
292 |
$this->correct = false; |
293 |
$this->addToMessage(sprintf( |
294 |
__("Le champ %s est obligatoire pour une tâche entrante."), |
295 |
sprintf('<span class="bold">%s</span>', $this->getLibFromField('type')) |
296 |
)); |
297 |
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
298 |
} |
299 |
if (isset($this->valF['json_payload']) === false) { |
300 |
$this->correct = false; |
301 |
$this->addToMessage(sprintf( |
302 |
__("Le champ %s est obligatoire pour une tâche entrante."), |
303 |
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
304 |
)); |
305 |
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
306 |
} |
307 |
} |
308 |
|
309 |
// les JSONs doivent être décodables |
310 |
foreach(array('json_payload', 'timestamp_log') as $key) { |
311 |
if (isset($this->valF[$key]) && ! empty($this->valF[$key]) && ( |
312 |
is_array(json_decode($this->valF[$key], true)) === false |
313 |
|| json_last_error() !== JSON_ERROR_NONE)) { |
314 |
$this->correct = false; |
315 |
$champ_text = sprintf('<span class="bold">%s</span>', $this->getLibFromField($key)); |
316 |
$this->addToMessage(sprintf( |
317 |
__("Le champ %s doit être dans un format JSON valide (erreur: %s).". |
318 |
"<p>%s valF:</br><pre>%s</pre></p>". |
319 |
"<p>%s val:</br><pre>%s</pre></p>". |
320 |
"<p>%s POST:</br><pre>%s</pre></p>". |
321 |
"<p>%s submitted POST value:</br><pre>%s</pre></p>"), |
322 |
$champ_text, |
323 |
json_last_error() !== JSON_ERROR_NONE ? json_last_error_msg() : __('invalide'), |
324 |
$champ_text, |
325 |
$this->valF[$key], |
326 |
$champ_text, |
327 |
$val[$key], |
328 |
$champ_text, |
329 |
isset($_POST[$key]) ? $_POST[$key] : '', |
330 |
$champ_text, |
331 |
$this->f->get_submitted_post_value($key) |
332 |
)); |
333 |
$this->addToLog(__METHOD__.'(): erreur JSON: '.$this->msg, DEBUG_MODE); |
334 |
} |
335 |
} |
336 |
|
337 |
// une tâche entrante doit avoir une payload avec les clés requises |
338 |
if ($this->correct && (isset($this->valF['stream']) === false || |
339 |
$this->valF['stream'] == 'input')) { |
340 |
|
341 |
// décode la payload JSON |
342 |
$json_payload = json_decode($this->valF['json_payload'], true); |
343 |
|
344 |
// défini une liste de chemin de clés requises |
345 |
$paths = array(); |
346 |
if ($this->valF['category'] === 'platau') { |
347 |
$paths = array( |
348 |
'external_uids/dossier' |
349 |
); |
350 |
} |
351 |
|
352 |
// tâche de type création de DI/DA |
353 |
if (isset($this->valF['type']) !== false && $this->valF['type'] == 'create_DI_for_consultation') { |
354 |
|
355 |
$paths = array_merge($paths, array( |
356 |
'dossier/dossier', |
357 |
'dossier/dossier_autorisation_type_detaille_code', |
358 |
'dossier/date_demande', |
359 |
'dossier/depot_electronique', |
360 |
)); |
361 |
|
362 |
// si l'option commune est activée (mode MC) |
363 |
if ($this->f->is_option_dossier_commune_enabled()) { |
364 |
$paths[] = 'dossier/insee'; |
365 |
} |
366 |
|
367 |
// présence d'un moyen d'identifier la collectivité/le service |
368 |
if (! isset($json_payload['external_uids']['acteur']) && |
369 |
! isset($json_payload['dossier']['om_collectivite'])) { |
370 |
$this->correct = false; |
371 |
$this->addToMessage(sprintf( |
372 |
__("L'une des clés %s ou %s est obligatoire dans le contenu du champ %s pour une tâche entrante."), |
373 |
sprintf('<span class="bold">%s</span>', 'external_uids/acteur'), |
374 |
sprintf('<span class="bold">%s</span>', 'dossier/om_collectivite'), |
375 |
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
376 |
)); |
377 |
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
378 |
} |
379 |
} |
380 |
|
381 |
// pas d'erreur déjà trouvée |
382 |
if($this->correct) { |
383 |
|
384 |
// pour chaque chemin |
385 |
foreach($paths as $path) { |
386 |
|
387 |
// décompose le chemin |
388 |
$tokens = explode('/', $path); |
389 |
$cur_depth = $json_payload; |
390 |
|
391 |
// descend au et à mesure dans l'arborescence du chemin |
392 |
foreach($tokens as $token) { |
393 |
|
394 |
// en vérifiant que chaque élément du chemin est défini et non-nul |
395 |
if (isset($cur_depth[$token]) === false) { |
396 |
|
397 |
// sinon on produit une erreur |
398 |
$this->correct = false; |
399 |
$this->addToMessage(sprintf( |
400 |
__("La clé %s est obligatoire dans le contenu du champ %s pour une tâche entrante."), |
401 |
sprintf('<span class="bold">%s</span>', $path), |
402 |
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
403 |
)); |
404 |
$this->addToLog(__METHOD__.'(): erreur: '.$this->msg, DEBUG_MODE); |
405 |
break 2; |
406 |
} |
407 |
$cur_depth = $cur_depth[$token]; |
408 |
} |
409 |
} |
410 |
} |
411 |
} |
412 |
|
413 |
return $ret && $this->correct; |
414 |
} |
415 |
|
416 |
/** |
417 |
* [task_exists description] |
418 |
* @param string $type [description] |
419 |
* @param string $object_id [description] |
420 |
* @param bool $is_not_done [description] |
421 |
* @return [type] [description] |
422 |
*/ |
423 |
public function task_exists(string $type, string $object_id, string $dossier = null, bool $is_not_done = true) { |
424 |
$query = sprintf(' |
425 |
SELECT task |
426 |
FROM %1$stask |
427 |
WHERE %2$s |
428 |
type = \'%3$s\' |
429 |
AND (object_id = \'%4$s\' |
430 |
%5$s) |
431 |
AND state != \'%6$s\' |
432 |
', |
433 |
DB_PREFIXE, |
434 |
$is_not_done == true ? 'state != \''.self::STATUS_DONE.'\' AND' : '', |
435 |
$type, |
436 |
$object_id, |
437 |
$dossier !== null ? sprintf('OR dossier = \'%s\'', $dossier) : '', |
438 |
self::STATUS_CANCELED |
439 |
); |
440 |
$res = $this->f->get_one_result_from_db_query($query); |
441 |
if ($res['result'] !== null && $res['result'] !== '') { |
442 |
return $res['result']; |
443 |
} |
444 |
return false; |
445 |
} |
446 |
|
447 |
/** |
448 |
* Permet la recherche multi-critères des tasks. |
449 |
* |
450 |
* @param array $search_values Chaque entrée du tableau est une ligne dans le WHERE |
451 |
* @return mixed Retourne le résultat de la requête ou false |
452 |
*/ |
453 |
public function task_exists_multi_search(array $search_values) { |
454 |
$query = sprintf(' |
455 |
SELECT * |
456 |
FROM %1$stask |
457 |
%2$s |
458 |
%3$s |
459 |
', |
460 |
DB_PREFIXE, |
461 |
empty($search_values) === false ? ' WHERE ' : '', |
462 |
implode(' AND ', $search_values) |
463 |
); |
464 |
$res = $this->f->get_all_results_from_db_query($query); |
465 |
if (count($res['result']) > 0) { |
466 |
return $res['result']; |
467 |
} |
468 |
return false; |
469 |
} |
470 |
|
471 |
/** |
472 |
* TRIGGER - triggerajouter. |
473 |
* |
474 |
* @param string $id |
475 |
* @param null &$dnu1 @deprecated Ne pas utiliser. |
476 |
* @param array $val Tableau des valeurs brutes. |
477 |
* @param null $dnu2 @deprecated Ne pas utiliser. |
478 |
* |
479 |
* @return boolean |
480 |
*/ |
481 |
function triggerajouter($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
482 |
|
483 |
// tâche entrante |
484 |
if (isset($this->valF['stream']) === false || $this->valF['stream'] == 'input') { |
485 |
|
486 |
// décode la paylod JSON pour extraire les données métiers à ajouter |
487 |
// en tant que métadonnées de la tâche |
488 |
$json_payload = json_decode($this->valF['json_payload'], true); |
489 |
|
490 |
// si la tâche possède déjà une clé dossier |
491 |
if (isset($json_payload['dossier']['dossier']) && |
492 |
! empty($json_payload['dossier']['dossier'])) { |
493 |
$this->valF["dossier"] = $json_payload['dossier']['dossier']; |
494 |
} |
495 |
} |
496 |
|
497 |
// gestion d'une tache de type notification et de category mail |
498 |
if (isset($val['type']) |
499 |
&& ((//$val['type'] === 'notification_recepisse' |
500 |
$val['type'] === 'notification_instruction' |
501 |
|| $val['type'] === 'notification_decision') |
502 |
&& isset($val['category']) |
503 |
&& $val['category'] === 'mail') |
504 |
|| $val['type'] === 'notification_service_consulte' |
505 |
|| $val['type'] === 'notification_tiers_consulte' |
506 |
) { |
507 |
// Récupère la payload de la tache |
508 |
$data = array(); |
509 |
// TODO : pour l'instant la gestion des notifs des demandeurs a été séparée |
510 |
// de celle des autres type de notif afin de ne pas risquer de casser l'existant |
511 |
// et pour des contraintes de temps. A optimiser plus tard |
512 |
if ($val['type'] === 'notification_service_consulte' |
513 |
|| $val['type'] === 'notification_tiers_consulte') { |
514 |
$data['instruction_notification'] = $this->get_instruction_notification_data_annexe_multiple( |
515 |
$this->valF['category'], |
516 |
'with-id', |
517 |
array('with-id' => $this->valF['object_id']) |
518 |
); |
519 |
} else { |
520 |
$data['instruction_notification'] = $this->get_instruction_notification_data( |
521 |
$this->valF['category'], |
522 |
'with-id', |
523 |
array('with-id' => $this->valF['object_id']) |
524 |
); |
525 |
} |
526 |
$data['dossier'] = $this->get_dossier_data($this->valF['dossier']); |
527 |
|
528 |
// Récupère l'instance de la notification |
529 |
$inst_notif = $this->f->get_inst__om_dbform(array( |
530 |
"obj" => "instruction_notification", |
531 |
"idx" => $val['object_id'], |
532 |
)); |
533 |
// Envoi le mail et met à jour le suivi |
534 |
$envoiMail = $inst_notif->send_mail_notification($data, $val['type']); |
535 |
// Passage de la tache à done si elle a réussi et à error |
536 |
// si l'envoi a échoué |
537 |
$this->valF['state'] = 'done'; |
538 |
if ($envoiMail === false) { |
539 |
$this->valF['state'] = 'error'; |
540 |
} |
541 |
} |
542 |
} |
543 |
|
544 |
/** |
545 |
* TRIGGER - triggermodifierapres. |
546 |
* |
547 |
* @param string $id |
548 |
* @param null &$dnu1 @deprecated Ne pas utiliser. |
549 |
* @param array $val Tableau des valeurs brutes. |
550 |
* @param null $dnu2 @deprecated Ne pas utiliser. |
551 |
* |
552 |
* @return boolean |
553 |
*/ |
554 |
public function triggermodifierapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
555 |
parent::triggermodifierapres($id, $dnu1, $val, $dnu2); |
556 |
|
557 |
// Suivi des notificiations |
558 |
// En cas de changement de l'état de la tâche de notification, alors |
559 |
// le suivi des dates de la notification et de l'instruction, est effectué |
560 |
if (isset($val['category']) === true |
561 |
&& $val['category'] === 'portal' |
562 |
&& isset($val['type']) === true |
563 |
&& ($val['type'] === 'notification_recepisse' |
564 |
|| $val['type'] === 'notification_instruction' |
565 |
|| $val['type'] === 'notification_decision' |
566 |
|| $val['type'] === 'notification_service_consulte' |
567 |
|| $val['type'] === 'notification_tiers_consulte')) { |
568 |
// |
569 |
if (isset($this->valF['state']) === true |
570 |
&& $this->valF['state'] !== $this->getVal('state') |
571 |
&& $this->valF['state'] !== self::STATUS_CANCELED) { |
572 |
// |
573 |
$inst_in = $this->f->get_inst__om_dbform(array( |
574 |
"obj" => "instruction_notification", |
575 |
"idx" => $val['object_id'], |
576 |
)); |
577 |
$valF_in = array(); |
578 |
foreach ($inst_in->champs as $champ) { |
579 |
$valF_in[$champ] = $inst_in->getVal($champ); |
580 |
} |
581 |
// Par défaut la date d'envoi et la date de premier accès sur |
582 |
// la notification ne sont pas renseignées |
583 |
$valF_in['date_envoi'] = null; |
584 |
$valF_in['date_premier_acces'] = null; |
585 |
// Lorsque la tâche est correctement traitée |
586 |
if ($this->valF['state'] === self::STATUS_DONE) { |
587 |
// |
588 |
$valF_in['statut'] = __("envoyé"); |
589 |
$valF_in['commentaire'] = __("Notification traitée"); |
590 |
$valF_in['date_envoi'] = date('d/m/Y H:i:s'); |
591 |
// Si l'instruction possède un document lié, alors ses dates |
592 |
// de suivi sont mises à jour |
593 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
594 |
"obj" => "instruction", |
595 |
"idx" => $inst_in->getVal('instruction'), |
596 |
)); |
597 |
if ($inst_instruction->has_an_edition() === true) { |
598 |
$valF_instruction = array(); |
599 |
foreach ($inst_instruction->champs as $champ) { |
600 |
$valF_instruction[$champ] = $inst_instruction->getVal($champ); |
601 |
} |
602 |
$valF_instruction['date_envoi_rar'] = date('d/m/Y'); |
603 |
$valF_instruction['date_retour_rar'] = date('d/m/Y', strtotime('now + 1 day')); |
604 |
$inst_instruction->setParameter('maj', 1); |
605 |
$update_instruction = $inst_instruction->modifier($valF_instruction); |
606 |
if ($update_instruction === false) { |
607 |
$this->addToLog(__METHOD__."(): ".$inst_instruction->msg, DEBUG_MODE); |
608 |
return false; |
609 |
} |
610 |
} |
611 |
} |
612 |
// En cas d'erreur lors du traitement de la task |
613 |
if ($this->valF['state'] === self::STATUS_ERROR) { |
614 |
$valF_in['statut'] = __("échec"); |
615 |
$valF_in['commentaire'] = __("Le traitement de la notification a échoué"); |
616 |
} |
617 |
// Met à jour la notification |
618 |
$inst_in->setParameter('maj', 1); |
619 |
$update_in = $inst_in->modifier($valF_in); |
620 |
if ($update_in === false) { |
621 |
$this->addToLog(__METHOD__."(): ".$inst_in->msg, DEBUG_MODE); |
622 |
return false; |
623 |
} |
624 |
} |
625 |
} |
626 |
|
627 |
// Envoi au contrôle de légalité |
628 |
// En cas de changement de l'état de la tâche envoi_CL, alors le suivi |
629 |
// des dates de l'instruction est effectué |
630 |
if ($val['type'] === 'envoi_CL' |
631 |
&& isset($this->valF['state']) === true |
632 |
&& $this->valF['state'] === self::STATUS_DONE) { |
633 |
// |
634 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
635 |
"obj" => "instruction", |
636 |
"idx" => $this->getVal('object_id'), |
637 |
)); |
638 |
if ($inst_instruction->has_an_edition() === true) { |
639 |
$valF_instruction = array(); |
640 |
foreach ($inst_instruction->champs as $champ) { |
641 |
$valF_instruction[$champ] = $inst_instruction->getVal($champ); |
642 |
} |
643 |
} |
644 |
$valF_instruction['date_envoi_controle_legalite'] = date("Y-m-d"); |
645 |
$inst_instruction->setParameter('maj', 1); |
646 |
$update_instruction = $inst_instruction->modifier($valF_instruction); |
647 |
if ($update_instruction === false) { |
648 |
$this->addToLog(__METHOD__."(): ".$inst_instruction->msg, DEBUG_MODE); |
649 |
return false; |
650 |
} |
651 |
} |
652 |
|
653 |
// |
654 |
return true; |
655 |
} |
656 |
|
657 |
/** |
658 |
* TREATMENT - add_task |
659 |
* Ajoute un enregistrement. |
660 |
* |
661 |
* @param array $params Tableau des paramètres |
662 |
* @return boolean |
663 |
*/ |
664 |
public function add_task($params = array()) { |
665 |
$this->begin_treatment(__METHOD__); |
666 |
|
667 |
// Vérifie si la task doit être ajoutée en fonction du mode de l'application, |
668 |
// seulement pour les tasks output |
669 |
$task_types_si = self::TASK_TYPE_SI; |
670 |
$task_types_sc = self::TASK_TYPE_SC; |
671 |
$stream = isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output'; |
672 |
if ($stream === 'output' |
673 |
&& isset($params['val']['type']) === true |
674 |
&& $this->f->is_option_mode_service_consulte_enabled() === true |
675 |
&& in_array($params['val']['type'], $task_types_sc) === false) { |
676 |
// |
677 |
return $this->end_treatment(__METHOD__, true); |
678 |
} |
679 |
if ($stream === 'output' |
680 |
&& isset($params['val']['type']) === true |
681 |
&& $this->f->is_option_mode_service_consulte_enabled() === false |
682 |
&& in_array($params['val']['type'], $task_types_si) === false) { |
683 |
// |
684 |
return $this->end_treatment(__METHOD__, true); |
685 |
} |
686 |
|
687 |
// |
688 |
$timestamp_log = json_encode(array( |
689 |
'creation_date' => date('Y-m-d H:i:s'), |
690 |
)); |
691 |
|
692 |
// |
693 |
$category = isset($params['val']['category']) === true ? $params['val']['category'] : $this->category; |
694 |
|
695 |
// Si la tâche est de type ajout_piece et de stream input alors on ajoute le fichier |
696 |
// et on ajoute l'uid dans le champ json_payload avant l'ajout de la tâche |
697 |
if (isset($params['val']['type']) |
698 |
&& ($params['val']['type'] == "add_piece" || $params['val']['type'] == "avis_consultation") |
699 |
&& isset($params['val']['stream']) |
700 |
&& $params['val']['stream'] == "input" ) { |
701 |
// |
702 |
$json_payload = json_decode($params['val']['json_payload'], true); |
703 |
if (json_last_error() !== JSON_ERROR_NONE) { |
704 |
$this->addToMessage(__("Le contenu JSON de la tâche n'est pas valide.")); |
705 |
return $this->end_treatment(__METHOD__, false); |
706 |
} |
707 |
if (isset($json_payload['document_numerise']) === true |
708 |
&& empty($json_payload['document_numerise']) === false) { |
709 |
// |
710 |
$document_numerise = $json_payload['document_numerise']; |
711 |
$file_content = base64_decode($document_numerise["file_content"]); |
712 |
if ($file_content === false){ |
713 |
$this->addToMessage(__("Le contenu du fichier lié à la tâche n'a pas pu etre recupere.")); |
714 |
return $this->end_treatment(__METHOD__, false); |
715 |
} |
716 |
$metadata = array( |
717 |
"filename" => $document_numerise['nom_fichier'], |
718 |
"size" => strlen($file_content), |
719 |
"mimetype" => $document_numerise['file_content_type'], |
720 |
"date_creation" => isset($document_numerise['date_creation']) === true ? $document_numerise['date_creation'] : date("Y-m-d"), |
721 |
); |
722 |
$uid_fichier = $this->f->storage->create($file_content, $metadata, "from_content", "task.uid_fichier"); |
723 |
if ($uid_fichier === OP_FAILURE) { |
724 |
$this->addToMessage(__("Erreur lors de la creation du fichier lié à la tâche.")); |
725 |
return $this->end_treatment(__METHOD__, false); |
726 |
} |
727 |
$json_payload["document_numerise"]["uid"] = $uid_fichier; |
728 |
// Le fichier a été ajouté nous n'avons plus besoin du champ file_content dans la payload |
729 |
unset($json_payload["document_numerise"]["file_content"]); |
730 |
$params['val']['json_payload'] = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
731 |
} |
732 |
} |
733 |
|
734 |
// Mise à jour du DI |
735 |
$valF = array( |
736 |
'task' => '', |
737 |
'type' => $params['val']['type'], |
738 |
'timestamp_log' => $timestamp_log, |
739 |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : self::STATUS_NEW, |
740 |
'object_id' => isset($params['val']['object_id']) ? $params['val']['object_id'] : '', |
741 |
'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '', |
742 |
'stream' => $stream, |
743 |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
744 |
'category' => $category, |
745 |
); |
746 |
|
747 |
// tâche sortante |
748 |
$typeNonConcerne = array( |
749 |
'notification_recepisse', |
750 |
'notification_instruction', |
751 |
'notification_decision', |
752 |
'notification_service_consulte', |
753 |
'notification_tiers_consulte' |
754 |
); |
755 |
if ($valF["stream"] == "output" |
756 |
&& ! in_array($valF['type'], $typeNonConcerne)) { |
757 |
// TODO expliquer ce code |
758 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id'], $valF['dossier']); |
759 |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
760 |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
761 |
} |
762 |
if ($valF['type'] === 'modification_DA' && $task_exists === false) { |
763 |
$task_exists = $this->task_exists('creation_DA', $valF['object_id']); |
764 |
} |
765 |
if ($valF['type'] === 'ajout_piece') { |
766 |
$task_exists = $this->task_exists('ajout_piece', $valF['object_id']); |
767 |
} |
768 |
if ($valF['type'] === 'creation_consultation') { |
769 |
$task_exists = $this->task_exists('creation_consultation', $valF['object_id']); |
770 |
} |
771 |
if ($task_exists !== false) { |
772 |
$inst_task = $this->f->get_inst__om_dbform(array( |
773 |
"obj" => "task", |
774 |
"idx" => $task_exists, |
775 |
)); |
776 |
$update_state = $inst_task->getVal('state'); |
777 |
if (isset($params['update_val']['state']) === true) { |
778 |
$update_state = $params['update_val']['state']; |
779 |
} |
780 |
$update_params = array( |
781 |
'val' => array( |
782 |
'state' => $update_state, |
783 |
), |
784 |
'object_id' => $valF['object_id'], |
785 |
); |
786 |
return $inst_task->update_task($update_params); |
787 |
} |
788 |
} |
789 |
$add = $this->ajouter($valF); |
790 |
$this->addToLog(__METHOD__."(): retour de l'ajout de tâche: ".var_export($add, true), VERBOSE_MODE); |
791 |
if ($add === false) { |
792 |
$this->addToLog(__METHOD__."(): ".$this->msg, DEBUG_MODE); |
793 |
return $this->end_treatment(__METHOD__, false); |
794 |
} |
795 |
return $this->end_treatment(__METHOD__, true); |
796 |
} |
797 |
|
798 |
/** |
799 |
* TREATMENT - update_task |
800 |
* Met à jour l'enregistrement instancié. |
801 |
* |
802 |
* @param array $params Tableau des paramètres |
803 |
* @return boolean |
804 |
*/ |
805 |
public function update_task($params = array()) { |
806 |
$this->begin_treatment(__METHOD__); |
807 |
$timestamp_log = $this->get_timestamp_log(); |
808 |
if ($timestamp_log === false) { |
809 |
$this->addToLog(__METHOD__."(): erreur timestamp log", DEBUG_MODE); |
810 |
return $this->end_treatment(__METHOD__, false); |
811 |
} |
812 |
// Vérification des object_id précédent en cas de tentative d'appliquer |
813 |
// l'état CANCELED sur la tâche |
814 |
if (isset($params['val']['state']) === true |
815 |
&& $params['val']['state'] === self::STATUS_CANCELED) { |
816 |
// Récupération du journal d'activité de la tâche sous forme de tableau |
817 |
// trié par ordre décroissant |
818 |
$log = $timestamp_log; |
819 |
unset($log['creation_date']); |
820 |
krsort($log); |
821 |
// Pour chaque entrée dans le journal d'activité de la tâche : |
822 |
// - vérification de la présence de l'object_id précédent |
823 |
// - vérification que l'object_id précédent existe toujours dans la base de données |
824 |
// - l'object_id est mise à jour avec la valeur de l'object_id précédent |
825 |
// - le state n'est pas modifié |
826 |
// - sortie du traitement dès que le premier object_id précédent existant est trouvé |
827 |
// - si aucun object_id précédent existant n'est trouvé alors ni le state, ni l'object_id n'est modifiés |
828 |
foreach ($log as $key => $value) { |
829 |
// |
830 |
if (isset($value['prev_object_id']) === true |
831 |
&& $this->getVal('object_id') !== $value['prev_object_id']) { |
832 |
// Récupère la liste des tables potentielles pour un type de tâche |
833 |
$tables = $this->get_tables_by_task_type($this->getVal('type'), $this->getVal('stream')); |
834 |
foreach ($tables as $table) { |
835 |
// Vérifie s'il y a un ou aucun résultat |
836 |
$query = sprintf(' |
837 |
SELECT COUNT(%2$s) |
838 |
FROM %1$s%2$s |
839 |
WHERE %2$s::CHARACTER VARYING = \'%3$s\' |
840 |
', |
841 |
DB_PREFIXE, |
842 |
$table, |
843 |
$value['prev_object_id'] |
844 |
); |
845 |
$res = $this->f->get_one_result_from_db_query($query, true); |
846 |
if ($res['code'] === 'KO') { |
847 |
return $this->end_treatment(__METHOD__, false); |
848 |
} |
849 |
// Affectation des valeurs et sortie de la boucle |
850 |
if ($res['result'] == '1') { |
851 |
$params['object_id'] = $value['prev_object_id']; |
852 |
$params['val']['state'] = $this->getVal('state'); |
853 |
break; |
854 |
} |
855 |
} |
856 |
// Sortie de la boucle si les valeurs sont affectées |
857 |
if (isset($params['object_id']) === true |
858 |
&& $params['object_id'] === $value['prev_object_id']) { |
859 |
// |
860 |
break; |
861 |
} |
862 |
} |
863 |
} |
864 |
} |
865 |
// Mise à jour du journal d'activité de la tâche |
866 |
array_push($timestamp_log, array( |
867 |
'modification_date' => date('Y-m-d H:i:s'), |
868 |
'state' => $params['val']['state'], |
869 |
'prev_state' => $this->getVal('state'), |
870 |
'object_id' => isset($params['object_id']) == true ? $params['object_id'] : $this->getVal('object_id'), |
871 |
'prev_object_id' => $this->getVal('object_id'), |
872 |
)); |
873 |
$timestamp_log = json_encode($timestamp_log); |
874 |
// Mise à jour de la tâche |
875 |
$valF = array( |
876 |
'task' => $this->getVal($this->clePrimaire), |
877 |
'type' => $this->getVal('type'), |
878 |
'timestamp_log' => $timestamp_log, |
879 |
'state' => $params['val']['state'], |
880 |
'object_id' => isset($params['object_id']) == true ? $params['object_id'] : $this->getVal('object_id'), |
881 |
'stream' => $this->getVal('stream'), |
882 |
'dossier' => $this->getVal('dossier'), |
883 |
'json_payload' => $this->getVal('json_payload'), |
884 |
'category' => $this->getVal('category'), |
885 |
); |
886 |
$update = $this->modifier($valF); |
887 |
if ($update === false) { |
888 |
$this->addToLog($this->msg, DEBUG_MODE); |
889 |
return $this->end_treatment(__METHOD__, false); |
890 |
} |
891 |
return $this->end_treatment(__METHOD__, true); |
892 |
} |
893 |
|
894 |
/** |
895 |
* Récupère le journal d'horodatage dans le champ timestamp_log de |
896 |
* l'enregistrement instancié. |
897 |
* |
898 |
* @param array $params Tableau des paramètres |
899 |
* @return array sinon false en cas d'erreur |
900 |
*/ |
901 |
protected function get_timestamp_log($params = array()) { |
902 |
$val = $this->getVal('timestamp_log'); |
903 |
if ($val === '') { |
904 |
$val = json_encode(array()); |
905 |
} |
906 |
if($this->isJson($val) === false) { |
907 |
return false; |
908 |
} |
909 |
return json_decode($val, true); |
910 |
} |
911 |
|
912 |
/** |
913 |
* VIEW - view_json_data |
914 |
* Affiche l'enregistrement dans le format JSON. |
915 |
* |
916 |
* @return void |
917 |
*/ |
918 |
public function view_json_data() { |
919 |
$this->checkAccessibility(); |
920 |
$this->f->disableLog(); |
921 |
if ($this->getParameter('idx') !== ']' |
922 |
&& $this->getParameter('idx') !== '0') { |
923 |
// |
924 |
$this->view_form_json(); |
925 |
} |
926 |
else { |
927 |
$this->view_tab_json(); |
928 |
} |
929 |
} |
930 |
|
931 |
protected function view_tab_json() { |
932 |
$where = ''; |
933 |
if ($this->f->get_submitted_get_value('state') !== null |
934 |
&& $this->f->get_submitted_get_value('state') !== '') { |
935 |
// |
936 |
$where_or_and = 'WHERE'; |
937 |
if ($where !== '') { |
938 |
$where_or_and = 'AND'; |
939 |
} |
940 |
$where .= sprintf(' %s state = \'%s\' ', $where_or_and, $this->f->get_submitted_get_value('state')); |
941 |
} |
942 |
if ($this->f->get_submitted_get_value('category') !== null |
943 |
&& $this->f->get_submitted_get_value('category') !== '') { |
944 |
// |
945 |
$where_or_and = 'WHERE'; |
946 |
if ($where !== '') { |
947 |
$where_or_and = 'AND'; |
948 |
} |
949 |
$where .= sprintf(' %s category = \'%s\' ', $where_or_and, $this->f->get_submitted_get_value('category')); |
950 |
} |
951 |
$query = sprintf(' |
952 |
SELECT |
953 |
* |
954 |
FROM %1$stask |
955 |
%2$s |
956 |
ORDER BY task ASC |
957 |
', |
958 |
DB_PREFIXE, |
959 |
$where |
960 |
); |
961 |
$res = $this->f->get_all_results_from_db_query($query, true); |
962 |
if ($res['code'] === 'KO') { |
963 |
return false; |
964 |
} |
965 |
$list_tasks = array(); |
966 |
foreach ($res['result'] as $task) { |
967 |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
968 |
$task['dossier'] = $task['dossier']; |
969 |
if ($task['type'] === 'ajout_piece') { |
970 |
$val_dn = $this->get_document_numerise_data($task['object_id']); |
971 |
} |
972 |
if ($task['stream'] === 'output') { |
973 |
$task['external_uids'] = $this->get_all_external_uids($task['dossier']); |
974 |
} |
975 |
$list_tasks[$task['task']] = $task; |
976 |
} |
977 |
printf(json_encode($list_tasks)); |
978 |
} |
979 |
|
980 |
protected function get_dossier_data(string $dossier) { |
981 |
$val_di = array(); |
982 |
$inst_di = $this->f->get_inst__om_dbform(array( |
983 |
"obj" => "dossier", |
984 |
"idx" => $dossier, |
985 |
)); |
986 |
if (empty($inst_di->val) === true) { |
987 |
return $val_di; |
988 |
} |
989 |
$val_di = $inst_di->get_json_data(); |
990 |
if ($val_di['dossier_instruction_type_code'] === 'T') { |
991 |
$val_di['date_decision_transfert'] = $val_di['date_decision']; |
992 |
} |
993 |
unset($val_di['initial_dt']); |
994 |
unset($val_di['log_instructions']); |
995 |
return $val_di; |
996 |
} |
997 |
|
998 |
protected function get_dossier_autorisation_data(string $da) { |
999 |
$val_da = array(); |
1000 |
$inst_da = $this->f->get_inst__om_dbform(array( |
1001 |
"obj" => "dossier_autorisation", |
1002 |
"idx" => $da, |
1003 |
)); |
1004 |
$val_da = $inst_da->get_json_data(); |
1005 |
return $val_da; |
1006 |
} |
1007 |
|
1008 |
protected function get_donnees_techniques_data(string $fk_idx, string $fk_field) { |
1009 |
$val_dt = array(); |
1010 |
$inst_dt = $this->f->get_inst__by_other_idx(array( |
1011 |
"obj" => "donnees_techniques", |
1012 |
"fk_field" => $fk_field, |
1013 |
"fk_idx" => $fk_idx, |
1014 |
)); |
1015 |
$val_dt = array( |
1016 |
'donnees_techniques' => $inst_dt->getVal($inst_dt->clePrimaire), |
1017 |
'cerfa' => $inst_dt->getVal('cerfa'), |
1018 |
); |
1019 |
$val_dt = array_merge($val_dt, $inst_dt->get_donnees_techniques_applicables()); |
1020 |
if (isset($val_dt['am_exist_date']) === true) { |
1021 |
$val_dt['am_exist_date_num'] = ''; |
1022 |
if (is_numeric($val_dt['am_exist_date']) === true) { |
1023 |
$val_dt['am_exist_date_num'] = $val_dt['am_exist_date']; |
1024 |
} |
1025 |
} |
1026 |
// Correspond à la nomenclature de Plat'AU STATUT_INFO |
1027 |
$val_dt['tax_statut_info'] = 'Déclaré'; |
1028 |
// |
1029 |
if ($inst_dt->is_tab_surf_ssdest_enabled() === true) { |
1030 |
$fields_tab_surf_dest = $inst_dt->get_fields_tab_surf_dest(); |
1031 |
foreach ($fields_tab_surf_dest as $field) { |
1032 |
if (isset($val_dt[$field]) === true) { |
1033 |
unset($val_dt[$field]); |
1034 |
} |
1035 |
} |
1036 |
} else { |
1037 |
$fields_tab_surf_ssdest = $inst_dt->get_fields_tab_surf_ssdest(); |
1038 |
foreach ($fields_tab_surf_ssdest as $field) { |
1039 |
if (isset($val_dt[$field]) === true) { |
1040 |
unset($val_dt[$field]); |
1041 |
} |
1042 |
} |
1043 |
} |
1044 |
// Correspond à la nouvelle ligne CERFA v7 dans le DENSI imposition 1.2.3 |
1045 |
if (isset($val_dt['tax_su_non_habit_surf2']) === true |
1046 |
&& isset($val_dt['tax_su_non_habit_surf3']) === true |
1047 |
&& (($val_dt['tax_su_non_habit_surf2'] !== null |
1048 |
&& $val_dt['tax_su_non_habit_surf2'] !== '') |
1049 |
|| ($val_dt['tax_su_non_habit_surf3'] !== null |
1050 |
&& $val_dt['tax_su_non_habit_surf3'] !== ''))) { |
1051 |
// |
1052 |
$val_dt['tax_su_non_habit_surf8'] = intval($val_dt['tax_su_non_habit_surf2']) + intval($val_dt['tax_su_non_habit_surf3']); |
1053 |
} |
1054 |
if (isset($val_dt['tax_su_non_habit_surf_stat2']) === true |
1055 |
&& isset($val_dt['tax_su_non_habit_surf_stat3']) === true |
1056 |
&& (($val_dt['tax_su_non_habit_surf_stat2'] !== null |
1057 |
&& $val_dt['tax_su_non_habit_surf_stat2'] !== '') |
1058 |
|| ($val_dt['tax_su_non_habit_surf_stat3'] !== null |
1059 |
&& $val_dt['tax_su_non_habit_surf_stat3'] !== ''))) { |
1060 |
// |
1061 |
$val_dt['tax_su_non_habit_surf_stat8'] = intval($val_dt['tax_su_non_habit_surf_stat2']) + intval($val_dt['tax_su_non_habit_surf_stat3']); |
1062 |
} |
1063 |
// Cas particulier d'un projet réduit à l'extension d'une habitation existante |
1064 |
$particular_case = false; |
1065 |
$fields_tab_crea_loc_hab = $inst_dt->get_fields_tab_crea_loc_hab(); |
1066 |
foreach ($fields_tab_crea_loc_hab as $field) { |
1067 |
if (isset($val_dt[$field]) === false |
1068 |
|| (isset($val_dt[$field]) === true |
1069 |
&& ($val_dt[$field] === null |
1070 |
|| $val_dt[$field] === ''))) { |
1071 |
// |
1072 |
$particular_case = true; |
1073 |
} |
1074 |
} |
1075 |
if ($particular_case === true) { |
1076 |
if (isset($val_dt['tax_ext_pret']) === true |
1077 |
&& $val_dt['tax_ext_pret'] === 'f') { |
1078 |
// |
1079 |
$val_dt['tax_su_princ_surf1'] = $val_dt['tax_surf_tot_cstr']; |
1080 |
$val_dt['tax_su_princ_surf_stat1'] = $val_dt['tax_surf_loc_stat']; |
1081 |
} |
1082 |
if (isset($val_dt['tax_ext_pret']) === true |
1083 |
&& $val_dt['tax_ext_pret'] === 't') { |
1084 |
// |
1085 |
if (isset($val_dt['tax_ext_desc']) === true) { |
1086 |
if (preg_match('/[pP].*[lL].*[aA].*[iI]/', $val_dt['tax_ext_desc']) === 1 |
1087 |
|| preg_match('/[lL].*[lL].*[tT].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
1088 |
// |
1089 |
$val_dt['tax_su_princ_surf2'] = $val_dt['tax_surf_tot_cstr']; |
1090 |
$val_dt['tax_su_princ_surf_stat2'] = $val_dt['tax_surf_loc_stat']; |
1091 |
} |
1092 |
// if (preg_match('/[pP].*[tT].*[zZ]/', $val_dt['tax_ext_desc']) === 1) { |
1093 |
// $val_dt['tax_su_princ_surf4'] = $val_dt['tax_surf_tot_cstr']; |
1094 |
// $val_dt['tax_su_princ_surf_stat4'] = $val_dt['tax_surf_loc_stat']; |
1095 |
// } |
1096 |
// if (preg_match('/[pP].*[lL].*[uU].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
1097 |
// || preg_match('/[lL].*[eE].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
1098 |
// || preg_match('/[pP].*[sS].*[lL].*[aA]/', $val_dt['tax_ext_desc']) === 1 |
1099 |
// || preg_match('/[pP].*[lL].*[sS]/', $val_dt['tax_ext_desc']) === 1 |
1100 |
// || preg_match('/[lL].*[lL].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
1101 |
// // |
1102 |
// $val_dt['tax_su_princ_surf3'] = $val_dt['tax_surf_tot_cstr']; |
1103 |
// $val_dt['tax_su_princ_surf_stat3'] = $val_dt['tax_surf_loc_stat']; |
1104 |
// } |
1105 |
} |
1106 |
} |
1107 |
} |
1108 |
// Cas particulier de la surface taxable démolie |
1109 |
if (isset($val_dt['tax_surf_tot_demo']) === true |
1110 |
&& isset($val_dt['tax_surf_tax_demo']) === true |
1111 |
&& ($val_dt['tax_surf_tot_demo'] === null |
1112 |
|| $val_dt['tax_surf_tot_demo'] === '')) { |
1113 |
// |
1114 |
$val_dt['tax_surf_tot_demo'] = $val_dt['tax_surf_tax_demo']; |
1115 |
} |
1116 |
return $val_dt; |
1117 |
} |
1118 |
|
1119 |
/** |
1120 |
* Récupère la liste des objets distincts existants dans la table des liens |
1121 |
* entre identifiants internes et identifiants externes. |
1122 |
* |
1123 |
* @return array |
1124 |
*/ |
1125 |
protected function get_list_distinct_objects_external_link() { |
1126 |
$query = sprintf(' |
1127 |
SELECT |
1128 |
DISTINCT(object) |
1129 |
FROM %1$slien_id_interne_uid_externe |
1130 |
ORDER BY object ASC |
1131 |
', |
1132 |
DB_PREFIXE |
1133 |
); |
1134 |
$res = $this->f->get_all_results_from_db_query($query, true); |
1135 |
if ($res['code'] === 'KO') { |
1136 |
return array(); |
1137 |
} |
1138 |
$result = array(); |
1139 |
foreach ($res['result'] as $object) { |
1140 |
$result[] = $object['object']; |
1141 |
} |
1142 |
return $result; |
1143 |
} |
1144 |
|
1145 |
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
1146 |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
1147 |
"obj" => "lien_id_interne_uid_externe", |
1148 |
"fk_field" => 'object_id', |
1149 |
"fk_idx" => $fk_idx, |
1150 |
"fk_field_2" => 'object', |
1151 |
"fk_idx_2" => $fk_idx_2, |
1152 |
)); |
1153 |
return $inst_external_uid->getVal('external_uid'); |
1154 |
} |
1155 |
|
1156 |
protected function get_all_external_uids($fk_idx, $link_objects = array()) { |
1157 |
if (count($link_objects) == 0) { |
1158 |
$link_objects = $this->get_list_distinct_objects_external_link(); |
1159 |
} |
1160 |
$val_external_uid = array(); |
1161 |
foreach ($link_objects as $link_object) { |
1162 |
$external_uid = $this->get_external_uid($fk_idx, $link_object); |
1163 |
if ($external_uid !== '' && $external_uid !== null) { |
1164 |
$val_external_uid[$link_object] = $external_uid; |
1165 |
} |
1166 |
} |
1167 |
return $val_external_uid; |
1168 |
} |
1169 |
|
1170 |
protected function get_demandeurs_data($dossier) { |
1171 |
$val_demandeur = array(); |
1172 |
if ($dossier === null) { |
1173 |
return $val_demandeur; |
1174 |
} |
1175 |
$inst_di = $this->f->get_inst__om_dbform(array( |
1176 |
"obj" => "dossier", |
1177 |
"idx" => $dossier, |
1178 |
)); |
1179 |
$list_demandeurs = $inst_di->get_demandeurs(); |
1180 |
foreach ($list_demandeurs as $demandeur) { |
1181 |
$inst_demandeur = $this->f->get_inst__om_dbform(array( |
1182 |
"obj" => "demandeur", |
1183 |
"idx" => $demandeur['demandeur'], |
1184 |
)); |
1185 |
$val_demandeur[$demandeur['demandeur']] = $inst_demandeur->get_json_data(); |
1186 |
$val_demandeur[$demandeur['demandeur']]['petitionnaire_principal'] = $demandeur['petitionnaire_principal']; |
1187 |
} |
1188 |
return $val_demandeur; |
1189 |
} |
1190 |
|
1191 |
protected function get_architecte_data($architecte = null) { |
1192 |
$val_architecte = null; |
1193 |
if ($architecte !== null |
1194 |
&& $architecte !== '') { |
1195 |
// |
1196 |
$inst_architecte = $this->f->get_inst__om_dbform(array( |
1197 |
"obj" => "architecte", |
1198 |
"idx" => $architecte, |
1199 |
)); |
1200 |
$val_architecte = $inst_architecte->get_json_data(); |
1201 |
} |
1202 |
return $val_architecte; |
1203 |
} |
1204 |
|
1205 |
protected function get_instruction_data($dossier, $type = 'decision', $extra_params = array()) { |
1206 |
$val_instruction = null; |
1207 |
if ($dossier === null) { |
1208 |
return $val_instruction; |
1209 |
} |
1210 |
$instruction_with_doc = null; |
1211 |
$inst_di = $this->f->get_inst__om_dbform(array( |
1212 |
"obj" => "dossier", |
1213 |
"idx" => $dossier, |
1214 |
)); |
1215 |
$idx = null; |
1216 |
if ($type === 'decision') { |
1217 |
$idx = $inst_di->get_last_instruction_decision(); |
1218 |
} |
1219 |
if ($type === 'incompletude') { |
1220 |
$idx = $inst_di->get_last_instruction_incompletude(); |
1221 |
} |
1222 |
// XXX Permet de récupérer l'instruction par son identifiant |
1223 |
if ($type === 'with-id') { |
1224 |
$idx = $extra_params['with-id']; |
1225 |
} |
1226 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
1227 |
"obj" => "instruction", |
1228 |
"idx" => $idx, |
1229 |
)); |
1230 |
if (count($inst_instruction->val) > 0) { |
1231 |
$val_instruction = array(); |
1232 |
$instruction_data = $inst_instruction->get_json_data(); |
1233 |
$val_instruction = $this->sort_instruction_data($instruction_data, $val_instruction); |
1234 |
if ($instruction_data['om_fichier_instruction'] !== null |
1235 |
&& $instruction_data['om_fichier_instruction'] !== '') { |
1236 |
// |
1237 |
$instruction_with_doc = $inst_instruction->getVal($inst_instruction->clePrimaire); |
1238 |
} |
1239 |
$inst_ev = $this->f->get_inst__om_dbform(array( |
1240 |
"obj" => "evenement", |
1241 |
"idx" => $inst_instruction->getVal('evenement'), |
1242 |
)); |
1243 |
if ($inst_ev->getVal('retour') === 't') { |
1244 |
$instructions_related = $inst_instruction->get_related_instructions(); |
1245 |
foreach ($instructions_related as $instruction) { |
1246 |
if ($instruction !== null && $instruction !== '') { |
1247 |
$inst_related_instruction = $this->f->get_inst__om_dbform(array( |
1248 |
"obj" => "instruction", |
1249 |
"idx" => $instruction, |
1250 |
)); |
1251 |
$instruction_data = $inst_related_instruction->get_json_data(); |
1252 |
$val_instruction = $this->sort_instruction_data($instruction_data, $val_instruction); |
1253 |
if ($instruction_data['om_fichier_instruction'] !== null |
1254 |
&& $instruction_data['om_fichier_instruction'] !== '') { |
1255 |
// |
1256 |
$instruction_with_doc = $inst_related_instruction->getVal($inst_related_instruction->clePrimaire); |
1257 |
} |
1258 |
} |
1259 |
} |
1260 |
} |
1261 |
if ($instruction_with_doc !== null) { |
1262 |
// |
1263 |
$val_instruction['path'] = sprintf('%s&snippet=%s&obj=%s&champ=%s&id=%s', 'app/index.php?module=form', 'file', 'instruction', 'om_fichier_instruction', $instruction_with_doc); |
1264 |
} |
1265 |
} |
1266 |
return $val_instruction; |
1267 |
} |
1268 |
|
1269 |
/** |
1270 |
* Récupère les informations |
1271 |
*/ |
1272 |
protected function get_instruction_notification_data($category, $type = '', $extra_params = array()) { |
1273 |
$val_in = null; |
1274 |
|
1275 |
$idx = null; |
1276 |
if ($type === 'with-id') { |
1277 |
$idx = $extra_params['with-id']; |
1278 |
} |
1279 |
|
1280 |
// récupére les données à intégrer à la payload |
1281 |
$inst_in = $this->f->get_inst__om_dbform(array( |
1282 |
"obj" => "instruction_notification", |
1283 |
"idx" => $idx, |
1284 |
)); |
1285 |
if (count($inst_in->val) > 0) { |
1286 |
$val_in = $inst_in->get_json_data(); |
1287 |
|
1288 |
$val_in['parametre_courriel_type_titre'] = ''; |
1289 |
$val_in['parametre_courriel_type_message'] = ''; |
1290 |
// Récupération du message et du titre |
1291 |
if ($category === 'mail') { |
1292 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
1293 |
"obj" => "instruction", |
1294 |
"idx" => $inst_in->getVal('instruction'), |
1295 |
)); |
1296 |
$collectivite_id = $inst_instruction->get_dossier_instruction_om_collectivite($inst_instruction->getVal('dossier')); |
1297 |
$phrase_type_notification = array(); |
1298 |
$phrase_type_notification = $this->f->get_notification_parametre_courriel_type($collectivite_id); |
1299 |
$val_in['parametre_courriel_type_titre'] = $phrase_type_notification['parametre_courriel_type_titre']; |
1300 |
$val_in['parametre_courriel_type_message'] = $phrase_type_notification['parametre_courriel_type_message']; |
1301 |
} |
1302 |
|
1303 |
// Récupération des liens vers les documents et de l'id de l'instruction |
1304 |
// de l'annexe |
1305 |
$infoDocNotif = $inst_in->getInfosDocumentsNotif($inst_in->getVal($inst_in->clePrimaire)); |
1306 |
$val_in['lien_telechargement_document'] = $infoDocNotif['document']['lien']; |
1307 |
$val_in['lien_telechargement_annexe'] = $infoDocNotif['annexe']['lien']; |
1308 |
$val_in['instruction_annexe'] = $infoDocNotif['annexe']['id_instruction']; |
1309 |
} |
1310 |
|
1311 |
return $val_in; |
1312 |
} |
1313 |
|
1314 |
/** |
1315 |
* Récupère les informations pour les notifications ayant plusieurs annexe |
1316 |
*/ |
1317 |
protected function get_instruction_notification_data_annexe_multiple($category, $type = '', $extra_params = array()) { |
1318 |
$val_in = null; |
1319 |
|
1320 |
$idx = null; |
1321 |
if ($type === 'with-id') { |
1322 |
$idx = $extra_params['with-id']; |
1323 |
} |
1324 |
|
1325 |
// récupére les données à intégrer à la payload |
1326 |
$inst_in = $this->f->get_inst__om_dbform(array( |
1327 |
"obj" => "instruction_notification", |
1328 |
"idx" => $idx, |
1329 |
)); |
1330 |
if (count($inst_in->val) > 0) { |
1331 |
$val_in = $inst_in->get_json_data(); |
1332 |
|
1333 |
$val_in['parametre_courriel_type_titre'] = ''; |
1334 |
$val_in['parametre_courriel_type_message'] = ''; |
1335 |
// Récupération du message et du titre |
1336 |
if ($category === 'mail') { |
1337 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
1338 |
"obj" => "instruction", |
1339 |
"idx" => $inst_in->getVal('instruction'), |
1340 |
)); |
1341 |
$collectivite_id = $inst_instruction->get_dossier_instruction_om_collectivite($inst_instruction->getVal('dossier')); |
1342 |
$phrase_type_notification = array(); |
1343 |
$phrase_type_notification = $this->f->get_notification_parametre_courriel_type($collectivite_id); |
1344 |
$val_in['parametre_courriel_type_titre'] = $phrase_type_notification['parametre_courriel_type_titre']; |
1345 |
$val_in['parametre_courriel_type_message'] = $phrase_type_notification['parametre_courriel_type_message']; |
1346 |
} |
1347 |
|
1348 |
// Récupération des liens vers les documents et de l'id de l'instruction |
1349 |
// de l'annexe |
1350 |
$infoDocNotif = $inst_in->getInfosDocumentsNotifAnnexeMultiple($inst_in->getVal($inst_in->clePrimaire)); |
1351 |
$val_in['lien_telechargement_document'] = $infoDocNotif['document']['lien']; |
1352 |
$val_in['annexes'] = $infoDocNotif['annexes']; |
1353 |
} |
1354 |
|
1355 |
return $val_in; |
1356 |
} |
1357 |
|
1358 |
protected function sort_instruction_data(array $values, array $res) { |
1359 |
$fields = array( |
1360 |
"date_evenement", |
1361 |
"date_envoi_signature", |
1362 |
"date_retour_signature", |
1363 |
"date_envoi_rar", |
1364 |
"date_retour_rar", |
1365 |
"date_envoi_controle_legalite", |
1366 |
"date_retour_controle_legalite", |
1367 |
"signataire_arrete", |
1368 |
"om_fichier_instruction", |
1369 |
"tacite", |
1370 |
"lettretype", |
1371 |
"commentaire", |
1372 |
"complement_om_html", |
1373 |
); |
1374 |
foreach ($values as $key => $value) { |
1375 |
if (in_array($key, $fields) === true) { |
1376 |
if (array_key_exists($key, $res) === false |
1377 |
&& $value !== null |
1378 |
&& $value !== '') { |
1379 |
// |
1380 |
$res[$key] = $value; |
1381 |
} elseif ($key === 'tacite' |
1382 |
&& $value === 't') { |
1383 |
// |
1384 |
$res[$key] = $value; |
1385 |
} |
1386 |
} |
1387 |
} |
1388 |
return $res; |
1389 |
} |
1390 |
|
1391 |
/** |
1392 |
* Permet de définir si l'instruction passée en paramètre est une instruction |
1393 |
* récépissé d'une demande et si la demande en question a générée un dossier d'instruction. |
1394 |
* |
1395 |
* @param integer $instruction Identifiant de l'instruction |
1396 |
* @return boolean |
1397 |
*/ |
1398 |
protected function is_demande_instruction_recepisse_without_dossier($instruction) { |
1399 |
if ($instruction === null) { |
1400 |
return false; |
1401 |
} |
1402 |
$query = sprintf(' |
1403 |
SELECT demande_type.dossier_instruction_type |
1404 |
FROM %1$sdemande |
1405 |
INNER JOIN %1$sdemande_type ON demande.demande_type = demande_type.demande_type |
1406 |
WHERE demande.instruction_recepisse = %2$s |
1407 |
', |
1408 |
DB_PREFIXE, |
1409 |
$instruction |
1410 |
); |
1411 |
$res = $this->f->get_one_result_from_db_query( |
1412 |
$query, |
1413 |
true |
1414 |
); |
1415 |
if ($res['code'] === 'KO') { |
1416 |
return null; |
1417 |
} |
1418 |
if ($res['result'] === '') { |
1419 |
return true; |
1420 |
} |
1421 |
return false; |
1422 |
} |
1423 |
|
1424 |
protected function get_document_numerise_data(string $dn) { |
1425 |
$val_dn = array(); |
1426 |
$inst_dn = $this->f->get_inst__om_dbform(array( |
1427 |
"obj" => "document_numerise", |
1428 |
"idx" => $dn, |
1429 |
)); |
1430 |
$val_dn = $inst_dn->get_json_data(); |
1431 |
$val_dn['path'] = sprintf('%s&snippet=%s&obj=%s&champ=%s&id=%s', 'app/index.php?module=form', 'file', 'document_numerise', 'uid', $this->getVal('object_id')); |
1432 |
// Correspond à la nomenclature Plat'AU NATURE_PIECE |
1433 |
$val_dn['nature'] = $val_dn['document_numerise_nature_libelle']; |
1434 |
return $val_dn; |
1435 |
} |
1436 |
|
1437 |
protected function get_parcelles_data(string $object, string $idx) { |
1438 |
$val_dp = array(); |
1439 |
$inst_di = $this->f->get_inst__om_dbform(array( |
1440 |
"obj" => $object, |
1441 |
"idx" => $idx, |
1442 |
)); |
1443 |
$list_parcelles = $inst_di->get_parcelles(); |
1444 |
$no_ordre = 1; |
1445 |
foreach ($list_parcelles as $parcelle) { |
1446 |
$val_dp[$parcelle[$object.'_parcelle']] = array( |
1447 |
$object.'_parcelle' => $parcelle[$object.'_parcelle'], |
1448 |
'libelle' => $parcelle['libelle'], |
1449 |
'no_ordre' => $no_ordre, |
1450 |
); |
1451 |
$no_ordre++; |
1452 |
} |
1453 |
return $val_dp; |
1454 |
} |
1455 |
|
1456 |
protected function get_avis_decision_data(string $dossier) { |
1457 |
$inst_di = $this->f->get_inst__om_dbform(array( |
1458 |
"obj" => "dossier", |
1459 |
"idx" => $dossier, |
1460 |
)); |
1461 |
$ad = $inst_di->getVal('avis_decision'); |
1462 |
$val_ad = array(); |
1463 |
if ($ad !== null) { |
1464 |
$inst_ad = $this->f->get_inst__om_dbform(array( |
1465 |
"obj" => "avis_decision", |
1466 |
"idx" => $ad, |
1467 |
)); |
1468 |
$val_ad = $inst_ad->get_json_data(); |
1469 |
$val_ad['txAvis'] = "Voir document joint"; |
1470 |
if (isset($val_ad['tacite']) === true |
1471 |
&& $val_ad['tacite'] === 't') { |
1472 |
// |
1473 |
$val_ad['txAvis'] = "Sans objet"; |
1474 |
} |
1475 |
} |
1476 |
return $val_ad; |
1477 |
} |
1478 |
|
1479 |
protected function get_signataire_arrete_data(string $sa) { |
1480 |
$inst_sa = $this->f->get_inst__om_dbform(array( |
1481 |
"obj" => "signataire_arrete", |
1482 |
"idx" => $sa, |
1483 |
)); |
1484 |
$val_sa = array_combine($inst_sa->champs, $inst_sa->val); |
1485 |
foreach ($val_sa as $key => $value) { |
1486 |
$val_sa[$key] = strip_tags($value); |
1487 |
} |
1488 |
return $val_sa; |
1489 |
} |
1490 |
|
1491 |
// XXX WIP |
1492 |
protected function get_consultation_data(string $consultation) { |
1493 |
$val_consultation = array(); |
1494 |
$inst_consultation = $this->f->get_inst__om_dbform(array( |
1495 |
"obj" => "consultation", |
1496 |
"idx" => $consultation, |
1497 |
)); |
1498 |
$val_consultation = $inst_consultation->get_json_data(); |
1499 |
if (isset($val_consultation['fichier']) === true |
1500 |
&& $val_consultation['fichier'] !== '') { |
1501 |
// |
1502 |
$val_consultation['path_fichier'] = sprintf('%s&snippet=%s&obj=%s&champ=%s&id=%s', 'app/index.php?module=form', 'file', 'consultation', 'fichier', $this->getVal('object_id')); |
1503 |
} |
1504 |
if (isset($val_consultation['om_fichier_consultation']) === true |
1505 |
&& $val_consultation['om_fichier_consultation'] !== '') { |
1506 |
// |
1507 |
$val_consultation['path_om_fichier_consultation'] = sprintf('%s&snippet=%s&obj=%s&champ=%s&id=%s', 'app/index.php?module=form', 'file', 'consultation', 'om_fichier_consultation', $this->getVal('object_id')); |
1508 |
} |
1509 |
return $val_consultation; |
1510 |
} |
1511 |
|
1512 |
// XXX WIP |
1513 |
protected function get_service_data(string $service) { |
1514 |
$val_service = array(); |
1515 |
$inst_service = $this->f->get_inst__om_dbform(array( |
1516 |
"obj" => "service", |
1517 |
"idx" => $service, |
1518 |
)); |
1519 |
$val_service = $inst_service->get_json_data(); |
1520 |
return $val_service; |
1521 |
} |
1522 |
|
1523 |
protected function view_form_json($in_field = false) { |
1524 |
// |
1525 |
if ($this->f->get_submitted_post_value('valid') === null |
1526 |
&& $this->getVal('state') !== self::STATUS_CANCELED) { |
1527 |
// Liste des valeurs à afficher |
1528 |
$val = array(); |
1529 |
// |
1530 |
$val_task = array_combine($this->champs, $this->val); |
1531 |
foreach ($val_task as $key => $value) { |
1532 |
$val_task[$key] = strip_tags($value); |
1533 |
} |
1534 |
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
1535 |
$val['task'] = $val_task; |
1536 |
// |
1537 |
if ($this->getVal('type') === 'creation_DA' |
1538 |
|| $this->getVal('type') === 'modification_DA') { |
1539 |
// |
1540 |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
1541 |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
1542 |
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
1543 |
$val_external_uid = array(); |
1544 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
1545 |
$val['external_uids'] = $val_external_uid; |
1546 |
} |
1547 |
// |
1548 |
if ($this->getVal('type') === 'creation_DI' |
1549 |
|| $this->getVal('type') === 'modification_DI' |
1550 |
|| $this->getVal('type') === 'depot_DI') { |
1551 |
// |
1552 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
1553 |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction'); |
1554 |
$val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']); |
1555 |
$architecte = isset($val['donnees_techniques']['architecte']) === true ? $val['donnees_techniques']['architecte'] : null; |
1556 |
$val['architecte'] = $this->get_architecte_data($architecte); |
1557 |
$val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']); |
1558 |
$val_external_uid = array(); |
1559 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1560 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1561 |
$val['external_uids'] = $val_external_uid; |
1562 |
} |
1563 |
// |
1564 |
if ($this->getVal('type') === 'qualification_DI') { |
1565 |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1566 |
$val_external_uid = array(); |
1567 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1568 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1569 |
$val['external_uids'] = $val_external_uid; |
1570 |
} |
1571 |
// |
1572 |
if ($this->getVal('type') === 'ajout_piece') { |
1573 |
$val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id')); |
1574 |
$val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']); |
1575 |
$val_external_uid = array(); |
1576 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1577 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1578 |
$val_external_uid['document_numerise'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'document_numerise'); |
1579 |
$val['external_uids'] = $val_external_uid; |
1580 |
} |
1581 |
// |
1582 |
if ($this->getVal('type') === 'decision_DI') { |
1583 |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1584 |
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
1585 |
$val['instruction']['final'] = 't'; |
1586 |
if (isset($val['instruction']['signataire_arrete']) === true) { |
1587 |
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
1588 |
} |
1589 |
$val_external_uid = array(); |
1590 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1591 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1592 |
$val['external_uids'] = $val_external_uid; |
1593 |
} |
1594 |
// |
1595 |
if ($this->getVal('type') === 'incompletude_DI') { |
1596 |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1597 |
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
1598 |
$val_external_uid = array(); |
1599 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1600 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1601 |
$val['external_uids'] = $val_external_uid; |
1602 |
} |
1603 |
// |
1604 |
if ($this->getVal('type') === 'completude_DI') { |
1605 |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1606 |
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
1607 |
$val_external_uid = array(); |
1608 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1609 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1610 |
$val['external_uids'] = $val_external_uid; |
1611 |
} |
1612 |
// |
1613 |
if ($this->getVal('type') === 'pec_metier_consultation') { |
1614 |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1615 |
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1616 |
$val_external_uid = array(); |
1617 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1618 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1619 |
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
1620 |
$val['external_uids'] = $val_external_uid; |
1621 |
} |
1622 |
// |
1623 |
if ($this->getVal('type') === 'avis_consultation') { |
1624 |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1625 |
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1626 |
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
1627 |
if (isset($val['instruction']['signataire_arrete']) === true) { |
1628 |
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
1629 |
} |
1630 |
$val_external_uid = array(); |
1631 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1632 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1633 |
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
1634 |
$val['external_uids'] = $val_external_uid; |
1635 |
} |
1636 |
// XXX WIP |
1637 |
if ($this->getVal('type') === 'creation_consultation') { |
1638 |
// |
1639 |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1640 |
$val['consultation'] = $this->get_consultation_data($this->getVal('object_id')); |
1641 |
$val['service'] = $this->get_service_data($val['consultation']['service']); |
1642 |
$val_external_uid = array(); |
1643 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1644 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1645 |
$val['external_uids'] = $val_external_uid; |
1646 |
} |
1647 |
// |
1648 |
if ($this->getVal('type') === 'envoi_CL') { |
1649 |
// |
1650 |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1651 |
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1652 |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($val['dossier']['dossier_autorisation']); |
1653 |
$val_external_uid = array(); |
1654 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1655 |
$val_external_uid['dossier'] = $this->get_external_uid($this->getVal('dossier'), 'dossier'); |
1656 |
$val_external_uid['decision'] = $this->get_external_uid($this->getVal('object_id'), 'instruction'); |
1657 |
if ($val_external_uid['decision'] === null) { |
1658 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
1659 |
"obj" => "instruction", |
1660 |
"idx" => $this->getVal('object_id'), |
1661 |
)); |
1662 |
$val_external_uid['decision'] = $this->get_external_uid($inst_instruction->get_related_instructions_next('retour_signature'), 'instruction'); |
1663 |
} |
1664 |
$val['external_uids'] = $val_external_uid; |
1665 |
} |
1666 |
// |
1667 |
if ($this->getVal('type') === 'notification_instruction' |
1668 |
|| $this->getVal('type') === 'notification_recepisse' |
1669 |
|| $this->getVal('type') === 'notification_decision') { |
1670 |
// |
1671 |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1672 |
$dossier_id = isset($val['dossier']['dossier']) === true ? $val['dossier']['dossier'] : null; |
1673 |
$val['demandeur'] = $this->get_demandeurs_data($dossier_id); |
1674 |
$val['instruction_notification'] = $this->get_instruction_notification_data($this->getVal('category'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1675 |
$instruction_id = isset($val['instruction_notification']['instruction']) === true ? $val['instruction_notification']['instruction'] : null; |
1676 |
$instruction_annexe = isset($val['instruction_notification']['instruction_annexe']) === true ? $val['instruction_notification']['instruction_annexe'] : null; |
1677 |
$val['instruction'] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $instruction_id)); |
1678 |
// Précise qu'il s'agit d'une instruction final si l'instruction est liée à une |
1679 |
// demande dont le type ne génère pas de dossier |
1680 |
if ($this->is_demande_instruction_recepisse_without_dossier($instruction_id) === true) { |
1681 |
$val['instruction']['final'] = 't'; |
1682 |
} |
1683 |
// |
1684 |
if ($instruction_annexe != '') { |
1685 |
$val['instruction_annexe'] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $instruction_annexe)); |
1686 |
} |
1687 |
$val_external_uid = array(); |
1688 |
// Affiche l'identifiant externe lié à l'instruction si cette combinaison existe, sinon celui lié au dossier |
1689 |
$val_external_uid['demande'] = $this->get_external_uid($instruction_id, 'demande') !== '' ? $this->get_external_uid($instruction_id, 'demande') : $this->get_external_uid($dossier_id, 'demande'); |
1690 |
$val['external_uids'] = $val_external_uid; |
1691 |
} |
1692 |
if ($this->getVal('type') === 'notification_service_consulte' |
1693 |
|| $this->getVal('type') === 'notification_tiers_consulte') { |
1694 |
// |
1695 |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1696 |
$dossier_id = isset($val['dossier']['dossier']) === true ? $val['dossier']['dossier'] : null; |
1697 |
$val['demandeur'] = $this->get_demandeurs_data($dossier_id); |
1698 |
$val['instruction_notification'] = $this->get_instruction_notification_data_annexe_multiple($this->getVal('category'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1699 |
$instruction_id = isset($val['instruction_notification']['instruction']) === true ? $val['instruction_notification']['instruction'] : null; |
1700 |
$instruction_annexes = isset($val['instruction_notification']['annexes']) === true ? $val['instruction_notification']['annexes'] : null; |
1701 |
$val['instruction'] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $instruction_id)); |
1702 |
// Précise qu'il s'agit d'une instruction final si l'instruction est liée à une |
1703 |
// demande dont le type ne génère pas de dossier |
1704 |
if ($this->is_demande_instruction_recepisse_without_dossier($instruction_id) === true) { |
1705 |
$val['instruction']['final'] = 't'; |
1706 |
} |
1707 |
// |
1708 |
if (is_array($instruction_annexes) && $instruction_annexes != array()) { |
1709 |
$val['instruction_annexe'] = array(); |
1710 |
$numAnnexe = 0; |
1711 |
foreach ($instruction_annexes as $annexe) { |
1712 |
if ($annexe['document_type'] === 'instruction') { |
1713 |
$val['instruction_annexe']['annexe_'.$numAnnexe++] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $annexe['document_id'])); |
1714 |
} elseif ($annexe['document_type'] === 'consultation') { |
1715 |
$val['instruction_annexe']['annexe_'.$numAnnexe++] = $this->get_consultation_data($annexe['document_id']); |
1716 |
} |
1717 |
} |
1718 |
} |
1719 |
$val_external_uid = array(); |
1720 |
// Affiche l'identifiant externe lié à l'instruction si cette combinaison existe, sinon celui lié au dossier |
1721 |
$val_external_uid['demande'] = $this->get_external_uid($instruction_id, 'demande') !== '' ? $this->get_external_uid($instruction_id, 'demande') : $this->get_external_uid($dossier_id, 'demande'); |
1722 |
$val['external_uids'] = $val_external_uid; |
1723 |
} |
1724 |
// |
1725 |
if ($this->getVal('type') === 'prescription') { |
1726 |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1727 |
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1728 |
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
1729 |
if (isset($val['instruction']['signataire_arrete']) === true) { |
1730 |
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
1731 |
} |
1732 |
$val_external_uid = array(); |
1733 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1734 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1735 |
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
1736 |
$val['external_uids'] = $val_external_uid; |
1737 |
} |
1738 |
|
1739 |
if ($in_field === true) { |
1740 |
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
1741 |
} else { |
1742 |
// Liste des valeurs affichée en JSON |
1743 |
echo(json_encode($val, JSON_UNESCAPED_SLASHES)); |
1744 |
} |
1745 |
} |
1746 |
} |
1747 |
|
1748 |
function post_update_task() { |
1749 |
// Mise à jour des valeurs |
1750 |
|
1751 |
// Modification de l'état de la tâche |
1752 |
if ($this->f->get_submitted_post_value('state') !== null) { |
1753 |
$params = array( |
1754 |
'val' => array( |
1755 |
'state' => $this->f->get_submitted_post_value('state') |
1756 |
), |
1757 |
); |
1758 |
$update = $this->update_task($params); |
1759 |
$message_class = "valid"; |
1760 |
$message = $this->msg; |
1761 |
if ($update === false) { |
1762 |
$this->addToLog($this->msg, DEBUG_MODE); |
1763 |
$message_class = "error"; |
1764 |
$message = sprintf( |
1765 |
'%s %s', |
1766 |
__('Impossible de mettre à jour la tâche.'), |
1767 |
__('Veuillez contacter votre administrateur.') |
1768 |
); |
1769 |
} |
1770 |
$this->f->displayMessage($message_class, $message); |
1771 |
} |
1772 |
|
1773 |
// Sauvegarde de l'uid externe retourné |
1774 |
if ($this->f->get_submitted_post_value('external_uid') !== null) { |
1775 |
// |
1776 |
$objects = $this->get_objects_by_task_type($this->getVal('type'), $this->getVal('stream')); |
1777 |
foreach ($objects as $object) { |
1778 |
$inst_lien = $this->f->get_inst__om_dbform(array( |
1779 |
"obj" => "lien_id_interne_uid_externe", |
1780 |
"idx" => ']', |
1781 |
)); |
1782 |
$object_id = $this->getVal('object_id'); |
1783 |
// Dans le cas spécifique de la mise à jour d'une notification |
1784 |
// et de la création d'une liaison d'identifiant pour l'objet demande, |
1785 |
// l'identifiant de l'objet n'est plus celui de la notification |
1786 |
// d'instruction mais celui du dossier d'instruction |
1787 |
if ($object === 'demande' |
1788 |
&& ($this->getVal('type') === 'notification_recepisse' |
1789 |
|| $this->getVal('type') === 'notification_instruction' |
1790 |
|| $this->getVal('type') === 'notification_decision' |
1791 |
|| $this->getVal('type') === 'notification_service_consulte' |
1792 |
|| $this->getVal('type') === 'notification_tiers_consulte')) { |
1793 |
// |
1794 |
$object_id = $this->getVal('dossier'); |
1795 |
} |
1796 |
if ($inst_lien->is_exists($object, $object_id, $this->f->get_submitted_post_value('external_uid'), $this->getVal('dossier')) === false) { |
1797 |
$valF = array( |
1798 |
'lien_id_interne_uid_externe' => '', |
1799 |
'object' => $object, |
1800 |
'object_id' => $object_id, |
1801 |
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
1802 |
'dossier' => $this->getVal('dossier'), |
1803 |
'category' => $this->getVal('category'), |
1804 |
); |
1805 |
$add = $inst_lien->ajouter($valF); |
1806 |
$message_class = "valid"; |
1807 |
$message = $inst_lien->msg; |
1808 |
if ($add === false) { |
1809 |
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
1810 |
$message_class = "error"; |
1811 |
$message = sprintf( |
1812 |
'%s %s', |
1813 |
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
1814 |
__('Veuillez contacter votre administrateur.') |
1815 |
); |
1816 |
} |
1817 |
$this->f->displayMessage($message_class, $message); |
1818 |
} |
1819 |
} |
1820 |
} |
1821 |
} |
1822 |
|
1823 |
function post_add_task() { |
1824 |
// TODO Tester de remplacer la ligne de json_payload par un $_POST |
1825 |
$result = $this->add_task(array( |
1826 |
'val' => array( |
1827 |
'stream' => 'input', |
1828 |
'json_payload' => html_entity_decode($this->f->get_submitted_post_value('json_payload')), |
1829 |
'type' => $this->f->get_submitted_post_value('type'), |
1830 |
'category' => $this->f->get_submitted_post_value('category'), |
1831 |
) |
1832 |
)); |
1833 |
$message = sprintf( |
1834 |
__("Tâche %s ajoutée avec succès"), |
1835 |
$this->getVal($this->clePrimaire)). |
1836 |
'<br/><br/>'. |
1837 |
$this->msg; |
1838 |
$message_class = "valid"; |
1839 |
if ($result === false){ |
1840 |
$this->addToLog($this->msg, DEBUG_MODE); |
1841 |
$message_class = "error"; |
1842 |
$message = sprintf( |
1843 |
'%s %s', |
1844 |
__('Impossible d\'ajouter la tâche.'), |
1845 |
__('Veuillez contacter votre administrateur.') |
1846 |
); |
1847 |
} |
1848 |
$this->f->displayMessage($message_class, $message); |
1849 |
} |
1850 |
|
1851 |
function setLayout(&$form, $maj) { |
1852 |
|
1853 |
// Récupération du mode de l'action |
1854 |
$crud = $this->get_action_crud($maj); |
1855 |
|
1856 |
// MODE different de CREER |
1857 |
if ($maj != 0 || $crud != 'create') { |
1858 |
$form->setBloc('json_payload', 'D', '', 'col_6'); |
1859 |
$form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed"); |
1860 |
$form->setBloc('json_payload', 'F'); |
1861 |
} |
1862 |
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
1863 |
} |
1864 |
|
1865 |
/** |
1866 |
* Récupère le nom de l'objet à mentionner dans la table lien_id_interne_uid_externe |
1867 |
* en fonction du type et du stream de la tâche. |
1868 |
* |
1869 |
* @param string $type Type de la tâche |
1870 |
* @param string $stream Stream de la tâche |
1871 |
* |
1872 |
* @return array |
1873 |
*/ |
1874 |
function get_objects_by_task_type($type, $stream = 'all') { |
1875 |
$objects = array(); |
1876 |
if (in_array($type, array('creation_DA', 'modification_DA', )) === true) { |
1877 |
$objects = array('dossier_autorisation', ); |
1878 |
} |
1879 |
if (in_array($type, array('creation_DI', 'depot_DI', 'notification_DI', 'qualification_DI', )) === true) { |
1880 |
$objects = array('dossier', ); |
1881 |
} |
1882 |
if (in_array($type, array('create_DI_for_consultation', )) === true) { |
1883 |
$objects = array('dossier', 'dossier_consultation', ); |
1884 |
} |
1885 |
if (in_array($type, array('create_DI', )) === true |
1886 |
&& $stream === 'input') { |
1887 |
$objects = array('dossier', 'dossier_autorisation', 'demande', ); |
1888 |
} |
1889 |
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
1890 |
$objects = array('instruction', ); |
1891 |
} |
1892 |
if (in_array($type, array('envoi_CL', )) === true) { |
1893 |
$objects = array('instruction_action_cl', ); |
1894 |
} |
1895 |
if (in_array($type, array('pec_metier_consultation', )) === true |
1896 |
&& $stream === 'output') { |
1897 |
$objects = array('pec_dossier_consultation', ); |
1898 |
} |
1899 |
if (in_array($type, array('avis_consultation', )) === true |
1900 |
&& $stream === 'output') { |
1901 |
$objects = array('avis_dossier_consultation', ); |
1902 |
} |
1903 |
if (in_array($type, array('prescription', )) === true |
1904 |
&& $stream === 'output') { |
1905 |
$objects = array('prescription', ); |
1906 |
} |
1907 |
if (in_array($type, array('ajout_piece', 'add_piece', )) === true) { |
1908 |
$objects = array('piece', ); |
1909 |
} |
1910 |
if (in_array($type, array('creation_consultation', )) === true) { |
1911 |
$objects = array('consultation', ); |
1912 |
} |
1913 |
if (in_array($type, array('pec_metier_consultation', )) === true |
1914 |
&& $stream === 'input') { |
1915 |
$objects = array('pec_metier_consultation', ); |
1916 |
} |
1917 |
if (in_array($type, array('avis_consultation', )) === true |
1918 |
&& $stream === 'input') { |
1919 |
$objects = array('avis_consultation', ); |
1920 |
} |
1921 |
if (in_array($type, array('create_message', )) === true |
1922 |
&& $stream === 'input') { |
1923 |
$objects = array('dossier_message', ); |
1924 |
} |
1925 |
if (in_array( |
1926 |
$type, |
1927 |
array( |
1928 |
'notification_recepisse', |
1929 |
'notification_instruction', |
1930 |
'notification_decision', |
1931 |
'notification_service_consulte', |
1932 |
'notification_tiers_consulte', |
1933 |
) |
1934 |
) === true) { |
1935 |
$objects = array('instruction_notification', 'demande', ); |
1936 |
} |
1937 |
return $objects; |
1938 |
} |
1939 |
|
1940 |
/** |
1941 |
* Récupère les tables auxquelles pourrait être rattaché l'objet lié à la tâche, |
1942 |
* par rapport à son type. |
1943 |
* |
1944 |
* @param string $type Type de la tâche |
1945 |
* @param string $stream input ou output |
1946 |
* @return array |
1947 |
*/ |
1948 |
function get_tables_by_task_type($type, $stream = 'all') { |
1949 |
$tables = array(); |
1950 |
if (in_array($type, array('creation_DA', 'modification_DA', )) === true) { |
1951 |
$tables = array('dossier_autorisation', ); |
1952 |
} |
1953 |
if (in_array($type, array('creation_DI', 'depot_DI', )) === true) { |
1954 |
$tables = array('dossier', ); |
1955 |
} |
1956 |
if (in_array($type, array('qualification_DI', )) === true) { |
1957 |
$tables = array('instruction', 'dossier', ); |
1958 |
} |
1959 |
if (in_array($type, array('create_DI_for_consultation', )) === true) { |
1960 |
$tables = array('dossier', ); |
1961 |
} |
1962 |
if (in_array($type, array('create_DI', )) === true |
1963 |
&& $stream === 'input') { |
1964 |
$tables = array('dossier', 'dossier_autorisation', 'demande', ); |
1965 |
} |
1966 |
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
1967 |
$tables = array('instruction', ); |
1968 |
} |
1969 |
if (in_array($type, array('pec_metier_consultation', )) === true |
1970 |
&& $stream === 'output') { |
1971 |
$tables = array('instruction', ); |
1972 |
} |
1973 |
if (in_array($type, array('avis_consultation', )) === true |
1974 |
&& $stream === 'output') { |
1975 |
$tables = array('instruction', ); |
1976 |
} |
1977 |
if (in_array($type, array('prescription', )) === true |
1978 |
&& $stream === 'output') { |
1979 |
$tables = array('instruction', ); |
1980 |
} |
1981 |
if (in_array($type, array('ajout_piece', 'add_piece', )) === true) { |
1982 |
$tables = array('document_numerise', ); |
1983 |
} |
1984 |
if (in_array($type, array('creation_consultation', )) === true) { |
1985 |
$tables = array('consultation', ); |
1986 |
} |
1987 |
if (in_array($type, array('pec_metier_consultation', )) === true |
1988 |
&& $stream === 'input') { |
1989 |
$tables = array('consultation', ); |
1990 |
} |
1991 |
if (in_array($type, array('avis_consultation', )) === true |
1992 |
&& $stream === 'input') { |
1993 |
$tables = array('consultation', ); |
1994 |
} |
1995 |
if (in_array($type, array('create_message', )) === true |
1996 |
&& $stream === 'input') { |
1997 |
$tables = array('dossier_message', ); |
1998 |
} |
1999 |
if (in_array( |
2000 |
$type, |
2001 |
array( |
2002 |
'notification_recepisse', |
2003 |
'notification_instruction', |
2004 |
'notification_decision', |
2005 |
'notification_service_consulte', |
2006 |
'notification_tiers_consulte' |
2007 |
) |
2008 |
) === true) { |
2009 |
$tables = array('instruction_notification', ); |
2010 |
} |
2011 |
return $tables; |
2012 |
} |
2013 |
|
2014 |
} |