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 |
* Liste des types de tâche concernant les services instructeurs |
30 |
'ajout_piece', |
'ajout_piece', |
31 |
'add_piece', |
'add_piece', |
32 |
'creation_consultation', |
'creation_consultation', |
33 |
|
'modification_DA', |
34 |
'create_DI', |
'create_DI', |
35 |
|
'notification_recepisse', |
36 |
|
'notification_instruction', |
37 |
|
'notification_decision', |
38 |
); |
); |
39 |
|
|
40 |
/** |
/** |
44 |
'create_DI_for_consultation', |
'create_DI_for_consultation', |
45 |
'avis_consultation', |
'avis_consultation', |
46 |
'pec_metier_consultation', |
'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. |
61 |
* |
* |
62 |
* @return void |
* @return void |
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') { |
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 |
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 |
|
if (isset($val['type']) |
494 |
|
&& (//$val['type'] === 'notification_recepisse' |
495 |
|
$val['type'] === 'notification_instruction' |
496 |
|
|| $val['type'] === 'notification_decision') |
497 |
|
&& isset($val['category']) |
498 |
|
&& $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 |
|
// Récupère l'instance de la notification |
509 |
|
$inst_notif = $this->f->get_inst__om_dbform(array( |
510 |
|
"obj" => "instruction_notification", |
511 |
|
"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 |
|
if (isset($val['category']) === true |
539 |
|
&& $val['category'] === 'portal' |
540 |
|
&& isset($val['type']) === true |
541 |
|
&& ($val['type'] === 'notification_recepisse' |
542 |
|
|| $val['type'] === 'notification_instruction' |
543 |
|
|| $val['type'] === 'notification_decision')) { |
544 |
|
// |
545 |
|
if (isset($this->valF['state']) === true |
546 |
|
&& $this->valF['state'] !== $this->getVal('state')) { |
547 |
|
// |
548 |
|
$inst_in = $this->f->get_inst__om_dbform(array( |
549 |
|
"obj" => "instruction_notification", |
550 |
|
"idx" => $val['object_id'], |
551 |
|
)); |
552 |
|
$valF_in = array(); |
553 |
|
foreach ($inst_in->champs as $champ) { |
554 |
|
$valF_in[$champ] = $inst_in->getVal($champ); |
555 |
|
} |
556 |
|
$valF_in['date_envoi'] = null; |
557 |
|
$valF_in['date_premier_acces'] = null; |
558 |
|
// |
559 |
|
if ($this->valF['state'] === self::STATUS_DONE) { |
560 |
|
// |
561 |
|
$valF_in['statut'] = __("envoyé"); |
562 |
|
$valF_in['commentaire'] = __("Notification traitée"); |
563 |
|
$valF_in['date_envoi'] = date('d/m/Y H:i:s'); |
564 |
|
// |
565 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
566 |
|
"obj" => "instruction", |
567 |
|
"idx" => $inst_in->getVal('instruction'), |
568 |
|
)); |
569 |
|
if ($inst_instruction->has_an_edition() === true) { |
570 |
|
$valF_instruction = array(); |
571 |
|
foreach ($inst_instruction->champs as $champ) { |
572 |
|
$valF_instruction[$champ] = $inst_instruction->getVal($champ); |
573 |
|
} |
574 |
|
$valF_instruction['date_envoi_rar'] = date('d/m/Y'); |
575 |
|
$valF_instruction['date_retour_rar'] = date('d/m/Y', strtotime('now + 1 day')); |
576 |
|
$inst_instruction->setParameter('maj', 1); |
577 |
|
$update_instruction = $inst_instruction->modifier($valF_instruction); |
578 |
|
if ($update_instruction === false) { |
579 |
|
$this->addToLog(__METHOD__."(): ".$inst_instruction->msg, DEBUG_MODE); |
580 |
|
return false; |
581 |
|
} |
582 |
|
} |
583 |
|
} |
584 |
|
if ($this->valF['state'] === self::STATUS_ERROR) { |
585 |
|
$valF_in['statut'] = __("échec"); |
586 |
|
$valF_in['commentaire'] = __("Le traitement de la notification a échoué"); |
587 |
|
} |
588 |
|
$inst_in->setParameter('maj', 1); |
589 |
|
$update_in = $inst_in->modifier($valF_in); |
590 |
|
if ($update_in === false) { |
591 |
|
$this->addToLog(__METHOD__."(): ".$inst_in->msg, DEBUG_MODE); |
592 |
|
return false; |
593 |
|
} |
594 |
|
} |
595 |
|
} |
596 |
|
|
597 |
|
// |
598 |
|
return true; |
599 |
} |
} |
600 |
|
|
601 |
/** |
/** |
628 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
629 |
} |
} |
630 |
|
|
631 |
|
// |
632 |
$timestamp_log = json_encode(array( |
$timestamp_log = json_encode(array( |
633 |
'creation_date' => date('Y-m-d H:i:s'), |
'creation_date' => date('Y-m-d H:i:s'), |
634 |
)); |
)); |
635 |
|
|
636 |
|
// |
637 |
|
$category = isset($params['val']['category']) === true ? $params['val']['category'] : $this->category; |
638 |
|
|
639 |
// 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 |
640 |
// 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 |
641 |
if (isset($params['val']['type']) |
if (isset($params['val']['type']) |
685 |
'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '', |
'dossier' => isset($params['val']['dossier']) ? $params['val']['dossier'] : '', |
686 |
'stream' => $stream, |
'stream' => $stream, |
687 |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
688 |
|
'category' => $category, |
689 |
); |
); |
690 |
|
|
691 |
// tâche sortante |
// tâche sortante |
692 |
if($valF["stream"] == "output"){ |
if ($valF["stream"] == "output" |
693 |
|
&& $valF['type'] !== 'notification_recepisse' |
694 |
|
&& $valF['type'] !== 'notification_instruction' |
695 |
|
&& $valF['type'] !== 'notification_decision') { |
696 |
|
|
697 |
// TODO expliquer ce code |
// TODO expliquer ce code |
698 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
$task_exists = $this->task_exists($valF['type'], $valF['object_id'], $valF['dossier']); |
699 |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
700 |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
701 |
} |
} |
702 |
|
if ($valF['type'] === 'modification_DA' && $task_exists === false) { |
703 |
|
$task_exists = $this->task_exists('creation_DA', $valF['object_id']); |
704 |
|
} |
705 |
|
if ($valF['type'] === 'ajout_piece') { |
706 |
|
$task_exists = $this->task_exists('ajout_piece', $valF['object_id']); |
707 |
|
} |
708 |
|
if ($valF['type'] === 'creation_consultation') { |
709 |
|
$task_exists = $this->task_exists('creation_consultation', $valF['object_id']); |
710 |
|
} |
711 |
if ($task_exists !== false) { |
if ($task_exists !== false) { |
712 |
$inst_task = $this->f->get_inst__om_dbform(array( |
$inst_task = $this->f->get_inst__om_dbform(array( |
713 |
"obj" => "task", |
"obj" => "task", |
725 |
return $inst_task->update_task($update_params); |
return $inst_task->update_task($update_params); |
726 |
} |
} |
727 |
} |
} |
|
|
|
728 |
$add = $this->ajouter($valF); |
$add = $this->ajouter($valF); |
729 |
$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); |
730 |
if ($add === false) { |
if ($add === false) { |
759 |
'type' => $this->getVal('type'), |
'type' => $this->getVal('type'), |
760 |
'timestamp_log' => $timestamp_log, |
'timestamp_log' => $timestamp_log, |
761 |
'state' => $params['val']['state'], |
'state' => $params['val']['state'], |
762 |
'object_id' => $this->getVal('object_id'), |
'object_id' => isset($params['object_id']) == true && $this->getVal('type') == 'create_DI' ? $params['object_id'] : $this->getVal('object_id'), |
763 |
'stream' => $this->getVal('stream'), |
'stream' => $this->getVal('stream'), |
764 |
'dossier' => $this->getVal('dossier'), |
'dossier' => $this->getVal('dossier'), |
765 |
'json_payload' => $this->getVal('json_payload'), |
'json_payload' => $this->getVal('json_payload'), |
766 |
|
'category' => $this->getVal('category'), |
767 |
); |
); |
768 |
$update = $this->modifier($valF); |
$update = $this->modifier($valF); |
769 |
if ($update === false) { |
if ($update === false) { |
815 |
if ($this->f->get_submitted_get_value('state') !== null |
if ($this->f->get_submitted_get_value('state') !== null |
816 |
&& $this->f->get_submitted_get_value('state') !== '') { |
&& $this->f->get_submitted_get_value('state') !== '') { |
817 |
// |
// |
818 |
$where = sprintf(' WHERE state = \'%s\' ', $this->f->get_submitted_get_value('state')); |
$where_or_and = 'WHERE'; |
819 |
|
if ($where !== '') { |
820 |
|
$where_or_and = 'AND'; |
821 |
|
} |
822 |
|
$where .= sprintf(' %s state = \'%s\' ', $where_or_and, $this->f->get_submitted_get_value('state')); |
823 |
|
} |
824 |
|
if ($this->f->get_submitted_get_value('category') !== null |
825 |
|
&& $this->f->get_submitted_get_value('category') !== '') { |
826 |
|
// |
827 |
|
$where_or_and = 'WHERE'; |
828 |
|
if ($where !== '') { |
829 |
|
$where_or_and = 'AND'; |
830 |
|
} |
831 |
|
$where .= sprintf(' %s category = \'%s\' ', $where_or_and, $this->f->get_submitted_get_value('category')); |
832 |
} |
} |
833 |
$query = sprintf(' |
$query = sprintf(' |
834 |
SELECT |
SELECT |
1139 |
return $val_instruction; |
return $val_instruction; |
1140 |
} |
} |
1141 |
|
|
1142 |
|
/** |
1143 |
|
* Récupère les informations |
1144 |
|
*/ |
1145 |
|
protected function get_instruction_notification_data($category, $type = '', $extra_params = array()) { |
1146 |
|
$val_in = array(); |
1147 |
|
|
1148 |
|
$idx = null; |
1149 |
|
if ($type === 'with-id') { |
1150 |
|
$idx = $extra_params['with-id']; |
1151 |
|
} |
1152 |
|
|
1153 |
|
// récupére les données à intégrer à la payload |
1154 |
|
$inst_in = $this->f->get_inst__om_dbform(array( |
1155 |
|
"obj" => "instruction_notification", |
1156 |
|
"idx" => $idx, |
1157 |
|
)); |
1158 |
|
$val_in = $inst_in->get_json_data(); |
1159 |
|
|
1160 |
|
$val_in['parametre_courriel_type_titre'] = ''; |
1161 |
|
$val_in['parametre_courriel_type_message'] = ''; |
1162 |
|
// Récupération du message et du titre |
1163 |
|
if ($category === 'mail') { |
1164 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
1165 |
|
"obj" => "instruction", |
1166 |
|
"idx" => $inst_in->getVal('instruction'), |
1167 |
|
)); |
1168 |
|
$collectivite_id = $inst_instruction->get_dossier_instruction_om_collectivite($inst_instruction->getVal('dossier')); |
1169 |
|
$phrase_type_notification = array(); |
1170 |
|
$phrase_type_notification = $this->f->get_notification_parametre_courriel_type($collectivite_id); |
1171 |
|
$val_in['parametre_courriel_type_titre'] = $phrase_type_notification['parametre_courriel_type_titre']; |
1172 |
|
$val_in['parametre_courriel_type_message'] = $phrase_type_notification['parametre_courriel_type_message']; |
1173 |
|
} |
1174 |
|
|
1175 |
|
// Récupération des liens vers les documents et de l'id de l'instruction |
1176 |
|
// de l'annexe |
1177 |
|
$infoDocNotif = $inst_in->getInfosDocumentsNotif($inst_in->getVal($inst_in->clePrimaire)); |
1178 |
|
$val_in['lien_telechargement_document'] = $infoDocNotif['document']['lien']; |
1179 |
|
$val_in['lien_telechargement_annexe'] = $infoDocNotif['annexe']['lien']; |
1180 |
|
$val_in['instruction_annexe'] = $infoDocNotif['annexe']['id_instruction']; |
1181 |
|
|
1182 |
|
return $val_in; |
1183 |
|
} |
1184 |
|
|
1185 |
protected function sort_instruction_data(array $values, array $res) { |
protected function sort_instruction_data(array $values, array $res) { |
1186 |
$fields = array( |
$fields = array( |
1187 |
"date_evenement", |
"date_evenement", |
1195 |
"om_fichier_instruction", |
"om_fichier_instruction", |
1196 |
"tacite", |
"tacite", |
1197 |
"lettretype", |
"lettretype", |
1198 |
|
"commentaire", |
1199 |
|
"complement_om_html", |
1200 |
); |
); |
1201 |
foreach ($values as $key => $value) { |
foreach ($values as $key => $value) { |
1202 |
if (in_array($key, $fields) === true) { |
if (in_array($key, $fields) === true) { |
1215 |
return $res; |
return $res; |
1216 |
} |
} |
1217 |
|
|
1218 |
|
/** |
1219 |
|
* Permet de définir si l'instruction passée en paramètre est une instruction |
1220 |
|
* récépissé d'une demande et si la demande en question a générée un dossier d'instruction. |
1221 |
|
* |
1222 |
|
* @param integer $instruction Identifiant de l'instruction |
1223 |
|
* @return boolean |
1224 |
|
*/ |
1225 |
|
protected function is_demande_instruction_recepisse_without_dossier($instruction) { |
1226 |
|
$query = sprintf(' |
1227 |
|
SELECT demande_type.dossier_instruction_type |
1228 |
|
FROM %1$sdemande |
1229 |
|
INNER JOIN %1$sdemande_type ON demande.demande_type = demande_type.demande_type |
1230 |
|
WHERE demande.instruction_recepisse = %2$s |
1231 |
|
', |
1232 |
|
DB_PREFIXE, |
1233 |
|
$instruction |
1234 |
|
); |
1235 |
|
$res = $this->f->get_one_result_from_db_query( |
1236 |
|
$query, |
1237 |
|
true |
1238 |
|
); |
1239 |
|
if ($res['code'] === 'KO') { |
1240 |
|
return null; |
1241 |
|
} |
1242 |
|
if ($res['result'] === '') { |
1243 |
|
return true; |
1244 |
|
} |
1245 |
|
return false; |
1246 |
|
} |
1247 |
|
|
1248 |
protected function get_document_numerise_data(string $dn) { |
protected function get_document_numerise_data(string $dn) { |
1249 |
$val_dn = array(); |
$val_dn = array(); |
1250 |
$inst_dn = $this->f->get_inst__om_dbform(array( |
$inst_dn = $this->f->get_inst__om_dbform(array( |
1346 |
|
|
1347 |
protected function view_form_json($in_field = false) { |
protected function view_form_json($in_field = false) { |
1348 |
// |
// |
1349 |
if ($this->f->get_submitted_post_value('valid') === null) { |
if ($this->f->get_submitted_post_value('valid') === null |
1350 |
|
&& $this->getVal('state') !== self::STATUS_CANCELED) { |
1351 |
// Liste des valeurs à afficher |
// Liste des valeurs à afficher |
1352 |
$val = array(); |
$val = array(); |
1353 |
// |
// |
1358 |
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
1359 |
$val['task'] = $val_task; |
$val['task'] = $val_task; |
1360 |
// |
// |
1361 |
if ($this->getVal('type') === 'creation_DA') { |
if ($this->getVal('type') === 'creation_DA' |
1362 |
|
|| $this->getVal('type') === 'modification_DA') { |
1363 |
|
// |
1364 |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
1365 |
$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'); |
1366 |
$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']); |
1386 |
} |
} |
1387 |
// |
// |
1388 |
if ($this->getVal('type') === 'qualification_DI') { |
if ($this->getVal('type') === 'qualification_DI') { |
1389 |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1390 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1391 |
$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'); |
1392 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1406 |
if ($this->getVal('type') === 'decision_DI') { |
if ($this->getVal('type') === 'decision_DI') { |
1407 |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1408 |
$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'))); |
1409 |
|
$val['instruction']['final'] = 't'; |
1410 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
1411 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
1412 |
|
} |
1413 |
$val_external_uid = array(); |
$val_external_uid = array(); |
1414 |
$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'); |
1415 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1468 |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
1469 |
$val['external_uids'] = $val_external_uid; |
$val['external_uids'] = $val_external_uid; |
1470 |
} |
} |
1471 |
|
// |
1472 |
|
if ($this->getVal('type') === 'notification_instruction' |
1473 |
|
|| $this->getVal('type') === 'notification_recepisse' |
1474 |
|
|| $this->getVal('type') === 'notification_decision') { |
1475 |
|
// |
1476 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1477 |
|
$val['demandeur'] = $this->get_demandeurs_data($this->getVal('dossier')); |
1478 |
|
$val['instruction_notification'] = $this->get_instruction_notification_data($this->getVal('category'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1479 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $val['instruction_notification']['instruction'])); |
1480 |
|
// Précise qu'il s'agit d'une instruction final si l'instruction est liée à une |
1481 |
|
// demande dont le type ne génère pas de dossier |
1482 |
|
if ($this->is_demande_instruction_recepisse_without_dossier($val['instruction_notification']['instruction']) === true) { |
1483 |
|
$val['instruction']['final'] = 't'; |
1484 |
|
} |
1485 |
|
// |
1486 |
|
if ($val['instruction_notification']['instruction_annexe'] != '') { |
1487 |
|
$val['instruction_annexe'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $val['instruction_notification']['instruction_annexe'])); |
1488 |
|
} |
1489 |
|
$val_external_uid = array(); |
1490 |
|
// Affiche l'identifiant externe lié à l'instruction si cette combinaison existe, sinon celui lié au dossier |
1491 |
|
$val_external_uid['demande'] = $this->get_external_uid($val['instruction_notification']['instruction'], 'demande') !== '' ? $this->get_external_uid($val['instruction_notification']['instruction'], 'demande') : $this->get_external_uid($val['dossier']['dossier'], 'demande'); |
1492 |
|
$val['external_uids'] = $val_external_uid; |
1493 |
|
} |
1494 |
|
// |
1495 |
|
if ($this->getVal('type') === 'prescription') { |
1496 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
1497 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
1498 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
1499 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
1500 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
1501 |
|
} |
1502 |
|
$val_external_uid = array(); |
1503 |
|
$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'); |
1505 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
1506 |
|
$val['external_uids'] = $val_external_uid; |
1507 |
|
} |
1508 |
|
|
1509 |
if ($in_field === true) { |
if ($in_field === true) { |
1510 |
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
1511 |
} else { |
} else { |
1512 |
// Liste des valeurs affichée en JSON |
// Liste des valeurs affichée en JSON |
1513 |
printf(json_encode($val, JSON_UNESCAPED_SLASHES)); |
echo(json_encode($val, JSON_UNESCAPED_SLASHES)); |
1514 |
} |
} |
1515 |
} |
} |
1516 |
} |
} |
1556 |
'object_id' => $this->getVal('object_id'), |
'object_id' => $this->getVal('object_id'), |
1557 |
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
1558 |
'dossier' => $this->getVal('dossier'), |
'dossier' => $this->getVal('dossier'), |
1559 |
|
'category' => $this->getVal('category'), |
1560 |
); |
); |
1561 |
$add = $inst_lien->ajouter($valF); |
$add = $inst_lien->ajouter($valF); |
1562 |
$message_class = "valid"; |
$message_class = "valid"; |
1583 |
'stream' => 'input', |
'stream' => 'input', |
1584 |
'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')), |
1585 |
'type' => $this->f->get_submitted_post_value('type'), |
'type' => $this->f->get_submitted_post_value('type'), |
1586 |
|
'category' => $this->f->get_submitted_post_value('category'), |
1587 |
) |
) |
1588 |
)); |
)); |
1589 |
$message = sprintf( |
$message = sprintf( |
1625 |
*/ |
*/ |
1626 |
function get_objects_by_task_type($type, $stream = 'all') { |
function get_objects_by_task_type($type, $stream = 'all') { |
1627 |
$objects = array(); |
$objects = array(); |
1628 |
if (in_array($type, array('creation_DA', )) === true) { |
if (in_array($type, array('creation_DA', 'modification_DA', )) === true) { |
1629 |
$objects = array('dossier_autorisation', ); |
$objects = array('dossier_autorisation', ); |
1630 |
} |
} |
1631 |
if (in_array($type, array('creation_DI', 'depot_DI', 'notification_DI', 'qualification_DI', )) === true) { |
if (in_array($type, array('creation_DI', 'depot_DI', 'notification_DI', 'qualification_DI', )) === true) { |
1636 |
} |
} |
1637 |
if (in_array($type, array('create_DI', )) === true |
if (in_array($type, array('create_DI', )) === true |
1638 |
&& $stream === 'input') { |
&& $stream === 'input') { |
1639 |
$objects = array('dossier', 'dossier_autorisation', ); |
$objects = array('dossier', 'dossier_autorisation', 'demande', ); |
1640 |
} |
} |
1641 |
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
1642 |
$objects = array('instruction', ); |
$objects = array('instruction', ); |
1649 |
&& $stream === 'output') { |
&& $stream === 'output') { |
1650 |
$objects = array('avis_dossier_consultation', ); |
$objects = array('avis_dossier_consultation', ); |
1651 |
} |
} |
1652 |
|
if (in_array($type, array('prescription', )) === true |
1653 |
|
&& $stream === 'output') { |
1654 |
|
$objects = array('prescription', ); |
1655 |
|
} |
1656 |
if (in_array($type, array('ajout_piece', 'add_piece', )) === true) { |
if (in_array($type, array('ajout_piece', 'add_piece', )) === true) { |
1657 |
$objects = array('piece', ); |
$objects = array('piece', ); |
1658 |
} |
} |
1667 |
&& $stream === 'input') { |
&& $stream === 'input') { |
1668 |
$objects = array('avis_consultation', ); |
$objects = array('avis_consultation', ); |
1669 |
} |
} |
1670 |
|
if (in_array($type, array('create_message', )) === true |
1671 |
|
&& $stream === 'input') { |
1672 |
|
$objects = array('dossier_message', ); |
1673 |
|
} |
1674 |
|
if (in_array($type, array('notification_recepisse', 'notification_instruction', 'notification_decision' )) === true) { |
1675 |
|
$objects = array('instruction_notification', ); |
1676 |
|
} |
1677 |
return $objects; |
return $objects; |
1678 |
} |
} |
1679 |
|
|