80 |
'annee' => 'getDossierAnnee', |
'annee' => 'getDossierAnnee', |
81 |
'division' => 'getDossierDivision', |
'division' => 'getDossierDivision', |
82 |
'collectivite' => 'getDossierServiceOrCollectivite', |
'collectivite' => 'getDossierServiceOrCollectivite', |
|
'titre_document' => 'getDocumentTitre' |
|
83 |
), |
), |
84 |
"arrete" => array( |
"arrete" => array( |
85 |
"numArrete" => "getNumArrete", |
"numArrete" => "getNumArrete", |
96 |
"ap_ville" => "getAp_ville", |
"ap_ville" => "getAp_ville", |
97 |
"activite" => "getActivite", |
"activite" => "getActivite", |
98 |
"dateControleLegalite" => "getDateControleLegalite", |
"dateControleLegalite" => "getDateControleLegalite", |
|
'titre_document' => 'getDocumentTitre' |
|
99 |
) |
) |
100 |
); |
); |
101 |
|
|
411 |
"permission_suffix" => "envoyer_a_signature", |
"permission_suffix" => "envoyer_a_signature", |
412 |
); |
); |
413 |
|
|
414 |
|
// ACTION - 404 - Annuler l'envoi en signature |
415 |
|
// Cet évenement permet d'annuler l'envoi en signature du document au parapheur |
416 |
|
$this->class_actions[404] = array( |
417 |
|
"identifier" => "annuler_envoi_signature", |
418 |
|
"portlet" => array( |
419 |
|
"libelle" => __("Annuler l'envoi en signature"), |
420 |
|
"type" => "action-direct-with-confirmation", |
421 |
|
"class" => "annuler_envoi_signature-16", |
422 |
|
), |
423 |
|
"view" => "formulaire", |
424 |
|
"method" => "annuler_envoi_en_signature", |
425 |
|
"condition" => array( |
426 |
|
"is_sent_for_signature", |
427 |
|
"is_parapheur_annulation_parameter_enabled" |
428 |
|
), |
429 |
|
"permission_suffix" => "envoyer_a_signature", |
430 |
|
); |
431 |
|
|
432 |
// |
// |
433 |
$this->class_actions[401] = array( |
$this->class_actions[401] = array( |
434 |
"identifier" => "preview_edition", |
"identifier" => "preview_edition", |
446 |
), |
), |
447 |
"condition" => array( |
"condition" => array( |
448 |
"is_notifiable_by_task_manual", |
"is_notifiable_by_task_manual", |
449 |
"is_not_portail_notification" |
"is_not_portail_notification_sans_annexe" |
450 |
), |
), |
451 |
"view" => "view_overlay_notification_manuelle", |
"view" => "view_overlay_notification_manuelle", |
452 |
"permission_suffix" => "modifier", |
"permission_suffix" => "modifier", |
453 |
); |
); |
454 |
|
|
455 |
// ACTION - 410 - Notifier les pétitionnaires (portail citoyen) |
// ACTION - 411 - Notifier les pétitionnaires (portail citoyen) |
456 |
$this->class_actions[411] = array( |
$this->class_actions[411] = array( |
457 |
"identifier" => "notification_manuelle_portal", |
"identifier" => "notification_manuelle_portal", |
458 |
"portlet" => array( |
"portlet" => array( |
462 |
), |
), |
463 |
"condition" => array( |
"condition" => array( |
464 |
"is_notifiable_by_task_manual", |
"is_notifiable_by_task_manual", |
465 |
"is_portail_notification" |
"is_portail_notification_sans_annexe" |
466 |
), |
), |
467 |
"method" => "notifier_demandeur_principal", |
"method" => "notifier_demandeur_principal", |
468 |
"permission_suffix" => "modifier", |
"permission_suffix" => "modifier", |
469 |
); |
); |
470 |
|
|
471 |
|
// ACTION - 420 - Notifier les services consultés (mail) |
472 |
|
$this->class_actions[420] = array( |
473 |
|
"identifier" => "overlay_notification_service_consulte", |
474 |
|
"portlet" => array( |
475 |
|
"libelle" => __("Notifier les services consultés"), |
476 |
|
"type" => "action-self", |
477 |
|
"class" => "notifier_commune-16", |
478 |
|
), |
479 |
|
"condition" => array( |
480 |
|
"is_service_notifiable" |
481 |
|
), |
482 |
|
"view" => "view_overlay_notification_service_consulte", |
483 |
|
"permission_suffix" => "tab", |
484 |
|
); |
485 |
|
|
486 |
|
// ACTION - 430 - Notifier les tiers consultés (mail) |
487 |
|
$this->class_actions[430] = array( |
488 |
|
"identifier" => "overlay_notification_tiers_consulte", |
489 |
|
"portlet" => array( |
490 |
|
"libelle" => __("Notifier les tiers consultés"), |
491 |
|
"type" => "action-self", |
492 |
|
"class" => "notifier_commune-16", |
493 |
|
), |
494 |
|
"condition" => array( |
495 |
|
"is_tiers_notifiable" |
496 |
|
), |
497 |
|
"view" => "view_overlay_notification_tiers_consulte", |
498 |
|
"permission_suffix" => "tab", |
499 |
|
); |
500 |
|
|
501 |
|
// |
502 |
|
$this->class_actions[403] = array( |
503 |
|
"identifier" => "envoyer_au_controle_de_legalite", |
504 |
|
"portlet" => array( |
505 |
|
"libelle" => __("Envoyer au contrôle de légalité"), |
506 |
|
"type" => "action-direct-with-confirmation", |
507 |
|
"class" => "envoyer_au_controle_de_legalite-16", |
508 |
|
), |
509 |
|
"view" => "formulaire", |
510 |
|
"method" => "envoyer_au_controle_de_legalite", |
511 |
|
"condition" => array( |
512 |
|
"can_be_sended_to_cl" |
513 |
|
), |
514 |
|
"permission_suffix" => "envoyer_au_controle_de_legalite", |
515 |
|
); |
516 |
|
|
517 |
// |
// |
518 |
$this->class_actions[998] = array( |
$this->class_actions[998] = array( |
519 |
"identifier" => "json_data", |
"identifier" => "json_data", |
643 |
"commentaire_signature", |
"commentaire_signature", |
644 |
"historique_signature", |
"historique_signature", |
645 |
"'' as suivi_notification", |
"'' as suivi_notification", |
646 |
|
"'' as suivi_notification_service", |
647 |
|
"'' as suivi_notification_tiers", |
648 |
|
"'' as suivi_notification_commune", |
649 |
|
|
650 |
"'' as preview_edition", |
"'' as preview_edition", |
651 |
|
"envoye_cl_platau", |
652 |
|
"'' as log_instruction" |
653 |
); |
); |
654 |
} |
} |
655 |
|
|
711 |
return true; |
return true; |
712 |
} |
} |
713 |
|
|
714 |
|
/** |
715 |
|
* CONDITION - is_parapheur_annulation_parameter_enabled |
716 |
|
* |
717 |
|
* Vérifie que l'option d'annulation de l'envoi en signature est activée. |
718 |
|
* |
719 |
|
* @return boolean |
720 |
|
*/ |
721 |
|
function is_parapheur_annulation_parameter_enabled() { |
722 |
|
//Instanciation de la classe electronicsignature |
723 |
|
$inst_es = $this->get_electronicsignature_instance(); |
724 |
|
if ($inst_es === false) { |
725 |
|
return false; |
726 |
|
} |
727 |
|
|
728 |
|
if ($inst_es->get_conf('cancel_send') !== 'true' && $inst_es->get_conf('cancel_send') !== true) { |
729 |
|
return false; |
730 |
|
} |
731 |
|
|
732 |
|
return true; |
733 |
|
} |
734 |
|
|
735 |
|
|
736 |
/** |
/** |
737 |
* CONDITION - is_sent_for_signature |
* CONDITION - is_sent_for_signature |
748 |
if ($this->has_connector_electronicsignature() === true |
if ($this->has_connector_electronicsignature() === true |
749 |
&& empty($this->getVal("id_parapheur_signature")) === false |
&& empty($this->getVal("id_parapheur_signature")) === false |
750 |
&& ($this->getVal("statut_signature") != "canceled" |
&& ($this->getVal("statut_signature") != "canceled" |
751 |
|| $this->getVal("statut_signature") != "expired" |
&& $this->getVal("statut_signature") != "expired" |
752 |
|| $this->getVal("statut_signature") != "finished")) { |
&& $this->getVal("statut_signature") != "finished")) { |
753 |
// |
// |
754 |
return true; |
return true; |
755 |
} |
} |
765 |
* @return boolean |
* @return boolean |
766 |
*/ |
*/ |
767 |
function is_not_sent_for_signature() { |
function is_not_sent_for_signature() { |
768 |
|
// Contrôle si l'utilisateur possède un bypass |
769 |
|
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_definaliser_bypass"); |
770 |
|
if ($bypass == true) { |
771 |
|
return true; |
772 |
|
} |
773 |
|
|
774 |
return !$this->is_sent_for_signature(); |
return !$this->is_sent_for_signature(); |
775 |
} |
} |
776 |
|
|
797 |
return false; |
return false; |
798 |
} |
} |
799 |
|
|
800 |
|
|
801 |
|
/** |
802 |
|
* is_sent_to_cl |
803 |
|
* |
804 |
|
* Vérifie que l'instruction a été envoyé au contrôle de légalité |
805 |
|
* |
806 |
|
* @return boolean |
807 |
|
*/ |
808 |
|
function is_sent_to_cl() { |
809 |
|
// Si la case à cocher de l'instruction envoye_cl_platau est à "t" |
810 |
|
if ($this->getVal('envoye_cl_platau') === 't') { |
811 |
|
// |
812 |
|
return true; |
813 |
|
} |
814 |
|
// |
815 |
|
return false; |
816 |
|
} |
817 |
|
|
818 |
/** |
/** |
819 |
* CONDITION - is_portail_notification |
* CONDITION - is_portail_notification |
820 |
* |
* |
822 |
* |
* |
823 |
* @return boolean |
* @return boolean |
824 |
*/ |
*/ |
825 |
function is_portail_notification() { |
function is_portail_notification_sans_annexe() { |
826 |
$collectiviteDi = $this->get_dossier_instruction_om_collectivite(); |
$collectiviteDi = $this->get_dossier_instruction_om_collectivite(); |
827 |
if ($this->f->get_param_option_notification($collectiviteDi) === null || |
$ev = $this->get_inst_evenement($this->getVal('evenement')); |
828 |
$this->f->get_param_option_notification($collectiviteDi) === 'portal') { |
if (($this->f->get_param_option_notification($collectiviteDi) === null || |
829 |
|
$this->f->get_param_option_notification($collectiviteDi) === 'portal') |
830 |
|
&& $ev->getVal('notification') != 'notification_manuelle_annexe' |
831 |
|
&& $ev->getVal('notification') != 'notification_manuelle_annexe_signature_requise' |
832 |
|
) { |
833 |
return true; |
return true; |
834 |
} |
} |
835 |
return false; |
return false; |
842 |
* |
* |
843 |
* @return boolean |
* @return boolean |
844 |
*/ |
*/ |
845 |
function is_not_portail_notification() { |
function is_not_portail_notification_sans_annexe() { |
846 |
return (! $this->is_portail_notification()); |
return (! $this->is_portail_notification_sans_annexe()); |
847 |
} |
} |
848 |
|
|
849 |
/** |
/** |
926 |
/** |
/** |
927 |
* CONDITION - can_display_notification |
* CONDITION - can_display_notification |
928 |
* |
* |
929 |
* Vérifie que le fieldset "Suivi notification" soit affichable |
* Vérifie que le champs "Suivi notification" est affichable |
930 |
* |
* |
931 |
* @return boolean |
* @return boolean |
932 |
*/ |
*/ |
933 |
function can_display_notification() { |
function can_display_notification_demandeur() { |
934 |
// Le suivi des notification est affiché si l'événement est notifiable |
// Le suivi des notification est affiché si l'événement est notifiable |
935 |
// et si des notifications ont été envoyées |
// et si des notifications ont été envoyées |
936 |
$evenement_id = $this->getVal("evenement"); |
$evenement_id = $this->getVal("evenement"); |
939 |
$inst_evenement->getVal('notification') != '') { |
$inst_evenement->getVal('notification') != '') { |
940 |
// Des notifications ont été envoyé si il existe au moins une notification |
// Des notifications ont été envoyé si il existe au moins une notification |
941 |
// liées à l'instruction |
// liées à l'instruction |
942 |
$idsNotifs = $this->get_instruction_notification($this->getVal($this->clePrimaire)); |
$idsNotifs = $this->get_instruction_notification( |
943 |
|
$this->getVal($this->clePrimaire), |
944 |
|
array( |
945 |
|
'notification_recepisse', |
946 |
|
'notification_instruction', |
947 |
|
'notification_decision', |
948 |
|
), |
949 |
|
true |
950 |
|
); |
951 |
if (isset($idsNotifs) && $idsNotifs !== array()) { |
if (isset($idsNotifs) && $idsNotifs !== array()) { |
952 |
return true; |
return true; |
953 |
} |
} |
956 |
} |
} |
957 |
|
|
958 |
/** |
/** |
959 |
|
* CONDITION - can_display_notification |
960 |
|
* |
961 |
|
* Vérifie que le champs "suivi_notification_service" est affichable |
962 |
|
* |
963 |
|
* @return boolean |
964 |
|
*/ |
965 |
|
function can_display_notification_service() { |
966 |
|
// Le suivi des notification est affiché si l'événement est notifiable |
967 |
|
// et si des notifications ont été envoyées |
968 |
|
$evenement_id = $this->getVal("evenement"); |
969 |
|
$inst_evenement = $this->get_inst_evenement($evenement_id); |
970 |
|
if ($this->get_boolean_from_pgsql_value($inst_evenement->getVal('notification_service')) == true) { |
971 |
|
// Des notifications ont été envoyé si il existe au moins une notification |
972 |
|
// de type notification_service_consulte liées à l'instruction |
973 |
|
$idsNotifs = $this->get_instruction_notification( |
974 |
|
$this->getVal($this->clePrimaire), |
975 |
|
'notification_service_consulte' |
976 |
|
); |
977 |
|
if (isset($idsNotifs) && $idsNotifs !== array()) { |
978 |
|
return true; |
979 |
|
} |
980 |
|
} |
981 |
|
return false; |
982 |
|
} |
983 |
|
|
984 |
|
|
985 |
|
/** |
986 |
|
* CONDITION - can_display_notification_tiers |
987 |
|
* |
988 |
|
* Vérifie que le champs "suivi_notification_tiers" est affichable |
989 |
|
* |
990 |
|
* @return boolean |
991 |
|
*/ |
992 |
|
function can_display_notification_tiers() { |
993 |
|
// Le suivi des notification est affiché si l'événement est notifiable |
994 |
|
// et si des notifications ont été envoyées |
995 |
|
$evenement_id = $this->getVal("evenement"); |
996 |
|
$inst_evenement = $this->get_inst_evenement($evenement_id); |
997 |
|
if ($this->get_boolean_from_pgsql_value($inst_evenement->getVal('notification_tiers')) == true) { |
998 |
|
// Des notifications ont été envoyé si il existe au moins une notification |
999 |
|
// de type notification_tiers_consulte liées à l'instruction |
1000 |
|
$idsNotifs = $this->get_instruction_notification( |
1001 |
|
$this->getVal($this->clePrimaire), |
1002 |
|
'notification_tiers_consulte' |
1003 |
|
); |
1004 |
|
if (isset($idsNotifs) && $idsNotifs !== array()) { |
1005 |
|
return true; |
1006 |
|
} |
1007 |
|
} |
1008 |
|
return false; |
1009 |
|
} |
1010 |
|
|
1011 |
|
/** |
1012 |
|
* CONDITION - can_display_notification_commune |
1013 |
|
* |
1014 |
|
* Vérifie que le champs "suivi_notification_commune" est affichable |
1015 |
|
* |
1016 |
|
* @return boolean |
1017 |
|
*/ |
1018 |
|
function can_display_notification_commune() { |
1019 |
|
// Le suivi des notification si il existe au moins une notification |
1020 |
|
// de type notification_depot_demat liées à l'instruction |
1021 |
|
$idsNotifs = $this->get_instruction_notification( |
1022 |
|
$this->getVal($this->clePrimaire), |
1023 |
|
array('notification_depot_demat', 'notification_commune') |
1024 |
|
); |
1025 |
|
if (isset($idsNotifs) && $idsNotifs !== array()) { |
1026 |
|
return true; |
1027 |
|
} |
1028 |
|
return false; |
1029 |
|
} |
1030 |
|
|
1031 |
|
/** |
1032 |
* TREATMENT - disable_edition_integrale. |
* TREATMENT - disable_edition_integrale. |
1033 |
* |
* |
1034 |
* Cette methode permet de passer la consultation en "lu" |
* Cette methode permet de passer la consultation en "lu" |
1162 |
} |
} |
1163 |
|
|
1164 |
// Les champs historique_signature et statut_signature ne sont pas saisissable dans tous les cas |
// Les champs historique_signature et statut_signature ne sont pas saisissable dans tous les cas |
1165 |
if ($this->can_display_parapheur() === true) { |
if ($this->can_display_parapheur() === true && $maj == 3) { |
1166 |
$form->setType('statut_signature', 'selectstatic'); |
$form->setType('statut_signature', 'selectstatic'); |
1167 |
$form->setType('historique_signature', 'jsontotab'); |
$form->setType('historique_signature', 'jsontotab'); |
1168 |
if ($this->getVal('commentaire_signature') == null) { |
if ($this->getVal('commentaire_signature') == null) { |
1172 |
} |
} |
1173 |
} |
} |
1174 |
|
|
1175 |
// Le champ de suivi des notifications n'est pas affichable dans tous les cas |
// Le champ de suivi des notifications des demandeurs n'est pas affichable dans tous les cas |
1176 |
if ($this->can_display_notification() === true && $maj == 3) { |
if ($maj == 3 && $this->can_display_notification_demandeur() === true) { |
1177 |
$form->setType('suivi_notification', 'jsontotab'); |
$form->setType('suivi_notification', 'jsontotab'); |
1178 |
} |
} |
1179 |
|
// Le champ de suivi des notifications des services n'est pas affichable dans tous les cas |
1180 |
|
if ($maj == 3 && $this->can_display_notification_service() === true) { |
1181 |
|
$form->setType('suivi_notification_service', 'jsontotab'); |
1182 |
|
} |
1183 |
|
// Le champ de suivi des notifications des tiers n'est pas affichable dans tous les cas |
1184 |
|
if ($maj == 3 && $this->can_display_notification_tiers() === true) { |
1185 |
|
$form->setType('suivi_notification_tiers', 'jsontotab'); |
1186 |
|
} |
1187 |
|
// Le champ de suivi des notifications des communes n'est pas affichable dans tous les cas |
1188 |
|
if ($maj == 3 && $this->can_display_notification_commune() === true) { |
1189 |
|
$form->setType('suivi_notification_commune', 'jsontotab'); |
1190 |
|
} |
1191 |
|
|
1192 |
// MODE AJOUTER |
// MODE AJOUTER |
1193 |
if ($this->getParameter('maj') == 0) { |
if ($this->getParameter('maj') == 0) { |
1248 |
$form->setType('btn_refresh', 'httpclickbutton'); |
$form->setType('btn_refresh', 'httpclickbutton'); |
1249 |
$form->setType('btn_preview', 'httpclickbutton'); |
$form->setType('btn_preview', 'httpclickbutton'); |
1250 |
$form->setType('btn_redaction', 'httpclickbutton'); |
$form->setType('btn_redaction', 'httpclickbutton'); |
1251 |
$form->setType('live_preview', 'pdf'); |
// /!\ le type du champs est utilisé dans un selecteur dans le jscript.js |
1252 |
|
// pour identifiant le champ de prévisualisation et régler sa taille à |
1253 |
|
// l'affichage du champ. En cas de modification, le selecteur doit également |
1254 |
|
// être mis à jour |
1255 |
|
$form->setType('live_preview', 'previsualiser_pdf'); |
1256 |
} |
} |
1257 |
|
|
1258 |
// necessaire pour calcul de date en modification |
// necessaire pour calcul de date en modification |
1275 |
$form->setType('date_envoi_rar', 'date'); |
$form->setType('date_envoi_rar', 'date'); |
1276 |
$form->setType('date_retour_rar', 'date'); |
$form->setType('date_retour_rar', 'date'); |
1277 |
$form->setType('date_envoi_controle_legalite', 'date'); |
$form->setType('date_envoi_controle_legalite', 'date'); |
1278 |
|
if ($this->is_sent_to_cl() === true) { |
1279 |
|
$form->setType("date_envoi_controle_legalite", "datedisabled"); |
1280 |
|
} |
1281 |
$form->setType('date_retour_controle_legalite', 'date'); |
$form->setType('date_retour_controle_legalite', 'date'); |
1282 |
$form->setType('date_finalisation_courrier', 'date'); |
$form->setType('date_finalisation_courrier', 'date'); |
1283 |
} |
} |
1347 |
$form->setType('date_envoi_rar', 'date'); |
$form->setType('date_envoi_rar', 'date'); |
1348 |
$form->setType('date_retour_rar', 'date'); |
$form->setType('date_retour_rar', 'date'); |
1349 |
$form->setType('date_envoi_controle_legalite', 'date'); |
$form->setType('date_envoi_controle_legalite', 'date'); |
1350 |
|
if ($this->is_sent_to_cl() === true) { |
1351 |
|
$form->setType("date_envoi_controle_legalite", "datedisabled"); |
1352 |
|
} |
1353 |
$form->setType('date_retour_controle_legalite', 'date'); |
$form->setType('date_retour_controle_legalite', 'date'); |
1354 |
$form->setType('date_finalisation_courrier', 'date'); |
$form->setType('date_finalisation_courrier', 'date'); |
1355 |
} |
} |
1358 |
foreach ($this->champs as $champ) { |
foreach ($this->champs as $champ) { |
1359 |
$form->setType($champ, 'hidden'); |
$form->setType($champ, 'hidden'); |
1360 |
} |
} |
1361 |
$form->setType('preview_edition', 'pdf'); |
$form->setType('preview_edition', 'previsualiser'); |
1362 |
|
} |
1363 |
|
|
1364 |
|
// Si l'instruction a été envoyé au contrôle de légalité et que la |
1365 |
|
// tâche envoi_cl lié n'a pas encore été traité il faut indiquer à |
1366 |
|
// l'utilisateur que l'envoi au cl est en cours de traitement. |
1367 |
|
if ($this->is_sent_to_cl() === true |
1368 |
|
&& empty($this->getVal('date_envoi_controle_legalite')) |
1369 |
|
&& $maj == 3) { |
1370 |
|
$form->setType("date_envoi_controle_legalite", "hiddenstatic"); |
1371 |
} |
} |
1372 |
} |
} |
1373 |
|
|
1413 |
echo json_encode($json_return); |
echo json_encode($json_return); |
1414 |
} |
} |
1415 |
|
|
1416 |
|
|
1417 |
|
/** |
1418 |
|
* CONDITION - can_be_sended_to_cl |
1419 |
|
* |
1420 |
|
* Vérifie que le contrôle de légalité est disponible |
1421 |
|
* |
1422 |
|
* @return boolean |
1423 |
|
*/ |
1424 |
|
function can_be_sended_to_cl() { |
1425 |
|
// Si l'instruction a une édition |
1426 |
|
// et que l'événement est paramétré pour envoyer le contrôle de légalité |
1427 |
|
// par Plat'AU |
1428 |
|
// et que la date de retour signature est renseignée |
1429 |
|
// et que la date d'envoi au contrôle légalité n'est pas renseignée |
1430 |
|
// et qu'il n'existe pas de task envoi_CL en cours (!= done ou canceled) |
1431 |
|
if ($this->has_an_edition() === true) { |
1432 |
|
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
1433 |
|
$inst_evenement = $this->get_inst_evenement($this->getVal('evenement')); |
1434 |
|
if ($inst_evenement->getVal('envoi_cl_platau') === 't' |
1435 |
|
&& empty($this->getVal('date_retour_signature')) === false |
1436 |
|
&& empty($this->getVal('date_envoi_controle_legalite')) === true |
1437 |
|
&& $this->getVal('envoye_cl_platau') === 'f' |
1438 |
|
&& $this->f->is_type_dossier_platau($inst_di->getVal('dossier_autorisation')) === true |
1439 |
|
&& $inst_di->getVal('etat_transmission_platau') !== 'jamais_transmissible') { |
1440 |
|
// |
1441 |
|
return true; |
1442 |
|
} |
1443 |
|
} |
1444 |
|
// |
1445 |
|
return false; |
1446 |
|
} |
1447 |
|
|
1448 |
/** |
/** |
1449 |
* |
* |
1450 |
* @return string |
* @return string |
1451 |
*/ |
*/ |
1452 |
function get_var_sql_forminc__sql_signataire_arrete() { |
function get_var_sql_forminc__sql_signataire_arrete() { |
1453 |
return "SELECT |
return sprintf( |
1454 |
signataire_arrete.signataire_arrete, |
"SELECT |
1455 |
CONCAT(signataire_arrete.prenom, ' ', signataire_arrete.nom) |
signataire_arrete.signataire_arrete, |
1456 |
FROM ".DB_PREFIXE."signataire_arrete |
CONCAT_WS( |
1457 |
WHERE ((signataire_arrete.om_validite_debut IS NULL AND (signataire_arrete.om_validite_fin IS NULL OR signataire_arrete.om_validite_fin > CURRENT_DATE)) OR (signataire_arrete.om_validite_debut <= CURRENT_DATE AND (signataire_arrete.om_validite_fin IS NULL OR signataire_arrete.om_validite_fin > CURRENT_DATE))) |
' - ', |
1458 |
ORDER BY signataire_arrete.prenom, signataire_arrete.nom"; |
CONCAT_WS(' ', signataire_arrete.prenom, signataire_arrete.nom), |
1459 |
|
signataire_habilitation.libelle, |
1460 |
|
signataire_arrete.description |
1461 |
|
) |
1462 |
|
FROM |
1463 |
|
%1\$ssignataire_arrete |
1464 |
|
LEFT JOIN %1\$ssignataire_habilitation |
1465 |
|
ON signataire_arrete.signataire_habilitation = signataire_habilitation.signataire_habilitation |
1466 |
|
WHERE |
1467 |
|
((signataire_arrete.om_validite_debut IS NULL |
1468 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1469 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE)) |
1470 |
|
OR (signataire_arrete.om_validite_debut <= CURRENT_DATE |
1471 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1472 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE))) |
1473 |
|
ORDER BY |
1474 |
|
signataire_arrete.prenom, |
1475 |
|
signataire_arrete.nom", |
1476 |
|
DB_PREFIXE |
1477 |
|
); |
1478 |
} |
} |
1479 |
|
|
1480 |
/** |
/** |
1482 |
* @return string |
* @return string |
1483 |
*/ |
*/ |
1484 |
function get_var_sql_forminc__sql_signataire_arrete_by_id() { |
function get_var_sql_forminc__sql_signataire_arrete_by_id() { |
1485 |
return "SELECT |
return sprintf( |
1486 |
signataire_arrete.signataire_arrete, |
"SELECT |
1487 |
CONCAT(signataire_arrete.prenom, ' ', signataire_arrete.nom) |
signataire_arrete.signataire_arrete, |
1488 |
FROM ".DB_PREFIXE."signataire_arrete |
CONCAT_WS( |
1489 |
WHERE signataire_arrete.signataire_arrete = <idx>"; |
' - ', |
1490 |
|
CONCAT_WS(' ', signataire_arrete.prenom, signataire_arrete.nom), |
1491 |
|
signataire_habilitation.libelle, |
1492 |
|
signataire_arrete.description |
1493 |
|
) |
1494 |
|
FROM |
1495 |
|
%1\$ssignataire_arrete |
1496 |
|
LEFT JOIN %1\$ssignataire_habilitation |
1497 |
|
ON signataire_arrete.signataire_habilitation = signataire_habilitation.signataire_habilitation |
1498 |
|
WHERE |
1499 |
|
signataire_arrete.signataire_arrete = <idx>", |
1500 |
|
DB_PREFIXE |
1501 |
|
); |
1502 |
} |
} |
1503 |
|
|
1504 |
/** |
/** |
1506 |
* @return string |
* @return string |
1507 |
*/ |
*/ |
1508 |
function get_var_sql_forminc__sql_signataire_arrete_by_di() { |
function get_var_sql_forminc__sql_signataire_arrete_by_di() { |
1509 |
return "SELECT |
return sprintf( |
1510 |
signataire_arrete.signataire_arrete, |
"SELECT |
1511 |
CONCAT(signataire_arrete.prenom, ' ', signataire_arrete.nom) |
signataire_arrete.signataire_arrete, |
1512 |
FROM ".DB_PREFIXE."signataire_arrete |
CONCAT_WS( |
1513 |
LEFT JOIN ".DB_PREFIXE."om_collectivite ON signataire_arrete.om_collectivite = om_collectivite.om_collectivite |
' - ', |
1514 |
WHERE ((signataire_arrete.om_validite_debut IS NULL AND (signataire_arrete.om_validite_fin IS NULL OR signataire_arrete.om_validite_fin > CURRENT_DATE)) OR (signataire_arrete.om_validite_debut <= CURRENT_DATE AND (signataire_arrete.om_validite_fin IS NULL OR signataire_arrete.om_validite_fin > CURRENT_DATE))) |
CONCAT_WS(' ', signataire_arrete.prenom, signataire_arrete.nom), |
1515 |
AND (om_collectivite.niveau = '2' OR signataire_arrete.om_collectivite = <collectivite_di>) |
signataire_habilitation.libelle, |
1516 |
ORDER BY signataire_arrete.prenom, signataire_arrete.nom"; |
signataire_arrete.description |
1517 |
|
) |
1518 |
|
FROM |
1519 |
|
%1\$ssignataire_arrete |
1520 |
|
LEFT JOIN %1\$som_collectivite |
1521 |
|
ON signataire_arrete.om_collectivite = om_collectivite.om_collectivite |
1522 |
|
LEFT JOIN %1\$ssignataire_habilitation |
1523 |
|
ON signataire_arrete.signataire_habilitation = signataire_habilitation.signataire_habilitation |
1524 |
|
WHERE |
1525 |
|
((signataire_arrete.om_validite_debut IS NULL |
1526 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1527 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE)) |
1528 |
|
OR (signataire_arrete.om_validite_debut <= CURRENT_DATE |
1529 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1530 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE))) |
1531 |
|
AND (om_collectivite.niveau = '2' |
1532 |
|
OR signataire_arrete.om_collectivite = <collectivite_di>) |
1533 |
|
ORDER BY |
1534 |
|
signataire_arrete.prenom, signataire_arrete.nom", |
1535 |
|
DB_PREFIXE |
1536 |
|
); |
1537 |
} |
} |
1538 |
|
|
1539 |
/** |
/** |
1541 |
* @return string |
* @return string |
1542 |
*/ |
*/ |
1543 |
function get_var_sql_forminc__sql_signataire_arrete_defaut() { |
function get_var_sql_forminc__sql_signataire_arrete_defaut() { |
1544 |
return "SELECT |
return sprintf( |
1545 |
signataire_arrete.signataire_arrete, |
"SELECT |
1546 |
CONCAT(signataire_arrete.prenom, ' ', signataire_arrete.nom) |
signataire_arrete.signataire_arrete, |
1547 |
FROM ".DB_PREFIXE."signataire_arrete |
CONCAT_WS( |
1548 |
WHERE ((signataire_arrete.om_validite_debut IS NULL AND (signataire_arrete.om_validite_fin IS NULL OR signataire_arrete.om_validite_fin > CURRENT_DATE)) OR (signataire_arrete.om_validite_debut <= CURRENT_DATE AND (signataire_arrete.om_validite_fin IS NULL OR signataire_arrete.om_validite_fin > CURRENT_DATE))) AND signataire_arrete.defaut IS TRUE |
' - ', |
1549 |
ORDER BY signataire_arrete.prenom, signataire_arrete.nom"; |
CONCAT_WS(' ', signataire_arrete.prenom, signataire_arrete.nom), |
1550 |
|
signataire_habilitation.libelle, |
1551 |
|
signataire_arrete.description |
1552 |
|
) |
1553 |
|
FROM |
1554 |
|
%1\$ssignataire_arrete |
1555 |
|
LEFT JOIN %1\$ssignataire_habilitation |
1556 |
|
ON signataire_arrete.signataire_habilitation = signataire_habilitation.signataire_habilitation |
1557 |
|
WHERE |
1558 |
|
((signataire_arrete.om_validite_debut IS NULL |
1559 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1560 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE)) |
1561 |
|
OR (signataire_arrete.om_validite_debut <= CURRENT_DATE |
1562 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1563 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE))) |
1564 |
|
AND signataire_arrete.defaut IS TRUE |
1565 |
|
ORDER BY |
1566 |
|
signataire_arrete.prenom, signataire_arrete.nom", |
1567 |
|
DB_PREFIXE |
1568 |
|
); |
1569 |
} |
} |
1570 |
|
|
1571 |
/** |
/** |
1573 |
* @return string |
* @return string |
1574 |
*/ |
*/ |
1575 |
function get_var_sql_forminc__sql_signataire_arrete_defaut_by_di() { |
function get_var_sql_forminc__sql_signataire_arrete_defaut_by_di() { |
1576 |
return "SELECT |
return sprintf( |
1577 |
signataire_arrete.signataire_arrete, |
"SELECT |
1578 |
CONCAT(signataire_arrete.prenom, ' ', signataire_arrete.nom) |
signataire_arrete.signataire_arrete, |
1579 |
FROM ".DB_PREFIXE."signataire_arrete |
CONCAT_WS( |
1580 |
LEFT JOIN ".DB_PREFIXE."om_collectivite ON signataire_arrete.om_collectivite = om_collectivite.om_collectivite |
' - ', |
1581 |
WHERE ((signataire_arrete.om_validite_debut IS NULL AND (signataire_arrete.om_validite_fin IS NULL OR signataire_arrete.om_validite_fin > CURRENT_DATE)) OR (signataire_arrete.om_validite_debut <= CURRENT_DATE AND (signataire_arrete.om_validite_fin IS NULL OR signataire_arrete.om_validite_fin > CURRENT_DATE))) AND signataire_arrete.defaut IS TRUE |
CONCAT_WS(' ', signataire_arrete.prenom, signataire_arrete.nom), |
1582 |
AND (om_collectivite.niveau = '2' OR signataire_arrete.om_collectivite = <collectivite_di>) |
signataire_habilitation.libelle, |
1583 |
ORDER BY signataire_arrete.prenom, signataire_arrete.nom"; |
signataire_arrete.description |
1584 |
|
) |
1585 |
|
FROM |
1586 |
|
%1\$ssignataire_arrete |
1587 |
|
LEFT JOIN %1\$ssignataire_habilitation |
1588 |
|
ON signataire_arrete.signataire_habilitation = signataire_habilitation.signataire_habilitation |
1589 |
|
LEFT JOIN %1\$som_collectivite |
1590 |
|
ON signataire_arrete.om_collectivite = om_collectivite.om_collectivite |
1591 |
|
WHERE |
1592 |
|
((signataire_arrete.om_validite_debut IS NULL |
1593 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1594 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE)) |
1595 |
|
OR (signataire_arrete.om_validite_debut <= CURRENT_DATE |
1596 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1597 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE))) |
1598 |
|
AND signataire_arrete.defaut IS TRUE |
1599 |
|
AND (om_collectivite.niveau = '2' |
1600 |
|
OR signataire_arrete.om_collectivite = <collectivite_di>) |
1601 |
|
ORDER BY |
1602 |
|
signataire_arrete.prenom, |
1603 |
|
signataire_arrete.nom", |
1604 |
|
DB_PREFIXE |
1605 |
|
); |
1606 |
} |
} |
1607 |
|
|
1608 |
/** |
/** |
1793 |
|
|
1794 |
if ($maj == 401) { |
if ($maj == 401) { |
1795 |
$file = $this->f->storage->get($this->getVal('om_fichier_instruction')); |
$file = $this->f->storage->get($this->getVal('om_fichier_instruction')); |
1796 |
$base64 = base64_encode($file['file_content']); |
$form->setSelect('preview_edition', array( |
1797 |
$form->setSelect('preview_edition', array('base64' => $base64)); |
'base64' => base64_encode($file['file_content']), |
1798 |
|
'mimetype' => $file['metadata']['mimetype'], |
1799 |
|
'label' => 'instruction_'.$this->getVal($this->clePrimaire), |
1800 |
|
'href' => sprintf( |
1801 |
|
'../app/index.php?module=form&snippet=file&obj=instruction&champ=om_fichier_instruction&id=%1$s', |
1802 |
|
$this->getVal($this->clePrimaire) |
1803 |
|
) |
1804 |
|
)); |
1805 |
} |
} |
1806 |
} |
} |
1807 |
|
|
1808 |
function cleSecondaire($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
function cleSecondaire($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
1809 |
// |
// |
1810 |
parent::cleSecondaire($id, $dnu1, $val); |
// Vérifie uniquementla cle secondaire : demande |
1811 |
|
$this->rechercheTable($this->f->db, "demande", "instruction_recepisse", $id); |
1812 |
|
|
1813 |
$id = $this->getVal($this->clePrimaire); |
$id = $this->getVal($this->clePrimaire); |
1814 |
|
|
1936 |
$form->setVal("destinataire", $this->getParameter("idxformulaire")); |
$form->setVal("destinataire", $this->getParameter("idxformulaire")); |
1937 |
$form->setVal("dossier", $this->getParameter("idxformulaire")); |
$form->setVal("dossier", $this->getParameter("idxformulaire")); |
1938 |
} |
} |
1939 |
|
|
1940 |
|
// Si l'instruction a été envoyé au contrôle de légalité et que la |
1941 |
|
// tâche envoi_cl lié n'a pas encore été traité il faut indiquer à |
1942 |
|
// l'utilisateur que l'envoi au cl est en cours de traitement. |
1943 |
|
if ($this->is_sent_to_cl() === true |
1944 |
|
&& empty($this->getVal('date_envoi_controle_legalite')) |
1945 |
|
&& $maj == 3) { |
1946 |
|
$form->setVal("date_envoi_controle_legalite", __("En cours de traitement.")); |
1947 |
|
} |
1948 |
// |
// |
1949 |
$this->set_form_default_values($form, $maj, $validation); |
$this->set_form_default_values($form, $maj, $validation); |
1950 |
} |
} |
2013 |
$form->setVal("btn_redaction", "show_instr_redaction()"); |
$form->setVal("btn_redaction", "show_instr_redaction()"); |
2014 |
} |
} |
2015 |
|
|
2016 |
if ($maj == 3 |
// Gestion de l'affichage des suivis de notification des demandeurs, des services, des tiers et |
2017 |
&& $this->can_display_notification() |
// des communes |
2018 |
) { |
if ($maj == 3) { |
2019 |
$form->setVal("suivi_notification", $this->get_json_suivi_notification()); |
if ($this->can_display_notification_demandeur()) { |
2020 |
|
$typeNotification = array( |
2021 |
|
'notification_recepisse', |
2022 |
|
'notification_instruction', |
2023 |
|
'notification_decision', |
2024 |
|
); |
2025 |
|
$form->setVal("suivi_notification", $this->get_json_suivi_notification($typeNotification, true)); |
2026 |
|
} |
2027 |
|
if ($this->can_display_notification_service()) { |
2028 |
|
$form->setVal("suivi_notification_service", $this->get_json_suivi_notification(array('notification_service_consulte'))); |
2029 |
|
} |
2030 |
|
if ($this->can_display_notification_tiers()) { |
2031 |
|
$form->setVal("suivi_notification_tiers", $this->get_json_suivi_notification(array('notification_tiers_consulte'))); |
2032 |
|
} |
2033 |
|
if ($this->can_display_notification_commune()) { |
2034 |
|
$form->setVal("suivi_notification_commune", $this->get_json_suivi_notification(array('notification_depot_demat', 'notification_commune'))); |
2035 |
|
} |
2036 |
} |
} |
2037 |
} |
} |
2038 |
|
|
2039 |
function setLayout(&$form, $maj){ |
function setLayout(&$form, $maj){ |
2040 |
|
// En consultation, pour les dossiers qui n'ont pas été transmis par le portail |
2041 |
|
// citoyen, si la notification des demandeurs est activée sur l'évenement |
2042 |
|
// d'instruction et que le paramétrage du demandeur principal n'est pas |
2043 |
|
// correct alors un message a destination de l'instructeur est affiché. |
2044 |
|
if ($maj == 3) { |
2045 |
|
// Si le dossier n'a pas été déposé sur le portail citoyen ou si |
2046 |
|
// la requête permettant de savoir le type de demande à échouée, on |
2047 |
|
// vérifie si il y a des erreurs de paramétrage et si c'est le cas |
2048 |
|
// on affiche un message d'information |
2049 |
|
if ($this->dossier_depose_sur_portail() == null || |
2050 |
|
! $this->dossier_depose_sur_portail()) { |
2051 |
|
$erreurParam = $this->get_info_notification_fail(); |
2052 |
|
// Récupération de l'évenement d'instruction |
2053 |
|
$instEV = $this->get_inst_evenement(); |
2054 |
|
if (! empty($instEV->getVal('notification')) && $erreurParam != array()) { |
2055 |
|
$class = 'text-info ui-state-highlight ui-state-info'; |
2056 |
|
$message = __("Attention l'envoi de notification automatique n'est pas possible."); |
2057 |
|
$this->f->display_panel_information( |
2058 |
|
$class, |
2059 |
|
$message, |
2060 |
|
$erreurParam, |
2061 |
|
__('Veuillez corriger les informations suivantes.'), |
2062 |
|
'erreur_param_notif' |
2063 |
|
); |
2064 |
|
} |
2065 |
|
} |
2066 |
|
} |
2067 |
$form->setBloc('evenement','D',"","sousform-instruction-action-".$maj); |
$form->setBloc('evenement','D',"","sousform-instruction-action-".$maj); |
2068 |
|
|
2069 |
$form->setFieldset('evenement','D',_('Evenement')); |
$form->setFieldset('evenement','D',_('Evenement')); |
2093 |
|
|
2094 |
$form->setFieldset('suivi_notification', 'D', __("Suivi notification"), "collapsible"); |
$form->setFieldset('suivi_notification', 'D', __("Suivi notification"), "collapsible"); |
2095 |
$form->setFieldset('suivi_notification','F'); |
$form->setFieldset('suivi_notification','F'); |
2096 |
|
$form->setFieldset('suivi_notification_service', 'D', __("Suivi notification service"), "collapsible"); |
2097 |
|
$form->setFieldset('suivi_notification_service','F'); |
2098 |
|
$form->setFieldset('suivi_notification_tiers', 'D', __("Suivi notification tiers"), "collapsible"); |
2099 |
|
$form->setFieldset('suivi_notification_tiers','F'); |
2100 |
|
$form->setFieldset('suivi_notification_commune', 'D', __("Suivi notification commune"), "collapsible"); |
2101 |
|
$form->setFieldset('suivi_notification_commune','F'); |
2102 |
|
|
2103 |
if ($maj == 1) { |
if ($maj == 1) { |
2104 |
// Récupère la collectivité du dossier d'instruction |
// Récupère la collectivité du dossier d'instruction |
2180 |
$form->setLib('commentaire_signature', __("commentaire")); |
$form->setLib('commentaire_signature', __("commentaire")); |
2181 |
$form->setLib('historique_signature', ''); |
$form->setLib('historique_signature', ''); |
2182 |
$form->setLib('suivi_notification', ''); |
$form->setLib('suivi_notification', ''); |
2183 |
|
$form->setLib('suivi_notification_service', ''); |
2184 |
|
$form->setLib('suivi_notification_tiers', ''); |
2185 |
|
$form->setLib('suivi_notification_commune', ''); |
2186 |
$form->setLib('preview_edition', ""); |
$form->setLib('preview_edition', ""); |
2187 |
|
|
2188 |
// Ajout d'une infobulle d'aide lorsque le formulaire est en mode |
// Ajout d'une infobulle d'aide lorsque le formulaire est en mode |
2333 |
$this->valF["code_barres"] = $idTypeCourrier . $idCourrier; |
$this->valF["code_barres"] = $idTypeCourrier . $idCourrier; |
2334 |
} |
} |
2335 |
|
|
2336 |
// Test si une restriction est valide |
/** |
2337 |
// return boolean |
* Test si une restriction est valide. |
2338 |
|
* |
2339 |
|
* @return boolean |
2340 |
|
*/ |
2341 |
function restrictionIsValid($restriction){ |
function restrictionIsValid($restriction){ |
2342 |
if($this->restriction_valid != null) { |
if($this->restriction_valid != null) { |
2343 |
return $this->restriction_valid; |
return $this->restriction_valid; |
3055 |
"idx" => $this->valF['dossier'], |
"idx" => $this->valF['dossier'], |
3056 |
)); |
)); |
3057 |
$valF['instruction'] = $id; |
$valF['instruction'] = $id; |
3058 |
|
$valF['crud'] = 'create'; |
3059 |
$update_by_instruction = $inst_dossier->update_by_instruction($valF); |
$update_by_instruction = $inst_dossier->update_by_instruction($valF); |
3060 |
if ($update_by_instruction === false) { |
if ($update_by_instruction === false) { |
3061 |
$this->cleanMessage(); |
$this->cleanMessage(); |
3269 |
($inst_evenement->getVal('lettretype') === null || |
($inst_evenement->getVal('lettretype') === null || |
3270 |
$inst_evenement->getVal('lettretype') === '')) { |
$inst_evenement->getVal('lettretype') === '')) { |
3271 |
// Récupération de la liste des demandeurs à notifier et de la catégorie |
// Récupération de la liste des demandeurs à notifier et de la catégorie |
|
$demandeursANotifie = $this->get_demandeurs_notifiable($this->valF['dossier']); |
|
3272 |
$categorie = $this->f->get_param_option_notification($collectivite_di); |
$categorie = $this->f->get_param_option_notification($collectivite_di); |
3273 |
|
$isPortal = $categorie == null || $categorie == '' || $categorie == 'portal' ? true : false; |
3274 |
|
$demandeursANotifie = $this->get_demandeurs_notifiable( |
3275 |
|
$this->valF['dossier'], |
3276 |
|
$isPortal |
3277 |
|
); |
3278 |
|
|
3279 |
// Création d'une notification et d'une tâche pour chaque demandeur à notifier |
// Création d'une notification et d'une tâche pour chaque demandeur à notifier |
3280 |
|
$demandeurPrincipalNotifie = false; |
3281 |
foreach ($demandeursANotifie as $demandeur) { |
foreach ($demandeursANotifie as $demandeur) { |
3282 |
|
// Identifie si le demandeur principal a été notifié ou pas |
3283 |
|
// et récupère ses informations |
3284 |
|
if ($demandeur['petitionnaire_principal'] == 't') { |
3285 |
|
$demandeurPrincipalNotifie = true; |
3286 |
|
// Si le demandeur principal est notifiable mais qu'il y a des erreurs dans |
3287 |
|
// son paramétrage, on effectue pas le traitement et on passe à l'itération |
3288 |
|
// suivante. On le considère également comme non notifié pour gérer l'envoie |
3289 |
|
// des messages d'erreurs |
3290 |
|
// Si la demande a été déposée via le portail alors le paramétrage n'a pas |
3291 |
|
// d'impact sur la notification |
3292 |
|
$erreursParam = $this->get_info_notification_fail($val['dossier']); |
3293 |
|
if (! $this->dossier_depose_sur_portail($val['dossier']) && $erreursParam != array()) { |
3294 |
|
$demandeurPrincipalNotifie = false; |
3295 |
|
continue; |
3296 |
|
} |
3297 |
|
} |
3298 |
// Ajout de la notif et récupération de son id |
// Ajout de la notif et récupération de son id |
3299 |
$idNotif = $this->ajouter_notification( |
$idNotif = $this->ajouter_notification( |
3300 |
$this->valF[$this->clePrimaire], |
$this->valF[$this->clePrimaire], |
|
true, |
|
3301 |
$this->f->get_connected_user_login_name(), |
$this->f->get_connected_user_login_name(), |
3302 |
$demandeur |
$demandeur, |
3303 |
|
$collectivite_di, |
3304 |
|
array(), |
3305 |
|
true |
3306 |
); |
); |
3307 |
if ($idNotif === false) { |
if ($idNotif === false) { |
|
$this->addToMessage( |
|
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
|
|
); |
|
3308 |
return false; |
return false; |
3309 |
} |
} |
3310 |
// Création de la tache en lui donnant l'id de la notification |
// Création de la tache en lui donnant l'id de la notification |
3320 |
return false; |
return false; |
3321 |
} |
} |
3322 |
} |
} |
3323 |
|
// Si le demandeur principal n'est pas notifiable, on créé une nouvelle notification |
3324 |
|
// en erreur avec en commentaire la raison pour laquelle le demandeur principal |
3325 |
|
// n'a pas pu être notifié |
3326 |
|
if (! $demandeurPrincipalNotifie) { |
3327 |
|
// Analyse pour savoir pourquoi le demandeur principal n'est pas notifiable |
3328 |
|
$erreursParam = $this->get_info_notification_fail($val['dossier']); |
3329 |
|
$demandeurPrincipal = $this->get_info_petitionnaire_principal_dossier($val['dossier']); |
3330 |
|
// Ajout de la notif et récupération de son id |
3331 |
|
$idNotif = $this->ajouter_notification( |
3332 |
|
$this->valF[$this->clePrimaire], |
3333 |
|
$this->f->get_connected_user_login_name(), |
3334 |
|
$demandeurPrincipal, |
3335 |
|
$collectivite_di, |
3336 |
|
array(), |
3337 |
|
true, |
3338 |
|
'Echec', |
3339 |
|
implode(' ', $erreursParam) |
3340 |
|
); |
3341 |
|
if ($idNotif === false) { |
3342 |
|
$this->addToMessage( |
3343 |
|
__('Erreur : la création de la notification a échouée.'). |
3344 |
|
__("Veuillez contacter votre administrateur.") |
3345 |
|
); |
3346 |
|
return false; |
3347 |
|
} |
3348 |
|
// Prépare un message d'alerte à destination de l'instructeur pour l'informer |
3349 |
|
// de l'échec de la notification |
3350 |
|
$dossier_message = $this->get_inst_dossier_message(0); |
3351 |
|
$dossier_message_val = array( |
3352 |
|
'dossier' => $val['dossier'], |
3353 |
|
'type' => _('erreur expedition'), |
3354 |
|
'emetteur' => $this->f->get_connected_user_login_name().' (automatique)', |
3355 |
|
'login' => $_SESSION['login'], |
3356 |
|
'date_emission' => date('Y-m-d H:i:s'), |
3357 |
|
'contenu' => _('Échec lors de la notification de l\'instruction '). |
3358 |
|
$inst_evenement->getVal('libelle'). |
3359 |
|
'.<br>'. |
3360 |
|
implode("\n", $erreursParam). |
3361 |
|
'<br>'. |
3362 |
|
_('Veuillez corriger ces informations avant de renvoyer la notification.') |
3363 |
|
); |
3364 |
|
$add = $dossier_message->add_notification_message($dossier_message_val, true); |
3365 |
|
// Si une erreur se produit pendant l'ajout |
3366 |
|
if ($add !== true) { |
3367 |
|
$this->addToLog(__METHOD__."(): Le message d'alerte concernant l'echec de l'envoi de la notification n'a pas pu être envoyé.", DEBUG_MODE); |
3368 |
|
return false; |
3369 |
|
} |
3370 |
|
} |
3371 |
$this->addToMessage($message = sprintf('%s<br/>%s', __("La notification a été générée."), __("Le suivi de la notification est disponible depuis l'instruction."))); |
$this->addToMessage($message = sprintf('%s<br/>%s', __("La notification a été générée."), __("Le suivi de la notification est disponible depuis l'instruction."))); |
3372 |
} |
} |
3373 |
|
|
3374 |
|
// Notification automatique en cas de dépôt de dossier dématérialisé |
3375 |
|
// Vérifie si l'option de notification est active et si il s'agit bien d'une |
3376 |
|
// instruction de récépissé |
3377 |
|
if ( |
3378 |
|
$this->f->is_option_notification_depot_demat_enabled($collectivite_di) |
3379 |
|
&& $this->is_instruction_recepisse() |
3380 |
|
) { |
3381 |
|
// Récupère l'instance de la demande |
3382 |
|
$demande = $inst_di->get_inst_demande(); |
3383 |
|
// Récupère la liste des mails fournis en paramètre |
3384 |
|
$listeEmails = $this->f->get_param_courriel_de_notification_commune($collectivite_di); |
3385 |
|
// Vérifie que le dossier a été déposé via platau ou ideau et qu'il y a |
3386 |
|
// des adresses à notifier |
3387 |
|
if ( |
3388 |
|
($demande->getVal('source_depot') == 'platau' || |
3389 |
|
$demande->getVal('source_depot') == 'ideau') && |
3390 |
|
! empty($listeEmails) |
3391 |
|
) { |
3392 |
|
foreach ($listeEmails as $email) { |
3393 |
|
// Ajout de la notif et récupération de son id |
3394 |
|
$destinataire = array( |
3395 |
|
'destinataire' => $email, |
3396 |
|
'courriel' => $email |
3397 |
|
); |
3398 |
|
$idNotif = $this->ajouter_notification( |
3399 |
|
$this->valF[$this->clePrimaire], |
3400 |
|
$this->f->get_connected_user_login_name(), |
3401 |
|
$destinataire, |
3402 |
|
$collectivite_di, |
3403 |
|
array(), |
3404 |
|
true |
3405 |
|
); |
3406 |
|
if ($idNotif === false) { |
3407 |
|
return false; |
3408 |
|
} |
3409 |
|
// Création de la tache en lui donnant l'id de la notification |
3410 |
|
$notification_by_task = $this->notification_by_task( |
3411 |
|
$idNotif, |
3412 |
|
$this->valF['dossier'], |
3413 |
|
'mail', |
3414 |
|
'notification_depot_demat' |
3415 |
|
); |
3416 |
|
if ($notification_by_task === false) { |
3417 |
|
$this->addToMessage( |
3418 |
|
__("Erreur lors de la génération de la notification de dépot de dossier par voie dématérialisée.") |
3419 |
|
); |
3420 |
|
return false; |
3421 |
|
} |
3422 |
|
} |
3423 |
|
} |
3424 |
|
} |
3425 |
|
|
3426 |
/** |
/** |
3427 |
* Mise à jour de la date de dernière modification du dossier |
* Mise à jour de la date de dernière modification du dossier |
3428 |
*/ |
*/ |
3446 |
return $this->add_log_to_dossier($id, array_merge($val, $this->valF)); |
return $this->add_log_to_dossier($id, array_merge($val, $this->valF)); |
3447 |
} |
} |
3448 |
|
|
3449 |
|
/** |
3450 |
|
* Cette méthode vérifie si toutes les conditions de l'envoi de la notification |
3451 |
|
* sont remplies. |
3452 |
|
* Les conditions vérifiées sont les suivantes : |
3453 |
|
* - Le petitionnaire principal doit accepter les notifications |
3454 |
|
* - Le pétitionnaire principal doit avoir une adresse mail renseignée |
3455 |
|
* - Le pétitionnaire principal doit avoir une adresse mail correcte |
3456 |
|
* Pour chaque vérification effectué un message d'erreur est ajouté si la |
3457 |
|
* condition n'est pas remplie. |
3458 |
|
* Renvoie le message d'erreur en sortie. |
3459 |
|
* |
3460 |
|
* @param string identifiant du dossier sur lequel les notifications ont échouée |
3461 |
|
* @return string |
3462 |
|
*/ |
3463 |
|
protected function get_info_notification_fail($dossier = null) { |
3464 |
|
// Utilise l'identifiant du dossier passé en paramètre et si aucun dossier n'a été récupéré |
3465 |
|
// utilise celui associé à l'instruction |
3466 |
|
if ($dossier == null) { |
3467 |
|
$dossier = $this->getVal('dossier'); |
3468 |
|
} |
3469 |
|
// Tableau contenant la liste des messages d'erreur |
3470 |
|
$errorMessage = array(); |
3471 |
|
// Récupère les informations du demandeurs principal |
3472 |
|
$infoPetitionnaire = $this->get_info_petitionnaire_principal_dossier($dossier); |
3473 |
|
// Vérifie si le pétitionnaire principal à bien la case "accepte les notification" cochée |
3474 |
|
if (isset($infoPetitionnaire['notification']) && $infoPetitionnaire['notification'] != 't') { |
3475 |
|
$errorMessage[] = __('Le pétitionnaire principal n\'accepte pas les notifications.'); |
3476 |
|
} |
3477 |
|
// Vérifie si l'adresse mail du pétitionnaire principale est renseignée |
3478 |
|
if (isset($infoPetitionnaire['courriel']) && ! empty($infoPetitionnaire['courriel'])) { |
3479 |
|
// Vérifie si le format de l'adresse mail est pas correct et, si ce n'est pas le cas, informe l'utilisateur |
3480 |
|
// qu'il doit le corriger avant de pouvoir ajouter l'nstruction |
3481 |
|
if (! $this->f->checkValidEmailAddress($infoPetitionnaire['courriel'])) { |
3482 |
|
$errorMessage[] = __('Le courriel du pétitionnaire principal n\'est pas correct : '). |
3483 |
|
$infoPetitionnaire['courriel']. |
3484 |
|
'.'; |
3485 |
|
} |
3486 |
|
} else { |
3487 |
|
// Si le courriel du pétitionnaire principal |
3488 |
|
$errorMessage[] = __('Le courriel du pétitionnaire principal n\'est pas renseigné.'); |
3489 |
|
} |
3490 |
|
|
3491 |
|
return $errorMessage; |
3492 |
|
} |
3493 |
|
|
3494 |
|
/** |
3495 |
|
* Méthode servant à vérifier si un dossier a été déposé sur |
3496 |
|
* le portail citoyen ou pas. |
3497 |
|
* La verification se fait via une requête sql dans laquelle |
3498 |
|
* on va chercher un dossier ayant pour id l'identifiant de |
3499 |
|
* dossier associé à l'instruction et pour lequel la demande |
3500 |
|
* associée la plus ancienne est une demande de création de |
3501 |
|
* dossier via portail |
3502 |
|
* |
3503 |
|
* @param string identifiant du dossier. Si non renseigné c'est le dossier |
3504 |
|
* associé à l'instruction qui est utilisé |
3505 |
|
* @return boolean|void true : dossier déposé via portail, false : dossier |
3506 |
|
* non déposé via portail et null : erreur de base de données. |
3507 |
|
*/ |
3508 |
|
protected function dossier_depose_sur_portail($dossier = null) { |
3509 |
|
if (empty($dossier)) { |
3510 |
|
$dossier = $this->getVal('dossier'); |
3511 |
|
} |
3512 |
|
$sql = sprintf( |
3513 |
|
'SELECT |
3514 |
|
dossier |
3515 |
|
FROM |
3516 |
|
%1$sdossier |
3517 |
|
-- Récuperation de la première demande associée au dossier |
3518 |
|
LEFT JOIN ( |
3519 |
|
SELECT |
3520 |
|
demande, |
3521 |
|
dossier_instruction, |
3522 |
|
source_depot |
3523 |
|
FROM |
3524 |
|
%1$sdemande |
3525 |
|
WHERE |
3526 |
|
dossier_instruction = \'%2$s\' |
3527 |
|
ORDER BY |
3528 |
|
demande ASC |
3529 |
|
LIMIT 1 |
3530 |
|
) as demande ON dossier.dossier = demande.dossier_instruction |
3531 |
|
WHERE |
3532 |
|
dossier.dossier = \'%2$s\' |
3533 |
|
AND demande.source_depot = \'portal\'', |
3534 |
|
DB_PREFIXE, |
3535 |
|
$dossier |
3536 |
|
); |
3537 |
|
$res = $this->f->get_one_result_from_db_query($sql, true); |
3538 |
|
if ($res['code'] === 'KO') { |
3539 |
|
$this->addToMessage(__('Erreur : La vérification du mode de dépôt du dossier à échoué')); |
3540 |
|
return; |
3541 |
|
} |
3542 |
|
// Si on a un résultat c'est que le dossier a été déposé via le portail |
3543 |
|
return ! empty($res['result']); |
3544 |
|
} |
3545 |
|
|
3546 |
|
public function is_service_notifiable() { |
3547 |
|
$evenement = $this->get_inst_evenement($this->getVal('evenement')); |
3548 |
|
|
3549 |
|
// Si l'instruction a une édition non finalisé quel que soit |
3550 |
|
// le type de notification, il n'est pas notifiable |
3551 |
|
if ($this->has_an_edition() === true) { |
3552 |
|
if ($this->is_unfinalizable_without_bypass() === false) { |
3553 |
|
return false; |
3554 |
|
} |
3555 |
|
} |
3556 |
|
// Vérifie si la notification des tiers est active pour l'évènement |
3557 |
|
return $this->get_boolean_from_pgsql_value($evenement->getVal('notification_service')); |
3558 |
|
} |
3559 |
|
|
3560 |
|
public function is_tiers_notifiable() { |
3561 |
|
$evenement = $this->get_inst_evenement($this->getVal('evenement')); |
3562 |
|
|
3563 |
|
// Si l'instruction a une édition non finalisé quel que soit |
3564 |
|
// le type de notification, il n'est pas notifiable |
3565 |
|
if ($this->has_an_edition() === true) { |
3566 |
|
if ($this->is_unfinalizable_without_bypass() === false) { |
3567 |
|
return false; |
3568 |
|
} |
3569 |
|
} |
3570 |
|
// Vérifie si la notification des tiers est active pour l'évènement |
3571 |
|
return $this->get_boolean_from_pgsql_value($evenement->getVal('notification_tiers')); |
3572 |
|
} |
3573 |
|
|
3574 |
|
/** |
3575 |
|
* Méthode permettant de savoir si une instruction peut |
3576 |
|
* être notifiée manuellement selon les différents types |
3577 |
|
* de notification. |
3578 |
|
* |
3579 |
|
* Si l'instruction a une édition non finalisée alors elle n'est pas |
3580 |
|
* manuellement notifiable. |
3581 |
|
* Si l'instruction est associé à un événement de notification pour |
3582 |
|
* lequel un retour signature est recquis, elle n'est notifiable que |
3583 |
|
* si la date de retour de signature est remplie. |
3584 |
|
* Par défaut si le type de notification n'est pas connu alors l'instruction |
3585 |
|
* n'est pas notifiable. |
3586 |
|
* Pour tous les autres cas l'instruction est manuellement notifiable. |
3587 |
|
* |
3588 |
|
* @return boolean true : notifiable | false : non notifiable |
3589 |
|
*/ |
3590 |
public function is_notifiable_by_task_manual() { |
public function is_notifiable_by_task_manual() { |
3591 |
$ev = $this->get_inst_evenement($this->getVal('evenement')); |
$ev = $this->get_inst_evenement($this->getVal('evenement')); |
3592 |
|
|
3599 |
} |
} |
3600 |
|
|
3601 |
// Gestion des différents cas selon la valeur du champs notification |
// Gestion des différents cas selon la valeur du champs notification |
3602 |
switch ($ev->getVal('notification')) { |
if ($ev->getVal('notification') == 'notification_manuelle' || |
3603 |
case 'notification_manuelle': |
$ev->getVal('notification') == 'notification_manuelle_annexe' || |
3604 |
return true; |
$ev->getVal('notification') == 'notification_automatique' |
3605 |
case 'notification_automatique': |
) { |
3606 |
return false; |
return true; |
3607 |
case 'notification_auto_signature_requise': |
} elseif (($ev->getVal('notification') == 'notification_auto_signature_requise' || |
3608 |
return false; |
$ev->getVal('notification') == 'notification_manuelle_signature_requise' || |
3609 |
case 'notification_manuelle_signature_requise': |
$ev->getVal('notification') == 'notification_manuelle_annexe_signature_requise') && |
3610 |
// Si il y a une date de retour de signature la notification est possible |
$this->getVal('date_retour_signature') != null && |
3611 |
if ($this->getVal('date_retour_signature') === null |
$this->getVal('date_retour_signature') != '' |
3612 |
|| $this->getVal('date_retour_signature') === '') { |
) { |
3613 |
return false; |
return true ; |
|
} |
|
|
return true; |
|
|
default: |
|
|
return false; |
|
3614 |
} |
} |
3615 |
|
return false; |
3616 |
} |
} |
3617 |
|
|
3618 |
/** |
/** |
3626 |
$message = ''; |
$message = ''; |
3627 |
// Récupération des informations concernant le demandeur |
// Récupération des informations concernant le demandeur |
3628 |
$dossier = $this->getVal('dossier'); |
$dossier = $this->getVal('dossier'); |
3629 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite($dossier); |
3630 |
$demandeur = $this->get_demandeurs_notifiable( |
$demandeur = $this->get_demandeurs_notifiable( |
3631 |
$dossier, |
$dossier, |
3632 |
true |
true |
3633 |
); |
); |
3634 |
if ($demandeur !== array()) { |
if ($demandeur !== array()) { |
3635 |
$courriel = array_values($demandeur); |
$destinataire = array_values($demandeur); |
3636 |
// Ajout de la notif et récupération de son id |
// Ajout de la notif et récupération de son id |
3637 |
$idNotification = $this->ajouter_notification( |
$idNotification = $this->ajouter_notification( |
3638 |
$this->getVal($this->clePrimaire), |
$this->getVal($this->clePrimaire), |
|
true, |
|
3639 |
$this->f->get_connected_user_login_name(), |
$this->f->get_connected_user_login_name(), |
3640 |
$courriel[0] |
$destinataire[0], |
3641 |
|
$collectivite_di, |
3642 |
|
array(), |
3643 |
|
true |
3644 |
); |
); |
3645 |
if ($idNotification === false) { |
if ($idNotification === false) { |
|
$this->addToMessage( |
|
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
|
|
); |
|
3646 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
3647 |
} |
} |
3648 |
// Création de la tâche en lui donnant l'id de la notification |
// Création de la tâche en lui donnant l'id de la notification |
3657 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
3658 |
} |
} |
3659 |
$this->addToMessage( __("Le demandeur principal n'est pas notifiable.")); |
$this->addToMessage( __("Le demandeur principal n'est pas notifiable.")); |
3660 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, false); |
3661 |
} |
} |
3662 |
|
|
3663 |
public function notification_by_task($object_id, $dossier, $category = null, $type = null) { |
public function notification_by_task($object_id, $dossier, $category = null, $type = null) { |
3666 |
$category = 'portal'; |
$category = 'portal'; |
3667 |
} |
} |
3668 |
// Si le type n'est pas correctement spécifié, alors il est calculé |
// Si le type n'est pas correctement spécifié, alors il est calculé |
3669 |
if ($type === null |
if ($type !== 'notification_recepisse' |
3670 |
|| $type !== 'notification_recepisse' |
&& $type !== 'notification_instruction' |
3671 |
|| $type !== 'notification_instruction' |
&& $type !== 'notification_decision' |
3672 |
|| $type !== 'notification_decision') { |
&& $type !== 'notification_service_consulte' |
3673 |
|
&& $type !== 'notification_tiers_consulte' |
3674 |
|
&& $type !== 'notification_depot_demat' |
3675 |
|
&& $type !== 'notification_commune') { |
3676 |
// |
// |
3677 |
$type = 'notification_instruction'; |
$type = 'notification_instruction'; |
3678 |
// Vérifie si l'instruction est un récépissé |
// Vérifie si l'instruction est un récépissé |
3679 |
$instruction_id = $this->getVal('instruction') !== null ? $this->getVal('instruction') : $this->valF['instruction']; |
if ($this->is_instruction_recepisse()) { |
|
$dossier_id = $this->getVal('dossier') !== null ? $this->getVal('dossier') : $this->valF['dossier']; |
|
|
$inst_dossier = $this->f->get_inst__om_dbform(array( |
|
|
"obj" => "dossier_instruction", |
|
|
"idx" => $dossier_id, |
|
|
)); |
|
|
$recepisse = $inst_dossier->get_demande_instruction_recepisse(); |
|
|
if ($instruction_id === $recepisse |
|
|
|| $recepisse === '' |
|
|
|| $recepisse === null) { |
|
|
// |
|
3680 |
$type = 'notification_recepisse'; |
$type = 'notification_recepisse'; |
3681 |
|
|
3682 |
} |
} |
3683 |
// Vérifie si l'instruction est une décision |
// Vérifie si l'instruction est une décision |
3684 |
if ($type !== 'notification_recepisse') { |
if ($type !== 'notification_recepisse') { |
3708 |
return true; |
return true; |
3709 |
} |
} |
3710 |
|
|
3711 |
protected function ajouter_notification($idInstruction, $demandeAuto = false, $emetteur, $destinataire) { |
/** |
3712 |
|
* Cette méthode permet de savoir si l'instruction est une instruction |
3713 |
|
* de recepisse (instruction lié à l'ajout du dossier). |
3714 |
|
* |
3715 |
|
* Pour cela, on récupère la liste des actions qui ont menées à la création |
3716 |
|
* de l'instruction. Si une de ces actions est lié à un objet "demande" on |
3717 |
|
* en deduis que c'est l'ajout d'une demande qui a déclenché la création de |
3718 |
|
* l'instruction et donc qu'il s'agit d'un recepisse. |
3719 |
|
* |
3720 |
|
* @return boolean |
3721 |
|
*/ |
3722 |
|
protected function is_instruction_recepisse() { |
3723 |
|
// Récupère la liste des actions qui ont mené à la création de |
3724 |
|
// l'instruction |
3725 |
|
$trace = debug_backtrace(); |
3726 |
|
// Parcours la liste des actions et si une de ces actions est lié |
3727 |
|
// à la classe demande on cosidère que l'instruction est un recepisse |
3728 |
|
foreach ($trace as $key => $value) { |
3729 |
|
if (isset($trace[$key]['class']) === true |
3730 |
|
&& empty($trace[$key]['class']) === false) { |
3731 |
|
if (strtolower($trace[$key]['class']) === 'demande') { |
3732 |
|
return true; |
3733 |
|
} |
3734 |
|
} |
3735 |
|
} |
3736 |
|
return false; |
3737 |
|
} |
3738 |
|
|
3739 |
|
/** |
3740 |
|
* A partir des informations passée en argument ajoute un nouvel élément |
3741 |
|
* dans la table instruction_notification. |
3742 |
|
* Avant l'ajout vérifie en utilisant l'id de la collectivité passée en |
3743 |
|
* paramètre si le paramétrage attendus est ok. |
3744 |
|
* Ajoute également un nouvel élement dans instruction_notification_document |
3745 |
|
* si l'instruction possède une lettretype. |
3746 |
|
* Si un identifiant d'une instruction annexe est donnée ajoute un deuxième |
3747 |
|
* élement dans la table instruction_notification_document qui correspondra |
3748 |
|
* à l'annexe de la notification. |
3749 |
|
* |
3750 |
|
* @param integer identifiant de l'instruction notifiée |
3751 |
|
* @param string information concernant l'emetteur |
3752 |
|
* @param array tableau contenant 2 entrées |
3753 |
|
* - destinatire : nom, prenom ou raison sociale, dénomination et courriel |
3754 |
|
* - courriel : adresse mail de la personne à notifier |
3755 |
|
* @param integer identifiant de la collectivité permettant de récupèrer les |
3756 |
|
* paramètres à valider |
3757 |
|
* @param boolean indique si la notification est automatique ou manuelle |
3758 |
|
* @param integer identifiant d'une instruction dont l'édition sera annexé |
3759 |
|
* à la notification |
3760 |
|
* |
3761 |
|
* @return integer|boolean identifiant de la notification créée si le traitement |
3762 |
|
* a réussie, false sinon. |
3763 |
|
*/ |
3764 |
|
protected function ajouter_notification( |
3765 |
|
$idInstruction, |
3766 |
|
$emetteur, |
3767 |
|
$destinataire, |
3768 |
|
$collectiviteId, |
3769 |
|
$annexes = array(), |
3770 |
|
$demandeAuto = false, |
3771 |
|
$statut = 'en cours d\'envoi', |
3772 |
|
$commentaire = 'Notification en cours de traitement' |
3773 |
|
) { |
3774 |
|
// Vérification que les paramètres nécessaires à l'envoi de la notification existe avant |
3775 |
|
// de créer la notification |
3776 |
|
if (! $this->is_parametrage_notification_correct($collectiviteId)) { |
3777 |
|
$this->addToMessage(__("Erreur de paramétrage. L'url d'accès au(x) document(s) notifié(s) n'est pas paramétrée.")); |
3778 |
|
return false; |
3779 |
|
} |
3780 |
// Préparation de la notification |
// Préparation de la notification |
3781 |
$inst_notif = $this->f->get_inst__om_dbform(array( |
$inst_notif = $this->f->get_inst__om_dbform(array( |
3782 |
"obj" => "instruction_notification", |
"obj" => "instruction_notification", |
3788 |
'automatique' => $demandeAuto, |
'automatique' => $demandeAuto, |
3789 |
'emetteur' => $emetteur, |
'emetteur' => $emetteur, |
3790 |
'date_envoi' => null, |
'date_envoi' => null, |
3791 |
'destinataire' => $destinataire, |
'destinataire' => $destinataire['destinataire'], |
3792 |
|
'courriel' => $destinataire['courriel'], |
3793 |
'date_premier_acces' => null, |
'date_premier_acces' => null, |
3794 |
'statut' => 'en cours d\'envoi', |
'statut' => $statut, |
3795 |
'commentaire' => 'Notification en cours de traitement' |
'commentaire' => $commentaire |
3796 |
); |
); |
3797 |
|
|
3798 |
// Création de la notification |
// Création de la notification |
3799 |
$add_notif = $inst_notif->ajouter($notif_val); |
$add_notif = $inst_notif->ajouter($notif_val); |
3800 |
if ($add_notif === false) { |
if ($add_notif === false) { |
3801 |
|
$this->addToMessage(__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).")); |
3802 |
return false; |
return false; |
3803 |
} |
} |
3804 |
|
|
3805 |
// Si il y a une lettretype stockage de la clé d'accès au document |
// Si il y a une lettretype finalisé stockage de la clé d'accès au documents |
3806 |
// TODO : gerer le cas ou il y a une annexe |
if ($this->evenement_has_an_edition($this->getVal('evenement')) === true) { |
3807 |
/* |
$add_notif_doc = $this->ajouter_notification_document( |
3808 |
if ($this->evenement_has_an_edition($this->getVal('evenement')) === true ) { |
$inst_notif->getVal($inst_notif->clePrimaire), |
3809 |
$inst_notif_doc = $this->f->get_inst__om_dbform(array( |
$this->getVal($this->clePrimaire), |
3810 |
"obj" => "instruction_notification_document", |
'instruction' |
|
"idx" => 0, |
|
|
)); |
|
|
$notif_doc_val = array( |
|
|
'instruction_notification_document' => null, |
|
|
'instruction_notification' => $inst_notif->getVal($this->clePrimaire), |
|
|
'instruction' => $this->getCleAccesDocument(), |
|
|
'cle' => null, |
|
|
'annexe' => false |
|
3811 |
); |
); |
|
|
|
|
$add_notif_doc = $inst_notif_doc->ajouter($notif_doc_val); |
|
3812 |
if ($add_notif_doc === false) { |
if ($add_notif_doc === false) { |
3813 |
|
$this->addToMessage(__("Erreur lors de la génération de la notification du document.")); |
3814 |
|
return false; |
3815 |
|
} |
3816 |
|
} |
3817 |
|
// Si une annexe a été choisie stockage de la clé d'accès à l'annexe |
3818 |
|
if (! empty($annexes) && is_array($annexes)) { |
3819 |
|
$add_notif_annexe = $this->ajouter_notification_document_multiple( |
3820 |
|
$inst_notif->getVal($inst_notif->clePrimaire), |
3821 |
|
$annexes |
3822 |
|
); |
3823 |
|
if ($add_notif_annexe === false) { |
3824 |
|
$this->addToMessage(__("Erreur lors de la génération de la notification de l'annexe.")); |
3825 |
return false; |
return false; |
3826 |
} |
} |
3827 |
}*/ |
} |
3828 |
|
|
3829 |
// Renvoie l'id de la nouvelle instance de instruction_notification |
// Renvoie l'id de la nouvelle instance de instruction_notification |
3830 |
return $inst_notif->getVal($inst_notif->clePrimaire); |
return $inst_notif->getVal($inst_notif->clePrimaire); |
3831 |
} |
} |
3832 |
|
|
3833 |
/** |
/** |
3834 |
|
* Pour chaque élément du tableau passé en paramètre ajoute une nouvelle |
3835 |
|
* instance dans la table instruction_notification_document lié a la |
3836 |
|
* notification dont l'id est passé en paramètre. |
3837 |
|
* |
3838 |
|
* @param array tableau contenant les informations nécessaires pour créer les annexes |
3839 |
|
* |
3840 |
|
* @return integer|boolean identifiant de la notification créée si le traitement |
3841 |
|
* a réussie, false sinon. |
3842 |
|
*/ |
3843 |
|
protected function ajouter_notification_document_multiple($idNotification, $listeDocument) { |
3844 |
|
foreach ($listeDocument as $paramDoc) { |
3845 |
|
if (! $this->ajouter_notification_document($idNotification, $paramDoc['id'], $paramDoc['tableDocument'], $paramDoc['isAnnexe'])) { |
3846 |
|
$this->addToMessage(__("Erreur lors de la génération des documents à notifier.")); |
3847 |
|
return false; |
3848 |
|
} |
3849 |
|
} |
3850 |
|
return true; |
3851 |
|
} |
3852 |
|
|
3853 |
|
/** |
3854 |
|
* Ajoute un élément dans la table instruction_notification_document en utilisant |
3855 |
|
* les éléments fourni en paramètre |
3856 |
|
* |
3857 |
|
* @param integer $idNotification : id de la notification à laquelle on associe le document |
3858 |
|
* @param integer $idDocument : id de l'objet auquel est rattaché le document |
3859 |
|
* @param string $tableDocument : nom de la table a laquelle est rattaché le document |
3860 |
|
* @param boolean $isAnnexe : indique si le document est une annexe ou pas |
3861 |
|
* |
3862 |
|
* @return boolean indique si le traitement a réussi |
3863 |
|
*/ |
3864 |
|
protected function ajouter_notification_document($idNotification, $idDocument, $tableDocument, $isAnnexe = false) { |
3865 |
|
$inst_notif_doc = $this->f->get_inst__om_dbform(array( |
3866 |
|
"obj" => "instruction_notification_document", |
3867 |
|
"idx" => "]", |
3868 |
|
)); |
3869 |
|
// l'attribut instruction doit obligatoirement être renseigné |
3870 |
|
// pour éviter toutes confusion avec d'autres instruction l'id |
3871 |
|
// 0 est donné au document n'appartenant pas aux instructions |
3872 |
|
$notif_doc_val = array( |
3873 |
|
'instruction_notification_document' => null, |
3874 |
|
'instruction_notification' => $idNotification, |
3875 |
|
'instruction' => $tableDocument == 'instruction' ? $idDocument : 0, |
3876 |
|
'document_type' => $tableDocument, |
3877 |
|
'document_id' => $idDocument, |
3878 |
|
'cle' => $this->getCleAccesDocument(), |
3879 |
|
'annexe' => $isAnnexe |
3880 |
|
); |
3881 |
|
|
3882 |
|
$add_notif_doc = $inst_notif_doc->ajouter($notif_doc_val); |
3883 |
|
if ($add_notif_doc === false) { |
3884 |
|
return false; |
3885 |
|
} |
3886 |
|
return true; |
3887 |
|
} |
3888 |
|
|
3889 |
|
/** |
3890 |
|
* Vérifie si le paramétrage de la notification des demandeurs est correct. |
3891 |
|
* |
3892 |
|
* @param integer identifiant de la collectivité |
3893 |
|
* @return boolean |
3894 |
|
*/ |
3895 |
|
protected function is_parametrage_notification_correct($collectiviteId) { |
3896 |
|
$categorie = $this->f->get_param_option_notification($collectiviteId); |
3897 |
|
$urlAccesNotif = $this->f->get_parametre_notification_url_acces($collectiviteId); |
3898 |
|
if ($categorie == 'mail' && $urlAccesNotif == null) { |
3899 |
|
return false; |
3900 |
|
} |
3901 |
|
return true; |
3902 |
|
} |
3903 |
|
|
3904 |
|
/** |
3905 |
* TRIGGER - triggermodifierapres. |
* TRIGGER - triggermodifierapres. |
3906 |
* |
* |
3907 |
* @return boolean |
* @return boolean |
4030 |
"idx" => $this->valF['dossier'], |
"idx" => $this->valF['dossier'], |
4031 |
)); |
)); |
4032 |
$valF['instruction'] = $id; |
$valF['instruction'] = $id; |
4033 |
|
$valF['crud'] = 'update'; |
4034 |
$update_by_instruction = $inst_dossier->update_by_instruction($valF); |
$update_by_instruction = $inst_dossier->update_by_instruction($valF); |
4035 |
if ($update_by_instruction === false) { |
if ($update_by_instruction === false) { |
4036 |
$this->cleanMessage(); |
$this->cleanMessage(); |
4247 |
$ev = $this->get_inst_evenement($this->valF['evenement']); |
$ev = $this->get_inst_evenement($this->valF['evenement']); |
4248 |
if ($ev->getVal('notification') === 'notification_auto_signature_requise') { |
if ($ev->getVal('notification') === 'notification_auto_signature_requise') { |
4249 |
// Récupération de la liste des demandeurs à notifier et de la catégorie |
// Récupération de la liste des demandeurs à notifier et de la catégorie |
|
$demandeursANotifie = $this->get_demandeurs_notifiable(); |
|
4250 |
$categorie = $this->f->get_param_option_notification($collectivite_di); |
$categorie = $this->f->get_param_option_notification($collectivite_di); |
4251 |
|
$isPortal = $categorie == null || $categorie == '' || $categorie == 'portal' ? true : false; |
4252 |
|
$demandeursANotifie = $this->get_demandeurs_notifiable( |
4253 |
|
$this->valF['dossier'], |
4254 |
|
$isPortal |
4255 |
|
); |
4256 |
|
|
4257 |
// Création d'une notification et d'une tâche pour chaque demandeur à notifier |
// Création d'une notification et d'une tâche pour chaque demandeur à notifier |
4258 |
|
$demandeurPrincipalNotifie = false; |
4259 |
foreach ($demandeursANotifie as $demandeur) { |
foreach ($demandeursANotifie as $demandeur) { |
4260 |
|
// Identifie si le demandeur principal a été notifié ou pas |
4261 |
|
// et récupère ses informations |
4262 |
|
if ($demandeur['petitionnaire_principal'] == 't') { |
4263 |
|
$demandeurPrincipalNotifie = true; |
4264 |
|
// Si le demandeur principal est notifiable mais qu'il y a des erreurs dans |
4265 |
|
// son paramétrage, on effectue pas le traitement et on passe à l'itération |
4266 |
|
// suivante. On le considère également comme non notifié pour gérer l'envoie |
4267 |
|
// des messages d'erreurs |
4268 |
|
// Si la demande a été déposée via le portail alors le paramétrage n'a pas |
4269 |
|
// d'impact sur la notification |
4270 |
|
$erreursParam = $this->get_info_notification_fail(); |
4271 |
|
if (! $this->dossier_depose_sur_portail() && $erreursParam != array()) { |
4272 |
|
$demandeurPrincipalNotifie = false; |
4273 |
|
continue; |
4274 |
|
} |
4275 |
|
} |
4276 |
// Ajout de la notif et récupération de son id |
// Ajout de la notif et récupération de son id |
4277 |
$idNotif = $this->ajouter_notification( |
$idNotif = $this->ajouter_notification( |
4278 |
$this->valF[$this->clePrimaire], |
$this->valF[$this->clePrimaire], |
|
true, |
|
4279 |
$this->f->get_connected_user_login_name(), |
$this->f->get_connected_user_login_name(), |
4280 |
$demandeur |
$demandeur, |
4281 |
|
$collectivite_di, |
4282 |
|
array(), |
4283 |
|
true |
4284 |
); |
); |
4285 |
if ($idNotif === false) { |
if ($idNotif === false) { |
|
$this->addToMessage( |
|
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
|
|
); |
|
4286 |
return false; |
return false; |
4287 |
} |
} |
4288 |
// Création de la tache en lui donnant l'id de la notification |
// Création de la tache en lui donnant l'id de la notification |
4298 |
return false; |
return false; |
4299 |
} |
} |
4300 |
} |
} |
4301 |
|
// Si le demandeur principal n'est pas notifiable, on créé une nouvelle notification |
4302 |
|
// en erreur avec en commentaire la raison pour laquelle le demandeur principal |
4303 |
|
// n'a pas pu être notifié |
4304 |
|
if (! $demandeurPrincipalNotifie) { |
4305 |
|
// Analyse pour savoir pourquoi le demandeur principal n'est pas notifiable |
4306 |
|
$erreursParam = $this->get_info_notification_fail(); |
4307 |
|
$demandeurPrincipal = $this->get_info_petitionnaire_principal_dossier($this->getVal('dossier')); |
4308 |
|
// Ajout de la notif et récupération de son id |
4309 |
|
$idNotif = $this->ajouter_notification( |
4310 |
|
$this->valF[$this->clePrimaire], |
4311 |
|
$this->f->get_connected_user_login_name(), |
4312 |
|
$demandeurPrincipal, |
4313 |
|
$collectivite_di, |
4314 |
|
array(), |
4315 |
|
true, |
4316 |
|
'Echec', |
4317 |
|
implode(' ', $erreursParam) |
4318 |
|
); |
4319 |
|
if ($idNotif === false) { |
4320 |
|
$this->addToMessage( |
4321 |
|
__('Erreur : la création de la notification a échouée.'). |
4322 |
|
__("Veuillez contacter votre administrateur.") |
4323 |
|
); |
4324 |
|
return false; |
4325 |
|
} |
4326 |
|
// Prépare un message d'alerte à destination de l'instructeur pour l'informer |
4327 |
|
// de l'échec de la notification |
4328 |
|
$dossier_message = $this->get_inst_dossier_message(0); |
4329 |
|
$dossier_message_val = array( |
4330 |
|
'dossier' => $this->getVal('dossier'), |
4331 |
|
'type' => _('erreur expedition'), |
4332 |
|
'emetteur' => $this->f->get_connected_user_login_name(), |
4333 |
|
'login' => $_SESSION['login'], |
4334 |
|
'date_emission' => date('Y-m-d H:i:s'), |
4335 |
|
'contenu' => _('Échec lors de la notification de l\'instruction '). |
4336 |
|
$ev->getVal('libelle'). |
4337 |
|
'.<br>'. |
4338 |
|
implode("\n", $erreursParam). |
4339 |
|
'<br>'. |
4340 |
|
_('Veuillez corriger ces informations avant de renvoyer la notification.') |
4341 |
|
); |
4342 |
|
$add = $dossier_message->add_notification_message($dossier_message_val, true); |
4343 |
|
// Si une erreur se produit pendant l'ajout |
4344 |
|
if ($add !== true) { |
4345 |
|
$this->addToLog(__METHOD__."(): Le message d'alerte concernant l'echec de l'envoi de la notification n'a pas pu être envoyé.", DEBUG_MODE); |
4346 |
|
return false; |
4347 |
|
} |
4348 |
|
} |
4349 |
$this->addToMessage($message .= sprintf('%s<br/>%s', __("La notification a été générée."), __("Le suivi de la notification est disponible depuis l'instruction."))); |
$this->addToMessage($message .= sprintf('%s<br/>%s', __("La notification a été générée."), __("Le suivi de la notification est disponible depuis l'instruction."))); |
4350 |
} |
} |
4351 |
} |
} |
4440 |
} |
} |
4441 |
} |
} |
4442 |
// On supprime toutes les notications liées à l'instruction |
// On supprime toutes les notications liées à l'instruction |
4443 |
$notifASupprimer = $this->get_instruction_notification($this->getVal($this->clePrimaire)); |
$notifASupprimer = $this->get_instruction_notification( |
4444 |
|
$this->getVal($this->clePrimaire), |
4445 |
|
array( |
4446 |
|
'notification_recepisse', |
4447 |
|
'notification_instruction', |
4448 |
|
'notification_decision', |
4449 |
|
'notification_service_consulte', |
4450 |
|
'notification_tiers_consulte', |
4451 |
|
), |
4452 |
|
true |
4453 |
|
); |
4454 |
|
|
4455 |
foreach ($notifASupprimer as $idNotif) { |
foreach ($notifASupprimer as $idNotif) { |
4456 |
$inst_notif = $this->f->get_inst__om_dbform(array( |
$inst_notif = $this->f->get_inst__om_dbform(array( |
4457 |
"obj" => "instruction_notification", |
"obj" => "instruction_notification", |
4476 |
|
|
4477 |
// On met à jour le dossier |
// On met à jour le dossier |
4478 |
$valF['instruction'] = $id; |
$valF['instruction'] = $id; |
4479 |
|
$valF['crud'] = 'delete'; |
4480 |
$update_by_instruction = $inst_di->update_by_instruction($valF); |
$update_by_instruction = $inst_di->update_by_instruction($valF); |
4481 |
if ($update_by_instruction === false) { |
if ($update_by_instruction === false) { |
4482 |
$this->cleanMessage(); |
$this->cleanMessage(); |
4615 |
} |
} |
4616 |
|
|
4617 |
/** |
/** |
4618 |
|
* Surcharge de la méthode verifier() de la classe om_dbform pour y ajouter |
4619 |
|
* les vérifications suivantes : |
4620 |
|
* - Si l'instruction à un événement associé et que cet événement à des restrictions : |
4621 |
|
* 1. vérifie si la restriction est valide, si ce n'est pas le cas récupère et affiche |
4622 |
|
* le message d'erreur associé à la restriction |
4623 |
|
* 2. vérifie si les restrictions sont respectées. Si ce n'est pas le cas bloque l'ajout |
4624 |
|
* et / ou la modification et affiche un message d'erreur |
4625 |
|
* - |
4626 |
|
* - |
4627 |
|
* - |
4628 |
|
* - |
4629 |
|
* - |
4630 |
|
* - |
4631 |
|
* |
4632 |
|
* @param array val : tableau contenant les valeurs issues du formulaire. |
4633 |
|
* @param - dnu1 : Paramètre déprécié et non utilisé. |
4634 |
|
* @param - dnu2 : Paramètre déprécié et non utilisé. |
4635 |
|
* |
4636 |
* @return void |
* @return void |
4637 |
*/ |
*/ |
4638 |
function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
4714 |
} |
} |
4715 |
|
|
4716 |
} |
} |
4717 |
|
|
4718 |
|
/** |
4719 |
|
* Récupère et stocket dans un tableau toutes les infos du pétitionnaire |
4720 |
|
* principal du dossier auquel appartiens l'instruction. |
4721 |
|
* Renvoie un tableau contenant les informations du pétitionnaire principal. |
4722 |
|
* |
4723 |
|
* Si l'identifiant de l'instruction n'a pas pu etre récupéré renvoie false |
4724 |
|
* et affiche un message dans les logs. |
4725 |
|
* En cas d'erreur de base de donnée renvoie false et affiche un message d'erreur. |
4726 |
|
* |
4727 |
|
* @param string identifiant du dossier |
4728 |
|
* @return array|boolean |
4729 |
|
*/ |
4730 |
|
protected function get_info_petitionnaire_principal_dossier($dossier = null) { |
4731 |
|
// Si l'identifiant de l'instruction n'a pas été fournit on récupère celui de |
4732 |
|
// l'objet courant |
4733 |
|
if (empty($dossier)) { |
4734 |
|
$dossier = $this->getVal('dossier'); |
4735 |
|
// Si la récupération de l'identifiant de l'instruction a échoué la méthode renvoie |
4736 |
|
// false et on affiche un message d'erreur dans les logs |
4737 |
|
if (empty($dossier)) { |
4738 |
|
$this->addToLog(__METHOD__.' : L\'identifiant du dossier n\'a pas pu être récupéré'); |
4739 |
|
return false; |
4740 |
|
} |
4741 |
|
} |
4742 |
|
|
4743 |
|
// Requête sql servant à récupérer toutes les informations relatives au demandeurs |
4744 |
|
// principal |
4745 |
|
$sql = sprintf( |
4746 |
|
'SELECT |
4747 |
|
-- Récupère toutes les informations du demandeur principal |
4748 |
|
demandeur.*, |
4749 |
|
CASE |
4750 |
|
WHEN demandeur.qualite=\'particulier\' |
4751 |
|
THEN TRIM(CONCAT(demandeur.particulier_nom, \' \', demandeur.particulier_prenom, \' \', demandeur.courriel)) |
4752 |
|
ELSE |
4753 |
|
TRIM(CONCAT(demandeur.personne_morale_raison_sociale, \' \', demandeur.personne_morale_denomination, \' \', demandeur.courriel)) |
4754 |
|
END AS destinataire |
4755 |
|
FROM |
4756 |
|
%1$sdossier |
4757 |
|
LEFT JOIN %1$slien_dossier_demandeur |
4758 |
|
ON lien_dossier_demandeur.dossier = dossier.dossier |
4759 |
|
LEFT JOIN %1$sdemandeur |
4760 |
|
ON demandeur.demandeur = lien_dossier_demandeur.demandeur |
4761 |
|
WHERE |
4762 |
|
dossier.dossier = \'%2$s\' |
4763 |
|
AND lien_dossier_demandeur.petitionnaire_principal IS TRUE', |
4764 |
|
DB_PREFIXE, |
4765 |
|
$dossier |
4766 |
|
); |
4767 |
|
|
4768 |
|
$res = $this->f->get_one_row_result_from_db_query($sql); |
4769 |
|
if ($res['code'] === 'KO') { |
4770 |
|
return false; |
4771 |
|
} |
4772 |
|
return $res['result']; |
4773 |
|
} |
4774 |
|
|
4775 |
|
|
4776 |
|
|
4777 |
/** |
/** |
4778 |
* Finalisation des documents. |
* Finalisation des documents. |
5921 |
|
|
5922 |
|
|
5923 |
// Sinon on vérifie l'éligibilité du dossier au changement de décision |
// Sinon on vérifie l'éligibilité du dossier au changement de décision |
5924 |
$sql = |
// /!\ Requête lié à celles du widget indiquant les dossiers éligible au changement |
5925 |
"SELECT |
// de décision : |
5926 |
|
// * dossier_instruction.class.php : view_widget_dossiers_evenement_retour_finalise() |
5927 |
|
// * dossier_instruction.inc.php : si le paramètre filtre_decision = true |
5928 |
|
$sql = sprintf( |
5929 |
|
'SELECT |
5930 |
dossier.dossier |
dossier.dossier |
5931 |
FROM |
FROM |
5932 |
".DB_PREFIXE."dossier |
%1$sdossier |
5933 |
JOIN ".DB_PREFIXE."instruction ON instruction.instruction = ( |
JOIN %1$setat |
5934 |
SELECT instruction |
ON dossier.etat = etat.etat AND etat.statut = \'encours\' |
5935 |
FROM ".DB_PREFIXE."instruction |
JOIN %1$slien_dossier_demandeur |
5936 |
JOIN ".DB_PREFIXE."evenement on instruction.evenement=evenement.evenement |
ON dossier.dossier = lien_dossier_demandeur.dossier AND lien_dossier_demandeur.petitionnaire_principal IS TRUE |
5937 |
WHERE instruction.dossier = dossier.dossier |
JOIN %1$sdossier_instruction_type |
5938 |
AND evenement.retour IS FALSE |
ON dossier.dossier_instruction_type=dossier_instruction_type.dossier_instruction_type |
5939 |
ORDER BY date_evenement DESC, instruction DESC |
JOIN %1$sinstruction |
5940 |
LIMIT 1 |
-- Recherche de la dernière instruction qui ne soit pas liée à un événement retour |
5941 |
) |
ON instruction.instruction = ( |
5942 |
JOIN ".DB_PREFIXE."evenement ON instruction.evenement=evenement.evenement |
SELECT instruction |
5943 |
JOIN ".DB_PREFIXE."instructeur ON dossier.instructeur=instructeur.instructeur |
FROM %1$sinstruction |
5944 |
JOIN ".DB_PREFIXE."om_utilisateur ON instructeur.om_utilisateur=om_utilisateur.om_utilisateur |
JOIN %1$sevenement ON instruction.evenement=evenement.evenement |
5945 |
JOIN ".DB_PREFIXE."om_collectivite ON om_collectivite.om_collectivite=om_utilisateur.om_collectivite |
AND evenement.retour IS FALSE |
5946 |
JOIN ".DB_PREFIXE."etat ON dossier.etat = etat.etat |
WHERE instruction.dossier = dossier.dossier |
5947 |
|
ORDER BY date_evenement DESC, instruction DESC |
5948 |
|
LIMIT 1 |
5949 |
|
) |
5950 |
|
-- On ne garde que les dossiers pour lesquels la dernière instruction est finalisée |
5951 |
|
-- ou alors pour laquelle l instruction a été ajouté par la commune et est |
5952 |
|
-- non signée, non notifié, etc. |
5953 |
|
AND (instruction.om_final_instruction IS TRUE |
5954 |
|
OR instruction.created_by_commune IS TRUE) |
5955 |
|
AND instruction.date_retour_signature IS NULL |
5956 |
|
AND instruction.date_envoi_rar IS NULL |
5957 |
|
AND instruction.date_retour_rar IS NULL |
5958 |
|
AND instruction.date_envoi_controle_legalite IS NULL |
5959 |
|
AND instruction.date_retour_controle_legalite IS NULL |
5960 |
|
-- On vérifie que l instruction soit un arrêté ou un changement de décision |
5961 |
|
JOIN %1$sevenement |
5962 |
|
ON instruction.evenement=evenement.evenement |
5963 |
|
AND (evenement.type = \'arrete\' |
5964 |
|
OR evenement.type = \'changement_decision\') |
5965 |
|
-- Recherche les informations du pétitionnaire principal pour l affichage |
5966 |
|
JOIN %1$sdemandeur |
5967 |
|
ON lien_dossier_demandeur.demandeur = demandeur.demandeur |
5968 |
|
-- Recherche la collectivité rattachée à l instructeur |
5969 |
|
JOIN %1$sinstructeur |
5970 |
|
ON dossier.instructeur=instructeur.instructeur |
5971 |
|
JOIN %1$sdivision |
5972 |
|
ON instructeur.division=division.division |
5973 |
|
JOIN %1$sdirection |
5974 |
|
ON division.direction=direction.direction |
5975 |
|
JOIN %1$som_collectivite |
5976 |
|
ON direction.om_collectivite=om_collectivite.om_collectivite |
5977 |
WHERE |
WHERE |
5978 |
|
-- Vérification que la décision a été prise par l agglo |
5979 |
( |
om_collectivite.niveau = \'2\' |
5980 |
evenement.type = 'arrete' AND |
AND dossier.dossier = \'%2$s\' |
5981 |
( |
', |
5982 |
instruction.om_final_instruction IS TRUE |
DB_PREFIXE, |
5983 |
OR instruction.created_by_commune IS TRUE |
$idx |
5984 |
) OR |
); |
|
evenement.type = 'changement_decision' |
|
|
) |
|
|
AND evenement.retour IS FALSE |
|
|
AND instruction.date_retour_signature IS NULL |
|
|
AND instruction.date_envoi_rar IS NULL |
|
|
AND instruction.date_retour_rar IS NULL |
|
|
AND instruction.date_envoi_controle_legalite IS NULL |
|
|
AND instruction.date_retour_controle_legalite IS NULL |
|
|
AND etat.statut = 'encours' |
|
|
AND dossier.dossier = '".$idx."' |
|
|
AND om_collectivite.niveau = '2' |
|
|
"; |
|
5985 |
|
|
5986 |
|
|
5987 |
// Si collectivité de l'utilisateur niveau mono alors filtre sur celle-ci |
// Si collectivité de l'utilisateur niveau mono alors filtre sur celle-ci |
5988 |
if ($this->f->isCollectiviteMono($_SESSION['collectivite']) === true) { |
if ($this->f->isCollectiviteMono($_SESSION['collectivite']) === true) { |
5989 |
$sql .= " AND dossier.om_collectivite=".$_SESSION['collectivite']; |
$sql .= sprintf( |
5990 |
|
' AND dossier.om_collectivite=%1$s', |
5991 |
|
$_SESSION['collectivite'] |
5992 |
|
); |
5993 |
} |
} |
5994 |
$res = $this->f->db->getone($sql); |
$res = $this->f->db->getone($sql); |
5995 |
if (database::isError($res)) { |
if (database::isError($res)) { |
6098 |
// dites de TREATMENT. |
// dites de TREATMENT. |
6099 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
6100 |
$message = ''; |
$message = ''; |
6101 |
|
$ev = $this->get_inst_evenement($this->getVal('evenement')); |
6102 |
|
|
6103 |
|
// Controle du signataire |
6104 |
|
if (! $this->controle_signataire($ev)) { |
6105 |
|
$this->addToMessage(__("Le document ne peut pas être finalisé car aucun signataire n'a été sélectionné.")); |
6106 |
|
// Termine le traitement |
6107 |
|
return $this->end_treatment(__METHOD__, false); |
6108 |
|
} |
6109 |
|
|
6110 |
// Traitement de la finalisation |
// Traitement de la finalisation |
6111 |
$ret = $this->manage_finalizing("finalize", $val); |
$ret = $this->manage_finalizing("finalize", $val); |
6119 |
|
|
6120 |
// Envoi des notifications aux demandeurs si la notification est automatique |
// Envoi des notifications aux demandeurs si la notification est automatique |
6121 |
// et que la signature n'est pas requise |
// et que la signature n'est pas requise |
|
$ev = $this->get_inst_evenement($this->getVal('evenement')); |
|
6122 |
if ($ev->getVal('notification') === 'notification_automatique') { |
if ($ev->getVal('notification') === 'notification_automatique') { |
6123 |
// Récupération de la catégorie et envoie des notifications au(x) demandeur(s) |
// Récupération de la catégorie et envoie des notifications au(x) demandeur(s) |
6124 |
$collectivite_di = $this->get_dossier_instruction_om_collectivite($this->getVal('dossier')); |
$collectivite_di = $this->get_dossier_instruction_om_collectivite($this->getVal('dossier')); |
6125 |
// Récupération de la liste des demandeurs à notifier et de la catégorie |
// Récupération de la liste des demandeurs à notifier et de la catégorie |
|
$demandeursANotifie = $this->get_demandeurs_notifiable(); |
|
6126 |
$categorie = $this->f->get_param_option_notification($collectivite_di); |
$categorie = $this->f->get_param_option_notification($collectivite_di); |
6127 |
|
$isPortal = $categorie == null || $categorie == '' || $categorie == 'portal' ? true : false; |
6128 |
|
$demandeursANotifie = $this->get_demandeurs_notifiable( |
6129 |
|
$this->getVal('dossier'), |
6130 |
|
$isPortal |
6131 |
|
); |
6132 |
|
|
6133 |
// Création d'une notification et d'une tâche pour chaque demandeur à notifier |
// Création d'une notification et d'une tâche pour chaque demandeur à notifier |
6134 |
|
$demandeurPrincipalNotifie = false; |
6135 |
if (count($demandeursANotifie) > 0) { |
if (count($demandeursANotifie) > 0) { |
6136 |
foreach ($demandeursANotifie as $demandeur) { |
foreach ($demandeursANotifie as $demandeur) { |
6137 |
|
// Identifie si le demandeur principal a été notifié ou pas |
6138 |
|
// et récupère ses informations |
6139 |
|
if ($demandeur['petitionnaire_principal'] == 't') { |
6140 |
|
$demandeurPrincipalNotifie = true; |
6141 |
|
// Si le demandeur principal est notifiable mais qu'il y a des erreurs dans |
6142 |
|
// son paramétrage, on effectue pas le traitement et on passe à l'itération |
6143 |
|
// suivante. On le considère également comme non notifié pour gérer l'envoie |
6144 |
|
// des messages d'erreurs |
6145 |
|
// Si la demande a été déposée via le portail alors le paramétrage n'a pas |
6146 |
|
// d'impact sur la notification |
6147 |
|
$erreursParam = $this->get_info_notification_fail(); |
6148 |
|
if (! $this->dossier_depose_sur_portail() && $erreursParam != array()) { |
6149 |
|
$demandeurPrincipalNotifie = false; |
6150 |
|
continue; |
6151 |
|
} |
6152 |
|
} |
6153 |
// Ajout de la notif et récupération de son id |
// Ajout de la notif et récupération de son id |
6154 |
$idNotif = $this->ajouter_notification( |
$idNotif = $this->ajouter_notification( |
6155 |
$this->getVal($this->clePrimaire), |
$this->getVal($this->clePrimaire), |
|
true, |
|
6156 |
$this->f->get_connected_user_login_name(), |
$this->f->get_connected_user_login_name(), |
6157 |
$demandeur |
$demandeur, |
6158 |
|
$collectivite_di, |
6159 |
|
array(), |
6160 |
|
true |
6161 |
); |
); |
6162 |
if ($idNotif === false) { |
if ($idNotif === false) { |
|
$this->addToMessage( |
|
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
|
|
); |
|
6163 |
// Termine le traitement |
// Termine le traitement |
6164 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
6165 |
} |
} |
6175 |
// Termine le traitement |
// Termine le traitement |
6176 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
6177 |
} |
} |
6178 |
|
$this->addToMessage($message .= sprintf('%s<br/>%s', __("La notification a été générée."), __("Le suivi de la notification est disponible depuis l'instruction."))); |
6179 |
|
} |
6180 |
|
} |
6181 |
|
// Si le demandeur principal n'est pas notifiable, on créé une nouvelle notification |
6182 |
|
// en erreur avec en commentaire la raison pour laquelle le demandeur principal |
6183 |
|
// n'a pas pu être notifié |
6184 |
|
if (! $demandeurPrincipalNotifie) { |
6185 |
|
// Analyse pour savoir pourquoi le demandeur principal n'est pas notifiable |
6186 |
|
$erreursParam = $this->get_info_notification_fail(); |
6187 |
|
$demandeurPrincipal = $this->get_info_petitionnaire_principal_dossier($this->getVal('dossier')); |
6188 |
|
// Ajout de la notif et récupération de son id |
6189 |
|
$idNotif = $this->ajouter_notification( |
6190 |
|
$this->valF[$this->clePrimaire], |
6191 |
|
$this->f->get_connected_user_login_name(), |
6192 |
|
$demandeurPrincipal, |
6193 |
|
$collectivite_di, |
6194 |
|
array(), |
6195 |
|
true, |
6196 |
|
'Echec', |
6197 |
|
implode(' ', $erreursParam) |
6198 |
|
); |
6199 |
|
if ($idNotif === false) { |
6200 |
|
$this->addToMessage( |
6201 |
|
__('Erreur : la création de la notification a échouée.'). |
6202 |
|
__("Veuillez contacter votre administrateur.") |
6203 |
|
); |
6204 |
|
return false; |
6205 |
|
} |
6206 |
|
// Prépare un message d'alerte à destination de l'instructeur pour l'informer |
6207 |
|
// de l'échec de la notification |
6208 |
|
$dossier_message = $this->get_inst_dossier_message(0); |
6209 |
|
$dossier_message_val = array( |
6210 |
|
'dossier' => $this->getVal('dossier'), |
6211 |
|
'type' => _('erreur expedition'), |
6212 |
|
'emetteur' => $this->f->get_connected_user_login_name(), |
6213 |
|
'login' => $_SESSION['login'], |
6214 |
|
'date_emission' => date('Y-m-d H:i:s'), |
6215 |
|
'contenu' => _('Échec lors de la notification de l\'instruction '). |
6216 |
|
$ev->getVal('libelle'). |
6217 |
|
'.<br>'. |
6218 |
|
implode("\n", $erreursParam). |
6219 |
|
'<br>'. |
6220 |
|
_('Veuillez corriger ces informations avant de renvoyer la notification.') |
6221 |
|
); |
6222 |
|
$add = $dossier_message->add_notification_message($dossier_message_val, true); |
6223 |
|
// Si une erreur se produit pendant l'ajout |
6224 |
|
if ($add !== true) { |
6225 |
|
$this->addToLog(__METHOD__."(): Le message d'alerte concernant l'echec de l'envoi de la notification n'a pas pu être envoyé.", DEBUG_MODE); |
6226 |
|
return false; |
6227 |
} |
} |
|
$this->addToMessage($message .= sprintf('%s<br/>%s', __("La notification a été générée."), __("Le suivi de la notification est disponible depuis l'instruction."))); |
|
6228 |
} |
} |
6229 |
} |
} |
6230 |
|
|
6233 |
} |
} |
6234 |
|
|
6235 |
/** |
/** |
6236 |
|
* Récupère l'instance de dossier message. |
6237 |
|
* |
6238 |
|
* @param string $dossier_message Identifiant du message. |
6239 |
|
* |
6240 |
|
* @return object |
6241 |
|
*/ |
6242 |
|
private function get_inst_dossier_message($dossier_message = null) { |
6243 |
|
// |
6244 |
|
return $this->get_inst_common("dossier_message", $dossier_message); |
6245 |
|
} |
6246 |
|
|
6247 |
|
/** |
6248 |
|
* Vérifie si le signataire est obligatoire pour finaliser |
6249 |
|
* le document apartir du paramétrage de l'événement. |
6250 |
|
* Si c'est le cas, vérifie si il y a bien un signataire |
6251 |
|
* renseigné. |
6252 |
|
* Si c'est le cas renvoie true, sinon renvoie false. |
6253 |
|
* |
6254 |
|
* @param evenement évenement de l'instruction permettant de |
6255 |
|
* récupérer le paramétrage |
6256 |
|
* @return boolean |
6257 |
|
*/ |
6258 |
|
protected function controle_signataire($evenement) { |
6259 |
|
// Vérifie si le signataire est obligatoire et si c'est le cas |
6260 |
|
// vérifie si il y a bien un signataire pour le document |
6261 |
|
if ($evenement->is_signataire_obligatoire() && |
6262 |
|
($this->getVal('signataire_arrete') === null || |
6263 |
|
$this->getVal('signataire_arrete') === '')) { |
6264 |
|
return false; |
6265 |
|
} |
6266 |
|
return true; |
6267 |
|
} |
6268 |
|
|
6269 |
|
/** |
6270 |
* TREATMENT - unfinalize. |
* TREATMENT - unfinalize. |
6271 |
* |
* |
6272 |
* Permet de définaliser un enregistrement. |
* Permet de définaliser un enregistrement. |
6545 |
$this->f->isDatabaseError($consultation); |
$this->f->isDatabaseError($consultation); |
6546 |
// Si consultation liée, récupération du retour d'avis |
// Si consultation liée, récupération du retour d'avis |
6547 |
if($consultation=='Oui'){ |
if($consultation=='Oui'){ |
6548 |
$sql="select date_retour,avis_consultation.libelle as avis_consultation, |
$sql = sprintf( |
6549 |
service.libelle as service |
'(SELECT |
6550 |
from ".DB_PREFIXE."consultation inner join ".DB_PREFIXE."service |
date_retour, |
6551 |
on consultation.service =service.service |
avis_consultation.libelle as avis_consultation, |
6552 |
left join ".DB_PREFIXE."avis_consultation on |
COALESCE(service.libelle, tiers_consulte.libelle) as service |
6553 |
consultation.avis_consultation = avis_consultation.avis_consultation |
FROM |
6554 |
where dossier ='".$idx."' and consultation.visible"; |
%1$sconsultation |
6555 |
|
LEFT JOIN %1$stiers_consulte ON consultation.tiers_consulte = tiers_consulte.tiers_consulte |
6556 |
|
LEFT JOIN %1$sservice ON consultation.service = service.service |
6557 |
|
LEFT JOIN %1$savis_consultation ON consultation.avis_consultation = avis_consultation.avis_consultation |
6558 |
|
WHERE |
6559 |
|
dossier = \'%2$s\' |
6560 |
|
AND consultation.visible)', |
6561 |
|
DB_PREFIXE, |
6562 |
|
$this->f->db->escapeSimple($idx) |
6563 |
|
); |
6564 |
$res = $this->f->db->query($sql); |
$res = $this->f->db->query($sql); |
6565 |
$this->f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
6566 |
// Récupération des consultations |
// Récupération des consultations |
6617 |
$merge_fields = array(); |
$merge_fields = array(); |
6618 |
// |
// |
6619 |
if (array_key_exists('c1', $_POST) === true) { |
if (array_key_exists('c1', $_POST) === true) { |
6620 |
$merge_fields['[complement_instruction]'] = urldecode($_POST['c1']); |
$merge_fields['[complement_instruction]'] = $_POST['c1']; |
6621 |
$merge_fields['[complement1_instruction]'] = urldecode($_POST['c1']); |
$merge_fields['[complement1_instruction]'] = $_POST['c1']; |
6622 |
} |
} |
6623 |
if (array_key_exists('c2', $_POST) === true) { |
if (array_key_exists('c2', $_POST) === true) { |
6624 |
$merge_fields['[complement2_instruction]'] = urldecode($_POST['c2']); |
$merge_fields['[complement2_instruction]'] = $_POST['c2']; |
6625 |
} |
} |
6626 |
if (array_key_exists('c3', $_POST) === true) { |
if (array_key_exists('c3', $_POST) === true) { |
6627 |
$merge_fields['[complement3_instruction]'] = urldecode($_POST['c3']); |
$merge_fields['[complement3_instruction]'] = $_POST['c3']; |
6628 |
} |
} |
6629 |
if (array_key_exists('c4', $_POST) === true) { |
if (array_key_exists('c4', $_POST) === true) { |
6630 |
$merge_fields['[complement4_instruction]'] = urldecode($_POST['c4']); |
$merge_fields['[complement4_instruction]'] = $_POST['c4']; |
6631 |
} |
} |
6632 |
$params = array( |
$params = array( |
6633 |
"watermark" => true, |
"watermark" => true, |
6639 |
if (array_key_exists('corps', $_POST) === true) { |
if (array_key_exists('corps', $_POST) === true) { |
6640 |
$params["specific"]["corps"] = array( |
$params["specific"]["corps"] = array( |
6641 |
"mode" => "set", |
"mode" => "set", |
6642 |
"value" => urldecode($_POST['corps']), |
"value" => $_POST['corps'], |
6643 |
); |
); |
6644 |
} |
} |
6645 |
if (array_key_exists('titre', $_POST) === true) { |
if (array_key_exists('titre', $_POST) === true) { |
6646 |
$params["specific"]["titre"] = array( |
$params["specific"]["titre"] = array( |
6647 |
"mode" => "set", |
"mode" => "set", |
6648 |
"value" => urldecode($_POST['titre']), |
"value" => $_POST['titre'], |
6649 |
); |
); |
6650 |
} |
} |
6651 |
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
7378 |
|
|
7379 |
if($res->numrows() == 1) { |
if($res->numrows() == 1) { |
7380 |
$liste_champs = explode(";", $type_mise_a_jour); |
$liste_champs = explode(";", $type_mise_a_jour); |
7381 |
|
$row =& $res->fetchRow(DB_FETCHMODE_ASSOC); |
7382 |
|
$instr = $this->f->get_inst__om_dbform(array( |
7383 |
|
"obj" => "instruction", |
7384 |
|
"idx" => $row['instruction'], |
7385 |
|
)); |
7386 |
// Mise à jour des dates après l'écran de verification |
// Mise à jour des dates après l'écran de verification |
7387 |
if($this->f->get_submitted_post_value('is_valid') !== null and $this->f->get_submitted_post_value('is_valid') == "true") { |
if($this->f->get_submitted_post_value('is_valid') !== null and $this->f->get_submitted_post_value('is_valid') == "true") { |
|
$row =& $res->fetchRow(DB_FETCHMODE_ASSOC); |
|
|
$instr = $this->f->get_inst__om_dbform(array( |
|
|
"obj" => "instruction", |
|
|
"idx" => $row['instruction'], |
|
|
)); |
|
7388 |
$valF = array(); |
$valF = array(); |
7389 |
foreach($instr->champs as $id => $champ) { |
foreach($instr->champs as $id => $champ) { |
7390 |
$valF[$champ] = $instr->val[$id]; |
$valF[$champ] = $instr->val[$id]; |
7489 |
|
|
7490 |
// Vérification de la non modification des dates de suivi |
// Vérification de la non modification des dates de suivi |
7491 |
foreach(explode(";", $type_mise_a_jour) as $champ) { |
foreach(explode(";", $type_mise_a_jour) as $champ) { |
7492 |
|
if ($champ === 'date_envoi_controle_legalite') { |
7493 |
|
if ($instr->is_sent_to_cl() === true) { |
7494 |
|
$error = __("Les dates de suivis ne peuvent etre modifiees"); |
7495 |
|
$date_error = true; |
7496 |
|
break; |
7497 |
|
} |
7498 |
|
} |
7499 |
if($infos[$champ] != "" AND $infos[$champ] != $date) { |
if($infos[$champ] != "" AND $infos[$champ] != $date) { |
7500 |
$error = _("Les dates de suivis ne peuvent etre modifiees"); |
$error = _("Les dates de suivis ne peuvent etre modifiees"); |
7501 |
$date_error = true; |
$date_error = true; |
7502 |
|
break; |
7503 |
} |
} |
7504 |
} |
} |
7505 |
} |
} |
8066 |
} |
} |
8067 |
|
|
8068 |
/** |
/** |
8069 |
|
* VIEW - view_overlay_notification_service_consulte. |
8070 |
|
* |
8071 |
|
* Ouvre le sous-formulaire de notification des services consulte |
8072 |
|
* en ajaxIt dans un overlay. |
8073 |
|
* Cette action est bindée pour utiliser la fonction popUpIt. |
8074 |
|
* |
8075 |
|
* @return void |
8076 |
|
*/ |
8077 |
|
function view_overlay_notification_service_consulte() { |
8078 |
|
|
8079 |
|
// Vérification de l'accessibilité sur l'élément |
8080 |
|
$this->checkAccessibility(); |
8081 |
|
|
8082 |
|
printf( |
8083 |
|
'<script type="text/javascript" > |
8084 |
|
overlayIt(\'%1$s\',\'%2$s&objsf=%1$s&idxformulaire=%4$s&retourformulaire=dossier_instruction&obj=%1$s&action=420&idx=%3$s\', 1); |
8085 |
|
</script>', |
8086 |
|
'instruction_notification_manuelle', |
8087 |
|
OM_ROUTE_SOUSFORM, |
8088 |
|
$this->getVal($this->clePrimaire), |
8089 |
|
$this->getVal('dossier') |
8090 |
|
); |
8091 |
|
} |
8092 |
|
|
8093 |
|
/** |
8094 |
|
* VIEW - overlay_notification_tiers_consulte. |
8095 |
|
* |
8096 |
|
* Ouvre le sous-formulaire de notification des tiers consulte |
8097 |
|
* en ajaxIt dans un overlay. |
8098 |
|
* Cette action est bindée pour utiliser la fonction popUpIt. |
8099 |
|
* |
8100 |
|
* @return void |
8101 |
|
*/ |
8102 |
|
function view_overlay_notification_tiers_consulte() { |
8103 |
|
|
8104 |
|
// Vérification de l'accessibilité sur l'élément |
8105 |
|
$this->checkAccessibility(); |
8106 |
|
|
8107 |
|
printf( |
8108 |
|
'<script type="text/javascript" > |
8109 |
|
overlayIt(\'%1$s\',\'%2$s&objsf=%1$s&idxformulaire=%4$s&retourformulaire=dossier_instruction&obj=%1$s&action=430&idx=%3$s\', 1); |
8110 |
|
</script>', |
8111 |
|
'instruction_notification_manuelle', |
8112 |
|
OM_ROUTE_SOUSFORM, |
8113 |
|
$this->getVal($this->clePrimaire), |
8114 |
|
$this->getVal('dossier') |
8115 |
|
); |
8116 |
|
} |
8117 |
|
/** |
8118 |
* Retourne l'événement d'instruction dont on donne le code-barres, avec un filtre |
* Retourne l'événement d'instruction dont on donne le code-barres, avec un filtre |
8119 |
* pour exclure les dossiers du groupe contentieux. |
* pour exclure les dossiers du groupe contentieux. |
8120 |
* |
* |
8342 |
// Cette méthode permet d'exécuter une routine en début des méthodes |
// Cette méthode permet d'exécuter une routine en début des méthodes |
8343 |
// dites de TREATMENT. |
// dites de TREATMENT. |
8344 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
8345 |
// Définition des paramètres |
$message = __('Erreur de paramétrage :'); |
8346 |
$p_objet = 'param_courriel_de_notification_commune_objet_depuis_instruction'; |
$erreurParametrage = false; |
8347 |
$p_modele = 'param_courriel_de_notification_commune_modele_depuis_instruction'; |
// Récupération du paramétrage de la collectivité du dossier |
|
$p_courriel = 'param_courriel_de_notification_commune'; |
|
|
// Définition des variables de substitution |
|
8348 |
$id_di = $this->getVal('dossier'); |
$id_di = $this->getVal('dossier'); |
|
$id_inst = $this->getVal($this->clePrimaire); |
|
|
// Instanciation du DI |
|
8349 |
$di = $this->get_inst_dossier($id_di); |
$di = $this->get_inst_dossier($id_di); |
|
// Récupération du paramétrage de la collectivité du dossier |
|
8350 |
$collectivite_di = $di->getVal('om_collectivite'); |
$collectivite_di = $di->getVal('om_collectivite'); |
8351 |
$params_mono = $this->f->getCollectivite($collectivite_di); |
// Récupération de l'url permettant d'accèder à l'instruction et au dossier |
8352 |
// Récupération du paramétrage de la collectivité multi |
$urlAcces = $this->f->get_parametre_notification_url_acces($collectivite_di); |
8353 |
$collectivite_multi = $this->f->get_idx_collectivite_multi(); |
if (empty($urlAcces) && empty(PATH_BASE_URL)) { |
8354 |
$params_multi = $this->f->getCollectivite($collectivite_multi); |
$erreurParametrage = true; |
8355 |
// Vérification de l'objet (obligatoirement multi) |
$message .= '<br>'.__("* l'url de notification n'est pas correctement paramétré"); |
8356 |
$objet = null; |
} |
8357 |
if (isset($params_multi[$p_objet]) === true |
|
8358 |
&& $params_multi[$p_objet] !== '') { |
// Récupération de la liste des mails |
8359 |
$objet = $params_multi[$p_objet]; |
$adresses = $this->f->get_param_courriel_de_notification_commune($collectivite_di); |
8360 |
} |
if (empty($adresses)) { |
8361 |
// Vérification du modèle mono en priorité |
$erreurParametrage = true; |
8362 |
$modele = null; |
$message .= '<br>'.__("* aucun courriel valide de destinataire de la commune"); |
8363 |
if (isset($params_mono[$p_modele]) === true |
} |
8364 |
&& $params_mono[$p_modele] !== '') { |
|
8365 |
$modele = $params_mono[$p_modele]; |
// Vérification du paramétrage des mails |
8366 |
|
$paramMail = $this->f->get_notification_commune_parametre_courriel_type($collectivite_di); |
8367 |
} |
if (empty($paramMail) || empty($paramMail['parametre_courriel_type_message'])) { |
8368 |
// Sinon vérification du modèle multi |
$erreurParametrage = true; |
8369 |
if ($modele === null |
$message .= '<br>'.__("* le modèle du courriel envoyé aux communes est vide"); |
8370 |
&& isset($params_multi[$p_modele]) === true |
} |
8371 |
&& $params_multi[$p_modele] !== '') { |
if (empty($paramMail) || empty($paramMail['parametre_courriel_type_titre'])) { |
8372 |
$modele = $params_multi[$p_modele]; |
$erreurParametrage = true; |
8373 |
} |
$message .= '<br>'.__("* l'objet du courriel envoyé aux communes est vide"); |
8374 |
// Vérification des adresses de courriel mono |
} |
8375 |
$courriels_valides = array(); |
|
8376 |
$courriels_invalides = array(); |
// Si il y a des erreurs de paramétrage on ne déclenche pas la notification et |
8377 |
if (isset($params_mono[$p_courriel]) === true |
// un message a destination de l'utilisateur est affiché |
8378 |
&& $params_mono[$p_courriel] !== '') { |
if ($erreurParametrage) { |
8379 |
// Un mail par ligne |
$message .= '<br>'.__("Veuillez contacter votre administrateur."); |
8380 |
$adresses = explode("\n", $params_mono[$p_courriel]); |
$this->addToMessage($message); |
8381 |
// Vérification de la validité de chaque mail avec preg_match |
return $this->end_treatment(__METHOD__, false); |
|
foreach ($adresses as $adresse) { |
|
|
$adresse = trim($adresse); |
|
|
if ($this->f->checkValidEmailAddress($adresse) === 1) { |
|
|
$courriels_valides[] = $adresse; |
|
|
} else { |
|
|
$courriels_invalides[] = $adresse; |
|
|
} |
|
|
} |
|
8382 |
} |
} |
8383 |
// Vérification du paramétrage global : |
|
8384 |
// on stoppe le traitement si au moins un paramètre est incorrect |
// Création d'un notification et de sa tâche associé pour chaque mail |
8385 |
if ($objet === null |
foreach ($adresses as $adresse) { |
8386 |
|| $modele === null |
// Ajout de la notif et récupération de son id |
8387 |
|| count($courriels_valides) === 0 |
$destinataire = array( |
8388 |
|| count($courriels_invalides) > 0) { |
'destinataire' => $adresse, |
8389 |
// On construit le message d'erreur adéquat |
'courriel' => $adresse |
8390 |
$this->addToMessage(_('Erreur de paramétrage :')); |
); |
8391 |
if ($objet === null) { |
$idNotif = $this->ajouter_notification( |
8392 |
$this->addToMessage(_("* l'objet du courriel envoyé aux communes est vide")); |
$this->getVal($this->clePrimaire), |
8393 |
} |
$this->f->get_connected_user_login_name(), |
8394 |
if ($modele === null) { |
$destinataire, |
8395 |
$this->addToMessage(_("* le modèle du courriel envoyé aux communes est vide")); |
$collectivite_di |
8396 |
} |
); |
8397 |
if (count($courriels_valides) === 0) { |
if ($idNotif === false) { |
8398 |
$this->addToMessage(_("* aucun courriel valide de destinataire de la commune")); |
$this->addToMessage(__("Veuillez contacter votre administrateur.")); |
8399 |
|
return $this->end_treatment(__METHOD__, false); |
8400 |
} |
} |
8401 |
if (count($courriels_invalides) > 0) { |
// Création de la tache en lui donnant l'id de la notification |
8402 |
$courriels_invalides = implode(', ', $courriels_invalides); |
$notification_by_task = $this->notification_by_task( |
8403 |
$this->addToMessage(_("* un ou plusieurs courriels des destinataires de la commune sont invalides : ").$courriels_invalides); |
$idNotif, |
8404 |
|
$this->getVal('dossier'), |
8405 |
|
'mail', |
8406 |
|
'notification_commune' |
8407 |
|
); |
8408 |
|
if ($notification_by_task === false) { |
8409 |
|
$this->addToMessage(__("Erreur lors de la préparation de la notification des communes.")); |
8410 |
|
$this->addToMessage(__("Veuillez contacter votre administrateur.")); |
8411 |
|
return $this->end_treatment(__METHOD__, false); |
8412 |
} |
} |
|
$this->addToMessage(_("Veuillez contacter votre administrateur.")); |
|
|
return $this->end_treatment(__METHOD__, false); |
|
|
} |
|
|
// Remplacement des variables de substitution |
|
|
$objet = str_replace('<DOSSIER_INSTRUCTION>', $id_di, $objet); |
|
|
$modele = $this->formater_modele($modele, $id_di, $id_inst); |
|
|
// Exécution du traitement d'envoi du/des mail(s) |
|
|
$fails = array(); |
|
|
foreach ($courriels_valides as $email) { |
|
|
if ($this->f->sendMail( |
|
|
iconv("UTF-8", "CP1252", $objet), |
|
|
iconv("UTF-8", "CP1252", $modele), |
|
|
iconv("UTF-8", "CP1252", $email)) === false) { |
|
|
$fails[] = $email; |
|
|
} |
|
|
} |
|
|
// Si échec message d'erreur et arrêt du traitement |
|
|
if (count($fails) > 0) { |
|
|
$fails = implode(', ', $fails); |
|
|
$this->addToMessage(_("Erreur lors de l'envoi du courriel aux destinataires : ").$fails); |
|
|
$this->addToMessage(_("Veuillez contacter votre administrateur.")); |
|
|
return $this->end_treatment(__METHOD__, false); |
|
|
} |
|
|
// Ajout du log |
|
|
$this->setValFFromVal(); |
|
|
$val_inst = $this->valF; |
|
|
$val_inst['mails_destinataires'] = implode(', ', $courriels_valides); |
|
|
if ($this->add_log_to_dossier($id_inst, $val_inst) === false) { |
|
|
$this->addToMessage(_("Erreur lors de la notification.")); |
|
|
$this->addToMessage(_("Veuillez contacter votre administrateur.")); |
|
|
return $this->end_treatment(__METHOD__, false); |
|
8413 |
} |
} |
8414 |
// Message de validation |
$this->addToMessage(__('La commune a été notifiée.')); |
|
$this->addToMessage(_('La commune a été notifiée.')); |
|
8415 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
8416 |
} |
} |
8417 |
|
|
8418 |
/** |
/** |
|
* Formatte le corps du courriel notifié aux communes |
|
|
* |
|
|
* @param string $modele template du modèle du courriel |
|
|
* @param string $id_di clé primaire du DI |
|
|
* @param string $id_inst clé primaire de l'instruction |
|
|
* @return string corps du mail au format HTML |
|
|
*/ |
|
|
public function formater_modele($modele, $id_di, $id_inst) { |
|
|
// Création du lien d'accès direct à l'instruction |
|
|
$url_inst = PATH_BASE_URL.'app/index.php?module=form&direct_link=true&obj=dossier_instruction&action=3'. |
|
|
'&direct_field=dossier&direct_form=instruction&direct_action=3&direct_idx='.$id_inst; |
|
|
$url_inst = '<a href="'.$url_inst.'">'.$url_inst.'</a>'; |
|
|
// Remplacement des champs de fusion |
|
|
$modele = str_replace('<DOSSIER_INSTRUCTION>', $id_di, $modele); |
|
|
$modele = str_replace('<URL_INSTRUCTION>', $url_inst, $modele); |
|
|
$modele = str_replace('<ID_INSTRUCTION>', $id_inst, $modele); |
|
|
// Encodage HTML des sauts de ligne |
|
|
$modele = preg_replace("/\r\n|\r|\n/",'<br/>',$modele); |
|
|
// |
|
|
return $modele; |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
8419 |
* Récupère l'instance de l'instructeur |
* Récupère l'instance de l'instructeur |
8420 |
* |
* |
8421 |
* @param integer $instructeur Identifiant de l'instructeur. |
* @param integer $instructeur Identifiant de l'instructeur. |
8600 |
"signataire_arrete_email" => $inst_signataire_arrete->getVal('email'), |
"signataire_arrete_email" => $inst_signataire_arrete->getVal('email'), |
8601 |
"signataire_arrete_nom" => $inst_signataire_arrete->getVal('nom'), |
"signataire_arrete_nom" => $inst_signataire_arrete->getVal('nom'), |
8602 |
"signataire_arrete_prenom" => $inst_signataire_arrete->getVal('prenom'), |
"signataire_arrete_prenom" => $inst_signataire_arrete->getVal('prenom'), |
8603 |
"date_limite_instruction" => $inst_dossier->getVal('incomplet_notifie') === 't' ? $inst_dossier->getVal('date_limite_incompletude') : $inst_dossier->getVal('date_limite'), |
// Permet d'envoyer en signature l'instruction le jour de la date limite |
8604 |
|
"date_limite_instruction" => $this->compute_date_limite(1), |
8605 |
"dossier" => $this->getVal('dossier'), |
"dossier" => $this->getVal('dossier'), |
8606 |
"is_forced_view_files" => $is_forced_view_files, |
"is_forced_view_files" => $is_forced_view_files, |
8607 |
'commentaire_signature' => $is_forced_view_files === true ? __('relecture demandee.') : null |
'commentaire_signature' => $is_forced_view_files === true ? __('relecture demandee.') : null |
8609 |
|
|
8610 |
// Initialisation des métadonnées |
// Initialisation des métadonnées |
8611 |
$metadonnee_dossier = $file['metadata']; |
$metadonnee_dossier = $file['metadata']; |
8612 |
|
// récupération de l'extension du fichier |
8613 |
|
$extension = substr($metadonnee_dossier['filename'], strrpos($metadonnee_dossier['filename'], '.')); |
8614 |
|
// Modification du libellé du document transmis au parapheur |
8615 |
|
// pour le mettre sous la forme : instruction_xxx_libelle_lettretype.extension |
8616 |
|
$metadonnee_dossier['filename'] = $this->getDocumentLibelle().$extension; |
8617 |
|
$metadonnee_dossier['titre_document'] = $this->getDocumentTitre(); |
8618 |
|
|
8619 |
$metadonnee_dossier['url_di'] = sprintf( |
$metadonnee_dossier['url_di'] = sprintf( |
8620 |
'%sapp/index.php?module=form&direct_link=true&obj=dossier_instruction&action=3&direct_field=dossier&direct_form=instruction&direct_action=3&direct_idx=%s', |
'%sapp/index.php?module=form&direct_link=true&obj=dossier_instruction&action=3&direct_field=dossier&direct_form=instruction&direct_action=3&direct_idx=%s', |
8621 |
PATH_BASE_URL, |
$this->f->get_param_base_path_metadata_url_di() !== null ? $this->f->get_param_base_path_metadata_url_di() : PATH_BASE_URL, |
8622 |
$this->getVal($this->clePrimaire) |
$this->getVal($this->clePrimaire) |
8623 |
); |
); |
8624 |
|
|
8680 |
// Message |
// Message |
8681 |
$this->addToMessage(__("Le document a été envoyé pour signature dans le parapheur.")); |
$this->addToMessage(__("Le document a été envoyé pour signature dans le parapheur.")); |
8682 |
if (array_key_exists('signature_page_url', $result) === true) { |
if (array_key_exists('signature_page_url', $result) === true) { |
|
$link_text = $result['signature_page_url']; |
|
|
if (strlen($link_text) > 300) { |
|
|
$link_text = substr($link_text, 0, 300).'…'; |
|
|
} |
|
8683 |
$this->addToMessage(sprintf( |
$this->addToMessage(sprintf( |
8684 |
__("Lien vers la page de signature : %s"), |
'<br> > <a href="%1$s" title="%2$s" target="_blank">%2$s</a>', |
8685 |
'<a href="'.$result['signature_page_url'].'" title="'.__("Signer le document").'" target="_blank">'.$link_text.'</a>' |
$result['signature_page_url'], |
8686 |
|
__("Signez directement le document") |
8687 |
)); |
)); |
8688 |
} |
} |
8689 |
|
|
8692 |
} |
} |
8693 |
|
|
8694 |
/** |
/** |
8695 |
|
* Permet de récupérer la bonne date limite en fonction de si l'instruction |
8696 |
|
* est en incomplet notifié ou non. |
8697 |
|
* On peut ajouter des jours à cette date grâce au paramètre "delay". |
8698 |
|
* Cette fonction est utilisée dans un cas spécifique où on veut envoyer |
8699 |
|
* l'instruction en signature le jour de la date limite. |
8700 |
|
* |
8701 |
|
* @param int $delay Le nombre de jour à ajouter à la date limite. |
8702 |
|
* |
8703 |
|
* @return string $date_limite la date limite calculé ou false |
8704 |
|
*/ |
8705 |
|
private function compute_date_limite($delay) { |
8706 |
|
// Instanciation de l'objet dossier |
8707 |
|
$inst_dossier = $this->f->get_inst__om_dbform(array( |
8708 |
|
'obj' => 'dossier', |
8709 |
|
'idx' => $this->getVal('dossier'), |
8710 |
|
)); |
8711 |
|
|
8712 |
|
$date_to_compute = null; |
8713 |
|
if ($inst_dossier->getVal('incomplet_notifie') === 't') { |
8714 |
|
$date_to_compute = $inst_dossier->getVal('date_limite_incompletude'); |
8715 |
|
} else { |
8716 |
|
$date_to_compute = $inst_dossier->getVal('date_limite'); |
8717 |
|
} |
8718 |
|
|
8719 |
|
$date_limite = date("Y-m-d", strtotime($date_to_compute."+ $delay days")); |
8720 |
|
|
8721 |
|
return $date_limite; |
8722 |
|
} |
8723 |
|
|
8724 |
|
/** |
8725 |
* Permet de récupérer la traduction de la valeur de statut_signature |
* Permet de récupérer la traduction de la valeur de statut_signature |
8726 |
* |
* |
8727 |
* @return string la valeur de statut_signature traduite | false |
* @return string la valeur de statut_signature traduite | false |
8769 |
|
|
8770 |
$date_to_convert = array( |
$date_to_convert = array( |
8771 |
'date_envoi_signature' => $historique_signature_values['date_envoi_signature'], |
'date_envoi_signature' => $historique_signature_values['date_envoi_signature'], |
8772 |
'date_limite_instruction' => $historique_signature_values['date_limite_instruction'], |
'date_limite_instruction' => $this->compute_date_limite(0), |
8773 |
'date_retour_signature' => $historique_signature_values['date_retour_signature'] |
'date_retour_signature' => $historique_signature_values['date_retour_signature'] |
8774 |
); |
); |
8775 |
|
|
8812 |
|
|
8813 |
return json_encode($historique_signature_value_tab, JSON_HEX_APOS); |
return json_encode($historique_signature_value_tab, JSON_HEX_APOS); |
8814 |
} |
} |
8815 |
|
|
8816 |
|
/** |
8817 |
|
* TREATMENT - annuler_envoi_en_signature |
8818 |
|
* |
8819 |
|
* Permet d'annuler l'envoi du document de l'instruction au parapheur pour signature |
8820 |
|
* |
8821 |
|
* @return boolean true si l'annulation a été effectué avec succès false sinon |
8822 |
|
*/ |
8823 |
|
function annuler_envoi_en_signature() { |
8824 |
|
$this->begin_treatment(__METHOD__); |
8825 |
|
$this->correct = true; |
8826 |
|
|
8827 |
|
//Instanciation de la classe electronicsignature |
8828 |
|
$inst_es = $this->get_electronicsignature_instance(); |
8829 |
|
if ($inst_es === false) { |
8830 |
|
$this->correct = false; |
8831 |
|
return $this->end_treatment(__METHOD__, false); |
8832 |
|
} |
8833 |
|
|
8834 |
|
$data = array(); |
8835 |
|
if (! empty($this->getVal('id_parapheur_signature'))) { |
8836 |
|
$data['id_parapheur_signature'] = $this->getVal('id_parapheur_signature'); |
8837 |
|
} else { |
8838 |
|
$this->correct = false; |
8839 |
|
$this->addToMessage(__("Il n'y a pas d'identifiant de parapheur.")); |
8840 |
|
return $this->end_treatment(__METHOD__, false); |
8841 |
|
} |
8842 |
|
|
8843 |
|
// Appel de la méthode de l'abstracteur cancel_send_for_signature() |
8844 |
|
// Cette méthode doit retourner un tableau de valeur |
8845 |
|
try { |
8846 |
|
$result = $inst_es->cancel_send_for_signature($data); |
8847 |
|
} catch (electronicsignature_exception $e) { |
8848 |
|
$this->handle_electronicsignature_exception($e); |
8849 |
|
return $this->end_treatment(__METHOD__, false); |
8850 |
|
} |
8851 |
|
|
8852 |
|
// Après avoir reçu le résultat du parapheur, il faut mettre à jour les champs |
8853 |
|
$valF = array(); |
8854 |
|
|
8855 |
|
// Pour appeler la fonction modifier il faut traiter tous les champs de l'objet |
8856 |
|
foreach($this->champs as $identifiant => $champ) { |
8857 |
|
$valF[$champ] = $this->val[$identifiant]; |
8858 |
|
} |
8859 |
|
// On fait ensuite nos modifications spécifiques |
8860 |
|
$valF['id_parapheur_signature'] = null; |
8861 |
|
$valF['statut_signature'] = $result['statut']; |
8862 |
|
$valF['commentaire_signature'] = isset($result['commentaire_signature']) == true ? $result['commentaire_signature'] : null; |
8863 |
|
$valF['date_envoi_signature'] = null; |
8864 |
|
$valF['historique_signature'] = $this->get_updated_historique_signature($result); |
8865 |
|
|
8866 |
|
$ret = $this->modifier($valF); |
8867 |
|
|
8868 |
|
if ($ret === false) { |
8869 |
|
$this->correct = false; |
8870 |
|
$this->addToMessage(__("Une erreur est survenue lors de la mise à jour des champs.")); |
8871 |
|
// Termine le traitement |
8872 |
|
return $this->end_treatment(__METHOD__, false); |
8873 |
|
} |
8874 |
|
|
8875 |
|
// Message |
8876 |
|
$this->addToMessage(__("L'annulation a été effectuée avec succès.")); |
8877 |
|
|
8878 |
|
// Tout s'est bien passé, on termine le traitement |
8879 |
|
return $this->end_treatment(__METHOD__, true); |
8880 |
|
} |
8881 |
|
|
8882 |
|
|
8883 |
/** |
/** |
8886 |
* @return array sinon false en cas d'erreur |
* @return array sinon false en cas d'erreur |
8887 |
*/ |
*/ |
8888 |
protected function get_historique_signature_decoded() { |
protected function get_historique_signature_decoded() { |
8889 |
$val = $this->getVal('historique_signature'); |
$val = str_replace("'", '"', $this->getVal('historique_signature')); |
8890 |
if ($val === '') { |
if ($val === '' || $val == 'false') { |
8891 |
$val = json_encode(array()); |
$val = json_encode(array()); |
8892 |
} |
} |
8893 |
if($this->isJson($val) === false) { |
if($this->isJson($val) === false) { |
8899 |
/** |
/** |
8900 |
* Récupère les informations à afficher dans le tableau de suivi à l'aide |
* Récupère les informations à afficher dans le tableau de suivi à l'aide |
8901 |
* d'une requête sql. Stocke ces informations dans un tableau. |
* d'une requête sql. Stocke ces informations dans un tableau. |
8902 |
* Converti le tableau au format json et renvoi le json obtenu |
* Converti le tableau au format json et renvoi le json obtenu. |
8903 |
|
* |
8904 |
|
* Pour identifier quel suivi est affiché (notification des demandeurs, des services ou |
8905 |
|
* de tiers) ce sont les tâches liées aux notifications qui sont utilisés. |
8906 |
|
* La clause where de la requête est construite à partir du tableau contenant les types |
8907 |
|
* de tâches fourni en paramètre. |
8908 |
|
* Il est également possible d'afficher les notifications n'étant pas lié à des tâches. |
8909 |
|
* |
8910 |
|
* Si le suivi concerne la notification des demandeurs via le portail citoyen, |
8911 |
|
* la date de premier accès ne sera pas affichée. |
8912 |
* |
* |
8913 |
|
* @param array liste des tâches permettant d'identifier quelles notification afficher |
8914 |
|
* @param boolean permet d'afficher les notifications non liées à des tâches |
8915 |
* @return json |
* @return json |
8916 |
*/ |
*/ |
8917 |
protected function get_json_suivi_notification() { |
protected function get_json_suivi_notification($typeTache, $nonLieTache = false) { |
8918 |
$valSuivi = array(); |
$whereTypeTache = ''; |
8919 |
|
$sqlTaskNull = ''; |
8920 |
|
|
8921 |
// Liste des champs à afficher. Permet également la traduction des noms de colonnes. |
// Liste des champs à afficher. Permet également la traduction des noms de colonnes. |
8922 |
$listeChampsTrad = array( |
$listeChampsTrad = array( |
8923 |
__('emetteur'), |
__('emetteur'), |
8925 |
__('destinataire'), |
__('destinataire'), |
8926 |
__('date_premier_acces'), |
__('date_premier_acces'), |
8927 |
__('instruction'), |
__('instruction'), |
8928 |
|
__('annexes'), |
8929 |
__('statut'), |
__('statut'), |
8930 |
__('commentaire') |
__('commentaire') |
8931 |
); |
); |
8935 |
'destinataire', |
'destinataire', |
8936 |
'date_premier_acces', |
'date_premier_acces', |
8937 |
'instruction', |
'instruction', |
8938 |
|
'annexes', |
8939 |
'statut', |
'statut', |
8940 |
'commentaire' |
'commentaire' |
8941 |
); |
); |
8942 |
|
|
8943 |
|
// Défini si on veux que la requête récupère également les notifications qui n'ont pas |
8944 |
|
// de tâches associées. C'est le cas pour les notifications de demandeurs lorsque la |
8945 |
|
// notification du demandeur principal n'a pas pu être envoyée à cause d'un mauvais |
8946 |
|
// paramétrage |
8947 |
|
if(is_bool($nonLieTache) && $nonLieTache === true) { |
8948 |
|
$sqlTaskNull = 'OR task.type is null'; |
8949 |
|
} |
8950 |
|
// Prépare la clause where pour ne récupérer que les notifications liées à certain type de tâches |
8951 |
|
// Permet de différencier les notifications des demandeurs de celle des services et de celles des |
8952 |
|
// tiers consulté |
8953 |
|
if (is_array($typeTache) && $typeTache != array()) { |
8954 |
|
if (is_array($typeTache)) { |
8955 |
|
$whereTypeTache = sprintf( |
8956 |
|
'AND (task.type IN (%1$s) %2$s)', |
8957 |
|
"'".implode("', '", $typeTache)."'", |
8958 |
|
$sqlTaskNull |
8959 |
|
); |
8960 |
|
} |
8961 |
|
// La date de premier accès n'a pas besoin d'être renseigné pour |
8962 |
|
// les notifications des demandeurs via le portail citoyen. |
8963 |
|
// Les notifications des demandeurs sont liés à 3 types de tâches |
8964 |
|
// notification_recepisse, notification_instruction, notification_decision |
8965 |
|
// Si le suivi de la notification concerne un de ces types de tâches on |
8966 |
|
// considère que c'est une notification de demandeurs. |
8967 |
|
// Dans ce cas on vérifie si cette notification est paramétrée pour passer |
8968 |
|
// via le portail. Par défaut si rien n'est paramétré on considère que la |
8969 |
|
// notification est faite via le portail |
8970 |
|
if ((in_array('notification_recepisse', $typeTache) || |
8971 |
|
in_array('notification_instruction', $typeTache) || |
8972 |
|
in_array('notification_decision', $typeTache))) { |
8973 |
|
$dossier = $this->getVal('dossier'); |
8974 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite($dossier); |
8975 |
|
$modeNotification = $this->f->get_param_option_notification($collectivite_di); |
8976 |
|
if (empty($modeNotification) || $modeNotification == 'portal') { |
8977 |
|
$listeChamps = array( |
8978 |
|
'emetteur', |
8979 |
|
'date_envoi', |
8980 |
|
'destinataire', |
8981 |
|
'instruction', |
8982 |
|
'annexes', |
8983 |
|
'statut', |
8984 |
|
'commentaire' |
8985 |
|
); |
8986 |
|
} |
8987 |
|
} |
8988 |
|
// Il n'y a pas d'annexe pour la notification des communes donc pas besoin |
8989 |
|
// de les afficher dans le suivi |
8990 |
|
if (in_array('notification_depot_demat', $typeTache)) { |
8991 |
|
$listeChamps = array( |
8992 |
|
'emetteur', |
8993 |
|
'date_envoi', |
8994 |
|
'destinataire', |
8995 |
|
'instruction', |
8996 |
|
'statut', |
8997 |
|
'commentaire' |
8998 |
|
); |
8999 |
|
} |
9000 |
|
} |
9001 |
|
|
9002 |
|
$valSuivi = array(); |
9003 |
// Récupération des infos nécessaires à l'affichage du tableau |
// Récupération des infos nécessaires à l'affichage du tableau |
9004 |
$sql = sprintf( |
$sql = sprintf( |
9005 |
'SELECT |
'SELECT DISTINCT |
9006 |
instruction_notification, |
instruction_notification.instruction_notification, |
9007 |
emetteur, |
-- Affiche la mention automatique avec le nom de l emetteur si la notification a été envoyé automatiquement |
9008 |
|
CASE WHEN instruction_notification.automatique = TRUE |
9009 |
|
THEN TRIM(CONCAT(instruction_notification.emetteur, \' \', \'(automatique)\')) |
9010 |
|
ELSE instruction_notification.emetteur |
9011 |
|
END as emetteur, |
9012 |
date_envoi, |
date_envoi, |
9013 |
instruction_notification.destinataire, |
instruction_notification.destinataire, |
9014 |
date_premier_acces, |
instruction_notification.date_premier_acces, |
9015 |
evenement.libelle as instruction, |
evenement.libelle as instruction, |
9016 |
statut, |
instruction_notification.statut, |
9017 |
instruction_notification.commentaire |
instruction_notification.commentaire, |
9018 |
|
annexes.instruction_annexe as annexes |
9019 |
FROM |
FROM |
9020 |
%1$sinstruction_notification |
%1$sinstruction_notification |
9021 |
LEFT JOIN %1$sinstruction |
LEFT JOIN %1$sinstruction |
9022 |
ON instruction.instruction = instruction_notification.instruction |
ON instruction.instruction = instruction_notification.instruction |
9023 |
LEFT JOIN %1$sevenement |
LEFT JOIN %1$sevenement |
9024 |
ON instruction.evenement = evenement.evenement |
ON instruction.evenement = evenement.evenement |
9025 |
|
LEFT JOIN %1$sinstruction_notification_document |
9026 |
|
ON instruction_notification.instruction_notification = instruction_notification_document.instruction_notification |
9027 |
|
AND instruction_notification_document.annexe = true |
9028 |
|
-- Récupère les tâches liées au notification pour pouvoir par la suite identifier le type de notification |
9029 |
|
LEFT JOIN %1$stask |
9030 |
|
ON instruction_notification.instruction_notification::CHARACTER VARYING = task.object_id |
9031 |
|
-- Récupération de la liste des annexes sous la forme d une liste |
9032 |
|
LEFT JOIN ( |
9033 |
|
SELECT |
9034 |
|
instruction_notification, |
9035 |
|
-- Récupère la liste des annexes de la notification |
9036 |
|
-- sous la forme d un json pour récupérer toutes les informatiosn nécessaire |
9037 |
|
-- à l affichage du lien vers les annexes |
9038 |
|
CONCAT( |
9039 |
|
\'[\', |
9040 |
|
STRING_AGG( |
9041 |
|
-- Affiche le nom du fichier selon le type de document/pièce |
9042 |
|
CASE |
9043 |
|
WHEN instruction_notification_document.document_type = \'instruction\' |
9044 |
|
THEN CONCAT( |
9045 |
|
\'{ |
9046 |
|
"obj" : "instruction", |
9047 |
|
"champs" : "om_fichier_instruction", |
9048 |
|
"label" : "\', evenement.libelle, \'", |
9049 |
|
"id" : "\', instruction.instruction,\'" |
9050 |
|
}\' |
9051 |
|
) |
9052 |
|
WHEN instruction_notification_document.document_type = \'consultation\' |
9053 |
|
THEN CONCAT( |
9054 |
|
\'{ |
9055 |
|
"obj" : "consultation", |
9056 |
|
"champs" : "fichier", |
9057 |
|
"label" : "Avis - \', service.libelle, \'", |
9058 |
|
"id" : "\', consultation.consultation,\'" |
9059 |
|
}\' |
9060 |
|
) |
9061 |
|
ELSE |
9062 |
|
CONCAT( |
9063 |
|
\'{ |
9064 |
|
"obj" : "document_numerise", |
9065 |
|
"champs" : "uid", |
9066 |
|
"label" : "\', document_numerise.nom_fichier, \' - \', document_numerise_type.libelle, \'", |
9067 |
|
"id" : "\', document_numerise.document_numerise,\'" |
9068 |
|
}\' |
9069 |
|
) |
9070 |
|
END, |
9071 |
|
\', \'), |
9072 |
|
\']\' |
9073 |
|
) AS instruction_annexe |
9074 |
|
FROM |
9075 |
|
%1$sinstruction_notification_document |
9076 |
|
LEFT JOIN %1$sinstruction |
9077 |
|
ON instruction_notification_document.instruction = instruction.instruction |
9078 |
|
LEFT JOIN %1$sevenement |
9079 |
|
ON instruction.evenement = evenement.evenement |
9080 |
|
LEFT JOIN %1$sconsultation |
9081 |
|
ON instruction_notification_document.document_id = consultation.consultation |
9082 |
|
LEFT JOIN %1$sservice |
9083 |
|
ON consultation.service = service.service |
9084 |
|
LEFT JOIN %1$sdocument_numerise |
9085 |
|
ON instruction_notification_document.document_id = document_numerise.document_numerise |
9086 |
|
LEFT JOIN %1$sdocument_numerise_type |
9087 |
|
ON document_numerise.document_numerise_type = document_numerise_type.document_numerise_type |
9088 |
|
WHERE |
9089 |
|
instruction_notification_document.annexe = \'t\' |
9090 |
|
GROUP BY |
9091 |
|
instruction_notification |
9092 |
|
) AS annexes |
9093 |
|
ON |
9094 |
|
annexes.instruction_notification = instruction_notification.instruction_notification |
9095 |
WHERE |
WHERE |
9096 |
instruction.instruction = %2$s', |
instruction.instruction = %2$s |
9097 |
|
%3$s |
9098 |
|
ORDER BY |
9099 |
|
date_envoi ASC, instruction_notification.destinataire ASC', |
9100 |
DB_PREFIXE, |
DB_PREFIXE, |
9101 |
$this->getVal('instruction') |
$this->getVal('instruction'), |
9102 |
|
$whereTypeTache |
9103 |
); |
); |
9104 |
$res = $this->f->db->query($sql); |
$res = $this->f->db->query($sql); |
9105 |
$this->f->addToLog(__METHOD__."(): db->query(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__."(): db->query(\"".$sql."\")", VERBOSE_MODE); |
9106 |
$this->f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
9107 |
|
// Préparation du lien de téléchargement des annexes |
9108 |
|
$htmlList = |
9109 |
|
'<style> |
9110 |
|
#content .gridjs-td a.lien_annexe { |
9111 |
|
text-decoration : underline dotted 1px; |
9112 |
|
} |
9113 |
|
#content a.lien_annexe:hover { |
9114 |
|
text-decoration : underline solid 1px; |
9115 |
|
color : #46aede; |
9116 |
|
} |
9117 |
|
ol {padding-left : 10px;} |
9118 |
|
</style> |
9119 |
|
<ol>%1$s</ol>'; |
9120 |
|
$lienTelechargement = |
9121 |
|
'<a class="lien_annexe" href="../app/index.php?module=form&snippet=file&obj=%1$s&champ=%2$s&id=%3$s" target="blank" title="%4$s"> |
9122 |
|
Annexe |
9123 |
|
</a>'; |
9124 |
// Stockage des infos de chaque notification dans un tableau |
// Stockage des infos de chaque notification dans un tableau |
9125 |
while( $row =& $res->fetchrow(DB_FETCHMODE_ASSOC) ) { |
while( $row =& $res->fetchrow(DB_FETCHMODE_ASSOC) ) { |
9126 |
$valNotif = array(); |
$valNotif = array(); |
9127 |
foreach($listeChamps as $champ) { |
foreach($listeChamps as $champ) { |
9128 |
$valNotif[$champ] = $row[$champ]; |
$valNotif[$champ] = $row[$champ]; |
9129 |
|
if (($champ === 'date_envoi' |
9130 |
|
|| $champ === 'date_premier_acces') |
9131 |
|
&& $row[$champ] !== null |
9132 |
|
&& $row[$champ] !== '') { |
9133 |
|
// |
9134 |
|
$valNotif[$champ] = date('d/m/Y H:i:s', strtotime($row[$champ])); |
9135 |
|
} else if ($champ === 'annexes') { |
9136 |
|
$listeAnnexe = ''; |
9137 |
|
$infoAnnexes = json_decode($row[$champ], true); |
9138 |
|
if (! empty($infoAnnexes) && json_last_error() === JSON_ERROR_NONE) { |
9139 |
|
// A partir des infos récupérées prépare le code html du lien vers chacune |
9140 |
|
// des annexes et ajoute un élément de liste par annexe |
9141 |
|
foreach($infoAnnexes as $annexe) { |
9142 |
|
$listeAnnexe .= sprintf( |
9143 |
|
'<li>%s</li>', |
9144 |
|
sprintf($lienTelechargement, |
9145 |
|
$annexe['obj'], |
9146 |
|
$annexe['champs'], |
9147 |
|
$annexe['id'], |
9148 |
|
$annexe['label'] |
9149 |
|
) |
9150 |
|
); |
9151 |
|
} |
9152 |
|
// Construction de la liste des annexes |
9153 |
|
$valNotif[$champ] = sprintf( |
9154 |
|
$htmlList, |
9155 |
|
$listeAnnexe |
9156 |
|
); |
9157 |
|
} |
9158 |
|
} |
9159 |
} |
} |
9160 |
array_push($valSuivi, $valNotif); |
array_push($valSuivi, $valNotif); |
9161 |
} |
} |
9201 |
} |
} |
9202 |
|
|
9203 |
/** |
/** |
9204 |
|
* TREATMENT - envoyer_au_controle_de_legalite |
9205 |
|
* |
9206 |
|
* Ajoute la tâche envoi_CL. |
9207 |
|
* C'est le traitement de la tâche qui mettra à jour la date d'envoi au contrôle de légalité. |
9208 |
|
* |
9209 |
|
* @return [type] [description] |
9210 |
|
*/ |
9211 |
|
function envoyer_au_controle_de_legalite() { |
9212 |
|
$this->begin_treatment(__METHOD__); |
9213 |
|
$this->correct = true; |
9214 |
|
|
9215 |
|
// |
9216 |
|
if ($this->can_be_sended_to_cl() === true) { |
9217 |
|
// Création de la task 'envoi_CL' |
9218 |
|
$inst_task = $this->f->get_inst__om_dbform(array( |
9219 |
|
"obj" => "task", |
9220 |
|
"idx" => 0, |
9221 |
|
)); |
9222 |
|
$task_val = array( |
9223 |
|
'type' => 'envoi_CL', |
9224 |
|
'object_id' => $this->getVal('instruction'), |
9225 |
|
'dossier' => $this->getVal('dossier'), |
9226 |
|
); |
9227 |
|
// Change l'état de la tâche de notification en fonction de l'état de |
9228 |
|
// transmission du dossier d'instruction |
9229 |
|
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
9230 |
|
if ($this->f->is_option_mode_service_consulte_enabled() === false |
9231 |
|
&& ($inst_di->getVal('etat_transmission_platau') == 'non_transmissible' |
9232 |
|
|| $inst_di->getVal('etat_transmission_platau') == 'transmis_mais_non_transmissible')) { |
9233 |
|
// |
9234 |
|
$task_val['state'] = $inst_task::STATUS_DRAFT; |
9235 |
|
} |
9236 |
|
$add_task = $inst_task->add_task(array('val' => $task_val)); |
9237 |
|
if ($add_task === false) { |
9238 |
|
$this->addToMessage(sprintf('%s %s', |
9239 |
|
__("Une erreur s'est produite lors de la création tâche."), |
9240 |
|
__("Veuillez contacter votre administrateur.") |
9241 |
|
)); |
9242 |
|
$this->correct = false; |
9243 |
|
return $this->end_treatment(__METHOD__, false); |
9244 |
|
} |
9245 |
|
// Mise à jour du champs 'envoye_cl_platau' |
9246 |
|
$instr_val = array( |
9247 |
|
'envoye_cl_platau' => 't', |
9248 |
|
); |
9249 |
|
$res = $this->f->db->autoExecute( |
9250 |
|
DB_PREFIXE.$this->table, |
9251 |
|
$instr_val, |
9252 |
|
DB_AUTOQUERY_UPDATE, |
9253 |
|
$this->getCle($this->getVal($this->clePrimaire)) |
9254 |
|
); |
9255 |
|
$this->addToLog(__METHOD__."(): db->autoexecute(\"".DB_PREFIXE.'.'.$this->table."\", ".print_r($instr_val, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($this->clePrimaire)."\");", VERBOSE_MODE); |
9256 |
|
if ($this->f->isDatabaseError($res, true) === true) { |
9257 |
|
$this->addToMessage(sprintf('%s %s', |
9258 |
|
__("Une erreur s'est produite lors de la mise à jour de l'instruction."), |
9259 |
|
__("Veuillez contacter votre administrateur.") |
9260 |
|
)); |
9261 |
|
$this->correct = false; |
9262 |
|
return $this->end_treatment(__METHOD__, false); |
9263 |
|
} |
9264 |
|
// Message de validation à l'utilisateur |
9265 |
|
$this->addToMessage(__('Votre demande de transfert au contrôle de légalité à bien été prise en compte.')); |
9266 |
|
$this->addToMessage(__("La date d'envoi au contrôle de légalité sera mise à jour ultérieurement.")); |
9267 |
|
} |
9268 |
|
// |
9269 |
|
return $this->end_treatment(__METHOD__, true); |
9270 |
|
} |
9271 |
|
|
9272 |
|
|
9273 |
|
/** |
9274 |
* Retourne le lien de retour (VIEW formulaire et VIEW sousformulaire). |
* Retourne le lien de retour (VIEW formulaire et VIEW sousformulaire). |
9275 |
* |
* |
9276 |
* @param string $view Appel dans le contexte de la vue 'formulaire' ou de |
* @param string $view Appel dans le contexte de la vue 'formulaire' ou de |
9337 |
return $val; |
return $val; |
9338 |
} |
} |
9339 |
|
|
9340 |
|
public function get_related_instructions_next($next_type = 'retour_signature', $instruction = null) { |
9341 |
|
if (in_array($next_type, array('retour_signature', 'retour_ar', 'suivant_tacite', )) === false) { |
9342 |
|
return false; |
9343 |
|
} |
9344 |
|
$result = array(); |
9345 |
|
$evenements = array(); |
9346 |
|
if ($instruction === null) { |
9347 |
|
$instruction = $this->getVal($this->clePrimaire); |
9348 |
|
$evenement = $this->getVal('evenement'); |
9349 |
|
$dossier = $this->getVal('dossier'); |
9350 |
|
} else { |
9351 |
|
$inst = $this->f->get_inst__om_dbform(array( |
9352 |
|
"obj" => "instruction", |
9353 |
|
"idx" => $instruction, |
9354 |
|
)); |
9355 |
|
$evenement = $inst->getVal('evenement'); |
9356 |
|
$dossier = $inst->getVal('dossier'); |
9357 |
|
} |
9358 |
|
// |
9359 |
|
$query = sprintf(' |
9360 |
|
SELECT evenement_%3$s |
9361 |
|
FROM %1$sevenement |
9362 |
|
WHERE evenement = %2$s |
9363 |
|
', |
9364 |
|
DB_PREFIXE, |
9365 |
|
$evenement, |
9366 |
|
$next_type |
9367 |
|
); |
9368 |
|
$res = $this->f->get_one_result_from_db_query($query, true); |
9369 |
|
if ($res['code'] === 'KO') { |
9370 |
|
return false; |
9371 |
|
} |
9372 |
|
$ev_next = $res['result']; |
9373 |
|
// |
9374 |
|
$query = sprintf(' |
9375 |
|
SELECT MAX(instruction.instruction) as instruction |
9376 |
|
FROM %1$sinstruction |
9377 |
|
WHERE dossier = \'%3$s\' |
9378 |
|
AND evenement = %2$s |
9379 |
|
', |
9380 |
|
DB_PREFIXE, |
9381 |
|
$ev_next, |
9382 |
|
$dossier |
9383 |
|
); |
9384 |
|
$res = $this->f->get_one_result_from_db_query($query, true); |
9385 |
|
if ($res['code'] === 'KO') { |
9386 |
|
return false; |
9387 |
|
} |
9388 |
|
// |
9389 |
|
return $res['result']; |
9390 |
|
} |
9391 |
|
|
9392 |
public function get_related_instructions($instruction = null) { |
public function get_related_instructions($instruction = null) { |
9393 |
$result = array(); |
$result = array(); |
9394 |
$evenements = array(); |
$evenements = array(); |
9521 |
// Ajoute une condition sur le where pour ne récupérer que le pétitionnaire principal |
// Ajoute une condition sur le where pour ne récupérer que le pétitionnaire principal |
9522 |
// pour une notification depuis le portail citoyen |
// pour une notification depuis le portail citoyen |
9523 |
$sqlPetitionnairePrincipal = ''; |
$sqlPetitionnairePrincipal = ''; |
9524 |
|
// Gestion des champs nécessaires pour la notification d'un demandeur |
9525 |
|
$condition_demandeur = "AND demandeur.notification = 't' |
9526 |
|
AND demandeur.courriel IS NOT NULL"; |
9527 |
if ($portail === true) { |
if ($portail === true) { |
9528 |
$sqlPetitionnairePrincipal = 'AND lien_dossier_demandeur.petitionnaire_principal = true'; |
$sqlPetitionnairePrincipal = 'AND lien_dossier_demandeur.petitionnaire_principal = true'; |
9529 |
|
$condition_demandeur = "AND ( |
9530 |
|
(notification = 't' AND courriel IS NOT NULL) |
9531 |
|
OR demande.source_depot = 'portal' |
9532 |
|
)"; |
9533 |
} |
} |
9534 |
|
|
9535 |
$listeDemandeursNotifiable = array(); |
$listeDemandeursNotifiable = array(); |
|
// Liste des champs à récupérer |
|
|
$champsARecup = array( |
|
|
'particulier_nom', |
|
|
'particulier_prenom', |
|
|
'personne_morale_raison_sociale', |
|
|
'personne_morale_denomination', |
|
|
'qualite', |
|
|
'courriel', |
|
|
'notification' |
|
|
); |
|
9536 |
|
|
9537 |
// Requête de récupération des demandeurs |
// Requête de récupération des demandeurs |
9538 |
$sql = sprintf( |
$sql = sprintf( |
9539 |
'SELECT |
'SELECT |
9540 |
demandeur.demandeur, |
demandeur.demandeur, |
9541 |
%3$s |
CASE |
9542 |
|
WHEN demandeur.qualite=\'particulier\' |
9543 |
|
THEN TRIM(CONCAT(demandeur.particulier_nom, \' \', demandeur.particulier_prenom, \' \', demandeur.courriel)) |
9544 |
|
ELSE |
9545 |
|
TRIM(CONCAT(demandeur.personne_morale_raison_sociale, \' \', demandeur.personne_morale_denomination, \' \', demandeur.courriel)) |
9546 |
|
END AS destinataire, |
9547 |
|
demandeur.courriel, |
9548 |
|
petitionnaire_principal |
9549 |
FROM |
FROM |
9550 |
%1$sdossier |
%1$sdossier |
9551 |
INNER JOIN %1$slien_dossier_demandeur |
INNER JOIN %1$slien_dossier_demandeur |
9552 |
ON dossier.dossier = lien_dossier_demandeur.dossier |
ON dossier.dossier = lien_dossier_demandeur.dossier |
9553 |
INNER JOIN %1$sdemandeur |
INNER JOIN %1$sdemandeur |
9554 |
ON lien_dossier_demandeur.demandeur = demandeur.demandeur |
ON lien_dossier_demandeur.demandeur = demandeur.demandeur |
9555 |
|
-- Récupération de la plus ancienne demande associée au dossier (la demande |
9556 |
|
-- de création du dossier) |
9557 |
|
INNER JOIN ( |
9558 |
|
SELECT |
9559 |
|
demande, |
9560 |
|
dossier_instruction, |
9561 |
|
source_depot |
9562 |
|
FROM |
9563 |
|
%1$sdemande |
9564 |
|
WHERE |
9565 |
|
dossier_instruction = \'%2$s\' |
9566 |
|
ORDER BY |
9567 |
|
demande ASC |
9568 |
|
LIMIT 1 |
9569 |
|
) as demande |
9570 |
|
ON dossier.dossier = demande.dossier_instruction |
9571 |
WHERE |
WHERE |
9572 |
dossier.dossier = \'%2$s\' AND |
dossier.dossier = \'%2$s\' |
9573 |
notification = \'t\' AND |
%3$s |
|
courriel IS NOT NULL |
|
9574 |
%4$s', |
%4$s', |
9575 |
DB_PREFIXE, |
DB_PREFIXE, |
9576 |
$idDossier, |
$idDossier, |
9577 |
implode(",\n", $champsARecup), |
$condition_demandeur, |
9578 |
$sqlPetitionnairePrincipal |
$sqlPetitionnairePrincipal |
9579 |
); |
); |
9580 |
$res = $this->f->db->query($sql); |
$res = $this->f->db->query($sql); |
9583 |
// Récupération des infos des demandeurs et stockage dans un tableau |
// Récupération des infos des demandeurs et stockage dans un tableau |
9584 |
// ayant pour clé les id des demandeurs |
// ayant pour clé les id des demandeurs |
9585 |
while($row = $res->fetchrow(DB_FETCHMODE_ASSOC)) { |
while($row = $res->fetchrow(DB_FETCHMODE_ASSOC)) { |
9586 |
$listeDemandeursNotifiable[$row['demandeur']] = $row['courriel']; |
$listeDemandeursNotifiable[$row['demandeur']] = $row; |
9587 |
} |
} |
9588 |
|
|
9589 |
return $listeDemandeursNotifiable; |
return $listeDemandeursNotifiable; |
9595 |
* @param integer id de l'instruction dont on cherche les notifications |
* @param integer id de l'instruction dont on cherche les notifications |
9596 |
* @return array liste des instruction_notification liés à l'instruction |
* @return array liste des instruction_notification liés à l'instruction |
9597 |
*/ |
*/ |
9598 |
public function get_instruction_notification($id_instruction) { |
public function get_instruction_notification($id_instruction, $typeNotification = null, $nonLieTache = false) { |
9599 |
|
$whereTypeTache = ''; |
9600 |
|
$sqlTaskNull = ''; |
9601 |
|
// Défini si on veux que la requête récupère également les notifications qui n'ont pas |
9602 |
|
// de tâches associées. C'est le cas pour les notifications de demandeurs lorsque la |
9603 |
|
// notification du demandeur principal n'a pas pu être envoyée à cause d'un mauvais |
9604 |
|
// paramétrage |
9605 |
|
if(is_bool($nonLieTache) && $nonLieTache === true) { |
9606 |
|
$sqlTaskNull = 'OR task.type is null'; |
9607 |
|
} |
9608 |
|
if ($typeNotification != null) { |
9609 |
|
if (is_array($typeNotification)) { |
9610 |
|
$whereTypeTache = sprintf( |
9611 |
|
'AND (task.type IN (%1$s) %2$s)', |
9612 |
|
"'".implode("', '", $typeNotification)."'", |
9613 |
|
$sqlTaskNull |
9614 |
|
); |
9615 |
|
} else { |
9616 |
|
$whereTypeTache = sprintf( |
9617 |
|
'AND (task.type = \'%1$s\' %2$s)', |
9618 |
|
$typeNotification, |
9619 |
|
$sqlTaskNull |
9620 |
|
); |
9621 |
|
} |
9622 |
|
} |
9623 |
$listeInstrNotif = array(); |
$listeInstrNotif = array(); |
9624 |
$sql = sprintf(' |
$sql = sprintf(' |
9625 |
SELECT |
SELECT |
9626 |
instruction_notification.instruction_notification |
instruction_notification.instruction_notification |
9627 |
FROM |
FROM |
9628 |
%1$sinstruction_notification |
%1$sinstruction_notification |
9629 |
|
LEFT JOIN %1$stask |
9630 |
|
ON instruction_notification.instruction_notification::CHARACTER VARYING = task.object_id |
9631 |
WHERE |
WHERE |
9632 |
instruction = %2$s', |
instruction = %2$s |
9633 |
|
%3$s', |
9634 |
DB_PREFIXE, |
DB_PREFIXE, |
9635 |
$id_instruction |
$id_instruction, |
9636 |
|
$whereTypeTache |
9637 |
); |
); |
9638 |
$res = $this->f->db->query($sql); |
$res = $this->f->db->query($sql); |
9639 |
$this->f->addToLog(__METHOD__."(): db->query(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__."(): db->query(\"".$sql."\")", VERBOSE_MODE); |
9651 |
* @return string clé d'accès du document |
* @return string clé d'accès du document |
9652 |
*/ |
*/ |
9653 |
protected function getCleAccesDocument() { |
protected function getCleAccesDocument() { |
9654 |
return ''; |
// Initialisation d'un tableau |
9655 |
|
$number_list = array(); |
9656 |
|
|
9657 |
|
// Génération aléatoire d'un nombre sur 4 caractères, 4 fois |
9658 |
|
for ($i = 0; $i < 4; $i++) { |
9659 |
|
$number_list[] = str_pad(mt_rand(0, 9999), 4, 0, STR_PAD_LEFT); |
9660 |
|
} |
9661 |
|
|
9662 |
|
// Transformation en chaîne tout en séparant les nombres par un "-" |
9663 |
|
$result = implode('-', $number_list); |
9664 |
|
|
9665 |
|
// Vérifie si la clé existe déjà et si c'est le cas génére une nouvelle clé |
9666 |
|
if ($this->getUidDocumentInstructionWithKey($result) != null) { |
9667 |
|
return $this->getCleAccesDocument(); |
9668 |
|
} |
9669 |
|
|
9670 |
|
// |
9671 |
|
return $result; |
9672 |
|
} |
9673 |
|
|
9674 |
|
/** |
9675 |
|
* Récupère une clé et renvoie l'uid du document liée à cette |
9676 |
|
* clé. Si la clé n'existe pas renvoie null. |
9677 |
|
* |
9678 |
|
* @param string $cleGen clé dont on cherche l'instruction |
9679 |
|
* @return integer|null |
9680 |
|
*/ |
9681 |
|
protected function getUidDocumentInstructionWithKey($cleGen) { |
9682 |
|
$query = sprintf( |
9683 |
|
'SELECT |
9684 |
|
instruction.om_fichier_instruction |
9685 |
|
FROM |
9686 |
|
%1$sinstruction_notification_document |
9687 |
|
LEFT JOIN %1$sinstruction ON instruction_notification_document.instruction = instruction.instruction |
9688 |
|
WHERE |
9689 |
|
instruction_notification_document.cle = \'%2$s\'', |
9690 |
|
DB_PREFIXE, |
9691 |
|
$this->f->db->escapeSimple($cleGen) |
9692 |
|
); |
9693 |
|
|
9694 |
|
$res = $this->f->db->getOne($query); |
9695 |
|
$this->addToLog(__METHOD__.": db->getOne(\"".$query."\");", VERBOSE_MODE); |
9696 |
|
$this->f->isDatabaseError($res); |
9697 |
|
return $res; |
9698 |
|
} |
9699 |
|
|
9700 |
|
/** |
9701 |
|
* Récupère une clé, fait une requête pour récupérer l'id de la notification liée a cette clé. |
9702 |
|
* Récupère l'instance de instruction_notification dont l'id a été récupéré et la renvoie. |
9703 |
|
* |
9704 |
|
* @param string $cleGen |
9705 |
|
* @return instruction_notification |
9706 |
|
*/ |
9707 |
|
protected function getInstanceNotificationWithKey($key) { |
9708 |
|
$sql = sprintf( |
9709 |
|
"SELECT |
9710 |
|
instruction_notification |
9711 |
|
FROM |
9712 |
|
%1\$sinstruction_notification_document |
9713 |
|
WHERE |
9714 |
|
cle = '%2\$s'", |
9715 |
|
DB_PREFIXE, |
9716 |
|
$this->f->db->escapeSimple($key) |
9717 |
|
); |
9718 |
|
$res = $this->f->db->getOne($sql); |
9719 |
|
$this->addToLog(__METHOD__.": db->getOne(\"".$sql."\");", VERBOSE_MODE); |
9720 |
|
$this->f->isDatabaseError($res); |
9721 |
|
|
9722 |
|
// Récupération de l'instance de notification |
9723 |
|
$instNotif = $this->f->get_inst__om_dbform(array( |
9724 |
|
"obj" => "instruction_notification", |
9725 |
|
"idx" => $res, |
9726 |
|
)); |
9727 |
|
return $instNotif; |
9728 |
} |
} |
9729 |
|
|
9730 |
|
|
9731 |
/** |
/** |
9732 |
* Affiche la page de téléchargement du document de la notification. |
* Affiche la page de téléchargement du document de la notification. |
9733 |
* |
* |
9735 |
* |
* |
9736 |
* @return void |
* @return void |
9737 |
*/ |
*/ |
9738 |
public function view_telecharger_document_anonym($content_only = false) { |
public function view_telecharger_document_anonym() { |
|
|
|
9739 |
// Par défaut on considère qu'on va afficher le formulaire |
// Par défaut on considère qu'on va afficher le formulaire |
9740 |
$idx = 0; |
$idx = 0; |
9741 |
// Flag d'erreur |
// Flag d'erreur |
9743 |
// Message d'erreur |
// Message d'erreur |
9744 |
$message = ''; |
$message = ''; |
9745 |
|
|
9746 |
// Paramètres POST |
// Paramètres GET : récupération de la clé d'accès |
9747 |
$validation = $this->f->get_submitted_post_value('validation'); |
$cle_acces_document = $this->f->get_submitted_get_value('key'); |
|
// |
|
|
$cle_acces_document = $this->f->get_submitted_post_value('cle_acces_citoyen_complete'); |
|
9748 |
$cle_acces_document = $this->f->db->escapeSimple($cle_acces_document); |
$cle_acces_document = $this->f->db->escapeSimple($cle_acces_document); |
9749 |
// |
// Vérification de l'existence de la clé et récupération de l'uid du fichier |
9750 |
$timestamp_generation_formulaire = $this->f->get_submitted_post_value('timestamp_generation_formulaire'); |
$uidFichier = $this->getUidDocumentInstructionWithKey($cle_acces_document); |
9751 |
|
if ($uidFichier != null) { |
9752 |
// Si au moins un des champs n'est pas renseignés |
// Récupération du document |
9753 |
if ($error !== true |
$file = $this->f->storage->get($uidFichier); |
9754 |
&& $validation !== null |
|
9755 |
&& (($dossier === null || $dossier == '') |
// Headers |
9756 |
|| ($cle_acces_document === null || $cle_acces_document == ''))) { |
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 |
9757 |
// |
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date dans le passé |
9758 |
$message = _("Tous les champs doivent etre remplis."); |
header("Content-Type: ".$file['metadata']['mimetype']); |
9759 |
$error = true; |
header("Accept-Ranges: bytes"); |
9760 |
} |
header("Content-Disposition: inline; filename=\"".$file['metadata']['filename']."\";" ); |
9761 |
|
// Affichage du document |
9762 |
// Si le formulaire est expiré |
echo $file['file_content']; |
9763 |
if ($error !== true |
|
9764 |
&& $validation !== null |
// Récupération de la date de premier accès et maj du suivi uniquement |
9765 |
&& time() >= strtotime('+5 minutes', $timestamp_generation_formulaire)) { |
// si la date de 1er accès n'a pas encore été remplis |
9766 |
// |
$inst_notif = $this->getInstanceNotificationWithKey($cle_acces_document); |
9767 |
$message = _("Le formulaire a expire. Veuillez recharger la page."); |
if ($inst_notif->getVal('date_premier_acces') == null || |
9768 |
$error = true; |
$inst_notif->getVal('date_premier_acces') == '') { |
9769 |
} |
$notif_val = array(); |
9770 |
|
foreach ($inst_notif->champs as $champ) { |
9771 |
// Si les valeurs renseignées semblent correctes |
$notif_val[$champ] = $inst_notif->getVal($champ); |
9772 |
if ($error !== true |
} |
9773 |
&& $validation !== null |
$notif_val['date_premier_acces'] = date("d/m/Y H:i:s"); |
9774 |
&& strlen($cle_acces_document) != 19) { |
$notif_val['statut'] = 'vu'; |
9775 |
// |
$notif_val['commentaire'] = 'Le document a été vu'; |
9776 |
$message = _("La cle d'acces n'est pas valide."); |
$suivi_notif = $inst_notif->modifier($notif_val); |
|
$error = true; |
|
|
} |
|
|
|
|
|
// S'il n'y a pas eu d'erreur |
|
|
if ($error !== true |
|
|
&& $validation !== null) { |
|
|
// Vérifie le couple identifiant de l'instruction et clé d'accès au document |
|
|
$idx = $this->verify_document_access_credentials($instruction, $cle_acces_document); |
|
|
|
|
|
// Si le couple n'est pas correct |
|
|
if ($idx === false) { |
|
|
// |
|
|
$message = _("La cle d'acces n'est pas valide."); |
|
|
$error = true; |
|
9777 |
} |
} |
|
} |
|
9778 |
|
|
|
// S'il n'y a pas d'erreur et que le formulaire a été validé |
|
|
if ($error !== true && $validation !== null) { |
|
|
// Instanciation de l'instruction |
|
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
|
|
"obj" => "instruction", |
|
|
"idx" => $idx, |
|
|
)); |
|
|
// On affiche l'édition associée à l'instruction |
|
|
$inst_instruction->view_edition(); |
|
9779 |
} else { |
} else { |
9780 |
// Sinon on affiche une page indiquant que le document n'a pas été trouvé |
// Page vide 404 |
9781 |
$this->display_404(); |
printf('Ressource inexistante'); |
9782 |
|
header('HTTP/1.0 404 Not Found'); |
9783 |
} |
} |
9784 |
} |
} |
9785 |
|
|
|
|
|
9786 |
/** |
/** |
9787 |
* Vérifie que la clé de récupération du document de l'instruction existe |
* Récupère le titre du document envoyé au parapheur |
|
* |
|
|
* @param string $instruction L'identifiant de l'instruction. |
|
|
* @param string $citizen_access_key La clé d'accès au document. |
|
|
* |
|
|
* @return string Identifiant de l'instruction sinon 0. |
|
9788 |
*/ |
*/ |
9789 |
public function verify_document_access_credentials($instruction, $doc_access_key) { |
protected function getDocumentTitre($champ = null) { |
9790 |
|
$title = $this->getTitle(); |
9791 |
|
$dossier = $this->getDossier(); |
9792 |
|
return $dossier.' '.$title; |
9793 |
|
} |
9794 |
|
|
9795 |
|
/** |
9796 |
|
* Compose le nom du document à transmettre au parapheur. |
9797 |
|
* Le nom ets composé de cette manière : |
9798 |
|
* instruction_xxx_libelle_de_la_lettre_type_associee |
9799 |
|
* ou xxx correspond au numéro de l'instruction |
9800 |
|
*/ |
9801 |
|
protected function getDocumentLibelle() { |
9802 |
|
// Récupère le champ instruction |
9803 |
|
$instruction = $this->getVal("instruction"); |
9804 |
|
|
9805 |
|
// Requête sql servant à récupérer le titre du document |
9806 |
|
// TO_CHAR() introduit un espace avant l'affichage du nombre |
9807 |
|
// comme les espaces sont remplacé par des '_' dans le retour de la fonction |
9808 |
|
// il n'est pas nécessaire de mettre un '_' après le mot instruction. |
9809 |
$sql = sprintf( |
$sql = sprintf( |
9810 |
'SELECT |
'SELECT |
9811 |
instruction_notification_document.instruction |
CONCAT( |
9812 |
|
\'instruction\', |
9813 |
|
TO_CHAR(instruction.instruction, \'000\'), |
9814 |
|
\'_\', |
9815 |
|
LOWER(om_lettretype.libelle) |
9816 |
|
) as nom_fichier |
9817 |
FROM |
FROM |
9818 |
%1$sinstruction_notification_document |
%1$sinstruction |
9819 |
|
LEFT JOIN %1$som_lettretype ON om_lettretype.id = instruction.lettretype |
9820 |
WHERE |
WHERE |
9821 |
instruction = %2$s AND |
instruction = %2$s', |
|
cle = %3$s', |
|
9822 |
DB_PREFIXE, |
DB_PREFIXE, |
9823 |
$instruction, |
$instruction |
|
$doc_access_key |
|
9824 |
); |
); |
9825 |
$res = $this->f->db->getOne($sql); |
$documentLibelle = $this->f->db->getOne($sql); |
9826 |
$this->f->addToLog(__METHOD__."() : db->query(\"".$sql."\")", VERBOSE_MODE); |
$this->addToLog("getDocumentTitre(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
9827 |
$this->f->isDatabaseError($res); |
if (database::isError($documentLibelle)) { |
9828 |
|
die(); |
|
// Si aucun dossier n'existe avec la clé fournie, on renvoie faux |
|
|
if ($res == null) { |
|
|
return false; |
|
9829 |
} |
} |
|
// |
|
|
return $res; |
|
|
} |
|
9830 |
|
|
9831 |
protected function getDocumentTitre($champ = null) { |
// Transforamtion des ' ' en '_', des accents en lettres sans accents et des |
9832 |
$title = $this->getTitle(); |
// caractères spéciaux en '_' |
9833 |
$dossier = $this->getDossier(); |
// La méthode normalize_string est utilisé pour gérer les accents |
9834 |
return $dossier.' '.$title; |
$documentLibelle = $this->f->normalize_string($documentLibelle); |
9835 |
|
// TODO : comparer cette liste et celle de la méthode normalize_string |
9836 |
|
// pour éviter les doublons + vérifier qu'il n'y a pas de doublons dans cette |
9837 |
|
// liste |
9838 |
|
$invalid = array('Œ'=>'oe', 'œ'=>'oe', 'Ÿ'=>'y', 'ü'=>'u', |
9839 |
|
'¢' => '_', 'ß' => '_', '¥' => '_', '£' => '_', '™' => '_', '©' => '_', |
9840 |
|
'®' => '_', 'ª' => '_', '×' => '_', '÷' => '_', '±' => '_', '²' => '_', |
9841 |
|
'³' => '_', '¼' => '_', '½' => '_', '¾' => '_', 'µ' => '_', '¿' => '_', |
9842 |
|
'¶' => '_', '·' => '_', '¸' => '_', 'º' => '_', '°' => '_', '¯' => '_', |
9843 |
|
'§' => '_', '…' => '_', '¤' => '_', '¦' => '_', '≠' => '_', '¬' => '_', |
9844 |
|
'ˆ' => '_', '¨' => '_', '‰' => '_', '¤' => '_', '€' => '_', '$' => '_', |
9845 |
|
'«' => '_', '»' => '_', '‹' => '_', '›' => '_', 'ƒ' => '_', '¥' => '_', |
9846 |
|
'‘‘' => '_', '‚' => '_', '!' => '_', '¡' => '_', '¢' => '_', '£' => '_', |
9847 |
|
'?' => '_', '[' => '_', ']' => '_', '´' => '_', '`' => '_', '^' => '_', |
9848 |
|
'~' => '_', '˜' => '_', '#' => '_', '*' => '_', '.' => '_', ':' => '_', |
9849 |
|
';' => '_', '•' => '_', '¯' => '_', '‾' => '_', '–' => '_', '–' => '_', |
9850 |
|
'—' => '_', '_' => '_', '|' => '_', '¦' => '_', '‡' => '_', '§' => '_', |
9851 |
|
'¶' => '_', '©' => '_', '®' => '_', '™' => '_', '&' => '_', '@' => '_', |
9852 |
|
'/' => '_', '\\' => '_', '◊' => '_', '♠' => '_', '♣' => '_', '♥' => '_', |
9853 |
|
'♦' => '_', '←' => '_', '↑' => '_', '→' => '_', '↓' => '_', '↔' => '_', |
9854 |
|
'°' => '_', 'µ' => '_', '<' => '_', '>' => '_', '≤' => '_', '≥' => '_', |
9855 |
|
'=' => '_', '≈' => '_', '≠' => '_', '≡' => '_', '±' => '_', '−' => '_', |
9856 |
|
'+' => '_', '×' => '_', '÷' => '_', '⁄' => '_', '%' => '_', '‰' => '_', |
9857 |
|
'¼' => '_', '½' => '_', '¾' => '_', '¹' => '_', '²' => '_', '³' => '_', |
9858 |
|
'' => '_', 'º' => '_', 'ª' => '_', 'ƒ' => '_', '′' => '_', '″' => '_', |
9859 |
|
'∂' => '_', '∏' => '_', '∑' => '_', '√' => '_', '∞' => '_', '¬' => '_', |
9860 |
|
'∩' => '_', '∫' => '_', 'α' => '_', 'Α' => '_', 'β' => '_', 'Β' => '_', |
9861 |
|
'γ' => '_', 'Γ' => '_', 'δ' => '_', 'Δ' => '_', 'ε' => '_', 'Ε' => '_', |
9862 |
|
'ζ' => '_', 'Ζ' => '_', 'η' => '_', 'Η' => '_', 'θ' => '_', 'Θ' => '_', |
9863 |
|
'ι' => '_', 'Ι' => '_', 'κ' => '_', 'Κ' => '_', 'λ' => '_', 'Λ' => '_', |
9864 |
|
'μ' => '_', 'Μ' => '_', 'ν' => '_', 'Ν' => '_', 'ξ' => '_', 'Ξ' => '_', |
9865 |
|
'ο' => '_', 'Ο' => '_', 'π' => '_', 'Π' => '_', 'ρ' => '_', 'Ρ' => '_', |
9866 |
|
'σ' => '_', 'ς' => '_', 'Σ' => '_', 'τ' => '_', 'Τ' => '_', 'υ' => '_', |
9867 |
|
'Υ' => '_', 'φ' => '_', 'Φ' => '_', 'χ' => '_', 'Χ' => '_', 'ψ' => '_', |
9868 |
|
'Ψ' => '_', 'ω' => '_', 'Ω' => '_', ',' => '_', ' ' => '_' |
9869 |
|
); |
9870 |
|
|
9871 |
|
return str_replace(array_keys($invalid), array_values($invalid), $documentLibelle); |
9872 |
} |
} |
9873 |
|
|
9874 |
|
/** |
9875 |
|
* Surcharge permettant de ne pas afficher le fil d'Ariane dans |
9876 |
|
* l'overlay de notification des demandeurs. |
9877 |
|
*/ |
9878 |
|
function getSubFormTitle($ent) { |
9879 |
|
$actionSansPath = array('411', '420', '430'); |
9880 |
|
if (in_array($this->getParameter('maj'), $actionSansPath)) { |
9881 |
|
return ''; |
9882 |
|
} |
9883 |
|
return parent::getSubFormTitle($ent); |
9884 |
|
} |
9885 |
}// fin classe |
}// fin classe |