13 |
const STATUS_ERROR = 'error'; |
const STATUS_ERROR = 'error'; |
14 |
const STATUS_DEBUG = 'debug'; |
const STATUS_DEBUG = 'debug'; |
15 |
const STATUS_ARCHIVED = 'archived'; |
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 |
|
); |
40 |
|
|
41 |
|
/** |
42 |
|
* Liste des types de tâche concernant les services consultés |
43 |
|
*/ |
44 |
|
const TASK_TYPE_SC = array( |
45 |
|
'create_DI_for_consultation', |
46 |
|
'avis_consultation', |
47 |
|
'pec_metier_consultation', |
48 |
|
'create_message', |
49 |
|
'notification_recepisse', |
50 |
|
'notification_instruction', |
51 |
|
'notification_decision', |
52 |
|
'prescription', |
53 |
|
); |
54 |
|
|
55 |
|
/** |
56 |
|
* Catégorie de la tâche |
57 |
|
*/ |
58 |
|
var $category = 'platau'; |
59 |
|
|
60 |
/** |
/** |
61 |
* Définition des actions disponibles sur la classe. |
* Définition des actions disponibles sur la classe. |
135 |
if (! isset($val['json_payload']) || empty($val['json_payload'])) { |
if (! isset($val['json_payload']) || empty($val['json_payload'])) { |
136 |
|
|
137 |
// récupère l'objet existant |
// récupère l'objet existant |
138 |
$existing = $this->f->findObjectById(get_class($this), $id); |
$existing = $this->f->findObjectById('task', $id); |
139 |
if (! empty($existing)) { |
if (! empty($existing)) { |
140 |
|
|
141 |
// récupère la payload de l'objet |
// récupère la payload de l'objet |
146 |
} |
} |
147 |
} |
} |
148 |
} |
} |
149 |
|
|
150 |
|
if (array_key_exists('category', $val) === false |
151 |
|
|| $this->valF['category'] === '' |
152 |
|
|| $this->valF['category'] === null) { |
153 |
|
// |
154 |
|
$this->valF['category'] = $this->category; |
155 |
|
} |
156 |
} |
} |
157 |
|
|
158 |
/** |
/** |
169 |
"stream", |
"stream", |
170 |
"json_payload", |
"json_payload", |
171 |
"timestamp_log", |
"timestamp_log", |
172 |
|
"category", |
173 |
); |
); |
174 |
} |
} |
175 |
|
|
179 |
// Récupération du mode de l'action |
// Récupération du mode de l'action |
180 |
$crud = $this->get_action_crud($maj); |
$crud = $this->get_action_crud($maj); |
181 |
|
|
182 |
|
// ALL |
183 |
|
$form->setType("category", "hidden"); |
184 |
|
|
185 |
// MODE CREER |
// MODE CREER |
186 |
if ($maj == 0 || $crud == 'create') { |
if ($maj == 0 || $crud == 'create') { |
187 |
$form->setType("state", "select"); |
$form->setType("state", "select"); |
209 |
if($maj < 2) { |
if($maj < 2) { |
210 |
|
|
211 |
$contenu = array(); |
$contenu = array(); |
212 |
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG') as $key) { |
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG', 'ARCHIVED', 'CANCELED') as $key) { |
213 |
$const_name = 'STATUS_'.$key; |
$const_name = 'STATUS_'.$key; |
214 |
$const_value = constant("self::$const_name"); |
$const_value = constant("self::$const_name"); |
215 |
$contenu[0][] = $const_value; |
$contenu[0][] = $const_value; |
216 |
$contenu[1][] = __($const_value); |
$contenu[1][] = $const_value; |
217 |
} |
} |
218 |
|
|
219 |
$form->setSelect("state", $contenu); |
$form->setSelect("state", $contenu); |
234 |
"idx" => $form->val['dossier'], |
"idx" => $form->val['dossier'], |
235 |
)); |
)); |
236 |
|
|
237 |
if($form->val['type'] == "creation_DA"){ |
if($form->val['type'] == "creation_DA" |
238 |
|
|| $form->val['type'] == "modification_DA"){ |
239 |
|
// |
240 |
$obj_link = 'dossier_autorisation'; |
$obj_link = 'dossier_autorisation'; |
241 |
} else { |
} else { |
242 |
$obj_link = 'dossier_instruction'; |
$obj_link = 'dossier_instruction'; |
338 |
$json_payload = json_decode($this->valF['json_payload'], true); |
$json_payload = json_decode($this->valF['json_payload'], true); |
339 |
|
|
340 |
// défini une liste de chemin de clés requises |
// défini une liste de chemin de clés requises |
341 |
$paths = array( |
$paths = array(); |
342 |
'external_uids/dossier' |
if ($this->valF['category'] === 'platau') { |
343 |
); |
$paths = array( |
344 |
|
'external_uids/dossier' |
345 |
|
); |
346 |
|
} |
347 |
|
|
348 |
// tâche de type création de DI/DA |
// tâche de type création de DI/DA |
349 |
if (isset($this->valF['type']) !== false && $this->valF['type'] == 'create_DI_for_consultation') { |
if (isset($this->valF['type']) !== false && $this->valF['type'] == 'create_DI_for_consultation') { |
361 |
} |
} |
362 |
|
|
363 |
// présence d'un moyen d'identifier la collectivité/le service |
// présence d'un moyen d'identifier la collectivité/le service |
364 |
if (! isset($json_payload['dossier']['acteur']) && |
if (! isset($json_payload['external_uids']['acteur']) && |
365 |
! isset($json_payload['dossier']['om_collectivite'])) { |
! isset($json_payload['dossier']['om_collectivite'])) { |
366 |
$this->correct = false; |
$this->correct = false; |
367 |
$this->addToMessage(sprintf( |
$this->addToMessage(sprintf( |
368 |
__("L'une des clés %s ou %s est obligatoire dans le contenu du champ %s pour une tâche entrante."), |
__("L'une des clés %s ou %s est obligatoire dans le contenu du champ %s pour une tâche entrante."), |
369 |
sprintf('<span class="bold">%s</span>', 'dossier/acteur'), |
sprintf('<span class="bold">%s</span>', 'external_uids/acteur'), |
370 |
sprintf('<span class="bold">%s</span>', 'dossier/om_collectivite'), |
sprintf('<span class="bold">%s</span>', 'dossier/om_collectivite'), |
371 |
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
372 |
)); |
)); |
409 |
return $ret && $this->correct; |
return $ret && $this->correct; |
410 |
} |
} |
411 |
|
|
412 |
protected function task_exists(string $type, string $object_id) { |
/** |
413 |
|
* [task_exists description] |
414 |
|
* @param string $type [description] |
415 |
|
* @param string $object_id [description] |
416 |
|
* @param bool $is_not_done [description] |
417 |
|
* @return [type] [description] |
418 |
|
*/ |
419 |
|
public function task_exists(string $type, string $object_id, string $dossier = null, bool $is_not_done = true) { |
420 |
$query = sprintf(' |
$query = sprintf(' |
421 |
SELECT task |
SELECT task |
422 |
FROM %1$stask |
FROM %1$stask |
423 |
WHERE state != \'%2$s\' |
WHERE %2$s |
424 |
AND type = \'%3$s\' |
type = \'%3$s\' |
425 |
AND object_id = \'%4$s\' |
AND (object_id = \'%4$s\' |
426 |
|
%5$s) |
427 |
|
AND state != \'%6$s\' |
428 |
', |
', |
429 |
DB_PREFIXE, |
DB_PREFIXE, |
430 |
self::STATUS_DONE, |
$is_not_done == true ? 'state != \''.self::STATUS_DONE.'\' AND' : '', |
431 |
$type, |
$type, |
432 |
$object_id |
$object_id, |
433 |
|
$dossier !== null ? sprintf('OR dossier = \'%s\'', $dossier) : '', |
434 |
|
self::STATUS_CANCELED |
435 |
); |
); |
436 |
$res = $this->f->get_one_result_from_db_query($query); |
$res = $this->f->get_one_result_from_db_query($query); |
437 |
if ($res['result'] !== null && $res['result'] !== '') { |
if ($res['result'] !== null && $res['result'] !== '') { |
441 |
} |
} |
442 |
|
|
443 |
/** |
/** |
444 |
|
* Permet la recherche multi-critères des tasks. |
445 |
|
* |
446 |
|
* @param array $search_values Chaque entrée du tableau est une ligne dans le WHERE |
447 |
|
* @return mixed Retourne le résultat de la requête ou false |
448 |
|
*/ |
449 |
|
public function task_exists_multi_search(array $search_values) { |
450 |
|
$query = sprintf(' |
451 |
|
SELECT task |
452 |
|
FROM %1$stask |
453 |
|
%2$s |
454 |
|
%3$s |
455 |
|
', |
456 |
|
DB_PREFIXE, |
457 |
|
empty($search_values) === false ? ' WHERE ' : '', |
458 |
|
implode(' AND ', $search_values) |
459 |
|
); |
460 |
|
$res = $this->f->get_all_results_from_db_query($query); |
461 |
|
if (count($res['result']) > 0) { |
462 |
|
return $res['result']; |
463 |
|
} |
464 |
|
return false; |
465 |
|
} |
466 |
|
|
467 |
|
/** |
468 |
* TRIGGER - triggerajouter. |
* TRIGGER - triggerajouter. |
469 |
* |
* |
470 |
* @param string $id |
* @param string $id |
488 |
! empty($json_payload['dossier']['dossier'])) { |
! empty($json_payload['dossier']['dossier'])) { |
489 |
$this->valF["dossier"] = $json_payload['dossier']['dossier']; |
$this->valF["dossier"] = $json_payload['dossier']['dossier']; |
490 |
} |
} |
491 |
|
} |
492 |
|
|
493 |
/** |
// gestion d'une tache de type notification et de category mail |
494 |
* Puisque le dossier n'a potentiellement pas encore été créé |
if (isset($val['type']) |
495 |
* alors il faut ne faut chercher à récupérer le numéro de dossier openADS |
&& (//$val['type'] === 'notification_recepisse' |
496 |
* à partir de l'external_uids (en passant par la table de liens) |
$val['type'] === 'notification_instruction' |
497 |
// sinon si la tâche possède une clé external_uids/dossier |
|| $val['type'] === 'notification_decision') |
498 |
elseif(isset($json_payload['external_uids']['dossier']) && |
&& isset($val['category']) |
499 |
! empty($json_payload['external_uids']['dossier'])) { |
&& $val['category'] === 'mail') { |
500 |
|
// Récupère la payload de la tache |
501 |
|
$data = array(); |
502 |
|
$data['instruction_notification'] = $this->get_instruction_notification_data( |
503 |
|
$this->valF['category'], |
504 |
|
'with-id', |
505 |
|
array('with-id' => $this->valF['object_id']) |
506 |
|
); |
507 |
|
$data['dossier'] = $this->get_dossier_data($this->valF['dossier']); |
508 |
|
|
509 |
// instancie l'objet lien_id_interne_uid_externe |
// Récupère l'instance de la notification |
510 |
$inst_lien = $this->f->get_inst__om_dbform(array( |
$inst_notif = $this->f->get_inst__om_dbform(array( |
511 |
"obj" => "lien_id_interne_uid_externe", |
"obj" => "instruction_notification", |
512 |
"idx" => ']', |
"idx" => $val['object_id'], |
513 |
|
)); |
514 |
|
// Envoi le mail et met à jour le suivi |
515 |
|
$envoiMail = $inst_notif->send_mail_notification_demandeur($data); |
516 |
|
// Passage de la tache à done si elle a réussi et à error |
517 |
|
// si l'envoi a échoué |
518 |
|
$this->valF['state'] = 'done'; |
519 |
|
if ($envoiMail === false) { |
520 |
|
$this->valF['state'] = 'error'; |
521 |
|
} |
522 |
|
} |
523 |
|
} |
524 |
|
|
525 |
|
/** |
526 |
|
* TRIGGER - triggermodifierapres. |
527 |
|
* |
528 |
|
* @param string $id |
529 |
|
* @param null &$dnu1 @deprecated Ne pas utiliser. |
530 |
|
* @param array $val Tableau des valeurs brutes. |
531 |
|
* @param null $dnu2 @deprecated Ne pas utiliser. |
532 |
|
* |
533 |
|
* @return boolean |
534 |
|
*/ |
535 |
|
public function triggermodifierapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
536 |
|
parent::triggermodifierapres($id, $dnu1, $val, $dnu2); |
537 |
|
|
538 |
|
// Suivi des notificiations |
539 |
|
// En cas de changement de l'état de la tâche de notification, alors |
540 |
|
// le suivi des dates de la notification et de l'instruction, est effectué |
541 |
|
if (isset($val['category']) === true |
542 |
|
&& $val['category'] === 'portal' |
543 |
|
&& isset($val['type']) === true |
544 |
|
&& ($val['type'] === 'notification_recepisse' |
545 |
|
|| $val['type'] === 'notification_instruction' |
546 |
|
|| $val['type'] === 'notification_decision')) { |
547 |
|
// |
548 |
|
if (isset($this->valF['state']) === true |
549 |
|
&& $this->valF['state'] !== $this->getVal('state') |
550 |
|
&& $this->valF['state'] !== self::STATUS_CANCELED) { |
551 |
|
// |
552 |
|
$inst_in = $this->f->get_inst__om_dbform(array( |
553 |
|
"obj" => "instruction_notification", |
554 |
|
"idx" => $val['object_id'], |
555 |
)); |
)); |
556 |
if(! $dossier = $inst_lien->get_id_dossier_from_external_uid( |
$valF_in = array(); |
557 |
$json_payload['external_uids']['dossier'])){ |
foreach ($inst_in->champs as $champ) { |
558 |
$error_msg = sprintf( |
$valF_in[$champ] = $inst_in->getVal($champ); |
559 |
__("Aucune correspondance de dossier pour l'external_uid.dossier '%s'."), |
} |
560 |
$json_payload['external_uids']['dossier']); |
// Par défaut la date d'envoi et la date de premier accès sur |
561 |
$this->addToLog(__METHOD__."() : erreur : $error_msg", DEBUG_MODE); |
// la notification ne sont pas renseignées |
562 |
$this->addToMessage($error_msg); |
$valF_in['date_envoi'] = null; |
563 |
$this->correct = false; |
$valF_in['date_premier_acces'] = null; |
564 |
|
// Lorsque la tâche est correctement traitée |
565 |
|
if ($this->valF['state'] === self::STATUS_DONE) { |
566 |
|
// |
567 |
|
$valF_in['statut'] = __("envoyé"); |
568 |
|
$valF_in['commentaire'] = __("Notification traitée"); |
569 |
|
$valF_in['date_envoi'] = date('d/m/Y H:i:s'); |
570 |
|
// Si l'instruction possède un document lié, alors ses dates |
571 |
|
// de suivi sont mises à jour |
572 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
573 |
|
"obj" => "instruction", |
574 |
|
"idx" => $inst_in->getVal('instruction'), |
575 |
|
)); |
576 |
|
if ($inst_instruction->has_an_edition() === true) { |
577 |
|
$valF_instruction = array(); |
578 |
|
foreach ($inst_instruction->champs as $champ) { |
579 |
|
$valF_instruction[$champ] = $inst_instruction->getVal($champ); |
580 |
|
} |
581 |
|
$valF_instruction['date_envoi_rar'] = date('d/m/Y'); |
582 |
|
$valF_instruction['date_retour_rar'] = date('d/m/Y', strtotime('now + 1 day')); |
583 |
|
$inst_instruction->setParameter('maj', 1); |
584 |
|
$update_instruction = $inst_instruction->modifier($valF_instruction); |
585 |
|
if ($update_instruction === false) { |
586 |
|
$this->addToLog(__METHOD__."(): ".$inst_instruction->msg, DEBUG_MODE); |
587 |
|
return false; |
588 |
|
} |
589 |
|
} |
590 |
|
} |
591 |
|
// En cas d'erreur lors du traitement de la task |
592 |
|
if ($this->valF['state'] === self::STATUS_ERROR) { |
593 |
|
$valF_in['statut'] = __("échec"); |
594 |
|
$valF_in['commentaire'] = __("Le traitement de la notification a échoué"); |
595 |
|
} |
596 |
|
// Met à jour la notification |
597 |
|
$inst_in->setParameter('maj', 1); |
598 |
|
$update_in = $inst_in->modifier($valF_in); |
599 |
|
if ($update_in === false) { |
600 |
|
$this->addToLog(__METHOD__."(): ".$inst_in->msg, DEBUG_MODE); |
601 |
return false; |
return false; |
602 |
} |
} |
603 |
$this->valF["dossier"] = $dossier; |
} |
604 |
}*/ |
} |
605 |
|
|
606 |
|
// Envoi au contrôle de légalité |
607 |
|
// En cas de changement de l'état de la tâche envoi_CL, alors le suivi |
608 |
|
// des dates de l'instruction est effectué |
609 |
|
if ($val['type'] === 'envoi_CL' |
610 |
|
&& isset($this->valF['state']) === true |
611 |
|
&& $this->valF['state'] === self::STATUS_DONE) { |
612 |
|
// |
613 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
614 |
|
"obj" => "instruction", |
615 |
|
"idx" => $this->getVal('object_id'), |
616 |
|
)); |
617 |
|
if ($inst_instruction->has_an_edition() === true) { |
618 |
|
$valF_instruction = array(); |
619 |
|
foreach ($inst_instruction->champs as $champ) { |
620 |
|
$valF_instruction[$champ] = $inst_instruction->getVal($champ); |
621 |
|
} |
622 |
|
} |
623 |
|
$valF_instruction['date_envoi_controle_legalite'] = date("Y-m-d"); |
624 |
|
$inst_instruction->setParameter('maj', 1); |
625 |
|
$update_instruction = $inst_instruction->modifier($valF_instruction); |
626 |
|
if ($update_instruction === false) { |
627 |
|
$this->addToLog(__METHOD__."(): ".$inst_instruction->msg, DEBUG_MODE); |
628 |
|
return false; |
629 |
|
} |
630 |
} |
} |
631 |
|
|
632 |
|
// |
633 |
|
return true; |
634 |
} |
} |
635 |
|
|
636 |
/** |
/** |
645 |
|
|
646 |
// Vérifie si la task doit être ajoutée en fonction du mode de l'application, |
// Vérifie si la task doit être ajoutée en fonction du mode de l'application, |
647 |
// seulement pour les tasks output |
// seulement pour les tasks output |
648 |
$task_types_si = array( |
$task_types_si = self::TASK_TYPE_SI; |
649 |
'creation_DA', |
$task_types_sc = self::TASK_TYPE_SC; |
|
'creation_DI', |
|
|
'depot_DI', |
|
|
'modification_DI', |
|
|
'qualification_DI', |
|
|
'decision_DI', |
|
|
'incompletude_DI', |
|
|
'completude_DI', |
|
|
'ajout_piece', |
|
|
'add_piece', |
|
|
); |
|
|
$task_types_sc = array( |
|
|
'create_DI_for_consultation', |
|
|
'avis_consultation', |
|
|
'pec_metier_consultation', |
|
|
); |
|
650 |
$stream = isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output'; |
$stream = isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output'; |
651 |
if ($stream === 'output' |
if ($stream === 'output' |
652 |
&& isset($params['val']['type']) === true |
&& isset($params['val']['type']) === true |
663 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
664 |
} |
} |
665 |
|
|
666 |
|
// |
667 |
$timestamp_log = json_encode(array( |
$timestamp_log = json_encode(array( |
668 |
'creation_date' => date('Y-m-d H:i:s'), |
'creation_date' => date('Y-m-d H:i:s'), |
669 |
)); |
)); |
670 |
|
|
671 |
|
// |
672 |
|
$category = isset($params['val']['category']) === true ? $params['val']['category'] : $this->category; |
673 |
|
|
674 |
// Si la tâche est de type ajout_piece et de stream input alors on ajoute le fichier |
// Si la tâche est de type ajout_piece et de stream input alors on ajoute le fichier |
675 |
// et on ajoute l'uid dans le champ json_payload avant l'ajout de la tâche |
// et on ajoute l'uid dans le champ json_payload avant l'ajout de la tâche |
676 |
if (isset($params['val']['type']) |
if (isset($params['val']['type']) |
677 |
&& $params['val']['type'] == "add_piece" |
&& ($params['val']['type'] == "add_piece" || $params['val']['type'] == "avis_consultation") |
678 |
&& isset($params['val']['stream']) |
&& isset($params['val']['stream']) |
679 |
&& $params['val']['stream'] == "input" ) { |
&& $params['val']['stream'] == "input" ) { |
680 |
// |
// |
681 |
$json_payload = json_decode($params['val']['json_payload'], true); |
$json_payload = json_decode($params['val']['json_payload'], true); |
682 |
$document_numerise = $json_payload['document_numerise']; |
if (json_last_error() !== JSON_ERROR_NONE) { |
683 |
$file_content = base64_decode($document_numerise["file_content"]); |
$this->addToMessage(__("Le contenu JSON de la tâche n'est pas valide.")); |
|
if ($file_content === false){ |
|
|
$this->addToMessage(__("Le contenu du fichier lié à la tâche n'a pas pu etre recupere.")); |
|
684 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
685 |
} |
} |
686 |
$metadata = array( |
if (isset($json_payload['document_numerise']) === true |
687 |
"filename" => $document_numerise['nom_fichier'], |
&& empty($json_payload['document_numerise']) === false) { |
688 |
"size" => strlen($file_content), |
// |
689 |
"mimetype" => $document_numerise['file_content_type'], |
$document_numerise = $json_payload['document_numerise']; |
690 |
"date_creation" => $document_numerise['date_creation'], |
$file_content = base64_decode($document_numerise["file_content"]); |
691 |
); |
if ($file_content === false){ |
692 |
$uid_fichier = $this->f->storage->create($file_content, $metadata, "from_content"); |
$this->addToMessage(__("Le contenu du fichier lié à la tâche n'a pas pu etre recupere.")); |
693 |
if ($uid_fichier === OP_FAILURE) { |
return $this->end_treatment(__METHOD__, false); |
694 |
$this->addToMessage(__("Erreur lors de la creation du fichier lié à la tâche.")); |
} |
695 |
return $this->end_treatment(__METHOD__, false); |
$metadata = array( |
696 |
|
"filename" => $document_numerise['nom_fichier'], |
697 |
|
"size" => strlen($file_content), |
698 |
|
"mimetype" => $document_numerise['file_content_type'], |
699 |
|
"date_creation" => isset($document_numerise['date_creation']) === true ? $document_numerise['date_creation'] : date("Y-m-d"), |
700 |
|
); |
701 |
|
$uid_fichier = $this->f->storage->create($file_content, $metadata, "from_content", "task.uid_fichier"); |
702 |
|
if ($uid_fichier === OP_FAILURE) { |
703 |
|
$this->addToMessage(__("Erreur lors de la creation du fichier lié à la tâche.")); |
704 |
|
return $this->end_treatment(__METHOD__, false); |
705 |
|
} |
706 |
|
$json_payload["document_numerise"]["uid"] = $uid_fichier; |
707 |
|
// Le fichier a été ajouté nous n'avons plus besoin du champ file_content dans la payload |
708 |
|
unset($json_payload["document_numerise"]["file_content"]); |
709 |
|
$params['val']['json_payload'] = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
710 |
} |
} |
|
$json_payload["document_numerise"]["uid"] = $uid_fichier; |
|
|
// Le fichier a été ajouté nous n'avons plus besoin du champ file_content dans la payload |
|
|
unset($json_payload["document_numerise"]["file_content"]); |
|
|
$params['val']['json_payload'] = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
|
711 |
} |
} |
712 |
|
|
713 |
// Mise à jour du DI |
// Mise à jour du DI |
720 |
'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '', |
'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '', |
721 |
'stream' => $stream, |
'stream' => $stream, |
722 |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
723 |
|
'category' => $category, |
724 |
); |
); |
725 |
|
|
726 |
// tâche sortante |
// tâche sortante |
727 |
if($valF["stream"] == "output"){ |
if ($valF["stream"] == "output" |
728 |
|
&& $valF['type'] !== 'notification_recepisse' |
729 |
|
&& $valF['type'] !== 'notification_instruction' |
730 |
|
&& $valF['type'] !== 'notification_decision') { |
731 |
|
|
732 |
// TODO expliquer ce code |
// TODO expliquer ce code |
733 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
$task_exists = $this->task_exists($valF['type'], $valF['object_id'], $valF['dossier']); |
734 |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
735 |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
736 |
} |
} |
737 |
|
if ($valF['type'] === 'modification_DA' && $task_exists === false) { |
738 |
|
$task_exists = $this->task_exists('creation_DA', $valF['object_id']); |
739 |
|
} |
740 |
|
if ($valF['type'] === 'ajout_piece') { |
741 |
|
$task_exists = $this->task_exists('ajout_piece', $valF['object_id']); |
742 |
|
} |
743 |
|
if ($valF['type'] === 'creation_consultation') { |
744 |
|
$task_exists = $this->task_exists('creation_consultation', $valF['object_id']); |
745 |
|
} |
746 |
if ($task_exists !== false) { |
if ($task_exists !== false) { |
747 |
$inst_task = $this->f->get_inst__om_dbform(array( |
$inst_task = $this->f->get_inst__om_dbform(array( |
748 |
"obj" => "task", |
"obj" => "task", |
756 |
'val' => array( |
'val' => array( |
757 |
'state' => $update_state, |
'state' => $update_state, |
758 |
), |
), |
759 |
|
'object_id' => $valF['object_id'], |
760 |
); |
); |
761 |
return $inst_task->update_task($update_params); |
return $inst_task->update_task($update_params); |
762 |
} |
} |
763 |
} |
} |
|
|
|
764 |
$add = $this->ajouter($valF); |
$add = $this->ajouter($valF); |
765 |
$this->addToLog(__METHOD__."(): retour de l'ajout de tâche: ".var_export($add, true), VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): retour de l'ajout de tâche: ".var_export($add, true), VERBOSE_MODE); |
766 |
if ($add === false) { |
if ($add === false) { |
784 |
$this->addToLog(__METHOD__."(): erreur timestamp log", DEBUG_MODE); |
$this->addToLog(__METHOD__."(): erreur timestamp log", DEBUG_MODE); |
785 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
786 |
} |
} |
787 |
|
// Vérification des object_id précédent en cas de tentative d'appliquer |
788 |
|
// l'état CANCELED sur la tâche |
789 |
|
if (isset($params['val']['state']) === true |
790 |
|
&& $params['val']['state'] === self::STATUS_CANCELED) { |
791 |
|
// Récupération du journal d'activité de la tâche sous forme de tableau |
792 |
|
// trié par ordre décroissant |
793 |
|
$log = $timestamp_log; |
794 |
|
unset($log['creation_date']); |
795 |
|
krsort($log); |
796 |
|
// Pour chaque entrée dans le journal d'activité de la tâche : |
797 |
|
// - vérification de la présence de l'object_id précédent |
798 |
|
// - vérification que l'object_id précédent existe toujours dans la base de données |
799 |
|
// - l'object_id est mise à jour avec la valeur de l'object_id précédent |
800 |
|
// - le state n'est pas modifié |
801 |
|
// - sortie du traitement dès que le premier object_id précédent existant est trouvé |
802 |
|
// - si aucun object_id précédent existant n'est trouvé alors ni le state, ni l'object_id n'est modifiés |
803 |
|
foreach ($log as $key => $value) { |
804 |
|
// |
805 |
|
if (isset($value['prev_object_id']) === true |
806 |
|
&& $this->getVal('object_id') !== $value['prev_object_id']) { |
807 |
|
// Récupère la liste des tables potentielles pour un type de tâche |
808 |
|
$tables = $this->get_tables_by_task_type($this->getVal('type'), $this->getVal('stream')); |
809 |
|
foreach ($tables as $table) { |
810 |
|
// Vérifie s'il y a un ou aucun résultat |
811 |
|
$query = sprintf(' |
812 |
|
SELECT COUNT(%2$s) |
813 |
|
FROM %1$s%2$s |
814 |
|
WHERE %2$s = \'%3$s\' |
815 |
|
', |
816 |
|
DB_PREFIXE, |
817 |
|
$table, |
818 |
|
$value['prev_object_id'] |
819 |
|
); |
820 |
|
$res = $this->f->get_one_result_from_db_query($query, true); |
821 |
|
if ($res['code'] === 'KO') { |
822 |
|
return $this->end_treatment(__METHOD__, false); |
823 |
|
} |
824 |
|
// Affectation des valeurs et sortie de la boucle |
825 |
|
if ($res['result'] == '1') { |
826 |
|
$params['object_id'] = $value['prev_object_id']; |
827 |
|
$params['val']['state'] = $this->getVal('state'); |
828 |
|
break; |
829 |
|
} |
830 |
|
} |
831 |
|
// Sortie de la boucle si les valeurs sont affectées |
832 |
|
if (isset($params['object_id']) === true |
833 |
|
&& $params['object_id'] === $value['prev_object_id']) { |
834 |
|
// |
835 |
|
break; |
836 |
|
} |
837 |
|
} |
838 |
|
} |
839 |
|
} |
840 |
|
// Mise à jour du journal d'activité de la tâche |
841 |
array_push($timestamp_log, array( |
array_push($timestamp_log, array( |
842 |
'modification_date' => date('Y-m-d H:i:s'), |
'modification_date' => date('Y-m-d H:i:s'), |
843 |
'state' => $params['val']['state'], |
'state' => $params['val']['state'], |
844 |
'prev_state' => $this->getVal('state'), |
'prev_state' => $this->getVal('state'), |
845 |
|
'object_id' => isset($params['object_id']) == true ? $params['object_id'] : $this->getVal('object_id'), |
846 |
|
'prev_object_id' => $this->getVal('object_id'), |
847 |
)); |
)); |
848 |
$timestamp_log = json_encode($timestamp_log); |
$timestamp_log = json_encode($timestamp_log); |
849 |
|
// Mise à jour de la tâche |
850 |
$valF = array( |
$valF = array( |
851 |
'task' => $this->getVal($this->clePrimaire), |
'task' => $this->getVal($this->clePrimaire), |
852 |
'type' => $this->getVal('type'), |
'type' => $this->getVal('type'), |
853 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
854 |
'state' => $params['val']['state'], |
'state' => $params['val']['state'], |
855 |
'object_id' => $this->getVal('object_id'), |
'object_id' => isset($params['object_id']) == true ? $params['object_id'] : $this->getVal('object_id'), |
856 |
'stream' => $this->getVal('stream'), |
'stream' => $this->getVal('stream'), |
857 |
'dossier' => $this->getVal('dossier'), |
'dossier' => $this->getVal('dossier'), |
858 |
'json_payload' => $this->getVal('json_payload'), |
'json_payload' => $this->getVal('json_payload'), |
859 |
|
'category' => $this->getVal('category'), |
860 |
); |
); |
861 |
$update = $this->modifier($valF); |
$update = $this->modifier($valF); |
862 |
if ($update === false) { |
if ($update === false) { |
908 |
if ($this->f->get_submitted_get_value('state') !== null |
if ($this->f->get_submitted_get_value('state') !== null |
909 |
&& $this->f->get_submitted_get_value('state') !== '') { |
&& $this->f->get_submitted_get_value('state') !== '') { |
910 |
// |
// |
911 |
$where = sprintf(' WHERE state = \'%s\' ', $this->f->get_submitted_get_value('state')); |
$where_or_and = 'WHERE'; |
912 |
|
if ($where !== '') { |
913 |
|
$where_or_and = 'AND'; |
914 |
|
} |
915 |
|
$where .= sprintf(' %s state = \'%s\' ', $where_or_and, $this->f->get_submitted_get_value('state')); |
916 |
|
} |
917 |
|
if ($this->f->get_submitted_get_value('category') !== null |
918 |
|
&& $this->f->get_submitted_get_value('category') !== '') { |
919 |
|
// |
920 |
|
$where_or_and = 'WHERE'; |
921 |
|
if ($where !== '') { |
922 |
|
$where_or_and = 'AND'; |
923 |
|
} |
924 |
|
$where .= sprintf(' %s category = \'%s\' ', $where_or_and, $this->f->get_submitted_get_value('category')); |
925 |
} |
} |
926 |
$query = sprintf(' |
$query = sprintf(' |
927 |
SELECT |
SELECT |
941 |
foreach ($res['result'] as $task) { |
foreach ($res['result'] as $task) { |
942 |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
943 |
$task['dossier'] = $task['dossier']; |
$task['dossier'] = $task['dossier']; |
944 |
if ($this->get_lien_objet_by_type($task['type']) === 'document_numerise') { |
if ($task['type'] === 'ajout_piece') { |
945 |
$val_dn = $this->get_document_numerise_data($task['object_id']); |
$val_dn = $this->get_document_numerise_data($task['object_id']); |
946 |
} |
} |
947 |
if ($task['stream'] === 'output') { |
if ($task['stream'] === 'output') { |
958 |
"obj" => "dossier", |
"obj" => "dossier", |
959 |
"idx" => $dossier, |
"idx" => $dossier, |
960 |
)); |
)); |
961 |
|
if (empty($inst_di->val) === true) { |
962 |
|
return $val_di; |
963 |
|
} |
964 |
$val_di = $inst_di->get_json_data(); |
$val_di = $inst_di->get_json_data(); |
965 |
if ($val_di['dossier_instruction_type_code'] === 'T') { |
if ($val_di['dossier_instruction_type_code'] === 'T') { |
966 |
$val_di['date_decision_transfert'] = $val_di['date_decision']; |
$val_di['date_decision_transfert'] = $val_di['date_decision']; |
1091 |
return $val_dt; |
return $val_dt; |
1092 |
} |
} |
1093 |
|
|
1094 |
|
/** |
1095 |
|
* Récupère la liste des objets distincts existants dans la table des liens |
1096 |
|
* entre identifiants internes et identifiants externes. |
1097 |
|
* |
1098 |
|
* @return array |
1099 |
|
*/ |
1100 |
|
protected function get_list_distinct_objects_external_link() { |
1101 |
|
$query = sprintf(' |
1102 |
|
SELECT |
1103 |
|
DISTINCT(object) |
1104 |
|
FROM %1$slien_id_interne_uid_externe |
1105 |
|
ORDER BY object ASC |
1106 |
|
', |
1107 |
|
DB_PREFIXE |
1108 |
|
); |
1109 |
|
$res = $this->f->get_all_results_from_db_query($query, true); |
1110 |
|
if ($res['code'] === 'KO') { |
1111 |
|
return array(); |
1112 |
|
} |
1113 |
|
$result = array(); |
1114 |
|
foreach ($res['result'] as $object) { |
1115 |
|
$result[] = $object['object']; |
1116 |
|
} |
1117 |
|
return $result; |
1118 |
|
} |
1119 |
|
|
1120 |
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
1121 |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
1122 |
"obj" => "lien_id_interne_uid_externe", |
"obj" => "lien_id_interne_uid_externe", |
1128 |
return $inst_external_uid->getVal('external_uid'); |
return $inst_external_uid->getVal('external_uid'); |
1129 |
} |
} |
1130 |
|
|
1131 |
protected function get_all_external_uids($fk_idx) { |
protected function get_all_external_uids($fk_idx, $link_objects = array()) { |
1132 |
$link_objects = array( |
if (count($link_objects) == 0) { |
1133 |
'dossier_autorisation', |
$link_objects = $this->get_list_distinct_objects_external_link(); |
1134 |
'dossier', |
} |
|
'consultation', |
|
|
'document_numerise', |
|
|
); |
|
1135 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1136 |
foreach ($link_objects as $link_object) { |
foreach ($link_objects as $link_object) { |
1137 |
$external_uid = $this->get_external_uid($fk_idx, $link_object); |
$external_uid = $this->get_external_uid($fk_idx, $link_object); |
1142 |
return $val_external_uid; |
return $val_external_uid; |
1143 |
} |
} |
1144 |
|
|
1145 |
protected function get_demandeurs_data(string $dossier) { |
protected function get_demandeurs_data($dossier) { |
1146 |
$val_demandeur = array(); |
$val_demandeur = array(); |
1147 |
|
if ($dossier === null) { |
1148 |
|
return $val_demandeur; |
1149 |
|
} |
1150 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
1151 |
"obj" => "dossier", |
"obj" => "dossier", |
1152 |
"idx" => $dossier, |
"idx" => $dossier, |
1177 |
return $val_architecte; |
return $val_architecte; |
1178 |
} |
} |
1179 |
|
|
1180 |
protected function get_instruction_data(string $dossier, $type = 'decision', $extra_params = array()) { |
protected function get_instruction_data($dossier, $type = 'decision', $extra_params = array()) { |
1181 |
$val_instruction = null; |
$val_instruction = null; |
1182 |
|
if ($dossier === null) { |
1183 |
|
return $val_instruction; |
1184 |
|
} |
1185 |
$instruction_with_doc = null; |
$instruction_with_doc = null; |
1186 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
1187 |
"obj" => "dossier", |
"obj" => "dossier", |
1241 |
return $val_instruction; |
return $val_instruction; |
1242 |
} |
} |
1243 |
|
|
1244 |
|
/** |
1245 |
|
* Récupère les informations |
1246 |
|
*/ |
1247 |
|
protected function get_instruction_notification_data($category, $type = '', $extra_params = array()) { |
1248 |
|
$val_in = null; |
1249 |
|
|
1250 |
|
$idx = null; |
1251 |
|
if ($type === 'with-id') { |
1252 |
|
$idx = $extra_params['with-id']; |
1253 |
|
} |
1254 |
|
|
1255 |
|
// récupére les données à intégrer à la payload |
1256 |
|
$inst_in = $this->f->get_inst__om_dbform(array( |
1257 |
|
"obj" => "instruction_notification", |
1258 |
|
"idx" => $idx, |
1259 |
|
)); |
1260 |
|
if (count($inst_in->val) > 0) { |
1261 |
|
$val_in = $inst_in->get_json_data(); |
1262 |
|
|
1263 |
|
$val_in['parametre_courriel_type_titre'] = ''; |
1264 |
|
$val_in['parametre_courriel_type_message'] = ''; |
1265 |
|
// Récupération du message et du titre |
1266 |
|
if ($category === 'mail') { |
1267 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
1268 |
|
"obj" => "instruction", |
1269 |
|
"idx" => $inst_in->getVal('instruction'), |
1270 |
|
)); |
1271 |
|
$collectivite_id = $inst_instruction->get_dossier_instruction_om_collectivite($inst_instruction->getVal('dossier')); |
1272 |
|
$phrase_type_notification = array(); |
1273 |
|
$phrase_type_notification = $this->f->get_notification_parametre_courriel_type($collectivite_id); |
1274 |
|
$val_in['parametre_courriel_type_titre'] = $phrase_type_notification['parametre_courriel_type_titre']; |
1275 |
|
$val_in['parametre_courriel_type_message'] = $phrase_type_notification['parametre_courriel_type_message']; |
1276 |
|
} |
1277 |
|
|
1278 |
|
// Récupération des liens vers les documents et de l'id de l'instruction |
1279 |
|
// de l'annexe |
1280 |
|
$infoDocNotif = $inst_in->getInfosDocumentsNotif($inst_in->getVal($inst_in->clePrimaire)); |
1281 |
|
$val_in['lien_telechargement_document'] = $infoDocNotif['document']['lien']; |
1282 |
|
$val_in['lien_telechargement_annexe'] = $infoDocNotif['annexe']['lien']; |
1283 |
|
$val_in['instruction_annexe'] = $infoDocNotif['annexe']['id_instruction']; |
1284 |
|
} |
1285 |
|
|
1286 |
|
return $val_in; |
1287 |
|
} |
1288 |
|
|
1289 |
protected function sort_instruction_data(array $values, array $res) { |
protected function sort_instruction_data(array $values, array $res) { |
1290 |
$fields = array( |
$fields = array( |
1291 |
"date_evenement", |
"date_evenement", |
1299 |
"om_fichier_instruction", |
"om_fichier_instruction", |
1300 |
"tacite", |
"tacite", |
1301 |
"lettretype", |
"lettretype", |
1302 |
|
"commentaire", |
1303 |
|
"complement_om_html", |
1304 |
); |
); |
1305 |
foreach ($values as $key => $value) { |
foreach ($values as $key => $value) { |
1306 |
if (in_array($key, $fields) === true) { |
if (in_array($key, $fields) === true) { |
1319 |
return $res; |
return $res; |
1320 |
} |
} |
1321 |
|
|
1322 |
|
/** |
1323 |
|
* Permet de définir si l'instruction passée en paramètre est une instruction |
1324 |
|
* récépissé d'une demande et si la demande en question a générée un dossier d'instruction. |
1325 |
|
* |
1326 |
|
* @param integer $instruction Identifiant de l'instruction |
1327 |
|
* @return boolean |
1328 |
|
*/ |
1329 |
|
protected function is_demande_instruction_recepisse_without_dossier($instruction) { |
1330 |
|
if ($instruction === null) { |
1331 |
|
return false; |
1332 |
|
} |
1333 |
|
$query = sprintf(' |
1334 |
|
SELECT demande_type.dossier_instruction_type |
1335 |
|
FROM %1$sdemande |
1336 |
|
INNER JOIN %1$sdemande_type ON demande.demande_type = demande_type.demande_type |
1337 |
|
WHERE demande.instruction_recepisse = %2$s |
1338 |
|
', |
1339 |
|
DB_PREFIXE, |
1340 |
|
$instruction |
1341 |
|
); |
1342 |
|
$res = $this->f->get_one_result_from_db_query( |
1343 |
|
$query, |
1344 |
|
true |
1345 |
|
); |
1346 |
|
if ($res['code'] === 'KO') { |
1347 |
|
return null; |
1348 |
|
} |
1349 |
|
if ($res['result'] === '') { |
1350 |
|
return true; |
1351 |
|
} |
1352 |
|
return false; |
1353 |
|
} |
1354 |
|
|
1355 |
protected function get_document_numerise_data(string $dn) { |
protected function get_document_numerise_data(string $dn) { |
1356 |
$val_dn = array(); |
$val_dn = array(); |
1357 |
$inst_dn = $this->f->get_inst__om_dbform(array( |
$inst_dn = $this->f->get_inst__om_dbform(array( |
1391 |
)); |
)); |
1392 |
$ad = $inst_di->getVal('avis_decision'); |
$ad = $inst_di->getVal('avis_decision'); |
1393 |
$val_ad = array(); |
$val_ad = array(); |
1394 |
$inst_ad = $this->f->get_inst__om_dbform(array( |
if ($ad !== null) { |
1395 |
"obj" => "avis_decision", |
$inst_ad = $this->f->get_inst__om_dbform(array( |
1396 |
"idx" => $ad, |
"obj" => "avis_decision", |
1397 |
)); |
"idx" => $ad, |
1398 |
$val_ad = $inst_ad->get_json_data(); |
)); |
1399 |
$val_ad['txAvis'] = "Voir document joint"; |
$val_ad = $inst_ad->get_json_data(); |
1400 |
if (isset($val_ad['tacite']) === true |
$val_ad['txAvis'] = "Voir document joint"; |
1401 |
&& $val_ad['tacite'] === 't') { |
if (isset($val_ad['tacite']) === true |
1402 |
// |
&& $val_ad['tacite'] === 't') { |
1403 |
$val_ad['txAvis'] = "Sans objet"; |
// |
1404 |
|
$val_ad['txAvis'] = "Sans objet"; |
1405 |
|
} |
1406 |
} |
} |
1407 |
return $val_ad; |
return $val_ad; |
1408 |
} |
} |
1419 |
return $val_sa; |
return $val_sa; |
1420 |
} |
} |
1421 |
|
|
1422 |
|
// XXX WIP |
1423 |
|
protected function get_consultation_data(string $consultation) { |
1424 |
|
$val_consultation = array(); |
1425 |
|
$inst_consultation = $this->f->get_inst__om_dbform(array( |
1426 |
|
"obj" => "consultation", |
1427 |
|
"idx" => $consultation, |
1428 |
|
)); |
1429 |
|
$val_consultation = $inst_consultation->get_json_data(); |
1430 |
|
if (isset($val_consultation['fichier']) === true |
1431 |
|
&& $val_consultation['fichier'] !== '') { |
1432 |
|
// |
1433 |
|
$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')); |
1434 |
|
} |
1435 |
|
if (isset($val_consultation['om_fichier_consultation']) === true |
1436 |
|
&& $val_consultation['om_fichier_consultation'] !== '') { |
1437 |
|
// |
1438 |
|
$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')); |
1439 |
|
} |
1440 |
|
return $val_consultation; |
1441 |
|
} |
1442 |
|
|
1443 |
|
// XXX WIP |
1444 |
|
protected function get_service_data(string $service) { |
1445 |
|
$val_service = array(); |
1446 |
|
$inst_service = $this->f->get_inst__om_dbform(array( |
1447 |
|
"obj" => "service", |
1448 |
|
"idx" => $service, |
1449 |
|
)); |
1450 |
|
$val_service = $inst_service->get_json_data(); |
1451 |
|
return $val_service; |
1452 |
|
} |
1453 |
|
|
1454 |
protected function view_form_json($in_field = false) { |
protected function view_form_json($in_field = false) { |
1455 |
// |
// |
1456 |
if ($this->f->get_submitted_post_value('valid') === null) { |
if ($this->f->get_submitted_post_value('valid') === null |
1457 |
|
&& $this->getVal('state') !== self::STATUS_CANCELED) { |
1458 |
// Liste des valeurs à afficher |
// Liste des valeurs à afficher |
1459 |
$val = array(); |
$val = array(); |
1460 |
// |
// |
1465 |
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
1466 |
$val['task'] = $val_task; |
$val['task'] = $val_task; |
1467 |
// |
// |
1468 |
if ($this->getVal('type') === 'creation_DA') { |
if ($this->getVal('type') === 'creation_DA' |
1469 |
|
|| $this->getVal('type') === 'modification_DA') { |
1470 |
|
// |
1471 |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
1472 |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
1473 |
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
1493 |
} |
} |
1494 |
// |
// |
1495 |
if ($this->getVal('type') === 'qualification_DI') { |
if ($this->getVal('type') === 'qualification_DI') { |
1496 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1497 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1498 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1499 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1513 |
if ($this->getVal('type') === 'decision_DI') { |
if ($this->getVal('type') === 'decision_DI') { |
1514 |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1515 |
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
1516 |
|
$val['instruction']['final'] = 't'; |
1517 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
1518 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
1519 |
|
} |
1520 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1521 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1522 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1547 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1548 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1549 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1550 |
$val_external_uid['consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'consultation'); |
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
1551 |
$val['external_uids'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1552 |
} |
} |
1553 |
// |
// |
1561 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1562 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1563 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1564 |
$val_external_uid['consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'consultation'); |
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
1565 |
|
$val['external_uids'] = $val_external_uid; |
1566 |
|
} |
1567 |
|
// XXX WIP |
1568 |
|
if ($this->getVal('type') === 'creation_consultation') { |
1569 |
|
// |
1570 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1571 |
|
$val['consultation'] = $this->get_consultation_data($this->getVal('object_id')); |
1572 |
|
$val['service'] = $this->get_service_data($val['consultation']['service']); |
1573 |
|
$val_external_uid = array(); |
1574 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1575 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1576 |
|
$val['external_uids'] = $val_external_uid; |
1577 |
|
} |
1578 |
|
// |
1579 |
|
if ($this->getVal('type') === 'envoi_CL') { |
1580 |
|
// |
1581 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1582 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1583 |
|
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($val['dossier']['dossier_autorisation']); |
1584 |
|
$val_external_uid = array(); |
1585 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1586 |
|
$val_external_uid['dossier'] = $this->get_external_uid($this->getVal('dossier'), 'dossier'); |
1587 |
|
$val_external_uid['decision'] = $this->get_external_uid($this->getVal('object_id'), 'instruction'); |
1588 |
|
if ($val_external_uid['decision'] === null) { |
1589 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
1590 |
|
"obj" => "instruction", |
1591 |
|
"idx" => $this->getVal('object_id'), |
1592 |
|
)); |
1593 |
|
$val_external_uid['decision'] = $this->get_external_uid($inst_instruction->get_related_instructions_next('retour_signature'), 'instruction'); |
1594 |
|
} |
1595 |
|
$val['external_uids'] = $val_external_uid; |
1596 |
|
} |
1597 |
|
// |
1598 |
|
if ($this->getVal('type') === 'notification_instruction' |
1599 |
|
|| $this->getVal('type') === 'notification_recepisse' |
1600 |
|
|| $this->getVal('type') === 'notification_decision') { |
1601 |
|
// |
1602 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1603 |
|
$dossier_id = isset($val['dossier']['dossier']) === true ? $val['dossier']['dossier'] : null; |
1604 |
|
$val['demandeur'] = $this->get_demandeurs_data($dossier_id); |
1605 |
|
$val['instruction_notification'] = $this->get_instruction_notification_data($this->getVal('category'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1606 |
|
$instruction_id = isset($val['instruction_notification']['instruction']) === true ? $val['instruction_notification']['instruction'] : null; |
1607 |
|
$instruction_annexe = isset($val['instruction_notification']['instruction_annexe']) === true ? $val['instruction_notification']['instruction_annexe'] : null; |
1608 |
|
$val['instruction'] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $instruction_id)); |
1609 |
|
// Précise qu'il s'agit d'une instruction final si l'instruction est liée à une |
1610 |
|
// demande dont le type ne génère pas de dossier |
1611 |
|
if ($this->is_demande_instruction_recepisse_without_dossier($instruction_id) === true) { |
1612 |
|
$val['instruction']['final'] = 't'; |
1613 |
|
} |
1614 |
|
// |
1615 |
|
if ($instruction_annexe != '') { |
1616 |
|
$val['instruction_annexe'] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $instruction_annexe)); |
1617 |
|
} |
1618 |
|
$val_external_uid = array(); |
1619 |
|
// Affiche l'identifiant externe lié à l'instruction si cette combinaison existe, sinon celui lié au dossier |
1620 |
|
$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'); |
1621 |
|
$val['external_uids'] = $val_external_uid; |
1622 |
|
} |
1623 |
|
// |
1624 |
|
if ($this->getVal('type') === 'prescription') { |
1625 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1626 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1627 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
1628 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
1629 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
1630 |
|
} |
1631 |
|
$val_external_uid = array(); |
1632 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1633 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1634 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
1635 |
$val['external_uids'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1636 |
} |
} |
1637 |
|
|
1639 |
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
1640 |
} else { |
} else { |
1641 |
// Liste des valeurs affichée en JSON |
// Liste des valeurs affichée en JSON |
1642 |
printf(json_encode($val, JSON_UNESCAPED_SLASHES)); |
echo(json_encode($val, JSON_UNESCAPED_SLASHES)); |
1643 |
} |
} |
1644 |
} |
} |
1645 |
} |
} |
1646 |
|
|
1647 |
function post_update_task() { |
function post_update_task() { |
1648 |
// Mise à jour des valeurs |
// Mise à jour des valeurs |
1649 |
// |
|
1650 |
$params = array( |
// Modification de l'état de la tâche |
1651 |
'val' => array( |
if ($this->f->get_submitted_post_value('state') !== null) { |
1652 |
'state' => $this->f->get_submitted_post_value('state') |
$params = array( |
1653 |
), |
'val' => array( |
1654 |
); |
'state' => $this->f->get_submitted_post_value('state') |
1655 |
$update = $this->update_task($params); |
), |
|
$message_class = "valid"; |
|
|
$message = $this->msg; |
|
|
if ($update === false) { |
|
|
$this->addToLog($this->msg, DEBUG_MODE); |
|
|
$message_class = "error"; |
|
|
$message = sprintf( |
|
|
'%s %s', |
|
|
__('Impossible de mettre à jour la tâche.'), |
|
|
__('Veuillez contacter votre administrateur.') |
|
|
); |
|
|
} |
|
|
$this->f->displayMessage($message_class, $message); |
|
|
// |
|
|
if ($this->f->get_submitted_post_value('external_uid') !== null |
|
|
&& $this->f->get_submitted_post_value('external_uid') != "") { |
|
|
$inst_lien = $this->f->get_inst__om_dbform(array( |
|
|
"obj" => "lien_id_interne_uid_externe", |
|
|
"idx" => ']', |
|
|
)); |
|
|
$valF = array( |
|
|
'lien_id_interne_uid_externe' => '', |
|
|
'object' => $this->get_lien_objet_by_type($this->getVal('type')), |
|
|
'object_id' => $this->getVal('object_id'), |
|
|
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
|
1656 |
); |
); |
1657 |
$add = $inst_lien->ajouter($valF); |
$update = $this->update_task($params); |
1658 |
$message_class = "valid"; |
$message_class = "valid"; |
1659 |
$message = $inst_lien->msg; |
$message = $this->msg; |
1660 |
if ($add === false) { |
if ($update === false) { |
1661 |
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
$this->addToLog($this->msg, DEBUG_MODE); |
1662 |
$message_class = "error"; |
$message_class = "error"; |
1663 |
$message = sprintf( |
$message = sprintf( |
1664 |
'%s %s', |
'%s %s', |
1665 |
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
__('Impossible de mettre à jour la tâche.'), |
1666 |
__('Veuillez contacter votre administrateur.') |
__('Veuillez contacter votre administrateur.') |
1667 |
); |
); |
1668 |
} |
} |
1669 |
$this->f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
1670 |
} |
} |
1671 |
|
|
1672 |
|
// Sauvegarde de l'uid externe retourné |
1673 |
|
if ($this->f->get_submitted_post_value('external_uid') !== null) { |
1674 |
|
// |
1675 |
|
$objects = $this->get_objects_by_task_type($this->getVal('type'), $this->getVal('stream')); |
1676 |
|
foreach ($objects as $object) { |
1677 |
|
$inst_lien = $this->f->get_inst__om_dbform(array( |
1678 |
|
"obj" => "lien_id_interne_uid_externe", |
1679 |
|
"idx" => ']', |
1680 |
|
)); |
1681 |
|
$object_id = $this->getVal('object_id'); |
1682 |
|
// Dans le cas spécifique de la mise à jour d'une notification |
1683 |
|
// et de la création d'une liaison d'identifiant pour l'objet demande, |
1684 |
|
// l'identifiant de l'objet n'est plus celui de la notification |
1685 |
|
// d'instruction mais celui du dossier d'instruction |
1686 |
|
if ($object === 'demande' |
1687 |
|
&& ($this->getVal('type') === 'notification_recepisse' |
1688 |
|
|| $this->getVal('type') === 'notification_instruction' |
1689 |
|
|| $this->getVal('type') === 'notification_decision')) { |
1690 |
|
// |
1691 |
|
$object_id = $this->getVal('dossier'); |
1692 |
|
} |
1693 |
|
if ($inst_lien->is_exists($object, $object_id, $this->f->get_submitted_post_value('external_uid'), $this->getVal('dossier')) === false) { |
1694 |
|
$valF = array( |
1695 |
|
'lien_id_interne_uid_externe' => '', |
1696 |
|
'object' => $object, |
1697 |
|
'object_id' => $object_id, |
1698 |
|
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
1699 |
|
'dossier' => $this->getVal('dossier'), |
1700 |
|
'category' => $this->getVal('category'), |
1701 |
|
); |
1702 |
|
$add = $inst_lien->ajouter($valF); |
1703 |
|
$message_class = "valid"; |
1704 |
|
$message = $inst_lien->msg; |
1705 |
|
if ($add === false) { |
1706 |
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
1707 |
|
$message_class = "error"; |
1708 |
|
$message = sprintf( |
1709 |
|
'%s %s', |
1710 |
|
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
1711 |
|
__('Veuillez contacter votre administrateur.') |
1712 |
|
); |
1713 |
|
} |
1714 |
|
$this->f->displayMessage($message_class, $message); |
1715 |
|
} |
1716 |
|
} |
1717 |
|
} |
1718 |
} |
} |
1719 |
|
|
1720 |
function post_add_task() { |
function post_add_task() { |
1724 |
'stream' => 'input', |
'stream' => 'input', |
1725 |
'json_payload' => html_entity_decode($this->f->get_submitted_post_value('json_payload')), |
'json_payload' => html_entity_decode($this->f->get_submitted_post_value('json_payload')), |
1726 |
'type' => $this->f->get_submitted_post_value('type'), |
'type' => $this->f->get_submitted_post_value('type'), |
1727 |
|
'category' => $this->f->get_submitted_post_value('category'), |
1728 |
) |
) |
1729 |
)); |
)); |
1730 |
$message = $this->msg; |
$message = sprintf( |
1731 |
|
__("Tâche %s ajoutée avec succès"), |
1732 |
|
$this->getVal($this->clePrimaire)). |
1733 |
|
'<br/><br/>'. |
1734 |
|
$this->msg; |
1735 |
$message_class = "valid"; |
$message_class = "valid"; |
1736 |
if ($result === false){ |
if ($result === false){ |
1737 |
$this->addToLog($this->msg, DEBUG_MODE); |
$this->addToLog($this->msg, DEBUG_MODE); |
1745 |
$this->f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
1746 |
} |
} |
1747 |
|
|
|
function get_lien_objet_by_type($type) { |
|
|
// |
|
|
$objet = ''; |
|
|
if ($type === 'creation_DA') { |
|
|
$objet = 'dossier_autorisation'; |
|
|
} |
|
|
if ($type === 'creation_DI' |
|
|
|| $type === 'create_DI_for_consultation' |
|
|
|| $type === 'depot_DI' |
|
|
|| $type === 'modification_DI' |
|
|
|| $type === 'qualification_DI') { |
|
|
// |
|
|
$objet = 'dossier'; |
|
|
} |
|
|
if ($type === 'pec_metier_consultation' |
|
|
|| $type === 'decision_DI' |
|
|
|| $type === 'avis_consultation' |
|
|
|| $type === 'incompletude_DI' |
|
|
|| $type === 'completude_DI') { |
|
|
// |
|
|
$objet = 'instruction'; |
|
|
} |
|
|
if ($type === 'ajout_piece') { |
|
|
$objet = 'document_numerise'; |
|
|
} |
|
|
// La tâche entrante se nomme add_piece |
|
|
if ($type === 'add_piece') { |
|
|
$objet = 'piece'; |
|
|
} |
|
|
return $objet; |
|
|
} |
|
|
|
|
1748 |
function setLayout(&$form, $maj) { |
function setLayout(&$form, $maj) { |
1749 |
|
|
1750 |
// Récupération du mode de l'action |
// Récupération du mode de l'action |
1759 |
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
1760 |
} |
} |
1761 |
|
|
1762 |
|
/** |
1763 |
|
* [get_objects_by_task_type description] |
1764 |
|
* @param [type] $type [description] |
1765 |
|
* @return [type] [description] |
1766 |
|
*/ |
1767 |
|
function get_objects_by_task_type($type, $stream = 'all') { |
1768 |
|
$objects = array(); |
1769 |
|
if (in_array($type, array('creation_DA', 'modification_DA', )) === true) { |
1770 |
|
$objects = array('dossier_autorisation', ); |
1771 |
|
} |
1772 |
|
if (in_array($type, array('creation_DI', 'depot_DI', 'notification_DI', 'qualification_DI', )) === true) { |
1773 |
|
$objects = array('dossier', ); |
1774 |
|
} |
1775 |
|
if (in_array($type, array('create_DI_for_consultation', )) === true) { |
1776 |
|
$objects = array('dossier', 'dossier_consultation', ); |
1777 |
|
} |
1778 |
|
if (in_array($type, array('create_DI', )) === true |
1779 |
|
&& $stream === 'input') { |
1780 |
|
$objects = array('dossier', 'dossier_autorisation', 'demande', ); |
1781 |
|
} |
1782 |
|
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', 'envoi_CL', )) === true) { |
1783 |
|
$objects = array('instruction', ); |
1784 |
|
} |
1785 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
1786 |
|
&& $stream === 'output') { |
1787 |
|
$objects = array('pec_dossier_consultation', ); |
1788 |
|
} |
1789 |
|
if (in_array($type, array('avis_consultation', )) === true |
1790 |
|
&& $stream === 'output') { |
1791 |
|
$objects = array('avis_dossier_consultation', ); |
1792 |
|
} |
1793 |
|
if (in_array($type, array('prescription', )) === true |
1794 |
|
&& $stream === 'output') { |
1795 |
|
$objects = array('prescription', ); |
1796 |
|
} |
1797 |
|
if (in_array($type, array('ajout_piece', 'add_piece', )) === true) { |
1798 |
|
$objects = array('piece', ); |
1799 |
|
} |
1800 |
|
if (in_array($type, array('creation_consultation', )) === true) { |
1801 |
|
$objects = array('consultation', ); |
1802 |
|
} |
1803 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
1804 |
|
&& $stream === 'input') { |
1805 |
|
$objects = array('pec_metier_consultation', ); |
1806 |
|
} |
1807 |
|
if (in_array($type, array('avis_consultation', )) === true |
1808 |
|
&& $stream === 'input') { |
1809 |
|
$objects = array('avis_consultation', ); |
1810 |
|
} |
1811 |
|
if (in_array($type, array('create_message', )) === true |
1812 |
|
&& $stream === 'input') { |
1813 |
|
$objects = array('dossier_message', ); |
1814 |
|
} |
1815 |
|
if (in_array($type, array('notification_recepisse', 'notification_instruction', 'notification_decision' )) === true) { |
1816 |
|
$objects = array('instruction_notification', 'demande', ); |
1817 |
|
} |
1818 |
|
return $objects; |
1819 |
|
} |
1820 |
|
|
1821 |
|
/** |
1822 |
|
* Récupère les tables auxquelles pourrait être rattaché l'objet lié à la tâche, |
1823 |
|
* par rapport à son type. |
1824 |
|
* |
1825 |
|
* @param string $type Type de la tâche |
1826 |
|
* @param string $stream input ou output |
1827 |
|
* @return array |
1828 |
|
*/ |
1829 |
|
function get_tables_by_task_type($type, $stream = 'all') { |
1830 |
|
$tables = array(); |
1831 |
|
if (in_array($type, array('creation_DA', 'modification_DA', )) === true) { |
1832 |
|
$tables = array('dossier_autorisation', ); |
1833 |
|
} |
1834 |
|
if (in_array($type, array('creation_DI', 'depot_DI', )) === true) { |
1835 |
|
$tables = array('dossier', ); |
1836 |
|
} |
1837 |
|
if (in_array($type, array('qualification_DI', )) === true) { |
1838 |
|
$tables = array('instruction', ); |
1839 |
|
} |
1840 |
|
if (in_array($type, array('create_DI_for_consultation', )) === true) { |
1841 |
|
$tables = array('dossier', ); |
1842 |
|
} |
1843 |
|
if (in_array($type, array('create_DI', )) === true |
1844 |
|
&& $stream === 'input') { |
1845 |
|
$tables = array('dossier', 'dossier_autorisation', 'demande', ); |
1846 |
|
} |
1847 |
|
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
1848 |
|
$tables = array('instruction', ); |
1849 |
|
} |
1850 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
1851 |
|
&& $stream === 'output') { |
1852 |
|
$tables = array('instruction', ); |
1853 |
|
} |
1854 |
|
if (in_array($type, array('avis_consultation', )) === true |
1855 |
|
&& $stream === 'output') { |
1856 |
|
$tables = array('instruction', ); |
1857 |
|
} |
1858 |
|
if (in_array($type, array('prescription', )) === true |
1859 |
|
&& $stream === 'output') { |
1860 |
|
$tables = array('instruction', ); |
1861 |
|
} |
1862 |
|
if (in_array($type, array('ajout_piece', 'add_piece', )) === true) { |
1863 |
|
$tables = array('document_numerise', ); |
1864 |
|
} |
1865 |
|
if (in_array($type, array('creation_consultation', )) === true) { |
1866 |
|
$tables = array('consultation', ); |
1867 |
|
} |
1868 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
1869 |
|
&& $stream === 'input') { |
1870 |
|
$tables = array('consultation', ); |
1871 |
|
} |
1872 |
|
if (in_array($type, array('avis_consultation', )) === true |
1873 |
|
&& $stream === 'input') { |
1874 |
|
$tables = array('consultation', ); |
1875 |
|
} |
1876 |
|
if (in_array($type, array('create_message', )) === true |
1877 |
|
&& $stream === 'input') { |
1878 |
|
$tables = array('dossier_message', ); |
1879 |
|
} |
1880 |
|
if (in_array($type, array('notification_recepisse', 'notification_instruction', 'notification_decision' )) === true) { |
1881 |
|
$tables = array('instruction_notification', ); |
1882 |
|
} |
1883 |
|
return $tables; |
1884 |
|
} |
1885 |
|
|
1886 |
} |
} |