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 |
|
'notification_recepisse', |
36 |
|
'notification_instruction', |
37 |
|
'notification_decision', |
38 |
|
); |
39 |
|
|
40 |
|
/** |
41 |
|
* Liste des types de tâche concernant les services consultés |
42 |
|
*/ |
43 |
|
const TASK_TYPE_SC = array( |
44 |
|
'create_DI_for_consultation', |
45 |
|
'avis_consultation', |
46 |
|
'pec_metier_consultation', |
47 |
|
'create_message', |
48 |
|
'notification_recepisse', |
49 |
|
'notification_instruction', |
50 |
|
'notification_decision', |
51 |
|
'prescription', |
52 |
|
); |
53 |
|
|
54 |
|
/** |
55 |
|
* Catégorie de la tâche |
56 |
|
*/ |
57 |
|
var $category = 'platau'; |
58 |
|
|
59 |
/** |
/** |
60 |
* Définition des actions disponibles sur la classe. |
* Définition des actions disponibles sur la classe. |
83 |
|
|
84 |
public function setvalF($val = array()) { |
public function setvalF($val = array()) { |
85 |
|
|
86 |
// les guillets doubles sont remplacés automatiquement par des simples |
// // les guillets doubles sont remplacés automatiquement par des simples |
87 |
// dans core/om_formulaire.clasS.php::recupererPostvar() |
// // dans core/om_formulaire.clasS.php::recupererPostvar() |
88 |
// voir le ticket https://dev.atreal.fr/projets/openmairie/tracker/209 |
// // voir le ticket https://dev.atreal.fr/projets/openmairie/tracker/209 |
89 |
// ceci est un hack sale temporaire en attendant résolution du ticket |
// // ceci est un hack sale temporaire en attendant résolution du ticket |
90 |
foreach(array('json_payload', 'timestamp_log') as $key) { |
// foreach(array('json_payload', 'timestamp_log') as $key) { |
91 |
if (isset($val[$key]) && ! empty($val[$key]) && |
// if (isset($val[$key]) && ! empty($val[$key]) && |
92 |
isset($_POST[$key]) && ! empty($_POST[$key])) { |
// isset($_POST[$key]) && ! empty($_POST[$key])) { |
93 |
$submited_payload = $_POST[$key]; |
// $submited_payload = $_POST[$key]; |
94 |
if (! empty($submited_payload)) { |
// if (! empty($submited_payload)) { |
95 |
$new_payload = str_replace("'", '"', $val[$key]); |
// $new_payload = str_replace("'", '"', $val[$key]); |
96 |
if ($new_payload == $submited_payload || |
// if ($new_payload == $submited_payload || |
97 |
strpos($submited_payload, '"') === false) { |
// strpos($submited_payload, '"') === false) { |
98 |
$val[$key] = $new_payload; |
// $val[$key] = $new_payload; |
99 |
} |
// } |
100 |
else { |
// else { |
101 |
$error_msg = sprintf( |
// $error_msg = sprintf( |
102 |
__("La convertion des guillemets de la payload JSON '%s' ". |
// __("La convertion des guillemets de la payload JSON '%s' ". |
103 |
"n'est pas idempotente (courante: %s, postée: %s, convertie: %s)"), |
// "n'est pas idempotente (courante: %s, postée: %s, convertie: %s)"), |
104 |
$key, var_export($val[$key], true), var_export($submited_payload, true), |
// $key, var_export($val[$key], true), var_export($submited_payload, true), |
105 |
var_export($new_payload, true)); |
// var_export($new_payload, true)); |
106 |
$this->correct = false; |
// $this->correct = false; |
107 |
$this->addToMessage($error_msg); |
// $this->addToMessage($error_msg); |
108 |
$this->addToLog(__METHOD__."() erreur : $error_msg", DEBUG_MODE); |
// $this->addToLog(__METHOD__."() erreur : $error_msg", DEBUG_MODE); |
109 |
return false; |
// return false; |
110 |
} |
// } |
111 |
} |
// } |
112 |
} |
// } |
113 |
} |
// } |
114 |
|
|
115 |
parent::setvalF($val); |
parent::setvalF($val); |
116 |
|
|
117 |
|
// XXX Ancien code : permet de ne pas avoir d'erreru lors de la modification d'une task |
118 |
|
if (array_key_exists('timestamp_log', $val) === true) { |
119 |
|
$this->valF['timestamp_log'] = str_replace("'", '"', $val['timestamp_log']); |
120 |
|
} |
121 |
|
|
122 |
// récupération de l'ID de l'objet existant |
// récupération de l'ID de l'objet existant |
123 |
$id = property_exists($this, 'id') ? $this->id : null; |
$id = property_exists($this, 'id') ? $this->id : null; |
124 |
if(isset($val[$this->clePrimaire])) { |
if(isset($val[$this->clePrimaire])) { |
134 |
if (! isset($val['json_payload']) || empty($val['json_payload'])) { |
if (! isset($val['json_payload']) || empty($val['json_payload'])) { |
135 |
|
|
136 |
// récupère l'objet existant |
// récupère l'objet existant |
137 |
$existing = $this->f->findObjectById(get_class($this), $id); |
$existing = $this->f->findObjectById('task', $id); |
138 |
if (! empty($existing)) { |
if (! empty($existing)) { |
139 |
|
|
140 |
// récupère la payload de l'objet |
// récupère la payload de l'objet |
145 |
} |
} |
146 |
} |
} |
147 |
} |
} |
148 |
|
|
149 |
|
if (array_key_exists('category', $val) === false |
150 |
|
|| $this->valF['category'] === '' |
151 |
|
|| $this->valF['category'] === null) { |
152 |
|
// |
153 |
|
$this->valF['category'] = $this->category; |
154 |
|
} |
155 |
} |
} |
156 |
|
|
157 |
/** |
/** |
168 |
"stream", |
"stream", |
169 |
"json_payload", |
"json_payload", |
170 |
"timestamp_log", |
"timestamp_log", |
171 |
|
"category", |
172 |
); |
); |
173 |
} |
} |
174 |
|
|
178 |
// Récupération du mode de l'action |
// Récupération du mode de l'action |
179 |
$crud = $this->get_action_crud($maj); |
$crud = $this->get_action_crud($maj); |
180 |
|
|
181 |
|
// ALL |
182 |
|
$form->setType("category", "hidden"); |
183 |
|
|
184 |
// MODE CREER |
// MODE CREER |
185 |
if ($maj == 0 || $crud == 'create') { |
if ($maj == 0 || $crud == 'create') { |
186 |
$form->setType("state", "select"); |
$form->setType("state", "select"); |
208 |
if($maj < 2) { |
if($maj < 2) { |
209 |
|
|
210 |
$contenu = array(); |
$contenu = array(); |
211 |
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG') as $key) { |
foreach(array('DRAFT', 'NEW', 'PENDING', 'DONE', 'ERROR', 'DEBUG', 'ARCHIVED', 'CANCELED') as $key) { |
212 |
$const_name = 'STATUS_'.$key; |
$const_name = 'STATUS_'.$key; |
213 |
$const_value = constant("self::$const_name"); |
$const_value = constant("self::$const_name"); |
214 |
$contenu[0][] = $const_value; |
$contenu[0][] = $const_value; |
233 |
"idx" => $form->val['dossier'], |
"idx" => $form->val['dossier'], |
234 |
)); |
)); |
235 |
|
|
236 |
if($form->val['type'] == "creation_DA"){ |
if($form->val['type'] == "creation_DA" |
237 |
|
|| $form->val['type'] == "modification_DA"){ |
238 |
|
// |
239 |
$obj_link = 'dossier_autorisation'; |
$obj_link = 'dossier_autorisation'; |
240 |
} else { |
} else { |
241 |
$obj_link = 'dossier_instruction'; |
$obj_link = 'dossier_instruction'; |
337 |
$json_payload = json_decode($this->valF['json_payload'], true); |
$json_payload = json_decode($this->valF['json_payload'], true); |
338 |
|
|
339 |
// défini une liste de chemin de clés requises |
// défini une liste de chemin de clés requises |
340 |
$paths = array( |
$paths = array(); |
341 |
'external_uids/dossier' |
if ($this->valF['category'] === 'platau') { |
342 |
); |
$paths = array( |
343 |
|
'external_uids/dossier' |
344 |
|
); |
345 |
|
} |
346 |
|
|
347 |
// tâche de type création de DI/DA |
// tâche de type création de DI/DA |
348 |
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') { |
360 |
} |
} |
361 |
|
|
362 |
// présence d'un moyen d'identifier la collectivité/le service |
// présence d'un moyen d'identifier la collectivité/le service |
363 |
if (! isset($json_payload['dossier']['acteur']) && |
if (! isset($json_payload['external_uids']['acteur']) && |
364 |
! isset($json_payload['dossier']['om_collectivite'])) { |
! isset($json_payload['dossier']['om_collectivite'])) { |
365 |
$this->correct = false; |
$this->correct = false; |
366 |
$this->addToMessage(sprintf( |
$this->addToMessage(sprintf( |
367 |
__("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."), |
368 |
sprintf('<span class="bold">%s</span>', 'dossier/acteur'), |
sprintf('<span class="bold">%s</span>', 'external_uids/acteur'), |
369 |
sprintf('<span class="bold">%s</span>', 'dossier/om_collectivite'), |
sprintf('<span class="bold">%s</span>', 'dossier/om_collectivite'), |
370 |
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
sprintf('<span class="bold">%s</span>', $this->getLibFromField('json_payload')) |
371 |
)); |
)); |
408 |
return $ret && $this->correct; |
return $ret && $this->correct; |
409 |
} |
} |
410 |
|
|
411 |
protected function task_exists(string $type, string $object_id) { |
/** |
412 |
|
* [task_exists description] |
413 |
|
* @param string $type [description] |
414 |
|
* @param string $object_id [description] |
415 |
|
* @param bool $is_not_done [description] |
416 |
|
* @return [type] [description] |
417 |
|
*/ |
418 |
|
public function task_exists(string $type, string $object_id, string $dossier = null, bool $is_not_done = true) { |
419 |
$query = sprintf(' |
$query = sprintf(' |
420 |
SELECT task |
SELECT task |
421 |
FROM %1$stask |
FROM %1$stask |
422 |
WHERE state != \'%2$s\' |
WHERE %2$s |
423 |
AND type = \'%3$s\' |
type = \'%3$s\' |
424 |
AND object_id = \'%4$s\' |
AND (object_id = \'%4$s\' |
425 |
|
%5$s) |
426 |
|
AND state != \'%6$s\' |
427 |
', |
', |
428 |
DB_PREFIXE, |
DB_PREFIXE, |
429 |
self::STATUS_DONE, |
$is_not_done == true ? 'state != \''.self::STATUS_DONE.'\' AND' : '', |
430 |
$type, |
$type, |
431 |
$object_id |
$object_id, |
432 |
|
$dossier !== null ? sprintf('OR dossier = \'%s\'', $dossier) : '', |
433 |
|
self::STATUS_CANCELED |
434 |
); |
); |
435 |
$res = $this->f->get_one_result_from_db_query($query); |
$res = $this->f->get_one_result_from_db_query($query); |
436 |
if ($res['result'] !== null && $res['result'] !== '') { |
if ($res['result'] !== null && $res['result'] !== '') { |
440 |
} |
} |
441 |
|
|
442 |
/** |
/** |
443 |
|
* Permet la recherche multi-critères des tasks. |
444 |
|
* |
445 |
|
* @param array $search_values Chaque entrée du tableau est une ligne dans le WHERE |
446 |
|
* @return mixed Retourne le résultat de la requête ou false |
447 |
|
*/ |
448 |
|
public function task_exists_multi_search(array $search_values) { |
449 |
|
$query = sprintf(' |
450 |
|
SELECT task |
451 |
|
FROM %1$stask |
452 |
|
%2$s |
453 |
|
%3$s |
454 |
|
', |
455 |
|
DB_PREFIXE, |
456 |
|
empty($search_values) === false ? ' WHERE ' : '', |
457 |
|
implode(' AND ', $search_values) |
458 |
|
); |
459 |
|
$res = $this->f->get_all_results_from_db_query($query); |
460 |
|
if (count($res['result']) > 0) { |
461 |
|
return $res['result']; |
462 |
|
} |
463 |
|
return false; |
464 |
|
} |
465 |
|
|
466 |
|
/** |
467 |
* TRIGGER - triggerajouter. |
* TRIGGER - triggerajouter. |
468 |
* |
* |
469 |
* @param string $id |
* @param string $id |
487 |
! empty($json_payload['dossier']['dossier'])) { |
! empty($json_payload['dossier']['dossier'])) { |
488 |
$this->valF["dossier"] = $json_payload['dossier']['dossier']; |
$this->valF["dossier"] = $json_payload['dossier']['dossier']; |
489 |
} |
} |
490 |
|
} |
491 |
|
|
492 |
/** |
// gestion d'une tache de type notification et de category mail |
493 |
* Puisque le dossier n'a potentiellement pas encore été créé |
if (isset($val['type']) |
494 |
* alors il faut ne faut chercher à récupérer le numéro de dossier openADS |
&& (//$val['type'] === 'notification_recepisse' |
495 |
* à partir de l'external_uids (en passant par la table de liens) |
$val['type'] === 'notification_instruction' |
496 |
// sinon si la tâche possède une clé external_uids/dossier |
|| $val['type'] === 'notification_decision') |
497 |
elseif(isset($json_payload['external_uids']['dossier']) && |
&& isset($val['category']) |
498 |
! empty($json_payload['external_uids']['dossier'])) { |
&& $val['category'] === 'mail') { |
499 |
|
// Récupère la payload de la tache |
500 |
|
$data = array(); |
501 |
|
$data['instruction_notification'] = $this->get_instruction_notification_data( |
502 |
|
$this->valF['category'], |
503 |
|
'with-id', |
504 |
|
array('with-id' => $this->valF['object_id']) |
505 |
|
); |
506 |
|
$data['dossier'] = $this->get_dossier_data($this->valF['dossier']); |
507 |
|
|
508 |
// instancie l'objet lien_id_interne_uid_externe |
// Récupère l'instance de la notification |
509 |
$inst_lien = $this->f->get_inst__om_dbform(array( |
$inst_notif = $this->f->get_inst__om_dbform(array( |
510 |
"obj" => "lien_id_interne_uid_externe", |
"obj" => "instruction_notification", |
511 |
"idx" => ']', |
"idx" => $val['object_id'], |
512 |
|
)); |
513 |
|
// Envoi le mail et met à jour le suivi |
514 |
|
$envoiMail = $inst_notif->send_mail_notification_demandeur($data); |
515 |
|
// Passage de la tache à done si elle a réussi et à error |
516 |
|
// si l'envoi a échoué |
517 |
|
$this->valF['state'] = 'done'; |
518 |
|
if ($envoiMail === false) { |
519 |
|
$this->valF['state'] = 'error'; |
520 |
|
} |
521 |
|
} |
522 |
|
} |
523 |
|
|
524 |
|
/** |
525 |
|
* TRIGGER - triggermodifierapres. |
526 |
|
* |
527 |
|
* @param string $id |
528 |
|
* @param null &$dnu1 @deprecated Ne pas utiliser. |
529 |
|
* @param array $val Tableau des valeurs brutes. |
530 |
|
* @param null $dnu2 @deprecated Ne pas utiliser. |
531 |
|
* |
532 |
|
* @return boolean |
533 |
|
*/ |
534 |
|
public function triggermodifierapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
535 |
|
parent::triggermodifierapres($id, $dnu1, $val, $dnu2); |
536 |
|
|
537 |
|
// Suivi des notificiations |
538 |
|
// En cas de changement de l'état de la tâche de notification, alors |
539 |
|
// le suivi des dates de la notification et de l'instruction, est effectué |
540 |
|
if (isset($val['category']) === true |
541 |
|
&& $val['category'] === 'portal' |
542 |
|
&& isset($val['type']) === true |
543 |
|
&& ($val['type'] === 'notification_recepisse' |
544 |
|
|| $val['type'] === 'notification_instruction' |
545 |
|
|| $val['type'] === 'notification_decision')) { |
546 |
|
// |
547 |
|
if (isset($this->valF['state']) === true |
548 |
|
&& $this->valF['state'] !== $this->getVal('state') |
549 |
|
&& $this->valF['state'] !== self::STATUS_CANCELED) { |
550 |
|
// |
551 |
|
$inst_in = $this->f->get_inst__om_dbform(array( |
552 |
|
"obj" => "instruction_notification", |
553 |
|
"idx" => $val['object_id'], |
554 |
)); |
)); |
555 |
if(! $dossier = $inst_lien->get_id_dossier_from_external_uid( |
$valF_in = array(); |
556 |
$json_payload['external_uids']['dossier'])){ |
foreach ($inst_in->champs as $champ) { |
557 |
$error_msg = sprintf( |
$valF_in[$champ] = $inst_in->getVal($champ); |
558 |
__("Aucune correspondance de dossier pour l'external_uid.dossier '%s'."), |
} |
559 |
$json_payload['external_uids']['dossier']); |
// Par défaut la date d'envoi et la date de premier accès sur |
560 |
$this->addToLog(__METHOD__."() : erreur : $error_msg", DEBUG_MODE); |
// la notification ne sont pas renseignées |
561 |
$this->addToMessage($error_msg); |
$valF_in['date_envoi'] = null; |
562 |
$this->correct = false; |
$valF_in['date_premier_acces'] = null; |
563 |
|
// Lorsque la tâche est correctement traitée |
564 |
|
if ($this->valF['state'] === self::STATUS_DONE) { |
565 |
|
// |
566 |
|
$valF_in['statut'] = __("envoyé"); |
567 |
|
$valF_in['commentaire'] = __("Notification traitée"); |
568 |
|
$valF_in['date_envoi'] = date('d/m/Y H:i:s'); |
569 |
|
// Si l'instruction possède un document lié, alors ses dates |
570 |
|
// de suivi sont mises à jour |
571 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
572 |
|
"obj" => "instruction", |
573 |
|
"idx" => $inst_in->getVal('instruction'), |
574 |
|
)); |
575 |
|
if ($inst_instruction->has_an_edition() === true) { |
576 |
|
$valF_instruction = array(); |
577 |
|
foreach ($inst_instruction->champs as $champ) { |
578 |
|
$valF_instruction[$champ] = $inst_instruction->getVal($champ); |
579 |
|
} |
580 |
|
$valF_instruction['date_envoi_rar'] = date('d/m/Y'); |
581 |
|
$valF_instruction['date_retour_rar'] = date('d/m/Y', strtotime('now + 1 day')); |
582 |
|
$inst_instruction->setParameter('maj', 1); |
583 |
|
$update_instruction = $inst_instruction->modifier($valF_instruction); |
584 |
|
if ($update_instruction === false) { |
585 |
|
$this->addToLog(__METHOD__."(): ".$inst_instruction->msg, DEBUG_MODE); |
586 |
|
return false; |
587 |
|
} |
588 |
|
} |
589 |
|
} |
590 |
|
// En cas d'erreur lors du traitement de la task |
591 |
|
if ($this->valF['state'] === self::STATUS_ERROR) { |
592 |
|
$valF_in['statut'] = __("échec"); |
593 |
|
$valF_in['commentaire'] = __("Le traitement de la notification a échoué"); |
594 |
|
} |
595 |
|
// Met à jour la notification |
596 |
|
$inst_in->setParameter('maj', 1); |
597 |
|
$update_in = $inst_in->modifier($valF_in); |
598 |
|
if ($update_in === false) { |
599 |
|
$this->addToLog(__METHOD__."(): ".$inst_in->msg, DEBUG_MODE); |
600 |
return false; |
return false; |
601 |
} |
} |
602 |
$this->valF["dossier"] = $dossier; |
} |
|
}*/ |
|
603 |
} |
} |
604 |
|
|
605 |
|
// |
606 |
|
return true; |
607 |
} |
} |
608 |
|
|
609 |
/** |
/** |
615 |
*/ |
*/ |
616 |
public function add_task($params = array()) { |
public function add_task($params = array()) { |
617 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
618 |
|
|
619 |
|
// Vérifie si la task doit être ajoutée en fonction du mode de l'application, |
620 |
|
// seulement pour les tasks output |
621 |
|
$task_types_si = self::TASK_TYPE_SI; |
622 |
|
$task_types_sc = self::TASK_TYPE_SC; |
623 |
|
$stream = isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output'; |
624 |
|
if ($stream === 'output' |
625 |
|
&& isset($params['val']['type']) === true |
626 |
|
&& $this->f->is_option_mode_service_consulte_enabled() === true |
627 |
|
&& in_array($params['val']['type'], $task_types_sc) === false) { |
628 |
|
// |
629 |
|
return $this->end_treatment(__METHOD__, true); |
630 |
|
} |
631 |
|
if ($stream === 'output' |
632 |
|
&& isset($params['val']['type']) === true |
633 |
|
&& $this->f->is_option_mode_service_consulte_enabled() === false |
634 |
|
&& in_array($params['val']['type'], $task_types_si) === false) { |
635 |
|
// |
636 |
|
return $this->end_treatment(__METHOD__, true); |
637 |
|
} |
638 |
|
|
639 |
|
// |
640 |
$timestamp_log = json_encode(array( |
$timestamp_log = json_encode(array( |
641 |
'creation_date' => date('Y-m-d H:i:s'), |
'creation_date' => date('Y-m-d H:i:s'), |
642 |
)); |
)); |
643 |
|
|
644 |
|
// |
645 |
|
$category = isset($params['val']['category']) === true ? $params['val']['category'] : $this->category; |
646 |
|
|
647 |
// 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 |
648 |
// 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 |
649 |
if (isset($params['val']['type']) |
if (isset($params['val']['type']) |
650 |
&& $params['val']['type'] == "add_piece" |
&& ($params['val']['type'] == "add_piece" || $params['val']['type'] == "avis_consultation") |
651 |
&& isset($params['val']['stream']) |
&& isset($params['val']['stream']) |
652 |
&& $params['val']['stream'] == "input" ) { |
&& $params['val']['stream'] == "input" ) { |
653 |
// |
// |
654 |
$json_payload = json_decode($params['val']['json_payload'], true); |
$json_payload = json_decode($params['val']['json_payload'], true); |
655 |
$document_numerise = $json_payload['document_numerise']; |
if (json_last_error() !== JSON_ERROR_NONE) { |
656 |
$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.")); |
|
657 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
658 |
} |
} |
659 |
$metadata = array( |
if (isset($json_payload['document_numerise']) === true |
660 |
"filename" => $document_numerise['nom_fichier'], |
&& empty($json_payload['document_numerise']) === false) { |
661 |
"size" => strlen($file_content), |
// |
662 |
"mimetype" => $document_numerise['file_content_type'], |
$document_numerise = $json_payload['document_numerise']; |
663 |
"date_creation" => $document_numerise['date_creation'], |
$file_content = base64_decode($document_numerise["file_content"]); |
664 |
); |
if ($file_content === false){ |
665 |
$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.")); |
666 |
if ($uid_fichier === OP_FAILURE) { |
return $this->end_treatment(__METHOD__, false); |
667 |
$this->addToMessage(__("Erreur lors de la creation du fichier lié à la tâche.")); |
} |
668 |
return $this->end_treatment(__METHOD__, false); |
$metadata = array( |
669 |
|
"filename" => $document_numerise['nom_fichier'], |
670 |
|
"size" => strlen($file_content), |
671 |
|
"mimetype" => $document_numerise['file_content_type'], |
672 |
|
"date_creation" => isset($document_numerise['date_creation']) === true ? $document_numerise['date_creation'] : date("Y-m-d"), |
673 |
|
); |
674 |
|
$uid_fichier = $this->f->storage->create($file_content, $metadata, "from_content", "task.uid_fichier"); |
675 |
|
if ($uid_fichier === OP_FAILURE) { |
676 |
|
$this->addToMessage(__("Erreur lors de la creation du fichier lié à la tâche.")); |
677 |
|
return $this->end_treatment(__METHOD__, false); |
678 |
|
} |
679 |
|
$json_payload["document_numerise"]["uid"] = $uid_fichier; |
680 |
|
// Le fichier a été ajouté nous n'avons plus besoin du champ file_content dans la payload |
681 |
|
unset($json_payload["document_numerise"]["file_content"]); |
682 |
|
$params['val']['json_payload'] = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
683 |
} |
} |
|
$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); |
|
684 |
} |
} |
685 |
|
|
686 |
// Mise à jour du DI |
// Mise à jour du DI |
691 |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : self::STATUS_NEW, |
'state' => isset($params['val']['state']) === true ? $params['val']['state'] : self::STATUS_NEW, |
692 |
'object_id' => isset($params['val']['object_id']) ? $params['val']['object_id'] : '', |
'object_id' => isset($params['val']['object_id']) ? $params['val']['object_id'] : '', |
693 |
'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '', |
'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '', |
694 |
'stream' => isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output', |
'stream' => $stream, |
695 |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
696 |
|
'category' => $category, |
697 |
); |
); |
698 |
|
|
699 |
// tâche sortante |
// tâche sortante |
700 |
if($valF["stream"] == "output"){ |
if ($valF["stream"] == "output" |
701 |
|
&& $valF['type'] !== 'notification_recepisse' |
702 |
|
&& $valF['type'] !== 'notification_instruction' |
703 |
|
&& $valF['type'] !== 'notification_decision') { |
704 |
|
|
705 |
// TODO expliquer ce code |
// TODO expliquer ce code |
706 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
$task_exists = $this->task_exists($valF['type'], $valF['object_id'], $valF['dossier']); |
707 |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
708 |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
709 |
} |
} |
710 |
|
if ($valF['type'] === 'modification_DA' && $task_exists === false) { |
711 |
|
$task_exists = $this->task_exists('creation_DA', $valF['object_id']); |
712 |
|
} |
713 |
|
if ($valF['type'] === 'ajout_piece') { |
714 |
|
$task_exists = $this->task_exists('ajout_piece', $valF['object_id']); |
715 |
|
} |
716 |
|
if ($valF['type'] === 'creation_consultation') { |
717 |
|
$task_exists = $this->task_exists('creation_consultation', $valF['object_id']); |
718 |
|
} |
719 |
if ($task_exists !== false) { |
if ($task_exists !== false) { |
720 |
$inst_task = $this->f->get_inst__om_dbform(array( |
$inst_task = $this->f->get_inst__om_dbform(array( |
721 |
"obj" => "task", |
"obj" => "task", |
729 |
'val' => array( |
'val' => array( |
730 |
'state' => $update_state, |
'state' => $update_state, |
731 |
), |
), |
732 |
|
'object_id' => $valF['object_id'], |
733 |
); |
); |
734 |
return $inst_task->update_task($update_params); |
return $inst_task->update_task($update_params); |
735 |
} |
} |
736 |
} |
} |
|
|
|
737 |
$add = $this->ajouter($valF); |
$add = $this->ajouter($valF); |
738 |
$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); |
739 |
if ($add === false) { |
if ($add === false) { |
757 |
$this->addToLog(__METHOD__."(): erreur timestamp log", DEBUG_MODE); |
$this->addToLog(__METHOD__."(): erreur timestamp log", DEBUG_MODE); |
758 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
759 |
} |
} |
760 |
|
// Vérification des object_id précédent en cas de tentative d'appliquer |
761 |
|
// l'état CANCELED sur la tâche |
762 |
|
if (isset($params['val']['state']) === true |
763 |
|
&& $params['val']['state'] === self::STATUS_CANCELED) { |
764 |
|
// Récupération du journal d'activité de la tâche sous forme de tableau |
765 |
|
// trié par ordre décroissant |
766 |
|
$log = $timestamp_log; |
767 |
|
unset($log['creation_date']); |
768 |
|
krsort($log); |
769 |
|
// Pour chaque entrée dans le journal d'activité de la tâche : |
770 |
|
// - vérification de la présence de l'object_id précédent |
771 |
|
// - vérification que l'object_id précédent existe toujours dans la base de données |
772 |
|
// - l'object_id est mise à jour avec la valeur de l'object_id précédent |
773 |
|
// - le state n'est pas modifié |
774 |
|
// - sortie du traitement dès que le premier object_id précédent existant est trouvé |
775 |
|
// - si aucun object_id précédent existant n'est trouvé alors ni le state, ni l'object_id n'est modifiés |
776 |
|
foreach ($log as $key => $value) { |
777 |
|
// |
778 |
|
if (isset($value['prev_object_id']) === true |
779 |
|
&& $this->getVal('object_id') !== $value['prev_object_id']) { |
780 |
|
// Récupère la liste des tables potentielles pour un type de tâche |
781 |
|
$tables = $this->get_tables_by_task_type($this->getVal('type'), $this->getVal('stream')); |
782 |
|
foreach ($tables as $table) { |
783 |
|
// Vérifie s'il y a un ou aucun résultat |
784 |
|
$query = sprintf(' |
785 |
|
SELECT COUNT(%2$s) |
786 |
|
FROM %1$s%2$s |
787 |
|
WHERE %2$s = \'%3$s\' |
788 |
|
', |
789 |
|
DB_PREFIXE, |
790 |
|
$table, |
791 |
|
$value['prev_object_id'] |
792 |
|
); |
793 |
|
$res = $this->f->get_one_result_from_db_query($query, true); |
794 |
|
if ($res['code'] === 'KO') { |
795 |
|
return $this->end_treatment(__METHOD__, false); |
796 |
|
} |
797 |
|
// Affectation des valeurs et sortie de la boucle |
798 |
|
if ($res['result'] == '1') { |
799 |
|
$params['object_id'] = $value['prev_object_id']; |
800 |
|
$params['val']['state'] = $this->getVal('state'); |
801 |
|
break; |
802 |
|
} |
803 |
|
} |
804 |
|
// Sortie de la boucle si les valeurs sont affectées |
805 |
|
if (isset($params['object_id']) === true |
806 |
|
&& $params['object_id'] === $value['prev_object_id']) { |
807 |
|
// |
808 |
|
break; |
809 |
|
} |
810 |
|
} |
811 |
|
} |
812 |
|
} |
813 |
|
// Mise à jour du journal d'activité de la tâche |
814 |
array_push($timestamp_log, array( |
array_push($timestamp_log, array( |
815 |
'modification_date' => date('Y-m-d H:i:s'), |
'modification_date' => date('Y-m-d H:i:s'), |
816 |
'state' => $params['val']['state'], |
'state' => $params['val']['state'], |
817 |
'prev_state' => $this->getVal('state'), |
'prev_state' => $this->getVal('state'), |
818 |
|
'object_id' => isset($params['object_id']) == true ? $params['object_id'] : $this->getVal('object_id'), |
819 |
|
'prev_object_id' => $this->getVal('object_id'), |
820 |
)); |
)); |
821 |
$timestamp_log = json_encode($timestamp_log); |
$timestamp_log = json_encode($timestamp_log); |
822 |
|
// Mise à jour de la tâche |
823 |
$valF = array( |
$valF = array( |
824 |
'task' => $this->getVal($this->clePrimaire), |
'task' => $this->getVal($this->clePrimaire), |
825 |
'type' => $this->getVal('type'), |
'type' => $this->getVal('type'), |
826 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
827 |
'state' => $params['val']['state'], |
'state' => $params['val']['state'], |
828 |
'object_id' => $this->getVal('object_id'), |
'object_id' => isset($params['object_id']) == true ? $params['object_id'] : $this->getVal('object_id'), |
829 |
'stream' => $this->getVal('stream'), |
'stream' => $this->getVal('stream'), |
830 |
'dossier' => $this->getVal('dossier'), |
'dossier' => $this->getVal('dossier'), |
831 |
'json_payload' => $this->getVal('json_payload'), |
'json_payload' => $this->getVal('json_payload'), |
832 |
|
'category' => $this->getVal('category'), |
833 |
); |
); |
834 |
$update = $this->modifier($valF); |
$update = $this->modifier($valF); |
835 |
if ($update === false) { |
if ($update === false) { |
881 |
if ($this->f->get_submitted_get_value('state') !== null |
if ($this->f->get_submitted_get_value('state') !== null |
882 |
&& $this->f->get_submitted_get_value('state') !== '') { |
&& $this->f->get_submitted_get_value('state') !== '') { |
883 |
// |
// |
884 |
$where = sprintf(' WHERE state = \'%s\' ', $this->f->get_submitted_get_value('state')); |
$where_or_and = 'WHERE'; |
885 |
|
if ($where !== '') { |
886 |
|
$where_or_and = 'AND'; |
887 |
|
} |
888 |
|
$where .= sprintf(' %s state = \'%s\' ', $where_or_and, $this->f->get_submitted_get_value('state')); |
889 |
|
} |
890 |
|
if ($this->f->get_submitted_get_value('category') !== null |
891 |
|
&& $this->f->get_submitted_get_value('category') !== '') { |
892 |
|
// |
893 |
|
$where_or_and = 'WHERE'; |
894 |
|
if ($where !== '') { |
895 |
|
$where_or_and = 'AND'; |
896 |
|
} |
897 |
|
$where .= sprintf(' %s category = \'%s\' ', $where_or_and, $this->f->get_submitted_get_value('category')); |
898 |
} |
} |
899 |
$query = sprintf(' |
$query = sprintf(' |
900 |
SELECT |
SELECT |
913 |
$list_tasks = array(); |
$list_tasks = array(); |
914 |
foreach ($res['result'] as $task) { |
foreach ($res['result'] as $task) { |
915 |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
$task['timestamp_log'] = json_decode($task['timestamp_log'], true); |
916 |
$task['dossier'] = $task['object_id']; |
$task['dossier'] = $task['dossier']; |
917 |
if ($this->get_lien_objet_by_type($task['type']) === 'document_numerise') { |
if ($task['type'] === 'ajout_piece') { |
918 |
$val_dn = $this->get_document_numerise_data($task['object_id']); |
$val_dn = $this->get_document_numerise_data($task['object_id']); |
919 |
$task['dossier'] = $val_dn['dossier']; |
} |
920 |
|
if ($task['stream'] === 'output') { |
921 |
|
$task['external_uids'] = $this->get_all_external_uids($task['dossier']); |
922 |
} |
} |
923 |
$list_tasks[$task['task']] = $task; |
$list_tasks[$task['task']] = $task; |
924 |
} |
} |
931 |
"obj" => "dossier", |
"obj" => "dossier", |
932 |
"idx" => $dossier, |
"idx" => $dossier, |
933 |
)); |
)); |
934 |
|
if (empty($inst_di->val) === true) { |
935 |
|
return $val_di; |
936 |
|
} |
937 |
$val_di = $inst_di->get_json_data(); |
$val_di = $inst_di->get_json_data(); |
938 |
if ($val_di['dossier_instruction_type_code'] === 'T') { |
if ($val_di['dossier_instruction_type_code'] === 'T') { |
939 |
$val_di['date_decision_transfert'] = $val_di['date_decision']; |
$val_di['date_decision_transfert'] = $val_di['date_decision']; |
1064 |
return $val_dt; |
return $val_dt; |
1065 |
} |
} |
1066 |
|
|
1067 |
|
/** |
1068 |
|
* Récupère la liste des objets distincts existants dans la table des liens |
1069 |
|
* entre identifiants internes et identifiants externes. |
1070 |
|
* |
1071 |
|
* @return array |
1072 |
|
*/ |
1073 |
|
protected function get_list_distinct_objects_external_link() { |
1074 |
|
$query = sprintf(' |
1075 |
|
SELECT |
1076 |
|
DISTINCT(object) |
1077 |
|
FROM %1$slien_id_interne_uid_externe |
1078 |
|
ORDER BY object ASC |
1079 |
|
', |
1080 |
|
DB_PREFIXE |
1081 |
|
); |
1082 |
|
$res = $this->f->get_all_results_from_db_query($query, true); |
1083 |
|
if ($res['code'] === 'KO') { |
1084 |
|
return array(); |
1085 |
|
} |
1086 |
|
$result = array(); |
1087 |
|
foreach ($res['result'] as $object) { |
1088 |
|
$result[] = $object['object']; |
1089 |
|
} |
1090 |
|
return $result; |
1091 |
|
} |
1092 |
|
|
1093 |
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
protected function get_external_uid($fk_idx, string $fk_idx_2) { |
1094 |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
1095 |
"obj" => "lien_id_interne_uid_externe", |
"obj" => "lien_id_interne_uid_externe", |
1101 |
return $inst_external_uid->getVal('external_uid'); |
return $inst_external_uid->getVal('external_uid'); |
1102 |
} |
} |
1103 |
|
|
1104 |
protected function get_demandeurs_data(string $dossier) { |
protected function get_all_external_uids($fk_idx, $link_objects = array()) { |
1105 |
|
if (count($link_objects) == 0) { |
1106 |
|
$link_objects = $this->get_list_distinct_objects_external_link(); |
1107 |
|
} |
1108 |
|
$val_external_uid = array(); |
1109 |
|
foreach ($link_objects as $link_object) { |
1110 |
|
$external_uid = $this->get_external_uid($fk_idx, $link_object); |
1111 |
|
if ($external_uid !== '' && $external_uid !== null) { |
1112 |
|
$val_external_uid[$link_object] = $external_uid; |
1113 |
|
} |
1114 |
|
} |
1115 |
|
return $val_external_uid; |
1116 |
|
} |
1117 |
|
|
1118 |
|
protected function get_demandeurs_data($dossier) { |
1119 |
$val_demandeur = array(); |
$val_demandeur = array(); |
1120 |
|
if ($dossier === null) { |
1121 |
|
return $val_demandeur; |
1122 |
|
} |
1123 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
1124 |
"obj" => "dossier", |
"obj" => "dossier", |
1125 |
"idx" => $dossier, |
"idx" => $dossier, |
1150 |
return $val_architecte; |
return $val_architecte; |
1151 |
} |
} |
1152 |
|
|
1153 |
protected function get_instruction_data(string $dossier, $type = 'decision', $extra_params = array()) { |
protected function get_instruction_data($dossier, $type = 'decision', $extra_params = array()) { |
1154 |
$val_instruction = null; |
$val_instruction = null; |
1155 |
|
if ($dossier === null) { |
1156 |
|
return $val_instruction; |
1157 |
|
} |
1158 |
$instruction_with_doc = null; |
$instruction_with_doc = null; |
1159 |
$inst_di = $this->f->get_inst__om_dbform(array( |
$inst_di = $this->f->get_inst__om_dbform(array( |
1160 |
"obj" => "dossier", |
"obj" => "dossier", |
1214 |
return $val_instruction; |
return $val_instruction; |
1215 |
} |
} |
1216 |
|
|
1217 |
|
/** |
1218 |
|
* Récupère les informations |
1219 |
|
*/ |
1220 |
|
protected function get_instruction_notification_data($category, $type = '', $extra_params = array()) { |
1221 |
|
$val_in = null; |
1222 |
|
|
1223 |
|
$idx = null; |
1224 |
|
if ($type === 'with-id') { |
1225 |
|
$idx = $extra_params['with-id']; |
1226 |
|
} |
1227 |
|
|
1228 |
|
// récupére les données à intégrer à la payload |
1229 |
|
$inst_in = $this->f->get_inst__om_dbform(array( |
1230 |
|
"obj" => "instruction_notification", |
1231 |
|
"idx" => $idx, |
1232 |
|
)); |
1233 |
|
if (count($inst_in->val) > 0) { |
1234 |
|
$val_in = $inst_in->get_json_data(); |
1235 |
|
|
1236 |
|
$val_in['parametre_courriel_type_titre'] = ''; |
1237 |
|
$val_in['parametre_courriel_type_message'] = ''; |
1238 |
|
// Récupération du message et du titre |
1239 |
|
if ($category === 'mail') { |
1240 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
1241 |
|
"obj" => "instruction", |
1242 |
|
"idx" => $inst_in->getVal('instruction'), |
1243 |
|
)); |
1244 |
|
$collectivite_id = $inst_instruction->get_dossier_instruction_om_collectivite($inst_instruction->getVal('dossier')); |
1245 |
|
$phrase_type_notification = array(); |
1246 |
|
$phrase_type_notification = $this->f->get_notification_parametre_courriel_type($collectivite_id); |
1247 |
|
$val_in['parametre_courriel_type_titre'] = $phrase_type_notification['parametre_courriel_type_titre']; |
1248 |
|
$val_in['parametre_courriel_type_message'] = $phrase_type_notification['parametre_courriel_type_message']; |
1249 |
|
} |
1250 |
|
|
1251 |
|
// Récupération des liens vers les documents et de l'id de l'instruction |
1252 |
|
// de l'annexe |
1253 |
|
$infoDocNotif = $inst_in->getInfosDocumentsNotif($inst_in->getVal($inst_in->clePrimaire)); |
1254 |
|
$val_in['lien_telechargement_document'] = $infoDocNotif['document']['lien']; |
1255 |
|
$val_in['lien_telechargement_annexe'] = $infoDocNotif['annexe']['lien']; |
1256 |
|
$val_in['instruction_annexe'] = $infoDocNotif['annexe']['id_instruction']; |
1257 |
|
} |
1258 |
|
|
1259 |
|
return $val_in; |
1260 |
|
} |
1261 |
|
|
1262 |
protected function sort_instruction_data(array $values, array $res) { |
protected function sort_instruction_data(array $values, array $res) { |
1263 |
$fields = array( |
$fields = array( |
1264 |
"date_evenement", |
"date_evenement", |
1272 |
"om_fichier_instruction", |
"om_fichier_instruction", |
1273 |
"tacite", |
"tacite", |
1274 |
"lettretype", |
"lettretype", |
1275 |
|
"commentaire", |
1276 |
|
"complement_om_html", |
1277 |
); |
); |
1278 |
foreach ($values as $key => $value) { |
foreach ($values as $key => $value) { |
1279 |
if (in_array($key, $fields) === true) { |
if (in_array($key, $fields) === true) { |
1292 |
return $res; |
return $res; |
1293 |
} |
} |
1294 |
|
|
1295 |
|
/** |
1296 |
|
* Permet de définir si l'instruction passée en paramètre est une instruction |
1297 |
|
* récépissé d'une demande et si la demande en question a générée un dossier d'instruction. |
1298 |
|
* |
1299 |
|
* @param integer $instruction Identifiant de l'instruction |
1300 |
|
* @return boolean |
1301 |
|
*/ |
1302 |
|
protected function is_demande_instruction_recepisse_without_dossier($instruction) { |
1303 |
|
if ($instruction === null) { |
1304 |
|
return false; |
1305 |
|
} |
1306 |
|
$query = sprintf(' |
1307 |
|
SELECT demande_type.dossier_instruction_type |
1308 |
|
FROM %1$sdemande |
1309 |
|
INNER JOIN %1$sdemande_type ON demande.demande_type = demande_type.demande_type |
1310 |
|
WHERE demande.instruction_recepisse = %2$s |
1311 |
|
', |
1312 |
|
DB_PREFIXE, |
1313 |
|
$instruction |
1314 |
|
); |
1315 |
|
$res = $this->f->get_one_result_from_db_query( |
1316 |
|
$query, |
1317 |
|
true |
1318 |
|
); |
1319 |
|
if ($res['code'] === 'KO') { |
1320 |
|
return null; |
1321 |
|
} |
1322 |
|
if ($res['result'] === '') { |
1323 |
|
return true; |
1324 |
|
} |
1325 |
|
return false; |
1326 |
|
} |
1327 |
|
|
1328 |
protected function get_document_numerise_data(string $dn) { |
protected function get_document_numerise_data(string $dn) { |
1329 |
$val_dn = array(); |
$val_dn = array(); |
1330 |
$inst_dn = $this->f->get_inst__om_dbform(array( |
$inst_dn = $this->f->get_inst__om_dbform(array( |
1357 |
return $val_dp; |
return $val_dp; |
1358 |
} |
} |
1359 |
|
|
1360 |
|
protected function get_avis_decision_data(string $dossier) { |
1361 |
|
$inst_di = $this->f->get_inst__om_dbform(array( |
1362 |
|
"obj" => "dossier", |
1363 |
|
"idx" => $dossier, |
1364 |
|
)); |
1365 |
|
$ad = $inst_di->getVal('avis_decision'); |
1366 |
|
$val_ad = array(); |
1367 |
|
if ($ad !== null) { |
1368 |
|
$inst_ad = $this->f->get_inst__om_dbform(array( |
1369 |
|
"obj" => "avis_decision", |
1370 |
|
"idx" => $ad, |
1371 |
|
)); |
1372 |
|
$val_ad = $inst_ad->get_json_data(); |
1373 |
|
$val_ad['txAvis'] = "Voir document joint"; |
1374 |
|
if (isset($val_ad['tacite']) === true |
1375 |
|
&& $val_ad['tacite'] === 't') { |
1376 |
|
// |
1377 |
|
$val_ad['txAvis'] = "Sans objet"; |
1378 |
|
} |
1379 |
|
} |
1380 |
|
return $val_ad; |
1381 |
|
} |
1382 |
|
|
1383 |
|
protected function get_signataire_arrete_data(string $sa) { |
1384 |
|
$inst_sa = $this->f->get_inst__om_dbform(array( |
1385 |
|
"obj" => "signataire_arrete", |
1386 |
|
"idx" => $sa, |
1387 |
|
)); |
1388 |
|
$val_sa = array_combine($inst_sa->champs, $inst_sa->val); |
1389 |
|
foreach ($val_sa as $key => $value) { |
1390 |
|
$val_sa[$key] = strip_tags($value); |
1391 |
|
} |
1392 |
|
return $val_sa; |
1393 |
|
} |
1394 |
|
|
1395 |
|
// XXX WIP |
1396 |
|
protected function get_consultation_data(string $consultation) { |
1397 |
|
$val_consultation = array(); |
1398 |
|
$inst_consultation = $this->f->get_inst__om_dbform(array( |
1399 |
|
"obj" => "consultation", |
1400 |
|
"idx" => $consultation, |
1401 |
|
)); |
1402 |
|
$val_consultation = $inst_consultation->get_json_data(); |
1403 |
|
if (isset($val_consultation['fichier']) === true |
1404 |
|
&& $val_consultation['fichier'] !== '') { |
1405 |
|
// |
1406 |
|
$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')); |
1407 |
|
} |
1408 |
|
if (isset($val_consultation['om_fichier_consultation']) === true |
1409 |
|
&& $val_consultation['om_fichier_consultation'] !== '') { |
1410 |
|
// |
1411 |
|
$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')); |
1412 |
|
} |
1413 |
|
return $val_consultation; |
1414 |
|
} |
1415 |
|
|
1416 |
|
// XXX WIP |
1417 |
|
protected function get_service_data(string $service) { |
1418 |
|
$val_service = array(); |
1419 |
|
$inst_service = $this->f->get_inst__om_dbform(array( |
1420 |
|
"obj" => "service", |
1421 |
|
"idx" => $service, |
1422 |
|
)); |
1423 |
|
$val_service = $inst_service->get_json_data(); |
1424 |
|
return $val_service; |
1425 |
|
} |
1426 |
|
|
1427 |
protected function view_form_json($in_field = false) { |
protected function view_form_json($in_field = false) { |
1428 |
// |
// |
1429 |
if ($this->f->get_submitted_post_value('valid') === null) { |
if ($this->f->get_submitted_post_value('valid') === null |
1430 |
|
&& $this->getVal('state') !== self::STATUS_CANCELED) { |
1431 |
// Liste des valeurs à afficher |
// Liste des valeurs à afficher |
1432 |
$val = array(); |
$val = array(); |
1433 |
// |
// |
1438 |
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
1439 |
$val['task'] = $val_task; |
$val['task'] = $val_task; |
1440 |
// |
// |
1441 |
if ($this->getVal('type') === 'creation_DA') { |
if ($this->getVal('type') === 'creation_DA' |
1442 |
|
|| $this->getVal('type') === 'modification_DA') { |
1443 |
|
// |
1444 |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
1445 |
$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'); |
1446 |
$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']); |
1466 |
} |
} |
1467 |
// |
// |
1468 |
if ($this->getVal('type') === 'qualification_DI') { |
if ($this->getVal('type') === 'qualification_DI') { |
1469 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1470 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1471 |
$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'); |
1472 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1484 |
} |
} |
1485 |
// |
// |
1486 |
if ($this->getVal('type') === 'decision_DI') { |
if ($this->getVal('type') === 'decision_DI') { |
1487 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1488 |
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier']); |
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
1489 |
|
$val['instruction']['final'] = 't'; |
1490 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
1491 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
1492 |
|
} |
1493 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1494 |
$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'); |
1495 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1497 |
} |
} |
1498 |
// |
// |
1499 |
if ($this->getVal('type') === 'incompletude_DI') { |
if ($this->getVal('type') === 'incompletude_DI') { |
1500 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1501 |
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'incompletude'); |
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
1502 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1503 |
$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'); |
1504 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1506 |
} |
} |
1507 |
// |
// |
1508 |
if ($this->getVal('type') === 'completude_DI') { |
if ($this->getVal('type') === 'completude_DI') { |
1509 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1510 |
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'completude'); |
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
1511 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1512 |
$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'); |
1513 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
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'); |
1523 |
$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'); |
1524 |
|
$val['external_uids'] = $val_external_uid; |
1525 |
|
} |
1526 |
|
// |
1527 |
|
if ($this->getVal('type') === 'avis_consultation') { |
1528 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1529 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1530 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
1531 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
1532 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
1533 |
|
} |
1534 |
|
$val_external_uid = array(); |
1535 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1536 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1537 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
1538 |
|
$val['external_uids'] = $val_external_uid; |
1539 |
|
} |
1540 |
|
// XXX WIP |
1541 |
|
if ($this->getVal('type') === 'creation_consultation') { |
1542 |
|
// |
1543 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1544 |
|
$val['consultation'] = $this->get_consultation_data($this->getVal('object_id')); |
1545 |
|
$val['service'] = $this->get_service_data($val['consultation']['service']); |
1546 |
|
$val_external_uid = array(); |
1547 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1548 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1549 |
|
$val['external_uids'] = $val_external_uid; |
1550 |
|
} |
1551 |
|
// |
1552 |
|
if ($this->getVal('type') === 'notification_instruction' |
1553 |
|
|| $this->getVal('type') === 'notification_recepisse' |
1554 |
|
|| $this->getVal('type') === 'notification_decision') { |
1555 |
|
// |
1556 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1557 |
|
$dossier_id = isset($val['dossier']['dossier']) === true ? $val['dossier']['dossier'] : null; |
1558 |
|
$val['demandeur'] = $this->get_demandeurs_data($dossier_id); |
1559 |
|
$val['instruction_notification'] = $this->get_instruction_notification_data($this->getVal('category'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1560 |
|
$instruction_id = isset($val['instruction_notification']['instruction']) === true ? $val['instruction_notification']['instruction'] : null; |
1561 |
|
$instruction_annexe = isset($val['instruction_notification']['instruction_annexe']) === true ? $val['instruction_notification']['instruction_annexe'] : null; |
1562 |
|
$val['instruction'] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $instruction_id)); |
1563 |
|
// Précise qu'il s'agit d'une instruction final si l'instruction est liée à une |
1564 |
|
// demande dont le type ne génère pas de dossier |
1565 |
|
if ($this->is_demande_instruction_recepisse_without_dossier($instruction_id) === true) { |
1566 |
|
$val['instruction']['final'] = 't'; |
1567 |
|
} |
1568 |
|
// |
1569 |
|
if ($instruction_annexe != '') { |
1570 |
|
$val['instruction_annexe'] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $instruction_annexe)); |
1571 |
|
} |
1572 |
|
$val_external_uid = array(); |
1573 |
|
// Affiche l'identifiant externe lié à l'instruction si cette combinaison existe, sinon celui lié au dossier |
1574 |
|
$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'); |
1575 |
|
$val['external_uids'] = $val_external_uid; |
1576 |
|
} |
1577 |
|
// |
1578 |
|
if ($this->getVal('type') === 'prescription') { |
1579 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1580 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1581 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
1582 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
1583 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
1584 |
|
} |
1585 |
|
$val_external_uid = array(); |
1586 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
1587 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1588 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
1589 |
$val['external_uids'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1590 |
} |
} |
1591 |
|
|
1593 |
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
1594 |
} else { |
} else { |
1595 |
// Liste des valeurs affichée en JSON |
// Liste des valeurs affichée en JSON |
1596 |
printf(json_encode($val, JSON_UNESCAPED_SLASHES)); |
echo(json_encode($val, JSON_UNESCAPED_SLASHES)); |
1597 |
} |
} |
1598 |
} |
} |
1599 |
} |
} |
1600 |
|
|
1601 |
function post_update_task() { |
function post_update_task() { |
1602 |
// Mise à jour des valeurs |
// Mise à jour des valeurs |
1603 |
// |
|
1604 |
$params = array( |
// Modification de l'état de la tâche |
1605 |
'val' => array( |
if ($this->f->get_submitted_post_value('state') !== null) { |
1606 |
'state' => $this->f->get_submitted_post_value('state') |
$params = array( |
1607 |
), |
'val' => array( |
1608 |
); |
'state' => $this->f->get_submitted_post_value('state') |
1609 |
$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.') |
|
1610 |
); |
); |
1611 |
|
$update = $this->update_task($params); |
1612 |
|
$message_class = "valid"; |
1613 |
|
$message = $this->msg; |
1614 |
|
if ($update === false) { |
1615 |
|
$this->addToLog($this->msg, DEBUG_MODE); |
1616 |
|
$message_class = "error"; |
1617 |
|
$message = sprintf( |
1618 |
|
'%s %s', |
1619 |
|
__('Impossible de mettre à jour la tâche.'), |
1620 |
|
__('Veuillez contacter votre administrateur.') |
1621 |
|
); |
1622 |
|
} |
1623 |
|
$this->f->displayMessage($message_class, $message); |
1624 |
} |
} |
1625 |
$this->f->displayMessage($message_class, $message); |
|
1626 |
// |
// Sauvegarde de l'uid externe retourné |
1627 |
$inst_lien = $this->f->get_inst__om_dbform(array( |
if ($this->f->get_submitted_post_value('external_uid') !== null) { |
1628 |
"obj" => "lien_id_interne_uid_externe", |
// |
1629 |
"idx" => ']', |
$objects = $this->get_objects_by_task_type($this->getVal('type'), $this->getVal('stream')); |
1630 |
)); |
foreach ($objects as $object) { |
1631 |
$valF = array( |
$inst_lien = $this->f->get_inst__om_dbform(array( |
1632 |
'lien_id_interne_uid_externe' => '', |
"obj" => "lien_id_interne_uid_externe", |
1633 |
'object' => $this->get_lien_objet_by_type($this->getVal('type')), |
"idx" => ']', |
1634 |
'object_id' => $this->getVal('object_id'), |
)); |
1635 |
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
if ($inst_lien->is_exists($object, $this->getVal('object_id'), $this->f->get_submitted_post_value('external_uid'), $this->getVal('dossier')) === false) { |
1636 |
); |
$valF = array( |
1637 |
$add = $inst_lien->ajouter($valF); |
'lien_id_interne_uid_externe' => '', |
1638 |
$message_class = "valid"; |
'object' => $object, |
1639 |
$message = $inst_lien->msg; |
'object_id' => $this->getVal('object_id'), |
1640 |
if ($add === false) { |
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
1641 |
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
'dossier' => $this->getVal('dossier'), |
1642 |
$message_class = "error"; |
'category' => $this->getVal('category'), |
1643 |
$message = sprintf( |
); |
1644 |
'%s %s', |
$add = $inst_lien->ajouter($valF); |
1645 |
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
$message_class = "valid"; |
1646 |
__('Veuillez contacter votre administrateur.') |
$message = $inst_lien->msg; |
1647 |
); |
if ($add === false) { |
1648 |
|
$this->addToLog($inst_lien->msg, DEBUG_MODE); |
1649 |
|
$message_class = "error"; |
1650 |
|
$message = sprintf( |
1651 |
|
'%s %s', |
1652 |
|
__("Impossible de mettre à jour le lien entre l'identifiant interne et l'identifiant de l'application externe."), |
1653 |
|
__('Veuillez contacter votre administrateur.') |
1654 |
|
); |
1655 |
|
} |
1656 |
|
$this->f->displayMessage($message_class, $message); |
1657 |
|
} |
1658 |
|
} |
1659 |
} |
} |
|
$this->f->displayMessage($message_class, $message); |
|
1660 |
} |
} |
1661 |
|
|
1662 |
function post_add_task() { |
function post_add_task() { |
1666 |
'stream' => 'input', |
'stream' => 'input', |
1667 |
'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')), |
1668 |
'type' => $this->f->get_submitted_post_value('type'), |
'type' => $this->f->get_submitted_post_value('type'), |
1669 |
|
'category' => $this->f->get_submitted_post_value('category'), |
1670 |
) |
) |
1671 |
)); |
)); |
1672 |
$message = $this->msg; |
$message = sprintf( |
1673 |
|
__("Tâche %s ajoutée avec succès"), |
1674 |
|
$this->getVal($this->clePrimaire)). |
1675 |
|
'<br/><br/>'. |
1676 |
|
$this->msg; |
1677 |
$message_class = "valid"; |
$message_class = "valid"; |
1678 |
if ($result === false){ |
if ($result === false){ |
1679 |
$this->addToLog($this->msg, DEBUG_MODE); |
$this->addToLog($this->msg, DEBUG_MODE); |
1687 |
$this->f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
1688 |
} |
} |
1689 |
|
|
|
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' |
|
|
|| $type === 'decision_DI' |
|
|
|| $type === 'incompletude_DI' |
|
|
|| $type === 'completude_DI' |
|
|
|| $type === 'pec_metier_consultation') { |
|
|
// |
|
|
$objet = 'dossier'; |
|
|
} |
|
|
if ($type === 'ajout_piece') { |
|
|
$objet = 'document_numerise'; |
|
|
} |
|
|
// La tâche entrante se nomme add_piece |
|
|
if ($type === 'add_piece') { |
|
|
$objet = 'piece'; |
|
|
} |
|
|
return $objet; |
|
|
} |
|
|
|
|
1690 |
function setLayout(&$form, $maj) { |
function setLayout(&$form, $maj) { |
1691 |
|
|
1692 |
// Récupération du mode de l'action |
// Récupération du mode de l'action |
1701 |
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
1702 |
} |
} |
1703 |
|
|
1704 |
|
/** |
1705 |
|
* [get_objects_by_task_type description] |
1706 |
|
* @param [type] $type [description] |
1707 |
|
* @return [type] [description] |
1708 |
|
*/ |
1709 |
|
function get_objects_by_task_type($type, $stream = 'all') { |
1710 |
|
$objects = array(); |
1711 |
|
if (in_array($type, array('creation_DA', 'modification_DA', )) === true) { |
1712 |
|
$objects = array('dossier_autorisation', ); |
1713 |
|
} |
1714 |
|
if (in_array($type, array('creation_DI', 'depot_DI', 'notification_DI', 'qualification_DI', )) === true) { |
1715 |
|
$objects = array('dossier', ); |
1716 |
|
} |
1717 |
|
if (in_array($type, array('create_DI_for_consultation', )) === true) { |
1718 |
|
$objects = array('dossier', 'dossier_consultation', ); |
1719 |
|
} |
1720 |
|
if (in_array($type, array('create_DI', )) === true |
1721 |
|
&& $stream === 'input') { |
1722 |
|
$objects = array('dossier', 'dossier_autorisation', 'demande', ); |
1723 |
|
} |
1724 |
|
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
1725 |
|
$objects = array('instruction', ); |
1726 |
|
} |
1727 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
1728 |
|
&& $stream === 'output') { |
1729 |
|
$objects = array('pec_dossier_consultation', ); |
1730 |
|
} |
1731 |
|
if (in_array($type, array('avis_consultation', )) === true |
1732 |
|
&& $stream === 'output') { |
1733 |
|
$objects = array('avis_dossier_consultation', ); |
1734 |
|
} |
1735 |
|
if (in_array($type, array('prescription', )) === true |
1736 |
|
&& $stream === 'output') { |
1737 |
|
$objects = array('prescription', ); |
1738 |
|
} |
1739 |
|
if (in_array($type, array('ajout_piece', 'add_piece', )) === true) { |
1740 |
|
$objects = array('piece', ); |
1741 |
|
} |
1742 |
|
if (in_array($type, array('creation_consultation', )) === true) { |
1743 |
|
$objects = array('consultation', ); |
1744 |
|
} |
1745 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
1746 |
|
&& $stream === 'input') { |
1747 |
|
$objects = array('pec_metier_consultation', ); |
1748 |
|
} |
1749 |
|
if (in_array($type, array('avis_consultation', )) === true |
1750 |
|
&& $stream === 'input') { |
1751 |
|
$objects = array('avis_consultation', ); |
1752 |
|
} |
1753 |
|
if (in_array($type, array('create_message', )) === true |
1754 |
|
&& $stream === 'input') { |
1755 |
|
$objects = array('dossier_message', ); |
1756 |
|
} |
1757 |
|
if (in_array($type, array('notification_recepisse', 'notification_instruction', 'notification_decision' )) === true) { |
1758 |
|
$objects = array('instruction_notification', ); |
1759 |
|
} |
1760 |
|
return $objects; |
1761 |
|
} |
1762 |
|
|
1763 |
|
/** |
1764 |
|
* Récupère les tables auxquelles pourrait être rattaché l'objet lié à la tâche, |
1765 |
|
* par rapport à son type. |
1766 |
|
* |
1767 |
|
* @param string $type Type de la tâche |
1768 |
|
* @param string $stream input ou output |
1769 |
|
* @return array |
1770 |
|
*/ |
1771 |
|
function get_tables_by_task_type($type, $stream = 'all') { |
1772 |
|
$tables = array(); |
1773 |
|
if (in_array($type, array('creation_DA', 'modification_DA', )) === true) { |
1774 |
|
$tables = array('dossier_autorisation', ); |
1775 |
|
} |
1776 |
|
if (in_array($type, array('creation_DI', 'depot_DI', )) === true) { |
1777 |
|
$tables = array('dossier', ); |
1778 |
|
} |
1779 |
|
if (in_array($type, array('qualification_DI', )) === true) { |
1780 |
|
$tables = array('instruction', ); |
1781 |
|
} |
1782 |
|
if (in_array($type, array('create_DI_for_consultation', )) === true) { |
1783 |
|
$tables = array('dossier', ); |
1784 |
|
} |
1785 |
|
if (in_array($type, array('create_DI', )) === true |
1786 |
|
&& $stream === 'input') { |
1787 |
|
$tables = array('dossier', 'dossier_autorisation', 'demande', ); |
1788 |
|
} |
1789 |
|
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
1790 |
|
$tables = array('instruction', ); |
1791 |
|
} |
1792 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
1793 |
|
&& $stream === 'output') { |
1794 |
|
$tables = array('instruction', ); |
1795 |
|
} |
1796 |
|
if (in_array($type, array('avis_consultation', )) === true |
1797 |
|
&& $stream === 'output') { |
1798 |
|
$tables = array('instruction', ); |
1799 |
|
} |
1800 |
|
if (in_array($type, array('prescription', )) === true |
1801 |
|
&& $stream === 'output') { |
1802 |
|
$tables = array('instruction', ); |
1803 |
|
} |
1804 |
|
if (in_array($type, array('ajout_piece', 'add_piece', )) === true) { |
1805 |
|
$tables = array('document_numerise', ); |
1806 |
|
} |
1807 |
|
if (in_array($type, array('creation_consultation', )) === true) { |
1808 |
|
$tables = array('consultation', ); |
1809 |
|
} |
1810 |
|
if (in_array($type, array('pec_metier_consultation', )) === true |
1811 |
|
&& $stream === 'input') { |
1812 |
|
$tables = array('consultation', ); |
1813 |
|
} |
1814 |
|
if (in_array($type, array('avis_consultation', )) === true |
1815 |
|
&& $stream === 'input') { |
1816 |
|
$tables = array('consultation', ); |
1817 |
|
} |
1818 |
|
if (in_array($type, array('create_message', )) === true |
1819 |
|
&& $stream === 'input') { |
1820 |
|
$tables = array('dossier_message', ); |
1821 |
|
} |
1822 |
|
if (in_array($type, array('notification_recepisse', 'notification_instruction', 'notification_decision' )) === true) { |
1823 |
|
$tables = array('instruction_notification', ); |
1824 |
|
} |
1825 |
|
return $tables; |
1826 |
|
} |
1827 |
|
|
1828 |
} |
} |