38 |
'notification_decision', |
'notification_decision', |
39 |
'notification_service_consulte', |
'notification_service_consulte', |
40 |
'notification_tiers_consulte', |
'notification_tiers_consulte', |
41 |
|
'notification_depot_demat', |
42 |
|
'notification_commune', |
43 |
|
'notification_signataire', |
44 |
|
'lettre_incompletude', |
45 |
|
'lettre_majoration' |
46 |
); |
); |
47 |
|
|
48 |
/** |
/** |
58 |
'notification_decision', |
'notification_decision', |
59 |
'notification_service_consulte', |
'notification_service_consulte', |
60 |
'notification_tiers_consulte', |
'notification_tiers_consulte', |
61 |
|
'notification_depot_demat', |
62 |
'prescription', |
'prescription', |
63 |
); |
); |
64 |
|
|
65 |
/** |
/** |
66 |
|
* Liste des types de tâche pouvant avoir des documents associés |
67 |
|
*/ |
68 |
|
const TASK_WITH_DOCUMENT = array( |
69 |
|
'add_piece', |
70 |
|
'avis_consultation', |
71 |
|
'pec_metier_consultation' |
72 |
|
); |
73 |
|
|
74 |
|
/** |
75 |
|
* Préfixe pour identifier les codes de suivi |
76 |
|
* @var string |
77 |
|
*/ |
78 |
|
const CS_PREFIX = 'code-suivi://'; |
79 |
|
|
80 |
|
/** |
81 |
* Catégorie de la tâche |
* Catégorie de la tâche |
82 |
*/ |
*/ |
83 |
var $category = 'platau'; |
var $category = PLATAU; |
84 |
|
|
85 |
/** |
/** |
86 |
* Définition des actions disponibles sur la classe. |
* Définition des actions disponibles sur la classe. |
399 |
case "notification_tiers_consulte": |
case "notification_tiers_consulte": |
400 |
$value_type = __('Notification tiers consulté'); |
$value_type = __('Notification tiers consulté'); |
401 |
break; |
break; |
402 |
|
case "notification_signataire": |
403 |
|
$value_type = __('Notification signataire'); |
404 |
|
break; |
405 |
case "completude_DI": |
case "completude_DI": |
406 |
$value_type = __('complétude DI'); |
$value_type = __('complétude DI'); |
407 |
break; |
break; |
408 |
case "incompletude_DI": |
case "incompletude_DI": |
409 |
$value_type = __('incomplétude DI'); |
$value_type = __('incomplétude DI'); |
410 |
break; |
break; |
411 |
|
case "lettre_incompletude": |
412 |
|
$value_type = __('Lettre au pétitionnaire d\'incompletude'); |
413 |
|
break; |
414 |
|
case "lettre_majoration": |
415 |
|
$value_type = __('Lettre au pétitionnaire de majoration'); |
416 |
|
break; |
417 |
} |
} |
418 |
|
|
419 |
$contenu_type[1][] = $value_type; |
$contenu_type[1][] = $value_type; |
444 |
) { |
) { |
445 |
$external_uid = $json_payload['external_uids']['dossier']; |
$external_uid = $json_payload['external_uids']['dossier']; |
446 |
} elseif (array_key_exists('external_uids', $json_payload) |
} elseif (array_key_exists('external_uids', $json_payload) |
447 |
&& array_key_exists('dossier', $json_payload['external_uids'])) { |
&& array_key_exists('demande', $json_payload['external_uids'])) { |
448 |
$external_uid = $json_payload['external_uids']['dossier']; |
$external_uid = $json_payload['external_uids']['demande']; |
449 |
} |
} |
450 |
// Recherche l'external uid dans la base de données pour récupèrer le numéro de |
// Recherche l'external uid dans la base de données pour récupèrer le numéro de |
451 |
// DI / DA correspondant. On stocke le numéro de dossier dans la propriété val |
// DI / DA correspondant. On stocke le numéro de dossier dans la propriété val |
452 |
// du formulaire pour pouvoir l'afficher |
// du formulaire pour pouvoir l'afficher |
453 |
if ($external_uid != '') { |
if ($external_uid != '') { |
454 |
$uid = sprintf( |
$qres = $this->f->get_one_result_from_db_query( |
455 |
'SELECT |
sprintf( |
456 |
lien_id_interne_uid_externe.dossier |
'SELECT |
457 |
FROM |
lien_id_interne_uid_externe.dossier |
458 |
%1$slien_id_interne_uid_externe |
FROM |
459 |
WHERE |
%1$slien_id_interne_uid_externe |
460 |
lien_id_interne_uid_externe.external_uid = \'%2$s\'', |
WHERE |
461 |
DB_PREFIXE, |
lien_id_interne_uid_externe.external_uid = \'%2$s\'', |
462 |
$external_uid |
DB_PREFIXE, |
463 |
|
$this->f->db->escapeSimple($external_uid) |
464 |
|
), |
465 |
|
array( |
466 |
|
"origin" => __METHOD__, |
467 |
|
) |
468 |
); |
); |
469 |
$res_external_uid = $this->f->get_one_result_from_db_query($uid); |
if (! empty($qres["result"])) { |
470 |
if (! empty($res_external_uid['result'])) { |
$form->val['dossier'] = $qres["result"]; |
|
$form->val['dossier'] = $res_external_uid['result']; |
|
471 |
} |
} |
472 |
} |
} |
473 |
} |
} |
478 |
$obj_link = ''; |
$obj_link = ''; |
479 |
if ($form->val['type'] == "creation_DA" || $form->val['type'] == "modification_DA") { |
if ($form->val['type'] == "creation_DA" || $form->val['type'] == "modification_DA") { |
480 |
// Vérification que le numéro de DA affiché dans le formulaire existe |
// Vérification que le numéro de DA affiché dans le formulaire existe |
481 |
$idDA = sprintf( |
$qres = $this->f->get_one_result_from_db_query( |
482 |
'SELECT |
sprintf( |
483 |
dossier_autorisation.dossier_autorisation |
'SELECT |
484 |
FROM |
dossier_autorisation.dossier_autorisation |
485 |
%1$sdossier_autorisation |
FROM |
486 |
WHERE |
%1$sdossier_autorisation |
487 |
dossier_autorisation.dossier_autorisation = \'%2$s\'', |
WHERE |
488 |
DB_PREFIXE, |
dossier_autorisation.dossier_autorisation = \'%2$s\'', |
489 |
$form->val['dossier'] |
DB_PREFIXE, |
490 |
|
$this->f->db->escapeSimple($form->val['dossier']) |
491 |
|
), |
492 |
|
array( |
493 |
|
"origin" => __METHOD__, |
494 |
|
) |
495 |
); |
); |
|
$resIdDA=$this->f->get_one_result_from_db_query($idDA); |
|
496 |
// Si on a un résultat c'est que le dossier existe, il faut afficher le lien |
// Si on a un résultat c'est que le dossier existe, il faut afficher le lien |
497 |
if (! empty($resIdDA['result'])) { |
if (! empty($qres["result"])) { |
498 |
$obj_link = 'dossier_autorisation'; |
$obj_link = 'dossier_autorisation'; |
499 |
} |
} |
500 |
} else { |
} else { |
501 |
// Vérification que le numéro de DI affiché dans le formulaire existe |
// Vérification que le numéro de DI affiché dans le formulaire existe |
502 |
$idDI = sprintf( |
$qres = $this->f->get_one_result_from_db_query( |
503 |
'SELECT |
sprintf( |
504 |
dossier.dossier |
'SELECT |
505 |
FROM |
dossier.dossier |
506 |
%1$sdossier |
FROM |
507 |
WHERE |
%1$sdossier |
508 |
dossier.dossier = \'%2$s\'', |
WHERE |
509 |
DB_PREFIXE, |
dossier.dossier = \'%2$s\'', |
510 |
$form->val['dossier'] |
DB_PREFIXE, |
511 |
|
$this->f->db->escapeSimple($form->val['dossier']) |
512 |
|
), |
513 |
|
array( |
514 |
|
"origin" => __METHOD__, |
515 |
|
) |
516 |
); |
); |
|
$resDI = $this->f->get_one_result_from_db_query($idDI); |
|
517 |
// Si on a un résultat c'est que le dossier existe, il faut afficher le lien |
// Si on a un résultat c'est que le dossier existe, il faut afficher le lien |
518 |
if (! empty($resDI['result'])) { |
if (! empty($qres["result"])) { |
519 |
$obj_link = 'dossier_instruction'; |
$obj_link = 'dossier_instruction'; |
520 |
} |
} |
521 |
} |
} |
545 |
function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) { |
function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) { |
546 |
// parent::setVal($form, $maj, $validation); |
// parent::setVal($form, $maj, $validation); |
547 |
// |
// |
548 |
if ($this->getVal('stream') == "output") { |
if ($this->getVal('stream') == "output" |
549 |
|
&& ($this->getVal('state') !== self::STATUS_DONE |
550 |
|
|| $this->getVal('json_payload') === "{}")) { |
551 |
|
// |
552 |
$form->setVal('json_payload', $this->view_form_json(true)); |
$form->setVal('json_payload', $this->view_form_json(true)); |
553 |
} else { |
} else { |
554 |
$form->setVal('json_payload', htmlentities($this->getVal('json_payload'))); |
$form->setVal('json_payload', json_encode(json_decode($this->getVal('json_payload'), true), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); |
555 |
|
} |
556 |
|
// Gestion du contenu de l'historique |
557 |
|
if ($this->getVal('timestamp_log') !== '' |
558 |
|
&& $this->getVal('timestamp_log') !== null) { |
559 |
|
// |
560 |
|
$form->setVal('timestamp_log', $this->getVal('timestamp_log')); |
561 |
} |
} |
562 |
} |
} |
563 |
|
|
639 |
$this->valF['stream'] == 'input')) { |
$this->valF['stream'] == 'input')) { |
640 |
|
|
641 |
// décode la payload JSON |
// décode la payload JSON |
642 |
|
// TODO : COMMENTER |
643 |
$json_payload = json_decode($this->valF['json_payload'], true); |
$json_payload = json_decode($this->valF['json_payload'], true); |
644 |
|
|
645 |
// défini une liste de chemin de clés requises |
// défini une liste de chemin de clés requises |
646 |
$paths = array(); |
$paths = array(); |
647 |
if ($this->valF['category'] === 'platau') { |
if ($this->valF['category'] === PLATAU) { |
648 |
$paths = array( |
$paths = array( |
649 |
'external_uids/dossier' |
'external_uids/dossier' |
650 |
); |
); |
722 |
* @return [type] [description] |
* @return [type] [description] |
723 |
*/ |
*/ |
724 |
public function task_exists(string $type, string $object_id, string $dossier = null, bool $is_not_done = true) { |
public function task_exists(string $type, string $object_id, string $dossier = null, bool $is_not_done = true) { |
725 |
$query = sprintf(' |
$qres = $this->f->get_one_result_from_db_query( |
726 |
SELECT task |
sprintf( |
727 |
FROM %1$stask |
'SELECT |
728 |
WHERE %2$s |
task |
729 |
type = \'%3$s\' |
FROM |
730 |
AND (object_id = \'%4$s\' |
%1$stask |
731 |
%5$s) |
WHERE |
732 |
AND state != \'%6$s\' |
%2$s |
733 |
', |
type = \'%3$s\' |
734 |
DB_PREFIXE, |
AND ( |
735 |
$is_not_done == true ? 'state != \''.self::STATUS_DONE.'\' AND' : '', |
object_id = \'%4$s\' |
736 |
$type, |
%5$s |
737 |
$object_id, |
) |
738 |
$dossier !== null ? sprintf('OR dossier = \'%s\'', $dossier) : '', |
AND state != \'%6$s\'', |
739 |
self::STATUS_CANCELED |
DB_PREFIXE, |
740 |
|
$is_not_done == true ? 'state != \''.self::STATUS_DONE.'\' AND' : '', |
741 |
|
$type, |
742 |
|
$object_id, |
743 |
|
$dossier !== null ? sprintf('OR dossier = \'%s\'', $dossier) : '', |
744 |
|
self::STATUS_CANCELED |
745 |
|
), |
746 |
|
array( |
747 |
|
"origin" => __METHOD__, |
748 |
|
) |
749 |
); |
); |
750 |
$res = $this->f->get_one_result_from_db_query($query); |
if ($qres["result"] !== null && $qres["result"] !== "") { |
751 |
if ($res['result'] !== null && $res['result'] !== '') { |
return $qres["result"]; |
|
return $res['result']; |
|
752 |
} |
} |
753 |
return false; |
return false; |
754 |
} |
} |
765 |
FROM %1$stask |
FROM %1$stask |
766 |
%2$s |
%2$s |
767 |
%3$s |
%3$s |
768 |
|
ORDER BY task ASC |
769 |
', |
', |
770 |
DB_PREFIXE, |
DB_PREFIXE, |
771 |
empty($search_values) === false ? ' WHERE ' : '', |
empty($search_values) === false ? ' WHERE ' : '', |
772 |
implode(' AND ', $search_values) |
implode(' AND ', $search_values) |
773 |
); |
); |
774 |
$res = $this->f->get_all_results_from_db_query($query); |
$res = $this->f->get_all_results_from_db_query( |
775 |
|
$query, |
776 |
|
array( |
777 |
|
"origin" => __METHOD__, |
778 |
|
) |
779 |
|
); |
780 |
if (count($res['result']) > 0) { |
if (count($res['result']) > 0) { |
781 |
return $res['result']; |
return $res['result']; |
782 |
} |
} |
816 |
&& $val['category'] === 'mail') |
&& $val['category'] === 'mail') |
817 |
|| $val['type'] === 'notification_service_consulte' |
|| $val['type'] === 'notification_service_consulte' |
818 |
|| $val['type'] === 'notification_tiers_consulte' |
|| $val['type'] === 'notification_tiers_consulte' |
819 |
|
|| $val['type'] === 'notification_depot_demat' |
820 |
|
|| $val['type'] === 'notification_commune' |
821 |
|
|| $val['type'] === 'notification_signataire' |
822 |
) { |
) { |
823 |
// Récupère la payload de la tache |
// Récupère la payload de la tache |
824 |
$data = array(); |
$data = array(); |
877 |
$this->valF['object_id'] = $new_values['object_id']; |
$this->valF['object_id'] = $new_values['object_id']; |
878 |
$this->valF['last_modification_date'] = date('Y-m-d'); |
$this->valF['last_modification_date'] = date('Y-m-d'); |
879 |
$this->valF['last_modification_time'] = date('H:i:s'); |
$this->valF['last_modification_time'] = date('H:i:s'); |
880 |
|
if ($val['stream'] === 'output') { |
881 |
|
// Lorsque la task passe d'un état qui n'est pas "done" à l'état "done" |
882 |
|
if ($this->getVal("state") !== self::STATUS_DONE |
883 |
|
&& $this->valF['state'] === self::STATUS_DONE) { |
884 |
|
// |
885 |
|
$this->valF['json_payload'] = $this->view_form_json(true); |
886 |
|
} |
887 |
|
// Lorsque la task passe d'un état "done" à un état qui n'est pas "done" |
888 |
|
if ($this->getVal("state") === self::STATUS_DONE |
889 |
|
&& $this->valF['state'] !== self::STATUS_DONE) { |
890 |
|
// |
891 |
|
$this->valF['json_payload'] = "{}"; |
892 |
|
} |
893 |
|
} |
894 |
|
|
895 |
return true; |
return true; |
896 |
} |
} |
933 |
$tables = $this->get_tables_by_task_type($this->getVal('type'), $this->getVal('stream')); |
$tables = $this->get_tables_by_task_type($this->getVal('type'), $this->getVal('stream')); |
934 |
foreach ($tables as $table) { |
foreach ($tables as $table) { |
935 |
// Vérifie s'il y a un ou aucun résultat |
// Vérifie s'il y a un ou aucun résultat |
936 |
$query = sprintf(' |
$qres = $this->f->get_one_result_from_db_query( |
937 |
SELECT COUNT(%2$s) |
sprintf( |
938 |
FROM %1$s%2$s |
'SELECT |
939 |
WHERE %2$s::CHARACTER VARYING = \'%3$s\' |
COUNT(%2$s) |
940 |
', |
FROM |
941 |
DB_PREFIXE, |
%1$s%2$s |
942 |
$table, |
WHERE |
943 |
$value['prev_object_id'] |
%2$s::CHARACTER VARYING = \'%3$s\'', |
944 |
|
DB_PREFIXE, |
945 |
|
$table, |
946 |
|
$value['prev_object_id'] |
947 |
|
), |
948 |
|
array( |
949 |
|
"origin" => __METHOD__, |
950 |
|
"force_return" => true, |
951 |
|
) |
952 |
); |
); |
953 |
$res = $this->f->get_one_result_from_db_query($query, true); |
if ($qres["code"] !== "OK") { |
|
if ($res['code'] === 'KO') { |
|
954 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
955 |
} |
} |
956 |
// Affectation des valeurs et sortie de la boucle |
// Affectation des valeurs et sortie de la boucle |
957 |
if ($res['result'] == '1') { |
if ($qres["result"] == '1') { |
958 |
$params['object_id'] = $value['prev_object_id']; |
$params['object_id'] = $value['prev_object_id']; |
959 |
$params['state'] = $this->getVal('state'); |
$params['state'] = $this->getVal('state'); |
960 |
break; |
break; |
1011 |
// En cas de changement de l'état de la tâche de notification, alors |
// En cas de changement de l'état de la tâche de notification, alors |
1012 |
// le suivi des dates de la notification et de l'instruction, est effectué |
// le suivi des dates de la notification et de l'instruction, est effectué |
1013 |
if (isset($val['category']) === true |
if (isset($val['category']) === true |
1014 |
&& $val['category'] === 'portal' |
&& $val['category'] === PORTAL |
1015 |
&& isset($val['type']) === true |
&& isset($val['type']) === true |
1016 |
&& ($val['type'] === 'notification_recepisse' |
&& ($val['type'] === 'notification_recepisse' |
1017 |
|| $val['type'] === 'notification_instruction' |
|| $val['type'] === 'notification_instruction' |
1054 |
} |
} |
1055 |
$valF_instruction['date_envoi_rar'] = date('d/m/Y'); |
$valF_instruction['date_envoi_rar'] = date('d/m/Y'); |
1056 |
$valF_instruction['date_retour_rar'] = date('d/m/Y', strtotime('now + 1 day')); |
$valF_instruction['date_retour_rar'] = date('d/m/Y', strtotime('now + 1 day')); |
1057 |
$inst_instruction->setParameter('maj', 1); |
// Action spécifique pour identifier que la modification |
1058 |
|
// est une notification de demandeur |
1059 |
|
$inst_instruction->setParameter('maj', 175); |
1060 |
$update_instruction = $inst_instruction->modifier($valF_instruction); |
$update_instruction = $inst_instruction->modifier($valF_instruction); |
1061 |
if ($update_instruction === false) { |
if ($update_instruction === false) { |
1062 |
$this->addToLog(__METHOD__."(): ".$inst_instruction->msg, DEBUG_MODE); |
$this->addToLog(__METHOD__."(): ".$inst_instruction->msg, DEBUG_MODE); |
1148 |
// 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 |
1149 |
// 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 |
1150 |
if (isset($params['val']['type']) |
if (isset($params['val']['type']) |
1151 |
&& ($params['val']['type'] == "add_piece" || $params['val']['type'] == "avis_consultation") |
&& in_array($params['val']['type'], self::TASK_WITH_DOCUMENT) |
1152 |
&& isset($params['val']['stream']) |
&& isset($params['val']['stream']) |
1153 |
&& $params['val']['stream'] == "input" ) { |
&& $params['val']['stream'] == "input" ) { |
1154 |
// |
// |
1184 |
} |
} |
1185 |
} |
} |
1186 |
|
|
1187 |
// Mise à jour du DI |
// Valeurs de la tâche |
1188 |
$valF = array( |
$valF = array( |
1189 |
'task' => '', |
'task' => '', |
1190 |
'type' => $params['val']['type'], |
'type' => $params['val']['type'], |
1202 |
'comment' => null, |
'comment' => null, |
1203 |
); |
); |
1204 |
|
|
1205 |
// tâche sortante |
// Gestion de la mise à jour des tâches sortantes |
1206 |
$typeNonConcerne = array( |
$typeNonConcerne = array( |
1207 |
'notification_recepisse', |
'notification_recepisse', |
1208 |
'notification_instruction', |
'notification_instruction', |
1209 |
'notification_decision', |
'notification_decision', |
1210 |
'notification_service_consulte', |
'notification_service_consulte', |
1211 |
'notification_tiers_consulte' |
'notification_tiers_consulte', |
1212 |
|
'notification_depot_demat', |
1213 |
|
'notification_commune', |
1214 |
|
'notification_signataire', |
1215 |
); |
); |
1216 |
if ($valF["stream"] == "output" |
if ($valF["stream"] == "output" |
1217 |
&& ! in_array($valF['type'], $typeNonConcerne)) { |
&& ! in_array($valF['type'], $typeNonConcerne)) { |
1218 |
// TODO expliquer ce code |
// Vérification de l'existance d'une tâche pour l'objet concerné |
1219 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id'], $valF['dossier']); |
// La vérification diffère en fonction de certains types de tâche |
1220 |
|
$search_values_common = array( |
1221 |
|
sprintf('state != \'%s\'', self::STATUS_CANCELED), |
1222 |
|
sprintf('state != \'%s\'', self::STATUS_DONE), |
1223 |
|
); |
1224 |
|
$search_values_others = array( |
1225 |
|
sprintf('type = \'%s\'', $valF['type']), |
1226 |
|
sprintf('(object_id = \'%s\' OR dossier = \'%s\')', $valF['object_id'], $valF['dossier']), |
1227 |
|
); |
1228 |
|
$search_values_specifics = array( |
1229 |
|
sprintf('object_id = \'%s\'', $valF['object_id']), |
1230 |
|
); |
1231 |
|
|
1232 |
|
// Recherche multi-critères sur les tâches |
1233 |
|
// Si l'object id/dossier à des tâches de type $valF['type'] qui lui est associé |
1234 |
|
// Et que ces tâches ont des statut différents de canceled et done |
1235 |
|
// Alors on récupère ces tâches |
1236 |
|
// Sinon return false |
1237 |
|
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_others)); |
1238 |
|
|
1239 |
|
// S'il n'existe pas de tâche de type 'modification DI' pour l'object id/dossier |
1240 |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
1241 |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
// On se réfère à la tâche de type 'creation DI' de l'object id |
1242 |
|
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_specifics, array("type = 'creation_DI'"))); |
1243 |
} |
} |
1244 |
|
// S'il n'existe pas de tâche de type 'modification DA' pour l'object id/dossier |
1245 |
if ($valF['type'] === 'modification_DA' && $task_exists === false) { |
if ($valF['type'] === 'modification_DA' && $task_exists === false) { |
1246 |
$task_exists = $this->task_exists('creation_DA', $valF['object_id']); |
// On se réfère à la tâche de type 'creation DA' de l'object id |
1247 |
|
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_specifics, array("type = 'creation_DA'"))); |
1248 |
} |
} |
1249 |
if ($valF['type'] === 'ajout_piece') { |
if ($valF['type'] === 'ajout_piece') { |
1250 |
$task_exists = $this->task_exists('ajout_piece', $valF['object_id']); |
// On se réfère à la tâche de type 'ajout piece' de l'object id |
1251 |
|
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_specifics, array("type = 'ajout_piece'"))); |
1252 |
} |
} |
1253 |
if ($valF['type'] === 'creation_consultation') { |
if ($valF['type'] === 'creation_consultation') { |
1254 |
$task_exists = $this->task_exists('creation_consultation', $valF['object_id']); |
// On se réfère à la tâche de type 'creation consultation' de l'object id |
1255 |
|
$task_exists = $this->task_exists_multi_search(array_merge($search_values_common, $search_values_specifics, array("type = 'creation_consultation'"))); |
1256 |
} |
} |
1257 |
|
// S'il existe une tâche pour l'objet concerné, pas d'ajout de nouvelle |
1258 |
|
// tâche mais mise à jour de l'existante |
1259 |
if ($task_exists !== false) { |
if ($task_exists !== false) { |
1260 |
$inst_task = $this->f->get_inst__om_dbform(array( |
// Plusieurs tâches pourraient exister, elles sont contôler par ordre croissant |
1261 |
"obj" => "task", |
foreach ($task_exists as $task) { |
1262 |
"idx" => $task_exists, |
$inst_task = $this->f->get_inst__om_dbform(array( |
1263 |
)); |
"obj" => "task", |
1264 |
$update_state = $inst_task->getVal('state'); |
"idx" => $task['task'], |
1265 |
if (isset($params['update_val']['state']) === true) { |
)); |
1266 |
$update_state = $params['update_val']['state']; |
$update_state = $inst_task->getVal('state'); |
1267 |
} |
if (isset($params['update_val']['state']) === true) { |
1268 |
$update_params = array( |
$update_state = $params['update_val']['state']; |
1269 |
'val' => array( |
} |
1270 |
'state' => $update_state, |
$object_id = $inst_task->getVal('object_id'); |
1271 |
), |
if (!empty($valF['object_id'])) { |
1272 |
'object_id' => $valF['object_id'], |
$object_id = $valF['object_id']; |
1273 |
); |
} |
1274 |
return $inst_task->update_task($update_params); |
// Pour être mise à jour, la tâche existante ne doit pas être en cours de traitement |
1275 |
|
$task_pending = $inst_task->getVal('state') === self::STATUS_PENDING |
1276 |
|
&& $update_state === self::STATUS_PENDING |
1277 |
|
&& $inst_task->getVal('object_id') !== $object_id; |
1278 |
|
if ($task_pending === false) { |
1279 |
|
$update_params = array( |
1280 |
|
'val' => array( |
1281 |
|
'state' => $update_state, |
1282 |
|
), |
1283 |
|
'object_id' => $object_id, |
1284 |
|
); |
1285 |
|
return $inst_task->update_task($update_params); |
1286 |
|
} |
1287 |
|
} |
1288 |
} |
} |
1289 |
} |
} |
1290 |
$add = $this->ajouter($valF); |
$add = $this->ajouter($valF); |
1321 |
'creation_time' => $this->getVal('creation_time'), |
'creation_time' => $this->getVal('creation_time'), |
1322 |
'last_modification_date' => date('Y-m-d'), |
'last_modification_date' => date('Y-m-d'), |
1323 |
'last_modification_time' => date('H:i:s'), |
'last_modification_time' => date('H:i:s'), |
1324 |
'comment' => $this->getVal('comment'), |
'comment' => isset($params['comment']) == true ? $params['comment'] : $this->getVal('comment'), |
1325 |
); |
); |
1326 |
$update = $this->modifier($valF); |
$update = $this->modifier($valF); |
1327 |
if ($update === false) { |
if ($update === false) { |
1412 |
// |
// |
1413 |
$query = sprintf(' |
$query = sprintf(' |
1414 |
SELECT |
SELECT |
1415 |
task.* |
DISTINCT (task.task), |
1416 |
|
task.object_id, |
1417 |
|
task.dossier, |
1418 |
|
task.stream, |
1419 |
|
task.category, |
1420 |
|
task.creation_date, |
1421 |
|
task.creation_time, |
1422 |
|
task.last_modification_date, |
1423 |
|
task.last_modification_time, |
1424 |
|
task.comment |
1425 |
FROM %1$stask |
FROM %1$stask |
1426 |
LEFT JOIN %1$slien_id_interne_uid_externe |
LEFT JOIN %1$slien_id_interne_uid_externe |
1427 |
ON task.object_id = lien_id_interne_uid_externe.object_id |
ON task.object_id = lien_id_interne_uid_externe.object_id |
1432 |
DB_PREFIXE, |
DB_PREFIXE, |
1433 |
$where |
$where |
1434 |
); |
); |
1435 |
$res = $this->f->get_all_results_from_db_query($query, true); |
$res = $this->f->get_all_results_from_db_query( |
1436 |
|
$query, |
1437 |
|
array( |
1438 |
|
"origin" => __METHOD__, |
1439 |
|
"force_return" => true, |
1440 |
|
) |
1441 |
|
); |
1442 |
if ($res['code'] === 'KO') { |
if ($res['code'] === 'KO') { |
1443 |
return false; |
return false; |
1444 |
} |
} |
1445 |
$list_tasks = array(); |
$list_tasks = array(); |
1446 |
foreach ($res['result'] as $task) { |
foreach ($res['result'] as $task) { |
|
unset($task['timestamp_log']); |
|
|
unset($task['json_payload']); |
|
1447 |
if ($task['type'] === 'ajout_piece') { |
if ($task['type'] === 'ajout_piece') { |
1448 |
$val_dn = $this->get_document_numerise_data($task['object_id']); |
$val_dn = $this->get_document_numerise_data($task['object_id']); |
1449 |
} |
} |
1557 |
if (isset($val_dt['tax_ext_pret']) === true |
if (isset($val_dt['tax_ext_pret']) === true |
1558 |
&& $val_dt['tax_ext_pret'] === 'f') { |
&& $val_dt['tax_ext_pret'] === 'f') { |
1559 |
// |
// |
1560 |
$val_dt['tax_su_princ_surf1'] = $val_dt['tax_surf_tot_cstr']; |
$val_dt['tax_su_princ_surf1'] = isset($val_dt['tax_surf_tot_cstr']) === true ? $val_dt['tax_surf_tot_cstr'] : ''; |
1561 |
$val_dt['tax_su_princ_surf_stat1'] = $val_dt['tax_surf_loc_stat']; |
$val_dt['tax_su_princ_surf_stat1'] = isset($val_dt['tax_surf_loc_stat']) === true ? $val_dt['tax_surf_loc_stat'] : ''; |
1562 |
} |
} |
1563 |
if (isset($val_dt['tax_ext_pret']) === true |
if (isset($val_dt['tax_ext_pret']) === true |
1564 |
&& $val_dt['tax_ext_pret'] === 't') { |
&& $val_dt['tax_ext_pret'] === 't') { |
1567 |
if (preg_match('/[pP].*[lL].*[aA].*[iI]/', $val_dt['tax_ext_desc']) === 1 |
if (preg_match('/[pP].*[lL].*[aA].*[iI]/', $val_dt['tax_ext_desc']) === 1 |
1568 |
|| preg_match('/[lL].*[lL].*[tT].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
|| preg_match('/[lL].*[lL].*[tT].*[sS]/', $val_dt['tax_ext_desc']) === 1) { |
1569 |
// |
// |
1570 |
$val_dt['tax_su_princ_surf2'] = $val_dt['tax_surf_tot_cstr']; |
$val_dt['tax_su_princ_surf2'] = isset($val_dt['tax_surf_tot_cstr']) === true ? $val_dt['tax_surf_tot_cstr'] : ''; |
1571 |
$val_dt['tax_su_princ_surf_stat2'] = $val_dt['tax_surf_loc_stat']; |
$val_dt['tax_su_princ_surf_stat2'] = isset($val_dt['tax_surf_loc_stat']) === true ? $val_dt['tax_surf_loc_stat'] : ''; |
1572 |
} |
} |
1573 |
// if (preg_match('/[pP].*[tT].*[zZ]/', $val_dt['tax_ext_desc']) === 1) { |
// if (preg_match('/[pP].*[tT].*[zZ]/', $val_dt['tax_ext_desc']) === 1) { |
1574 |
// $val_dt['tax_su_princ_surf4'] = $val_dt['tax_surf_tot_cstr']; |
// $val_dt['tax_su_princ_surf4'] = $val_dt['tax_surf_tot_cstr']; |
1612 |
', |
', |
1613 |
DB_PREFIXE |
DB_PREFIXE |
1614 |
); |
); |
1615 |
$res = $this->f->get_all_results_from_db_query($query, true); |
$res = $this->f->get_all_results_from_db_query( |
1616 |
|
$query, |
1617 |
|
array( |
1618 |
|
"origin" => __METHOD__, |
1619 |
|
"force_return" => true, |
1620 |
|
) |
1621 |
|
); |
1622 |
if ($res['code'] === 'KO') { |
if ($res['code'] === 'KO') { |
1623 |
return array(); |
return array(); |
1624 |
} |
} |
1629 |
return $result; |
return $result; |
1630 |
} |
} |
1631 |
|
|
1632 |
protected function get_external_uid($fk_idx, string $fk_idx_2, $fk_idx_3 = 'platau', $order_asc_desc = 'DESC') { |
protected function get_external_uid($fk_idx, string $fk_idx_2, $fk_idx_3 = PLATAU, $order_asc_desc = 'DESC') { |
1633 |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
$inst_external_uid = $this->f->get_inst__by_other_idx(array( |
1634 |
"obj" => "lien_id_interne_uid_externe", |
"obj" => "lien_id_interne_uid_externe", |
1635 |
"fk_field" => 'object_id', |
"fk_field" => 'object_id', |
1644 |
return $inst_external_uid->getVal('external_uid'); |
return $inst_external_uid->getVal('external_uid'); |
1645 |
} |
} |
1646 |
|
|
1647 |
protected function get_all_external_uids($fk_idx, $link_objects = array(), $category='platau') { |
protected function get_all_external_uids($fk_idx, $link_objects = array(), $category=PLATAU) { |
1648 |
if (count($link_objects) == 0) { |
if (count($link_objects) == 0) { |
1649 |
$link_objects = $this->get_list_distinct_objects_external_link(); |
$link_objects = $this->get_list_distinct_objects_external_link(); |
1650 |
} |
} |
1798 |
$val_in['parametre_courriel_type_message'] = $phrase_type_notification['parametre_courriel_type_message']; |
$val_in['parametre_courriel_type_message'] = $phrase_type_notification['parametre_courriel_type_message']; |
1799 |
} |
} |
1800 |
|
|
1801 |
// Récupération des liens vers les documents et des id et type des annexes |
if ($typeNotification == 'notification_signataire') { |
1802 |
$infoDocNotif = $inst_in->getInfosDocumentsNotif($inst_in->getVal($inst_in->clePrimaire)); |
$val_in['lien_page_signature'] = $inst_in->getLienPageSignature($inst_instruction); |
1803 |
$val_in['lien_telechargement_document'] = $infoDocNotif['document']['lien']; |
} |
1804 |
$val_in['annexes'] = $infoDocNotif['annexes']; |
else { |
1805 |
|
// Récupération des liens vers les documents et des id et type des annexes |
1806 |
|
$infoDocNotif = $inst_in->getInfosDocumentsNotif($inst_in->getVal($inst_in->clePrimaire), $category); |
1807 |
|
$cle = $category == PORTAL ? 'path' : 'lien_telechargement_document'; |
1808 |
|
$val_in[$cle] = $infoDocNotif['document']['path']; |
1809 |
|
$val_in['annexes'] = $infoDocNotif['annexes']; |
1810 |
|
} |
1811 |
} |
} |
1812 |
return $val_in; |
return $val_in; |
1813 |
} |
} |
1814 |
|
|
1815 |
|
/** |
1816 |
|
* Récupère les informations concernant la lettre au pétitionnaire. |
1817 |
|
* |
1818 |
|
* @param string identifiant du dossier |
1819 |
|
* @param string type de tâche |
1820 |
|
* @param array paramètre supplémentaire permettant de récupérer les informations |
1821 |
|
* |
1822 |
|
* @return array information concernant la lettre au pétitionnaire |
1823 |
|
*/ |
1824 |
|
protected function get_lettre_petitionnaire_data($dossier, $type, $extra_params = array()) { |
1825 |
|
// Si la date limite de notification n'a pas été dépassé le type de lettre est 1 |
1826 |
|
// Si la date a été dépassé et qu'il s'agit d'une demande de pièce le type est 3 |
1827 |
|
// Si la date a été dépassé et qu'il s'agit d'une prolongation le type est 4 |
1828 |
|
// Le type de document dépend du type de pièce |
1829 |
|
$nomTypeLettre = ''; |
1830 |
|
$nomTypeDocument = ''; |
1831 |
|
if ($type === 'lettre_incompletude') { |
1832 |
|
$nomTypeLettre = '3'; |
1833 |
|
$nomTypeDocument = '4'; |
1834 |
|
} elseif ($type === 'lettre_majoration') { |
1835 |
|
$nomTypeLettre = '4'; |
1836 |
|
$nomTypeDocument = '6'; |
1837 |
|
} |
1838 |
|
|
1839 |
|
$inst_di = $this->f->get_inst__om_dbform(array( |
1840 |
|
"obj" => "dossier", |
1841 |
|
"idx" => $dossier, |
1842 |
|
)); |
1843 |
|
$date_limite_notification = DateTime::createFromFormat('Y-m-d', $inst_di->getVal('date_notification_delai')); |
1844 |
|
$aujourdhui = new DateTime(); |
1845 |
|
if (! $date_limite_notification instanceof DateTime) { |
1846 |
|
$nomTypeLettre = ''; |
1847 |
|
$nomTypeDocument = ''; |
1848 |
|
} elseif ($aujourdhui < $date_limite_notification) { |
1849 |
|
$nomTypeLettre = '1'; |
1850 |
|
$nomTypeDocument = '3'; |
1851 |
|
} |
1852 |
|
|
1853 |
|
return array( |
1854 |
|
'nomEtatLettre' => '3', |
1855 |
|
'nomModaliteNotifMetier' => '4', |
1856 |
|
'nomTypeLettre' => $nomTypeLettre, |
1857 |
|
'nomTypeDocument' => $nomTypeDocument |
1858 |
|
); |
1859 |
|
} |
1860 |
|
|
1861 |
protected function sort_instruction_data(array $values, array $res) { |
protected function sort_instruction_data(array $values, array $res) { |
1862 |
$fields = array( |
$fields = array( |
1863 |
"date_evenement", |
"date_evenement", |
1902 |
if ($instruction === null) { |
if ($instruction === null) { |
1903 |
return false; |
return false; |
1904 |
} |
} |
1905 |
$query = sprintf(' |
$qres = $this->f->get_one_result_from_db_query( |
1906 |
SELECT demande_type.dossier_instruction_type |
sprintf( |
1907 |
FROM %1$sdemande |
'SELECT |
1908 |
INNER JOIN %1$sdemande_type ON demande.demande_type = demande_type.demande_type |
demande_type.dossier_instruction_type |
1909 |
WHERE demande.instruction_recepisse = %2$s |
FROM |
1910 |
', |
%1$sdemande |
1911 |
DB_PREFIXE, |
INNER JOIN %1$sdemande_type |
1912 |
$instruction |
ON demande.demande_type = demande_type.demande_type |
1913 |
); |
WHERE |
1914 |
$res = $this->f->get_one_result_from_db_query( |
demande.instruction_recepisse = %2$s', |
1915 |
$query, |
DB_PREFIXE, |
1916 |
true |
intval($instruction) |
1917 |
|
), |
1918 |
|
array( |
1919 |
|
"origin" => __METHOD__, |
1920 |
|
"force_return" => true, |
1921 |
|
) |
1922 |
); |
); |
1923 |
if ($res['code'] === 'KO') { |
if ($qres["code"] !== "OK") { |
1924 |
return null; |
return null; |
1925 |
} |
} |
1926 |
if ($res['result'] === '') { |
if ($qres["result"] === "") { |
1927 |
return true; |
return true; |
1928 |
} |
} |
1929 |
return false; |
return false; |
1968 |
)); |
)); |
1969 |
$ad = $inst_di->getVal('avis_decision'); |
$ad = $inst_di->getVal('avis_decision'); |
1970 |
$val_ad = array(); |
$val_ad = array(); |
1971 |
if ($ad !== null) { |
if ($ad !== null && trim($ad) !== '') { |
1972 |
$inst_ad = $this->f->get_inst__om_dbform(array( |
$inst_ad = $this->f->get_inst__om_dbform(array( |
1973 |
"obj" => "avis_decision", |
"obj" => "avis_decision", |
1974 |
"idx" => $ad, |
"idx" => $ad, |
2030 |
|
|
2031 |
protected function view_form_json($in_field = false) { |
protected function view_form_json($in_field = false) { |
2032 |
// |
// |
2033 |
if ($this->f->get_submitted_post_value('valid') === null |
$check_state = isset($this->valF['state']) === true ? $this->valF['state'] : $this->getVal('state'); |
2034 |
&& $this->getVal('state') !== self::STATUS_CANCELED) { |
if ($check_state !== self::STATUS_CANCELED) { |
2035 |
// Liste des valeurs à afficher |
// Liste des valeurs à afficher |
2036 |
$val = array(); |
$val = array(); |
2037 |
// |
// |
2039 |
foreach ($val_task as $key => $value) { |
foreach ($val_task as $key => $value) { |
2040 |
$val_task[$key] = strip_tags($value); |
$val_task[$key] = strip_tags($value); |
2041 |
} |
} |
2042 |
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
|
2043 |
unset($val_task['timestamp_log_hidden']); |
// Vérifie pour les tâches dont l'affichage de la payload est calculée si l'objet |
2044 |
$val['task'] = $val_task; |
// de référence de la tâche existe. |
2045 |
// |
$objectRefExist = true; |
2046 |
if ($this->getVal('type') === 'creation_DA' |
if ($val_task['stream'] === 'output' |
2047 |
|| $this->getVal('type') === 'modification_DA') { |
&& (empty($val_task['json_payload']) || $val_task['json_payload'] === '{}')) { |
2048 |
// |
$objectRefExist = $this->does_referenced_object_exist( |
2049 |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
$val_task['object_id'], |
2050 |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
$val_task['type'] |
2051 |
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
); |
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'creation_DI' |
|
|
|| $this->getVal('type') === 'modification_DI' |
|
|
|| $this->getVal('type') === 'depot_DI') { |
|
|
// |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
|
|
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction'); |
|
|
$val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']); |
|
|
$architecte = isset($val['donnees_techniques']['architecte']) === true ? $val['donnees_techniques']['architecte'] : null; |
|
|
$val['architecte'] = $this->get_architecte_data($architecte); |
|
|
$val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'qualification_DI') { |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'ajout_piece') { |
|
|
$val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id')); |
|
|
$val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val_external_uid['piece'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'piece'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'decision_DI') { |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
|
|
$val['instruction']['final'] = 't'; |
|
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
|
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
|
|
} |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'incompletude_DI') { |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'completude_DI') { |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'pec_metier_consultation') { |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'avis_consultation') { |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
|
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
|
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
|
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
|
|
} |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
|
|
$val_external_uid['avis_dossier_consultation'] = $this->get_external_uid($this->getVal('object_id'), 'avis_dossier_consultation'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// XXX WIP |
|
|
if ($this->getVal('type') === 'creation_consultation') { |
|
|
// |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val['consultation'] = $this->get_consultation_data($this->getVal('object_id')); |
|
|
$val['service'] = $this->get_service_data($val['consultation']['service']); |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
2052 |
} |
} |
2053 |
// |
|
2054 |
if ($this->getVal('type') === 'envoi_CL') { |
// Si l'objet de référence n'existe pas log le numéro de la tâche concerné et |
2055 |
|
// renvoie une payload contenant le message d'erreur. |
2056 |
|
// Sinon constitue la payload du json. |
2057 |
|
if (! $objectRefExist) { |
2058 |
|
$this->f->addToLog( |
2059 |
|
sprintf( |
2060 |
|
__('Impossible de récupérer la payload car l\'objet de réference n\'existe pas pour la tâche : %s'), |
2061 |
|
$val_task['task'] |
2062 |
|
), |
2063 |
|
DEBUG_MODE |
2064 |
|
); |
2065 |
|
$val = __('Impossible de recuperer la payload car l\'objet de reference n\'existe pas.'); |
2066 |
|
} else { |
2067 |
|
|
2068 |
|
// L'historique n'est pas nécessaire dans l'affichage en JSON |
2069 |
|
if ($in_field === true) { |
2070 |
|
$val_task['timestamp_log'] = json_decode($val_task['timestamp_log'], true); |
2071 |
|
} else { |
2072 |
|
unset($val_task['timestamp_log']); |
2073 |
|
} |
2074 |
|
unset($val_task['timestamp_log_hidden']); |
2075 |
|
$val['task'] = $val_task; |
2076 |
// |
// |
2077 |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
if ($this->getVal('type') === 'creation_DA' |
2078 |
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
|| $this->getVal('type') === 'modification_DA') { |
2079 |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($val['dossier']['dossier_autorisation']); |
// |
2080 |
$val_external_uid = array(); |
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($this->getVal('object_id')); |
2081 |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_autorisation'); |
2082 |
$val_external_uid['dossier'] = $this->get_external_uid($this->getVal('dossier'), 'dossier'); |
$val['dossier_autorisation_parcelle'] = $this->get_parcelles_data('dossier_autorisation', $val['dossier_autorisation']['dossier_autorisation']); |
2083 |
$val_external_uid['decision'] = $this->get_external_uid($this->getVal('object_id'), 'instruction'); |
$val_external_uid = array(); |
2084 |
if ($val_external_uid['decision'] === '') { |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier_autorisation']['dossier_autorisation'], 'dossier_autorisation'); |
2085 |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
$val['external_uids'] = $val_external_uid; |
|
"obj" => "instruction", |
|
|
"idx" => $this->getVal('object_id'), |
|
|
)); |
|
|
$val_external_uid['decision'] = $this->get_external_uid($inst_instruction->get_related_instructions_next('retour_signature'), 'instruction'); |
|
2086 |
} |
} |
2087 |
$val['external_uids'] = $val_external_uid; |
// |
2088 |
} |
if ($this->getVal('type') === 'creation_DI' |
2089 |
if ($this->getVal('type') === 'notification_instruction' |
|| $this->getVal('type') === 'modification_DI' |
2090 |
|| $this->getVal('type') === 'notification_recepisse' |
|| $this->getVal('type') === 'depot_DI') { |
2091 |
|| $this->getVal('type') === 'notification_decision' |
// |
2092 |
|| $this->getVal('type') === 'notification_service_consulte' |
$val['dossier'] = $this->get_dossier_data($this->getVal('object_id')); |
2093 |
|| $this->getVal('type') === 'notification_tiers_consulte') { |
$val['donnees_techniques'] = $this->get_donnees_techniques_data($this->getVal('object_id'), 'dossier_instruction'); |
2094 |
// |
$val['demandeur'] = $this->get_demandeurs_data($val['dossier']['dossier']); |
2095 |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
$architecte = isset($val['donnees_techniques']['architecte']) === true ? $val['donnees_techniques']['architecte'] : null; |
2096 |
$dossier_id = isset($val['dossier']['dossier']) === true ? $val['dossier']['dossier'] : null; |
$val['architecte'] = $this->get_architecte_data($architecte); |
2097 |
$val['demandeur'] = $this->get_demandeurs_data($dossier_id); |
$val['dossier_parcelle'] = $this->get_parcelles_data('dossier', $val['dossier']['dossier']); |
2098 |
$val['instruction_notification'] = $this->get_instruction_notification_data($this->getVal('category'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
$val_external_uid = array(); |
2099 |
$instruction_id = isset($val['instruction_notification']['instruction']) === true ? $val['instruction_notification']['instruction'] : null; |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2100 |
$instruction_annexes = isset($val['instruction_notification']['annexes']) === true ? $val['instruction_notification']['annexes'] : null; |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2101 |
$val['instruction'] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $instruction_id)); |
$val['external_uids'] = $val_external_uid; |
2102 |
// Précise qu'il s'agit d'une instruction final si l'instruction est liée à une |
} |
2103 |
// demande dont le type ne génère pas de dossier |
// |
2104 |
if ($this->is_demande_instruction_recepisse_without_dossier($instruction_id) === true) { |
if ($this->getVal('type') === 'qualification_DI') { |
2105 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2106 |
|
$val_external_uid = array(); |
2107 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2108 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2109 |
|
$val['external_uids'] = $val_external_uid; |
2110 |
|
} |
2111 |
|
// |
2112 |
|
if ($this->getVal('type') === 'ajout_piece') { |
2113 |
|
$val['document_numerise'] = $this->get_document_numerise_data($this->getVal('object_id')); |
2114 |
|
$val['dossier'] = $this->get_dossier_data($val['document_numerise']['dossier']); |
2115 |
|
$val_external_uid = array(); |
2116 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2117 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2118 |
|
$val_external_uid['piece'] = $this->get_external_uid($val['document_numerise']['document_numerise'], 'piece'); |
2119 |
|
$val['external_uids'] = $val_external_uid; |
2120 |
|
} |
2121 |
|
// |
2122 |
|
if ($this->getVal('type') === 'decision_DI') { |
2123 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2124 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
2125 |
$val['instruction']['final'] = 't'; |
$val['instruction']['final'] = 't'; |
2126 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
2127 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
2128 |
|
} |
2129 |
|
$val_external_uid = array(); |
2130 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2131 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2132 |
|
$val['external_uids'] = $val_external_uid; |
2133 |
} |
} |
2134 |
// |
// |
2135 |
if (is_array($instruction_annexes) && $instruction_annexes != array()) { |
if ($this->getVal('type') === 'incompletude_DI') { |
2136 |
$val['instruction_annexe'] = array(); |
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2137 |
$numAnnexe = 0; |
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
2138 |
foreach ($instruction_annexes as $annexe) { |
$val_external_uid = array(); |
2139 |
if ($annexe['document_type'] === 'instruction') { |
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2140 |
$val['instruction_annexe']['annexe_'.$numAnnexe++] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $annexe['document_id'])); |
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2141 |
} elseif ($annexe['document_type'] === 'consultation') { |
$val['external_uids'] = $val_external_uid; |
2142 |
$val['instruction_annexe']['annexe_'.$numAnnexe++] = $this->get_consultation_data($annexe['document_id']); |
} |
2143 |
} |
// |
2144 |
|
if ($this->getVal('type') === 'completude_DI') { |
2145 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2146 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
2147 |
|
$val_external_uid = array(); |
2148 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2149 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2150 |
|
$val['external_uids'] = $val_external_uid; |
2151 |
|
} |
2152 |
|
// |
2153 |
|
if ($this->getVal('type') === 'lettre_incompletude' |
2154 |
|
|| $this->getVal('type') === 'lettre_majoration') { |
2155 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2156 |
|
$val['instruction'] = $this->get_instruction_data($val['dossier']['dossier'], 'with-id', array('with-id' => $this->getVal('object_id'))); |
2157 |
|
$val['lettre_petitionnaire'] = $this->get_lettre_petitionnaire_data($val['dossier']['dossier'], $this->getVal('type')); |
2158 |
|
$val_external_uid = array(); |
2159 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2160 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2161 |
|
$val['external_uids'] = $val_external_uid; |
2162 |
|
} |
2163 |
|
// |
2164 |
|
if ($this->getVal('type') === 'pec_metier_consultation') { |
2165 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2166 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2167 |
|
$val_external_uid = array(); |
2168 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2169 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2170 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
2171 |
|
$val['external_uids'] = $val_external_uid; |
2172 |
|
} |
2173 |
|
// |
2174 |
|
if ($this->getVal('type') === 'avis_consultation') { |
2175 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2176 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2177 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
2178 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
2179 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
2180 |
} |
} |
2181 |
|
$val_external_uid = array(); |
2182 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2183 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2184 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
2185 |
|
$val_external_uid['avis_dossier_consultation'] = $this->get_external_uid($this->getVal('object_id'), 'avis_dossier_consultation'); |
2186 |
|
$val['external_uids'] = $val_external_uid; |
2187 |
|
} |
2188 |
|
// XXX WIP |
2189 |
|
if ($this->getVal('type') === 'creation_consultation') { |
2190 |
|
// |
2191 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2192 |
|
$val['consultation'] = $this->get_consultation_data($this->getVal('object_id')); |
2193 |
|
$val['service'] = $this->get_service_data($val['consultation']['service']); |
2194 |
|
$val_external_uid = array(); |
2195 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2196 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2197 |
|
$val['external_uids'] = $val_external_uid; |
2198 |
|
} |
2199 |
|
// |
2200 |
|
if ($this->getVal('type') === 'envoi_CL') { |
2201 |
|
// |
2202 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2203 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2204 |
|
$val['dossier_autorisation'] = $this->get_dossier_autorisation_data($val['dossier']['dossier_autorisation']); |
2205 |
|
$val_external_uid = array(); |
2206 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2207 |
|
$val_external_uid['dossier'] = $this->get_external_uid($this->getVal('dossier'), 'dossier'); |
2208 |
|
$val_external_uid['decision'] = $this->get_external_uid($this->getVal('object_id'), 'instruction'); |
2209 |
|
if ($val_external_uid['decision'] === '') { |
2210 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
2211 |
|
"obj" => "instruction", |
2212 |
|
"idx" => $this->getVal('object_id'), |
2213 |
|
)); |
2214 |
|
$val_external_uid['decision'] = $this->get_external_uid($inst_instruction->get_related_instructions_next('retour_signature'), 'instruction'); |
2215 |
|
} |
2216 |
|
$val['external_uids'] = $val_external_uid; |
2217 |
|
} |
2218 |
|
if ($this->getVal('type') === 'notification_instruction' |
2219 |
|
|| $this->getVal('type') === 'notification_recepisse' |
2220 |
|
|| $this->getVal('type') === 'notification_decision' |
2221 |
|
|| $this->getVal('type') === 'notification_service_consulte' |
2222 |
|
|| $this->getVal('type') === 'notification_tiers_consulte' |
2223 |
|
|| $this->getVal('type') === 'notification_signataire') { |
2224 |
|
// |
2225 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2226 |
|
$dossier_id = isset($val['dossier']['dossier']) === true ? $val['dossier']['dossier'] : null; |
2227 |
|
$val['demandeur'] = $this->get_demandeurs_data($dossier_id); |
2228 |
|
$val['instruction_notification'] = $this->get_instruction_notification_data($this->getVal('category'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2229 |
|
$instruction_id = isset($val['instruction_notification']['instruction']) === true ? $val['instruction_notification']['instruction'] : null; |
2230 |
|
$instruction_annexes = isset($val['instruction_notification']['annexes']) === true ? $val['instruction_notification']['annexes'] : null; |
2231 |
|
$val['instruction'] = $this->get_instruction_data($dossier_id, 'with-id', array('with-id' => $instruction_id)); |
2232 |
|
// Précise qu'il s'agit d'une instruction final si l'instruction est liée à une |
2233 |
|
// demande dont le type ne génère pas de dossier |
2234 |
|
if ($this->is_demande_instruction_recepisse_without_dossier($instruction_id) === true) { |
2235 |
|
$val['instruction']['final'] = 't'; |
2236 |
|
} |
2237 |
|
$val_external_uid = array(); |
2238 |
|
// Affiche l'identifiant externe lié à l'instruction si cette combinaison existe, sinon celui lié au dossier |
2239 |
|
$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'); |
2240 |
|
$val_external_uid['demande (instruction)'] = $this->get_external_uid($instruction_id, 'demande', PORTAL, 'ASC'); |
2241 |
|
$val_external_uid['instruction_notification'] = $this->get_external_uid($this->getVal('object_id'), 'instruction_notification', PORTAL); |
2242 |
|
$val['external_uids'] = $val_external_uid; |
2243 |
|
} |
2244 |
|
// |
2245 |
|
if ($this->getVal('type') === 'prescription') { |
2246 |
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
2247 |
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
2248 |
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
2249 |
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
2250 |
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
2251 |
|
} |
2252 |
|
$val_external_uid = array(); |
2253 |
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
2254 |
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
2255 |
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
2256 |
|
$val_external_uid['prescription'] = $this->get_external_uid($this->getVal('object_id'), 'prescription'); |
2257 |
|
$val['external_uids'] = $val_external_uid; |
2258 |
} |
} |
|
$val_external_uid = array(); |
|
|
// Affiche l'identifiant externe lié à l'instruction si cette combinaison existe, sinon celui lié au dossier |
|
|
$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'); |
|
|
$val_external_uid['demande (instruction)'] = $this->get_external_uid($instruction_id, 'demande', 'portal', 'ASC'); |
|
|
$val_external_uid['instruction_notification'] = $this->get_external_uid($this->getVal('object_id'), 'instruction_notification', 'portal'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
|
} |
|
|
// |
|
|
if ($this->getVal('type') === 'prescription') { |
|
|
$val['dossier'] = $this->get_dossier_data($this->getVal('dossier')); |
|
|
$val['instruction'] = $this->get_instruction_data($this->getVal('dossier'), 'with-id', array('with-id' => $this->getVal('object_id'))); |
|
|
$val['avis_decision'] = $this->get_avis_decision_data($this->getVal('dossier')); |
|
|
if (isset($val['instruction']['signataire_arrete']) === true) { |
|
|
$val['signataire_arrete'] = $this->get_signataire_arrete_data($val['instruction']['signataire_arrete']); |
|
|
} |
|
|
$val_external_uid = array(); |
|
|
$val_external_uid['dossier_autorisation'] = $this->get_external_uid($val['dossier']['dossier_autorisation'], 'dossier_autorisation'); |
|
|
$val_external_uid['dossier'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier'); |
|
|
$val_external_uid['dossier_consultation'] = $this->get_external_uid($val['dossier']['dossier'], 'dossier_consultation'); |
|
|
$val_external_uid['prescription'] = $this->get_external_uid($this->getVal('object_id'), 'prescription'); |
|
|
$val['external_uids'] = $val_external_uid; |
|
2259 |
} |
} |
2260 |
|
|
2261 |
if ($in_field === true) { |
if ($in_field === true) { |
2277 |
'state' => $this->f->get_submitted_post_value('state') |
'state' => $this->f->get_submitted_post_value('state') |
2278 |
), |
), |
2279 |
); |
); |
2280 |
|
if ($this->f->get_submitted_post_value('comment') !== null) { |
2281 |
|
$params['comment'] = $this->f->get_submitted_post_value('comment'); |
2282 |
|
} |
2283 |
$update = $this->update_task($params); |
$update = $this->update_task($params); |
2284 |
$message_class = "valid"; |
$message_class = "valid"; |
2285 |
$message = $this->msg; |
$message = $this->msg; |
2296 |
} |
} |
2297 |
|
|
2298 |
// Sauvegarde de l'uid externe retourné |
// Sauvegarde de l'uid externe retourné |
2299 |
if ($this->f->get_submitted_post_value('external_uid') !== null) { |
$external_uid = $this->f->get_submitted_post_value('external_uid'); |
2300 |
|
if ($external_uid !== null) { |
2301 |
// |
// |
2302 |
$objects = $this->get_objects_by_task_type($this->getVal('type'), $this->getVal('stream')); |
$objects = $this->get_objects_by_task_type($this->getVal('type'), $this->getVal('stream')); |
2303 |
|
// Si l'identifiant externe contient le préfixe pour identifier les codes de suivi, |
2304 |
|
// le seul objet concerné sera celui du code de suivi |
2305 |
|
if (strpos($external_uid, self::CS_PREFIX) !== false) { |
2306 |
|
$objects = array('code-suivi', ); |
2307 |
|
$external_uid = str_replace(self::CS_PREFIX, '', $external_uid); |
2308 |
|
} |
2309 |
foreach ($objects as $object) { |
foreach ($objects as $object) { |
2310 |
$inst_lien = $this->f->get_inst__om_dbform(array( |
$inst_lien = $this->f->get_inst__om_dbform(array( |
2311 |
"obj" => "lien_id_interne_uid_externe", |
"obj" => "lien_id_interne_uid_externe", |
2312 |
"idx" => ']', |
"idx" => ']', |
2313 |
)); |
)); |
2314 |
$object_id = $this->getVal('object_id'); |
$object_id = $this->getVal('object_id'); |
2315 |
$is_exists = $inst_lien->is_exists($object, $object_id, $this->f->get_submitted_post_value('external_uid'), $this->getVal('dossier')); |
$is_exists = $inst_lien->is_exists($object, $object_id, $external_uid, $this->getVal('dossier')); |
2316 |
// Dans le cas spécifique de la mise à jour d'une notification |
// Dans le cas spécifique de la mise à jour d'une notification |
2317 |
// et de la création d'une liaison d'identifiant pour l'objet demande, |
// et de la création d'une liaison d'identifiant pour l'objet demande, |
2318 |
// l'identifiant de l'objet n'est plus celui de la notification |
// l'identifiant de l'objet n'est plus celui de la notification |
2322 |
|| $this->getVal('type') === 'notification_instruction' |
|| $this->getVal('type') === 'notification_instruction' |
2323 |
|| $this->getVal('type') === 'notification_decision' |
|| $this->getVal('type') === 'notification_decision' |
2324 |
|| $this->getVal('type') === 'notification_service_consulte' |
|| $this->getVal('type') === 'notification_service_consulte' |
2325 |
|| $this->getVal('type') === 'notification_tiers_consulte')) { |
|| $this->getVal('type') === 'notification_tiers_consulte' |
2326 |
|
|| $this->getVal('type') === 'notification_signataire')) { |
2327 |
// |
// |
2328 |
$object_id = $this->getVal('dossier'); |
$object_id = $this->getVal('dossier'); |
2329 |
// Il ne doit y avoir qu'une liaison entre le numéro du dossier interne et un uid externe de "demande" |
// Il ne doit y avoir qu'une liaison entre le numéro du dossier interne et un uid externe de "demande" |
2334 |
'lien_id_interne_uid_externe' => '', |
'lien_id_interne_uid_externe' => '', |
2335 |
'object' => $object, |
'object' => $object, |
2336 |
'object_id' => $object_id, |
'object_id' => $object_id, |
2337 |
'external_uid' => $this->f->get_submitted_post_value('external_uid'), |
'external_uid' => $external_uid, |
2338 |
'dossier' => $this->getVal('dossier'), |
'dossier' => $this->getVal('dossier'), |
2339 |
'category' => $this->getVal('category'), |
'category' => $this->getVal('category'), |
2340 |
); |
); |
2361 |
$result = $this->add_task(array( |
$result = $this->add_task(array( |
2362 |
'val' => array( |
'val' => array( |
2363 |
'stream' => 'input', |
'stream' => 'input', |
2364 |
'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'), ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401), |
2365 |
'type' => $this->f->get_submitted_post_value('type'), |
'type' => $this->f->get_submitted_post_value('type'), |
2366 |
'category' => $this->f->get_submitted_post_value('category'), |
'category' => $this->f->get_submitted_post_value('category'), |
2367 |
) |
) |
2387 |
function setLayout(&$form, $maj) { |
function setLayout(&$form, $maj) { |
2388 |
// |
// |
2389 |
$form->setBloc('json_payload', 'D', '', 'col_6'); |
$form->setBloc('json_payload', 'D', '', 'col_6'); |
2390 |
$form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed"); |
$fieldset_title_payload = __("json_payload (calculée)"); |
2391 |
|
if ($this->getVal('json_payload') !== "{}") { |
2392 |
|
$fieldset_title_payload = __("json_payload"); |
2393 |
|
} |
2394 |
|
$form->setFieldset('json_payload', 'DF', $fieldset_title_payload, "collapsible, startClosed"); |
2395 |
$form->setBloc('json_payload', 'F'); |
$form->setBloc('json_payload', 'F'); |
2396 |
$form->setBloc('timestamp_log', 'DF', __("historique"), 'col_9 timestamp_log_jsontotab'); |
$form->setBloc('timestamp_log', 'DF', __("historique"), 'col_9 timestamp_log_jsontotab'); |
2397 |
} |
} |
2420 |
&& $stream === 'input') { |
&& $stream === 'input') { |
2421 |
$objects = array('dossier', 'dossier_autorisation', 'demande', ); |
$objects = array('dossier', 'dossier_autorisation', 'demande', ); |
2422 |
} |
} |
2423 |
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
if (in_array($type, array( |
2424 |
|
'decision_DI', |
2425 |
|
'incompletude_DI', |
2426 |
|
'completude_DI', |
2427 |
|
'lettre_incompletude', |
2428 |
|
'lettre_majoration' |
2429 |
|
)) === true) { |
2430 |
$objects = array('instruction', ); |
$objects = array('instruction', ); |
2431 |
} |
} |
2432 |
if (in_array($type, array('envoi_CL', )) === true) { |
if (in_array($type, array('envoi_CL', )) === true) { |
2470 |
'notification_decision', |
'notification_decision', |
2471 |
'notification_service_consulte', |
'notification_service_consulte', |
2472 |
'notification_tiers_consulte', |
'notification_tiers_consulte', |
2473 |
|
'notification_signataire', |
2474 |
) |
) |
2475 |
) === true) { |
) === true) { |
2476 |
$objects = array('instruction_notification', 'demande', ); |
$objects = array('instruction_notification', 'demande', ); |
2504 |
&& $stream === 'input') { |
&& $stream === 'input') { |
2505 |
$tables = array('dossier', 'dossier_autorisation', 'demande', ); |
$tables = array('dossier', 'dossier_autorisation', 'demande', ); |
2506 |
} |
} |
2507 |
if (in_array($type, array('decision_DI', 'incompletude_DI', 'completude_DI', )) === true) { |
if (in_array($type, array( |
2508 |
|
'decision_DI', |
2509 |
|
'incompletude_DI', |
2510 |
|
'completude_DI', |
2511 |
|
'lettre_incompletude', |
2512 |
|
'lettre_majoration' |
2513 |
|
)) === true) { |
2514 |
$tables = array('instruction', ); |
$tables = array('instruction', ); |
2515 |
} |
} |
2516 |
|
if (in_array($type, array('envoi_CL', )) === true) { |
2517 |
|
$objects = array('instruction', ); |
2518 |
|
} |
2519 |
if (in_array($type, array('pec_metier_consultation', )) === true |
if (in_array($type, array('pec_metier_consultation', )) === true |
2520 |
&& $stream === 'output') { |
&& $stream === 'output') { |
2521 |
$tables = array('instruction', ); |
$tables = array('instruction', ); |
2553 |
'notification_instruction', |
'notification_instruction', |
2554 |
'notification_decision', |
'notification_decision', |
2555 |
'notification_service_consulte', |
'notification_service_consulte', |
2556 |
'notification_tiers_consulte' |
'notification_tiers_consulte', |
2557 |
|
'notification_signataire' |
2558 |
) |
) |
2559 |
) === true) { |
) === true) { |
2560 |
$tables = array('instruction_notification', ); |
$tables = array('instruction_notification', ); |
2562 |
return $tables; |
return $tables; |
2563 |
} |
} |
2564 |
|
|
2565 |
|
/** |
2566 |
|
* Vérifie si l'objet référencé par la tâche existe en base de données. |
2567 |
|
* |
2568 |
|
* Récupère la liste des tables de référence associé à la tâche à partir |
2569 |
|
* du type de tâche et de son flux (input ou output). |
2570 |
|
* Pour chaque table potentiellement référencé par la tâche on essaye d'instancier |
2571 |
|
* l'objet correspondant à partir de l'identifiant de l'objet de référence de la tâche. |
2572 |
|
* Si l'élément instancié existe renvoie true sinon renvoie false. |
2573 |
|
* |
2574 |
|
* @param string|integer $taskObjectId : identifiant de l'objet de référence de la tâche |
2575 |
|
* @param string $taskType : type de la tâche |
2576 |
|
* @param string $taskStream : flux entrant (output - valeur par défaut) ou sortant (input) |
2577 |
|
* @return boolean |
2578 |
|
*/ |
2579 |
|
protected function does_referenced_object_exist($taskObjectId, string $taskType, string $taskStream = 'output') { |
2580 |
|
$refTables = $this->get_tables_by_task_type($taskType, $taskStream); |
2581 |
|
if (empty($refTables) === true) { |
2582 |
|
$this->f->addToLog( |
2583 |
|
sprintf( |
2584 |
|
__("Impossible de vérifier si l'objet de référence existe, car le type de task '%s' n'a pas de correspondance avec une table dans la méthode %s."), |
2585 |
|
$taskType, |
2586 |
|
"get_tables_by_task_type()" |
2587 |
|
), |
2588 |
|
DEBUG_MODE |
2589 |
|
); |
2590 |
|
return true; |
2591 |
|
} |
2592 |
|
foreach ($refTables as $table) { |
2593 |
|
$inst = $this->f->get_inst__om_dbform(array( |
2594 |
|
'obj' => $table, |
2595 |
|
'idx' => $taskObjectId |
2596 |
|
)); |
2597 |
|
if ($inst->exists() === true) { |
2598 |
|
return true; |
2599 |
|
} |
2600 |
|
} |
2601 |
|
return false; |
2602 |
|
} |
2603 |
|
|
2604 |
} |
} |