29 |
var $abstract_type = array( |
var $abstract_type = array( |
30 |
"om_fichier_instruction" => "file", |
"om_fichier_instruction" => "file", |
31 |
); |
); |
32 |
|
|
|
var $retourformulaire; // specific |
|
|
var $idxformulaire; // specific |
|
33 |
var $valEvenement; |
var $valEvenement; |
34 |
var $restriction_valid = null; |
var $restriction_valid = null; |
35 |
// Tableau contenant une partie des métadonnées arrêtés |
// Tableau contenant une partie des métadonnées arrêtés |
69 |
"groupeInstruction" => 'getGroupeInstruction', |
"groupeInstruction" => 'getGroupeInstruction', |
70 |
"title" => 'getTitle', |
"title" => 'getTitle', |
71 |
'concerneERP' => 'get_concerne_erp', |
'concerneERP' => 'get_concerne_erp', |
72 |
|
|
73 |
|
'date_cloture_metier' => 'getDossierDateDecision', |
74 |
|
'type' => 'getDocumentType', |
75 |
|
'dossier_autorisation_type_detaille' => 'getDossierAutorisationTypeDetaille', |
76 |
|
'dossier_instruction_type' => 'getDossierInstructionTypeLibelle', |
77 |
|
'region' => 'getDossierRegion', |
78 |
|
'departement' => 'getDossierDepartement', |
79 |
|
'commune' => 'getDossierCommune', |
80 |
|
'annee' => 'getDossierAnnee', |
81 |
|
'division' => 'getDossierDivision', |
82 |
|
'collectivite' => 'getDossierServiceOrCollectivite', |
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", |
99 |
), |
) |
100 |
); |
); |
101 |
|
|
102 |
|
/** |
103 |
|
* Flag pour identifier la reprise de l'instruction d'un dossier. |
104 |
|
* Le statut de l'état passe de "cloture" à "encours". |
105 |
|
* |
106 |
|
* @var boolean |
107 |
|
*/ |
108 |
|
var $di_reopened = null; |
109 |
|
|
110 |
|
/** |
111 |
|
* Méthode appelée par le module_manager lors de la récupération des modules de cet objet. |
112 |
|
* Permet d'ajouer des modules en plus de ceux récupérer par défaut par le module_manager. |
113 |
|
* |
114 |
|
* @return array Liste de modules supplémentaires pour cet objet |
115 |
|
*/ |
116 |
|
public function get_modules_append() { |
117 |
|
$modules = array(); |
118 |
|
|
119 |
|
// si on est dans le cadre de l'affichage d'une nouvelle instruction |
120 |
|
$action = $this->f->get_submitted_get_value('action'); |
121 |
|
if ($action == '0') { |
122 |
|
|
123 |
|
// si on est sur un dossier d'instruction |
124 |
|
if ($this->f->contexte_dossier_instruction()) { |
125 |
|
$idx = $this->f->get_submitted_get_value('idxformulaire'); |
126 |
|
if (! empty($idx)) { |
127 |
|
|
128 |
|
// ajoute les modules des évènements possible sur le dossier courant |
129 |
|
$evenements_data = $this->get_var_sql_forminc__sql_evenement(); |
130 |
|
$evenements_ids = array_map(function($item) { return $item['evenement']; }, $evenements_data); |
131 |
|
$this->f->log(__METHOD__, 'evenements: '.implode(',', $evenements_ids)); |
132 |
|
$modules = $this->f->module_manager->get_modules_for_object_name_and_ids( |
133 |
|
'evenement', $evenements_ids, $this, false); |
134 |
|
} |
135 |
|
} |
136 |
|
} |
137 |
|
return $modules; |
138 |
|
} |
139 |
|
|
140 |
// {{{ Gestion de la confidentialité des données spécifiques |
// {{{ Gestion de la confidentialité des données spécifiques |
141 |
|
|
142 |
/** |
/** |
158 |
"is_editable", |
"is_editable", |
159 |
"is_finalizable_without_bypass", |
"is_finalizable_without_bypass", |
160 |
"can_user_access_dossier_contexte_modification", |
"can_user_access_dossier_contexte_modification", |
161 |
|
"is_evenement_modifiable", |
162 |
); |
); |
163 |
$this->class_actions[1]["portlet"]["libelle"] = _("Modifier"); |
$this->class_actions[1]["portlet"]["libelle"] = _("Modifier"); |
164 |
|
|
167 |
$this->class_actions[2]["condition"] = array( |
$this->class_actions[2]["condition"] = array( |
168 |
"is_deletable", |
"is_deletable", |
169 |
"is_finalizable_without_bypass", |
"is_finalizable_without_bypass", |
170 |
"can_user_access_dossier_contexte_modification" |
"can_user_access_dossier_contexte_modification", |
171 |
|
"is_evenement_supprimable", |
172 |
); |
); |
173 |
$this->class_actions[2]["portlet"]["libelle"] = _("Supprimer"); |
$this->class_actions[2]["portlet"]["libelle"] = _("Supprimer"); |
174 |
|
|
216 |
"is_unfinalizable", |
"is_unfinalizable", |
217 |
"is_unfinalizable_without_bypass", |
"is_unfinalizable_without_bypass", |
218 |
"can_user_access_dossier_contexte_modification", |
"can_user_access_dossier_contexte_modification", |
219 |
|
"is_not_sent_for_signature", |
220 |
|
"is_not_signed", |
221 |
|
), |
222 |
|
); |
223 |
|
|
224 |
|
// ACTION - 115 - Modification d'un document généré par une instruction |
225 |
|
// Permet à un instructeur de modifier un document généré par une instruction |
226 |
|
$this->class_actions[115] = array( |
227 |
|
"identifier" => "modale_selection_document_signe", |
228 |
|
"portlet" => array( |
229 |
|
"type" => "action-self", |
230 |
|
"libelle" => _("Remplacer par le document signé"), |
231 |
|
"order" => 115, |
232 |
|
"class" => "selection-document-signé", |
233 |
|
), |
234 |
|
"view" => "view_modale_selection_document_signe", |
235 |
|
"permission_suffix" => "selection_document_signe", |
236 |
|
"condition" => array( |
237 |
|
"is_finalized", |
238 |
|
"is_not_date_retour_signature_set", |
239 |
), |
), |
240 |
); |
); |
241 |
|
|
309 |
"permission_suffix" => "consulter", |
"permission_suffix" => "consulter", |
310 |
); |
); |
311 |
|
|
312 |
|
// ACTION - 175 - edit_by_notification_task |
313 |
|
// Action à utiliser lors de la mise à jour des instructions par notification |
314 |
|
$this->class_actions[175] = array( |
315 |
|
"identifier" => "edit_by_notification_task", |
316 |
|
"view" => "formulaire", |
317 |
|
"permission_suffix" => "modifier", |
318 |
|
"crud" => "update", |
319 |
|
); |
320 |
|
|
321 |
|
// ACTION - 176 - add_by_evenement_retour_after_notification_task |
322 |
|
// Action à utiliser lors de l'ajout des instructions par événement suivant |
323 |
|
// suite à une notification par tâche (donc notification dématerialisée) |
324 |
|
$this->class_actions[176] = array( |
325 |
|
"identifier" => "add_by_evenement_retour_after_notification_task", |
326 |
|
"view" => "formulaire", |
327 |
|
"permission_suffix" => "ajouter", |
328 |
|
"crud" => "create", |
329 |
|
); |
330 |
|
|
331 |
// ACTION - 180 - pdf_lettre_rar |
// ACTION - 180 - pdf_lettre_rar |
332 |
// Génère PDF sur bordereaux de lettres RAR |
// Génère PDF sur bordereaux de lettres AR |
333 |
$this->class_actions[180] = array( |
$this->class_actions[180] = array( |
334 |
"identifier" => "pdf_lettre_rar", |
"identifier" => "pdf_lettre_rar", |
335 |
"view" => "view_pdf_lettre_rar", |
"view" => "view_pdf_lettre_rar", |
435 |
"view" => "view_evenement_has_an_edition_json", |
"view" => "view_evenement_has_an_edition_json", |
436 |
"permission_suffix" => "consulter", |
"permission_suffix" => "consulter", |
437 |
); |
); |
438 |
|
|
439 |
|
// ACTION - 301 - evenement_has_a_commentaire |
440 |
|
// |
441 |
|
$this->class_actions[301] = array( |
442 |
|
"identifier" => "evenement_has_a_commentaire_json", |
443 |
|
"view" => "view_evenement_has_a_commentaire_json", |
444 |
|
"permission_suffix" => "consulter", |
445 |
|
); |
446 |
|
|
447 |
|
// ACTION - 400 - Envoyer en signature |
448 |
|
// Cet évenement permet d'envoyer le document au parapheur pour signature |
449 |
|
$this->class_actions[400] = array( |
450 |
|
"identifier" => "envoyer_a_signature", |
451 |
|
"portlet" => array( |
452 |
|
"libelle" => _("Envoyer à signature"), |
453 |
|
"type" => "action-direct-with-confirmation", |
454 |
|
"class" => "envoyer_a_signature-16", |
455 |
|
), |
456 |
|
"view" => "formulaire", |
457 |
|
"method" => "envoyer_a_signature_sans_relecture", |
458 |
|
"condition" => array( |
459 |
|
"can_be_signed", |
460 |
|
), |
461 |
|
"permission_suffix" => "envoyer_a_signature", |
462 |
|
); |
463 |
|
|
464 |
|
// ACTION - 402 - Envoyer en signature avec relecture |
465 |
|
// Cet évenement permet d'envoyer le document au parapheur pour signature |
466 |
|
$this->class_actions[402] = array( |
467 |
|
"identifier" => "envoyer_a_signature_relecture", |
468 |
|
"portlet" => array( |
469 |
|
"libelle" => __("Envoyer à signature avec relecture"), |
470 |
|
"type" => "action-direct-with-confirmation", |
471 |
|
"class" => "envoyer_a_signature-16", |
472 |
|
), |
473 |
|
"view" => "formulaire", |
474 |
|
"method" => "envoyer_a_signature_avec_relecture", |
475 |
|
"condition" => array( |
476 |
|
"can_be_signed", |
477 |
|
"is_parapheur_relecture_parameter_enabled" |
478 |
|
), |
479 |
|
"permission_suffix" => "envoyer_a_signature", |
480 |
|
); |
481 |
|
|
482 |
|
// ACTION - 404 - Annuler l'envoi en signature |
483 |
|
// Cet évenement permet d'annuler l'envoi en signature du document au parapheur |
484 |
|
$this->class_actions[404] = array( |
485 |
|
"identifier" => "annuler_envoi_signature", |
486 |
|
"portlet" => array( |
487 |
|
"libelle" => __("Annuler l'envoi en signature"), |
488 |
|
"type" => "action-direct-with-confirmation", |
489 |
|
"class" => "annuler_envoi_signature-16", |
490 |
|
), |
491 |
|
"view" => "formulaire", |
492 |
|
"method" => "annuler_envoi_en_signature", |
493 |
|
"condition" => array( |
494 |
|
"is_sent_for_signature", |
495 |
|
"is_parapheur_annulation_parameter_enabled" |
496 |
|
), |
497 |
|
"permission_suffix" => "envoyer_a_signature", |
498 |
|
); |
499 |
|
|
500 |
|
// |
501 |
|
$this->class_actions[401] = array( |
502 |
|
"identifier" => "preview_edition", |
503 |
|
"view" => "formulaire", |
504 |
|
"permission_suffix" => "tab", |
505 |
|
); |
506 |
|
|
507 |
|
// |
508 |
|
$this->class_actions[405] = array( |
509 |
|
"identifier" => "telecharger_editions", |
510 |
|
"view" => "view_telecharger_editions", |
511 |
|
"permission_suffix" => "om_fichier_instruction_telecharger", |
512 |
|
); |
513 |
|
|
514 |
|
// ACTION - 410 - Notifier les pétitionnaires (mail ou autre) |
515 |
|
$this->class_actions[410] = array( |
516 |
|
"identifier" => "overlay_notification_manuelle", |
517 |
|
"portlet" => array( |
518 |
|
"libelle" => __("Notifier les pétitionnaires"), |
519 |
|
"type" => "action-self", |
520 |
|
"class" => "notifier_commune-16", |
521 |
|
), |
522 |
|
"condition" => array( |
523 |
|
"is_notifiable_by_task_manual", |
524 |
|
"is_not_portail_notification_sans_annexe" |
525 |
|
), |
526 |
|
"view" => "view_overlay_notification_manuelle", |
527 |
|
"permission_suffix" => "modifier", |
528 |
|
); |
529 |
|
|
530 |
|
// ACTION - 411 - Notifier les pétitionnaires (portail citoyen) |
531 |
|
$this->class_actions[411] = array( |
532 |
|
"identifier" => "notification_manuelle_portal", |
533 |
|
"portlet" => array( |
534 |
|
"libelle" => __("Notifier les pétitionnaires"), |
535 |
|
"type" => "action-direct-with-confirmation", |
536 |
|
"class" => "notifier_commune-16", |
537 |
|
), |
538 |
|
"condition" => array( |
539 |
|
"is_notifiable_by_task_manual", |
540 |
|
"is_portail_notification_sans_annexe" |
541 |
|
), |
542 |
|
"method" => "notifier_demandeur_principal_via_portal", |
543 |
|
"permission_suffix" => "modifier", |
544 |
|
); |
545 |
|
|
546 |
|
// ACTION - 412 - Vérifie le dépassement de la date limite de notification |
547 |
|
$this->class_actions[412] = array( |
548 |
|
"identifier" => "is_date_limite_notification_dossier_depasse", |
549 |
|
"view" => "is_date_limite_notification_dossier_depasse", |
550 |
|
"permission_suffix" => "modifier", |
551 |
|
); |
552 |
|
|
553 |
|
// ACTION - 420 - Notifier les services consultés (mail) |
554 |
|
$this->class_actions[420] = array( |
555 |
|
"identifier" => "overlay_notification_service_consulte", |
556 |
|
"portlet" => array( |
557 |
|
"libelle" => __("Notifier les services consultés"), |
558 |
|
"type" => "action-self", |
559 |
|
"class" => "notifier_commune-16", |
560 |
|
), |
561 |
|
"condition" => array( |
562 |
|
"is_service_notifiable" |
563 |
|
), |
564 |
|
"view" => "view_overlay_notification_service_consulte", |
565 |
|
"permission_suffix" => "tab", |
566 |
|
); |
567 |
|
|
568 |
|
// ACTION - 430 - Notifier les tiers consultés (mail) |
569 |
|
$this->class_actions[430] = array( |
570 |
|
"identifier" => "overlay_notification_tiers_consulte", |
571 |
|
"portlet" => array( |
572 |
|
"libelle" => __("Notifier les tiers consultés"), |
573 |
|
"type" => "action-self", |
574 |
|
"class" => "notifier_commune-16", |
575 |
|
), |
576 |
|
"condition" => array( |
577 |
|
"is_tiers_notifiable" |
578 |
|
), |
579 |
|
"view" => "view_overlay_notification_tiers_consulte", |
580 |
|
"permission_suffix" => "tab", |
581 |
|
); |
582 |
|
|
583 |
|
// |
584 |
|
$this->class_actions[403] = array( |
585 |
|
"identifier" => "envoyer_au_controle_de_legalite", |
586 |
|
"portlet" => array( |
587 |
|
"libelle" => __("Envoyer au contrôle de légalité"), |
588 |
|
"type" => "action-direct-with-confirmation", |
589 |
|
"class" => "envoyer_au_controle_de_legalite-16", |
590 |
|
), |
591 |
|
"view" => "formulaire", |
592 |
|
"method" => "envoyer_au_controle_de_legalite", |
593 |
|
"condition" => array( |
594 |
|
"can_be_sended_to_cl" |
595 |
|
), |
596 |
|
"permission_suffix" => "envoyer_au_controle_de_legalite", |
597 |
|
); |
598 |
|
|
599 |
|
// |
600 |
|
$this->class_actions[998] = array( |
601 |
|
"identifier" => "json_data", |
602 |
|
"view" => "view_json_data", |
603 |
|
"permission_suffix" => "consulter", |
604 |
|
); |
605 |
|
} |
606 |
|
|
607 |
|
/** |
608 |
|
* Clause select pour la requête de sélection des données de l'enregistrement. |
609 |
|
* |
610 |
|
* @return array |
611 |
|
*/ |
612 |
|
function get_var_sql_forminc__champs() { |
613 |
|
return array( |
614 |
|
"instruction", |
615 |
|
"destinataire", |
616 |
|
"instruction.evenement", |
617 |
|
"instruction.commentaire", |
618 |
|
"date_evenement", |
619 |
|
"instruction.lettretype", |
620 |
|
"signataire_arrete", |
621 |
|
"flag_edition_integrale", |
622 |
|
"om_final_instruction_utilisateur", |
623 |
|
"date_finalisation_courrier", |
624 |
|
"date_envoi_signature", |
625 |
|
"date_retour_signature", |
626 |
|
"date_envoi_rar", |
627 |
|
|
628 |
|
"date_retour_rar", |
629 |
|
"date_envoi_controle_legalite", |
630 |
|
"date_retour_controle_legalite", |
631 |
|
|
632 |
|
"numero_arrete", |
633 |
|
|
634 |
|
"complement_om_html", |
635 |
|
"'' as bible_auto", |
636 |
|
"'' as bible", |
637 |
|
"complement2_om_html", |
638 |
|
"'' as bible2", |
639 |
|
"complement3_om_html", |
640 |
|
"'' as bible3", |
641 |
|
"complement4_om_html", |
642 |
|
"'' as bible4", |
643 |
|
|
644 |
|
"titre_om_htmletat", |
645 |
|
"corps_om_htmletatex", |
646 |
|
|
647 |
|
"'' as btn_preview", |
648 |
|
"'' as btn_redaction", |
649 |
|
|
650 |
|
"'' as btn_refresh", |
651 |
|
"'' as live_preview", |
652 |
|
|
653 |
|
"dossier", |
654 |
|
"instruction.action", |
655 |
|
"instruction.delai", |
656 |
|
"instruction.etat", |
657 |
|
"instruction.autorite_competente", |
658 |
|
"instruction.accord_tacite", |
659 |
|
"instruction.delai_notification", |
660 |
|
"instruction.avis_decision", |
661 |
|
"archive_delai", |
662 |
|
"archive_accord_tacite", |
663 |
|
"archive_etat", |
664 |
|
"archive_avis", |
665 |
|
"archive_date_complet", |
666 |
|
"archive_date_rejet", |
667 |
|
"archive_date_limite", |
668 |
|
"archive_date_notification_delai", |
669 |
|
"archive_date_decision", |
670 |
|
"archive_date_validite", |
671 |
|
"archive_date_achevement", |
672 |
|
"archive_date_conformite", |
673 |
|
"archive_date_chantier", |
674 |
|
"archive_date_dernier_depot", |
675 |
|
"date_depot", |
676 |
|
"date_depot_mairie", |
677 |
|
"complement5_om_html", |
678 |
|
"'' as bible5", |
679 |
|
"complement6_om_html", |
680 |
|
"'' as bible6", |
681 |
|
"complement7_om_html", |
682 |
|
"'' as bible7", |
683 |
|
"complement8_om_html", |
684 |
|
"'' as bible8", |
685 |
|
"complement9_om_html", |
686 |
|
"'' as bible9", |
687 |
|
"complement10_om_html", |
688 |
|
"'' as bible10", |
689 |
|
"complement11_om_html", |
690 |
|
"'' as bible11", |
691 |
|
"complement12_om_html", |
692 |
|
"complement13_om_html", |
693 |
|
"complement14_om_html", |
694 |
|
"complement15_om_html", |
695 |
|
"archive_incompletude", |
696 |
|
"archive_incomplet_notifie", |
697 |
|
"archive_evenement_suivant_tacite", |
698 |
|
"archive_evenement_suivant_tacite_incompletude", |
699 |
|
"archive_etat_pendant_incompletude", |
700 |
|
"archive_date_limite_incompletude", |
701 |
|
"archive_delai_incompletude", |
702 |
|
"archive_autorite_competente", |
703 |
|
"code_barres", |
704 |
|
"om_fichier_instruction", |
705 |
|
"om_final_instruction", |
706 |
|
"om_fichier_instruction_dossier_final", |
707 |
|
"document_numerise", |
708 |
|
"duree_validite_parametrage", |
709 |
|
"duree_validite", |
710 |
|
"created_by_commune", |
711 |
|
"archive_date_cloture_instruction", |
712 |
|
"archive_date_premiere_visite", |
713 |
|
"archive_date_derniere_visite", |
714 |
|
"archive_date_contradictoire", |
715 |
|
"archive_date_retour_contradictoire", |
716 |
|
"archive_date_ait", |
717 |
|
"archive_date_transmission_parquet", |
718 |
|
"archive_dossier_instruction_type", |
719 |
|
"archive_date_affichage", |
720 |
|
"pec_metier", |
721 |
|
"archive_pec_metier", |
722 |
|
"archive_a_qualifier", |
723 |
|
"id_parapheur_signature", |
724 |
|
"statut_signature", |
725 |
|
"commentaire_signature", |
726 |
|
"historique_signature", |
727 |
|
"'' as suivi_notification", |
728 |
|
"'' as suivi_notification_service", |
729 |
|
"'' as suivi_notification_tiers", |
730 |
|
"'' as suivi_notification_commune", |
731 |
|
|
732 |
|
"'' as preview_edition", |
733 |
|
"envoye_cl_platau", |
734 |
|
"'' as log_instruction", |
735 |
|
"parapheur_lien_page_signature" |
736 |
|
); |
737 |
} |
} |
738 |
|
|
739 |
/** |
/** |
774 |
} |
} |
775 |
|
|
776 |
/** |
/** |
777 |
|
* CONDITION - is_option_parapheur_relecture_enabled |
778 |
|
* |
779 |
|
* Vérifie que l'option de relecture lors de l'envoi en signature est activée. |
780 |
|
* |
781 |
|
* @return boolean |
782 |
|
*/ |
783 |
|
function is_parapheur_relecture_parameter_enabled() { |
784 |
|
//Instanciation de la classe electronicsignature |
785 |
|
$inst_es = $this->get_electronicsignature_instance(); |
786 |
|
if ($inst_es === false) { |
787 |
|
return false; |
788 |
|
} |
789 |
|
|
790 |
|
if ($inst_es->get_conf('is_forced_view_files') !== 'true' && $inst_es->get_conf('is_forced_view_files') !== true) { |
791 |
|
return false; |
792 |
|
} |
793 |
|
|
794 |
|
return true; |
795 |
|
} |
796 |
|
|
797 |
|
/** |
798 |
|
* CONDITION - is_parapheur_annulation_parameter_enabled |
799 |
|
* |
800 |
|
* Vérifie que l'option d'annulation de l'envoi en signature est activée. |
801 |
|
* |
802 |
|
* @return boolean |
803 |
|
*/ |
804 |
|
function is_parapheur_annulation_parameter_enabled() { |
805 |
|
//Instanciation de la classe electronicsignature |
806 |
|
$inst_es = $this->get_electronicsignature_instance(); |
807 |
|
if ($inst_es === false) { |
808 |
|
return false; |
809 |
|
} |
810 |
|
|
811 |
|
if ($inst_es->get_conf('cancel_send') !== 'true' && $inst_es->get_conf('cancel_send') !== true) { |
812 |
|
return false; |
813 |
|
} |
814 |
|
|
815 |
|
return true; |
816 |
|
} |
817 |
|
|
818 |
|
|
819 |
|
/** |
820 |
|
* CONDITION - is_sent_for_signature |
821 |
|
* |
822 |
|
* Vérifie que l'instruction a été envoyé à signature |
823 |
|
* |
824 |
|
* @return boolean |
825 |
|
*/ |
826 |
|
function is_sent_for_signature() { |
827 |
|
// Si un parapheur a été configuré |
828 |
|
// et que le champ id_parapheur_signature n'est pas vide |
829 |
|
// que le status est différent de "canceled" ou "expired" |
830 |
|
// alors l'évènement a été envoyé en signature |
831 |
|
if ($this->has_connector_electronicsignature() === true |
832 |
|
&& empty($this->getVal("id_parapheur_signature")) === false |
833 |
|
&& ($this->getVal("statut_signature") != "canceled" |
834 |
|
&& $this->getVal("statut_signature") != "expired" |
835 |
|
&& $this->getVal("statut_signature") != "finished")) { |
836 |
|
// |
837 |
|
return true; |
838 |
|
} |
839 |
|
|
840 |
|
return false; |
841 |
|
} |
842 |
|
|
843 |
|
/** |
844 |
|
* CONDITION - is_not_sent_for_signature |
845 |
|
* |
846 |
|
* Vérifie que l'instruction n'a pas été envoyé à signature |
847 |
|
* |
848 |
|
* @return boolean |
849 |
|
*/ |
850 |
|
function is_not_sent_for_signature() { |
851 |
|
// Contrôle si l'utilisateur possède un bypass |
852 |
|
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_definaliser_bypass"); |
853 |
|
if ($bypass == true) { |
854 |
|
return true; |
855 |
|
} |
856 |
|
|
857 |
|
return !$this->is_sent_for_signature(); |
858 |
|
} |
859 |
|
|
860 |
|
|
861 |
|
/** |
862 |
|
* CONDITION - is_signed |
863 |
|
* |
864 |
|
* Vérifie que l'instruction a été signé |
865 |
|
* |
866 |
|
* @return boolean |
867 |
|
*/ |
868 |
|
function is_signed() { |
869 |
|
// Si un parapheur a été configuré |
870 |
|
// et que le champ id_parapheur_signature n'est pas vide |
871 |
|
// et que le statut est égal à "finished" |
872 |
|
// alors le document de l'instruciton à été signé |
873 |
|
if ($this->has_connector_electronicsignature() === true |
874 |
|
&& empty($this->getVal("id_parapheur_signature")) === false |
875 |
|
&& $this->getVal("statut_signature") == "finished") { |
876 |
|
// |
877 |
|
return true; |
878 |
|
} |
879 |
|
|
880 |
|
return false; |
881 |
|
} |
882 |
|
|
883 |
|
/** |
884 |
|
* CONDITION - is_signed |
885 |
|
* |
886 |
|
* Vérifie que l'instruction n'a pas été signée |
887 |
|
* |
888 |
|
* @return boolean |
889 |
|
*/ |
890 |
|
function is_not_signed() { |
891 |
|
// Contrôle si l'utilisateur possède un bypass |
892 |
|
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_definaliser_apres_signature"); |
893 |
|
if ($bypass == true) { |
894 |
|
return true; |
895 |
|
} |
896 |
|
|
897 |
|
return !$this->is_signed(); |
898 |
|
} |
899 |
|
|
900 |
|
|
901 |
|
/** |
902 |
|
* is_sent_to_cl |
903 |
|
* |
904 |
|
* Vérifie que l'instruction a été envoyé au contrôle de légalité |
905 |
|
* |
906 |
|
* @return boolean |
907 |
|
*/ |
908 |
|
function is_sent_to_cl() { |
909 |
|
// Si la case à cocher de l'instruction envoye_cl_platau est à "t" |
910 |
|
if ($this->getVal('envoye_cl_platau') === 't') { |
911 |
|
// |
912 |
|
return true; |
913 |
|
} |
914 |
|
// |
915 |
|
return false; |
916 |
|
} |
917 |
|
|
918 |
|
/** |
919 |
|
* CONDITION - is_portail_notification |
920 |
|
* |
921 |
|
* Vérifie si la notification est une notification de catégorie portail |
922 |
|
* |
923 |
|
* @return boolean |
924 |
|
*/ |
925 |
|
function is_portail_notification_sans_annexe() { |
926 |
|
$collectiviteDi = $this->get_dossier_instruction_om_collectivite(); |
927 |
|
$ev = $this->get_inst_evenement($this->getVal('evenement')); |
928 |
|
if ($this->f->get_param_option_notification($collectiviteDi) === PORTAL |
929 |
|
&& $ev->getVal('notification') != 'notification_manuelle_annexe' |
930 |
|
&& $ev->getVal('notification') != 'notification_manuelle_annexe_signature_requise' |
931 |
|
) { |
932 |
|
return true; |
933 |
|
} |
934 |
|
return false; |
935 |
|
} |
936 |
|
|
937 |
|
/** |
938 |
|
* CONDITION - is_not_portail_notification |
939 |
|
* |
940 |
|
* Vérifie si la notification n'est pas une notification de catégorie portail |
941 |
|
* |
942 |
|
* @return boolean |
943 |
|
*/ |
944 |
|
function is_not_portail_notification_sans_annexe() { |
945 |
|
return (! $this->is_portail_notification_sans_annexe()); |
946 |
|
} |
947 |
|
|
948 |
|
/** |
949 |
|
* CONDITION - can_be_signed |
950 |
|
* |
951 |
|
* Vérifie que le document de l'instruction peut être envoyé au parapheur pour signature |
952 |
|
* |
953 |
|
* @return boolean |
954 |
|
*/ |
955 |
|
function can_be_signed() { |
956 |
|
// Instanciation de l'objet signataire_arrete |
957 |
|
$inst_signataire_arrete = $this->f->get_inst__om_dbform(array( |
958 |
|
"obj" => "signataire_arrete", |
959 |
|
"idx" => $this->getVal("signataire_arrete"), |
960 |
|
)); |
961 |
|
// Si un parapheur a été configuré, que le document est finalisé, que le signataire |
962 |
|
// possède une adresse email, on vérifie le champ id_parapheur_signature |
963 |
|
// S'il est vide l'évènement peut être envoyé en signature |
964 |
|
// S'il ne l'est pas, alors on vérifie le champ statut_signature |
965 |
|
// Si la valeur de ce champ est égal à "canceled" ou "expired" |
966 |
|
// alors l'évènement peut être envoyé en signature |
967 |
|
if ($this->has_connector_electronicsignature() === true |
968 |
|
&& $this->getVal("om_final_instruction") == 't' |
969 |
|
&& empty($inst_signataire_arrete->getVal('email')) === false) { |
970 |
|
// |
971 |
|
if (empty($this->getVal("id_parapheur_signature")) === true |
972 |
|
|| $this->getVal("statut_signature") == "canceled" |
973 |
|
|| $this->getVal("statut_signature") == "expired") { |
974 |
|
// |
975 |
|
return true; |
976 |
|
} |
977 |
|
} |
978 |
|
|
979 |
|
$this->addToLog(__METHOD__."() has_connector_electronicsignature: ".var_export($this->has_connector_electronicsignature(), true), EXTRA_VERBOSE_MODE); |
980 |
|
$this->addToLog(__METHOD__."() om_final_instruction: ".var_export($this->getVal("om_final_instruction"), true), EXTRA_VERBOSE_MODE); |
981 |
|
$this->addToLog(__METHOD__."() email: ".var_export($inst_signataire_arrete->getVal('email'), true), EXTRA_VERBOSE_MODE); |
982 |
|
$this->addToLog(__METHOD__."() id_parapheur_signature: ".var_export($this->getVal("id_parapheur_signature"), true), EXTRA_VERBOSE_MODE); |
983 |
|
$this->addToLog(__METHOD__."() statut_signature: ".var_export($this->getVal("statut_signature"), true), EXTRA_VERBOSE_MODE); |
984 |
|
|
985 |
|
return false; |
986 |
|
} |
987 |
|
|
988 |
|
/** |
989 |
|
* CONDITION - has_connector_electronicsignature |
990 |
|
* |
991 |
|
* Vérifie qu'un parapheur est paramétré |
992 |
|
* |
993 |
|
* @return boolean |
994 |
|
*/ |
995 |
|
function has_connector_electronicsignature() { |
996 |
|
$inst_es = $this->get_electronicsignature_instance(false); |
997 |
|
if ($inst_es === false) { |
998 |
|
return false; |
999 |
|
} |
1000 |
|
return true; |
1001 |
|
} |
1002 |
|
|
1003 |
|
/** |
1004 |
|
* CONDITION - can_display_parapheur |
1005 |
|
* |
1006 |
|
* Vérifie que le fieldset "Suivi Parapheur" soit affichable |
1007 |
|
* |
1008 |
|
* @return boolean |
1009 |
|
*/ |
1010 |
|
function can_display_parapheur() { |
1011 |
|
$evenement_id = $this->getVal("evenement"); |
1012 |
|
$inst_evenement = $this->get_inst_evenement($evenement_id); |
1013 |
|
if ($this->has_connector_electronicsignature() === true |
1014 |
|
&& $inst_evenement->getVal('lettretype') !== '' |
1015 |
|
&& $inst_evenement->getVal('lettretype') !== null |
1016 |
|
&& (empty($this->getVal("id_parapheur_signature")) === false |
1017 |
|
|| empty($this->getVal("historique_signature")) === false)) { |
1018 |
|
// |
1019 |
|
return true; |
1020 |
|
} |
1021 |
|
|
1022 |
|
return false; |
1023 |
|
} |
1024 |
|
|
1025 |
|
/** |
1026 |
|
* CONDITION - can_display_notification |
1027 |
|
* |
1028 |
|
* Vérifie que le champs "Suivi notification" est affichable |
1029 |
|
* |
1030 |
|
* @return boolean |
1031 |
|
*/ |
1032 |
|
function can_display_notification_demandeur() { |
1033 |
|
// Le suivi des notification est affiché si l'événement est notifiable |
1034 |
|
// et si des notifications ont été envoyées |
1035 |
|
$evenement_id = $this->getVal("evenement"); |
1036 |
|
$inst_evenement = $this->get_inst_evenement($evenement_id); |
1037 |
|
if ($inst_evenement->getVal('notification') != null && |
1038 |
|
$inst_evenement->getVal('notification') != '') { |
1039 |
|
// Des notifications ont été envoyé si il existe au moins une notification |
1040 |
|
// liées à l'instruction |
1041 |
|
$idsNotifs = $this->get_instruction_notification( |
1042 |
|
$this->getVal($this->clePrimaire), |
1043 |
|
array( |
1044 |
|
'notification_recepisse', |
1045 |
|
'notification_instruction', |
1046 |
|
'notification_decision', |
1047 |
|
), |
1048 |
|
true |
1049 |
|
); |
1050 |
|
if (isset($idsNotifs) && $idsNotifs !== array()) { |
1051 |
|
return true; |
1052 |
|
} |
1053 |
|
} |
1054 |
|
return false; |
1055 |
|
} |
1056 |
|
|
1057 |
|
/** |
1058 |
|
* CONDITION - can_display_notification |
1059 |
|
* |
1060 |
|
* Vérifie que le champs "suivi_notification_service" est affichable |
1061 |
|
* |
1062 |
|
* @return boolean |
1063 |
|
*/ |
1064 |
|
function can_display_notification_service() { |
1065 |
|
// Le suivi des notification est affiché si l'événement est notifiable |
1066 |
|
// et si des notifications ont été envoyées |
1067 |
|
$evenement_id = $this->getVal("evenement"); |
1068 |
|
$inst_evenement = $this->get_inst_evenement($evenement_id); |
1069 |
|
if ($this->get_boolean_from_pgsql_value($inst_evenement->getVal('notification_service')) == true) { |
1070 |
|
// Des notifications ont été envoyé si il existe au moins une notification |
1071 |
|
// de type notification_service_consulte liées à l'instruction |
1072 |
|
$idsNotifs = $this->get_instruction_notification( |
1073 |
|
$this->getVal($this->clePrimaire), |
1074 |
|
'notification_service_consulte' |
1075 |
|
); |
1076 |
|
if (isset($idsNotifs) && $idsNotifs !== array()) { |
1077 |
|
return true; |
1078 |
|
} |
1079 |
|
} |
1080 |
|
return false; |
1081 |
|
} |
1082 |
|
|
1083 |
|
|
1084 |
|
/** |
1085 |
|
* CONDITION - can_display_notification_tiers |
1086 |
|
* |
1087 |
|
* Vérifie que le champs "suivi_notification_tiers" est affichable |
1088 |
|
* |
1089 |
|
* @return boolean |
1090 |
|
*/ |
1091 |
|
function can_display_notification_tiers() { |
1092 |
|
// Le suivi des notification est affiché si l'événement est notifiable |
1093 |
|
// et si des notifications ont été envoyées |
1094 |
|
$evenement_id = $this->getVal("evenement"); |
1095 |
|
$inst_evenement = $this->get_inst_evenement($evenement_id); |
1096 |
|
if (! empty($inst_evenement->getVal('notification_tiers'))) { |
1097 |
|
// Des notifications ont été envoyé si il existe au moins une notification |
1098 |
|
// de type notification_tiers_consulte liées à l'instruction |
1099 |
|
$idsNotifs = $this->get_instruction_notification( |
1100 |
|
$this->getVal($this->clePrimaire), |
1101 |
|
'notification_tiers_consulte' |
1102 |
|
); |
1103 |
|
if (isset($idsNotifs) && $idsNotifs !== array()) { |
1104 |
|
return true; |
1105 |
|
} |
1106 |
|
} |
1107 |
|
return false; |
1108 |
|
} |
1109 |
|
|
1110 |
|
/** |
1111 |
|
* CONDITION - can_display_notification_commune |
1112 |
|
* |
1113 |
|
* Vérifie que le champs "suivi_notification_commune" est affichable |
1114 |
|
* |
1115 |
|
* @return boolean |
1116 |
|
*/ |
1117 |
|
function can_display_notification_commune() { |
1118 |
|
// Le suivi des notification si il existe au moins une notification |
1119 |
|
// de type notification_depot_demat liées à l'instruction |
1120 |
|
$idsNotifs = $this->get_instruction_notification( |
1121 |
|
$this->getVal($this->clePrimaire), |
1122 |
|
array('notification_depot_demat', 'notification_commune') |
1123 |
|
); |
1124 |
|
if (isset($idsNotifs) && $idsNotifs !== array()) { |
1125 |
|
return true; |
1126 |
|
} |
1127 |
|
return false; |
1128 |
|
} |
1129 |
|
|
1130 |
|
/** |
1131 |
* TREATMENT - disable_edition_integrale. |
* TREATMENT - disable_edition_integrale. |
1132 |
* |
* |
1133 |
* Cette methode permet de passer la consultation en "lu" |
* Cette methode permet de passer la consultation en "lu" |
1229 |
} |
} |
1230 |
|
|
1231 |
/** |
/** |
1232 |
* Cette méthode permet de récupérer le dossier d'autorisation d'un dossier |
* Cette méthode instancie le dossier à partir de l'identifiant passé |
1233 |
|
* en paramètre et renvoie l'identifiant du dossier d'autorisation (DA) |
1234 |
|
* associé au dossier. |
1235 |
|
* Si l'identifiant du dossier n'est pas fourni alors cette méthode |
1236 |
|
* renverra NULL |
1237 |
|
* |
1238 |
|
* @param string identifiant du dossier |
1239 |
|
* @return null|string null ou identifiant du DA |
1240 |
*/ |
*/ |
1241 |
function getNumDemandeAutorFromDossier($id) { |
function getNumDemandeAutorFromDossier($id) { |
|
// |
|
1242 |
if (!isset($id)) { |
if (!isset($id)) { |
1243 |
return NULL; |
return NULL; |
1244 |
} |
} |
|
// |
|
|
$sql = "select dossier_autorisation from ".DB_PREFIXE."dossier "; |
|
|
$sql .= " where dossier='".$id."'"; |
|
|
// |
|
|
$dossier_autorisation = $this->db->getOne($sql); |
|
|
$this->addToLog("getNumDemandeAutorFromDossier(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
|
|
database::isError($dossier_autorisation); |
|
|
// |
|
|
return $dossier_autorisation; |
|
|
} |
|
1245 |
|
|
1246 |
// }}} |
$dossier = $this->f->get_inst__om_dbform(array( |
1247 |
|
'obj' => 'dossier', |
1248 |
|
'idx' => $id, |
1249 |
|
)); |
1250 |
|
|
1251 |
|
return $dossier->getVal('dossier_autorisation'); |
1252 |
|
} |
1253 |
|
|
1254 |
|
|
1255 |
function setType(&$form, $maj) { |
function setType(&$form, $maj) { |
1256 |
|
$data = array('form' => &$form, 'maj' => &$maj); |
1257 |
|
$this->f->module_manager->run_hooks('setType_pre', $this, $data); |
1258 |
|
|
1259 |
// Récupération du mode de l'action |
// Récupération du mode de l'action |
1260 |
$crud = $this->get_action_crud($maj); |
$crud = $this->get_action_crud($maj); |
1261 |
// Récupère la collectivité du dossier d'instruction |
// Récupère la collectivité du dossier d'instruction |
1266 |
$form->setType($value, 'hidden'); |
$form->setType($value, 'hidden'); |
1267 |
} |
} |
1268 |
|
|
1269 |
|
// Les champs historique_signature et statut_signature ne sont pas saisissable dans tous les cas |
1270 |
|
if ($this->can_display_parapheur() === true && $maj == 3) { |
1271 |
|
$form->setType('statut_signature', 'selectstatic'); |
1272 |
|
$form->setType('historique_signature', 'jsontotab'); |
1273 |
|
if ($this->getVal('commentaire_signature') == null) { |
1274 |
|
$form->setType('commentaire_signature', 'hidden'); |
1275 |
|
} else { |
1276 |
|
$form->setType('commentaire_signature', 'hiddenstatic'); |
1277 |
|
} |
1278 |
|
} |
1279 |
|
|
1280 |
|
// Le champ de suivi des notifications des demandeurs n'est pas affichable dans tous les cas |
1281 |
|
if ($maj == 3 && $this->can_display_notification_demandeur() === true) { |
1282 |
|
$form->setType('suivi_notification', 'jsontotab'); |
1283 |
|
} |
1284 |
|
// Le champ de suivi des notifications des services n'est pas affichable dans tous les cas |
1285 |
|
if ($maj == 3 && $this->can_display_notification_service() === true) { |
1286 |
|
$form->setType('suivi_notification_service', 'jsontotab'); |
1287 |
|
} |
1288 |
|
// Le champ de suivi des notifications des tiers n'est pas affichable dans tous les cas |
1289 |
|
if ($maj == 3 && $this->can_display_notification_tiers() === true) { |
1290 |
|
$form->setType('suivi_notification_tiers', 'jsontotab'); |
1291 |
|
} |
1292 |
|
// Le champ de suivi des notifications des communes n'est pas affichable dans tous les cas |
1293 |
|
if ($maj == 3 && $this->can_display_notification_commune() === true) { |
1294 |
|
$form->setType('suivi_notification_commune', 'jsontotab'); |
1295 |
|
} |
1296 |
|
|
1297 |
// MODE AJOUTER |
// MODE AJOUTER |
1298 |
if ($this->getParameter('maj') == 0) { |
if ($this->getParameter('maj') == 0) { |
1299 |
$form->setType("date_evenement", "date"); |
$form->setType('commentaire', 'textareahidden'); |
1300 |
if ($this->is_in_context_of_foreign_key("evenement", $this->retourformulaire)) { |
// Si l'option est active passage du champ date en lecture seule |
1301 |
|
if ($this->f->is_option_date_evenement_instruction_lecture_seule($collectivite_di) === true) { |
1302 |
|
$form->setType("date_evenement", "hiddenstaticdate"); |
1303 |
|
} else { |
1304 |
|
$form->setType("date_evenement", "date"); |
1305 |
|
} |
1306 |
|
if ($this->is_in_context_of_foreign_key("evenement", $this->getParameter("retourformulaire"))) { |
1307 |
$form->setType("evenement", "selecthiddenstatic"); |
$form->setType("evenement", "selecthiddenstatic"); |
1308 |
} else { |
} else { |
1309 |
$form->setType("evenement", "select"); |
$form->setType("evenement", "select"); |
1310 |
} |
} |
1311 |
if ($this->is_in_context_of_foreign_key("signataire_arrete", $this->retourformulaire)) { |
if ($this->is_in_context_of_foreign_key("signataire_arrete", $this->getParameter("retourformulaire"))) { |
1312 |
$form->setType("signataire_arrete", "selecthiddenstatic"); |
$form->setType("signataire_arrete", "selecthiddenstatic"); |
1313 |
} else { |
} else { |
1314 |
$form->setType("signataire_arrete", "select"); |
$form->setType("signataire_arrete", "select"); |
1320 |
|
|
1321 |
// MODE MODIFIER |
// MODE MODIFIER |
1322 |
if ($this->getParameter('maj') == 1) { |
if ($this->getParameter('maj') == 1) { |
1323 |
$form->setType("date_evenement", "date"); |
// Si l'option est active passage du champ date en lecture seule |
1324 |
|
if ($this->f->is_option_date_evenement_instruction_lecture_seule($collectivite_di) === true) { |
1325 |
|
$form->setType("date_evenement", "hiddenstaticdate"); |
1326 |
|
} else { |
1327 |
|
$form->setType("date_evenement", "date"); |
1328 |
|
} |
1329 |
$form->setType("evenement", "selecthiddenstatic"); |
$form->setType("evenement", "selecthiddenstatic"); |
1330 |
if ($this->has_an_edition() === true) { |
if ($this->has_an_edition() === true) { |
1331 |
$form->setType('lettretype', 'hiddenstatic'); |
$form->setType('lettretype', 'hiddenstatic'); |
1332 |
if ($this->is_in_context_of_foreign_key("signataire_arrete", $this->retourformulaire)) { |
if ($this->is_in_context_of_foreign_key("signataire_arrete", $this->getParameter("retourformulaire"))) { |
1333 |
$form->setType("signataire_arrete", "selecthiddenstatic"); |
$form->setType("signataire_arrete", "selecthiddenstatic"); |
1334 |
} else { |
} else { |
1335 |
$form->setType("signataire_arrete", "select"); |
$form->setType("signataire_arrete", "select"); |
1353 |
$form->setType('btn_refresh', 'httpclickbutton'); |
$form->setType('btn_refresh', 'httpclickbutton'); |
1354 |
$form->setType('btn_preview', 'httpclickbutton'); |
$form->setType('btn_preview', 'httpclickbutton'); |
1355 |
$form->setType('btn_redaction', 'httpclickbutton'); |
$form->setType('btn_redaction', 'httpclickbutton'); |
1356 |
$form->setType('live_preview', 'pdf'); |
// /!\ le type du champs est utilisé dans un selecteur dans le jscript.js |
1357 |
|
// pour identifiant le champ de prévisualisation et régler sa taille à |
1358 |
|
// l'affichage du champ. En cas de modification, le selecteur doit également |
1359 |
|
// être mis à jour |
1360 |
|
$form->setType('live_preview', 'previsualiser_pdf'); |
1361 |
} |
} |
1362 |
|
|
1363 |
// necessaire pour calcul de date en modification |
// necessaire pour calcul de date en modification |
1371 |
// |
// |
1372 |
$form->setType('date_envoi_signature', 'date'); |
$form->setType('date_envoi_signature', 'date'); |
1373 |
$form->setType('date_retour_signature', 'date'); |
$form->setType('date_retour_signature', 'date'); |
1374 |
|
if ($this->is_sent_for_signature() === true |
1375 |
|
&& $this->is_signed() === true) { |
1376 |
|
// |
1377 |
|
$form->setType("date_envoi_signature", "datereadonly"); |
1378 |
|
$form->setType("date_retour_signature", "datereadonly"); |
1379 |
|
} |
1380 |
$form->setType('date_envoi_rar', 'date'); |
$form->setType('date_envoi_rar', 'date'); |
1381 |
$form->setType('date_retour_rar', 'date'); |
$form->setType('date_retour_rar', 'date'); |
1382 |
$form->setType('date_envoi_controle_legalite', 'date'); |
$form->setType('date_envoi_controle_legalite', 'date'); |
1383 |
|
if ($this->is_sent_to_cl() === true) { |
1384 |
|
$form->setType("date_envoi_controle_legalite", "datedisabled"); |
1385 |
|
} |
1386 |
$form->setType('date_retour_controle_legalite', 'date'); |
$form->setType('date_retour_controle_legalite', 'date'); |
1387 |
$form->setType('date_finalisation_courrier', 'date'); |
$form->setType('date_finalisation_courrier', 'date'); |
1388 |
} |
} |
1389 |
} |
} |
1390 |
} |
} |
1391 |
|
|
1392 |
// MODE CONSULTER + SUPPRIMER + SUIVI DES DATES 125 |
// MODE CONSULTER + SUPPRIMER + SUIVI DES DATES 125 + NOTIFICATION MANUELLE |
1393 |
if ($this->getParameter('maj') == 3 |
if ($this->getParameter('maj') == 3 |
1394 |
|| $this->getParameter('maj') == 2 |
|| $this->getParameter('maj') == 2 |
1395 |
|| $this->getParameter('maj') == 125) { |
|| $this->getParameter('maj') == 125 |
1396 |
|
|| $this->getParameter('maj') == 410) { |
1397 |
// |
// |
1398 |
$form->setType("date_evenement", "datestatic"); |
$form->setType("date_evenement", "datestatic"); |
1399 |
$form->setType("evenement", "selecthiddenstatic"); |
$form->setType("evenement", "selecthiddenstatic"); |
1406 |
$form->setType('om_final_instruction_utilisateur', 'hidden'); |
$form->setType('om_final_instruction_utilisateur', 'hidden'); |
1407 |
} |
} |
1408 |
} |
} |
1409 |
|
if ($this->evenement_has_a_commentaire($this->getVal('evenement')) === true ) { |
1410 |
|
$form->setType('commentaire', 'textareastatic'); |
1411 |
|
} |
1412 |
} |
} |
1413 |
|
|
1414 |
// MODE CONSULTER + SUPPRIMER |
// MODE CONSULTER + SUPPRIMER + NOTIFICATION MANUELLE |
1415 |
if ($this->getParameter('maj') == 3 || $this->getParameter('maj') == 2) { |
if ($this->getParameter('maj') == 3 |
1416 |
|
|| $this->getParameter('maj') == 2 |
1417 |
|
|| $this->getParameter('maj') == 410) { |
1418 |
|
// Si il n'y a pas de lettre type (edition) associé à l'événement |
1419 |
|
// les dates de suivi ne sont pas affichée |
1420 |
if ($this->has_an_edition() === true) { |
if ($this->has_an_edition() === true) { |
1421 |
|
$form->setType('date_envoi_signature', 'datestatic'); |
1422 |
|
$form->setType('date_retour_signature', 'datestatic'); |
1423 |
|
$form->setType('date_envoi_rar', 'datestatic'); |
1424 |
|
$form->setType('date_retour_rar', 'datestatic'); |
1425 |
|
$form->setType('date_envoi_controle_legalite', 'datestatic'); |
1426 |
|
$form->setType('date_retour_controle_legalite', 'datestatic'); |
1427 |
|
$form->setType('date_finalisation_courrier', 'datestatic'); |
1428 |
if ($this->getVal("flag_edition_integrale") == "t") { |
if ($this->getVal("flag_edition_integrale") == "t") { |
1429 |
$form->setType("titre_om_htmletat", "htmlstatic"); |
$form->setType("titre_om_htmletat", "htmlstatic"); |
1430 |
$form->setType("corps_om_htmletatex", "htmlstatic"); |
$form->setType("corps_om_htmletatex", "htmlstatic"); |
1435 |
$form->setType("complement4_om_html", "htmlstatic"); |
$form->setType("complement4_om_html", "htmlstatic"); |
1436 |
} |
} |
1437 |
} |
} |
|
$form->setType('date_envoi_signature', 'datestatic'); |
|
|
$form->setType('date_retour_signature', 'datestatic'); |
|
|
$form->setType('date_envoi_rar', 'datestatic'); |
|
|
$form->setType('date_retour_rar', 'datestatic'); |
|
|
$form->setType('date_envoi_controle_legalite', 'datestatic'); |
|
|
$form->setType('date_retour_controle_legalite', 'datestatic'); |
|
|
$form->setType('date_finalisation_courrier', 'datestatic'); |
|
1438 |
} |
} |
1439 |
|
|
1440 |
// MODE SUIVI DES DATES 125 |
// MODE SUIVI DES DATES 125 |
1443 |
$form->setType('om_final_instruction_utilisateur', 'hiddenstatic'); |
$form->setType('om_final_instruction_utilisateur', 'hiddenstatic'); |
1444 |
$form->setType('date_envoi_signature', 'date'); |
$form->setType('date_envoi_signature', 'date'); |
1445 |
$form->setType('date_retour_signature', 'date'); |
$form->setType('date_retour_signature', 'date'); |
1446 |
|
if ($this->is_sent_for_signature() === true |
1447 |
|
|| $this->is_signed() === true) { |
1448 |
|
// |
1449 |
|
$form->setType("date_envoi_signature", "datereadonly"); |
1450 |
|
$form->setType("date_retour_signature", "datereadonly"); |
1451 |
|
} |
1452 |
$form->setType('date_envoi_rar', 'date'); |
$form->setType('date_envoi_rar', 'date'); |
1453 |
$form->setType('date_retour_rar', 'date'); |
$form->setType('date_retour_rar', 'date'); |
1454 |
$form->setType('date_envoi_controle_legalite', 'date'); |
$form->setType('date_envoi_controle_legalite', 'date'); |
1455 |
|
if ($this->is_sent_to_cl() === true) { |
1456 |
|
$form->setType("date_envoi_controle_legalite", "datedisabled"); |
1457 |
|
} |
1458 |
$form->setType('date_retour_controle_legalite', 'date'); |
$form->setType('date_retour_controle_legalite', 'date'); |
1459 |
$form->setType('date_finalisation_courrier', 'date'); |
$form->setType('date_finalisation_courrier', 'date'); |
1460 |
} |
} |
1461 |
|
|
1462 |
|
if ($maj == 401) { |
1463 |
|
foreach ($this->champs as $champ) { |
1464 |
|
$form->setType($champ, 'hidden'); |
1465 |
|
} |
1466 |
|
$form->setType('preview_edition', 'previsualiser'); |
1467 |
|
} |
1468 |
|
|
1469 |
|
// Si l'instruction a été envoyé au contrôle de légalité et que la |
1470 |
|
// tâche envoi_cl lié n'a pas encore été traité il faut indiquer à |
1471 |
|
// l'utilisateur que l'envoi au cl est en cours de traitement. |
1472 |
|
if ($this->is_sent_to_cl() === true |
1473 |
|
&& empty($this->getVal('date_envoi_controle_legalite')) |
1474 |
|
&& $maj == 3) { |
1475 |
|
$form->setType("date_envoi_controle_legalite", "hiddenstatic"); |
1476 |
|
} |
1477 |
|
$data = array('form' => &$form, 'maj' => &$maj); |
1478 |
|
$this->f->module_manager->run_hooks('setType_post', $this, $data); |
1479 |
} |
} |
1480 |
|
|
1481 |
function setOnchange(&$form,$maj){ |
function setOnchange(&$form,$maj){ |
1482 |
|
$this->f->log(__METHOD__, 'BEGIN'); |
1483 |
|
$data = array('form' => &$form, 'maj' => &$maj); |
1484 |
|
$this->f->module_manager->run_hooks('setOnchange_pre', $this, $data); |
1485 |
|
|
1486 |
parent::setOnchange($form,$maj); |
parent::setOnchange($form,$maj); |
1487 |
|
|
1488 |
// MODE AJOUTER |
// MODE AJOUTER |
1489 |
if ($this->getParameter('maj') == 0) { |
if ($this->getParameter('maj') == 0) { |
1490 |
$form->setOnchange("evenement", "manage_instruction_evenement_lettretype(this.value, '".addslashes($this->getParameter('idxformulaire'))."');"); |
$form->setOnchange( |
1491 |
|
"evenement", |
1492 |
|
"manage_instruction_evenement_lettretype(this.value, '".addslashes($this->getParameter('idxformulaire'))."'); |
1493 |
|
manage_instruction_evenement_commentaire(this.value, '".addslashes($this->getParameter('idxformulaire'))."');" |
1494 |
|
); |
1495 |
} |
} |
1496 |
|
|
1497 |
|
$data = array('form' => &$form, 'maj' => &$maj); |
1498 |
|
$this->f->module_manager->run_hooks('setOnchange_post', $this, $data); |
1499 |
|
$this->f->log(__METHOD__, 'END'); |
1500 |
} |
} |
1501 |
|
|
1502 |
function evenement_has_an_edition($evenement_id) { |
function evenement_has_an_edition($evenement_id) { |
1516 |
echo json_encode($json_return); |
echo json_encode($json_return); |
1517 |
} |
} |
1518 |
|
|
1519 |
function setSelect(&$form, $maj, &$db = null, $debug = null) { |
function evenement_has_a_commentaire($evenement_id) { |
1520 |
|
$evenement = $this->get_inst_evenement($evenement_id); |
1521 |
|
return $this->get_boolean_from_pgsql_value($evenement->getVal('commentaire')); |
1522 |
|
} |
1523 |
|
|
1524 |
|
function view_evenement_has_a_commentaire_json() { |
1525 |
|
$json_return = array( |
1526 |
|
"commentaire" => $this->evenement_has_a_commentaire($this->f->get_submitted_get_value('evenement_id')) |
1527 |
|
); |
1528 |
|
echo json_encode($json_return); |
1529 |
|
} |
1530 |
|
|
1531 |
|
|
1532 |
|
/** |
1533 |
|
* CONDITION - can_be_sended_to_cl |
1534 |
|
* |
1535 |
|
* Vérifie que le contrôle de légalité est disponible |
1536 |
|
* |
1537 |
|
* @return boolean |
1538 |
|
*/ |
1539 |
|
function can_be_sended_to_cl() { |
1540 |
|
// Si l'instruction a une édition |
1541 |
|
// et que l'événement est paramétré pour envoyer le contrôle de légalité |
1542 |
|
// par Plat'AU |
1543 |
|
// et que la date de retour signature est renseignée |
1544 |
|
// et que la date d'envoi au contrôle légalité n'est pas renseignée |
1545 |
|
// et qu'il n'existe pas de task envoi_CL en cours (!= done ou canceled) |
1546 |
|
if ($this->has_an_edition() === true) { |
1547 |
|
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
1548 |
|
$inst_evenement = $this->get_inst_evenement($this->getVal('evenement')); |
1549 |
|
if ($inst_evenement->getVal('envoi_cl_platau') === 't' |
1550 |
|
&& empty($this->getVal('date_retour_signature')) === false |
1551 |
|
&& empty($this->getVal('date_envoi_controle_legalite')) === true |
1552 |
|
&& $this->getVal('envoye_cl_platau') === 'f' |
1553 |
|
&& $this->f->is_type_dossier_platau($inst_di->getVal('dossier_autorisation')) === true |
1554 |
|
&& $inst_di->getVal('etat_transmission_platau') !== 'jamais_transmissible') { |
1555 |
|
// |
1556 |
|
return true; |
1557 |
|
} |
1558 |
|
} |
1559 |
|
// |
1560 |
|
return false; |
1561 |
|
} |
1562 |
|
|
1563 |
|
/** |
1564 |
|
* |
1565 |
|
* @return string |
1566 |
|
*/ |
1567 |
|
function get_var_sql_forminc__sql_signataire_arrete() { |
1568 |
|
return sprintf( |
1569 |
|
"SELECT |
1570 |
|
signataire_arrete.signataire_arrete, |
1571 |
|
CONCAT_WS( |
1572 |
|
' - ', |
1573 |
|
CONCAT_WS(' ', signataire_arrete.prenom, signataire_arrete.nom), |
1574 |
|
signataire_habilitation.libelle, |
1575 |
|
signataire_arrete.description |
1576 |
|
) |
1577 |
|
FROM |
1578 |
|
%1\$ssignataire_arrete |
1579 |
|
LEFT JOIN %1\$ssignataire_habilitation |
1580 |
|
ON signataire_arrete.signataire_habilitation = signataire_habilitation.signataire_habilitation |
1581 |
|
WHERE |
1582 |
|
((signataire_arrete.om_validite_debut IS NULL |
1583 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1584 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE)) |
1585 |
|
OR (signataire_arrete.om_validite_debut <= CURRENT_DATE |
1586 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1587 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE))) |
1588 |
|
ORDER BY |
1589 |
|
signataire_arrete.prenom, |
1590 |
|
signataire_arrete.nom", |
1591 |
|
DB_PREFIXE |
1592 |
|
); |
1593 |
|
} |
1594 |
|
|
1595 |
|
/** |
1596 |
|
* |
1597 |
|
* @return string |
1598 |
|
*/ |
1599 |
|
function get_var_sql_forminc__sql_signataire_arrete_by_id() { |
1600 |
|
return sprintf( |
1601 |
|
"SELECT |
1602 |
|
signataire_arrete.signataire_arrete, |
1603 |
|
CONCAT_WS( |
1604 |
|
' - ', |
1605 |
|
CONCAT_WS(' ', signataire_arrete.prenom, signataire_arrete.nom), |
1606 |
|
signataire_habilitation.libelle, |
1607 |
|
signataire_arrete.description |
1608 |
|
) |
1609 |
|
FROM |
1610 |
|
%1\$ssignataire_arrete |
1611 |
|
LEFT JOIN %1\$ssignataire_habilitation |
1612 |
|
ON signataire_arrete.signataire_habilitation = signataire_habilitation.signataire_habilitation |
1613 |
|
WHERE |
1614 |
|
signataire_arrete.signataire_arrete = <idx>", |
1615 |
|
DB_PREFIXE |
1616 |
|
); |
1617 |
|
} |
1618 |
|
|
1619 |
|
/** |
1620 |
|
* |
1621 |
|
* @return string |
1622 |
|
*/ |
1623 |
|
function get_var_sql_forminc__sql_signataire_arrete_by_di() { |
1624 |
|
return sprintf( |
1625 |
|
"SELECT |
1626 |
|
signataire_arrete.signataire_arrete, |
1627 |
|
CONCAT_WS( |
1628 |
|
' - ', |
1629 |
|
CONCAT_WS(' ', signataire_arrete.prenom, signataire_arrete.nom), |
1630 |
|
signataire_habilitation.libelle, |
1631 |
|
signataire_arrete.description |
1632 |
|
) |
1633 |
|
FROM |
1634 |
|
%1\$ssignataire_arrete |
1635 |
|
LEFT JOIN %1\$som_collectivite |
1636 |
|
ON signataire_arrete.om_collectivite = om_collectivite.om_collectivite |
1637 |
|
LEFT JOIN %1\$ssignataire_habilitation |
1638 |
|
ON signataire_arrete.signataire_habilitation = signataire_habilitation.signataire_habilitation |
1639 |
|
WHERE |
1640 |
|
((signataire_arrete.om_validite_debut IS NULL |
1641 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1642 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE)) |
1643 |
|
OR (signataire_arrete.om_validite_debut <= CURRENT_DATE |
1644 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1645 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE))) |
1646 |
|
AND (om_collectivite.niveau = '2' |
1647 |
|
OR signataire_arrete.om_collectivite = <collectivite_di>) |
1648 |
|
ORDER BY |
1649 |
|
signataire_arrete.prenom, signataire_arrete.nom", |
1650 |
|
DB_PREFIXE |
1651 |
|
); |
1652 |
|
} |
1653 |
|
|
1654 |
|
/** |
1655 |
|
* |
1656 |
|
* @return string |
1657 |
|
*/ |
1658 |
|
function get_var_sql_forminc__sql_signataire_arrete_defaut() { |
1659 |
|
return sprintf( |
1660 |
|
"SELECT |
1661 |
|
signataire_arrete.signataire_arrete, |
1662 |
|
CONCAT_WS( |
1663 |
|
' - ', |
1664 |
|
CONCAT_WS(' ', signataire_arrete.prenom, signataire_arrete.nom), |
1665 |
|
signataire_habilitation.libelle, |
1666 |
|
signataire_arrete.description |
1667 |
|
) |
1668 |
|
FROM |
1669 |
|
%1\$ssignataire_arrete |
1670 |
|
LEFT JOIN %1\$ssignataire_habilitation |
1671 |
|
ON signataire_arrete.signataire_habilitation = signataire_habilitation.signataire_habilitation |
1672 |
|
WHERE |
1673 |
|
((signataire_arrete.om_validite_debut IS NULL |
1674 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1675 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE)) |
1676 |
|
OR (signataire_arrete.om_validite_debut <= CURRENT_DATE |
1677 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1678 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE))) |
1679 |
|
AND signataire_arrete.defaut IS TRUE |
1680 |
|
ORDER BY |
1681 |
|
signataire_arrete.prenom, signataire_arrete.nom", |
1682 |
|
DB_PREFIXE |
1683 |
|
); |
1684 |
|
} |
1685 |
|
|
1686 |
|
/** |
1687 |
|
* |
1688 |
|
* @return string |
1689 |
|
*/ |
1690 |
|
function get_var_sql_forminc__sql_signataire_arrete_defaut_by_di() { |
1691 |
|
return sprintf( |
1692 |
|
"SELECT |
1693 |
|
signataire_arrete.signataire_arrete, |
1694 |
|
CONCAT_WS( |
1695 |
|
' - ', |
1696 |
|
CONCAT_WS(' ', signataire_arrete.prenom, signataire_arrete.nom), |
1697 |
|
signataire_habilitation.libelle, |
1698 |
|
signataire_arrete.description |
1699 |
|
) |
1700 |
|
FROM |
1701 |
|
%1\$ssignataire_arrete |
1702 |
|
LEFT JOIN %1\$ssignataire_habilitation |
1703 |
|
ON signataire_arrete.signataire_habilitation = signataire_habilitation.signataire_habilitation |
1704 |
|
LEFT JOIN %1\$som_collectivite |
1705 |
|
ON signataire_arrete.om_collectivite = om_collectivite.om_collectivite |
1706 |
|
WHERE |
1707 |
|
((signataire_arrete.om_validite_debut IS NULL |
1708 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1709 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE)) |
1710 |
|
OR (signataire_arrete.om_validite_debut <= CURRENT_DATE |
1711 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1712 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE))) |
1713 |
|
AND signataire_arrete.defaut IS TRUE |
1714 |
|
AND (om_collectivite.niveau = '2' |
1715 |
|
OR signataire_arrete.om_collectivite = <collectivite_di>) |
1716 |
|
ORDER BY |
1717 |
|
signataire_arrete.prenom, |
1718 |
|
signataire_arrete.nom", |
1719 |
|
DB_PREFIXE |
1720 |
|
); |
1721 |
|
} |
1722 |
|
|
1723 |
|
/** |
1724 |
|
* Renvoie sous la forme d'un tableau la liste des événements pouvant être ajoutés au dossier |
1725 |
|
* dont l'identifiant a été passé en paramètre dans l'url. |
1726 |
|
* |
1727 |
|
* @return array |
1728 |
|
*/ |
1729 |
|
function get_var_sql_forminc__sql_evenement() { |
1730 |
|
// Récupération du numéro de dossier |
1731 |
|
$dossier = $this->getParameter("idxformulaire") ?? $_GET['idxformulaire']; |
1732 |
|
$this->f->log(__METHOD__, 'dossier: '.var_export($dossier, true)); |
1733 |
|
// Si changement de décision par instructeur commune |
1734 |
|
$filter = ''; |
1735 |
|
if ($this->f->isUserInstructeur() === true |
1736 |
|
// TODO faire autrement car ça instancier le dossier et donc charge ses modules ! |
1737 |
|
&& $this->getDivisionFromDossier($dossier) != $_SESSION["division"] |
1738 |
|
&& $this->isInstrCanChangeDecision($dossier) === true) { |
1739 |
|
$filter = "AND evenement.type IN ('arrete', 'changement_decision')"; |
1740 |
|
} |
1741 |
|
// Récupération du libellé, de l'identifiant des évènement et d'un booléen permettant |
1742 |
|
// de déterminer si il s'agit d'évènements suggérés. |
1743 |
|
$qres = $this->f->get_all_results_from_db_query( |
1744 |
|
sprintf( |
1745 |
|
'SELECT |
1746 |
|
DISTINCT(evenement.evenement), |
1747 |
|
evenement.libelle, |
1748 |
|
-- Si l evenement est suggérés alors il sera lié à la table des événements suggérés du dossier |
1749 |
|
CASE WHEN evenement_suggere_dossier.evenement IS NULL |
1750 |
|
THEN FALSE |
1751 |
|
ELSE TRUE |
1752 |
|
END AS is_suggested |
1753 |
|
FROM |
1754 |
|
-- Jointures permettant de récupérer la liste des évènements compatibles avec le dossier |
1755 |
|
-- selon le type de dossier et l état du dossier. |
1756 |
|
%1$sevenement |
1757 |
|
JOIN %1$slien_dossier_instruction_type_evenement |
1758 |
|
ON evenement.evenement = lien_dossier_instruction_type_evenement.evenement |
1759 |
|
JOIN %1$stransition |
1760 |
|
ON evenement.evenement = transition.evenement |
1761 |
|
JOIN %1$sdossier |
1762 |
|
ON lien_dossier_instruction_type_evenement.dossier_instruction_type = dossier.dossier_instruction_type |
1763 |
|
AND transition.etat = dossier.etat |
1764 |
|
-- Jointures avec une sous requêtes servant à récupérer la liste des évènements suggérés du dossier. |
1765 |
|
LEFT JOIN ( |
1766 |
|
SELECT |
1767 |
|
lien_sig_contrainte_evenement.evenement, |
1768 |
|
dossier.dossier |
1769 |
|
FROM |
1770 |
|
%1$slien_sig_contrainte_evenement |
1771 |
|
JOIN %1$ssig_contrainte |
1772 |
|
ON lien_sig_contrainte_evenement.sig_contrainte = sig_contrainte.sig_contrainte |
1773 |
|
JOIN %1$slien_sig_contrainte_dossier_instruction_type |
1774 |
|
ON sig_contrainte.sig_contrainte = lien_sig_contrainte_dossier_instruction_type.sig_contrainte |
1775 |
|
JOIN %1$slien_sig_contrainte_om_collectivite |
1776 |
|
ON sig_contrainte.sig_contrainte = lien_sig_contrainte_om_collectivite.sig_contrainte |
1777 |
|
JOIN %1$scontrainte |
1778 |
|
ON sig_contrainte.libelle = contrainte.libelle |
1779 |
|
JOIN %1$sdossier_contrainte |
1780 |
|
ON contrainte.contrainte = dossier_contrainte.contrainte |
1781 |
|
JOIN %1$sdossier |
1782 |
|
ON dossier_contrainte.dossier = dossier.dossier |
1783 |
|
AND lien_sig_contrainte_dossier_instruction_type.dossier_instruction_type = dossier.dossier_instruction_type |
1784 |
|
JOIN %1$som_collectivite |
1785 |
|
ON lien_sig_contrainte_om_collectivite.om_collectivite = om_collectivite.om_collectivite |
1786 |
|
AND (dossier.om_collectivite = om_collectivite.om_collectivite |
1787 |
|
OR om_collectivite.niveau = \'2\') |
1788 |
|
) AS evenement_suggere_dossier |
1789 |
|
ON evenement.evenement = evenement_suggere_dossier.evenement |
1790 |
|
AND dossier.dossier = evenement_suggere_dossier.dossier |
1791 |
|
WHERE |
1792 |
|
dossier.dossier = \'%2$s\' |
1793 |
|
%3$s |
1794 |
|
ORDER BY |
1795 |
|
is_suggested DESC, |
1796 |
|
evenement.libelle', |
1797 |
|
DB_PREFIXE, |
1798 |
|
$this->f->db->escapeSimple($dossier), |
1799 |
|
$filter |
1800 |
|
), |
1801 |
|
array( |
1802 |
|
"origin" => __METHOD__ |
1803 |
|
) |
1804 |
|
); |
1805 |
|
return $qres['result']; |
1806 |
|
} |
1807 |
|
|
1808 |
|
/** |
1809 |
|
* Récupère un tableau contenant des évènements de la forme : |
1810 |
|
* $events = array( |
1811 |
|
* 1 => array( |
1812 |
|
* 'libelle' => 'evenement_libelle', |
1813 |
|
* 'evenement' => 'identifiant_evenement', |
1814 |
|
* 'is_suggested' => true/false -> booleen indiquant si c'est un événement suggéré |
1815 |
|
* )) |
1816 |
|
* Et le transforme pour pouvoir l'utiliser pour le remplissage d'un select de formulaire. |
1817 |
|
* |
1818 |
|
* Le format de sorti est le suivant : |
1819 |
|
* $select = array( |
1820 |
|
* 0 => array( -> liste des id des événements |
1821 |
|
* '0' => '', |
1822 |
|
* '1' => array( |
1823 |
|
* '0' => array(), -> liste des id des événements suggérés |
1824 |
|
* '1' => array(), -> liste des libelles des événements suggérés |
1825 |
|
* ), |
1826 |
|
* ..., |
1827 |
|
* n => 'id_evenement_n' |
1828 |
|
* ), |
1829 |
|
* 1 => array( |
1830 |
|
* '0' => '__('choisir')." ".__('evenement')', |
1831 |
|
* '1' => '💡 Suggestions', |
1832 |
|
* ..., |
1833 |
|
* 'n' => 'libelle_evenement_n', |
1834 |
|
* ) |
1835 |
|
* ) |
1836 |
|
* |
1837 |
|
* @param array tableau des événements |
1838 |
|
* @return array |
1839 |
|
*/ |
1840 |
|
protected function convert_events_array_to_select_format($events) { |
1841 |
|
// Remplissage du tableau du select en incluant le groupe des instructions suggérées. |
1842 |
|
$contenu = array( |
1843 |
|
0 => array("",), |
1844 |
|
1 => array(__('choisir')." ".__('evenement'),) |
1845 |
|
); |
1846 |
|
|
1847 |
|
if (! empty($events)) { |
1848 |
|
// S'il y a des évènements suggérés extraction de ces événements et mise en place du groupe |
1849 |
|
$suggested_event_group = array_filter($events, function($a) { |
1850 |
|
return $a['is_suggested'] === 't'; |
1851 |
|
}); |
1852 |
|
if (! empty($suggested_event_group)) { |
1853 |
|
// Prépare les données qui permettront d'afficher le groupe des événements |
1854 |
|
// suggérés. |
1855 |
|
$values = array(); |
1856 |
|
$labels = array(); |
1857 |
|
foreach ($suggested_event_group as $index => $suggested_event) { |
1858 |
|
$values[] = $suggested_event['evenement']; |
1859 |
|
$labels[] = $suggested_event['libelle']; |
1860 |
|
// Supprime les évènements suggérés de la liste des évènements |
1861 |
|
unset($events[$index]); |
1862 |
|
} |
1863 |
|
// Remplissage du select pour le groupe |
1864 |
|
$contenu[0][] = array($values, $labels); |
1865 |
|
$contenu[1][] = __('💡 Suggestions'); |
1866 |
|
} |
1867 |
|
|
1868 |
|
// Remplissage du select |
1869 |
|
foreach ($events as $event) { |
1870 |
|
$contenu[0][] = $event['evenement']; |
1871 |
|
$contenu[1][] = $event['libelle']; |
1872 |
|
} |
1873 |
|
} |
1874 |
|
return $contenu; |
1875 |
|
} |
1876 |
|
|
1877 |
|
/** |
1878 |
|
* SETTER_FORM - setSelect. |
1879 |
|
* |
1880 |
|
* @return void |
1881 |
|
*/ |
1882 |
|
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
1883 |
|
//parent::setSelect($form, $maj); |
1884 |
/** |
/** |
1885 |
* On ne surcharge pas la méthode parent car une requête sur la table |
* On ne surcharge pas la méthode parent car une requête sur la table |
1886 |
* dossier est mauvaise pour les performances, car la requête qui |
* dossier est mauvaise pour les performances, car la requête qui |
1888 |
* champs action, avis_decision et etat ne sont pas utilisés comme des |
* champs action, avis_decision et etat ne sont pas utilisés comme des |
1889 |
* select |
* select |
1890 |
*/ |
*/ |
|
if(file_exists ("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc.php")) |
|
|
include ("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc.php"); |
|
|
elseif(file_exists ("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc")) |
|
|
include ("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc"); |
|
|
|
|
1891 |
//// action |
//// action |
1892 |
//$this->init_select($form, $db, $maj, $debug, "action", |
//$this->init_select($form, $this->f->db, $maj, null, "action", |
1893 |
// $sql_action, $sql_action_by_id, false); |
// $sql_action, $sql_action_by_id, false); |
1894 |
|
|
1895 |
//// avis_decision |
//// avis_decision |
1896 |
//$this->init_select($form, $db, $maj, $debug, "avis_decision", |
//$this->init_select($form, $this->f->db, $maj, null, "avis_decision", |
1897 |
// $sql_avis_decision, $sql_avis_decision_by_id, false); |
// $sql_avis_decision, $sql_avis_decision_by_id, false); |
1898 |
|
|
1899 |
//// dossier |
//// dossier |
1900 |
//$this->init_select($form, $db, $maj, $debug, "dossier", |
//$this->init_select($form, $this->f->db, $maj, null, "dossier", |
1901 |
// $sql_dossier, $sql_dossier_by_id, false); |
// $sql_dossier, $sql_dossier_by_id, false); |
1902 |
|
|
1903 |
//// etat |
//// etat |
1904 |
//$this->init_select($form, $db, $maj, $debug, "etat", |
//$this->init_select($form, $this->f->db, $maj, null, "etat", |
1905 |
// $sql_etat, $sql_etat_by_id, false); |
// $sql_etat, $sql_etat_by_id, false); |
1906 |
|
|
1907 |
//// evenement |
//// evenement |
1908 |
//$this->init_select($form, $db, $maj, $debug, "evenement", |
//$this->init_select($form, $this->f->db, $maj, null, "evenement", |
1909 |
// $sql_evenement, $sql_evenement_by_id, false); |
// $sql_evenement, $sql_evenement_by_id, false); |
1910 |
|
|
1911 |
// signataire_arrete |
// signataire_arrete |
1912 |
// si contexte DI |
// si contexte DI |
1913 |
if ($this->getParameter("retourformulaire") == "dossier" |
if ($this->getParameter("retourformulaire") == "dossier" |
1914 |
|| $this->getParameter("retourformulaire") == "dossier_instruction" |
|| $this->f->contexte_dossier_instruction()) { |
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_encours" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_encours" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_clotures" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_clotures" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_mes_infractions" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_toutes_infractions" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_mes_recours" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_tous_recours") { |
|
1915 |
// on recupère les signataires de la multicollectivité et de celle du DI |
// on recupère les signataires de la multicollectivité et de celle du DI |
1916 |
$di = $this->f->get_inst__om_dbform(array( |
$di = $this->f->get_inst__om_dbform(array( |
1917 |
"obj" => "dossier_instruction", |
"obj" => "dossier_instruction", |
1918 |
"idx" => $this->getParameter('idxformulaire'), |
"idx" => $this->getParameter('idxformulaire'), |
1919 |
)); |
)); |
1920 |
$sql_signataire_arrete_by_di = str_replace('<collectivite_di>', $di->getVal("om_collectivite"), $sql_signataire_arrete_by_di); |
$sql_signataire_arrete_by_di = str_replace( |
1921 |
$this->init_select($form, $db, $maj, $debug, "signataire_arrete", |
'<collectivite_di>', |
1922 |
$sql_signataire_arrete_by_di, $sql_signataire_arrete_by_id, true); |
$di->getVal("om_collectivite"), |
1923 |
|
$this->get_var_sql_forminc__sql("signataire_arrete_by_di") |
1924 |
|
); |
1925 |
|
$this->init_select( |
1926 |
|
$form, |
1927 |
|
$this->f->db, |
1928 |
|
$maj, |
1929 |
|
null, |
1930 |
|
"signataire_arrete", |
1931 |
|
$sql_signataire_arrete_by_di, |
1932 |
|
$this->get_var_sql_forminc__sql("signataire_arrete_by_id"), |
1933 |
|
true |
1934 |
|
); |
1935 |
} else { |
} else { |
1936 |
$this->init_select($form, $db, $maj, $debug, "signataire_arrete", |
$this->init_select( |
1937 |
$sql_signataire_arrete, $sql_signataire_arrete_by_id, true); |
$form, |
1938 |
|
$this->f->db, |
1939 |
|
$maj, |
1940 |
|
null, |
1941 |
|
"signataire_arrete", |
1942 |
|
$this->get_var_sql_forminc__sql("signataire_arrete"), |
1943 |
|
$this->get_var_sql_forminc__sql("signataire_arrete_by_id"), |
1944 |
|
true |
1945 |
|
); |
1946 |
} |
} |
1947 |
|
|
1948 |
/** |
/** |
1952 |
* événements disponibles. |
* événements disponibles. |
1953 |
*/ |
*/ |
1954 |
if ($maj == 0) { |
if ($maj == 0) { |
1955 |
// Récupération des événements par une jointure entre la table dossier |
$evenements = $this->get_var_sql_forminc__sql_evenement(); |
1956 |
// et la table transition et la table evenement et la table |
$form->setSelect("evenement", $this->convert_events_array_to_select_format($evenements)); |
|
// lien_dossier_instruction_type_evenement en fonction de l'identifiant |
|
|
// du dossier d'instruction en cours |
|
|
$sql = "SELECT |
|
|
evenement.evenement, |
|
|
evenement.libelle as lib |
|
|
FROM ".DB_PREFIXE."dossier |
|
|
INNER JOIN ".DB_PREFIXE."lien_dossier_instruction_type_evenement |
|
|
ON dossier.dossier_instruction_type=lien_dossier_instruction_type_evenement.dossier_instruction_type |
|
|
INNER JOIN ".DB_PREFIXE."evenement |
|
|
ON evenement.evenement=lien_dossier_instruction_type_evenement.evenement |
|
|
INNER JOIN ".DB_PREFIXE."transition |
|
|
ON evenement.evenement = transition.evenement |
|
|
AND dossier.etat=transition.etat |
|
|
WHERE dossier.dossier='".$this->idxformulaire."' "; |
|
|
|
|
|
// Si changement de décision par instructeur commune |
|
|
if($this->f->isUserInstructeur() === true |
|
|
&& $this->getDivisionFromDossier($this->idxformulaire) != $_SESSION["division"] |
|
|
&& $this->isInstrCanChangeDecision($this->idxformulaire) === true) { |
|
|
$sql .= "AND evenement.type IN ('arrete', 'changement_decision') "; |
|
|
} |
|
|
$sql .= "ORDER BY evenement.libelle, evenement.action"; |
|
|
$res = $db->query($sql); |
|
|
$this->addToLog("setSelect(): db->query(\"".$sql."\");", VERBOSE_MODE); |
|
|
if (database::isError($res)) { |
|
|
die($res->getMessage()); |
|
|
} |
|
|
// Remplissage du tableau du select |
|
|
$contenu = array( |
|
|
0 => array("",), |
|
|
1 => array(_('choisir')." "._('evenement'),) |
|
|
); |
|
|
while ($row=& $res->fetchRow()) { |
|
|
$contenu[0][] = $row[0]; |
|
|
$contenu[1][] = $row[1]; |
|
|
} |
|
|
$form->setSelect("evenement", $contenu); |
|
|
|
|
1957 |
} else { |
} else { |
1958 |
$sql = "SELECT |
// Instanciation de l'événement pour récupérer son libellé |
1959 |
evenement.libelle as lib |
$evenement = $this->f->get_inst__om_dbform(array( |
1960 |
FROM ".DB_PREFIXE."evenement |
"obj" => "evenement", |
1961 |
WHERE evenement.evenement=".$this->getVal("evenement").""; |
"idx" => $this->getVal("evenement"), |
1962 |
$res = $db->getone($sql); |
)); |
1963 |
$this->addToLog("setSelect(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
|
|
if (database::isError($res)) { |
|
|
die($res->getMessage()); |
|
|
} |
|
|
// |
|
1964 |
$contenu = array( |
$contenu = array( |
1965 |
0 => array($this->getVal("evenement"),), |
0 => array($this->getVal("evenement"),), |
1966 |
1 => array($res,) |
1 => array($evenement->getVal('libelle'),) |
1967 |
); |
); |
1968 |
$form->setSelect("evenement", $contenu); |
$form->setSelect("evenement", $contenu); |
1969 |
} |
} |
2001 |
1 => array(_('Rédaction par compléments'), _('Rédaction libre'), ), |
1 => array(_('Rédaction par compléments'), _('Rédaction libre'), ), |
2002 |
); |
); |
2003 |
$form->setSelect('flag_edition_integrale', $content); |
$form->setSelect('flag_edition_integrale', $content); |
2004 |
|
|
2005 |
|
$contenu = array(); |
2006 |
|
foreach(array('waiting', 'in_progress', 'canceled', 'expired', 'finished') as $value) { |
2007 |
|
$contenu[0][] = $value; |
2008 |
|
$contenu[1][] = $this->get_trad_for_statut($value); |
2009 |
|
} |
2010 |
|
$form->setSelect('statut_signature', $contenu); |
2011 |
|
|
2012 |
|
|
2013 |
|
if ($maj == 401) { |
2014 |
|
$idx = $this->getParameter("idx"); |
2015 |
|
$dossier = $this->getParameter("idxformulaire"); |
2016 |
|
if ( strpos($idx, 'STORAGE_') !== FALSE) { |
2017 |
|
$idx = substr($idx, 8); |
2018 |
|
$model = 'storage'; |
2019 |
|
$champ = 'uid'; |
2020 |
|
$object = $this->f->get_inst__om_dbform(array( |
2021 |
|
"obj" => $model, |
2022 |
|
"idx" => $idx, |
2023 |
|
)); |
2024 |
|
|
2025 |
|
$file = $this->f->storage->get($object->getVal($champ)); |
2026 |
|
$label = $file['metadata']['filename']; |
2027 |
|
$href =sprintf( |
2028 |
|
'../app/index.php?module=form&snippet=file&obj=storage&champ=uid&id=%1$s', |
2029 |
|
$idx |
2030 |
|
); |
2031 |
|
$this->addToLog(__METHOD__."(): file['metadata']['filename'] = ".$file['metadata']['filename']." ", DEBUG_MODE); |
2032 |
|
$this->val['preview_edition'] = ''; |
2033 |
|
}else{ |
2034 |
|
$label ='instruction_'.$this->getVal($this->clePrimaire); |
2035 |
|
$href =sprintf( |
2036 |
|
'../app/index.php?module=form&snippet=file&obj=instruction&champ=om_fichier_instruction&id=%1$s', |
2037 |
|
$this->getVal($this->clePrimaire) |
2038 |
|
); |
2039 |
|
$file = $this->f->storage->get($this->getVal('om_fichier_instruction')); |
2040 |
|
} |
2041 |
|
|
2042 |
|
$form->setSelect('preview_edition', array( |
2043 |
|
'base64' => base64_encode($file['file_content']), |
2044 |
|
'mimetype' => $file['metadata']['mimetype'], |
2045 |
|
'label' => $label, |
2046 |
|
'href' => $href |
2047 |
|
)); |
2048 |
|
} |
2049 |
} |
} |
2050 |
|
|
2051 |
function cleSecondaire($id, &$db = null, $val = array(), $DEBUG = null) { |
function cleSecondaire($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
2052 |
// |
// |
2053 |
parent::cleSecondaire($id, $db, $val, $DEBUG); |
// Vérifie uniquementla cle secondaire : demande |
2054 |
|
$this->rechercheTable($this->f->db, "demande", "instruction_recepisse", $id); |
2055 |
|
|
2056 |
$id = $this->getVal($this->clePrimaire); |
$id = $this->getVal($this->clePrimaire); |
2057 |
|
|
|
|
|
2058 |
//Requête de vérification que cet événement d'instruction n'est pas lié |
//Requête de vérification que cet événement d'instruction n'est pas lié |
2059 |
//à la création d'un dossier d'instruction |
//à la création d'un dossier d'instruction |
2060 |
$sql = "SELECT demande_type.dossier_instruction_type |
$qres = $this->f->get_one_result_from_db_query( |
2061 |
FROM ".DB_PREFIXE."demande_type |
sprintf( |
2062 |
LEFT JOIN ".DB_PREFIXE."demande |
'SELECT |
2063 |
ON demande.demande_type = demande_type.demande_type |
demande_type.dossier_instruction_type |
2064 |
WHERE demande.instruction_recepisse = ".$id; |
FROM |
2065 |
$res = $this->db->getOne($sql); |
%1$sdemande_type |
2066 |
$this->addToLog("cleSecondaire(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
LEFT JOIN %1$sdemande |
2067 |
if (database::isError($res)) { |
ON demande.demande_type = demande_type.demande_type |
2068 |
die($res->getMessage()); |
WHERE |
2069 |
} |
demande.instruction_recepisse = \'%2$d\'', |
2070 |
|
DB_PREFIXE, |
2071 |
|
intval($id) |
2072 |
|
), |
2073 |
|
array( |
2074 |
|
"origin" => __METHOD__, |
2075 |
|
) |
2076 |
|
); |
2077 |
|
|
2078 |
// Aucune clé secondaire n'a été trouvée ou c'est un événement sans |
// Aucune clé secondaire n'a été trouvée ou c'est un événement sans |
2079 |
//création de dossier d'instruction, l'événement d'instruction peut être |
//création de dossier d'instruction, l'événement d'instruction peut être |
2080 |
//supprimé |
//supprimé |
2081 |
if ( $this->correct !== false || $res == null || $res == ""){ |
if ( $this->correct !== false || $qres['result'] == null || $qres['result'] == ""){ |
|
|
|
2082 |
// Requête de vérification que cet événement d'instruction est lié |
// Requête de vérification que cet événement d'instruction est lié |
2083 |
// à une demande |
// à une demande |
2084 |
$sql = "SELECT demande |
$qres = $this->f->get_one_result_from_db_query( |
2085 |
FROM ".DB_PREFIXE."demande |
sprintf( |
2086 |
WHERE instruction_recepisse = ".$id; |
'SELECT |
2087 |
$res = $this->db->getOne($sql); |
demande |
2088 |
$this->addToLog("cleSecondaire(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
FROM |
2089 |
if (database::isError($res)) { |
%1$sdemande |
2090 |
die($res->getMessage()); |
WHERE |
2091 |
} |
instruction_recepisse = \'%2$d\'', |
2092 |
|
DB_PREFIXE, |
2093 |
|
intval($id) |
2094 |
|
), |
2095 |
|
array( |
2096 |
|
"origin" => __METHOD__, |
2097 |
|
) |
2098 |
|
); |
2099 |
|
|
2100 |
//Si c'est un événement d'instruction lié à une demande |
//Si c'est un événement d'instruction lié à une demande |
2101 |
if ($res != null || $res != ""){ |
if ($qres['result'] != null || $qres['result'] != ""){ |
2102 |
$demande = $this->f->get_inst__om_dbform(array( |
$demande = $this->f->get_inst__om_dbform(array( |
2103 |
"obj" => "demande", |
"obj" => "demande", |
2104 |
"idx" => $res, |
"idx" => $qres['result'], |
2105 |
)); |
)); |
2106 |
|
|
2107 |
//On met à jour la demande en supprimant la liaison vers |
//On met à jour la demande en supprimant la liaison vers |
2108 |
//l'événement d'instruction |
//l'événement d'instruction |
2109 |
$demande->setParameter("maj", 1); |
$demande->setParameter("maj", 1); |
2110 |
$valF = array(); |
$valF = array(); |
2113 |
} |
} |
2114 |
$valF['date_demande']=$demande->dateDBToForm($valF['date_demande']); |
$valF['date_demande']=$demande->dateDBToForm($valF['date_demande']); |
2115 |
$valF['instruction_recepisse']=NULL; |
$valF['instruction_recepisse']=NULL; |
2116 |
$ret = $demande->modifier($valF, $this->db, DEBUG); |
$ret = $demande->modifier($valF); |
2117 |
} |
} |
2118 |
|
|
2119 |
/** |
/** |
2120 |
* Vérification que l'élément supprimé est le dernier pour pouvoir |
* Vérification que l'élément supprimé est le dernier pour pouvoir |
2121 |
* remodifier les données de manière itérative. |
* remodifier les données de manière itérative. |
2122 |
*/ |
*/ |
2123 |
// Initialisation |
$qres = $this->f->get_one_result_from_db_query( |
2124 |
$dernierevenement = ""; |
sprintf( |
2125 |
// Récupération du dernier élément de la table d'instruction qui |
'SELECT |
2126 |
// concerne le dossier en cours |
max(instruction) |
2127 |
$sql = "SELECT max(instruction) |
FROM |
2128 |
FROM ".DB_PREFIXE."instruction |
%1$sinstruction |
2129 |
WHERE dossier ='".$this->idxformulaire."'"; |
WHERE |
2130 |
$dernierevenement = $db->getOne($sql); |
dossier = \'%2$s\'', |
2131 |
$this->addToLog("setSelect(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
DB_PREFIXE, |
2132 |
if (database::isError($dernierevenement)) { |
$this->f->db->escapeSimple($this->getParameter("idxformulaire")) |
2133 |
die($dernierevenement->getMessage()); |
), |
2134 |
} |
array( |
2135 |
|
"origin" => __METHOD__, |
2136 |
|
) |
2137 |
|
); |
2138 |
|
|
2139 |
// Si on se trouve effectivement sur le dernier evenement d'instruction |
// Si on se trouve effectivement sur le dernier evenement d'instruction |
2140 |
if ($dernierevenement == $id) { |
// alors on valide la suppression sinon on l'annule |
2141 |
|
$this->correct = false; |
2142 |
|
$message = __("Seul le dernier evenement d'instruction peut etre supprime."); |
2143 |
|
if ($qres['result'] == $id) { |
2144 |
// Alors on valide la suppression |
// Alors on valide la suppression |
2145 |
$this->correct = true; |
$this->correct = true; |
2146 |
$this->addToMessage(_('Destruction_chronologique')); |
$message = __('Destruction_chronologique'); |
|
} else { |
|
|
// Alors on annule la suppression |
|
|
$this->correct = false; |
|
|
$this->addToMessage(_("Seul le dernier evenement d'instruction peut etre supprime.")); |
|
2147 |
} |
} |
2148 |
|
$this->addToMessage($message); |
2149 |
} |
} |
2150 |
} |
} |
2151 |
|
|
2157 |
|
|
2158 |
//Si le retourformulaire est "dossier_instruction" |
//Si le retourformulaire est "dossier_instruction" |
2159 |
if ($this->getParameter("retourformulaire") == "dossier" |
if ($this->getParameter("retourformulaire") == "dossier" |
2160 |
|| $this->getParameter("retourformulaire") == "dossier_instruction" |
|| $this->f->contexte_dossier_instruction()) { |
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_encours" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_encours" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_clotures" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_clotures" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_mes_infractions" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_toutes_infractions" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_mes_recours" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_tous_recours") { |
|
2161 |
|
|
2162 |
// Vérification de la possibilité de modifier les dates si déjà éditées |
// Vérification de la possibilité de modifier les dates si déjà éditées |
2163 |
if($this->valF[$champ] != "" AND !$this->f->user_is_admin) { |
if($this->valF[$champ] != "" AND !$this->f->user_is_admin) { |
2164 |
// si l'utilisateur n'est pas un admin |
// si l'utilisateur n'est pas un admin |
2165 |
if($this->getVal($champ) != "" AND $this->getVal($champ) != $this->valF[$champ]) { |
if($this->getVal($champ) != "" AND $this->getVal($champ) != $this->valF[$champ]) { |
2166 |
$this->correct = false; |
|
2167 |
$this->addToMessage(_("Les dates de suivis ne peuvent etre modifiees")); |
// si le champ concerné est 'date_envoi_signature' |
2168 |
|
// et que le statut du parapheur est 'expired' |
2169 |
|
// alors on autorise le changement de la date |
2170 |
|
// pour tous les autres cas, on ne peut modifier la date |
2171 |
|
if ($champ !== 'date_envoi_signature' || $this->getVal('statut_signature') !== 'expired') { |
2172 |
|
$this->correct = false; |
2173 |
|
$this->addToMessage(_("Les dates de suivis ne peuvent etre modifiees")); |
2174 |
|
} |
2175 |
} |
} |
2176 |
} |
} |
2177 |
} |
} |
2180 |
return true; |
return true; |
2181 |
} |
} |
2182 |
|
|
2183 |
/*Met des valeurs par défaut dans certains des sous-formulaire*/ |
/** |
2184 |
function setValsousformulaire(&$form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire, &$db = null, $DEBUG = null) { |
* SETTER_FORM - setValsousformulaire (setVal). |
2185 |
|
* |
2186 |
|
* @return void |
2187 |
|
*/ |
2188 |
|
function setValsousformulaire(&$form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire, &$dnu1 = null, $dnu2 = null) { |
2189 |
|
$data = array('form' => &$form, 'maj' => &$maj, 'validation' => &$validation, 'idxformulaire' => &$idxformulaire, 'retourformulaire' => &$retourformulaire, 'typeformulaire' => &$typeformulaire); |
2190 |
|
$this->f->module_manager->run_hooks('setValsousformulaire_pre', $this, $data); |
2191 |
|
|
2192 |
|
// parent::setValsousformulaire($form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire); |
2193 |
|
// |
2194 |
|
$this->retourformulaire = $retourformulaire; |
2195 |
// |
// |
|
$this->retourformulaire=$retourformulaire; |
|
|
$this->idxformulaire=$idxformulaire; |
|
|
// Ajout |
|
2196 |
if ($maj == 0) { |
if ($maj == 0) { |
2197 |
$form->setVal("destinataire", $idxformulaire); |
$form->setVal("destinataire", $this->getParameter("idxformulaire")); |
2198 |
$form->setVal("dossier", $idxformulaire); |
$form->setVal("dossier", $this->getParameter("idxformulaire")); |
2199 |
|
} |
2200 |
|
|
2201 |
|
// Si l'instruction a été envoyé au contrôle de légalité et que la |
2202 |
|
// tâche envoi_cl lié n'a pas encore été traité il faut indiquer à |
2203 |
|
// l'utilisateur que l'envoi au cl est en cours de traitement. |
2204 |
|
if ($this->is_sent_to_cl() === true |
2205 |
|
&& empty($this->getVal('date_envoi_controle_legalite')) |
2206 |
|
&& $maj == 3) { |
2207 |
|
$form->setVal("date_envoi_controle_legalite", __("En cours de traitement.")); |
2208 |
} |
} |
2209 |
// |
// |
2210 |
$this->set_form_default_values($form, $maj, $validation); |
$this->set_form_default_values($form, $maj, $validation); |
2211 |
|
|
2212 |
|
$data = array('form' => &$form, 'maj' => &$maj, 'validation' => &$validation, 'idxformulaire' => &$idxformulaire, 'retourformulaire' => &$retourformulaire, 'typeformulaire' => &$typeformulaire); |
2213 |
|
$this->f->module_manager->run_hooks('setValsousformulaire_post', $this, $data); |
2214 |
} |
} |
2215 |
|
|
2216 |
/** |
/** |
2217 |
* Permet de pré-remplir les valeurs des formulaires. |
* SETTER_FORM - set_form_default_values (setVal). |
2218 |
* |
* |
2219 |
* @param [object] $form formulaire |
* @return void |
|
* @param [integer] $maj mode |
|
|
* @param [integer] $validation validation |
|
2220 |
*/ |
*/ |
2221 |
function set_form_default_values(&$form, $maj, $validation) { |
function set_form_default_values(&$form, $maj, $validation) { |
2222 |
|
$data = array('form' => &$form, 'maj' => &$maj, 'validation' => &$validation); |
2223 |
|
$this->f->module_manager->run_hooks('set_form_default_values_pre', $this, $data); |
2224 |
|
|
|
// Ajout |
|
2225 |
if ($maj == 0) { |
if ($maj == 0) { |
|
if(file_exists ("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc.php")) |
|
|
include ("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc.php"); |
|
|
elseif(file_exists ("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc")) |
|
|
include ("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc"); |
|
2226 |
// si contexte DI |
// si contexte DI |
2227 |
if ($this->getParameter("retourformulaire") == "dossier" |
if ($this->getParameter("retourformulaire") == "dossier" |
2228 |
|| $this->getParameter("retourformulaire") == "dossier_instruction" |
|| $this->f->contexte_dossier_instruction()) { |
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_encours" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_encours" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_clotures" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_clotures" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_mes_infractions" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_toutes_infractions" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_mes_recours" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_tous_recours") { |
|
2229 |
// on recupère les signataires de la multicollectivité et de celle du DI |
// on recupère les signataires de la multicollectivité et de celle du DI |
2230 |
$di = $this->f->get_inst__om_dbform(array( |
$di = $this->f->get_inst__om_dbform(array( |
2231 |
"obj" => "dossier_instruction", |
"obj" => "dossier_instruction", |
2232 |
"idx" => $this->getParameter('idxformulaire'), |
"idx" => $this->getParameter("idxformulaire"), |
2233 |
)); |
)); |
2234 |
$sql = str_replace('<collectivite_di>', $di->getVal("om_collectivite"), $sql_signataire_arrete_defaut_by_di); |
$sql = str_replace( |
2235 |
|
"<collectivite_di>", |
2236 |
|
$di->getVal("om_collectivite"), |
2237 |
|
$this->get_var_sql_forminc__sql("signataire_arrete_defaut_by_di") |
2238 |
|
); |
2239 |
} else { |
} else { |
2240 |
$sql = $sql_signataire_arrete_defaut; |
$sql = $this->get_var_sql_forminc__sql("signataire_arrete_defaut"); |
|
} |
|
|
// Date du jour |
|
|
$form->setVal("date_evenement", date('Y-m-d')); |
|
|
|
|
|
// Exécution de la requête |
|
|
$res = $this->f->db->query($sql); |
|
|
$this->f->addToLog("setVal(): db->query(\"".$sql."\");", VERBOSE_MODE); |
|
|
if ( database::isError($res)){ |
|
|
die(); |
|
2241 |
} |
} |
|
|
|
|
$row = $res->fetchrow(DB_FETCHMODE_ASSOC); |
|
2242 |
|
|
2243 |
if (isset($row['signataire_arrete']) && is_numeric($row['signataire_arrete'])){ |
$qres = $this->f->get_all_results_from_db_query($sql, array( |
2244 |
$form->setVal("signataire_arrete",$row['signataire_arrete']); |
"origin" => __METHOD__)); |
2245 |
|
$row = array_shift($qres['result']); |
2246 |
|
if (isset($row["signataire_arrete"]) |
2247 |
|
&& is_numeric($row["signataire_arrete"])) { |
2248 |
|
// |
2249 |
|
$form->setVal("signataire_arrete", $row["signataire_arrete"]); |
2250 |
} |
} |
2251 |
|
// Date du jour |
2252 |
|
$form->setVal("date_evenement", date("Y-m-d")); |
2253 |
} |
} |
2254 |
|
// |
|
// Ajout et modification |
|
2255 |
if ($maj == 0 || $maj == 1 || $maj == 125) { |
if ($maj == 0 || $maj == 1 || $maj == 125) { |
2256 |
$form->setVal("bible_auto","bible_auto()"); |
$form->setVal("bible_auto", "bible_auto()"); |
2257 |
$form->setVal("bible","bible(1)"); |
$form->setVal("bible", "bible(1)"); |
2258 |
$form->setVal("bible2","bible(2)"); |
$form->setVal("bible2", "bible(2)"); |
2259 |
$form->setVal("bible3","bible(3)"); |
$form->setVal("bible3", "bible(3)"); |
2260 |
$form->setVal("bible4","bible(4)"); |
$form->setVal("bible4", "bible(4)"); |
2261 |
} |
} |
2262 |
|
// TODO à faire autrement car ça génère une requête à chaque fois, plus l'instanciation du dossier d'instruction et donc de ses modules ! |
|
// Récupère la collectivité du dossier d'instruction |
|
2263 |
$collectivite_di = $this->get_dossier_instruction_om_collectivite(); |
$collectivite_di = $this->get_dossier_instruction_om_collectivite(); |
2264 |
|
if ($maj == 1 |
2265 |
// Modification |
&& $this->f->is_option_preview_pdf_enabled($collectivite_di) === true |
|
if ($maj == 1 && $this->f->is_option_preview_pdf_enabled($collectivite_di) === true |
|
2266 |
&& $this->has_an_edition() === true) { |
&& $this->has_an_edition() === true) { |
2267 |
$form->setVal("live_preview",$this->getVal($this->clePrimaire)); |
// |
2268 |
$form->setVal("btn_refresh","reload_pdf_viewer()"); |
$form->setVal("live_preview", $this->getVal($this->clePrimaire)); |
2269 |
$form->setVal("btn_preview","show_instr_preview()"); |
$form->setVal("btn_refresh", "reload_pdf_viewer()"); |
2270 |
$form->setVal("btn_redaction","show_instr_redaction()"); |
$form->setVal("btn_preview", "show_instr_preview()"); |
2271 |
|
$form->setVal("btn_redaction", "show_instr_redaction()"); |
2272 |
} |
} |
|
} |
|
2273 |
|
|
2274 |
|
// Gestion de l'affichage des suivis de notification des demandeurs, des services, des tiers et |
2275 |
|
// des communes |
2276 |
|
if ($maj == 3) { |
2277 |
|
if ($this->can_display_notification_demandeur()) { |
2278 |
|
$typeNotification = array( |
2279 |
|
'notification_recepisse', |
2280 |
|
'notification_instruction', |
2281 |
|
'notification_decision', |
2282 |
|
); |
2283 |
|
$form->setVal("suivi_notification", $this->get_json_suivi_notification($typeNotification, true)); |
2284 |
|
} |
2285 |
|
if ($this->can_display_notification_service()) { |
2286 |
|
$form->setVal("suivi_notification_service", $this->get_json_suivi_notification(array('notification_service_consulte'))); |
2287 |
|
} |
2288 |
|
if ($this->can_display_notification_tiers()) { |
2289 |
|
$form->setVal("suivi_notification_tiers", $this->get_json_suivi_notification(array('notification_tiers_consulte'))); |
2290 |
|
} |
2291 |
|
if ($this->can_display_notification_commune()) { |
2292 |
|
$form->setVal("suivi_notification_commune", $this->get_json_suivi_notification(array('notification_depot_demat', 'notification_commune'))); |
2293 |
|
} |
2294 |
|
if ($this->getVal('flag_edition_integrale') == 't') { |
2295 |
|
$message = __("Aucun contenu à afficher."); |
2296 |
|
if (empty($this->getVal('titre_om_htmletat'))) { |
2297 |
|
$form->setVal("titre_om_htmletat", $message); |
2298 |
|
} |
2299 |
|
if (empty($this->getVal('corps_om_htmletatex'))) { |
2300 |
|
$form->setVal("corps_om_htmletatex", $message); |
2301 |
|
} |
2302 |
|
} |
2303 |
|
} |
2304 |
|
$data = array('form' => &$form, 'maj' => &$maj, 'validation' => &$validation); |
2305 |
|
$this->f->module_manager->run_hooks('set_form_default_values_post', $this, $data); |
2306 |
|
} |
2307 |
|
|
2308 |
function setLayout(&$form, $maj){ |
function setLayout(&$form, $maj){ |
2309 |
|
$data = array('form' => &$form, 'maj' => &$maj); |
2310 |
|
$this->f->module_manager->run_hooks('setLayout_pre', $this, $data); |
2311 |
|
|
2312 |
$form->setBloc('evenement','D',"","sousform-instruction-action-".$maj); |
$form->setBloc('evenement','D',"","sousform-instruction-action-".$maj); |
2313 |
|
|
2314 |
$form->setFieldset('evenement','D',_('Evenement')); |
$form->setFieldset('evenement','D',_('Evenement')); |
2315 |
$form->setFieldset('om_final_instruction_utilisateur','F',''); |
$form->setFieldset('om_final_instruction_utilisateur','F',''); |
2316 |
|
|
2317 |
$form->setBloc('om_final_instruction_utilisateur','F'); |
$form->setBloc('om_final_instruction_utilisateur','F'); |
2318 |
|
// Idem que pour le layout de la synthèse des DI, on est obligé de "casser" le setBloc en utilisant que la fin |
2319 |
|
// afin de bypasser le fait de ne pas avoir le form-content et le portlet dans le meme container |
2320 |
|
$form->setBloc('om_final_instruction_utilisateur','F'); |
2321 |
|
$form->setBloc('parapheur_lien_page_signature','D'); |
2322 |
|
|
2323 |
$form->setBloc('date_finalisation_courrier','D',"",""); |
$form->setBloc('date_finalisation_courrier','D',"",""); |
2324 |
|
|
2325 |
$form->setFieldset('date_finalisation_courrier','D',_('Dates')); |
$form->setFieldset('date_finalisation_courrier','D',_('Dates'),"instruction--suivi-dates"); |
2326 |
$form->setBloc('date_finalisation_courrier','D',"","col_6"); |
$form->setBloc('date_finalisation_courrier','D'); |
2327 |
$form->setBloc('date_envoi_controle_legalite','F'); |
$form->setBloc('date_envoi_rar','F'); |
2328 |
|
|
2329 |
$form->setBloc('date_retour_signature','D',"","col_6"); |
$form->setBloc('date_retour_rar','D'); |
2330 |
$form->setBloc('date_retour_controle_legalite','F'); |
$form->setBloc('date_retour_controle_legalite','F'); |
2331 |
$form->setFieldset('date_retour_controle_legalite','F',''); |
$form->setFieldset('date_retour_controle_legalite','F',''); |
2332 |
|
|
2333 |
$form->setBloc('date_retour_controle_legalite','F'); |
$form->setBloc('date_retour_controle_legalite','F'); |
2334 |
|
|
2335 |
|
$form->setBloc('statut_signature','D'); |
2336 |
|
$form->setFieldset('statut_signature','D','Suivi Parapheur'); |
2337 |
|
$form->setBloc('commentaire_signature','F'); |
2338 |
|
$form->setBloc('historique_signature','D'); |
2339 |
|
$form->setFieldset('historique_signature', 'DF', __("Historique"), "collapsible, startClosed"); |
2340 |
|
$form->setBloc('historique_signature','F'); |
2341 |
|
$form->setFieldset('historique_signature','F'); |
2342 |
|
|
2343 |
|
$form->setFieldset('suivi_notification', 'D', __("Suivi notification"), "collapsible"); |
2344 |
|
$form->setFieldset('suivi_notification','F'); |
2345 |
|
$form->setFieldset('suivi_notification_service', 'D', __("Suivi notification service"), "collapsible"); |
2346 |
|
$form->setFieldset('suivi_notification_service','F'); |
2347 |
|
$form->setFieldset('suivi_notification_tiers', 'D', __("Suivi notification tiers"), "collapsible"); |
2348 |
|
$form->setFieldset('suivi_notification_tiers','F'); |
2349 |
|
$form->setFieldset('suivi_notification_commune', 'D', __("Suivi notification commune"), "collapsible"); |
2350 |
|
$form->setFieldset('suivi_notification_commune','F'); |
2351 |
|
|
2352 |
if ($maj == 1) { |
if ($maj == 1) { |
2353 |
// Récupère la collectivité du dossier d'instruction |
// Récupère la collectivité du dossier d'instruction |
2354 |
$collectivite_di = $this->get_dossier_instruction_om_collectivite(); |
$collectivite_di = $this->get_dossier_instruction_om_collectivite(); |
2407 |
$form->setFieldset('corps_om_htmletatex','DF',_('Corps')); |
$form->setFieldset('corps_om_htmletatex','DF',_('Corps')); |
2408 |
$form->setBloc('corps_om_htmletatex','F'); |
$form->setBloc('corps_om_htmletatex','F'); |
2409 |
} |
} |
2410 |
|
$data = array('form' => &$form, 'maj' => &$maj); |
2411 |
|
$this->f->module_manager->run_hooks('setLayout_post', $this, $data); |
2412 |
} |
} |
2413 |
|
|
2414 |
function setLib(&$form, $maj) { |
function setLib(&$form, $maj) { |
2415 |
|
$data = array('form' => &$form, 'maj' => &$maj); |
2416 |
|
$this->f->module_manager->run_hooks('setLib_pre', $this, $data); |
2417 |
// |
// |
2418 |
parent::setLib($form, $maj); |
parent::setLib($form, $maj); |
2419 |
// |
// |
2427 |
$form->setLib('btn_redaction', ""); |
$form->setLib('btn_redaction', ""); |
2428 |
$form->setLib('live_preview', ""); |
$form->setLib('live_preview', ""); |
2429 |
$form->setLib('om_final_instruction_utilisateur', _("finalise par")); |
$form->setLib('om_final_instruction_utilisateur', _("finalise par")); |
2430 |
|
$form->setLib('date_envoi_rar', __("date_envoi_ar")); |
2431 |
|
$form->setLib('date_retour_rar', __("date_notification")); |
2432 |
|
$form->setLib('statut_signature', __("statut")); |
2433 |
|
$form->setLib('commentaire_signature', __("commentaire")); |
2434 |
|
$form->setLib('historique_signature', ''); |
2435 |
|
$form->setLib('suivi_notification', ''); |
2436 |
|
$form->setLib('suivi_notification_service', ''); |
2437 |
|
$form->setLib('suivi_notification_tiers', ''); |
2438 |
|
$form->setLib('suivi_notification_commune', ''); |
2439 |
|
$form->setLib('preview_edition', ""); |
2440 |
|
|
2441 |
// Ajout d'une infobulle d'aide lorsque le formulaire est en mode |
// Ajout d'une infobulle d'aide lorsque le formulaire est en mode |
2442 |
// ajout et que l'option de rédaction libre est activée sur la |
// ajout et que l'option de rédaction libre est activée sur la |
2462 |
$form->setLib('date_evenement', sprintf($help_text_template, _('date_evenement'), $help_text)); |
$form->setLib('date_evenement', sprintf($help_text_template, _('date_evenement'), $help_text)); |
2463 |
$form->setLib('signataire_arrete', sprintf($help_text_template, _('signataire_arrete'), $help_text)); |
$form->setLib('signataire_arrete', sprintf($help_text_template, _('signataire_arrete'), $help_text)); |
2464 |
} |
} |
2465 |
|
$data = array('form' => &$form, 'maj' => &$maj); |
2466 |
|
$this->f->module_manager->run_hooks('setLib_post', $this, $data); |
2467 |
|
} |
2468 |
|
|
2469 |
|
/** |
2470 |
|
* Surcharge om_dbform::set_form_specificity() |
2471 |
|
* |
2472 |
|
* Traitements spécifiques lié à l'affichage des formulaires. |
2473 |
|
* Les traitements gérés ici sont les suivants : |
2474 |
|
* - Affichage d'un message d'erreur si la lettretype de l'évènement n'a pas |
2475 |
|
* pu être récupérée. |
2476 |
|
* - Affichage d'un message d'information à l'attention de l'utilisateur si |
2477 |
|
* la notification est activée mais qu'elle n'est pas possible à cause du |
2478 |
|
* paramètrage. |
2479 |
|
* |
2480 |
|
* @param formulaire $form Instance formulaire. |
2481 |
|
* @param string $maj |
2482 |
|
* |
2483 |
|
* @return void |
2484 |
|
*/ |
2485 |
|
function set_form_specificity(&$form, $maj) { |
2486 |
|
parent::set_form_specificity($form, $maj); |
2487 |
|
|
2488 |
|
// En consultation, vérifie si une lettretype est associée à l'instruction et a pu être récupérée. |
2489 |
|
// Si ce n'est pas le cas affiche un message d'erreur. |
2490 |
|
if ((! empty($maj) && $maj == 3)) { |
2491 |
|
if (! empty($this->getVal('lettretype'))) { |
2492 |
|
|
2493 |
|
$om_edition = $this->f->get_inst__om_edition(); |
2494 |
|
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
2495 |
|
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
2496 |
|
$edition = $om_edition->get_edition_from_collectivite('om_lettretype', $this->getVal("lettretype"), $collectivite['om_collectivite_idx']); |
2497 |
|
|
2498 |
|
if (empty($edition)) { |
2499 |
|
$this->display_error_message(__("Erreur de paramétrage, le modèle de document n'a pas pu être récupéré. Contactez votre administrateur.")); |
2500 |
|
} |
2501 |
|
} |
2502 |
|
} |
2503 |
|
|
2504 |
|
$this->display_notification_info($maj); |
2505 |
} |
} |
2506 |
|
|
2507 |
function triggerajouter($id, &$db = null, $val = array(), $DEBUG = null) { |
/** |
2508 |
|
* En consultation, pour les dossiers qui n'ont pas été transmis par le portail |
2509 |
|
* citoyen, si la notification des demandeurs est activée sur l'évenement |
2510 |
|
* d'instruction et que le paramétrage du demandeur principal n'est pas |
2511 |
|
* correct alors un message a destination de l'instructeur est affiché. |
2512 |
|
* |
2513 |
|
* @param string $maj |
2514 |
|
* |
2515 |
|
* @return void |
2516 |
|
*/ |
2517 |
|
public function display_notification_info($maj) { |
2518 |
|
if ((! empty($maj) && $maj == 3)) { |
2519 |
|
// Si le dossier n'a pas été déposé sur le portail citoyen (ou si |
2520 |
|
// la requête permettant de savoir le type de demande à échouée) et si |
2521 |
|
// la notification se fait par mail vérifie si il y a des erreurs de |
2522 |
|
// paramétrage et si c'est le cas on affiche un message d'information |
2523 |
|
if ($this->dossier_depose_sur_portail() == null || ! $this->dossier_depose_sur_portail()) { |
2524 |
|
$erreurParam = $this->get_info_notification_fail(); |
2525 |
|
// Récupération de l'évenement d'instruction |
2526 |
|
$instEV = $this->get_inst_evenement(); |
2527 |
|
if (! empty($instEV->getVal('notification')) && $erreurParam != array()) { |
2528 |
|
$class = 'text-info ui-state-highlight ui-state-info'; |
2529 |
|
$message = __("La notification n'est pas possible."); |
2530 |
|
$this->f->display_panel_information( |
2531 |
|
$class, |
2532 |
|
$message, |
2533 |
|
$erreurParam, |
2534 |
|
__('Les données suivantes doivent être modifiées'), |
2535 |
|
'erreur_param_notif' |
2536 |
|
); |
2537 |
|
} |
2538 |
|
} |
2539 |
|
} |
2540 |
|
} |
2541 |
|
|
2542 |
|
/** |
2543 |
|
* Méthode permettant d'afficher des messages d'erreur sur les formulaires. |
2544 |
|
*/ |
2545 |
|
public function display_error_message($msg) { |
2546 |
|
$this->correct = false; |
2547 |
|
$this->msg = $msg; |
2548 |
|
} |
2549 |
|
|
2550 |
|
/** |
2551 |
|
* TRIGGER - triggerajouter. |
2552 |
|
* Réalise différents traitements avant d'ajouter l'instruction en base. |
2553 |
|
* |
2554 |
|
* Les traitements réalisés sont les suivant : |
2555 |
|
* - TODO : documenter les traietements existant |
2556 |
|
* - Intégre les bibles pré-chargé aux compléments de l'instruction. |
2557 |
|
* Ce traitement n'est déclenché que si l'on est pas en rédaction libre, et que l'évènement a une lettretype. |
2558 |
|
* |
2559 |
|
* @return boolean |
2560 |
|
*/ |
2561 |
|
function triggerajouter($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
2562 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
2563 |
|
$data = array('val' => &$val, 'id' => $id); |
2564 |
|
$this->f->module_manager->run_hooks('triggerajouter_pre', $this, $data); |
2565 |
/** |
/** |
2566 |
* Le code suivant permet de récupérer des valeurs des tables evenement |
* Le code suivant permet de récupérer des valeurs des tables evenement |
2567 |
* et dossier pour les stocker dans l'instruction : |
* et dossier pour les stocker dans l'instruction : |
2574 |
* - delai_notification |
* - delai_notification |
2575 |
* - lettretype |
* - lettretype |
2576 |
* - autorite_competente |
* - autorite_competente |
2577 |
|
* - pec_metier |
2578 |
* - complement_om_html |
* - complement_om_html |
2579 |
* - complement2_om_html |
* - complement2_om_html |
2580 |
* - complement3_om_html |
* - complement3_om_html |
2597 |
* - avis_decision |
* - avis_decision |
2598 |
*/ |
*/ |
2599 |
// Récupération de tous les paramètres de l'événement sélectionné |
// Récupération de tous les paramètres de l'événement sélectionné |
2600 |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
// TODO : remplacer cette requête par l'instanciation de l'événement |
2601 |
WHERE evenement=".$this->valF['evenement']; |
$qres = $this->f->get_all_results_from_db_query( |
2602 |
$res = $db->query($sql); |
sprintf( |
2603 |
$this->addToLog("triggerajouter(): db->query(\"".$sql."\");", VERBOSE_MODE); |
'SELECT |
2604 |
if (database::isError($res)) { |
* |
2605 |
die($res->getMessage()); |
FROM |
2606 |
} |
%1$sevenement |
2607 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
WHERE |
2608 |
|
evenement = %2$d', |
2609 |
|
DB_PREFIXE, |
2610 |
|
intval($this->valF['evenement']) |
2611 |
|
), |
2612 |
|
array( |
2613 |
|
"origin" => __METHOD__, |
2614 |
|
) |
2615 |
|
); |
2616 |
|
foreach ($qres['result'] as $row) { |
2617 |
// Récupération de l'identifiant de l'action |
// Récupération de l'identifiant de l'action |
2618 |
// si une action est paramétrée dans l'événement |
// si une action est paramétrée dans l'événement |
2619 |
$this->valF['action'] = NULL; |
$this->valF['action'] = NULL; |
2646 |
} |
} |
2647 |
// Récupération de la valeur de la lettre type |
// Récupération de la valeur de la lettre type |
2648 |
$this->valF['lettretype']=$row['lettretype']; |
$this->valF['lettretype']=$row['lettretype']; |
2649 |
|
// Récupération de la valeur de la prise en compte métier |
2650 |
|
// si la prise en compte métier est paramétrée dans l'événement |
2651 |
|
$this->valF['pec_metier'] = NULL; |
2652 |
|
if(isset($row['pec_metier']) === true and empty($row['pec_metier']) === false) { |
2653 |
|
$this->valF['pec_metier'] = $row['pec_metier']; |
2654 |
|
} |
2655 |
} |
} |
2656 |
// Récupération de toutes les valeurs du dossier d'instruction en cours |
// Récupération de toutes les valeurs du dossier d'instruction en cours |
2657 |
$sql = "SELECT * FROM ".DB_PREFIXE."dossier |
// TODO : remplacer cette requête par l'instanciation de l'objet |
2658 |
WHERE dossier='".$this->valF['dossier']."'"; |
$qres = $this->f->get_all_results_from_db_query( |
2659 |
$res = $db->query($sql); |
sprintf( |
2660 |
$this->addToLog("triggerajouter(): db->query(\"".$sql."\");", VERBOSE_MODE); |
'SELECT |
2661 |
if (database::isError($res)) { |
* |
2662 |
die($res->getMessage()); |
FROM |
2663 |
} |
%1$sdossier |
2664 |
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
WHERE |
2665 |
|
dossier = \'%2$s\'', |
2666 |
|
DB_PREFIXE, |
2667 |
|
$this->f->db->escapeSimple($this->valF['dossier']) |
2668 |
|
), |
2669 |
|
array( |
2670 |
|
"origin" => __METHOD__, |
2671 |
|
) |
2672 |
|
); |
2673 |
|
$row = array_shift($qres['result']); |
2674 |
$this->updateArchiveData($row); |
$this->updateArchiveData($row); |
2675 |
|
|
2676 |
// Récupération de la duree de validite du dossier d'autorisation |
// Récupération de la duree de validite du dossier d'autorisation |
2677 |
$sql = "SELECT duree_validite_parametrage |
$qres = $this->f->get_one_result_from_db_query( |
2678 |
FROM ".DB_PREFIXE."dossier_autorisation_type_detaille |
sprintf( |
2679 |
LEFT JOIN ".DB_PREFIXE."dossier_autorisation |
'SELECT |
2680 |
ON dossier_autorisation.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
duree_validite_parametrage |
2681 |
LEFT JOIN ".DB_PREFIXE."dossier |
FROM |
2682 |
ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
%1$sdossier_autorisation_type_detaille |
2683 |
WHERE dossier.dossier='".$this->valF['dossier']."'"; |
LEFT JOIN %1$sdossier_autorisation |
2684 |
$duree_validite_parametrage = $db->getOne($sql); |
ON dossier_autorisation.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
2685 |
$this->addToLog("triggerajouter(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
LEFT JOIN %1$sdossier |
2686 |
database::isError($duree_validite_parametrage); |
ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
2687 |
if ($duree_validite_parametrage != '') { |
WHERE |
2688 |
$this->valF['duree_validite_parametrage']= $duree_validite_parametrage; |
dossier.dossier = \'%2$s\'', |
2689 |
|
DB_PREFIXE, |
2690 |
|
$this->f->db->escapeSimple($this->valF['dossier']) |
2691 |
|
), |
2692 |
|
array( |
2693 |
|
"origin" => __METHOD__, |
2694 |
|
) |
2695 |
|
); |
2696 |
|
|
2697 |
|
if ($qres['result'] != '') { |
2698 |
|
$this->valF['duree_validite_parametrage'] = $qres['result']; |
2699 |
} |
} |
2700 |
|
|
2701 |
// Identifiant du type de courrier |
// Identifiant du type de courrier |
2704 |
// Code barres |
// Code barres |
2705 |
$this->valF["code_barres"] = $idTypeCourrier . $idCourrier; |
$this->valF["code_barres"] = $idTypeCourrier . $idCourrier; |
2706 |
|
|
2707 |
// Si le mode en rédaction intégrale est activé |
// Set dans la propriété valF les valeurs des compléments pour qu'ils soient enregistrés |
2708 |
if (isset($this->valF['flag_edition_integrale']) === true |
// à l'ajout de l'instruction. |
2709 |
&& $this->valF['flag_edition_integrale'] === true) { |
// Le traitement n'est réalisé que si il y a une lettretype et qu'on est pas en rédaction libre |
2710 |
|
if (! empty($this->valF['lettretype'])) { |
2711 |
|
$this->set_precharge_complement($this->valF['evenement'], $this->valF['dossier']); |
2712 |
|
} |
2713 |
|
|
2714 |
// Récupère la collectivite du dossier d'instruction |
$res = true; |
2715 |
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
$data = array('val' => &$val, 'id' => $id, 'result' => &$res); |
2716 |
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
$this->f->module_manager->run_hooks('triggerajouter_post', $this, $data); |
2717 |
// Récupère le corps de la lettre type |
return $res; |
2718 |
$params = array( |
} |
2719 |
"specific" => array( |
|
2720 |
"corps" => array( |
/** |
2721 |
"mode" => "get", |
* Récupère pour chaque champ complementX_om_html le complément correspondant |
2722 |
) |
* et set l'entrée correspondante de valF avec. |
2723 |
), |
* |
2724 |
); |
* Problème potentiel : Le nombre de complément se base sur le champs complement ayant |
2725 |
$result = $this->compute_pdf_output('lettretype', $this->valF['lettretype'], $collectivite, null, $params); |
* l'indice le plus grand visible dans get_var_sql_forminc__champs(). |
2726 |
$this->valF['corps_om_htmletatex'] = $result['pdf_output']; |
* Dans cette fonction on fait donc 15 itérations. Changer le nombre de complément |
2727 |
// Récupère le titre de la lettre type |
* aura donc un impact sur cette méthode. |
2728 |
$params = array( |
* |
2729 |
"specific" => array( |
* @param string dossier : identifiant du dossier de l'instruction |
2730 |
"titre" => array( |
* @param int evenement : identifiant de l'évènement d'instruction |
2731 |
"mode" => "get", |
* |
2732 |
) |
* @return void |
2733 |
), |
*/ |
2734 |
); |
public function set_precharge_complement($evenement, $dossier) { |
2735 |
$result = $this->compute_pdf_output('lettretype', $this->valF['lettretype'], $collectivite, null, $params); |
// Récupération des bibles et chargement dans les compléments |
2736 |
$this->valF['titre_om_htmletat'] = $result['pdf_output']; |
for ($i = 1; $i <= 15; $i++) { |
2737 |
|
// Constitution de l'id du champs. |
2738 |
|
// Pour l'indice 1, l'id est complement_om_html, l'indice n'est pas visible dans ce cas. |
2739 |
|
$field = "complement".($i === 1 ? '' : $i)."_om_html"; |
2740 |
|
// Récupération des compléments correspondant en fonction de l'évènement |
2741 |
|
// et du dossier puis insertion dans la champs voulu |
2742 |
|
$this->valF[$field] = $this->getBible($evenement, $dossier, $i, 'precharge'); |
2743 |
} |
} |
2744 |
} |
} |
2745 |
|
|
2746 |
|
|
2747 |
|
|
2748 |
// Test si une restriction est valide |
/** |
2749 |
// return boolean |
* Test si une restriction est valide. |
2750 |
|
* |
2751 |
|
* @return boolean |
2752 |
|
*/ |
2753 |
function restrictionIsValid($restriction){ |
function restrictionIsValid($restriction){ |
2754 |
if($this->restriction_valid != null) { |
if($this->restriction_valid != null) { |
2755 |
return $this->restriction_valid; |
return $this->restriction_valid; |
2931 |
if(empty($evenement) || !is_numeric($evenement)) { |
if(empty($evenement) || !is_numeric($evenement)) { |
2932 |
return ""; |
return ""; |
2933 |
} |
} |
2934 |
$sql = "SELECT retour |
|
2935 |
FROM ".DB_PREFIXE."evenement |
$evenement = $this->f->get_inst__om_dbform(array( |
2936 |
WHERE evenement = ".$evenement; |
"obj" => "evenement", |
2937 |
$retour = $this->db->getOne($sql); |
"idx" => $evenement, |
2938 |
$this->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE); |
)); |
2939 |
if (database::isError($retour)) { |
|
2940 |
die($retour->getMessage()); |
return $evenement->getVal('retour') == 't'; |
|
} |
|
|
if ($retour == 't') { |
|
|
return true; |
|
|
} else { |
|
|
return false; |
|
|
} |
|
2941 |
} |
} |
2942 |
|
|
2943 |
/** |
/** |
2952 |
return ""; |
return ""; |
2953 |
} |
} |
2954 |
//Récupère la restriction |
//Récupère la restriction |
2955 |
$sql= "SELECT |
$evenement = $this->f->get_inst__om_dbform(array( |
2956 |
restriction |
"obj" => "evenement", |
2957 |
FROM |
"idx" => $evenement, |
2958 |
".DB_PREFIXE."evenement |
)); |
2959 |
WHERE |
|
2960 |
evenement =".$evenement; |
return $evenement->getVal('restriction'); |
|
|
|
|
$restriction = $this->db->getOne($sql); |
|
|
$this->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE); |
|
|
if (database::isError($restriction)) { |
|
|
die($restriction->getMessage()); |
|
|
} |
|
|
return $restriction; |
|
2961 |
} |
} |
2962 |
|
|
2963 |
/** |
/** |
2988 |
|
|
2989 |
|
|
2990 |
/** |
/** |
2991 |
|
* Calcul une regle à partir des données de l'url et affiche son |
2992 |
|
* résultat au format json |
2993 |
|
*/ |
2994 |
|
public function is_date_limite_notification_dossier_depasse() { |
2995 |
|
// Récupération de la date limite |
2996 |
|
$dossier = $this->f->get_inst__om_dbform(array( |
2997 |
|
'obj' => 'dossier', |
2998 |
|
'idx' => $this->getVal('dossier') |
2999 |
|
)); |
3000 |
|
$date_limite = $dossier->getVal('incomplet_notifie') !== 't' ? |
3001 |
|
$dossier->getVal('date_limite') : |
3002 |
|
$dossier->getVal('date_limite_incompletude'); |
3003 |
|
// Ajout d'un jour à la date limite (reglementaire lors de la notification |
3004 |
|
// par demat) |
3005 |
|
$date_limite = $this->f->mois_date($date_limite, "1", "+", "jour"); |
3006 |
|
// Compare la date limite à j+1 et la date du jour |
3007 |
|
// La date du jour est récupérée via la fonction date pour pouvoir comparer |
3008 |
|
// des timestamps de début de journée |
3009 |
|
echo strtotime($date_limite) < strtotime(date("Y-m-d")) ? 'True' : 'False'; |
3010 |
|
} |
3011 |
|
|
3012 |
|
/** |
3013 |
* Calcul des règle d'action selon leur type. |
* Calcul des règle d'action selon leur type. |
3014 |
* |
* |
3015 |
* Types de règle : |
* Types de règle : |
3030 |
|
|
3031 |
// Supprime tous les espaces de la chaîne de caractère |
// Supprime tous les espaces de la chaîne de caractère |
3032 |
$rule = str_replace(' ', '', $rule); |
$rule = str_replace(' ', '', $rule); |
3033 |
|
// On force les minuscules |
3034 |
|
$rule = strtolower($rule); |
3035 |
// Coupe la chaîne au niveau de l'opérateur |
// Coupe la chaîne au niveau de l'opérateur |
3036 |
$operands = explode ("+", $rule); |
$operands = explode ("+", $rule); |
3037 |
// Nombre d'opérande |
// Nombre d'opérande |
3062 |
"regle_date_retour_contradictoire", |
"regle_date_retour_contradictoire", |
3063 |
"regle_date_ait", |
"regle_date_ait", |
3064 |
"regle_date_transmission_parquet", |
"regle_date_transmission_parquet", |
3065 |
|
"regle_date_affichage", |
3066 |
|
"duree_validite", |
3067 |
|
"duree_validite_parametrage", |
3068 |
); |
); |
3069 |
// Tableau des champs de type numérique |
// Tableau des champs de type numérique |
3070 |
$rule_type_numeric = array( |
$rule_type_numeric = array( |
3071 |
|
); |
3072 |
|
// Tableau des champs de type text |
3073 |
|
$rule_type_time_delai = array( |
3074 |
"regle_delai", |
"regle_delai", |
3075 |
"regle_delai_incompletude", |
"regle_delai_incompletude", |
3076 |
); |
); |
3079 |
); |
); |
3080 |
// Tableau des champs de type booléen |
// Tableau des champs de type booléen |
3081 |
$rule_type_bool = array( |
$rule_type_bool = array( |
3082 |
|
"regle_a_qualifier", |
3083 |
|
"regle_incompletude", |
3084 |
|
"regle_incomplet_notifie", |
3085 |
|
"regle_evenement_suivant_tacite_incompletude", |
3086 |
); |
); |
3087 |
// Tableau des champs spécifiques |
// Tableau des champs spécifiques |
3088 |
$rule_type_specific = array( |
$rule_type_specific = array( |
3090 |
"regle_etat", |
"regle_etat", |
3091 |
"regle_accord_tacite", |
"regle_accord_tacite", |
3092 |
"regle_avis", |
"regle_avis", |
3093 |
|
"regle_pec_metier", |
3094 |
|
"regle_etat_pendant_incompletude", |
3095 |
); |
); |
3096 |
// Tableau des champs de données techniques |
// Tableau des champs de données techniques |
3097 |
$rule_type_technical_data = array( |
$rule_type_technical_data = array( |
3123 |
$type = "specific"; |
$type = "specific"; |
3124 |
} |
} |
3125 |
if (in_array($rule_name, $rule_type_technical_data) === true) { |
if (in_array($rule_name, $rule_type_technical_data) === true) { |
3126 |
$type = 'text'; |
$type = 'technical_text'; |
3127 |
} |
} |
3128 |
if (in_array($rule_name, $rule_type_simple) === true) { |
if (in_array($rule_name, $rule_type_simple) === true) { |
3129 |
$type = 'simple'; |
$type = 'simple'; |
3130 |
} |
} |
3131 |
|
if (in_array($rule_name, $rule_type_time_delai) === true) { |
3132 |
|
$type = "time_delai"; |
3133 |
|
} |
3134 |
|
|
3135 |
// Si c'est un type spécifique ou booléen alors il n'a qu'un opérande |
// Si c'est un type spécifique ou booléen alors il n'a qu'un opérande |
3136 |
// Récupère directement la valeur de l'opérande |
// Récupère directement la valeur de l'opérande |
3137 |
if ($type === 'specific' || $type === 'bool') { |
if ($type === 'specific') { |
3138 |
// |
// |
3139 |
return $this->get_value_for_rule($rule); |
return $this->get_value_for_rule($rule); |
3140 |
} |
} |
3141 |
|
|
3142 |
// Initialisation des variables |
// Initialisation des variables |
|
$key_date = 0; |
|
3143 |
$total_numeric = 0; |
$total_numeric = 0; |
3144 |
$res_text = ''; |
$res_text = ''; |
3145 |
|
$final_date = 0; |
3146 |
|
|
3147 |
// Pour chaque opérande |
// Pour chaque opérande |
3148 |
foreach ($operands as $key => $operand) { |
foreach ($operands as $key => $operand) { |
|
|
|
3149 |
// Si c'est une règle de type date |
// Si c'est une règle de type date |
3150 |
if ($type == 'date') { |
if ($type == 'date') { |
3151 |
// Vérifie si au moins une des opérandes est une date |
if (is_numeric($operand) === false){ |
3152 |
if (is_numeric($operand) === false |
$rule_value = $this->get_value_for_rule($operand); |
3153 |
&& $this->get_value_for_rule($operand) !== null |
if ( |
3154 |
&& $this->f->check_date($this->get_value_for_rule($operand)) == true) { |
$rule_value !== null |
3155 |
// Récupère la position de la date |
&& ( |
3156 |
$key_date = $key; |
strpos($operand, 'mois') !== false |
3157 |
|
|| strpos($operand, 'jour') !== false |
3158 |
|
) |
3159 |
|
){ |
3160 |
|
$rule_value = $operand; |
3161 |
|
} |
3162 |
|
if ($rule_value !== null){ |
3163 |
|
// Vérifie si l'opérande est une date |
3164 |
|
if ($this->f->check_date($rule_value) == true) { |
3165 |
|
// Affecte la date |
3166 |
|
$final_date = $rule_value; |
3167 |
|
}else{ |
3168 |
|
// Gère les opérandes |
3169 |
|
preg_match_all('/(\d+) *([a-zA-Z]*)/', $rule_value, $matches, PREG_OFFSET_CAPTURE); |
3170 |
|
|
3171 |
|
// Ajoute l'opérande au total |
3172 |
|
foreach ($matches[1] as $matche_key => $matche_value) { |
3173 |
|
$timelength = $matches[1][$matche_key][0]; |
3174 |
|
$timetype = 'mois'; |
3175 |
|
if ( $matches[2][$matche_key][0] != ''){ |
3176 |
|
$timetype = $matches[2][$matche_key][0]; |
3177 |
|
} |
3178 |
|
// Ajout au calcul de la date |
3179 |
|
$final_date = $this->f->mois_date( |
3180 |
|
$final_date, |
3181 |
|
$timelength, |
3182 |
|
"+", |
3183 |
|
$timetype |
3184 |
|
); |
3185 |
|
} |
3186 |
|
} |
3187 |
|
} |
3188 |
} |
} |
3189 |
// Les autres opérandes doivent être que des numériques |
// Les autres opérandes doivent être que des numériques |
3190 |
if (is_numeric($operand) == true) { |
if (is_numeric($operand) == true) { |
3191 |
// Ajoute l'opérande au total |
// Ajoute l'opérande au total |
3192 |
$total_numeric += $operand; |
// Ajout au calcul de la date |
3193 |
} |
$final_date = $this->f->mois_date($final_date, |
3194 |
if (is_numeric($operand) === false |
$operand, "+"); |
|
&& $this->get_value_for_rule($operand) !== null |
|
|
&& is_numeric($this->get_value_for_rule($operand)) == true) { |
|
|
// Ajoute l'opérande au total |
|
|
$total_numeric += $this->get_value_for_rule($operand); |
|
3195 |
} |
} |
3196 |
} |
} |
3197 |
|
|
3211 |
} |
} |
3212 |
|
|
3213 |
// Si c'est une règle de type text |
// Si c'est une règle de type text |
3214 |
if ($type === 'text') { |
if ($type === 'text' || $type === 'technical_text') { |
3215 |
// Concatène toutes les chaînes de caractère |
// Concatène toutes les chaînes de caractère |
3216 |
$res_text .= $this->get_value_for_rule($operand); |
$res_text .= $this->get_value_for_rule($operand); |
3217 |
} |
} |
3218 |
|
|
3219 |
|
// Si c'est une règle de type time_delai |
3220 |
|
if ($type === 'time_delai') { |
3221 |
|
$rule_value = $this->get_value_for_rule($operand); |
3222 |
|
if ( strlen($res_text) != 0) { |
3223 |
|
$res_text .= "+"; |
3224 |
|
} |
3225 |
|
if ($rule_value != null && $rule_value != ''){ |
3226 |
|
// Supprime tous les espaces de la chaîne de caractère |
3227 |
|
// Concatène toutes les chaînes de caractère |
3228 |
|
$res_text .= $rule_value; |
3229 |
|
} else { |
3230 |
|
$res_text .= $operand; |
3231 |
|
} |
3232 |
|
} |
3233 |
|
|
3234 |
} |
} |
3235 |
|
|
3236 |
// Résultat pour une règle de type date |
// Résultat pour une règle de type date |
3237 |
if ($type == 'date') { |
if ($type == 'date') { |
3238 |
// Retourne le calcul de la date |
// Retourne la date |
3239 |
return $this->f->mois_date($this->valF[$operands[$key_date]], |
return $final_date; |
|
$total_numeric, "+"); |
|
3240 |
} |
} |
3241 |
|
|
3242 |
// Résultat pour une règle de type numérique |
// Résultat pour une règle de type numérique |
3246 |
} |
} |
3247 |
|
|
3248 |
// Résultat pour une règle de type text |
// Résultat pour une règle de type text |
3249 |
if ($type === 'text') { |
if (in_array($type, array('text', 'technical_text')) === true) { |
3250 |
// Retourne la chaîne de caractère |
// Retourne la chaîne de caractère |
3251 |
return $res_text; |
return $res_text; |
3252 |
} |
} |
3253 |
if ($type === 'simple') { |
|
3254 |
|
// Résultat pour une règle de type text |
3255 |
|
if (in_array($type, array('time_delai')) === true) { |
3256 |
|
// Traitement de la valeur à afficher |
3257 |
|
$res_text = str_replace(' ', '', $res_text); |
3258 |
|
$res_text = preg_replace('/(\d+)/', '$1 ', $res_text); |
3259 |
|
$res_text = preg_replace('/(\+)/', ' $1 ', $res_text); |
3260 |
|
$res_text = trim(preg_replace('/\s\s+/', ' ', strtolower($res_text))); |
3261 |
|
return $res_text; |
3262 |
|
} |
3263 |
|
|
3264 |
|
if ($type === 'simple' || $type === 'bool') { |
3265 |
// Retourne la valeur du champs rule |
// Retourne la valeur du champs rule |
3266 |
return $rule; |
return $rule; |
3267 |
} |
} |
3322 |
* @return string L'identifiant des données techniques liées du dossier |
* @return string L'identifiant des données techniques liées du dossier |
3323 |
*/ |
*/ |
3324 |
function getDonneesTechniques() { |
function getDonneesTechniques() { |
3325 |
|
|
3326 |
|
$qres = $this->f->get_one_result_from_db_query( |
3327 |
|
sprintf( |
3328 |
|
'SELECT |
3329 |
|
donnees_techniques |
3330 |
|
FROM |
3331 |
|
%1$sdonnees_techniques |
3332 |
|
WHERE |
3333 |
|
dossier_instruction = \'%2$s\'', |
3334 |
|
DB_PREFIXE, |
3335 |
|
$this->f->db->escapeSimple($this->valF["dossier"]) |
3336 |
|
), |
3337 |
|
array( |
3338 |
|
"origin" => __METHOD__, |
3339 |
|
) |
3340 |
|
); |
3341 |
|
|
3342 |
$donnees_techniques = ''; |
return $qres['result']; |
|
|
|
|
$sql = "SELECT donnees_techniques |
|
|
FROM ".DB_PREFIXE."donnees_techniques |
|
|
WHERE dossier_instruction ='".$this->valF["dossier"]."'"; |
|
|
$donnees_techniques = $this->db->getOne($sql); |
|
|
$this->f->addToLog("getStatut() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
|
|
if ( database::isError($donnees_techniques)){ |
|
|
die(); |
|
|
} |
|
|
|
|
|
return $donnees_techniques; |
|
3343 |
} |
} |
3344 |
|
|
|
|
|
3345 |
/** |
/** |
3346 |
* TRIGGER - triggerajouterapres. |
* TRIGGER - triggerajouterapres. |
3347 |
* |
* |
3352 |
* |
* |
3353 |
* @return boolean |
* @return boolean |
3354 |
*/ |
*/ |
3355 |
function triggerajouterapres($id, &$db = null, $val = array(), $DEBUG = null) { |
function triggerajouterapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
3356 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
3357 |
|
$data = array('val' => &$val, 'id' => $id); |
3358 |
|
$this->f->module_manager->run_hooks('triggerajouterapres_pre', $this, $data); |
3359 |
|
|
3360 |
// On a besoin de l'instance du dossier lié à l'événement d'instruction |
// On a besoin de l'instance du dossier lié à l'événement d'instruction |
3361 |
$inst_di = $this->get_inst_dossier($this->valF['dossier']); |
$inst_di = $this->get_inst_dossier($this->valF['dossier']); |
|
|
|
3362 |
// Instance de la classe evenement |
// Instance de la classe evenement |
3363 |
$inst_evenement = $this->get_inst_evenement($this->valF['evenement']); |
$inst_evenement = $this->get_inst_evenement($this->valF['evenement']); |
3364 |
|
// Instance de l'état courant du dossier d'instruction |
3365 |
|
$inst_current_etat = $this->f->get_inst__om_dbform(array( |
3366 |
|
"obj" => "etat", |
3367 |
|
"idx" => $inst_di->get_id_etat(), |
3368 |
|
)); |
3369 |
|
|
3370 |
/** |
/** |
3371 |
* Mise à jour des valeurs du dossier en fonction des valeurs calculées |
* Mise à jour des valeurs du dossier en fonction des valeurs calculées |
3373 |
*/ |
*/ |
3374 |
// état de complétude actuel du dossier |
// état de complétude actuel du dossier |
3375 |
$incompletude = ($inst_di->getVal('incompletude') == 't' ? true : false); |
$incompletude = ($inst_di->getVal('incompletude') == 't' ? true : false); |
3376 |
|
// L'événement suivant tacite paramétré est destiné à la gestion de l'incomplétude |
3377 |
|
$ev_suiv_tacite_incompletude = false; |
3378 |
// Initialisation |
// Initialisation |
3379 |
$valF = ""; |
$valF = array(); |
3380 |
$valF_dt = ""; |
$valF_dt = array(); |
3381 |
// |
// |
|
if($incompletude === FALSE) { |
|
|
// Si l'événement d'instruction est de type incompletude |
|
|
if($inst_evenement->getVal('type') == "incompletude") { |
|
|
// On marque le dossier en incomplétude pour application des actions |
|
|
$incompletude = TRUE; |
|
|
// Set du flag incomplétude de la table dossier |
|
|
$valF['incompletude'] = TRUE; |
|
|
// Enregistrement de l'état dans la variable provisoire |
|
|
$valF['etat_pendant_incompletude'] = $this->valF['archive_etat']; |
|
|
} |
|
|
} else { |
|
|
// Si l'evenement d'instruction est de type retour ou contient une |
|
|
// decision, on sort d'incomplétude |
|
|
if($inst_evenement->getVal('type') == "retour" OR |
|
|
$inst_evenement->getVal('avis_decision') != NULL) { |
|
|
// On enlève la marque d'incomplétude pour application des actions |
|
|
$incompletude = FALSE; |
|
|
// On enlève le flag d'incomplétude sur l'enregistrement de la table dossier |
|
|
$valF['incompletude'] = FALSE; |
|
|
$valF['incomplet_notifie'] = FALSE; |
|
|
// Restauration de l'état depuis l'état provisoire |
|
|
$valF['etat'] = $this->valF['archive_etat_pendant_incompletude']; |
|
|
// On vide la variable provisoire ainsi que le délai de complétude |
|
|
// et la date limite de complétude |
|
|
$valF['etat_pendant_incompletude'] = NULL; |
|
|
$valF['delai_incompletude'] = NULL; |
|
|
$valF['date_limite_incompletude'] = NULL; |
|
|
$valF['evenement_suivant_tacite_incompletude'] = NULL; |
|
|
} |
|
|
} |
|
3382 |
// Récupération des paramètres de l'action |
// Récupération des paramètres de l'action |
3383 |
$sql = "SELECT * FROM ".DB_PREFIXE."action |
// TODO : remplacer cette requête par l'instanciation de l'action |
3384 |
WHERE action='".$this->valF['action']."'"; |
$qres = $this->f->get_all_results_from_db_query( |
3385 |
$res = $db->query($sql); |
sprintf( |
3386 |
$this->addToLog("triggerajouterapres(): db->query(\"".$sql."\");", VERBOSE_MODE); |
'SELECT |
3387 |
if (database::isError($res)) { |
* |
3388 |
die($res->getMessage()); |
FROM |
3389 |
} |
%1$saction |
3390 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
WHERE |
3391 |
|
action = \'%2$s\'', |
3392 |
|
DB_PREFIXE, |
3393 |
|
$this->f->db->escapeSimple($this->valF['action']) |
3394 |
|
), |
3395 |
|
array( |
3396 |
|
"origin" => __METHOD__ |
3397 |
|
) |
3398 |
|
); |
3399 |
|
foreach ($qres['result'] as $row) { |
3400 |
|
|
3401 |
// pour chacune des regles, on applique la regle |
// pour chacune des regles, on applique la regle |
3402 |
if ($row['regle_delai'] != '') { |
if ($row['regle_delai'] != '') { |
3448 |
$valF['autorite_competente'] = $this->regle($row['regle_autorite_competente'], 'regle_autorite_competente'); |
$valF['autorite_competente'] = $this->regle($row['regle_autorite_competente'], 'regle_autorite_competente'); |
3449 |
} |
} |
3450 |
if ($row['regle_etat'] != '') { |
if ($row['regle_etat'] != '') { |
3451 |
// Si on est dans le cas général ou qu'on est en incomplétude et |
$valF['etat'] = $this->regle($row['regle_etat'], 'regle_etat'); |
|
// qu'on a un événement de type incomplétude alors : on stocke |
|
|
// l'état dans la variable courante |
|
|
if ($incompletude == FALSE OR $inst_evenement->getVal('type') == "incompletude") { |
|
|
$valF['etat'] = $this->regle($row['regle_etat'], 'regle_etat'); |
|
|
} else { |
|
|
$valF['etat_pendant_incompletude'] = $this->regle($row['regle_etat'], 'regle_etat'); |
|
|
} |
|
3452 |
} |
} |
3453 |
if ($row['regle_date_cloture_instruction'] !== '') { |
if ($row['regle_date_cloture_instruction'] !== '') { |
3454 |
$valF['date_cloture_instruction'] = $this->regle($row['regle_date_cloture_instruction'], 'regle_date_cloture_instruction'); |
$valF['date_cloture_instruction'] = $this->regle($row['regle_date_cloture_instruction'], 'regle_date_cloture_instruction'); |
3489 |
if ($row['regle_dossier_instruction_type'] !== '') { |
if ($row['regle_dossier_instruction_type'] !== '') { |
3490 |
$valF['dossier_instruction_type'] = $this->regle($row['regle_dossier_instruction_type'], 'regle_dossier_instruction_type'); |
$valF['dossier_instruction_type'] = $this->regle($row['regle_dossier_instruction_type'], 'regle_dossier_instruction_type'); |
3491 |
} |
} |
3492 |
|
// La date d'affichage est modifiée seulement si le champ n'est pas |
3493 |
|
// renseigné |
3494 |
|
if ($row['regle_date_affichage'] !== '' |
3495 |
|
&& ($inst_di->getVal('date_affichage') === '' |
3496 |
|
|| $inst_di->getVal('date_affichage') === null)) { |
3497 |
|
// |
3498 |
|
$valF['date_affichage'] = $this->regle($row['regle_date_affichage'], 'regle_date_affichage'); |
3499 |
|
} |
3500 |
|
// |
3501 |
|
if ($row['regle_pec_metier'] != '') { |
3502 |
|
$valF['pec_metier'] = $this->regle($row['regle_pec_metier'], 'regle_pec_metier'); |
3503 |
|
} |
3504 |
|
if ($row['regle_a_qualifier'] != '') { |
3505 |
|
$valF['a_qualifier'] = $this->regle($row['regle_a_qualifier'], 'regle_a_qualifier'); |
3506 |
|
} |
3507 |
|
// |
3508 |
|
if ($row['regle_incompletude'] != '') { |
3509 |
|
$valF['incompletude'] = $this->regle($row['regle_incompletude'], 'regle_incompletude'); |
3510 |
|
} |
3511 |
|
if ($row['regle_incomplet_notifie'] != '') { |
3512 |
|
$valF['incomplet_notifie'] = $this->regle($row['regle_incomplet_notifie'], 'regle_incomplet_notifie'); |
3513 |
|
} |
3514 |
|
if ($row['regle_etat_pendant_incompletude'] != '') { |
3515 |
|
$valF['etat_pendant_incompletude'] = $this->regle($row['regle_etat_pendant_incompletude'], 'regle_etat_pendant_incompletude'); |
3516 |
|
} |
3517 |
|
if ($row['regle_evenement_suivant_tacite_incompletude'] != '') { |
3518 |
|
$resti = $this->regle($row['regle_evenement_suivant_tacite_incompletude'], 'regle_evenement_suivant_tacite_incompletude'); |
3519 |
|
if (strtolower($resti) === 't' || strtolower($resti) === 'true') { |
3520 |
|
$ev_suiv_tacite_incompletude = true; |
3521 |
|
} |
3522 |
|
} |
3523 |
} |
} |
3524 |
|
|
3525 |
// Si l'événement a un événement suivant tacite |
// Si l'événement a un événement suivant tacite |
3526 |
if($inst_evenement->getVal('evenement_suivant_tacite') != '') { |
if($inst_evenement->getVal('evenement_suivant_tacite') != '') { |
3527 |
// Si le DI n'est pas en incomplétude, l'événement tacite est stocké |
// En fonction de l'action de l'événement, l'événement suivant tacite ne sera |
3528 |
// dans le champ evenement_suivant_tacite du dossier |
// pas associé de le même façon au dossier d'instruction |
3529 |
if ($incompletude == false OR $inst_evenement->getVal('type') != "incompletude") { |
if ($ev_suiv_tacite_incompletude === false) { |
|
// |
|
3530 |
$valF['evenement_suivant_tacite'] = $inst_evenement->getVal('evenement_suivant_tacite'); |
$valF['evenement_suivant_tacite'] = $inst_evenement->getVal('evenement_suivant_tacite'); |
3531 |
} else { |
} |
3532 |
// Sinon l'événement tacite est stocké dans le champ |
if ($ev_suiv_tacite_incompletude === true) { |
|
// evenement_suivant_tacite_incompletude du dossier |
|
3533 |
$valF['evenement_suivant_tacite_incompletude'] = $inst_evenement->getVal('evenement_suivant_tacite'); |
$valF['evenement_suivant_tacite_incompletude'] = $inst_evenement->getVal('evenement_suivant_tacite'); |
3534 |
} |
} |
3535 |
} |
} |
3536 |
// Si des valeurs de données techniques ont été calculées alors on met à jour l'enregistrement |
// Si des valeurs de données techniques ont été calculées alors on met à jour l'enregistrement |
3537 |
if ($valF_dt != "") { |
if (count($valF_dt) > 0) { |
3538 |
$dt_id = $this->getDonneesTechniques(); |
$dt_id = $this->getDonneesTechniques(); |
3539 |
// On met à jour le dossier |
// On met à jour le dossier |
3540 |
$cle = " donnees_techniques='".$dt_id."'"; |
$cle = " donnees_techniques='".$dt_id."'"; |
3541 |
$res1 = $db->autoExecute(DB_PREFIXE.'donnees_techniques', $valF_dt, DB_AUTOQUERY_UPDATE, $cle); |
$res1 = $this->f->db->autoexecute(DB_PREFIXE.'donnees_techniques', $valF_dt, DB_AUTOQUERY_UPDATE, $cle); |
3542 |
$this->addToLog("triggerajouterapres(): db->autoexecute(\"".DB_PREFIXE."donnees_techniques\", ".print_r($valF_dt, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
$this->addToLog( |
3543 |
if (database::isError($res1)) { |
__METHOD__."(): db->autoexecute(\"".DB_PREFIXE."donnees_techniques\", ".print_r($valF_dt, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", |
3544 |
die($res->getMessage()); |
VERBOSE_MODE |
3545 |
} |
); |
3546 |
|
$this->f->isDatabaseError($res1); |
3547 |
// Affichage d'informations à l'utilisateur |
// Affichage d'informations à l'utilisateur |
3548 |
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$this->f->db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
3549 |
} |
} |
3550 |
// Si des valeurs ont été calculées alors on met à jour l'enregistrement |
// Si des valeurs ont été calculées alors on met à jour l'enregistrement |
3551 |
if ($valF != "") { |
if (count($valF) > 0) { |
3552 |
// On met à jour le dossier |
// |
3553 |
$cle = " dossier='".$this->valF['dossier']."'"; |
$inst_dossier = $this->f->get_inst__om_dbform(array( |
3554 |
$res1 = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle); |
"obj" => "dossier", |
3555 |
$this->addToLog("triggerajouterapres(): db->autoexecute(\"".DB_PREFIXE."dossier\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
"idx" => $this->valF['dossier'], |
3556 |
if (database::isError($res1)) { |
)); |
3557 |
die($res->getMessage()); |
$valF['instruction'] = $id; |
3558 |
|
$valF['crud'] = 'create'; |
3559 |
|
$update_by_instruction = $inst_dossier->update_by_instruction($valF); |
3560 |
|
if ($update_by_instruction === false) { |
3561 |
|
$this->cleanMessage(); |
3562 |
|
$this->addToMessage(sprintf('%s %s', __("Une erreur s'est produite lors de la mise à jour du dossier d'instruction."), __("Veuillez contacter votre administrateur."))); |
3563 |
|
return false; |
3564 |
} |
} |
3565 |
// Affichage d'informations à l'utilisateur |
// Affichage d'informations à l'utilisateur |
3566 |
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$this->f->db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
3567 |
} |
} |
3568 |
|
|
3569 |
/** |
/** |
3599 |
$this->addToMessage(_("Notification (105) du référentiel ERP OK.")); |
$this->addToMessage(_("Notification (105) du référentiel ERP OK.")); |
3600 |
} |
} |
3601 |
|
|
3602 |
/** |
// Si le mode en rédaction intégrale est activé |
3603 |
* Mise à jour des données du DA. |
if (isset($this->valF['flag_edition_integrale']) === true |
3604 |
*/ |
&& $this->valF['flag_edition_integrale'] === true) { |
3605 |
// |
$redactionIntegraleValF = array(); |
3606 |
$inst_da = $inst_di->get_inst_dossier_autorisation(); |
|
3607 |
// |
// Récupère la collectivite du dossier d'instruction |
3608 |
if ($inst_da->majDossierAutorisation() === false) { |
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
3609 |
$this->addToMessage(_("Erreur lors de la mise a jour des donnees du dossier d'autorisation. Contactez votre administrateur.")); |
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
3610 |
$this->correct = false; |
// Récupère le corps de la lettre type |
3611 |
return false; |
$params = array( |
3612 |
|
"specific" => array( |
3613 |
|
"corps" => array( |
3614 |
|
"mode" => "get", |
3615 |
|
) |
3616 |
|
), |
3617 |
|
); |
3618 |
|
$result = $this->compute_pdf_output('lettretype', $this->valF['lettretype'], $collectivite, $id, $params); |
3619 |
|
$redactionIntegraleValF['corps_om_htmletatex'] = $result['pdf_output']; |
3620 |
|
// Récupère le titre de la lettre type |
3621 |
|
$params = array( |
3622 |
|
"specific" => array( |
3623 |
|
"titre" => array( |
3624 |
|
"mode" => "get", |
3625 |
|
) |
3626 |
|
), |
3627 |
|
); |
3628 |
|
$result = $this->compute_pdf_output('lettretype', $this->valF['lettretype'], $collectivite, $id, $params); |
3629 |
|
$redactionIntegraleValF['titre_om_htmletat'] = $result['pdf_output']; |
3630 |
|
|
3631 |
|
// mise à jour en base de données |
3632 |
|
$res = $this->f->db->autoExecute( |
3633 |
|
DB_PREFIXE.$this->table, |
3634 |
|
$redactionIntegraleValF, |
3635 |
|
DB_AUTOQUERY_UPDATE, |
3636 |
|
$this->clePrimaire."=".$id |
3637 |
|
); |
3638 |
|
$this->addToLog(__METHOD__."(): db->autoexecute(\"".DB_PREFIXE.'.'.$this->table."\", ".print_r($redactionIntegraleValF, true).", DB_AUTOQUERY_UPDATE, \"".$this->clePrimaire."=".$id."\");", VERBOSE_MODE); |
3639 |
|
if ($this->f->isDatabaseError($res, true) === true) { |
3640 |
|
return false; |
3641 |
|
} |
3642 |
} |
} |
3643 |
|
|
3644 |
/** |
/** |
3710 |
} |
} |
3711 |
|
|
3712 |
/** |
/** |
3713 |
|
* Mise à jour de la version de clôture *version_clos* du dossier si et |
3714 |
|
* seulement si l'instruction met à jour l'état du dossier. |
3715 |
|
*/ |
3716 |
|
if (isset($valF['etat']) === true |
3717 |
|
&& $valF['etat'] !== null |
3718 |
|
&& $valF['etat'] !== '') { |
3719 |
|
// Instanciation de l'état appliqué sur le dossier par l'instruction |
3720 |
|
$inst_etat = $this->f->get_inst__om_dbform(array( |
3721 |
|
"obj" => "etat", |
3722 |
|
"idx" => $valF['etat'], |
3723 |
|
)); |
3724 |
|
// |
3725 |
|
$update_version_clos = null; |
3726 |
|
// En cas d'instruction qui clôture le dossier |
3727 |
|
if ($inst_etat->getVal('statut') === 'cloture') { |
3728 |
|
$update_version_clos = $inst_di->update_version_clos('up'); |
3729 |
|
} |
3730 |
|
// En cas d'instruction qui rouvre le dossier |
3731 |
|
if ($inst_current_etat->getVal('statut') === 'cloture' |
3732 |
|
&& $inst_etat->getVal('statut') !== 'cloture') { |
3733 |
|
// |
3734 |
|
$update_version_clos = $inst_di->update_version_clos('down'); |
3735 |
|
// |
3736 |
|
$params = array( |
3737 |
|
'di_reopened' => true, |
3738 |
|
); |
3739 |
|
} |
3740 |
|
// |
3741 |
|
if ($update_version_clos === false) { |
3742 |
|
$this->f->addToLog(sprintf( |
3743 |
|
"%s() : ERREUR - %s %s", |
3744 |
|
__METHOD__, |
3745 |
|
sprintf( |
3746 |
|
__("Impossible de mettre à jour la version de clôture du dossier d'instruction %s."), |
3747 |
|
$inst_di->getVal($inst_di->clePrimaire) |
3748 |
|
), |
3749 |
|
sprintf( |
3750 |
|
__("L'instruction tente d'appliquer l'état %s."), |
3751 |
|
$inst_etat->getVal($inst_etat->clePrimaire) |
3752 |
|
) |
3753 |
|
)); |
3754 |
|
$this->addToMessage(sprintf( |
3755 |
|
"%s %s", |
3756 |
|
__("Erreur lors de la mise à jour de la version de clôture du dossier d'instruction."), |
3757 |
|
__("Veuillez contacter votre administrateur.") |
3758 |
|
)); |
3759 |
|
return false; |
3760 |
|
} |
3761 |
|
} |
3762 |
|
|
3763 |
|
/** |
3764 |
|
* Notification automatique |
3765 |
|
*/ |
3766 |
|
// Notification automatique à l'ajout de l'instruction si la notification |
3767 |
|
// automatique est choisie et qu'il n'y a pas de lettretype associée à l'événement |
3768 |
|
if ($inst_evenement->getVal('notification') === 'notification_automatique' && |
3769 |
|
($inst_evenement->getVal('lettretype') === null || |
3770 |
|
$inst_evenement->getVal('lettretype') === '')) { |
3771 |
|
// Message à afficher dans les logs pour indiquer quelle notification a échouée |
3772 |
|
$msgLog = sprintf( |
3773 |
|
'%s %s : %d', |
3774 |
|
__('Erreur lors de la notification automatique du(des) pétitionnaire(s).'), |
3775 |
|
__('Instruction notifiée'), |
3776 |
|
$id |
3777 |
|
); |
3778 |
|
|
3779 |
|
// Récupération de la liste des demandeurs à notifier et de la catégorie |
3780 |
|
$categorie = $this->f->get_param_option_notification($collectivite_di); |
3781 |
|
$isPortal = $categorie === PORTAL; |
3782 |
|
$demandeursANotifie = $this->get_demandeurs_notifiable( |
3783 |
|
$this->valF['dossier'], |
3784 |
|
$isPortal |
3785 |
|
); |
3786 |
|
|
3787 |
|
// Création d'une notification et d'une tâche pour chaque demandeur à notifier |
3788 |
|
$demandeurPrincipalNotifie = false; |
3789 |
|
foreach ($demandeursANotifie as $demandeur) { |
3790 |
|
// Identifie si le demandeur principal a été notifié ou pas |
3791 |
|
// et récupère ses informations |
3792 |
|
if ($demandeur['petitionnaire_principal'] == 't') { |
3793 |
|
$demandeurPrincipalNotifie = true; |
3794 |
|
// Si le demandeur principal est notifiable mais qu'il y a des erreurs dans |
3795 |
|
// son paramétrage, on effectue pas le traitement et on passe à l'itération |
3796 |
|
// suivante. On le considère également comme non notifié pour gérer l'envoie |
3797 |
|
// des messages d'erreurs |
3798 |
|
// Si la demande a été déposée via le portail alors le paramétrage n'a pas |
3799 |
|
// d'impact sur la notification |
3800 |
|
$erreursParam = $this->get_info_notification_fail($val['dossier']); |
3801 |
|
if (! $this->dossier_depose_sur_portail($val['dossier']) && $erreursParam != array()) { |
3802 |
|
$demandeurPrincipalNotifie = false; |
3803 |
|
continue; |
3804 |
|
} |
3805 |
|
} |
3806 |
|
// Ajout de la notif et récupération de son id |
3807 |
|
$idNotif = $this->ajouter_notification( |
3808 |
|
$this->valF[$this->clePrimaire], |
3809 |
|
$this->f->get_connected_user_login_name(), |
3810 |
|
$demandeur, |
3811 |
|
$collectivite_di, |
3812 |
|
array(), |
3813 |
|
true |
3814 |
|
); |
3815 |
|
if ($idNotif === false) { |
3816 |
|
$this->addToLog( |
3817 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
3818 |
|
DEBUG_MODE |
3819 |
|
); |
3820 |
|
return false; |
3821 |
|
} |
3822 |
|
// Création de la tache en lui donnant l'id de la notification |
3823 |
|
$notification_by_task = $this->notification_by_task( |
3824 |
|
$idNotif, |
3825 |
|
$this->valF['dossier'], |
3826 |
|
$categorie |
3827 |
|
); |
3828 |
|
if ($notification_by_task === false) { |
3829 |
|
$this->addToLog( |
3830 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
3831 |
|
DEBUG_MODE |
3832 |
|
); |
3833 |
|
$this->addToMessage( |
3834 |
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
3835 |
|
); |
3836 |
|
return false; |
3837 |
|
} |
3838 |
|
} |
3839 |
|
// Pour la notification par mail ou la notification via portal si le dossier a |
3840 |
|
// été déposés via portal, si le demandeur principal n'est pas notifiable, |
3841 |
|
// on créé une nouvelle notification en erreur avec en commentaire la raison pour |
3842 |
|
// laquelle le demandeur principal n'a pas pu être notifié |
3843 |
|
$depotPortal = $this->dossier_depose_sur_portail(); |
3844 |
|
if (! $demandeurPrincipalNotifie && ($isPortal === false || $depotPortal === true)) { |
3845 |
|
// Précision dans les logs que le pétitionnaire principal n'est pas notifiable. |
3846 |
|
// ' ' permet de mettre un espace entre les 2 msg de log. |
3847 |
|
$msgLog .= sprintf(' %s', __('Le pétitionnaire principale n\'est pas notifiable.')); |
3848 |
|
// Analyse pour savoir pourquoi le demandeur principal n'est pas notifiable |
3849 |
|
$erreursParam = $this->get_info_notification_fail($val['dossier']); |
3850 |
|
$demandeurPrincipal = $this->get_info_petitionnaire_principal_dossier($val['dossier']); |
3851 |
|
// Ajout de la notif et récupération de son id |
3852 |
|
$idNotif = $this->ajouter_notification( |
3853 |
|
$this->valF[$this->clePrimaire], |
3854 |
|
$this->f->get_connected_user_login_name(), |
3855 |
|
$demandeurPrincipal, |
3856 |
|
$collectivite_di, |
3857 |
|
array(), |
3858 |
|
true, |
3859 |
|
'Echec', |
3860 |
|
implode(' ', $erreursParam) |
3861 |
|
); |
3862 |
|
if ($idNotif === false) { |
3863 |
|
$this->addToLog( |
3864 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
3865 |
|
DEBUG_MODE |
3866 |
|
); |
3867 |
|
$this->addToMessage( |
3868 |
|
__('Erreur : la création de la notification a échouée.'). |
3869 |
|
__("Veuillez contacter votre administrateur.") |
3870 |
|
); |
3871 |
|
return false; |
3872 |
|
} |
3873 |
|
// Prépare un message d'alerte à destination de l'instructeur pour l'informer |
3874 |
|
// de l'échec de la notification |
3875 |
|
$dossier_message = $this->get_inst_dossier_message(0); |
3876 |
|
$dossier_message_val = array( |
3877 |
|
'dossier' => $val['dossier'], |
3878 |
|
'type' => _('erreur expedition'), |
3879 |
|
'emetteur' => $this->f->get_connected_user_login_name().' (automatique)', |
3880 |
|
'login' => $_SESSION['login'], |
3881 |
|
'date_emission' => date('Y-m-d H:i:s'), |
3882 |
|
'contenu' => _('Échec lors de la notification de l\'instruction '). |
3883 |
|
$inst_evenement->getVal('libelle'). |
3884 |
|
'.<br>'. |
3885 |
|
implode("\n", $erreursParam). |
3886 |
|
'<br>'. |
3887 |
|
_('Veuillez corriger ces informations avant de renvoyer la notification.') |
3888 |
|
); |
3889 |
|
$add = $dossier_message->add_notification_message($dossier_message_val, true); |
3890 |
|
// Si une erreur se produit pendant l'ajout |
3891 |
|
if ($add !== true) { |
3892 |
|
$this->addToLog(__METHOD__."(): Le message d'alerte concernant l'echec de l'envoi de la notification n'a pas pu être envoyé.", DEBUG_MODE); |
3893 |
|
return false; |
3894 |
|
} |
3895 |
|
} |
3896 |
|
$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."))); |
3897 |
|
} |
3898 |
|
|
3899 |
|
// Notification automatique en cas de dépôt de dossier dématérialisé |
3900 |
|
// Vérifie si l'option de notification est active et si il s'agit bien d'une |
3901 |
|
// instruction de récépissé |
3902 |
|
if ( |
3903 |
|
$this->f->is_option_notification_depot_demat_enabled($collectivite_di) |
3904 |
|
&& $this->is_instruction_recepisse() |
3905 |
|
) { |
3906 |
|
// Message à afficher dans les logs pour indiquer quelle notification a échouée |
3907 |
|
$msgLog = sprintf( |
3908 |
|
__('Erreur lors de la notification de dépôt du dossier dématérialisé : %s.'), |
3909 |
|
$val['dossier'] |
3910 |
|
); |
3911 |
|
// Récupère l'instance de la demande |
3912 |
|
$demande = $inst_di->get_inst_demande(); |
3913 |
|
// Vérifie que le dossier a été déposé via platau ou portal |
3914 |
|
if ( |
3915 |
|
($demande->getVal('source_depot') == PLATAU || |
3916 |
|
$demande->getVal('source_depot') == PORTAL) |
3917 |
|
) { |
3918 |
|
// Récupère la liste des mails fournis en paramètre. Si aucun adresse n'a été récupéré |
3919 |
|
// l'envoi de la notification n'est pas effectué et un message d'erreur est affiché. |
3920 |
|
$listeEmails = $this->f->get_param_courriel_de_notification_commune($collectivite_di); |
3921 |
|
if (empty($listeEmails)) { |
3922 |
|
$this->addToLog( |
3923 |
|
sprintf( |
3924 |
|
'%s(): %s %s', |
3925 |
|
__METHOD__, |
3926 |
|
$msgLog, |
3927 |
|
__('Aucun courriel paramétré.') |
3928 |
|
), |
3929 |
|
DEBUG_MODE |
3930 |
|
); |
3931 |
|
} else { |
3932 |
|
foreach ($listeEmails as $email) { |
3933 |
|
// Ajout de la notif et récupération de son id |
3934 |
|
$destinataire = array( |
3935 |
|
'destinataire' => $email, |
3936 |
|
'courriel' => $email |
3937 |
|
); |
3938 |
|
$idNotif = $this->ajouter_notification( |
3939 |
|
$this->valF[$this->clePrimaire], |
3940 |
|
$this->f->get_connected_user_login_name(), |
3941 |
|
$destinataire, |
3942 |
|
$collectivite_di, |
3943 |
|
array(), |
3944 |
|
true |
3945 |
|
); |
3946 |
|
if ($idNotif === false) { |
3947 |
|
$this->addToLog( |
3948 |
|
sprintf('%s(): %s', __METHOD__, $msgLog), |
3949 |
|
DEBUG_MODE |
3950 |
|
); |
3951 |
|
return false; |
3952 |
|
} |
3953 |
|
// Création de la tache en lui donnant l'id de la notification |
3954 |
|
$notification_by_task = $this->notification_by_task( |
3955 |
|
$idNotif, |
3956 |
|
$this->valF['dossier'], |
3957 |
|
'mail', |
3958 |
|
'notification_depot_demat' |
3959 |
|
); |
3960 |
|
if ($notification_by_task === false) { |
3961 |
|
$this->addToMessage( |
3962 |
|
__("Erreur lors de la génération de la notification de dépot de dossier par voie dématérialisée.") |
3963 |
|
); |
3964 |
|
$this->addToLog( |
3965 |
|
sprintf('%s(): %s', __METHOD__, $msgLog), |
3966 |
|
DEBUG_MODE |
3967 |
|
); |
3968 |
|
return false; |
3969 |
|
} |
3970 |
|
} |
3971 |
|
} |
3972 |
|
} |
3973 |
|
} |
3974 |
|
|
3975 |
|
/** |
3976 |
* Mise à jour de la date de dernière modification du dossier |
* Mise à jour de la date de dernière modification du dossier |
3977 |
*/ |
*/ |
3978 |
$inst_di->update_last_modification_date(); |
$inst_di->update_last_modification_date(); |
3979 |
|
|
3980 |
/** |
/** |
3981 |
* Historisation de la vie du DI. |
* Mise à jour des données du DA. |
3982 |
*/ |
*/ |
3983 |
// |
$inst_da = $inst_di->get_inst_dossier_autorisation(); |
3984 |
return $this->add_log_to_dossier($id, array_merge($val, $this->valF)); |
$params['di_id'] = $this->valF['dossier']; |
3985 |
} |
if ($inst_da->majDossierAutorisation($params) === false) { |
3986 |
|
$this->addToMessage(_("Erreur lors de la mise a jour des donnees du dossier d'autorisation. Contactez votre administrateur.")); |
3987 |
|
$this->correct = false; |
3988 |
|
return false; |
3989 |
|
} |
3990 |
|
|
|
function triggermodifierapres($id, &$db = null, $val = array(), $DEBUG = null) { |
|
3991 |
/** |
/** |
3992 |
* L'objectif ici est d'effectuer les recalculs de date dans le dossier |
* Historisation de la vie du DI. |
3993 |
* si la date de l'evenement est modifiee |
*/ |
|
*/ |
|
|
// Initialisation |
|
|
$valF = ""; |
|
|
$valF_dt = ""; |
|
|
// Initialisation du type d'événement |
|
|
$type_evmt = ""; |
|
|
// Récupération de l'action correspondante à l'événement |
|
|
$sql = "SELECT action |
|
|
FROM ".DB_PREFIXE."evenement |
|
|
WHERE evenement=".$this->valF['evenement']; |
|
|
$action = $db->getOne($sql); |
|
|
$this->addToLog("triggermodifierapres(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
|
|
if (database::isError($action)) { |
|
|
die($action->getMessage()); |
|
|
} |
|
3994 |
|
|
3995 |
// Récupération des paramètres de l'action |
$res = $this->add_log_to_dossier($id, array_merge($val, $this->valF)); |
3996 |
$sql = "SELECT * FROM ".DB_PREFIXE."action |
|
3997 |
WHERE action='".$action."'"; |
$data = array('val' => &$val, 'id' => $id, 'result' => &$res); |
3998 |
$res = $db->query($sql); |
$this->f->module_manager->run_hooks('triggerajouterapres_post', $this, $data); |
3999 |
$this->addToLog("triggermodifierapres(): db->query(\"".$sql."\");", VERBOSE_MODE); |
return $res; |
4000 |
if (database::isError($res)) { |
} |
4001 |
die($res->getMessage()); |
|
4002 |
|
/** |
4003 |
|
* Cette méthode vérifie si toutes les conditions de l'envoi de la notification |
4004 |
|
* sont remplies. |
4005 |
|
* Les conditions vérifiées sont les suivantes : |
4006 |
|
* - L'option de notification *option_notification* doit être définie |
4007 |
|
* - Le petitionnaire principal doit accepter les notifications |
4008 |
|
* - Le pétitionnaire principal doit avoir une adresse mail renseignée |
4009 |
|
* - Le pétitionnaire principal doit avoir une adresse mail correcte |
4010 |
|
* Pour chaque vérification effectué un message d'erreur est ajouté si la |
4011 |
|
* condition n'est pas remplie. |
4012 |
|
* Renvoie le message d'erreur en sortie. |
4013 |
|
* |
4014 |
|
* @param string identifiant du dossier sur lequel les notifications ont échouée |
4015 |
|
* @return string |
4016 |
|
*/ |
4017 |
|
protected function get_info_notification_fail($dossier = null) { |
4018 |
|
// Utilise l'identifiant du dossier passé en paramètre et si aucun dossier n'a été récupéré |
4019 |
|
// utilise celui associé à l'instruction |
4020 |
|
if ($dossier == null) { |
4021 |
|
$dossier = $this->getVal('dossier'); |
4022 |
|
} |
4023 |
|
// Tableau contenant la liste des messages d'erreur |
4024 |
|
$errorMessage = array(); |
4025 |
|
// Récupère l'option de notification |
4026 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite($dossier); |
4027 |
|
$option_notification = $this->f->get_param_option_notification($collectivite_di); |
4028 |
|
if ($option_notification !== PORTAL && $option_notification !== 'mail') { |
4029 |
|
$errorMessage[] = __("L'option de notification option_notification doit obligatoirement être définie."); |
4030 |
|
} |
4031 |
|
// Récupère les informations du demandeurs principal |
4032 |
|
$infoPetitionnaire = $this->get_info_petitionnaire_principal_dossier($dossier); |
4033 |
|
// Vérifie si le pétitionnaire principal à bien la case "accepte les notification" cochée |
4034 |
|
if (isset($infoPetitionnaire['notification']) && $infoPetitionnaire['notification'] != 't') { |
4035 |
|
$errorMessage[] = __('Le pétitionnaire principal n\'accepte pas les notifications.'); |
4036 |
|
} |
4037 |
|
// Vérifie si l'adresse mail du pétitionnaire principale est renseignée |
4038 |
|
if (isset($infoPetitionnaire['courriel']) && ! empty($infoPetitionnaire['courriel'])) { |
4039 |
|
// Vérifie si le format de l'adresse mail est pas correct et, si ce n'est pas le cas, informe l'utilisateur |
4040 |
|
// qu'il doit le corriger avant de pouvoir ajouter l'nstruction |
4041 |
|
if (! $this->f->checkValidEmailAddress($infoPetitionnaire['courriel'])) { |
4042 |
|
$errorMessage[] = __('Le courriel du pétitionnaire principal n\'est pas correct : '). |
4043 |
|
$infoPetitionnaire['courriel']. |
4044 |
|
'.'; |
4045 |
|
} |
4046 |
|
} else { |
4047 |
|
// Si le courriel du pétitionnaire principal |
4048 |
|
$errorMessage[] = __('Le courriel du pétitionnaire principal n\'est pas renseigné.'); |
4049 |
|
} |
4050 |
|
|
4051 |
|
return $errorMessage; |
4052 |
|
} |
4053 |
|
|
4054 |
|
/** |
4055 |
|
* Méthode servant à vérifier si un dossier a été déposé sur |
4056 |
|
* le portail citoyen ou pas. |
4057 |
|
* La verification se fait via une requête sql dans laquelle |
4058 |
|
* on va chercher un dossier ayant pour id l'identifiant de |
4059 |
|
* dossier associé à l'instruction et pour lequel la demande |
4060 |
|
* associée la plus ancienne est une demande de création de |
4061 |
|
* dossier via portail |
4062 |
|
* |
4063 |
|
* @param string identifiant du dossier. Si non renseigné c'est le dossier |
4064 |
|
* associé à l'instruction qui est utilisé |
4065 |
|
* @return boolean|void true : dossier déposé via portail, false : dossier |
4066 |
|
* non déposé via portail et null : erreur de base de données. |
4067 |
|
*/ |
4068 |
|
protected function dossier_depose_sur_portail($dossier = null) { |
4069 |
|
if (empty($dossier)) { |
4070 |
|
$dossier = $this->getVal('dossier'); |
4071 |
|
} |
4072 |
|
$qres = $this->f->get_one_result_from_db_query( |
4073 |
|
sprintf( |
4074 |
|
'SELECT |
4075 |
|
dossier |
4076 |
|
FROM |
4077 |
|
%1$sdossier |
4078 |
|
-- Récuperation de la première demande associée au dossier |
4079 |
|
LEFT JOIN ( |
4080 |
|
SELECT |
4081 |
|
demande, |
4082 |
|
dossier_instruction, |
4083 |
|
source_depot |
4084 |
|
FROM |
4085 |
|
%1$sdemande |
4086 |
|
WHERE |
4087 |
|
dossier_instruction = \'%2$s\' |
4088 |
|
ORDER BY |
4089 |
|
demande ASC |
4090 |
|
LIMIT 1 |
4091 |
|
) AS demande |
4092 |
|
ON dossier.dossier = demande.dossier_instruction |
4093 |
|
WHERE |
4094 |
|
dossier.dossier = \'%2$s\' |
4095 |
|
AND demande.source_depot = \'portal\'', |
4096 |
|
DB_PREFIXE, |
4097 |
|
$this->f->db->escapeSimple($dossier) |
4098 |
|
), |
4099 |
|
array( |
4100 |
|
"origin" => __METHOD__, |
4101 |
|
"force_return" => true, |
4102 |
|
) |
4103 |
|
); |
4104 |
|
if ($qres["code"] !== "OK") { |
4105 |
|
$this->addToMessage(__('Erreur : La vérification du mode de dépôt du dossier à échoué')); |
4106 |
|
return; |
4107 |
} |
} |
4108 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
// Si on a un résultat c'est que le dossier a été déposé via le portail |
4109 |
// application des regles sur le courrier + delai |
return ! empty($qres["result"]); |
4110 |
if(preg_match("/date_evenement/",$row['regle_date_limite'])){ |
} |
4111 |
$valF['date_limite']= $this->regle($row['regle_date_limite'], 'regle_date_limite'); |
|
4112 |
} |
public function is_service_notifiable() { |
4113 |
if(preg_match("/date_evenement/",$row['regle_date_complet'])){ |
$evenement = $this->get_inst_evenement($this->getVal('evenement')); |
4114 |
$valF['date_complet']= $this->regle($row['regle_date_complet'], 'regle_date_complet'); |
|
4115 |
} |
// Si l'instruction a une édition non finalisé quel que soit |
4116 |
if(preg_match("/date_evenement/",$row['regle_date_dernier_depot'])){ |
// le type de notification, il n'est pas notifiable |
4117 |
$valF['date_dernier_depot']= $this->regle($row['regle_date_dernier_depot'], 'regle_date_dernier_depot'); |
if ($this->has_an_edition() === true) { |
4118 |
} |
if ($this->is_unfinalizable_without_bypass() === false) { |
4119 |
if(preg_match("/date_evenement/",$row['regle_date_notification_delai'])){ |
return false; |
|
$valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai'], 'regle_date_notification_delai'); |
|
|
} |
|
|
if(preg_match("/date_evenement/",$row['regle_date_decision'])){ |
|
|
$valF['date_decision']= $this->regle($row['regle_date_decision'], 'regle_date_decision'); |
|
|
} |
|
|
if(preg_match("/date_evenement/",$row['regle_date_rejet'])){ |
|
|
$valF['date_rejet']= $this->regle($row['regle_date_rejet'], 'regle_date_rejet'); |
|
|
} |
|
|
if(preg_match("/date_evenement/",$row['regle_date_validite'])){ |
|
|
$valF['date_validite']= $this->regle($row['regle_date_validite'], 'regle_date_validite'); |
|
|
} |
|
|
if(preg_match("/date_evenement/",$row['regle_date_chantier'])){ |
|
|
$valF['date_chantier']= $this->regle($row['regle_date_chantier'], 'regle_date_chantier'); |
|
|
} |
|
|
if(preg_match("/date_evenement/",$row['regle_date_achevement'])){ |
|
|
$valF['date_achevement']= $this->regle($row['regle_date_achevement'], 'regle_date_achevement'); |
|
|
} |
|
|
if(preg_match("/date_evenement/",$row['regle_date_conformite'])){ |
|
|
$valF['date_conformite']= $this->regle($row['regle_date_conformite'], 'regle_date_conformite'); |
|
|
} |
|
|
if(preg_match("/date_evenement/",$row['regle_date_cloture_instruction'])){ |
|
|
$valF['date_cloture_instruction']= $this->regle($row['regle_date_cloture_instruction'], 'regle_date_cloture_instruction'); |
|
|
} |
|
|
if(preg_match("/date_evenement/",$row['regle_date_premiere_visite'])){ |
|
|
$valF['date_premiere_visite']= $this->regle($row['regle_date_premiere_visite'], 'regle_date_premiere_visite'); |
|
|
} |
|
|
if(preg_match("/date_evenement/",$row['regle_date_derniere_visite'])){ |
|
|
$valF['date_derniere_visite']= $this->regle($row['regle_date_derniere_visite'], 'regle_date_derniere_visite'); |
|
|
} |
|
|
if(preg_match("/date_evenement/",$row['regle_date_contradictoire'])){ |
|
|
$valF['date_contradictoire']= $this->regle($row['regle_date_contradictoire'], 'regle_date_contradictoire'); |
|
|
} |
|
|
if(preg_match("/date_evenement/",$row['regle_date_retour_contradictoire'])){ |
|
|
$valF['date_retour_contradictoire']= $this->regle($row['regle_date_retour_contradictoire'], 'regle_date_retour_contradictoire'); |
|
4120 |
} |
} |
4121 |
if(preg_match("/date_evenement/",$row['regle_date_ait'])){ |
} |
4122 |
$valF['date_ait']= $this->regle($row['regle_date_ait'], 'regle_date_ait'); |
// Vérifie si la notification des tiers est active pour l'évènement |
4123 |
|
return $this->get_boolean_from_pgsql_value($evenement->getVal('notification_service')); |
4124 |
|
} |
4125 |
|
|
4126 |
|
public function is_tiers_notifiable() { |
4127 |
|
$evenement = $this->get_inst_evenement($this->getVal('evenement')); |
4128 |
|
|
4129 |
|
// Si l'instruction a une édition non finalisé quel que soit |
4130 |
|
// le type de notification, il n'est pas notifiable |
4131 |
|
if ($this->has_an_edition() === true) { |
4132 |
|
if ($this->is_unfinalizable_without_bypass() === false) { |
4133 |
|
return false; |
4134 |
} |
} |
4135 |
if(preg_match("/date_evenement/",$row['regle_date_transmission_parquet'])){ |
} |
4136 |
$valF['date_transmission_parquet']= $this->regle($row['regle_date_transmission_parquet'], 'regle_date_transmission_parquet'); |
// Vérifie si la notification des tiers est active pour l'évènement |
4137 |
|
return ! empty($evenement->getVal('notification_tiers')); |
4138 |
|
} |
4139 |
|
|
4140 |
|
/** |
4141 |
|
* Méthode permettant de savoir si une instruction peut |
4142 |
|
* être notifiée manuellement selon les différents types |
4143 |
|
* de notification. |
4144 |
|
* |
4145 |
|
* Si l'instruction a une édition non finalisée alors elle n'est pas |
4146 |
|
* manuellement notifiable. |
4147 |
|
* Si l'instruction est associé à un événement de notification pour |
4148 |
|
* lequel un retour signature est recquis, elle n'est notifiable que |
4149 |
|
* si la date de retour de signature est remplie. |
4150 |
|
* Par défaut si le type de notification n'est pas connu alors l'instruction |
4151 |
|
* n'est pas notifiable. |
4152 |
|
* Pour tous les autres cas l'instruction est manuellement notifiable. |
4153 |
|
* |
4154 |
|
* @return boolean true : notifiable | false : non notifiable |
4155 |
|
*/ |
4156 |
|
public function is_notifiable_by_task_manual() { |
4157 |
|
$ev = $this->get_inst_evenement($this->getVal('evenement')); |
4158 |
|
|
4159 |
|
// Si l'instruction a une édition non finalisé quel que soit |
4160 |
|
// le type de notification, il n'est pas notifiable |
4161 |
|
if ($this->has_an_edition() === true) { |
4162 |
|
if ($this->is_unfinalizable_without_bypass() === false) { |
4163 |
|
return false; |
4164 |
} |
} |
4165 |
if ($row['regle_donnees_techniques1'] !== '') { |
} |
4166 |
$valF_dt[$row['cible_regle_donnees_techniques1']] = $this->regle($row['regle_donnees_techniques1'], 'regle_donnees_techniques1'); |
|
4167 |
|
// Gestion des différents cas selon la valeur du champs notification |
4168 |
|
if ($ev->getVal('notification') == 'notification_manuelle' || |
4169 |
|
$ev->getVal('notification') == 'notification_manuelle_annexe' || |
4170 |
|
$ev->getVal('notification') == 'notification_automatique' |
4171 |
|
) { |
4172 |
|
return true; |
4173 |
|
} elseif (($ev->getVal('notification') == 'notification_auto_signature_requise' || |
4174 |
|
$ev->getVal('notification') == 'notification_manuelle_signature_requise' || |
4175 |
|
$ev->getVal('notification') == 'notification_manuelle_annexe_signature_requise') && |
4176 |
|
$this->getVal('date_retour_signature') != null && |
4177 |
|
$this->getVal('date_retour_signature') != '' |
4178 |
|
) { |
4179 |
|
return true ; |
4180 |
|
} |
4181 |
|
return false; |
4182 |
|
} |
4183 |
|
|
4184 |
|
/** |
4185 |
|
* Crée une instance de notification et une tache notification_instruction de catégorie portal |
4186 |
|
* pour le demandeur principal. |
4187 |
|
* |
4188 |
|
* @return boolean true si le traitement à réussi |
4189 |
|
*/ |
4190 |
|
protected function notifier_demandeur_principal_via_portal() { |
4191 |
|
$this->begin_treatment(__METHOD__); |
4192 |
|
$message = ''; |
4193 |
|
// Récupération des informations concernant le demandeur |
4194 |
|
$dossier = $this->getVal('dossier'); |
4195 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite($dossier); |
4196 |
|
$demandeur = $this->get_demandeurs_notifiable( |
4197 |
|
$dossier, |
4198 |
|
true |
4199 |
|
); |
4200 |
|
if ($demandeur !== array()) { |
4201 |
|
$destinataire = array_values($demandeur); |
4202 |
|
// Ajout de la notif et récupération de son id |
4203 |
|
$idNotification = $this->ajouter_notification( |
4204 |
|
$this->getVal($this->clePrimaire), |
4205 |
|
$this->f->get_connected_user_login_name(), |
4206 |
|
$destinataire[0], |
4207 |
|
$collectivite_di, |
4208 |
|
array(), |
4209 |
|
true |
4210 |
|
); |
4211 |
|
if ($idNotification === false) { |
4212 |
|
return $this->end_treatment(__METHOD__, false); |
4213 |
} |
} |
4214 |
if ($row['regle_donnees_techniques2'] !== '') { |
// Création de la tâche en lui donnant l'id de la notification |
4215 |
$valF_dt[$row['cible_regle_donnees_techniques2']] = $this->regle($row['regle_donnees_techniques2'], 'regle_donnees_techniques2'); |
$notification_by_task = $this->notification_by_task($idNotification, $dossier, PORTAL); |
4216 |
|
if ($notification_by_task === false) { |
4217 |
|
$this->addToMessage( |
4218 |
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
4219 |
|
); |
4220 |
|
return $this->end_treatment(__METHOD__, false); |
4221 |
} |
} |
4222 |
if ($row['regle_donnees_techniques3'] !== '') { |
$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."))); |
4223 |
$valF_dt[$row['cible_regle_donnees_techniques3']] = $this->regle($row['regle_donnees_techniques3'], 'regle_donnees_techniques3'); |
return $this->end_treatment(__METHOD__, true); |
4224 |
|
} |
4225 |
|
$this->addToMessage( __("Le demandeur principal n'est pas notifiable.")); |
4226 |
|
return $this->end_treatment(__METHOD__, false); |
4227 |
|
} |
4228 |
|
|
4229 |
|
public function notification_by_task($object_id, $dossier, $category = null, $type = null) { |
4230 |
|
// Si le type n'est pas correctement spécifié, alors il est calculé |
4231 |
|
if ($type !== 'notification_recepisse' |
4232 |
|
&& $type !== 'notification_instruction' |
4233 |
|
&& $type !== 'notification_decision' |
4234 |
|
&& $type !== 'notification_service_consulte' |
4235 |
|
&& $type !== 'notification_tiers_consulte' |
4236 |
|
&& $type !== 'notification_depot_demat' |
4237 |
|
&& $type !== 'notification_commune' |
4238 |
|
&& $type !== 'notification_signataire') { |
4239 |
|
// |
4240 |
|
$type = 'notification_instruction'; |
4241 |
|
// Vérifie si l'instruction est un récépissé |
4242 |
|
if ($this->is_instruction_recepisse()) { |
4243 |
|
$type = 'notification_recepisse'; |
4244 |
|
|
4245 |
|
} |
4246 |
|
// Vérifie si l'instruction est une décision |
4247 |
|
if ($type !== 'notification_recepisse') { |
4248 |
|
$avis_decision = $this->getVal('avis_decision') !== null ? $this->getVal('avis_decision') : $this->valF['avis_decision']; |
4249 |
|
if ($avis_decision !== null && $avis_decision !== '') { |
4250 |
|
$type = 'notification_decision'; |
4251 |
|
} |
4252 |
} |
} |
4253 |
if ($row['regle_donnees_techniques4'] !== '') { |
} |
4254 |
$valF_dt[$row['cible_regle_donnees_techniques4']] = $this->regle($row['regle_donnees_techniques4'], 'regle_donnees_techniques4'); |
// Préparation des valeurs de la tâche |
4255 |
|
$task_val = array( |
4256 |
|
'type' => $type, |
4257 |
|
'object_id' => $object_id, |
4258 |
|
'dossier' => $dossier, |
4259 |
|
'category' => $category, |
4260 |
|
); |
4261 |
|
// Préparation de la tache de notification |
4262 |
|
$inst_task = $this->f->get_inst__om_dbform(array( |
4263 |
|
"obj" => "task", |
4264 |
|
"idx" => 0, |
4265 |
|
)); |
4266 |
|
|
4267 |
|
$add_task = $inst_task->add_task(array('val' => $task_val)); |
4268 |
|
if ($add_task === false) { |
4269 |
|
$this->addToLog( |
4270 |
|
sprintf( |
4271 |
|
'%s(): %s %s : %s', |
4272 |
|
__METHOD__, |
4273 |
|
__('Echec de l\'ajout de la tâche de notification.'), |
4274 |
|
__('Paramétrage de la tâche'), |
4275 |
|
var_export($task_val, true) |
4276 |
|
), |
4277 |
|
DEBUG_MODE |
4278 |
|
); |
4279 |
|
return false; |
4280 |
|
} |
4281 |
|
|
4282 |
|
return true; |
4283 |
|
} |
4284 |
|
|
4285 |
|
/** |
4286 |
|
* Cette méthode permet de savoir si l'instruction est une instruction |
4287 |
|
* de recepisse (instruction lié à l'ajout du dossier). |
4288 |
|
* |
4289 |
|
* Pour cela, on récupère la liste des actions qui ont menées à la création |
4290 |
|
* de l'instruction. Si une de ces actions est lié à un objet "demande" on |
4291 |
|
* en deduis que c'est l'ajout d'une demande qui a déclenché la création de |
4292 |
|
* l'instruction et donc qu'il s'agit d'un recepisse. |
4293 |
|
* |
4294 |
|
* @return boolean |
4295 |
|
*/ |
4296 |
|
protected function is_instruction_recepisse() { |
4297 |
|
// Récupère la liste des actions qui ont mené à la création de |
4298 |
|
// l'instruction |
4299 |
|
$trace = debug_backtrace(); |
4300 |
|
// Parcours la liste des actions et si une de ces actions est lié |
4301 |
|
// à la classe demande on cosidère que l'instruction est un recepisse |
4302 |
|
foreach ($trace as $key => $value) { |
4303 |
|
if (isset($trace[$key]['class']) === true |
4304 |
|
&& empty($trace[$key]['class']) === false) { |
4305 |
|
if (strtolower($trace[$key]['class']) === 'demande') { |
4306 |
|
return true; |
4307 |
|
} |
4308 |
} |
} |
4309 |
if ($row['regle_donnees_techniques5'] !== '') { |
} |
4310 |
$valF_dt[$row['cible_regle_donnees_techniques5']] = $this->regle($row['regle_donnees_techniques5'], 'regle_donnees_techniques5'); |
return false; |
4311 |
|
} |
4312 |
|
|
4313 |
|
/** |
4314 |
|
* A partir des informations passée en argument ajoute un nouvel élément |
4315 |
|
* dans la table instruction_notification. |
4316 |
|
* Avant l'ajout vérifie en utilisant l'id de la collectivité passée en |
4317 |
|
* paramètre si le paramétrage attendus est ok. |
4318 |
|
* Ajoute également un nouvel élement dans instruction_notification_document |
4319 |
|
* si l'instruction possède une lettretype. |
4320 |
|
* Si un identifiant d'une instruction annexe est donnée ajoute un deuxième |
4321 |
|
* élement dans la table instruction_notification_document qui correspondra |
4322 |
|
* à l'annexe de la notification. |
4323 |
|
* |
4324 |
|
* @param integer identifiant de l'instruction notifiée |
4325 |
|
* @param string information concernant l'emetteur |
4326 |
|
* @param array tableau contenant 2 entrées |
4327 |
|
* - destinatire : nom, prenom ou raison sociale, dénomination et courriel |
4328 |
|
* - courriel : adresse mail de la personne à notifier |
4329 |
|
* @param integer identifiant de la collectivité permettant de récupèrer les |
4330 |
|
* paramètres à valider |
4331 |
|
* @param boolean indique si la notification est automatique ou manuelle |
4332 |
|
* @param integer identifiant d'une instruction dont l'édition sera annexé |
4333 |
|
* à la notification |
4334 |
|
* |
4335 |
|
* @return integer|boolean identifiant de la notification créée si le traitement |
4336 |
|
* a réussie, false sinon. |
4337 |
|
*/ |
4338 |
|
protected function ajouter_notification( |
4339 |
|
$idInstruction, |
4340 |
|
$emetteur, |
4341 |
|
$destinataire, |
4342 |
|
$collectiviteId, |
4343 |
|
$annexes = array(), |
4344 |
|
$demandeAuto = false, |
4345 |
|
$statut = 'en cours d\'envoi', |
4346 |
|
$commentaire = 'Notification en cours de traitement' |
4347 |
|
) { |
4348 |
|
// Vérification que les paramètres nécessaires à l'envoi de la notification existe avant |
4349 |
|
// de créer la notification |
4350 |
|
if (! $this->is_parametrage_notification_correct($collectiviteId)) { |
4351 |
|
$msgErreur = __("Erreur de paramétrage. L'url d'accès au(x) document(s) notifié(s) n'est pas paramétrée."); |
4352 |
|
$this->addToMessage($msgErreur); |
4353 |
|
$this->addToLog( |
4354 |
|
sprintf('%s() : %s', __METHOD__, $msgErreur), |
4355 |
|
DEBUG_MODE |
4356 |
|
); |
4357 |
|
return false; |
4358 |
|
} |
4359 |
|
// Préparation de la notification |
4360 |
|
$inst_notif = $this->f->get_inst__om_dbform(array( |
4361 |
|
"obj" => "instruction_notification", |
4362 |
|
"idx" => "]", |
4363 |
|
)); |
4364 |
|
$notif_val = array( |
4365 |
|
'instruction_notification' => null, |
4366 |
|
'instruction' => $idInstruction, |
4367 |
|
'automatique' => $demandeAuto, |
4368 |
|
'emetteur' => $emetteur, |
4369 |
|
'date_envoi' => null, |
4370 |
|
'destinataire' => $destinataire['destinataire'], |
4371 |
|
'courriel' => $destinataire['courriel'], |
4372 |
|
'date_premier_acces' => null, |
4373 |
|
'statut' => $statut, |
4374 |
|
'commentaire' => $commentaire |
4375 |
|
); |
4376 |
|
|
4377 |
|
// Création de la notification |
4378 |
|
$add_notif = $inst_notif->ajouter($notif_val); |
4379 |
|
if ($add_notif === false) { |
4380 |
|
$this->addToMessage(__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).")); |
4381 |
|
$this->addToLog( |
4382 |
|
sprintf( |
4383 |
|
'%s() : %s %s : %s', |
4384 |
|
__METHOD__, |
4385 |
|
__("Echec de l'ajout de la notification en base de données."), |
4386 |
|
__('Paramétrage de la notification'), |
4387 |
|
var_export($notif_val, true) |
4388 |
|
), |
4389 |
|
DEBUG_MODE |
4390 |
|
); |
4391 |
|
return false; |
4392 |
|
} |
4393 |
|
|
4394 |
|
// Si il y a une lettretype finalisé stockage de la clé d'accès au documents |
4395 |
|
if ($this->evenement_has_an_edition($this->getVal('evenement')) === true) { |
4396 |
|
$add_notif_doc = $this->ajouter_notification_document( |
4397 |
|
$inst_notif->getVal($inst_notif->clePrimaire), |
4398 |
|
$this->getVal($this->clePrimaire), |
4399 |
|
'instruction' |
4400 |
|
); |
4401 |
|
if ($add_notif_doc === false) { |
4402 |
|
$this->addToMessage(__("Erreur lors de la génération de la notification du document.")); |
4403 |
|
return false; |
4404 |
} |
} |
4405 |
if ($row['regle_dossier_instruction_type'] !== '') { |
} |
4406 |
$valF['dossier_instruction_type'] = $this->regle($row['regle_dossier_instruction_type'], 'regle_dossier_instruction_type'); |
// Si une annexe a été choisie stockage de la clé d'accès à l'annexe |
4407 |
|
if (! empty($annexes) && is_array($annexes)) { |
4408 |
|
$add_notif_annexe = $this->ajouter_notification_document_multiple( |
4409 |
|
$inst_notif->getVal($inst_notif->clePrimaire), |
4410 |
|
$annexes |
4411 |
|
); |
4412 |
|
if ($add_notif_annexe === false) { |
4413 |
|
$this->addToMessage(__("Erreur lors de la génération de la notification de l'annexe.")); |
4414 |
|
return false; |
4415 |
} |
} |
4416 |
} |
} |
4417 |
// Si des valeurs de données techniques ont été calculées alors on met à jour l'enregistrement |
|
4418 |
if ($valF_dt != "") { |
// Renvoie l'id de la nouvelle instance de instruction_notification |
4419 |
$dt_id = $this->getDonneesTechniques(); |
return $inst_notif->getVal($inst_notif->clePrimaire); |
4420 |
// On met à jour le dossier |
} |
4421 |
$cle = " donnees_techniques='".$dt_id."'"; |
|
4422 |
$res1 = $db->autoExecute(DB_PREFIXE.'donnees_techniques', $valF_dt, DB_AUTOQUERY_UPDATE, $cle); |
/** |
4423 |
$this->addToLog("triggerajouterapres(): db->autoexecute(\"".DB_PREFIXE."donnees_techniques\", ".print_r($valF_dt, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
* Pour chaque élément du tableau passé en paramètre ajoute une nouvelle |
4424 |
if (database::isError($res1)) { |
* instance dans la table instruction_notification_document lié a la |
4425 |
die($res->getMessage()); |
* notification dont l'id est passé en paramètre. |
4426 |
|
* |
4427 |
|
* @param array tableau contenant les informations nécessaires pour créer les annexes |
4428 |
|
* |
4429 |
|
* @return integer|boolean identifiant de la notification créée si le traitement |
4430 |
|
* a réussie, false sinon. |
4431 |
|
*/ |
4432 |
|
protected function ajouter_notification_document_multiple($idNotification, $listeDocument) { |
4433 |
|
foreach ($listeDocument as $paramDoc) { |
4434 |
|
if (! $this->ajouter_notification_document($idNotification, $paramDoc['id'], $paramDoc['tableDocument'], $paramDoc['isAnnexe'])) { |
4435 |
|
$this->addToMessage(__("Erreur lors de la génération des documents à notifier.")); |
4436 |
|
return false; |
4437 |
} |
} |
|
// Affichage d'informations à l'utilisateur |
|
|
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
|
4438 |
} |
} |
4439 |
// Si des valeurs ont été calculées alors on met à jour l'enregistrement |
return true; |
4440 |
if ($valF != "") { |
} |
4441 |
// On met à jour le dossier |
|
4442 |
$cle = " dossier='".$this->valF['dossier']."'"; |
/** |
4443 |
$res1 = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle); |
* Ajoute un élément dans la table instruction_notification_document en utilisant |
4444 |
$this->addToLog("triggermodifierapres(): db->autoexecute(\"".DB_PREFIXE."dossier\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
* les éléments fourni en paramètre |
4445 |
if (database::isError($res1)) { |
* |
4446 |
die($res->getMessage()); |
* @param integer $idNotification : id de la notification à laquelle on associe le document |
4447 |
|
* @param integer $idDocument : id de l'objet auquel est rattaché le document |
4448 |
|
* @param string $tableDocument : nom de la table a laquelle est rattaché le document |
4449 |
|
* @param boolean $isAnnexe : indique si le document est une annexe ou pas |
4450 |
|
* |
4451 |
|
* @return boolean indique si le traitement a réussi |
4452 |
|
*/ |
4453 |
|
protected function ajouter_notification_document($idNotification, $idDocument, $tableDocument, $isAnnexe = false) { |
4454 |
|
$inst_notif_doc = $this->f->get_inst__om_dbform(array( |
4455 |
|
"obj" => "instruction_notification_document", |
4456 |
|
"idx" => "]", |
4457 |
|
)); |
4458 |
|
// l'attribut instruction doit obligatoirement être renseigné |
4459 |
|
// pour éviter toutes confusion avec d'autres instruction l'id |
4460 |
|
// 0 est donné au document n'appartenant pas aux instructions |
4461 |
|
$notif_doc_val = array( |
4462 |
|
'instruction_notification_document' => null, |
4463 |
|
'instruction_notification' => $idNotification, |
4464 |
|
'instruction' => $tableDocument == 'instruction' ? $idDocument : 0, |
4465 |
|
'document_type' => $tableDocument, |
4466 |
|
'document_id' => $idDocument, |
4467 |
|
'cle' => $this->getCleAccesDocument(), |
4468 |
|
'annexe' => $isAnnexe |
4469 |
|
); |
4470 |
|
|
4471 |
|
$add_notif_doc = $inst_notif_doc->ajouter($notif_doc_val); |
4472 |
|
if ($add_notif_doc === false) { |
4473 |
|
$this->addToLog( |
4474 |
|
sprintf( |
4475 |
|
'%s() : %s %s : %s', |
4476 |
|
__METHOD__, |
4477 |
|
__('Echec de l\'ajout du paramétrage du document notifié en base de données.'), |
4478 |
|
__('Paramétrage du document'), |
4479 |
|
var_export($notif_doc_val, true) |
4480 |
|
), |
4481 |
|
DEBUG_MODE |
4482 |
|
); |
4483 |
|
return false; |
4484 |
|
} |
4485 |
|
return true; |
4486 |
|
} |
4487 |
|
|
4488 |
|
/** |
4489 |
|
* Vérifie si le paramétrage de la notification des demandeurs est correct. |
4490 |
|
* |
4491 |
|
* @param integer identifiant de la collectivité |
4492 |
|
* @return boolean |
4493 |
|
*/ |
4494 |
|
protected function is_parametrage_notification_correct($collectiviteId) { |
4495 |
|
$categorie = $this->f->get_param_option_notification($collectiviteId); |
4496 |
|
$urlAccesNotif = $this->f->get_parametre_notification_url_acces($collectiviteId); |
4497 |
|
if ($categorie === 'mail' && $urlAccesNotif === null) { |
4498 |
|
return false; |
4499 |
|
} |
4500 |
|
return true; |
4501 |
|
} |
4502 |
|
|
4503 |
|
/** |
4504 |
|
* TRIGGER - triggermodifierapres. |
4505 |
|
* |
4506 |
|
* @return boolean |
4507 |
|
*/ |
4508 |
|
function triggermodifierapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
4509 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
4510 |
|
$data = array('val' => &$val, 'id' => $id); |
4511 |
|
$this->f->module_manager->run_hooks('triggermodifierapres_pre', $this, $data); |
4512 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite($val['dossier']); |
4513 |
|
$message = ''; |
4514 |
|
|
4515 |
|
// Définit si le dossier d'instruction doit être mis à jour |
4516 |
|
$update_dossier = true; |
4517 |
|
// Les actions de mise à jour des dates ne doivent pas appliquer |
4518 |
|
// l'action de l'événement et donc ne pas mettre à jour le dossier |
4519 |
|
if ($this->getParameter("maj") == 125 |
4520 |
|
|| $this->getParameter("maj") == 170 |
4521 |
|
|| $this->getParameter("maj") == 175) { |
4522 |
|
$update_dossier = false; |
4523 |
|
} |
4524 |
|
|
4525 |
|
// Traitement en cas de mise à jour du dossier |
4526 |
|
if ($update_dossier === true) { |
4527 |
|
/** |
4528 |
|
* L'objectif ici est d'effectuer les recalculs de date dans le dossier |
4529 |
|
* si la date de l'evenement est modifiee |
4530 |
|
*/ |
4531 |
|
// Initialisation |
4532 |
|
$valF = array(); |
4533 |
|
$valF_dt = array(); |
4534 |
|
// Initialisation du type d'événement |
4535 |
|
$type_evmt = ""; |
4536 |
|
// Récupération de l'action correspondante à l'événement |
4537 |
|
$evenement = $this->f->get_inst__om_dbform(array( |
4538 |
|
"obj" => "evenement", |
4539 |
|
"idx" => $this->valF['evenement'] |
4540 |
|
)); |
4541 |
|
|
4542 |
|
// Récupération des paramètres de l'action |
4543 |
|
// TODO : remplacer cette requête par l'instanciation de l'action |
4544 |
|
$qres = $this->f->get_all_results_from_db_query( |
4545 |
|
sprintf( |
4546 |
|
'SELECT |
4547 |
|
* |
4548 |
|
FROM |
4549 |
|
%1$saction |
4550 |
|
WHERE |
4551 |
|
action = \'%2$s\'', |
4552 |
|
DB_PREFIXE, |
4553 |
|
$this->f->db->escapeSimple($evenement->getVal('action')) |
4554 |
|
), |
4555 |
|
array( |
4556 |
|
"origin" => __METHOD__ |
4557 |
|
) |
4558 |
|
); |
4559 |
|
foreach ($qres['result'] as $row) { |
4560 |
|
// application des regles sur le courrier + delai |
4561 |
|
if(preg_match("/date_evenement/",$row['regle_date_limite'])){ |
4562 |
|
$valF['date_limite']= $this->regle($row['regle_date_limite'], 'regle_date_limite'); |
4563 |
|
} |
4564 |
|
if(preg_match("/date_evenement/",$row['regle_date_complet'])){ |
4565 |
|
$valF['date_complet']= $this->regle($row['regle_date_complet'], 'regle_date_complet'); |
4566 |
|
} |
4567 |
|
if(preg_match("/date_evenement/",$row['regle_date_dernier_depot'])){ |
4568 |
|
$valF['date_dernier_depot']= $this->regle($row['regle_date_dernier_depot'], 'regle_date_dernier_depot'); |
4569 |
|
} |
4570 |
|
if(preg_match("/date_evenement/",$row['regle_date_notification_delai'])){ |
4571 |
|
$valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai'], 'regle_date_notification_delai'); |
4572 |
|
} |
4573 |
|
if(preg_match("/date_evenement/",$row['regle_date_decision'])){ |
4574 |
|
$valF['date_decision']= $this->regle($row['regle_date_decision'], 'regle_date_decision'); |
4575 |
|
} |
4576 |
|
if(preg_match("/date_evenement/",$row['regle_date_rejet'])){ |
4577 |
|
$valF['date_rejet']= $this->regle($row['regle_date_rejet'], 'regle_date_rejet'); |
4578 |
|
} |
4579 |
|
if(preg_match("/date_evenement/",$row['regle_date_validite'])){ |
4580 |
|
$valF['date_validite']= $this->regle($row['regle_date_validite'], 'regle_date_validite'); |
4581 |
|
} |
4582 |
|
if(preg_match("/date_evenement/",$row['regle_date_chantier'])){ |
4583 |
|
$valF['date_chantier']= $this->regle($row['regle_date_chantier'], 'regle_date_chantier'); |
4584 |
|
} |
4585 |
|
if(preg_match("/date_evenement/",$row['regle_date_achevement'])){ |
4586 |
|
$valF['date_achevement']= $this->regle($row['regle_date_achevement'], 'regle_date_achevement'); |
4587 |
|
} |
4588 |
|
if(preg_match("/date_evenement/",$row['regle_date_conformite'])){ |
4589 |
|
$valF['date_conformite']= $this->regle($row['regle_date_conformite'], 'regle_date_conformite'); |
4590 |
|
} |
4591 |
|
if(preg_match("/date_evenement/",$row['regle_date_cloture_instruction'])){ |
4592 |
|
$valF['date_cloture_instruction']= $this->regle($row['regle_date_cloture_instruction'], 'regle_date_cloture_instruction'); |
4593 |
|
} |
4594 |
|
if(preg_match("/date_evenement/",$row['regle_date_premiere_visite'])){ |
4595 |
|
$valF['date_premiere_visite']= $this->regle($row['regle_date_premiere_visite'], 'regle_date_premiere_visite'); |
4596 |
|
} |
4597 |
|
if(preg_match("/date_evenement/",$row['regle_date_derniere_visite'])){ |
4598 |
|
$valF['date_derniere_visite']= $this->regle($row['regle_date_derniere_visite'], 'regle_date_derniere_visite'); |
4599 |
|
} |
4600 |
|
if(preg_match("/date_evenement/",$row['regle_date_contradictoire'])){ |
4601 |
|
$valF['date_contradictoire']= $this->regle($row['regle_date_contradictoire'], 'regle_date_contradictoire'); |
4602 |
|
} |
4603 |
|
if(preg_match("/date_evenement/",$row['regle_date_retour_contradictoire'])){ |
4604 |
|
$valF['date_retour_contradictoire']= $this->regle($row['regle_date_retour_contradictoire'], 'regle_date_retour_contradictoire'); |
4605 |
|
} |
4606 |
|
if(preg_match("/date_evenement/",$row['regle_date_ait'])){ |
4607 |
|
$valF['date_ait']= $this->regle($row['regle_date_ait'], 'regle_date_ait'); |
4608 |
|
} |
4609 |
|
if(preg_match("/date_evenement/",$row['regle_date_transmission_parquet'])){ |
4610 |
|
$valF['date_transmission_parquet']= $this->regle($row['regle_date_transmission_parquet'], 'regle_date_transmission_parquet'); |
4611 |
|
} |
4612 |
|
if ($row['regle_donnees_techniques1'] !== '') { |
4613 |
|
$valF_dt[$row['cible_regle_donnees_techniques1']] = $this->regle($row['regle_donnees_techniques1'], 'regle_donnees_techniques1'); |
4614 |
|
} |
4615 |
|
if ($row['regle_donnees_techniques2'] !== '') { |
4616 |
|
$valF_dt[$row['cible_regle_donnees_techniques2']] = $this->regle($row['regle_donnees_techniques2'], 'regle_donnees_techniques2'); |
4617 |
|
} |
4618 |
|
if ($row['regle_donnees_techniques3'] !== '') { |
4619 |
|
$valF_dt[$row['cible_regle_donnees_techniques3']] = $this->regle($row['regle_donnees_techniques3'], 'regle_donnees_techniques3'); |
4620 |
|
} |
4621 |
|
if ($row['regle_donnees_techniques4'] !== '') { |
4622 |
|
$valF_dt[$row['cible_regle_donnees_techniques4']] = $this->regle($row['regle_donnees_techniques4'], 'regle_donnees_techniques4'); |
4623 |
|
} |
4624 |
|
if ($row['regle_donnees_techniques5'] !== '') { |
4625 |
|
$valF_dt[$row['cible_regle_donnees_techniques5']] = $this->regle($row['regle_donnees_techniques5'], 'regle_donnees_techniques5'); |
4626 |
|
} |
4627 |
|
if ($row['regle_dossier_instruction_type'] !== '') { |
4628 |
|
$valF['dossier_instruction_type'] = $this->regle($row['regle_dossier_instruction_type'], 'regle_dossier_instruction_type'); |
4629 |
|
} |
4630 |
|
} |
4631 |
|
// Si des valeurs de données techniques ont été calculées alors on met à jour l'enregistrement |
4632 |
|
if (count($valF_dt) > 0) { |
4633 |
|
$dt_id = $this->getDonneesTechniques(); |
4634 |
|
// On met à jour le dossier |
4635 |
|
$cle = " donnees_techniques='".$dt_id."'"; |
4636 |
|
$res1 = $this->f->db->autoExecute(DB_PREFIXE.'donnees_techniques', $valF_dt, DB_AUTOQUERY_UPDATE, $cle); |
4637 |
|
$this->addToLog( |
4638 |
|
__METHOD__."(): db->autoexecute(\"".DB_PREFIXE."donnees_techniques\", ".print_r($valF_dt, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", |
4639 |
|
VERBOSE_MODE |
4640 |
|
); |
4641 |
|
$this->f->isDatabaseError($res1); |
4642 |
|
// Affichage d'informations à l'utilisateur |
4643 |
|
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$this->f->db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
4644 |
|
} |
4645 |
|
// Si des valeurs ont été calculées alors on met à jour l'enregistrement |
4646 |
|
if (count($valF) > 0) { |
4647 |
|
$inst_dossier = $this->f->get_inst__om_dbform(array( |
4648 |
|
"obj" => "dossier", |
4649 |
|
"idx" => $this->valF['dossier'], |
4650 |
|
)); |
4651 |
|
$valF['instruction'] = $id; |
4652 |
|
$valF['crud'] = 'update'; |
4653 |
|
$update_by_instruction = $inst_dossier->update_by_instruction($valF); |
4654 |
|
if ($update_by_instruction === false) { |
4655 |
|
$this->cleanMessage(); |
4656 |
|
$this->addToMessage(sprintf('%s %s', __("Une erreur s'est produite lors de la mise à jour du dossier d'instruction."), __("Veuillez contacter votre administrateur."))); |
4657 |
|
return false; |
4658 |
|
} |
4659 |
|
// Affichage d'informations à l'utilisateur |
4660 |
|
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$this->f->db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
4661 |
} |
} |
|
// Affichage d'informations à l'utilisateur |
|
|
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
|
4662 |
} |
} |
4663 |
|
|
4664 |
|
// Par défaut les instructions à ajouter suite à la saisie d'une date |
4665 |
|
// de retour signature ou de notification, utilisent l'action 0 |
4666 |
|
// Si la création d'événement d'instruction suivant est déclenchée par |
4667 |
|
// une notification suite au traitement d'une tâche (démat') alors l'ajout |
4668 |
|
// de la nouvelle instruction se fait avec l'action 176 |
4669 |
|
// Cela permet de ne pas contrôler la restriction lors de l'ajout de la |
4670 |
|
// nouvelle instruction, depuis la méthode verifier() |
4671 |
|
$code_action_add = 0; |
4672 |
|
if ($this->getParameter("maj") == 175) { |
4673 |
|
$code_action_add = 176; |
4674 |
|
} |
4675 |
$restriction = $this->get_restriction($val['evenement']); |
$restriction = $this->get_restriction($val['evenement']); |
4676 |
$this->restriction_valid = $this->restrictionIsValid($restriction); |
$this->restriction_valid = $this->restrictionIsValid($restriction); |
4677 |
|
|
4678 |
if($restriction == "" || $this->restriction_valid ){ |
if($restriction == "" || $this->restriction_valid ){ |
4679 |
// Récupération de tous les paramètres de l'événement sélectionné |
// Récupération de tous les paramètres de l'événement sélectionné |
4680 |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
// TODO : remplacer cette requête par l'instanciation de l'evenement |
4681 |
WHERE evenement=".$this->valF['evenement']; |
$qres = $this->f->get_all_results_from_db_query( |
4682 |
$res = $db->query($sql); |
sprintf( |
4683 |
$this->addToLog("triggermodifierapres(): db->query(\"".$sql."\");", VERBOSE_MODE); |
'SELECT |
4684 |
if (database::isError($res)) { |
* |
4685 |
die($res->getMessage()); |
FROM |
4686 |
} |
%1$sevenement |
4687 |
|
WHERE |
4688 |
|
evenement = %2$d', |
4689 |
|
DB_PREFIXE, |
4690 |
|
intval($this->valF['evenement']) |
4691 |
|
), |
4692 |
|
array( |
4693 |
|
"origin" => __METHOD__ |
4694 |
|
) |
4695 |
|
); |
4696 |
$current_id = $this->getVal($this->clePrimaire); |
$current_id = $this->getVal($this->clePrimaire); |
4697 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
foreach ($qres['result'] as $row) { |
4698 |
// Si la date de retour signature est éditée on vérifie si il existe un événement automatique |
// Si la date de retour signature est éditée on vérifie si il existe un événement automatique |
4699 |
if ($this->getVal('date_retour_signature') == "" AND |
if ($this->getVal('date_retour_signature') == "" AND |
4700 |
$this->valF['date_retour_signature'] != "" AND |
$this->valF['date_retour_signature'] != "" AND |
4718 |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
4719 |
$valNewInstr["date_envoi_controle_legalite"] = $this->f->formatDate($this->valF['date_envoi_controle_legalite']); |
$valNewInstr["date_envoi_controle_legalite"] = $this->f->formatDate($this->valF['date_envoi_controle_legalite']); |
4720 |
$valNewInstr["date_retour_controle_legalite"] = $this->f->formatDate($this->valF['date_retour_controle_legalite']); |
$valNewInstr["date_retour_controle_legalite"] = $this->f->formatDate($this->valF['date_retour_controle_legalite']); |
4721 |
$new_instruction->setParameter("maj", 0); |
$new_instruction->setParameter("maj", $code_action_add); |
4722 |
$new_instruction->class_actions[0]["identifier"] = |
$new_instruction->class_actions[$code_action_add]["identifier"] = |
4723 |
"retour signature de l'instruction $current_id"; |
sprintf( |
4724 |
$retour = $new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
__("Ajout suite au retour signature de l'instruction %s"), |
4725 |
|
$current_id |
4726 |
|
); |
4727 |
|
$retour = $new_instruction->ajouter($valNewInstr); |
4728 |
|
|
4729 |
//Si une erreur s'est produite et qu'il s'agit d'un problème |
//Si une erreur s'est produite et qu'il s'agit d'un problème |
4730 |
//de restriction |
//de restriction |
4731 |
if ($retour == false && !$new_instruction->restriction_valid){ |
if ($retour == false && !$new_instruction->restriction_valid){ |
4732 |
$error_message = $this->get_restriction_error_message($restriction); |
$error_message = $this->get_restriction_error_message($restriction); |
4733 |
$this->f->displayMessage("error", $error_message); |
$this->f->displayMessage("error", $error_message); |
4734 |
$this->addToLog("triggermodifierapres() : evenement retour ". |
$this->addToLog(__METHOD__."(): evenement retour ". |
4735 |
"instruction ".$this->valF[$this->clePrimaire]." : ". |
"instruction ".$this->valF[$this->clePrimaire]." : ". |
4736 |
$new_instruction->msg); |
$new_instruction->msg); |
4737 |
} |
} |
4766 |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
4767 |
$valNewInstr["date_envoi_controle_legalite"] = $this->f->formatDate($this->valF['date_envoi_controle_legalite']); |
$valNewInstr["date_envoi_controle_legalite"] = $this->f->formatDate($this->valF['date_envoi_controle_legalite']); |
4768 |
$valNewInstr["date_retour_controle_legalite"] = $this->f->formatDate($this->valF['date_retour_controle_legalite']); |
$valNewInstr["date_retour_controle_legalite"] = $this->f->formatDate($this->valF['date_retour_controle_legalite']); |
4769 |
$new_instruction->setParameter("maj", 0); |
$new_instruction->setParameter("maj", $code_action_add); |
4770 |
$new_instruction->class_actions[0]["identifier"] = |
$new_instruction->class_actions[$code_action_add]["identifier"] = |
4771 |
"retour RAR de l'instruction $current_id"; |
sprintf(__("Ajout suite à la notification de l'instruction %s"), $current_id); |
4772 |
$retour = $new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
$retour = $new_instruction->ajouter($valNewInstr); |
4773 |
|
|
4774 |
//Si une erreur s'est produite et qu'il s'agit d'un problème |
//Si une erreur s'est produite et qu'il s'agit d'un problème |
4775 |
//de restriction |
//de restriction |
4777 |
$error_message = $this->get_restriction_error_message($restriction); |
$error_message = $this->get_restriction_error_message($restriction); |
4778 |
$this->f->displayMessage("error", $error_message); |
$this->f->displayMessage("error", $error_message); |
4779 |
$this->addToLog( |
$this->addToLog( |
4780 |
"triggermodifierapres() : evenement retour instruction ". |
__METHOD__."(): evenement retour instruction ". |
4781 |
$this->valF[$this->clePrimaire]." : ". |
$this->valF[$this->clePrimaire]." : ". |
4782 |
$new_instruction->msg |
$new_instruction->msg |
4783 |
); |
); |
4789 |
return false; |
return false; |
4790 |
} |
} |
4791 |
} |
} |
4792 |
// Mise à jour du flag incomplet_notifie dans dossier si la |
} |
4793 |
// date limite d'instruction n'est pas dépassée |
} |
4794 |
if($row['type']=='incompletude' && |
} |
4795 |
($this->valF['archive_date_notification_delai'] >= $this->valF['date_retour_rar'] || |
|
4796 |
$this->valF['archive_date_notification_delai'] == "")) { |
// Traitement en cas de mise à jour du dossier |
4797 |
$valFIncomp['incomplet_notifie'] = true; |
if ($update_dossier === true) { |
4798 |
$cle = " dossier='".$val['dossier']."'"; |
/** |
4799 |
$resIncomp = $db->autoExecute( |
* Mise à jour de la date de dernière modification du dossier |
4800 |
DB_PREFIXE.'dossier', |
* d'instruction |
4801 |
$valFIncomp, |
*/ |
4802 |
DB_AUTOQUERY_UPDATE, |
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
4803 |
$cle |
$inst_di->update_last_modification_date(); |
4804 |
|
|
4805 |
|
// Mise à jour des données du dossier d'autorisation |
4806 |
|
$da = $this->f->get_inst__om_dbform(array( |
4807 |
|
"obj" => "dossier_autorisation", |
4808 |
|
"idx" => $this->getNumDemandeAutorFromDossier($this->valF['dossier']), |
4809 |
|
)); |
4810 |
|
$params = array( |
4811 |
|
'di_id' => $this->getVal('dossier'), |
4812 |
|
); |
4813 |
|
if($da->majDossierAutorisation($params) === false) { |
4814 |
|
$this->addToMessage(_("Erreur lors de la mise a jour des donnees du dossier d'autorisation. Contactez votre administrateur.")); |
4815 |
|
$this->correct = false; |
4816 |
|
return false; |
4817 |
|
} |
4818 |
|
} |
4819 |
|
|
4820 |
|
// mise à jour des métadonnées issues des dates de suivi |
4821 |
|
$dateRetourSignatureModified = ($this->valF['date_retour_signature'] != $this->getVal('date_retour_signature')); |
4822 |
|
$dateRetourRARModified = ($this->valF['date_retour_rar'] != $this->getVal('date_retour_rar')); |
4823 |
|
if ($dateRetourSignatureModified || $dateRetourRARModified) { |
4824 |
|
|
4825 |
|
// Calculs des nouvelles métadonnées |
4826 |
|
$metadata = $this->getMetadata("om_fichier_instruction"); |
4827 |
|
|
4828 |
|
// On vérifie si l'instruction à finaliser a un événement de type arrete |
4829 |
|
// TODO : A voir pour remplacer par une instanciation de l'événement. |
4830 |
|
// Voir également si l'événement ne dois pas être instancié en début de |
4831 |
|
// méthode pour pouvoir être réutilisé. |
4832 |
|
$qres = $this->f->get_one_result_from_db_query( |
4833 |
|
sprintf( |
4834 |
|
'SELECT |
4835 |
|
type |
4836 |
|
FROM |
4837 |
|
%1$sevenement |
4838 |
|
WHERE |
4839 |
|
evenement = \'%2$d\'', |
4840 |
|
DB_PREFIXE, |
4841 |
|
intval($this->getVal("evenement")) |
4842 |
|
), |
4843 |
|
array( |
4844 |
|
"origin" => __METHOD__, |
4845 |
|
"force_return" => true, |
4846 |
|
) |
4847 |
|
); |
4848 |
|
|
4849 |
|
if ($qres["code"] !== "OK") { |
4850 |
|
$this->correct = false; |
4851 |
|
$this->addToMessage(__("Erreur de traitement de fichier.")); |
4852 |
|
$this->addToLog(__METHOD__."() erreur BDD: ".var_export($qres['message'], true), DEBUG_MODE); |
4853 |
|
return false; |
4854 |
|
} |
4855 |
|
|
4856 |
|
// Si l'événement est de type arrete, on ajoute les métadonnées spécifiques |
4857 |
|
if ($qres['result'] == 'arrete'){ |
4858 |
|
$metadata = array_merge($metadata, $this->getMetadata("arrete")); |
4859 |
|
} |
4860 |
|
|
4861 |
|
// Filtre pour conserver uniquement les métadonnées liées aux dates |
4862 |
|
$metadataToKeep = array( |
4863 |
|
"statutAutorisation", |
4864 |
|
"dateEvenementDocument", |
4865 |
|
'date_cloture_metier', |
4866 |
|
"NotificationArrete", |
4867 |
|
"dateNotificationArrete", |
4868 |
|
"controleLegalite", |
4869 |
|
"dateSignature", |
4870 |
|
"nomSignataire", |
4871 |
|
"qualiteSignataire", |
4872 |
|
"dateControleLegalite", |
4873 |
|
); |
4874 |
|
$metadata = array_filter( |
4875 |
|
$metadata, |
4876 |
|
function($key) use ($metadataToKeep) { return in_array($key, $metadataToKeep); }, |
4877 |
|
ARRAY_FILTER_USE_KEY |
4878 |
|
); |
4879 |
|
|
4880 |
|
// Mise à jour des métadonnées du document en GED |
4881 |
|
$docUid = $this->getVal("om_fichier_instruction"); |
4882 |
|
$operationOrUID = $this->f->storage->update_metadata($docUid, $metadata); |
4883 |
|
if ($operationOrUID == 'OP_FAILURE') { |
4884 |
|
$this->correct = false; |
4885 |
|
$this->addToMessage(__("Erreur de traitement de fichier.")); |
4886 |
|
$this->addToLog(__METHOD__."() failed to update metadata: ".var_export($operationOrUID, true), DEBUG_MODE); |
4887 |
|
return false; |
4888 |
|
} |
4889 |
|
|
4890 |
|
// mise à jour de l'UID du document en BDD |
4891 |
|
else { |
4892 |
|
$valF = array('om_fichier_instruction' => $operationOrUID); |
4893 |
|
$res = $this->f->db->autoExecute(DB_PREFIXE.$this->table, $valF, DB_AUTOQUERY_UPDATE, $this->getCle($id)); |
4894 |
|
$this->addToLog(__METHOD__.'() : db->autoExecute("'.DB_PREFIXE.$this->table.'", '.print_r($valF, true).', DB_AUTOQUERY_UPDATE, "'.$this->getCle($id).'")', VERBOSE_MODE); |
4895 |
|
if ($this->f->isDatabaseError($res, true) === true) { |
4896 |
|
$this->correct = false; |
4897 |
|
$this->addToMessage(__("Erreur de traitement de fichier.")); |
4898 |
|
$this->addToLog(__METHOD__."() erreur BDD: ".var_export($res->getMessage(), true), DEBUG_MODE); |
4899 |
|
return false; |
4900 |
|
} |
4901 |
|
$this->addToMessage(__("La mise a jour du document s'est effectuee avec succes.")); |
4902 |
|
} |
4903 |
|
} |
4904 |
|
|
4905 |
|
// Déclenchement des notifications automatique après finalisation et |
4906 |
|
// retour de signature |
4907 |
|
if ($dateRetourSignatureModified === true |
4908 |
|
&& $this->valF['date_retour_signature'] !== '' |
4909 |
|
&& $this->valF['date_retour_signature'] !== null) { |
4910 |
|
|
4911 |
|
// Message à afficher dans les logs pour indiquer quelle notification a échouée |
4912 |
|
$msgLog = sprintf( |
4913 |
|
'%s %s : %d', |
4914 |
|
__('Erreur lors de la notification automatique du(des) pétitionnaire(s) après retour signature.'), |
4915 |
|
__('Instruction notifiée'), |
4916 |
|
$id |
4917 |
|
); |
4918 |
|
|
4919 |
|
// Récupération de l'instance de l'événement pour accéder au paramètrage |
4920 |
|
// des notifications |
4921 |
|
$ev = $this->get_inst_evenement($this->valF['evenement']); |
4922 |
|
// Si la notification automatique des tiers consulté est active |
4923 |
|
// déclenche le traitement de notification. |
4924 |
|
// Ce traitement va envoyer des courriels de notification à tous les tiers concernés |
4925 |
|
$typeNotifTiers = $ev->getVal('notification_tiers'); |
4926 |
|
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
4927 |
|
if ($typeNotifTiers === 'notification_automatique') { |
4928 |
|
if ($this->traitement_notification_automatique_tiers_consulte($ev, $inst_di) === false) { |
4929 |
|
$this->addToMessage(__('Le traitement de la notification automatique de tiers à échoué.')); |
4930 |
|
$this->correct = false; |
4931 |
|
} |
4932 |
|
} |
4933 |
|
|
4934 |
|
if ($ev->getVal('notification') === 'notification_auto_signature_requise') { |
4935 |
|
// Récupération de la liste des demandeurs à notifier et de la catégorie |
4936 |
|
$categorie = $this->f->get_param_option_notification($collectivite_di); |
4937 |
|
$isPortal = $categorie === PORTAL; |
4938 |
|
$demandeursANotifie = $this->get_demandeurs_notifiable( |
4939 |
|
$this->valF['dossier'], |
4940 |
|
$isPortal |
4941 |
|
); |
4942 |
|
|
4943 |
|
// Création d'une notification et d'une tâche pour chaque demandeur à notifier |
4944 |
|
$demandeurPrincipalNotifie = false; |
4945 |
|
foreach ($demandeursANotifie as $demandeur) { |
4946 |
|
// Identifie si le demandeur principal a été notifié ou pas |
4947 |
|
// et récupère ses informations |
4948 |
|
if ($demandeur['petitionnaire_principal'] == 't') { |
4949 |
|
$demandeurPrincipalNotifie = true; |
4950 |
|
// Si le demandeur principal est notifiable mais qu'il y a des erreurs dans |
4951 |
|
// son paramétrage, on effectue pas le traitement et on passe à l'itération |
4952 |
|
// suivante. On le considère également comme non notifié pour gérer l'envoie |
4953 |
|
// des messages d'erreurs |
4954 |
|
// Si la demande a été déposée via le portail alors le paramétrage n'a pas |
4955 |
|
// d'impact sur la notification |
4956 |
|
$erreursParam = $this->get_info_notification_fail(); |
4957 |
|
if (! $this->dossier_depose_sur_portail() && $erreursParam != array()) { |
4958 |
|
$demandeurPrincipalNotifie = false; |
4959 |
|
continue; |
4960 |
|
} |
4961 |
|
} |
4962 |
|
// Ajout de la notif et récupération de son id |
4963 |
|
$idNotif = $this->ajouter_notification( |
4964 |
|
$this->valF[$this->clePrimaire], |
4965 |
|
$this->f->get_connected_user_login_name(), |
4966 |
|
$demandeur, |
4967 |
|
$collectivite_di, |
4968 |
|
array(), |
4969 |
|
true |
4970 |
|
); |
4971 |
|
if ($idNotif === false) { |
4972 |
|
$this->addToLog( |
4973 |
|
sprintf('%s() : %s',__METHOD__, $msgLog), |
4974 |
|
DEBUG_MODE |
4975 |
); |
); |
4976 |
|
return false; |
4977 |
|
} |
4978 |
|
// Création de la tache en lui donnant l'id de la notification |
4979 |
|
$notification_by_task = $this->notification_by_task( |
4980 |
|
$idNotif, |
4981 |
|
$this->valF['dossier'], |
4982 |
|
$categorie |
4983 |
|
); |
4984 |
|
if ($notification_by_task === false) { |
4985 |
$this->addToLog( |
$this->addToLog( |
4986 |
"triggersupprimer(): db->autoexecute(\"". |
sprintf('%s() : %s',__METHOD__, $msgLog), |
4987 |
DB_PREFIXE."dossier\", ".print_r($valFIncomp, true). |
DEBUG_MODE |
|
", DB_AUTOQUERY_UPDATE, \"".$cle."\");", |
|
|
VERBOSE_MODE |
|
4988 |
); |
); |
4989 |
if (database::isError($resIncomp)) { |
$this->addToMessage( |
4990 |
die($resIncomp->getMessage()); |
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
4991 |
} |
); |
4992 |
|
return false; |
4993 |
} |
} |
4994 |
} |
} |
4995 |
|
// Pour la notification par mail ou la notification via portal si le dossier a |
4996 |
|
// été déposés via portal, si le demandeur principal n'est pas notifiable, |
4997 |
|
// on créé une nouvelle notification en erreur avec en commentaire la raison pour |
4998 |
|
// laquelle le demandeur principal n'a pas pu être notifié |
4999 |
|
$depotPortal = $this->dossier_depose_sur_portail(); |
5000 |
|
if (! $demandeurPrincipalNotifie && ($isPortal === false || $depotPortal === true)) { |
5001 |
|
// Précise dans les logs que le pétitionnaire principal n'a pas été notifié |
5002 |
|
$msgLog .= sprintf(' %s', __('Le pétitionnaire principale n\'est pas notifiable.')); |
5003 |
|
// Analyse pour savoir pourquoi le demandeur principal n'est pas notifiable |
5004 |
|
$erreursParam = $this->get_info_notification_fail(); |
5005 |
|
$demandeurPrincipal = $this->get_info_petitionnaire_principal_dossier($this->getVal('dossier')); |
5006 |
|
// Ajout de la notif et récupération de son id |
5007 |
|
$idNotif = $this->ajouter_notification( |
5008 |
|
$this->valF[$this->clePrimaire], |
5009 |
|
$this->f->get_connected_user_login_name(), |
5010 |
|
$demandeurPrincipal, |
5011 |
|
$collectivite_di, |
5012 |
|
array(), |
5013 |
|
true, |
5014 |
|
'Echec', |
5015 |
|
implode(' ', $erreursParam) |
5016 |
|
); |
5017 |
|
if ($idNotif === false) { |
5018 |
|
$this->addToLog( |
5019 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
5020 |
|
DEBUG_MODE |
5021 |
|
); |
5022 |
|
$this->addToMessage( |
5023 |
|
__('Erreur : la création de la notification a échouée.'). |
5024 |
|
__("Veuillez contacter votre administrateur.") |
5025 |
|
); |
5026 |
|
return false; |
5027 |
|
} |
5028 |
|
// Prépare un message d'alerte à destination de l'instructeur pour l'informer |
5029 |
|
// de l'échec de la notification |
5030 |
|
$dossier_message = $this->get_inst_dossier_message(0); |
5031 |
|
$dossier_message_val = array( |
5032 |
|
'dossier' => $this->getVal('dossier'), |
5033 |
|
'type' => _('erreur expedition'), |
5034 |
|
'emetteur' => $this->f->get_connected_user_login_name(), |
5035 |
|
'login' => $_SESSION['login'], |
5036 |
|
'date_emission' => date('Y-m-d H:i:s'), |
5037 |
|
'contenu' => _('Échec lors de la notification de l\'instruction '). |
5038 |
|
$ev->getVal('libelle'). |
5039 |
|
'.<br>'. |
5040 |
|
implode("\n", $erreursParam). |
5041 |
|
'<br>'. |
5042 |
|
_('Veuillez corriger ces informations avant de renvoyer la notification.') |
5043 |
|
); |
5044 |
|
$add = $dossier_message->add_notification_message($dossier_message_val, true); |
5045 |
|
// Si une erreur se produit pendant l'ajout |
5046 |
|
if ($add !== true) { |
5047 |
|
$this->addToLog( |
5048 |
|
sprintf( |
5049 |
|
'%s() : %s', |
5050 |
|
__METHOD__, |
5051 |
|
__("Le message d'alerte concernant l'echec de l'envoi de la notification n'a pas pu être envoyé.") |
5052 |
|
), |
5053 |
|
DEBUG_MODE |
5054 |
|
); |
5055 |
|
return false; |
5056 |
|
} |
5057 |
|
} |
5058 |
|
$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."))); |
5059 |
} |
} |
5060 |
} |
} |
5061 |
|
|
5062 |
// Mise à jour des données du dossier d'autorisation |
$res = $this->add_log_to_dossier($id, $val); |
5063 |
$da = $this->f->get_inst__om_dbform(array( |
$data = array('val' => &$val, 'id' => $id, 'result' => &$res); |
5064 |
"obj" => "dossier_autorisation", |
$this->f->module_manager->run_hooks('triggermodifierapres_post', $this, $data); |
5065 |
"idx" => $this->getNumDemandeAutorFromDossier($this->valF['dossier']), |
return $res; |
|
)); |
|
|
if($da->majDossierAutorisation() === false) { |
|
|
$this->addToMessage(_("Erreur lors de la mise a jour des donnees du dossier d'autorisation. Contactez votre administrateur.")); |
|
|
$this->correct = false; |
|
|
return false; |
|
|
} |
|
|
|
|
|
/** |
|
|
* Mise à jour de la date de dernière modification du dossier |
|
|
* d'instruction |
|
|
*/ |
|
|
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
|
|
$inst_di->update_last_modification_date(); |
|
|
|
|
|
return $this->add_log_to_dossier($id, $val); |
|
5066 |
} |
} |
5067 |
|
|
5068 |
function triggersupprimer($id, &$db = null, $val = array(), $DEBUG = null) { |
/** |
5069 |
|
* TRIGGER - triggersupprimer. |
5070 |
|
* |
5071 |
|
* @return boolean |
5072 |
|
*/ |
5073 |
|
function triggersupprimer($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
5074 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
5075 |
|
$data = array('val' => &$val, 'id' => $id); |
5076 |
|
$this->f->module_manager->run_hooks('triggersupprimer_pre', $this, $data); |
5077 |
/** |
/** |
5078 |
* L'objectif ici est de repositionner les valeurs récupérées en |
* L'objectif ici est de repositionner les valeurs récupérées en |
5079 |
* archive dans le dossier d'instruction avant de supprimer l'événement |
* archive dans le dossier d'instruction avant de supprimer l'événement |
5080 |
* d'instruction |
* d'instruction si les valeurs du dossier sont différentes |
5081 |
*/ |
*/ |
5082 |
|
$valF = array(); |
5083 |
// Mise à jour des 4 valeurs modifiées par l'action |
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
5084 |
$valF['delai'] = $val['archive_delai']; |
foreach ($inst_di->champs as $key => $champ) { |
5085 |
$valF['accord_tacite'] = $val['archive_accord_tacite']; |
// Si le champ du DI à une archive dans l'instruction |
5086 |
$valF['etat'] = $val['archive_etat']; |
if (isset($val[sprintf('archive_%s', $champ)]) === true) { |
5087 |
if ($val['archive_avis'] != '') { |
// Si la valeur entre le champ du DI et son archive dans instruction |
5088 |
$valF['avis_decision'] = $val['archive_avis']; |
// est différente |
5089 |
} else { |
if ($inst_di->getVal($champ) !== $val[sprintf('archive_%s', $champ)]) { |
5090 |
$valF['avis_decision'] = null; |
$val[sprintf('archive_%s', $champ)] === '' ? $valF[$champ] = null : $valF[$champ] = $val[sprintf('archive_%s', $champ)]; |
5091 |
} |
// Gestion du cas particulier 'accord_tacite' pour renvoyer la valeur ' ' (3 espaces vides) au lieu de null |
5092 |
// Mise à jour des dates avec la valeur présente dans le formulaire |
// Car les valeurs possibles du champ accord_tacite sont : 'Oui', 'Non' ou ' ' |
5093 |
// de suppression. Si la valeur de la date est vide alors on fixe |
if ($champ === "accord_tacite" && $valF[$champ] === null) { |
5094 |
// à la valeur null |
$valF[$champ] = ' '; |
5095 |
if ($val['archive_date_complet'] != '') { |
} |
5096 |
$valF['date_complet'] = $val['archive_date_complet']; |
} |
5097 |
} else { |
} |
|
$valF['date_complet'] = null; |
|
|
} |
|
|
if ($val['archive_date_dernier_depot'] != '') { |
|
|
$valF['date_dernier_depot'] = $val['archive_date_dernier_depot']; |
|
|
} else { |
|
|
$valF['date_dernier_depot'] = null; |
|
|
} |
|
|
if ($val['archive_date_rejet'] != '') { |
|
|
$valF['date_rejet'] = $val['archive_date_rejet']; |
|
|
} else { |
|
|
$valF['date_rejet'] = null; |
|
|
} |
|
|
if ($val['archive_date_limite'] != '') { |
|
|
$valF['date_limite'] = $val['archive_date_limite']; |
|
|
} else { |
|
|
$valF['date_limite'] = null; |
|
|
} |
|
|
if ($val['archive_date_notification_delai'] != '') { |
|
|
$valF['date_notification_delai'] = $val['archive_date_notification_delai']; |
|
|
} else { |
|
|
$valF['date_notification_delai'] = null; |
|
|
} |
|
|
if ($val['archive_date_decision'] != '') { |
|
|
$valF['date_decision'] = $val['archive_date_decision']; |
|
|
} else { |
|
|
$valF['date_decision'] = null; |
|
|
} |
|
|
if ($val['archive_date_validite'] != '') { |
|
|
$valF['date_validite'] = $val['archive_date_validite']; |
|
|
} else { |
|
|
$valF['date_validite'] = null; |
|
|
} |
|
|
if ($val['archive_date_achevement'] != '') { |
|
|
$valF['date_achevement'] = $val['archive_date_achevement']; |
|
|
} else { |
|
|
$valF['date_achevement'] = null; |
|
|
} |
|
|
if ($val['archive_date_chantier'] != '') { |
|
|
$valF['date_chantier'] = $val['archive_date_chantier']; |
|
|
} else { |
|
|
$valF['date_chantier'] = null; |
|
|
} |
|
|
if ($val['archive_date_conformite'] != '') { |
|
|
$valF['date_conformite'] = $val['archive_date_conformite']; |
|
|
} else { |
|
|
$valF['date_conformite'] = null; |
|
|
} |
|
|
if ($val['archive_incompletude'] != '') { |
|
|
$valF['incompletude'] = $val['archive_incompletude']; |
|
|
} else { |
|
|
$valF['incompletude'] = null; |
|
|
} |
|
|
if ($val['archive_incomplet_notifie'] != '') { |
|
|
$valF['incomplet_notifie'] = $val['archive_incomplet_notifie']; |
|
|
} else { |
|
|
$valF['incomplet_notifie'] = null; |
|
|
} |
|
|
if ($val['archive_evenement_suivant_tacite'] != '') { |
|
|
$valF['evenement_suivant_tacite'] = $val['archive_evenement_suivant_tacite']; |
|
|
} else { |
|
|
$valF['evenement_suivant_tacite'] = null; |
|
|
} |
|
|
if ($val['archive_evenement_suivant_tacite_incompletude'] != '') { |
|
|
$valF['evenement_suivant_tacite_incompletude'] = $val['archive_evenement_suivant_tacite_incompletude']; |
|
|
} else { |
|
|
$valF['evenement_suivant_tacite_incompletude'] = null; |
|
|
} |
|
|
if ($val['archive_etat_pendant_incompletude'] != '') { |
|
|
$valF['etat_pendant_incompletude'] = $val['archive_etat_pendant_incompletude']; |
|
|
} else { |
|
|
$valF['etat_pendant_incompletude'] = null; |
|
|
} |
|
|
if ($val['archive_date_limite_incompletude'] != '') { |
|
|
$valF['date_limite_incompletude'] = $val['archive_date_limite_incompletude']; |
|
|
} else { |
|
|
$valF['date_limite_incompletude'] = null; |
|
|
} |
|
|
if ($val['archive_delai_incompletude'] != '') { |
|
|
$valF['delai_incompletude'] = $val['archive_delai_incompletude']; |
|
|
} else { |
|
|
$valF['delai_incompletude'] = null; |
|
|
} |
|
|
if ($val['archive_autorite_competente'] != '') { |
|
|
$valF['autorite_competente'] = $val['archive_autorite_competente']; |
|
|
} else { |
|
|
$valF['autorite_competente'] = null; |
|
5098 |
} |
} |
5099 |
$valF['date_cloture_instruction'] = null; |
// Spécificité du champ avis_decision dont le champ archive est nommé |
5100 |
if ($val['archive_date_cloture_instruction'] !== '') { |
// différemment |
5101 |
$valF['date_cloture_instruction'] = $val['archive_date_cloture_instruction']; |
if ($inst_di->getVal('avis_decision') !== $val['archive_avis']) { |
5102 |
|
$val['archive_avis'] === '' ? $valF['avis_decision'] = null : $valF['avis_decision'] = $val['archive_avis']; |
5103 |
|
} |
5104 |
|
// Spécificité de la date d'affichage dont la valeur n'ai jamais modifiée |
5105 |
|
// par l'archive |
5106 |
|
unset($valF['date_affichage']); |
5107 |
|
|
5108 |
|
/** |
5109 |
|
* Mise à jour de la version de clôture *version_clos* du dossier si et |
5110 |
|
* seulement si l'instruction met à jour l'état du dossier. |
5111 |
|
*/ |
5112 |
|
if (isset($valF['etat']) === true |
5113 |
|
&& $valF['etat'] !== null |
5114 |
|
&& $valF['etat'] !== '') { |
5115 |
|
// Récupère l'état actuel du dossier d'instruction |
5116 |
|
$inst_current_etat = $this->f->get_inst__om_dbform(array( |
5117 |
|
"obj" => "etat", |
5118 |
|
"idx" => $inst_di->get_id_etat(), |
5119 |
|
)); |
5120 |
|
// Instanciation de l'état archivé appliqué sur le dossier |
5121 |
|
$inst_etat = $this->f->get_inst__om_dbform(array( |
5122 |
|
"obj" => "etat", |
5123 |
|
"idx" => $valF['etat'], |
5124 |
|
)); |
5125 |
|
// |
5126 |
|
$update_version_clos = null; |
5127 |
|
// En cas de clôture du dossier par l'état archivé |
5128 |
|
if ($inst_etat->getVal('statut') === 'cloture') { |
5129 |
|
$update_version_clos = $inst_di->update_version_clos('up'); |
5130 |
|
} |
5131 |
|
// En cas de réouverture du dossier par l'état archivé |
5132 |
|
if ($inst_current_etat->getVal('statut') === 'cloture' |
5133 |
|
&& $inst_etat->getVal('statut') !== 'cloture') { |
5134 |
|
// |
5135 |
|
$update_version_clos = $inst_di->update_version_clos('down'); |
5136 |
|
// |
5137 |
|
$this->set_att_di_reopened(true); |
5138 |
|
} |
5139 |
|
// |
5140 |
|
if ($update_version_clos === false) { |
5141 |
|
$this->f->addToLog(sprintf( |
5142 |
|
"%s() : ERREUR - %s %s", |
5143 |
|
__METHOD__, |
5144 |
|
sprintf( |
5145 |
|
__("Impossible de mettre à jour la version de clôture du dossier d'instruction %s."), |
5146 |
|
$inst_di->getVal($inst_di->clePrimaire) |
5147 |
|
), |
5148 |
|
sprintf( |
5149 |
|
__("L'instruction tente d'appliquer l'état %s."), |
5150 |
|
$inst_etat->getVal($inst_etat->clePrimaire) |
5151 |
|
) |
5152 |
|
)); |
5153 |
|
$this->addToMessage(sprintf( |
5154 |
|
"%s %s", |
5155 |
|
__("Erreur lors de la mise à jour de la version de clôture du dossier d'instruction."), |
5156 |
|
__("Veuillez contacter votre administrateur.") |
5157 |
|
)); |
5158 |
|
return false; |
5159 |
|
} |
5160 |
} |
} |
5161 |
// Dates concernant les dossiers contentieux |
// On supprime toutes les notications liées à l'instruction |
5162 |
// Date de première visite |
$notifASupprimer = $this->get_instruction_notification( |
5163 |
$valF['date_premiere_visite'] = null; |
$this->getVal($this->clePrimaire), |
5164 |
if ($val['archive_date_premiere_visite'] !== '') { |
array( |
5165 |
$valF['date_premiere_visite'] = $val['archive_date_premiere_visite']; |
'notification_recepisse', |
5166 |
} |
'notification_instruction', |
5167 |
// Date de dernière visite |
'notification_decision', |
5168 |
$valF['date_derniere_visite'] = null; |
'notification_service_consulte', |
5169 |
if ($val['archive_date_derniere_visite'] !== '') { |
'notification_tiers_consulte', |
5170 |
$valF['date_derniere_visite'] = $val['archive_date_derniere_visite']; |
'notification_depot_demat', |
5171 |
} |
'notification_commune', |
5172 |
// Date contradictoire |
'notification_signataire' |
5173 |
$valF['date_contradictoire'] = null; |
), |
5174 |
if ($val['archive_date_contradictoire'] !== '') { |
true |
5175 |
$valF['date_contradictoire'] = $val['archive_date_contradictoire']; |
); |
5176 |
} |
|
5177 |
// Date de retour contradictoire |
foreach ($notifASupprimer as $idNotif) { |
5178 |
$valF['date_retour_contradictoire'] = null; |
$inst_notif = $this->f->get_inst__om_dbform(array( |
5179 |
if ($val['archive_date_retour_contradictoire'] !== '') { |
"obj" => "instruction_notification", |
5180 |
$valF['date_retour_contradictoire'] = $val['archive_date_retour_contradictoire']; |
"idx" => $idNotif, |
5181 |
} |
)); |
5182 |
// Date de l'AIT |
$val_notif = array(); |
5183 |
$valF['date_ait'] = null; |
foreach ($inst_notif->champs as $champ) { |
5184 |
if ($val['archive_date_ait'] !== '') { |
$val_notif[$champ] = $inst_notif->getVal($champ); |
5185 |
$valF['date_ait'] = $val['archive_date_ait']; |
} |
5186 |
} |
// La suppression des notifications entrainera la suppression des tâches qui y sont |
5187 |
// Date de transmission au parquet |
// liées |
5188 |
$valF['date_transmission_parquet'] = null; |
$supprNotif = $inst_notif->supprimer($val_notif); |
5189 |
if ($val['archive_date_transmission_parquet'] !== '') { |
if ($supprNotif == false) { |
5190 |
$valF['date_transmission_parquet'] = $val['archive_date_transmission_parquet']; |
$this->addToMessage(sprintf( |
5191 |
} |
"%s %s", |
5192 |
// Type du dossier d'instruction |
__("Erreur lors de la suppression des notifications de l'instruction."), |
5193 |
if ($val['archive_dossier_instruction_type'] !== '' && $val['archive_dossier_instruction_type'] !== null) { |
__("Veuillez contacter votre administrateur.") |
5194 |
$valF['dossier_instruction_type'] = $val['archive_dossier_instruction_type']; |
)); |
5195 |
|
return false; |
5196 |
|
} |
5197 |
} |
} |
5198 |
|
|
5199 |
// On met à jour le dossier |
// On met à jour le dossier |
5200 |
$cle = " dossier='".$val['dossier']."'"; |
$valF['instruction'] = $id; |
5201 |
$res = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle); |
$valF['crud'] = 'delete'; |
5202 |
$this->addToLog("triggersupprimer(): db->autoexecute(\"".DB_PREFIXE."dossier\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
$update_by_instruction = $inst_di->update_by_instruction($valF); |
5203 |
if (database::isError($res)) { |
if ($update_by_instruction === false) { |
5204 |
die($res->getMessage()); |
$this->cleanMessage(); |
5205 |
|
$this->addToMessage(sprintf('%s %s', __("Une erreur s'est produite lors de la mise à jour du dossier d'instruction."), __("Veuillez contacter votre administrateur."))); |
5206 |
|
return false; |
5207 |
} |
} |
5208 |
|
|
5209 |
// Affichage d'informations à l'utilisateur |
// Affichage d'informations à l'utilisateur |
5210 |
$this->addToMessage(_("Suppression de l'instruction")." [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
$this->addToMessage(_("Suppression de l'instruction")." [".$this->f->db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
5211 |
|
|
5212 |
// Mise à jour de la demande si un récépissé d'instruction correspond à l'instruction à supprimer |
// Mise à jour de la demande si un récépissé d'instruction correspond à l'instruction à supprimer |
5213 |
|
|
5214 |
|
$res = true; |
5215 |
|
$data = array('val' => &$val, 'id' => $id, 'result' => &$res); |
5216 |
|
$this->f->module_manager->run_hooks('triggersupprimer_post', $this, $data); |
5217 |
|
return $res; |
5218 |
} |
} |
5219 |
|
|
5220 |
function triggersupprimerapres($id, &$db = null, $val = array(), $DEBUG = null) { |
/** |
5221 |
// Mise à jour des données du dossier d'autorisation |
* TRIGGER - triggersupprimerapres. |
5222 |
|
* |
5223 |
|
* @return boolean |
5224 |
|
*/ |
5225 |
|
function triggersupprimerapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
5226 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
5227 |
|
$data = array('val' => &$val, 'id' => $id); |
5228 |
|
$this->f->module_manager->run_hooks('triggersupprimerapres_pre', $this, $data); |
5229 |
|
/** |
5230 |
|
* Mise à jour de la date de dernière modification du dossier |
5231 |
|
* d'instruction |
5232 |
|
*/ |
5233 |
|
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
5234 |
|
$inst_di->update_last_modification_date(); |
5235 |
|
|
5236 |
|
/** |
5237 |
|
* Mise à jour des données du dossier d'autorisation |
5238 |
|
*/ |
5239 |
$da = $this->f->get_inst__om_dbform(array( |
$da = $this->f->get_inst__om_dbform(array( |
5240 |
"obj" => "dossier_autorisation", |
"obj" => "dossier_autorisation", |
5241 |
"idx" => $this->getNumDemandeAutorFromDossier($val["dossier"]), |
"idx" => $this->getNumDemandeAutorFromDossier($val["dossier"]), |
5242 |
)); |
)); |
5243 |
if($da->majDossierAutorisation() === false) { |
$params = array( |
5244 |
|
'di_id' => $this->getVal('dossier'), |
5245 |
|
'di_reopened' => $this->get_att_di_reopened(), |
5246 |
|
); |
5247 |
|
if($da->majDossierAutorisation($params) === false) { |
5248 |
$this->addToMessage(_("Erreur lors de la mise a jour des donnees du dossier d'autorisation. Contactez votre administrateur.")); |
$this->addToMessage(_("Erreur lors de la mise a jour des donnees du dossier d'autorisation. Contactez votre administrateur.")); |
5249 |
$this->correct = false; |
$this->correct = false; |
5250 |
return false; |
return false; |
5251 |
} |
} |
|
$val['evenement'] = $this->getVal('evenement'); |
|
5252 |
|
|
5253 |
/** |
/** |
5254 |
* Mise à jour de la date de dernière modification du dossier |
* Gestion des tâches pour la dématérialisation |
|
* d'instruction |
|
5255 |
*/ |
*/ |
5256 |
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
$inst_task_empty = $this->f->get_inst__om_dbform(array( |
5257 |
$inst_di->update_last_modification_date(); |
"obj" => "task", |
5258 |
|
"idx" => 0, |
5259 |
|
)); |
5260 |
|
foreach ($inst_di->task_types as $task_type) { |
5261 |
|
$task_exists = $inst_task_empty->task_exists($task_type, $id); |
5262 |
|
if ($task_exists !== false) { |
5263 |
|
$inst_task = $this->f->get_inst__om_dbform(array( |
5264 |
|
"obj" => "task", |
5265 |
|
"idx" => $task_exists, |
5266 |
|
)); |
5267 |
|
if ($inst_task->getVal('state') === $inst_task::STATUS_NEW || $inst_task->getVal('state') === $inst_task::STATUS_DRAFT) { |
5268 |
|
$task_val = array( |
5269 |
|
'state' => $inst_task::STATUS_CANCELED, |
5270 |
|
); |
5271 |
|
$update_task = $inst_task->update_task(array('val' => $task_val)); |
5272 |
|
if ($update_task === false) { |
5273 |
|
$this->addToMessage(sprintf('%s %s', |
5274 |
|
sprintf(__("Une erreur s'est produite lors de la modification de la tâche %."), $inst_task->getVal($inst_task->clePrimaire)), |
5275 |
|
__("Veuillez contacter votre administrateur.") |
5276 |
|
)); |
5277 |
|
$this->correct = false; |
5278 |
|
return false; |
5279 |
|
} |
5280 |
|
} |
5281 |
|
} |
5282 |
|
} |
5283 |
|
|
5284 |
// |
// |
5285 |
return $this->add_log_to_dossier($id, $val); |
$val['evenement'] = $this->getVal('evenement'); |
5286 |
|
$res = $this->add_log_to_dossier($id, $val); |
5287 |
|
$data = array('val' => &$val, 'id' => $id, 'result' => &$res); |
5288 |
|
$this->f->module_manager->run_hooks('triggersupprimerapres_post', $this, $data); |
5289 |
|
return $res; |
5290 |
|
} |
5291 |
|
|
5292 |
|
/** |
5293 |
|
* Permet de mettre la valeur passée en paramètre dans l'attribut de classe |
5294 |
|
* "di_reopened". |
5295 |
|
* |
5296 |
|
* @param boolean $val |
5297 |
|
*/ |
5298 |
|
function set_att_di_reopened($val) { |
5299 |
|
$this->di_reopened = $val; |
5300 |
|
} |
5301 |
|
|
5302 |
|
/** |
5303 |
|
* Permet de récupérer la valeur de l'attribut de classe "di_reopened". |
5304 |
|
* |
5305 |
|
* @return boolean |
5306 |
|
*/ |
5307 |
|
function get_att_di_reopened() { |
5308 |
|
return $this->di_reopened; |
5309 |
} |
} |
5310 |
|
|
5311 |
/** |
/** |
5347 |
} |
} |
5348 |
|
|
5349 |
/** |
/** |
5350 |
* Vérifie la restriction sur l'événement. |
* Surcharge de la méthode verifier() de la classe om_dbform pour y ajouter |
5351 |
* |
* les vérifications suivantes : |
5352 |
* @param array $val valeurs du formulaire |
* - Si l'instruction à un événement associé et que cet événement à des restrictions : |
5353 |
* @param database $db handler database |
* 1. vérifie si la restriction est valide, si ce n'est pas le cas récupère et affiche |
5354 |
* @param boolean $DEBUG NA |
* le message d'erreur associé à la restriction |
5355 |
|
* 2. vérifie si les restrictions sont respectées. Si ce n'est pas le cas bloque l'ajout |
5356 |
|
* et / ou la modification et affiche un message d'erreur |
5357 |
|
* - |
5358 |
|
* - |
5359 |
|
* - |
5360 |
|
* - |
5361 |
|
* - |
5362 |
|
* - |
5363 |
|
* |
5364 |
|
* @param array val : tableau contenant les valeurs issues du formulaire. |
5365 |
|
* @param - dnu1 : Paramètre déprécié et non utilisé. |
5366 |
|
* @param - dnu2 : Paramètre déprécié et non utilisé. |
5367 |
* |
* |
5368 |
* @return [type] [description] |
* @return void |
5369 |
*/ |
*/ |
5370 |
function verifier($val = array(), &$db = null, $DEBUG = null) { |
function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
5371 |
parent::verifier($val, $db, $DEBUG); |
parent::verifier($val); |
5372 |
|
// |
5373 |
if ( isset($val['evenement']) && is_numeric($val['evenement'])){ |
if ( isset($val['evenement']) && is_numeric($val['evenement'])){ |
5374 |
$restriction = $this->get_restriction($val['evenement']); |
$restriction = $this->get_restriction($val['evenement']); |
5375 |
|
|
5376 |
//Test qu'une restriction est présente |
//Test qu'une restriction est présente |
5377 |
if ($restriction != "" ){ |
if ($restriction != "" ){ |
5378 |
|
|
5379 |
//Test si la restriction est valide |
// Vérifie le contexte de la modification et test si la restriction est valide. |
5380 |
|
// Si l'instruction est modifiée par une tache le dossier n'est pas impacté. |
5381 |
|
// Il n'est donc pas nécessaire de vérifier les restrictions. |
5382 |
$this->restriction_valid = $this->restrictionIsValid($restriction); |
$this->restriction_valid = $this->restrictionIsValid($restriction); |
5383 |
if ( !$this->restriction_valid ){ |
if ($this->getParameter("maj") != 176 |
5384 |
|
&& !$this->restriction_valid) { |
5385 |
|
|
5386 |
// Affichage du message si la restriction s'applique |
// Affichage du message si la restriction s'applique |
5387 |
$this->addToMessage( |
$this->addToMessage( |
5449 |
} |
} |
5450 |
|
|
5451 |
} |
} |
5452 |
|
|
5453 |
|
/** |
5454 |
|
* Récupère et stocket dans un tableau toutes les infos du pétitionnaire |
5455 |
|
* principal du dossier auquel appartiens l'instruction. |
5456 |
|
* Renvoie un tableau contenant les informations du pétitionnaire principal. |
5457 |
|
* |
5458 |
|
* Si l'identifiant de l'instruction n'a pas pu etre récupéré renvoie false |
5459 |
|
* et affiche un message dans les logs. |
5460 |
|
* En cas d'erreur de base de donnée renvoie false et affiche un message d'erreur. |
5461 |
|
* |
5462 |
|
* @param string identifiant du dossier |
5463 |
|
* @return array|boolean |
5464 |
|
*/ |
5465 |
|
protected function get_info_petitionnaire_principal_dossier($dossier = null) { |
5466 |
|
// Si l'identifiant de l'instruction n'a pas été fournit on récupère celui de |
5467 |
|
// l'objet courant |
5468 |
|
if (empty($dossier)) { |
5469 |
|
$dossier = $this->getVal('dossier'); |
5470 |
|
// Si la récupération de l'identifiant de l'instruction a échoué la méthode renvoie |
5471 |
|
// false et on affiche un message d'erreur dans les logs |
5472 |
|
if (empty($dossier)) { |
5473 |
|
$this->addToLog(__METHOD__.' : L\'identifiant du dossier n\'a pas pu être récupéré'); |
5474 |
|
return false; |
5475 |
|
} |
5476 |
|
} |
5477 |
|
|
5478 |
|
// Requête sql servant à récupérer toutes les informations relatives au demandeurs |
5479 |
|
// principal |
5480 |
|
$qres = $this->f->get_all_results_from_db_query( |
5481 |
|
sprintf( |
5482 |
|
'SELECT |
5483 |
|
-- Récupère toutes les informations du demandeur principal |
5484 |
|
demandeur.*, |
5485 |
|
CASE |
5486 |
|
WHEN demandeur.qualite=\'particulier\' |
5487 |
|
THEN TRIM(CONCAT(demandeur.particulier_nom, \' \', demandeur.particulier_prenom, \' \', demandeur.courriel)) |
5488 |
|
ELSE |
5489 |
|
TRIM(CONCAT(demandeur.personne_morale_raison_sociale, \' \', demandeur.personne_morale_denomination, \' \', demandeur.courriel)) |
5490 |
|
END AS destinataire |
5491 |
|
FROM |
5492 |
|
%1$sdossier |
5493 |
|
LEFT JOIN %1$slien_dossier_demandeur |
5494 |
|
ON lien_dossier_demandeur.dossier = dossier.dossier |
5495 |
|
LEFT JOIN %1$sdemandeur |
5496 |
|
ON demandeur.demandeur = lien_dossier_demandeur.demandeur |
5497 |
|
WHERE |
5498 |
|
dossier.dossier = \'%2$s\' |
5499 |
|
AND lien_dossier_demandeur.petitionnaire_principal IS TRUE', |
5500 |
|
DB_PREFIXE, |
5501 |
|
$this->f->db->escapeSimple($dossier) |
5502 |
|
), |
5503 |
|
array( |
5504 |
|
"origin" => __METHOD__, |
5505 |
|
) |
5506 |
|
); |
5507 |
|
if (is_array($qres["result"]) === true |
5508 |
|
&& array_key_exists(0, $qres["result"]) === true) { |
5509 |
|
// |
5510 |
|
return $qres["result"][0]; |
5511 |
|
} |
5512 |
|
return null; |
5513 |
|
} |
5514 |
|
|
5515 |
|
|
5516 |
|
|
5517 |
/** |
/** |
5518 |
* Finalisation des documents. |
* Finalisation des documents. |
5564 |
// Génération du PDF |
// Génération du PDF |
5565 |
$result = $this->compute_pdf_output('lettretype', $this->getVal('lettretype'), $collectivite, null, $params); |
$result = $this->compute_pdf_output('lettretype', $this->getVal('lettretype'), $collectivite, null, $params); |
5566 |
$pdf_output = $result['pdf_output']; |
$pdf_output = $result['pdf_output']; |
5567 |
|
|
5568 |
//Métadonnées du document |
//Métadonnées du document |
5569 |
$metadata = array( |
$metadata = array( |
5570 |
'filename' => 'instruction_'.$id_inst.'.pdf', |
'filename' => 'instruction_'.$id_inst.'.pdf', |
5576 |
$spe_metadata = $this->getMetadata("om_fichier_instruction"); |
$spe_metadata = $this->getMetadata("om_fichier_instruction"); |
5577 |
|
|
5578 |
//On vérifie si l'instruction à finaliser a un événement de type arrete |
//On vérifie si l'instruction à finaliser a un événement de type arrete |
5579 |
$sql = "SELECT type |
// TODO : A voir pour remplacer par une instanciation de l'événement. |
5580 |
FROM ".DB_PREFIXE."evenement |
// Voir également si l'événement ne dois pas être instancié en début de |
5581 |
WHERE evenement = ".$this->getVal("evenement"); |
// méthode pour pouvoir être réutilisé. |
5582 |
$typeEvenement = $this->db->getOne($sql); |
$qres = $this->f->get_one_result_from_db_query( |
5583 |
$this->addToLog(__METHOD__."(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
sprintf( |
5584 |
if ($this->f->isDatabaseError($typeEvenement, true) === true) { |
'SELECT |
5585 |
|
type |
5586 |
|
FROM |
5587 |
|
%1$sevenement |
5588 |
|
WHERE |
5589 |
|
evenement = \'%2$d\'', |
5590 |
|
DB_PREFIXE, |
5591 |
|
intval($this->getVal("evenement")) |
5592 |
|
), |
5593 |
|
array( |
5594 |
|
"origin" => __METHOD__, |
5595 |
|
"force_return" => true, |
5596 |
|
) |
5597 |
|
); |
5598 |
|
|
5599 |
|
if ($qres["code"] !== "OK") { |
5600 |
$this->correct = false; |
$this->correct = false; |
5601 |
$this->addToMessage($bdd_msg_error); |
$this->addToMessage($bdd_msg_error); |
5602 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
5605 |
//Initialisation de la variable |
//Initialisation de la variable |
5606 |
$arrete_metadata = array(); |
$arrete_metadata = array(); |
5607 |
// Si l'événement est de type arrete, on ajoute les métadonnées spécifiques |
// Si l'événement est de type arrete, on ajoute les métadonnées spécifiques |
5608 |
if ( $typeEvenement === 'arrete' ){ |
if ($qres['result'] === 'arrete'){ |
5609 |
$arrete_metadata = $this->getMetadata("arrete"); |
$arrete_metadata = $this->getMetadata("arrete"); |
5610 |
} |
} |
5611 |
|
|
5612 |
$metadata = array_merge($metadata, $spe_metadata, $arrete_metadata); |
$metadata = array_merge($metadata, $spe_metadata, $arrete_metadata); |
5613 |
|
|
5614 |
|
/* |
5615 |
|
// transforme le tableau de métadonnées en objet |
5616 |
|
$mdf = new MetadataFactory(); |
5617 |
|
$md = $mdf->build('Instruction', $metadata); |
5618 |
|
*/ |
5619 |
|
|
5620 |
// Si le document a déjà été finalisé on le met à jour |
// Si le document a déjà été finalisé on le met à jour |
5621 |
// en conservant son UID |
// en conservant son UID |
5622 |
if ($this->getVal("om_fichier_instruction") != ''){ |
if ($this->getVal("om_fichier_instruction") != ''){ |
5625 |
} |
} |
5626 |
// Sinon on crée un nouveau document et dont on récupère l'UID |
// Sinon on crée un nouveau document et dont on récupère l'UID |
5627 |
else { |
else { |
5628 |
$uid = $this->f->storage->create($pdf_output, $metadata); |
$uid = $this->f->storage->create($pdf_output, $metadata, "from_content", $this->table.".om_fichier_instruction"); |
5629 |
} |
} |
5630 |
} |
} |
5631 |
|
|
5642 |
if ($uid == '' || $uid == 'OP_FAILURE' ) { |
if ($uid == '' || $uid == 'OP_FAILURE' ) { |
5643 |
$this->correct = false; |
$this->correct = false; |
5644 |
$this->addToMessage($file_msg_error); |
$this->addToMessage($file_msg_error); |
5645 |
$this->addToLog(sprintf($log_msg_error, $id_inst, $uid)); |
$this->addToLog(sprintf($log_msg_error, $id_inst, $uid), DEBUG_MODE); |
5646 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
5647 |
} |
} |
5648 |
|
|
5679 |
$val['archive_date_retour_contradictoire'] = $this->dateDBToForm($val['archive_date_retour_contradictoire']); |
$val['archive_date_retour_contradictoire'] = $this->dateDBToForm($val['archive_date_retour_contradictoire']); |
5680 |
$val['archive_date_ait'] = $this->dateDBToForm($val['archive_date_ait']); |
$val['archive_date_ait'] = $this->dateDBToForm($val['archive_date_ait']); |
5681 |
$val['archive_date_transmission_parquet'] = $this->dateDBToForm($val['archive_date_transmission_parquet']); |
$val['archive_date_transmission_parquet'] = $this->dateDBToForm($val['archive_date_transmission_parquet']); |
5682 |
|
$val['archive_date_affichage'] = $this->dateDBToForm($val['archive_date_affichage']); |
5683 |
$this->setvalF($val); |
$this->setvalF($val); |
5684 |
|
|
5685 |
// Verification de la validite des donnees |
// Verification de la validite des donnees |
5686 |
$this->verifier($this->val, $this->db, DEBUG); |
$this->verifier($this->val); |
5687 |
// Si les verifications precedentes sont correctes, on procede a |
// Si les verifications precedentes sont correctes, on procede a |
5688 |
// la modification, sinon on ne fait rien et on retourne une erreur |
// la modification, sinon on ne fait rien et on retourne une erreur |
5689 |
if ($this->correct === true) { |
if ($this->correct === true) { |
5717 |
|
|
5718 |
// Execution de la requête de modification des donnees de l'attribut |
// Execution de la requête de modification des donnees de l'attribut |
5719 |
// valF de l'objet dans l'attribut table de l'objet |
// valF de l'objet dans l'attribut table de l'objet |
5720 |
$res = $this->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
$res = $this->f->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
5721 |
DB_AUTOQUERY_UPDATE, $this->getCle($id_inst)); |
DB_AUTOQUERY_UPDATE, $this->getCle($id_inst)); |
5722 |
$this->addToLog(__METHOD__."() : db->autoExecute(\"".DB_PREFIXE.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($id_inst)."\")", VERBOSE_MODE); |
$this->addToLog(__METHOD__."() : db->autoExecute(\"".DB_PREFIXE.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($id_inst)."\")", VERBOSE_MODE); |
5723 |
// |
// |
5738 |
} |
} |
5739 |
// L'appel de verifier() a déjà positionné correct à false |
// L'appel de verifier() a déjà positionné correct à false |
5740 |
// et défini un message d'erreur. |
// et défini un message d'erreur. |
5741 |
$this->addToLog(sprintf($log_msg_error, $id_inst, $uid)); |
$this->addToLog(sprintf($log_msg_error, $id_inst, $uid), DEBUG_MODE); |
5742 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
5743 |
} |
} |
5744 |
|
|
5746 |
* Récupération du numéro de dossier d'instruction à ajouter aux métadonnées |
* Récupération du numéro de dossier d'instruction à ajouter aux métadonnées |
5747 |
* @return string numéro de dossier d'instruction |
* @return string numéro de dossier d'instruction |
5748 |
*/ |
*/ |
5749 |
protected function getDossier() { |
protected function getDossier($champ = null) { |
5750 |
if(empty($this->specificMetadata)) { |
if(empty($this->specificMetadata)) { |
5751 |
$this->getSpecificMetadata(); |
$this->getSpecificMetadata(); |
5752 |
} |
} |
5843 |
} |
} |
5844 |
|
|
5845 |
// Requête sql |
// Requête sql |
5846 |
$sql = "SELECT libelle FROM ".DB_PREFIXE."evenement |
$evenement = $this->f->get_inst__om_dbform(array( |
5847 |
WHERE evenement=".$evenement; |
"obj" => "evenement", |
5848 |
$evenement_libelle = $this->db->getOne($sql); |
"idx" => $evenement |
5849 |
$this->addToLog("getTitle(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
)); |
|
if (database::isError($evenement_libelle)) { |
|
|
die(); |
|
|
} |
|
5850 |
|
|
5851 |
// Retourne le libelle de l'événement |
// Retourne le libelle de l'événement |
5852 |
return $evenement_libelle; |
return $evenement->getVal('libelle'); |
5853 |
} |
} |
5854 |
|
|
5855 |
|
|
5879 |
$dossier = $this->getVal("dossier"); |
$dossier = $this->getVal("dossier"); |
5880 |
} |
} |
5881 |
//Requête pour récupérer les informations essentiels sur le dossier d'instruction |
//Requête pour récupérer les informations essentiels sur le dossier d'instruction |
5882 |
$sql = "SELECT dossier.dossier as dossier, |
$qres = $this->f->get_all_results_from_db_query( |
5883 |
dossier_autorisation.dossier_autorisation as dossier_autorisation, |
sprintf( |
5884 |
to_char(dossier.date_demande, 'YYYY/MM') as date_demande_initiale, |
'SELECT |
5885 |
dossier_instruction_type.code as dossier_instruction_type, |
dossier.dossier AS dossier, |
5886 |
etat_dossier_autorisation.libelle as statut, |
dossier_autorisation.dossier_autorisation AS dossier_autorisation, |
5887 |
dossier_autorisation_type.code as dossier_autorisation_type, |
to_char(dossier.date_demande, \'YYYY/MM\') AS date_demande_initiale, |
5888 |
groupe.code as groupe_instruction, |
dossier_instruction_type.code AS dossier_instruction_type, |
5889 |
CASE WHEN dossier.erp IS TRUE |
etat_dossier_autorisation.libelle AS statut, |
5890 |
THEN 'true' |
dossier_autorisation_type.code AS dossier_autorisation_type, |
5891 |
ELSE 'false' |
groupe.code AS groupe_instruction, |
5892 |
END as erp |
CASE WHEN dossier.erp IS TRUE |
5893 |
FROM ".DB_PREFIXE."dossier |
THEN \'true\' |
5894 |
LEFT JOIN ".DB_PREFIXE."dossier_instruction_type |
ELSE \'false\' |
5895 |
|
END AS erp |
5896 |
|
FROM |
5897 |
|
%1$sdossier |
5898 |
|
LEFT JOIN %1$sdossier_instruction_type |
5899 |
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
5900 |
LEFT JOIN ".DB_PREFIXE."dossier_autorisation |
LEFT JOIN %1$sdossier_autorisation |
5901 |
ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
5902 |
LEFT JOIN ".DB_PREFIXE."etat_dossier_autorisation |
LEFT JOIN %1$setat_dossier_autorisation |
5903 |
ON dossier_autorisation.etat_dossier_autorisation = etat_dossier_autorisation.etat_dossier_autorisation |
ON dossier_autorisation.etat_dossier_autorisation = etat_dossier_autorisation.etat_dossier_autorisation |
5904 |
LEFT JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille |
LEFT JOIN %1$sdossier_autorisation_type_detaille |
5905 |
ON dossier_autorisation.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
ON dossier_autorisation.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
5906 |
LEFT JOIN ".DB_PREFIXE."dossier_autorisation_type |
LEFT JOIN %1$sdossier_autorisation_type |
5907 |
ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
5908 |
LEFT JOIN ".DB_PREFIXE."groupe |
LEFT JOIN %1$sgroupe |
5909 |
ON dossier_autorisation_type.groupe = groupe.groupe |
ON dossier_autorisation_type.groupe = groupe.groupe |
5910 |
WHERE dossier.dossier = '".$dossier."'"; |
WHERE |
5911 |
$res = $this->db->query($sql); |
dossier.dossier = \'%2$s\'', |
5912 |
$this->f->addToLog("getSpecificMetadata() : db->query(".$sql.")", VERBOSE_MODE); |
DB_PREFIXE, |
5913 |
if ( database::isError($res)){ |
$this->f->db->escapeSimple($dossier) |
5914 |
die(); |
), |
5915 |
} |
array( |
5916 |
|
"origin" => __METHOD__, |
5917 |
//Le résultat est récupéré dans un objet |
) |
5918 |
$row =& $res->fetchRow(DB_FETCHMODE_OBJECT); |
); |
5919 |
|
$row = array_shift($qres['result']); |
5920 |
|
|
5921 |
//Si il y a un résultat |
//Si il y a un résultat |
5922 |
if ($row !== null) { |
if (! empty($row)) { |
5923 |
|
|
5924 |
// Instrance de la classe dossier |
// Instrance de la classe dossier |
5925 |
$inst_dossier = $this->get_inst_dossier($dossier); |
$inst_dossier = $this->get_inst_dossier($dossier); |
5926 |
|
// TODO : améliorer ce code |
5927 |
|
// |
5928 |
|
// Avant l e résultat été récupéré dans un objet à partir de la requête mais en modifiant pour |
5929 |
|
// utiliser la méthode get_all_results_from_db_query() c'est maintenant un tableau |
5930 |
|
// qu'on obtiens. Pour garder le même fonctionnement on transforme le tableau des |
5931 |
|
// valeurs issues de la requête en objet. |
5932 |
|
$metadata = (object)$row; |
5933 |
// Insère l'attribut version à l'objet |
// Insère l'attribut version à l'objet |
5934 |
$row->version = $inst_dossier->get_dossier_instruction_version(); |
$metadata->version = $inst_dossier->get_di_numero_suffixe(); |
5935 |
|
|
5936 |
//Alors on créé l'objet dossier_instruction |
//Alors on créé l'objet dossier_instruction |
5937 |
$this->specificMetadata = $row; |
$this->specificMetadata = $metadata; |
5938 |
|
|
5939 |
} |
} |
5940 |
} |
} |
5953 |
|
|
5954 |
//On récupère le statut de l'état du dossier à partir de l'identifiant du |
//On récupère le statut de l'état du dossier à partir de l'identifiant du |
5955 |
//dossier |
//dossier |
5956 |
$sql = "SELECT etat.statut |
$qres = $this->f->get_one_result_from_db_query( |
5957 |
FROM ".DB_PREFIXE."dossier |
sprintf( |
5958 |
LEFT JOIN |
'SELECT |
5959 |
".DB_PREFIXE."etat |
etat.statut |
5960 |
ON |
FROM |
5961 |
dossier.etat = etat.etat |
%1$sdossier |
5962 |
WHERE dossier ='".$idx."'"; |
LEFT JOIN |
5963 |
$statut = $this->db->getOne($sql); |
%1$setat |
5964 |
$this->f->addToLog("getStatutAutorisationDossier() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
ON |
5965 |
if ( database::isError($statut)){ |
dossier.etat = etat.etat |
5966 |
die(); |
WHERE |
5967 |
} |
dossier = \'%2$s\'', |
5968 |
|
DB_PREFIXE, |
5969 |
|
$this->f->db->escapeSimple($idx) |
5970 |
|
), |
5971 |
|
array( |
5972 |
|
"origin" => __METHOD__, |
5973 |
|
) |
5974 |
|
); |
5975 |
} |
} |
5976 |
return $statut; |
|
5977 |
|
return $qres['result']; |
5978 |
} |
} |
5979 |
|
|
5980 |
/** |
/** |
5987 |
$return = array(); |
$return = array(); |
5988 |
|
|
5989 |
// Récupération de toutes les valeurs du dossier d'instruction en cours |
// Récupération de toutes les valeurs du dossier d'instruction en cours |
5990 |
$sql = "SELECT * FROM ".DB_PREFIXE."dossier |
// TODO : remplacer cette requête par une instanciation de l'objet |
5991 |
WHERE dossier='".$this->valF['dossier']."'"; |
$qres = $this->f->get_all_results_from_db_query( |
5992 |
$res = $this->db->query($sql); |
sprintf( |
5993 |
$this->addToLog("get_dossier_actual(): db->query(\"".$sql."\");", VERBOSE_MODE); |
'SELECT |
5994 |
$this->f->isDatabaseError($res); |
* |
5995 |
|
FROM |
5996 |
|
%1$sdossier |
5997 |
|
WHERE |
5998 |
|
dossier = \'%2$s\'', |
5999 |
|
DB_PREFIXE, |
6000 |
|
$this->f->db->escapeSimple($this->valF['dossier']) |
6001 |
|
), |
6002 |
|
array( |
6003 |
|
'origin' => __METHOD__ |
6004 |
|
) |
6005 |
|
); |
6006 |
|
|
6007 |
// |
foreach ($qres['result'] as $row) { |
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
|
6008 |
|
|
6009 |
// Récupération de la valeur actuelle du délai, de l'accord tacite, |
// Récupération de la valeur actuelle du délai, de l'accord tacite, |
6010 |
// de l'état et de l'avis du dossier d'instruction |
// de l'état et de l'avis du dossier d'instruction |
6035 |
$return['archive_dossier_instruction_type'] = $row['dossier_instruction_type']; |
$return['archive_dossier_instruction_type'] = $row['dossier_instruction_type']; |
6036 |
$return['duree_validite'] = $row['duree_validite']; |
$return['duree_validite'] = $row['duree_validite']; |
6037 |
$return['date_depot'] = $row['date_depot']; |
$return['date_depot'] = $row['date_depot']; |
6038 |
|
$return['date_depot_mairie'] = $row['date_depot_mairie']; |
6039 |
$return['archive_date_cloture_instruction'] = $row['date_cloture_instruction']; |
$return['archive_date_cloture_instruction'] = $row['date_cloture_instruction']; |
6040 |
$return['archive_date_premiere_visite'] = $row['date_premiere_visite']; |
$return['archive_date_premiere_visite'] = $row['date_premiere_visite']; |
6041 |
$return['archive_date_derniere_visite'] = $row['date_derniere_visite']; |
$return['archive_date_derniere_visite'] = $row['date_derniere_visite']; |
6043 |
$return['archive_date_retour_contradictoire'] = $row['date_retour_contradictoire']; |
$return['archive_date_retour_contradictoire'] = $row['date_retour_contradictoire']; |
6044 |
$return['archive_date_ait'] = $row['date_ait']; |
$return['archive_date_ait'] = $row['date_ait']; |
6045 |
$return['archive_date_transmission_parquet'] = $row['date_transmission_parquet']; |
$return['archive_date_transmission_parquet'] = $row['date_transmission_parquet']; |
6046 |
|
$return['archive_date_affichage'] = $row['date_affichage']; |
6047 |
|
$return['archive_pec_metier'] = $row['pec_metier']; |
6048 |
|
$return['archive_a_qualifier'] = $row['a_qualifier']; |
6049 |
} |
} |
6050 |
|
|
6051 |
// Retour de la fonction |
// Retour de la fonction |
6059 |
* @return boolean |
* @return boolean |
6060 |
*/ |
*/ |
6061 |
function checkEvenementNonVerrouillable($idx) { |
function checkEvenementNonVerrouillable($idx) { |
|
|
|
|
// Initialisation du résultat |
|
|
$non_verrouillable = false; |
|
|
|
|
6062 |
// Si la condition n'est pas vide |
// Si la condition n'est pas vide |
6063 |
if ($idx != "") { |
if ($idx != "") { |
6064 |
|
|
6065 |
// Requête SQL |
// Requête SQL |
6066 |
$sql = "SELECT evenement.non_verrouillable |
$qres = $this->f->get_one_result_from_db_query( |
6067 |
FROM ".DB_PREFIXE."evenement |
sprintf( |
6068 |
LEFT JOIN ".DB_PREFIXE."instruction |
'SELECT |
6069 |
ON instruction.evenement = evenement.evenement |
evenement.non_verrouillable |
6070 |
WHERE instruction.instruction = $idx"; |
FROM |
6071 |
$this->f->addToLog("checkEvenementNonVerrouillable() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
%1$sevenement |
6072 |
$res = $this->db->getOne($sql); |
LEFT JOIN %1$sinstruction |
6073 |
$this->f->isDatabaseError($res); |
ON instruction.evenement = evenement.evenement |
6074 |
|
WHERE |
6075 |
// Si le retour de la requête est true |
instruction.instruction = \'%2$s\'', |
6076 |
if ($res == 't') { |
DB_PREFIXE, |
6077 |
// |
intval($idx) |
6078 |
$non_verrouillable = true; |
), |
6079 |
} |
array( |
6080 |
|
"origin" => __METHOD__, |
6081 |
|
) |
6082 |
|
); |
6083 |
} |
} |
6084 |
|
|
6085 |
// Retourne résultat |
// Si on a un résultat et que ce résultat indique que l'événement n'est |
6086 |
return $non_verrouillable; |
// pas vérrouillable renvoie true, sinon renvoie false |
6087 |
|
return isset($qres) && isset($qres['result']) && $qres['result'] == 't'; |
6088 |
} |
} |
6089 |
|
|
6090 |
/** |
/** |
6161 |
if ($row['date_depot'] != '') { |
if ($row['date_depot'] != '') { |
6162 |
$this->valF['date_depot']= $row['date_depot']; |
$this->valF['date_depot']= $row['date_depot']; |
6163 |
} |
} |
6164 |
|
if ($row['date_depot_mairie'] != '') { |
6165 |
|
$this->valF['date_depot_mairie']= $row['date_depot_mairie']; |
6166 |
|
} |
6167 |
// Dates concernant les dossiers contentieux |
// Dates concernant les dossiers contentieux |
6168 |
if ($row['date_cloture_instruction'] != '') { |
if ($row['date_cloture_instruction'] != '') { |
6169 |
$this->valF['archive_date_cloture_instruction']= $row['date_cloture_instruction']; |
$this->valF['archive_date_cloture_instruction']= $row['date_cloture_instruction']; |
6186 |
if ($row['date_transmission_parquet'] != '') { |
if ($row['date_transmission_parquet'] != '') { |
6187 |
$this->valF['archive_date_transmission_parquet']= $row['date_transmission_parquet']; |
$this->valF['archive_date_transmission_parquet']= $row['date_transmission_parquet']; |
6188 |
} |
} |
6189 |
|
// |
6190 |
if ($row['dossier_instruction_type'] != '') { |
if ($row['dossier_instruction_type'] != '') { |
6191 |
$this->valF['archive_dossier_instruction_type']= $row['dossier_instruction_type']; |
$this->valF['archive_dossier_instruction_type']= $row['dossier_instruction_type']; |
6192 |
} |
} |
6193 |
|
if ($row['date_affichage'] != '') { |
6194 |
|
$this->valF['archive_date_affichage']= $row['date_affichage']; |
6195 |
|
} |
6196 |
|
if (isset($row['pec_metier']) === true && $row['pec_metier'] != '') { |
6197 |
|
$this->valF['archive_pec_metier']= $row['pec_metier']; |
6198 |
|
} |
6199 |
|
if (isset($row['a_qualifier']) === true && $row['a_qualifier'] != '') { |
6200 |
|
$this->valF['archive_a_qualifier']= $row['a_qualifier']; |
6201 |
|
} |
6202 |
} |
} |
6203 |
|
|
6204 |
// {{{ |
// {{{ |
6324 |
*/ |
*/ |
6325 |
function getArreteMetadata() { |
function getArreteMetadata() { |
6326 |
|
|
6327 |
//Récupération de la dernière instruction dont l'événement est de type 'arrete' |
//Récupération de la dernière instruction dont l'événement est de type 'arrete' |
6328 |
$this->metadonneesArrete = array("nomsignataire"=>"", "qualitesignataire"=>"", |
$this->metadonneesArrete = array("nomsignataire"=>"", "qualitesignataire"=>"", |
6329 |
"decisionarrete"=>"", "datenotification"=>"", "datesignaturearrete"=>"", |
"decisionarrete"=>"", "datenotification"=>"", "datesignaturearrete"=>"", |
6330 |
"datecontrolelegalite"=>"", "ap_numrue"=>"", "ap_nomdelavoie"=>"", |
"datecontrolelegalite"=>"", "ap_numrue"=>"", "ap_nomdelavoie"=>"", |
6331 |
"ap_codepostal"=>"", "ap_ville"=>""); |
"ap_codepostal"=>"", "ap_ville"=>""); |
6332 |
|
|
6333 |
$sqlArrete = "SELECT signataire_arrete.nom as \"nomsignataire\", |
$qres = $this->f->get_all_results_from_db_query( |
6334 |
signataire_arrete.qualite as \"qualitesignataire\", |
sprintf( |
6335 |
instruction.etat as \"decisionarrete\", |
'SELECT |
6336 |
instruction.date_retour_rar as \"datenotification\", |
signataire_arrete.prenom || \' \' ||signataire_arrete.nom as nomsignataire, |
6337 |
instruction.date_retour_signature as \"datesignaturearrete\", |
signataire_arrete.qualite as qualitesignataire, |
6338 |
instruction.date_retour_controle_legalite as \"datecontrolelegalite\", |
instruction.etat as decisionarrete, |
6339 |
dossier.terrain_adresse_voie_numero as \"ap_numrue\", |
instruction.date_retour_rar as datenotification, |
6340 |
dossier.terrain_adresse_voie as \"ap_nomdelavoie\", |
instruction.date_retour_signature as datesignaturearrete, |
6341 |
dossier.terrain_adresse_code_postal as \"ap_codepostal\", |
instruction.date_retour_controle_legalite as datecontrolelegalite, |
6342 |
dossier.terrain_adresse_localite as \"ap_ville\" |
dossier.terrain_adresse_voie_numero as ap_numrue, |
6343 |
FROM ".DB_PREFIXE."instruction |
dossier.terrain_adresse_voie as ap_nomdelavoie, |
6344 |
LEFT JOIN ".DB_PREFIXE."signataire_arrete ON |
dossier.terrain_adresse_code_postal as ap_codepostal, |
6345 |
instruction.signataire_arrete = signataire_arrete.signataire_arrete |
dossier.terrain_adresse_localite as ap_ville |
6346 |
LEFT JOIN ".DB_PREFIXE."dossier ON |
FROM |
6347 |
instruction.dossier = dossier.dossier |
%1$sinstruction |
6348 |
LEFT JOIN ".DB_PREFIXE."donnees_techniques ON |
LEFT JOIN %1$ssignataire_arrete |
6349 |
donnees_techniques.dossier_instruction = dossier.dossier |
ON instruction.signataire_arrete = signataire_arrete.signataire_arrete |
6350 |
WHERE instruction.instruction = ".$this->getVal("instruction"); |
LEFT JOIN %1$sdossier |
6351 |
$resArrete = $this->db->query($sqlArrete); |
ON instruction.dossier = dossier.dossier |
6352 |
$this->f->addToLog("getArreteMetadata(): db->query(\"".$sqlArrete."\");", VERBOSE_MODE); |
LEFT JOIN %1$sdonnees_techniques |
6353 |
if ( database::isError($resArrete)){ |
ON donnees_techniques.dossier_instruction = dossier.dossier |
6354 |
die(); |
WHERE |
6355 |
} |
instruction.instruction = %2$d', |
6356 |
|
DB_PREFIXE, |
6357 |
$this->metadonneesArrete = $resArrete->fetchRow(DB_FETCHMODE_ASSOC); |
intval($this->getVal('instruction')) |
6358 |
|
), |
6359 |
|
array( |
6360 |
|
'origin' => __METHOD__ |
6361 |
|
) |
6362 |
|
); |
6363 |
|
$this->metadonneesArrete = array_shift($qres['result']); |
6364 |
} |
} |
6365 |
|
|
6366 |
/** |
/** |
6384 |
} |
} |
6385 |
|
|
6386 |
/** |
/** |
6387 |
|
* CONDITION - is_modifiable. |
6388 |
|
* |
6389 |
|
* Controle si l'évenement est modifiable. |
6390 |
|
* |
6391 |
|
* @return boolean |
6392 |
|
*/ |
6393 |
|
function is_evenement_modifiable() { |
6394 |
|
$evenement = $this->get_inst_evenement($this->getVal('evenement')); |
6395 |
|
return ! $this->get_boolean_from_pgsql_value($evenement->getVal('non_modifiable')); |
6396 |
|
} |
6397 |
|
|
6398 |
|
/** |
6399 |
* CONDITION - is_editable. |
* CONDITION - is_editable. |
6400 |
* |
* |
6401 |
* Condition pour la modification. |
* Condition pour la modification. |
6403 |
* @return boolean |
* @return boolean |
6404 |
*/ |
*/ |
6405 |
function is_editable() { |
function is_editable() { |
6406 |
|
|
6407 |
|
// XXX |
6408 |
|
// Identifier si l'instruction est lié à une tâche depuis le champ object_id (mais aussi voir le log car object_id peut être modifié) |
6409 |
|
// Si cette tâche identifiée est DONE alors la suppression/modification de cette intruction est impossible |
6410 |
|
|
6411 |
// Contrôle si l'utilisateur possède un bypass |
// Contrôle si l'utilisateur possède un bypass |
6412 |
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_modifier_bypass"); |
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_modifier_bypass"); |
6413 |
// |
// |
6432 |
return true; |
return true; |
6433 |
} |
} |
6434 |
|
|
|
// Si l'utilisateur est instructeur de la commune du dossier et que la |
|
|
// décision peut être changée par la commune. |
|
|
if ($this->is_instructeur_from_collectivite_dossier() === true and |
|
|
$this->isInstrCanChangeDecision($this->getVal('dossier')) === true) { |
|
|
return true; |
|
|
} |
|
|
|
|
6435 |
// Si l'utilisateur est instructeur de la commune du dossier et que |
// Si l'utilisateur est instructeur de la commune du dossier et que |
6436 |
// l'instruction est créée par un instructeur de la commune |
// l'instruction est créée par un instructeur de la commune |
6437 |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
6444 |
} |
} |
6445 |
|
|
6446 |
/** |
/** |
6447 |
|
* Vérifie si l'événement est supprimable ou pas. |
6448 |
|
* |
6449 |
|
* @return boolean |
6450 |
|
*/ |
6451 |
|
function is_evenement_supprimable() { |
6452 |
|
// Controle si l'évenement est supprimable |
6453 |
|
$evenement = $this->get_inst_evenement($this->getVal('evenement')); |
6454 |
|
return ! $this->get_boolean_from_pgsql_value($evenement->getVal('non_supprimable')); |
6455 |
|
} |
6456 |
|
|
6457 |
|
/** |
6458 |
* CONDITION - is_deletable. |
* CONDITION - is_deletable. |
6459 |
* |
* |
6460 |
* Condition pour la suppression. |
* Condition pour la suppression. |
6462 |
* @return boolean |
* @return boolean |
6463 |
*/ |
*/ |
6464 |
function is_deletable() { |
function is_deletable() { |
6465 |
|
|
6466 |
|
// XXX |
6467 |
|
// Identifier si l'instruction est lié à une tâche depuis le champ object_id (mais aussi voir le log car object_id peut être modifié) |
6468 |
|
// Si cette tâche identifiée est DONE alors la suppression/modification de cette intruction est impossible |
6469 |
|
|
6470 |
// Contrôle si l'utilisateur possède un bypass intégral |
// Contrôle si l'utilisateur possède un bypass intégral |
6471 |
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_supprimer_bypass"); |
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_supprimer_bypass"); |
6472 |
// |
// |
6594 |
return true; |
return true; |
6595 |
} |
} |
6596 |
|
|
|
// Si l'utilisateur est instructeur de la commune du dossier et que la |
|
|
// décision peut être changée par la commune. |
|
|
if ($this->is_instructeur_from_collectivite_dossier() === true and |
|
|
$this->isInstrCanChangeDecision($this->getVal('dossier')) === true) { |
|
|
return true; |
|
|
} |
|
|
|
|
6597 |
// Si l'utilisateur est instructeur de la commune du dossier et que |
// Si l'utilisateur est instructeur de la commune du dossier et que |
6598 |
// l'instruction est créée par un instructeur de la commune |
// l'instruction est créée par un instructeur de la commune |
6599 |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
6659 |
return true; |
return true; |
6660 |
} |
} |
6661 |
|
|
|
// Si l'utilisateur est instructeur de la commune du dossier et que la |
|
|
// décision peut être changée par la commune. |
|
|
if ($this->is_instructeur_from_collectivite_dossier() === true and |
|
|
$this->isInstrCanChangeDecision($this->getVal('dossier')) === true) { |
|
|
return true; |
|
|
} |
|
|
|
|
6662 |
// Si l'utilisateur est instructeur de la commune du dossier et que |
// Si l'utilisateur est instructeur de la commune du dossier et que |
6663 |
// l'instruction est créée par un instructeur de la commune |
// l'instruction est créée par un instructeur de la commune |
6664 |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
6707 |
|
|
6708 |
|
|
6709 |
// 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 |
6710 |
$sql = |
// /!\ Requête lié à celles du widget indiquant les dossiers éligible au changement |
6711 |
"SELECT |
// de décision : |
6712 |
|
// * dossier_instruction.class.php : view_widget_dossiers_evenement_retour_finalise() |
6713 |
|
// * dossier_instruction.inc.php : si le paramètre filtre_decision = true |
6714 |
|
$sql = sprintf( |
6715 |
|
'SELECT |
6716 |
dossier.dossier |
dossier.dossier |
6717 |
FROM |
FROM |
6718 |
".DB_PREFIXE."dossier |
%1$sdossier |
6719 |
JOIN ".DB_PREFIXE."instruction ON instruction.instruction = ( |
JOIN %1$setat |
6720 |
SELECT instruction |
ON dossier.etat = etat.etat AND etat.statut = \'encours\' |
6721 |
FROM ".DB_PREFIXE."instruction |
JOIN %1$slien_dossier_demandeur |
6722 |
JOIN ".DB_PREFIXE."evenement on instruction.evenement=evenement.evenement |
ON dossier.dossier = lien_dossier_demandeur.dossier AND lien_dossier_demandeur.petitionnaire_principal IS TRUE |
6723 |
WHERE instruction.dossier = dossier.dossier |
JOIN %1$sdossier_instruction_type |
6724 |
AND evenement.retour IS FALSE |
ON dossier.dossier_instruction_type=dossier_instruction_type.dossier_instruction_type |
6725 |
ORDER BY date_evenement DESC, instruction DESC |
JOIN %1$sinstruction |
6726 |
LIMIT 1 |
-- Recherche de la dernière instruction qui ne soit pas liée à un événement retour |
6727 |
) |
ON instruction.instruction = ( |
6728 |
JOIN ".DB_PREFIXE."evenement ON instruction.evenement=evenement.evenement |
SELECT instruction |
6729 |
JOIN ".DB_PREFIXE."instructeur ON dossier.instructeur=instructeur.instructeur |
FROM %1$sinstruction |
6730 |
JOIN ".DB_PREFIXE."om_utilisateur ON instructeur.om_utilisateur=om_utilisateur.om_utilisateur |
JOIN %1$sevenement ON instruction.evenement=evenement.evenement |
6731 |
JOIN ".DB_PREFIXE."om_collectivite ON om_collectivite.om_collectivite=om_utilisateur.om_collectivite |
AND evenement.retour IS FALSE |
6732 |
JOIN ".DB_PREFIXE."etat ON dossier.etat = etat.etat |
WHERE instruction.dossier = dossier.dossier |
6733 |
|
ORDER BY date_evenement DESC, instruction DESC |
6734 |
|
LIMIT 1 |
6735 |
|
) |
6736 |
|
-- On ne garde que les dossiers pour lesquels la dernière instruction est finalisée |
6737 |
|
-- ou alors pour laquelle l instruction a été ajouté par la commune et est |
6738 |
|
-- non signée, non notifié, etc. |
6739 |
|
AND (instruction.om_final_instruction IS TRUE |
6740 |
|
OR instruction.created_by_commune IS TRUE) |
6741 |
|
AND instruction.date_retour_signature IS NULL |
6742 |
|
AND instruction.date_envoi_rar IS NULL |
6743 |
|
AND instruction.date_retour_rar IS NULL |
6744 |
|
AND instruction.date_envoi_controle_legalite IS NULL |
6745 |
|
AND instruction.date_retour_controle_legalite IS NULL |
6746 |
|
-- On vérifie que l instruction soit un arrêté ou un changement de décision |
6747 |
|
JOIN %1$sevenement |
6748 |
|
ON instruction.evenement=evenement.evenement |
6749 |
|
AND (evenement.type = \'arrete\' |
6750 |
|
OR evenement.type = \'changement_decision\') |
6751 |
|
-- Recherche les informations du pétitionnaire principal pour l affichage |
6752 |
|
JOIN %1$sdemandeur |
6753 |
|
ON lien_dossier_demandeur.demandeur = demandeur.demandeur |
6754 |
|
-- Recherche la collectivité rattachée à l instructeur |
6755 |
|
JOIN %1$sinstructeur |
6756 |
|
ON dossier.instructeur=instructeur.instructeur |
6757 |
|
JOIN %1$sdivision |
6758 |
|
ON instructeur.division=division.division |
6759 |
|
JOIN %1$sdirection |
6760 |
|
ON division.direction=direction.direction |
6761 |
|
JOIN %1$som_collectivite |
6762 |
|
ON direction.om_collectivite=om_collectivite.om_collectivite |
6763 |
WHERE |
WHERE |
6764 |
|
-- Vérification que la décision a été prise par l agglo |
6765 |
( |
om_collectivite.niveau = \'2\' |
6766 |
evenement.type = 'arrete' AND |
AND dossier.dossier = \'%2$s\' |
6767 |
( |
', |
6768 |
instruction.om_final_instruction IS TRUE |
DB_PREFIXE, |
6769 |
OR instruction.created_by_commune IS TRUE |
$this->f->db->escapeSimple($idx) |
6770 |
) 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' |
|
|
"; |
|
6771 |
|
|
6772 |
|
|
6773 |
// Si collectivité de l'utilisateur niveau mono alors filtre sur celle-ci |
// Si collectivité de l'utilisateur niveau mono alors filtre sur celle-ci |
6774 |
if ($this->f->isCollectiviteMono($_SESSION['collectivite']) === true) { |
if ($this->f->isCollectiviteMono($_SESSION['collectivite']) === true) { |
6775 |
$sql .= " AND dossier.om_collectivite=".$_SESSION['collectivite']; |
$sql .= sprintf( |
6776 |
} |
' AND dossier.om_collectivite = %1$d', |
6777 |
$res = $this->db->getone($sql); |
intval($_SESSION['collectivite']) |
6778 |
if (database::isError($res)) { |
); |
|
die(); |
|
|
} |
|
|
// Si le dossier n'est pas sujet au changement de decision |
|
|
if($res == null) { |
|
|
return false; |
|
6779 |
} |
} |
6780 |
return true; |
$qres = $this->f->get_one_result_from_db_query( |
6781 |
|
$sql, |
6782 |
|
array( |
6783 |
|
"origin" => __METHOD__, |
6784 |
|
) |
6785 |
|
); |
6786 |
|
|
6787 |
|
return $qres['result'] !== null; |
6788 |
} |
} |
6789 |
|
|
6790 |
|
|
6811 |
return true; |
return true; |
6812 |
} |
} |
6813 |
|
|
6814 |
// On vérifie en premier lieu que le DI n'est pas clôturé |
// Permission de modifier le suivi des dates sur un dossier cloturé pour |
6815 |
|
// un utilisateur lié à un instructeur |
6816 |
|
$perm_moni_dates_d_closed = $this->f->isAccredited($this->get_absolute_class_name()."_modification_dates_cloture"); |
6817 |
|
|
6818 |
|
// On vérifie en premier lieu que le DI n'est pas clôturé et que |
6819 |
|
// l'utilisateur ne possède pas la permission de modifier le suivi des |
6820 |
|
// dates sur un dossier clôturé |
6821 |
$inst_dossier = $this->get_inst_dossier(); |
$inst_dossier = $this->get_inst_dossier(); |
6822 |
if ($inst_dossier->getStatut() === 'cloture') { |
if ($inst_dossier->getStatut() === 'cloture' |
6823 |
|
&& $perm_moni_dates_d_closed === false) { |
6824 |
// |
// |
6825 |
return false; |
return false; |
6826 |
} |
} |
6869 |
|
|
6870 |
|
|
6871 |
/** |
/** |
6872 |
|
* CONDITION - is_finalized. |
6873 |
|
* |
6874 |
|
* Condition pour vérifier si une instruction est finalisée. |
6875 |
|
* |
6876 |
|
* @return boolean |
6877 |
|
*/ |
6878 |
|
public function is_finalized() { |
6879 |
|
|
6880 |
|
return $this->getVal('om_final_instruction') === "t"; |
6881 |
|
} |
6882 |
|
|
6883 |
|
/** |
6884 |
|
* CONDITION - is_not_date_retour_signature_set. |
6885 |
|
* |
6886 |
|
* Condition pour vérifier si une date de retour signature n'est pas définie. |
6887 |
|
* |
6888 |
|
* @return boolean |
6889 |
|
*/ |
6890 |
|
public function is_not_date_retour_signature_set() { |
6891 |
|
|
6892 |
|
return $this->getVal('date_retour_signature') == null; |
6893 |
|
|
6894 |
|
} |
6895 |
|
|
6896 |
|
|
6897 |
|
/** |
6898 |
* TREATMENT - finalize. |
* TREATMENT - finalize. |
6899 |
* |
* |
6900 |
* Permet de finaliser un enregistrement. |
* Permet de finaliser un enregistrement. |
6908 |
// 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 |
6909 |
// dites de TREATMENT. |
// dites de TREATMENT. |
6910 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
6911 |
|
$message = ''; |
6912 |
|
$ev = $this->get_inst_evenement($this->getVal('evenement')); |
6913 |
|
|
6914 |
|
// Controle du signataire |
6915 |
|
if (! $this->controle_signataire($ev)) { |
6916 |
|
$this->addToMessage(__("Le document ne peut pas être finalisé car aucun signataire n'a été sélectionné.")); |
6917 |
|
// Termine le traitement |
6918 |
|
return $this->end_treatment(__METHOD__, false); |
6919 |
|
} |
6920 |
|
|
6921 |
// Traitement de la finalisation |
// Traitement de la finalisation |
6922 |
$ret = $this->manage_finalizing("finalize", $val); |
$ret = $this->manage_finalizing("finalize", $val); |
6928 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
6929 |
} |
} |
6930 |
|
|
6931 |
|
// Envoi des notifications aux demandeurs si la notification est automatique |
6932 |
|
// et que la signature n'est pas requise |
6933 |
|
if ($ev->getVal('notification') === 'notification_automatique') { |
6934 |
|
// Préparation du message de log en cas d'erreur de notification |
6935 |
|
$msgLog = sprintf( |
6936 |
|
'%s %s : %d', |
6937 |
|
__('Erreur lors de la notification automatique du(des) pétitionnaire(s) suite à la finalisation de l\'instruction.'), |
6938 |
|
__('Instruction notifiée'), |
6939 |
|
$this->getVal($this->clePrimaire) |
6940 |
|
); |
6941 |
|
// Récupération de la catégorie et envoie des notifications au(x) demandeur(s) |
6942 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite($this->getVal('dossier')); |
6943 |
|
// Récupération de la liste des demandeurs à notifier et de la catégorie |
6944 |
|
$categorie = $this->f->get_param_option_notification($collectivite_di); |
6945 |
|
$isPortal = $categorie === PORTAL; |
6946 |
|
$demandeursANotifie = $this->get_demandeurs_notifiable( |
6947 |
|
$this->getVal('dossier'), |
6948 |
|
$isPortal |
6949 |
|
); |
6950 |
|
|
6951 |
|
// Création d'une notification et d'une tâche pour chaque demandeur à notifier |
6952 |
|
$demandeurPrincipalNotifie = false; |
6953 |
|
if (count($demandeursANotifie) > 0) { |
6954 |
|
foreach ($demandeursANotifie as $demandeur) { |
6955 |
|
// Identifie si le demandeur principal a été notifié ou pas |
6956 |
|
// et récupère ses informations |
6957 |
|
if ($demandeur['petitionnaire_principal'] == 't') { |
6958 |
|
$demandeurPrincipalNotifie = true; |
6959 |
|
// Si le demandeur principal est notifiable mais qu'il y a des erreurs dans |
6960 |
|
// son paramétrage, on effectue pas le traitement et on passe à l'itération |
6961 |
|
// suivante. On le considère également comme non notifié pour gérer l'envoie |
6962 |
|
// des messages d'erreurs |
6963 |
|
// Si la demande a été déposée via le portail alors le paramétrage n'a pas |
6964 |
|
// d'impact sur la notification |
6965 |
|
$erreursParam = $this->get_info_notification_fail(); |
6966 |
|
if (! $this->dossier_depose_sur_portail() && $erreursParam != array()) { |
6967 |
|
$demandeurPrincipalNotifie = false; |
6968 |
|
continue; |
6969 |
|
} |
6970 |
|
} |
6971 |
|
// Ajout de la notif et récupération de son id |
6972 |
|
$idNotif = $this->ajouter_notification( |
6973 |
|
$this->getVal($this->clePrimaire), |
6974 |
|
$this->f->get_connected_user_login_name(), |
6975 |
|
$demandeur, |
6976 |
|
$collectivite_di, |
6977 |
|
array(), |
6978 |
|
true |
6979 |
|
); |
6980 |
|
if ($idNotif === false) { |
6981 |
|
// Termine le traitement |
6982 |
|
$this->addToLog( |
6983 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
6984 |
|
DEBUG_MODE |
6985 |
|
); |
6986 |
|
return $this->end_treatment(__METHOD__, false); |
6987 |
|
} |
6988 |
|
$notification_by_task = $this->notification_by_task( |
6989 |
|
$idNotif, |
6990 |
|
$this->getVal('dossier'), |
6991 |
|
$categorie |
6992 |
|
); |
6993 |
|
if ($notification_by_task === false) { |
6994 |
|
$this->addToLog( |
6995 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
6996 |
|
DEBUG_MODE |
6997 |
|
); |
6998 |
|
$this->addToMessage( |
6999 |
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
7000 |
|
); |
7001 |
|
// Termine le traitement |
7002 |
|
return $this->end_treatment(__METHOD__, false); |
7003 |
|
} |
7004 |
|
$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."))); |
7005 |
|
} |
7006 |
|
} |
7007 |
|
// Pour la notification par mail ou la notification via portal si le dossier a |
7008 |
|
// été déposés via portal, si le demandeur principal n'est pas notifiable, |
7009 |
|
// on créé une nouvelle notification en erreur avec en commentaire la raison pour |
7010 |
|
// laquelle le demandeur principal n'a pas pu être notifié |
7011 |
|
$depotPortal = $this->dossier_depose_sur_portail(); |
7012 |
|
if (! $demandeurPrincipalNotifie && ($isPortal === false || $depotPortal === true)) { |
7013 |
|
// Préparation des logs pour indiquer que le pétitionnaire principale n'est pas notifiable |
7014 |
|
$msgLog .= sprintf(' %s', __('Le pétitionnaire principale n\'est pas notifiable.')); |
7015 |
|
// Analyse pour savoir pourquoi le demandeur principal n'est pas notifiable |
7016 |
|
$erreursParam = $this->get_info_notification_fail(); |
7017 |
|
$demandeurPrincipal = $this->get_info_petitionnaire_principal_dossier($this->getVal('dossier')); |
7018 |
|
// Ajout de la notif et récupération de son id |
7019 |
|
$idNotif = $this->ajouter_notification( |
7020 |
|
$this->valF[$this->clePrimaire], |
7021 |
|
$this->f->get_connected_user_login_name(), |
7022 |
|
$demandeurPrincipal, |
7023 |
|
$collectivite_di, |
7024 |
|
array(), |
7025 |
|
true, |
7026 |
|
'Echec', |
7027 |
|
implode(' ', $erreursParam) |
7028 |
|
); |
7029 |
|
if ($idNotif === false) { |
7030 |
|
$this->addToMessage( |
7031 |
|
__('Erreur : la création de la notification a échouée.'). |
7032 |
|
__("Veuillez contacter votre administrateur.") |
7033 |
|
); |
7034 |
|
$this->addToLog( |
7035 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
7036 |
|
DEBUG_MODE |
7037 |
|
); |
7038 |
|
return false; |
7039 |
|
} |
7040 |
|
// Prépare un message d'alerte à destination de l'instructeur pour l'informer |
7041 |
|
// de l'échec de la notification |
7042 |
|
$dossier_message = $this->get_inst_dossier_message(0); |
7043 |
|
$dossier_message_val = array( |
7044 |
|
'dossier' => $this->getVal('dossier'), |
7045 |
|
'type' => _('erreur expedition'), |
7046 |
|
'emetteur' => $this->f->get_connected_user_login_name(), |
7047 |
|
'login' => $_SESSION['login'], |
7048 |
|
'date_emission' => date('Y-m-d H:i:s'), |
7049 |
|
'contenu' => _('Échec lors de la notification de l\'instruction '). |
7050 |
|
$ev->getVal('libelle'). |
7051 |
|
'.<br>'. |
7052 |
|
implode("\n", $erreursParam). |
7053 |
|
'<br>'. |
7054 |
|
_('Veuillez corriger ces informations avant de renvoyer la notification.') |
7055 |
|
); |
7056 |
|
$add = $dossier_message->add_notification_message($dossier_message_val, true); |
7057 |
|
// Si une erreur se produit pendant l'ajout |
7058 |
|
if ($add !== true) { |
7059 |
|
$this->addToLog(__METHOD__."(): Le message d'alerte concernant l'echec de l'envoi de la notification n'a pas pu être envoyé.", DEBUG_MODE); |
7060 |
|
return false; |
7061 |
|
} |
7062 |
|
} |
7063 |
|
} |
7064 |
|
|
7065 |
// Termine le traitement |
// Termine le traitement |
7066 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
7067 |
} |
} |
7068 |
|
|
7069 |
/** |
/** |
7070 |
|
* Récupère l'instance de dossier message. |
7071 |
|
* |
7072 |
|
* @param string $dossier_message Identifiant du message. |
7073 |
|
* |
7074 |
|
* @return object |
7075 |
|
*/ |
7076 |
|
private function get_inst_dossier_message($dossier_message = null) { |
7077 |
|
// |
7078 |
|
return $this->get_inst_common("dossier_message", $dossier_message); |
7079 |
|
} |
7080 |
|
|
7081 |
|
/** |
7082 |
|
* Vérifie si le signataire est obligatoire pour finaliser |
7083 |
|
* le document apartir du paramétrage de l'événement. |
7084 |
|
* Si c'est le cas, vérifie si il y a bien un signataire |
7085 |
|
* renseigné. |
7086 |
|
* Si c'est le cas renvoie true, sinon renvoie false. |
7087 |
|
* |
7088 |
|
* @param evenement évenement de l'instruction permettant de |
7089 |
|
* récupérer le paramétrage |
7090 |
|
* @return boolean |
7091 |
|
*/ |
7092 |
|
protected function controle_signataire($evenement) { |
7093 |
|
// Vérifie si le signataire est obligatoire et si c'est le cas |
7094 |
|
// vérifie si il y a bien un signataire pour le document |
7095 |
|
if ($evenement->is_signataire_obligatoire() && |
7096 |
|
($this->getVal('signataire_arrete') === null || |
7097 |
|
$this->getVal('signataire_arrete') === '')) { |
7098 |
|
return false; |
7099 |
|
} |
7100 |
|
return true; |
7101 |
|
} |
7102 |
|
|
7103 |
|
/** |
7104 |
* TREATMENT - unfinalize. |
* TREATMENT - unfinalize. |
7105 |
* |
* |
7106 |
* Permet de définaliser un enregistrement. |
* Permet de définaliser un enregistrement. |
7230 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
7231 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
7232 |
|
|
|
// XXX APP |
|
|
|
|
|
$f = $this->f; |
|
|
|
|
7233 |
/** |
/** |
7234 |
* Affichage de la structure HTML |
* Affichage de la structure HTML |
7235 |
*/ |
*/ |
7236 |
// |
// |
7237 |
if ($f->isAjaxRequest()) { |
if ($this->f->isAjaxRequest()) { |
7238 |
// |
// |
7239 |
header("Content-type: text/html; charset=".HTTPCHARSET.""); |
header("Content-type: text/html; charset=".HTTPCHARSET.""); |
7240 |
} else { |
} else { |
7241 |
// |
// |
7242 |
$f->setFlag("htmlonly"); |
$this->f->setFlag("htmlonly"); |
7243 |
$f->display(); |
$this->f->display(); |
7244 |
} |
} |
7245 |
// |
// |
7246 |
$f->displayStartContent(); |
$this->f->displayStartContent(); |
7247 |
// |
// |
7248 |
$f->setTitle(_("Liste des éléments de la bible en lien avec un evenement")); |
$this->f->setTitle(_("Liste des éléments de la bible en lien avec un evenement")); |
7249 |
$f->displayTitle(); |
$this->f->displayTitle(); |
7250 |
|
|
7251 |
/** |
/** |
7252 |
* |
* |
7253 |
*/ |
*/ |
7254 |
// |
// |
7255 |
($f->get_submitted_get_value("ev") ? $evenement = $f->get_submitted_get_value("ev") : $evenement = ""); |
($this->f->get_submitted_get_value("ev") ? $evenement = $this->f->get_submitted_get_value("ev") : $evenement = ""); |
7256 |
$evenement = intval($evenement); |
$evenement = intval($evenement); |
7257 |
// |
// |
7258 |
($f->get_submitted_get_value("idx") ? $idx = $f->get_submitted_get_value("idx") : $idx = ""); |
($this->f->get_submitted_get_value("idx") ? $idx = $this->f->get_submitted_get_value("idx") : $idx = ""); |
7259 |
// Récupération du code du type de DA |
// Récupération du code du type de DA |
7260 |
$code_da_type = ''; |
$code_da_type = ''; |
7261 |
if (preg_match('/[A-Za-z]{2,3}/', $idx, $matches) !== false) { |
if (preg_match('/[A-Za-z]{2,3}/', $idx, $matches) !== false) { |
7262 |
$code_da_type = $matches[0]; |
$code_da_type = $matches[0]; |
7263 |
} |
} |
7264 |
// |
// |
7265 |
($f->get_submitted_get_value("complement") ? $complement = $f->get_submitted_get_value("complement") : $complement = "1"); |
($this->f->get_submitted_get_value("complement") ? $complement = $this->f->get_submitted_get_value("complement") : $complement = "1"); |
7266 |
|
|
7267 |
// Récupération de la collectivité du dossier |
// Récupération de la collectivité du dossier |
7268 |
$dossier = $this->f->get_inst__om_dbform(array( |
$dossier = $this->f->get_inst__om_dbform(array( |
7270 |
"idx" => $idx, |
"idx" => $idx, |
7271 |
)); |
)); |
7272 |
|
|
7273 |
/** |
$qres = $this->f->get_all_results_from_db_query( |
7274 |
* |
sprintf( |
7275 |
*/ |
'SELECT |
7276 |
// |
*, |
7277 |
$sql = "SELECT *, bible.libelle as bible_lib |
bible.libelle as bible_lib |
7278 |
FROM ".DB_PREFIXE."bible |
FROM |
7279 |
LEFT OUTER JOIN ".DB_PREFIXE."dossier_autorisation_type |
%1$sbible |
7280 |
ON bible.dossier_autorisation_type=dossier_autorisation_type.dossier_autorisation_type |
LEFT OUTER JOIN %1$sdossier_autorisation_type |
7281 |
LEFT JOIN ".DB_PREFIXE."om_collectivite |
ON bible.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
7282 |
ON bible.om_collectivite = om_collectivite.om_collectivite |
LEFT JOIN %1$som_collectivite |
7283 |
WHERE (evenement=".$evenement." OR evenement IS NULL) |
ON bible.om_collectivite = om_collectivite.om_collectivite |
7284 |
AND complement=".$complement." |
WHERE |
7285 |
AND (bible.dossier_autorisation_type IS NULL |
(evenement = %2$d |
7286 |
OR dossier_autorisation_type.code ='".$code_da_type."') |
OR evenement IS NULL) |
7287 |
AND (om_collectivite.niveau = '2' |
AND (complement = %3$d |
7288 |
OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").") |
OR complement IS NULL) |
7289 |
ORDER BY bible_lib ASC"; |
AND (bible.dossier_autorisation_type IS NULL |
7290 |
$res = $f->db->query($sql); |
OR dossier_autorisation_type.code = \'%4$s\') |
7291 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\");", VERBOSE_MODE); |
AND (om_collectivite.niveau = \'2\' |
7292 |
$f->isDatabaseError($res); |
OR bible.om_collectivite = %5$d) |
7293 |
|
ORDER BY |
7294 |
|
bible_lib ASC', |
7295 |
|
DB_PREFIXE, |
7296 |
|
intval($evenement), |
7297 |
|
intval($complement), |
7298 |
|
$this->f->db->escapeSimple($code_da_type), |
7299 |
|
intval($dossier->getVal("om_collectivite")) |
7300 |
|
), |
7301 |
|
array( |
7302 |
|
'origin' => __METHOD__ |
7303 |
|
) |
7304 |
|
); |
7305 |
// |
// |
7306 |
echo "<form method=\"post\" name=\"f3\" action=\"#\">\n"; |
echo "<form method=\"post\" name=\"f3\" action=\"#\">\n"; |
7307 |
// |
// |
7308 |
if ($res->numrows() > 0) { |
if ($qres['row_count'] > 0) { |
7309 |
// |
// |
7310 |
echo "\t<table id='tab-bible' width='100%'>\n"; |
echo "\t<table id='tab-bible' width='100%'>\n"; |
7311 |
// |
// |
7316 |
// |
// |
7317 |
$i = 0; |
$i = 0; |
7318 |
// |
// |
7319 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
foreach ($qres['result'] as $row) { |
7320 |
// |
// |
7321 |
echo "\t\t<tr"; |
echo "\t\t<tr"; |
7322 |
echo " class=\"".($i % 2 == 0 ? "odd" : "even")."\""; |
echo " class=\"".($i % 2 == 0 ? "odd" : "even")."\""; |
7333 |
echo "\t</table>\n"; |
echo "\t</table>\n"; |
7334 |
// |
// |
7335 |
echo "<div class=\"formControls\">\n"; |
echo "<div class=\"formControls\">\n"; |
7336 |
$f->layout->display_form_button(array( |
$this->f->layout->display_form_button(array( |
7337 |
"value" => _("Valider"), |
"value" => _("Valider"), |
7338 |
"onclick" => "bible_return('f2', 'complement".($complement == "1" ? "" : $complement)."_om_html'); return false;", |
"onclick" => "bible_return('f2', 'complement".($complement == "1" ? "" : $complement)."_om_html'); return false;", |
7339 |
)); |
)); |
7340 |
$f->displayLinkJsCloseWindow(); |
$this->f->displayLinkJsCloseWindow(); |
7341 |
echo "</div>\n"; |
echo "</div>\n"; |
7342 |
|
|
7343 |
} else { |
} else { |
7344 |
// |
// |
7345 |
$message_class = "error"; |
$message_class = "error"; |
7346 |
$message = _("Aucun element dans la bible pour l'evenement")." : ".$evenement; |
$message = _("Aucun element dans la bible pour l'evenement")." : ".$evenement; |
7347 |
$f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
7348 |
// |
// |
7349 |
echo "<div class=\"formControls\">\n"; |
echo "<div class=\"formControls\">\n"; |
7350 |
$f->displayLinkJsCloseWindow(); |
$this->f->displayLinkJsCloseWindow(); |
7351 |
echo "</div>\n"; |
echo "</div>\n"; |
7352 |
} |
} |
7353 |
// |
// |
7357 |
* Affichage de la structure HTML |
* Affichage de la structure HTML |
7358 |
*/ |
*/ |
7359 |
// |
// |
7360 |
$f->displayEndContent(); |
$this->f->displayEndContent(); |
7361 |
} |
} |
7362 |
|
|
7363 |
/** |
/** |
7370 |
function view_bible_auto() { |
function view_bible_auto() { |
7371 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
7372 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
|
|
|
|
// XXX APP |
|
|
|
|
|
$f = $this->f; |
|
|
|
|
7373 |
// |
// |
7374 |
$f->disableLog(); |
$this->f->disableLog(); |
7375 |
|
|
7376 |
$formatDate="AAAA-MM-JJ"; |
$formatDate="AAAA-MM-JJ"; |
7377 |
|
|
7378 |
// Récupération des paramètres |
// Récupération des paramètres |
7379 |
$idx = $f->get_submitted_get_value('idx'); |
$idx = $this->f->get_submitted_get_value('idx'); |
7380 |
$evenement = $f->get_submitted_get_value('ev'); |
$evenement = $this->f->get_submitted_get_value('ev'); |
7381 |
|
|
7382 |
// Initialisation de la variable de retour |
// Initialisation de la variable de retour |
7383 |
$retour['complement_om_html'] = ''; |
$retour['complement_om_html'] = ''; |
7384 |
$retour['complement2_om_html'] = ''; |
$retour['complement2_om_html'] = ''; |
7385 |
$retour['complement3_om_html'] = ''; |
$retour['complement3_om_html'] = ''; |
7386 |
$retour['complement4_om_html'] = ''; |
$retour['complement4_om_html'] = ''; |
7387 |
|
|
7388 |
// Vérification d'une consultation liée à l'événement |
// Vérification d'une consultation liée à l'événement |
7389 |
$consultation = $f->db->getOne( |
$instEvenement = $this->f->get_inst__om_dbform(array( |
7390 |
"select consultation from ".DB_PREFIXE."evenement where evenement=".$evenement |
"obj" => "evenement", |
7391 |
); |
"idx" => $evenement, |
7392 |
$f->isDatabaseError($consultation); |
)); |
7393 |
|
|
7394 |
// Si consultation liée, récupération du retour d'avis |
// Si consultation liée, récupération du retour d'avis |
7395 |
if($consultation=='Oui'){ |
if($instEvenement->getVal('consultation') == 'Oui'){ |
7396 |
$sql="select date_retour,avis_consultation.libelle as avis_consultation, |
|
7397 |
service.libelle as service |
$qres = $this->f->get_all_results_from_db_query( |
7398 |
from ".DB_PREFIXE."consultation inner join ".DB_PREFIXE."service |
sprintf( |
7399 |
on consultation.service =service.service |
'SELECT |
7400 |
left join ".DB_PREFIXE."avis_consultation on |
date_retour, |
7401 |
consultation.avis_consultation = avis_consultation.avis_consultation |
avis_consultation.libelle as avis_consultation, |
7402 |
where dossier ='".$idx."'"; |
COALESCE(service.libelle, tiers_consulte.libelle) as service |
7403 |
$res = $f->db->query($sql); |
FROM |
7404 |
$f->isDatabaseError($res); |
%1$sconsultation |
7405 |
|
LEFT JOIN %1$stiers_consulte |
7406 |
|
ON consultation.tiers_consulte = tiers_consulte.tiers_consulte |
7407 |
|
LEFT JOIN %1$sservice |
7408 |
|
ON consultation.service = service.service |
7409 |
|
LEFT JOIN %1$savis_consultation |
7410 |
|
ON consultation.avis_consultation = avis_consultation.avis_consultation |
7411 |
|
WHERE |
7412 |
|
dossier = \'%2$s\' |
7413 |
|
AND consultation.visible', |
7414 |
|
DB_PREFIXE, |
7415 |
|
$this->f->db->escapeSimple($idx) |
7416 |
|
), |
7417 |
|
array( |
7418 |
|
'origin' => __METHOD__ |
7419 |
|
) |
7420 |
|
); |
7421 |
// Récupération des consultations |
// Récupération des consultations |
7422 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
foreach ($qres['result'] as $row) { |
7423 |
$correct=false; |
$correct=false; |
7424 |
// date retour |
// date retour |
7425 |
if ($row['date_retour']<>""){ |
if ($row['date_retour']<>""){ |
7447 |
|
|
7448 |
} // consultation |
} // consultation |
7449 |
// Récupération des bibles automatiques pour le champ complement_om_html |
// Récupération des bibles automatiques pour le champ complement_om_html |
7450 |
$retour['complement_om_html'] .= $this->getBible($f, $evenement, $idx, '1'); |
$retour['complement_om_html'] .= $this->getBible($evenement, $idx, '1'); |
7451 |
// Récupération des bibles automatiques pour le champ complement2_om_html |
// Récupération des bibles automatiques pour le champ complement2_om_html |
7452 |
$retour['complement2_om_html'] .= $this->getBible($f, $evenement, $idx, '2'); |
$retour['complement2_om_html'] .= $this->getBible($evenement, $idx, '2'); |
7453 |
// Récupération des bibles automatiques pour le champ complement3_om_html |
// Récupération des bibles automatiques pour le champ complement3_om_html |
7454 |
$retour['complement3_om_html'] .= $this->getBible($f, $evenement, $idx, '3'); |
$retour['complement3_om_html'] .= $this->getBible($evenement, $idx, '3'); |
7455 |
// Récupération des bibles automatiques pour le champ complement4_om_html |
// Récupération des bibles automatiques pour le champ complement4_om_html |
7456 |
$retour['complement4_om_html'] .= $this->getBible($f, $evenement, $idx, '4'); |
$retour['complement4_om_html'] .= $this->getBible($evenement, $idx, '4'); |
7457 |
|
|
7458 |
|
|
7459 |
|
|
7472 |
$merge_fields = array(); |
$merge_fields = array(); |
7473 |
// |
// |
7474 |
if (array_key_exists('c1', $_POST) === true) { |
if (array_key_exists('c1', $_POST) === true) { |
7475 |
$merge_fields['[complement_instruction]'] = urldecode($_POST['c1']); |
$merge_fields['[complement_instruction]'] = $_POST['c1']; |
7476 |
$merge_fields['[complement1_instruction]'] = urldecode($_POST['c1']); |
$merge_fields['[complement1_instruction]'] = $_POST['c1']; |
7477 |
} |
} |
7478 |
if (array_key_exists('c2', $_POST) === true) { |
if (array_key_exists('c2', $_POST) === true) { |
7479 |
$merge_fields['[complement2_instruction]'] = urldecode($_POST['c2']); |
$merge_fields['[complement2_instruction]'] = $_POST['c2']; |
7480 |
} |
} |
7481 |
if (array_key_exists('c3', $_POST) === true) { |
if (array_key_exists('c3', $_POST) === true) { |
7482 |
$merge_fields['[complement3_instruction]'] = urldecode($_POST['c3']); |
$merge_fields['[complement3_instruction]'] = $_POST['c3']; |
7483 |
} |
} |
7484 |
if (array_key_exists('c4', $_POST) === true) { |
if (array_key_exists('c4', $_POST) === true) { |
7485 |
$merge_fields['[complement4_instruction]'] = urldecode($_POST['c4']); |
$merge_fields['[complement4_instruction]'] = $_POST['c4']; |
7486 |
} |
} |
7487 |
$params = array( |
$params = array( |
7488 |
"watermark" => true, |
"watermark" => true, |
7494 |
if (array_key_exists('corps', $_POST) === true) { |
if (array_key_exists('corps', $_POST) === true) { |
7495 |
$params["specific"]["corps"] = array( |
$params["specific"]["corps"] = array( |
7496 |
"mode" => "set", |
"mode" => "set", |
7497 |
"value" => urldecode($_POST['corps']), |
"value" => $_POST['corps'], |
7498 |
); |
); |
7499 |
} |
} |
7500 |
if (array_key_exists('titre', $_POST) === true) { |
if (array_key_exists('titre', $_POST) === true) { |
7501 |
$params["specific"]["titre"] = array( |
$params["specific"]["titre"] = array( |
7502 |
"mode" => "set", |
"mode" => "set", |
7503 |
"value" => urldecode($_POST['titre']), |
"value" => $_POST['titre'], |
7504 |
); |
); |
7505 |
} |
} |
7506 |
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
7544 |
/** |
/** |
7545 |
* Récupération des éléments de bible. |
* Récupération des éléments de bible. |
7546 |
* |
* |
|
* @param utils $f handler de om_application |
|
7547 |
* @param integer $event id de l'événement |
* @param integer $event id de l'événement |
7548 |
* @param string $idx id du dossier |
* @param string $idx id du dossier |
7549 |
* @param integer $compnb numéro du champ complement |
* @param integer $compnb numéro du champ complement |
7550 |
|
* @param string $type types possibles : automatique ou precharge |
7551 |
* |
* |
7552 |
* @return string Chaîne de texte à insérer dans le champ complement |
* @return string Chaîne de texte à insérer dans le champ complement |
7553 |
*/ |
*/ |
7554 |
function getBible($f, $event, $idx, $compnb) { |
function getBible($event, $idx, $compnb, $type = 'automatique') { |
7555 |
// Récupération de la collectivité du dossier |
// Récupération de la collectivité du dossier |
7556 |
$dossier = $this->f->get_inst__om_dbform(array( |
$dossier = $this->f->get_inst__om_dbform(array( |
7557 |
"obj" => "dossier", |
"obj" => "dossier", |
7562 |
if (preg_match('/[A-Za-z]{2,3}/', $idx, $matches) !== false) { |
if (preg_match('/[A-Za-z]{2,3}/', $idx, $matches) !== false) { |
7563 |
$code_da_type = $matches[0]; |
$code_da_type = $matches[0]; |
7564 |
} |
} |
|
// |
|
|
$sql = "SELECT * FROM ".DB_PREFIXE."bible |
|
|
LEFT OUTER JOIN ".DB_PREFIXE."dossier_autorisation_type |
|
|
ON bible.dossier_autorisation_type= |
|
|
dossier_autorisation_type.dossier_autorisation_type |
|
|
LEFT JOIN |
|
|
".DB_PREFIXE."om_collectivite |
|
|
ON bible.om_collectivite = om_collectivite.om_collectivite |
|
|
WHERE (evenement =".$event." or evenement IS NULL) and |
|
|
complement=".$compnb." and |
|
|
automatique='Oui' and |
|
|
(dossier_autorisation_type.code ='".$code_da_type."' or |
|
|
bible.dossier_autorisation_type IS NULL) and |
|
|
(om_collectivite.niveau = '2' OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").")"; |
|
7565 |
|
|
7566 |
$res = $f->db->query($sql); |
// Prépare le filtre de la requête selon le type de remplissage voulu |
7567 |
$f->isDatabaseError($res); |
$sql_filter_type = ''; |
7568 |
|
if ($type === 'automatique') { |
7569 |
|
$sql_filter_type = "AND automatique = 'Oui'"; |
7570 |
|
} elseif ($type === 'precharge') { |
7571 |
|
$sql_filter_type = "AND precharge IS TRUE"; |
7572 |
|
} |
7573 |
|
|
7574 |
|
$qres = $this->f->get_all_results_from_db_query( |
7575 |
|
sprintf( |
7576 |
|
'SELECT |
7577 |
|
* |
7578 |
|
FROM |
7579 |
|
%1$sbible |
7580 |
|
LEFT OUTER JOIN %1$sdossier_autorisation_type |
7581 |
|
ON bible.dossier_autorisation_type = |
7582 |
|
dossier_autorisation_type.dossier_autorisation_type |
7583 |
|
LEFT JOIN %1$som_collectivite |
7584 |
|
ON bible.om_collectivite = om_collectivite.om_collectivite |
7585 |
|
WHERE |
7586 |
|
(evenement = %2$d |
7587 |
|
OR evenement IS NULL) |
7588 |
|
AND (complement = %3$d |
7589 |
|
OR complement IS NULL) |
7590 |
|
AND (dossier_autorisation_type.code = \'%4$s\' |
7591 |
|
OR bible.dossier_autorisation_type IS NULL) |
7592 |
|
AND (om_collectivite.niveau = \'2\' |
7593 |
|
OR bible.om_collectivite = %5$d) |
7594 |
|
%6$s', |
7595 |
|
DB_PREFIXE, |
7596 |
|
intval($event), |
7597 |
|
intval($compnb), |
7598 |
|
$this->f->db->escapeSimple($code_da_type), |
7599 |
|
intval($dossier->getVal("om_collectivite")), |
7600 |
|
$sql_filter_type |
7601 |
|
), |
7602 |
|
array( |
7603 |
|
"origin" => __METHOD__ |
7604 |
|
) |
7605 |
|
); |
7606 |
$temp = ""; |
$temp = ""; |
7607 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
foreach ($qres['result'] as $row) { |
7608 |
// Remplacement des retours à la ligne par des br |
// Remplacement des retours à la ligne par des br |
7609 |
$temp .= preg_replace( |
$temp .= preg_replace( |
7610 |
'#(\\\r|\\\r\\\n|\\\n)#', '<br/>', $row['contenu'] |
'#(\\\r|\\\r\\\n|\\\n)#', '<br/>', $row['contenu'] |
7628 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
7629 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
7630 |
|
|
|
// XXX APP |
|
|
|
|
|
$f = $this->f; |
|
|
|
|
7631 |
/** |
/** |
7632 |
* Validation du formulaire |
* Validation du formulaire |
7633 |
*/ |
*/ |
7634 |
// Si le formulaire a été validé |
// Si le formulaire a été validé |
7635 |
if ($f->get_submitted_post_value("validation") !== null) { |
if ($this->f->get_submitted_post_value("validation") !== null) { |
7636 |
// Si un bordereau à été sélectionné |
// Si un bordereau à été sélectionné |
7637 |
if ($f->get_submitted_post_value("bordereau") !== null && $f->get_submitted_post_value("bordereau") == "" ) { |
if ($this->f->get_submitted_post_value("bordereau") !== null && $this->f->get_submitted_post_value("bordereau") == "" ) { |
7638 |
// Si aucun bordereau n'a été sélectionné |
// Si aucun bordereau n'a été sélectionné |
7639 |
$message_class = "error"; |
$message_class = "error"; |
7640 |
$message = _("Veuillez selectionner un bordereau."); |
$message = _("Veuillez selectionner un bordereau."); |
7641 |
} |
} |
7642 |
// Sinon si les dates ne sont pas valide |
// Sinon si les dates ne sont pas valide |
7643 |
elseif (($f->get_submitted_post_value("date_bordereau_debut") !== null |
elseif (($this->f->get_submitted_post_value("date_bordereau_debut") !== null |
7644 |
&& $f->get_submitted_post_value("date_bordereau_debut") == "") |
&& $this->f->get_submitted_post_value("date_bordereau_debut") == "") |
7645 |
|| ($f->get_submitted_post_value("date_bordereau_fin") !== null |
|| ($this->f->get_submitted_post_value("date_bordereau_fin") !== null |
7646 |
&& $f->get_submitted_post_value("date_bordereau_fin") == "")) { |
&& $this->f->get_submitted_post_value("date_bordereau_fin") == "")) { |
7647 |
// Si aucune date n'a été saisie |
// Si aucune date n'a été saisie |
7648 |
$message_class = "error"; |
$message_class = "error"; |
7649 |
$message = _("Veuillez saisir une date valide."); |
$message = _("Veuillez saisir une date valide."); |
7650 |
} |
} |
7651 |
// Sinon si les dates ne sont pas valides |
// Sinon si les dates ne sont pas valides |
7652 |
elseif ($f->get_submitted_post_value("bordereau") === "bordereau_avis_maire_prefet" |
elseif ($this->f->get_submitted_post_value("bordereau") === "bordereau_avis_maire_prefet" |
7653 |
&& $f->getParameter("id_evenement_bordereau_avis_maire_prefet") == null) { |
&& $this->f->getParameter("id_evenement_bordereau_avis_maire_prefet") == null) { |
7654 |
// Si aucune date n'a été saisie |
// Si aucune date n'a été saisie |
7655 |
$message_class = "error"; |
$message_class = "error"; |
7656 |
$message = _("Erreur de parametrage. Contactez votre administrateur."); |
$message = _("Erreur de parametrage. Contactez votre administrateur."); |
7658 |
// Affiche le message de validation |
// Affiche le message de validation |
7659 |
else { |
else { |
7660 |
// On récupère le libellé du bordereau pour l'afficher à l'utilisateur |
// On récupère le libellé du bordereau pour l'afficher à l'utilisateur |
7661 |
$sql = "SELECT om_etat.libelle |
$etat = $this->f->get_inst__om_dbform(array( |
7662 |
FROM ".DB_PREFIXE."om_etat |
"obj" => "om_etat", |
7663 |
WHERE om_etat.id = '".$f->get_submitted_post_value("bordereau")."'"; |
"idx" => $this->f->get_submitted_post_value("bordereau") |
7664 |
$res = $f->db->getone($sql); |
)); |
7665 |
$f->addToLog(__METHOD__.": db->getone(\"".$sql."\")", VERBOSE_MODE); |
$qres = $this->f->get_one_result_from_db_query( |
7666 |
$f->isDatabaseError($res); |
sprintf( |
7667 |
|
'SELECT |
7668 |
|
om_etat.libelle |
7669 |
|
FROM |
7670 |
|
%som_etat |
7671 |
|
WHERE |
7672 |
|
om_etat.id = \'%s\'', |
7673 |
|
DB_PREFIXE, |
7674 |
|
$this->f->db->escapeSimple($this->f->get_submitted_post_value("bordereau")) |
7675 |
|
), |
7676 |
|
array( |
7677 |
|
"origin" => __METHOD__, |
7678 |
|
) |
7679 |
|
); |
7680 |
|
|
7681 |
// |
// |
7682 |
$message_class = "valid"; |
$message_class = "valid"; |
7683 |
$message = _("Cliquez sur le lien ci-dessous pour telecharger votre bordereau"); |
$message = _("Cliquez sur le lien ci-dessous pour telecharger votre bordereau"); |
7687 |
$message .= "href='".OM_ROUTE_FORM."&obj=instruction"; |
$message .= "href='".OM_ROUTE_FORM."&obj=instruction"; |
7688 |
$message .= "&action=220"; |
$message .= "&action=220"; |
7689 |
$message .= "&idx=0"; |
$message .= "&idx=0"; |
7690 |
$message .= "&type_bordereau=".$f->get_submitted_post_value("bordereau"); |
$message .= "&type_bordereau=".$this->f->get_submitted_post_value("bordereau"); |
7691 |
$message .= "&date_bordereau_debut=".$f->get_submitted_post_value("date_bordereau_debut"); |
$message .= "&date_bordereau_debut=".$this->f->get_submitted_post_value("date_bordereau_debut"); |
7692 |
$message .= "&date_bordereau_fin=".$f->get_submitted_post_value("date_bordereau_fin"); |
$message .= "&date_bordereau_fin=".$this->f->get_submitted_post_value("date_bordereau_fin"); |
7693 |
// Si l'utilisateur est MULTI alors on ajoute le paramètre collectivite |
// Si l'utilisateur est MULTI alors on ajoute le paramètre collectivite |
7694 |
if ($f->get_submitted_post_value("om_collectivite") !== null) { |
if ($this->f->get_submitted_post_value("om_collectivite") !== null) { |
7695 |
$message .= "&collectivite=".$f->get_submitted_post_value("om_collectivite"); |
$message .= "&collectivite=".$this->f->get_submitted_post_value("om_collectivite"); |
7696 |
} |
} |
7697 |
$message .= "'"." target='_blank'>"; |
$message .= "'"." target='_blank'>"; |
7698 |
$message .= $res." "._("du")." ".$f->get_submitted_post_value("date_bordereau_debut") |
$message .= $qres['result']." "._("du")." ".$this->f->get_submitted_post_value("date_bordereau_debut") |
7699 |
." "._("au")." ".$f->get_submitted_post_value("date_bordereau_fin"); |
." "._("au")." ".$this->f->get_submitted_post_value("date_bordereau_fin"); |
7700 |
$message .= "</a>"; |
$message .= "</a>"; |
7701 |
} |
} |
7702 |
} |
} |
7706 |
*/ |
*/ |
7707 |
// Affichage du message de validation ou d'erreur |
// Affichage du message de validation ou d'erreur |
7708 |
if (isset($message) && isset($message_class) && $message != "") { |
if (isset($message) && isset($message_class) && $message != "") { |
7709 |
$f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
7710 |
} |
} |
7711 |
// Ouverture du formulaire |
// Ouverture du formulaire |
7712 |
printf("\t<form"); |
printf("\t<form"); |
7716 |
printf(">\n"); |
printf(">\n"); |
7717 |
// Paramétrage des champs du formulaire |
// Paramétrage des champs du formulaire |
7718 |
$champs = array("date_bordereau_debut", "date_bordereau_fin", "bordereau"); |
$champs = array("date_bordereau_debut", "date_bordereau_fin", "bordereau"); |
7719 |
// Si l'utilisateur est d'une collectivité de niveau 2 on affiche un select |
// Si l'utilisateur est d'une collectivité de niveau 2 on affiche un select |
7720 |
// collectivité dans le formulaire |
// collectivité dans le formulaire |
7721 |
if($_SESSION["niveau"] == 2) { |
if ($_SESSION["niveau"] == 2) { |
7722 |
array_push($champs, "om_collectivite"); |
array_push($champs, "om_collectivite"); |
7723 |
} |
} |
7724 |
// Création d'un nouvel objet de type formulaire |
// Création d'un nouvel objet de type formulaire |
7748 |
$form->setType("bordereau", "select"); |
$form->setType("bordereau", "select"); |
7749 |
$form->setRequired("bordereau"); |
$form->setRequired("bordereau"); |
7750 |
// Valeurs des champs |
// Valeurs des champs |
7751 |
if ($f->get_submitted_post_value("validation") !== null) { |
if ($this->f->get_submitted_post_value("validation") !== null) { |
7752 |
$form->setVal("date_bordereau_debut", $f->get_submitted_post_value("date_bordereau_debut")); |
$form->setVal("date_bordereau_debut", $this->f->get_submitted_post_value("date_bordereau_debut")); |
7753 |
$form->setVal("date_bordereau_fin", $f->get_submitted_post_value("date_bordereau_fin")); |
$form->setVal("date_bordereau_fin", $this->f->get_submitted_post_value("date_bordereau_fin")); |
7754 |
$form->setVal("bordereau", $f->get_submitted_post_value("bordereau")); |
$form->setVal("bordereau", $this->f->get_submitted_post_value("bordereau")); |
7755 |
$form->setVal("om_collectivite", $f->get_submitted_post_value("om_collectivite")); |
$form->setVal("om_collectivite", $this->f->get_submitted_post_value("om_collectivite")); |
7756 |
} |
} |
7757 |
// Données du select - On récupère ici la liste de tous les états disponibles |
// Données du select - On récupère ici la liste de tous les états disponibles |
7758 |
// dans la table om_etat qui ont un id qui commence par la cahine de caractères |
// dans la table om_etat qui ont un id qui commence par la cahine de caractères |
7759 |
// 'bordereau_' |
// 'bordereau_' |
7760 |
$sql = "SELECT om_etat.id, om_etat.libelle |
$qres = $this->f->get_all_results_from_db_query( |
7761 |
FROM ".DB_PREFIXE."om_etat |
sprintf( |
7762 |
WHERE om_etat.id LIKE 'bordereau_%' |
'SELECT |
7763 |
ORDER BY om_etat.id"; |
om_etat.id, |
7764 |
$res = $f->db->query($sql); |
om_etat.libelle |
7765 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
FROM |
7766 |
$f->isDatabaseError($res); |
%1$som_etat |
7767 |
|
WHERE |
7768 |
|
om_etat.id LIKE \'bordereau_%%\' |
7769 |
|
ORDER BY |
7770 |
|
om_etat.id', |
7771 |
|
DB_PREFIXE |
7772 |
|
), |
7773 |
|
array( |
7774 |
|
"origin" => __METHOD__ |
7775 |
|
) |
7776 |
|
); |
7777 |
// Données du select |
// Données du select |
7778 |
$contenu = array( |
$contenu = array( |
7779 |
0 => array("", ), |
0 => array("", ), |
7780 |
1 => array(_("choisir bordereau")), |
1 => array(_("choisir bordereau")), |
7781 |
); |
); |
7782 |
while ($row =& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
foreach ($qres['result'] as $row) { |
7783 |
$contenu[0][] = $row['id']; |
$contenu[0][] = $row['id']; |
7784 |
$contenu[1][] = $row['libelle']; |
$contenu[1][] = $row['libelle']; |
7785 |
} |
} |
7786 |
$form->setSelect("bordereau", $contenu); |
$form->setSelect("bordereau", $contenu); |
7787 |
// |
// |
7788 |
if($_SESSION["niveau"] == 2) { |
if ($_SESSION["niveau"] == 2) { |
7789 |
$form->setLib("om_collectivite", _("collectivite")); |
$form->setLib("om_collectivite", _("collectivite")); |
7790 |
$form->setType("om_collectivite", "select"); |
$form->setType("om_collectivite", "select"); |
7791 |
|
|
7792 |
// Données du select - On récupère ici la liste de tous toutes les collectivités |
// Données du select - On récupère ici la liste de tous toutes les collectivités |
7793 |
// de niveau 1 |
// de niveau 1 |
7794 |
$sql = "SELECT om_collectivite, libelle |
$qres = $this->f->get_all_results_from_db_query( |
7795 |
FROM ".DB_PREFIXE."om_collectivite |
sprintf( |
7796 |
WHERE niveau = '1' ORDER BY libelle"; |
'SELECT |
7797 |
$res = $f->db->query($sql); |
om_collectivite, |
7798 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
libelle |
7799 |
$f->isDatabaseError($res); |
FROM |
7800 |
// La valeur par défaut du select est Toutes |
%1$som_collectivite |
7801 |
$list_collectivites = array( |
WHERE |
7802 |
0 => array("", ), |
niveau = \'1\' |
7803 |
1 => array(_("toutes")) |
ORDER BY |
7804 |
); |
libelle', |
7805 |
|
DB_PREFIXE |
7806 |
$id_colls = ""; |
), |
7807 |
// On stocke dans $id_colls l'id de toutes les collectivités de niveau 1 séparées |
array( |
7808 |
// par des virgules, pour un traitement plus facile dans la requête de sous-état |
"origin" => __METHOD__ |
7809 |
while ($row =& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
) |
7810 |
if ($id_colls != "") { |
); |
7811 |
$id_colls .= ","; |
// La valeur par défaut du select est Toutes |
7812 |
} |
$list_collectivites = array( |
7813 |
$id_colls .= $row['om_collectivite']; |
0 => array("", ), |
7814 |
$list_collectivites[0][] = $row['om_collectivite']; |
1 => array(_("toutes")) |
7815 |
$list_collectivites[1][] = $row['libelle']; |
); |
|
} |
|
|
// On affecte la liste d'identifiants à l'option Toutes |
|
|
$list_collectivites[0][0] = $id_colls ; |
|
|
$form->setSelect("om_collectivite", $list_collectivites); |
|
|
} |
|
7816 |
|
|
7817 |
|
$id_colls = ""; |
7818 |
|
// On stocke dans $id_colls l'id de toutes les collectivités de niveau 1 séparées |
7819 |
|
// par des virgules, pour un traitement plus facile dans la requête de sous-état |
7820 |
|
foreach ($qres['result'] as $row) { |
7821 |
|
if ($id_colls != "") { |
7822 |
|
$id_colls .= ","; |
7823 |
|
} |
7824 |
|
$id_colls .= $row['om_collectivite']; |
7825 |
|
$list_collectivites[0][] = $row['om_collectivite']; |
7826 |
|
$list_collectivites[1][] = $row['libelle']; |
7827 |
|
} |
7828 |
|
// On affecte la liste d'identifiants à l'option Toutes |
7829 |
|
$list_collectivites[0][0] = $id_colls ; |
7830 |
|
$form->setSelect("om_collectivite", $list_collectivites); |
7831 |
|
} |
7832 |
// Affichage du formulaire |
// Affichage du formulaire |
7833 |
$form->entete(); |
$form->entete(); |
7834 |
$form->afficher($champs, 0, false, false); |
$form->afficher($champs, 0, false, false); |
7835 |
$form->enpied(); |
$form->enpied(); |
7836 |
// Affichage du bouton |
// Affichage du bouton |
7837 |
printf("\t<div class=\"formControls\">\n"); |
printf("\t<div class=\"formControls\">\n"); |
7838 |
$f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
$this->f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
7839 |
printf("\t</div>\n"); |
printf("\t</div>\n"); |
7840 |
// Fermeture du formulaire |
// Fermeture du formulaire |
7841 |
printf("\t</form>\n"); |
printf("\t</form>\n"); |
|
|
|
7842 |
} |
} |
7843 |
|
|
7844 |
|
|
7867 |
/** |
/** |
7868 |
* VIEW - view_suivi_envoi_lettre_rar. |
* VIEW - view_suivi_envoi_lettre_rar. |
7869 |
* |
* |
7870 |
* Vu pour imprimer les RAR. |
* Vue pour imprimer les AR. |
7871 |
* |
* |
7872 |
* @return void |
* @return void |
7873 |
*/ |
*/ |
7875 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
7876 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
7877 |
|
|
|
// XXX APP |
|
|
|
|
|
$f = $this->f; |
|
|
|
|
7878 |
// |
// |
7879 |
if ($f->get_submitted_post_value("date") !== null) { |
if ($this->f->get_submitted_post_value("date") !== null) { |
7880 |
$date = $f->get_submitted_post_value("date"); |
$date = $this->f->get_submitted_post_value("date"); |
7881 |
} else { |
} else { |
7882 |
$date = ""; |
$date = ""; |
7883 |
} |
} |
7884 |
// |
// |
7885 |
if ($f->get_submitted_post_value("liste_code_barres_instruction") !== null) { |
if ($this->f->get_submitted_post_value("liste_code_barres_instruction") !== null) { |
7886 |
$liste_code_barres_instruction = $f->get_submitted_post_value("liste_code_barres_instruction"); |
$liste_code_barres_instruction = $this->f->get_submitted_post_value("liste_code_barres_instruction"); |
7887 |
} else { |
} else { |
7888 |
$liste_code_barres_instruction = ""; |
$liste_code_barres_instruction = ""; |
7889 |
} |
} |
7909 |
* Validation du formulaire |
* Validation du formulaire |
7910 |
*/ |
*/ |
7911 |
// Si le formulaire a été validé |
// Si le formulaire a été validé |
7912 |
if ($f->get_submitted_post_value('validation') !== null) { |
if ($this->f->get_submitted_post_value('validation') !== null) { |
7913 |
// |
// |
7914 |
if (empty($date) || empty($liste_code_barres_instruction)) { |
if (empty($date) || empty($liste_code_barres_instruction)) { |
7915 |
// |
// |
7917 |
$message = _("Tous les champs doivent etre remplis."); |
$message = _("Tous les champs doivent etre remplis."); |
7918 |
} else { |
} else { |
7919 |
// Création d'un tableau d'instruction |
// Création d'un tableau d'instruction |
7920 |
$liste = explode("\r\n", $f->get_submitted_post_value("liste_code_barres_instruction")); |
$liste = explode("\r\n", $this->f->get_submitted_post_value("liste_code_barres_instruction")); |
7921 |
// |
// |
7922 |
foreach ($liste as $code_barres) { |
foreach ($liste as $code_barres) { |
7923 |
// On enlève les éventuels espaces saisis |
// On enlève les éventuels espaces saisis |
7953 |
$conditions = implode(" OR ", $group_clause); |
$conditions = implode(" OR ", $group_clause); |
7954 |
$sql .= " AND (" . $conditions . ")"; |
$sql .= " AND (" . $conditions . ")"; |
7955 |
|
|
7956 |
$nbInstr = $f->db->getone($sql); |
$qres = $this->f->get_one_result_from_db_query( |
7957 |
$f->addToLog(__METHOD__.": db->getone(\"".$sql."\")", VERBOSE_MODE); |
$sql, |
7958 |
$f->isDatabaseError($nbInstr); |
array( |
7959 |
// |
"origin" => __METHOD__, |
7960 |
if ($nbInstr == "1") { |
) |
7961 |
|
); |
7962 |
|
|
7963 |
|
if ($qres['result'] == "1") { |
7964 |
// Récupération de la date d'envoi de l'instruction bippé |
// Récupération de la date d'envoi de l'instruction bippé |
7965 |
$sql = "SELECT to_char(date_envoi_rar,'DD/MM/YYYY') as date_envoi_rar, instruction FROM ".DB_PREFIXE."instruction WHERE code_barres='".$code_barres."'"; |
$qres = $this->f->get_all_results_from_db_query( |
7966 |
$res = $f->db->query($sql); |
sprintf( |
7967 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
'SELECT |
7968 |
$f->isDatabaseError($res); |
to_char(date_envoi_rar, \'DD/MM/YYYY\') as date_envoi_rar, |
7969 |
$row =& $res->fetchRow(DB_FETCHMODE_ASSOC); |
instruction |
7970 |
|
FROM |
7971 |
|
%1$sinstruction |
7972 |
|
WHERE |
7973 |
|
code_barres = \'%2$s\'', |
7974 |
|
DB_PREFIXE, |
7975 |
|
$this->f->db->escapeSimple($code_barres) |
7976 |
|
), |
7977 |
|
array( |
7978 |
|
'origin' => __METHOD__ |
7979 |
|
) |
7980 |
|
); |
7981 |
|
$row = array_shift($qres['result']); |
7982 |
// Si pas de date ou correspond à la date du formulaire on |
// Si pas de date ou correspond à la date du formulaire on |
7983 |
// effectue le traitement |
// effectue le traitement |
7984 |
if ($row["date_envoi_rar"] == "" || $row["date_envoi_rar"] == $date) { |
if ($row["date_envoi_rar"] == "" || $row["date_envoi_rar"] == $date) { |
8051 |
$instr->setParameter('maj', 1); |
$instr->setParameter('maj', 1); |
8052 |
$instr->class_actions[1]["identifier"] = |
$instr->class_actions[1]["identifier"] = |
8053 |
"envoi lettre RAR (depuis le menu suivi des pièces)"; |
"envoi lettre RAR (depuis le menu suivi des pièces)"; |
8054 |
if ($instr->modifier($valF, $f->db, DEBUG) == true) { |
if ($instr->modifier($valF) == true) { |
8055 |
$id4Gen[] = $code_barres; |
$id4Gen[] = $code_barres; |
8056 |
$nbLettres ++; |
$nbLettres ++; |
8057 |
} else { |
} else { |
8106 |
*/ |
*/ |
8107 |
// Affichage du message de validation ou d'erreur |
// Affichage du message de validation ou d'erreur |
8108 |
if (isset($message) && isset($message_class) && $message != "") { |
if (isset($message) && isset($message_class) && $message != "") { |
8109 |
$f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
8110 |
} |
} |
8111 |
// Affichage du message d'erreur |
// Affichage du message d'erreur |
8112 |
if(!empty($error)) { |
if(!empty($error)) { |
8113 |
$f->displayMessage("error", $error); |
$this->f->displayMessage("error", $error); |
8114 |
} |
} |
8115 |
// Affichage du message de validation de la saisie |
// Affichage du message de validation de la saisie |
8116 |
if ($nbLettres > 0) { |
if ($nbLettres > 0) { |
8122 |
echo _("Cliquez sur le lien ci-dessous pour telecharger votre document"); |
echo _("Cliquez sur le lien ci-dessous pour telecharger votre document"); |
8123 |
echo " : \n<br/><br/>"; |
echo " : \n<br/><br/>"; |
8124 |
echo "\n<a class='om-prev-icon pdf-16'"; |
echo "\n<a class='om-prev-icon pdf-16'"; |
8125 |
echo "\n title=\""._("imprimer les RAR")."\""; |
echo "\n title=\""._("imprimer les AR")."\""; |
8126 |
echo "\n href=\"".OM_ROUTE_FORM."&obj=instruction&action=180&idx=0&liste=".implode(",",$id4Gen)."\""; |
echo "\n href=\"".OM_ROUTE_FORM."&obj=instruction&action=180&idx=0&liste=".implode(",",$id4Gen)."\""; |
8127 |
echo "\n target='_blank'>"; |
echo "\n target='_blank'>"; |
8128 |
echo _("Telecharger le document pour")." ".$nbLettres." "._("RAR"); |
echo _("Telecharger le document pour")." ".$nbLettres." "._("AR"); |
8129 |
echo "\n</a>"; |
echo "\n</a>"; |
8130 |
echo "\n</span>"; |
echo "\n</span>"; |
8131 |
echo "\n</p>"; |
echo "\n</p>"; |
8224 |
$form->enpied(); |
$form->enpied(); |
8225 |
// Affichage du bouton |
// Affichage du bouton |
8226 |
echo "\t<div class=\"formControls\">\n"; |
echo "\t<div class=\"formControls\">\n"; |
8227 |
$f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
$this->f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
8228 |
echo "\t</div>\n"; |
echo "\t</div>\n"; |
8229 |
// Fermeture du formulaire |
// Fermeture du formulaire |
8230 |
echo "\t</form>\n"; |
echo "\t</form>\n"; |
8241 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
8242 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
8243 |
|
|
|
// XXX APP |
|
|
|
|
|
$f = $this->f; |
|
|
|
|
8244 |
// Récupération des valeur passées en POST ou GET |
// Récupération des valeur passées en POST ou GET |
8245 |
if($f->get_submitted_post_value("type_mise_a_jour") !== null) { |
if($this->f->get_submitted_post_value("type_mise_a_jour") !== null) { |
8246 |
$type_mise_a_jour = $f->get_submitted_post_value("type_mise_a_jour"); |
$type_mise_a_jour = $this->f->get_submitted_post_value("type_mise_a_jour"); |
8247 |
} elseif($f->get_submitted_get_value('type_mise_a_jour') !== null) { |
} elseif($this->f->get_submitted_get_value('type_mise_a_jour') !== null) { |
8248 |
$type_mise_a_jour = $f->get_submitted_get_value('type_mise_a_jour'); |
$type_mise_a_jour = $this->f->get_submitted_get_value('type_mise_a_jour'); |
8249 |
} else { |
} else { |
8250 |
$type_mise_a_jour = ""; |
$type_mise_a_jour = ""; |
8251 |
} |
} |
8252 |
if($f->get_submitted_post_value('date') !== null) { |
if($this->f->get_submitted_post_value('date') !== null) { |
8253 |
$date = $f->get_submitted_post_value('date'); |
$date = $this->f->get_submitted_post_value('date'); |
8254 |
} elseif($f->get_submitted_get_value('date') !== null) { |
} elseif($this->f->get_submitted_get_value('date') !== null) { |
8255 |
$date = $f->get_submitted_get_value('date'); |
$date = $this->f->get_submitted_get_value('date'); |
8256 |
} else { |
} else { |
8257 |
$date = ""; |
$date = ""; |
8258 |
} |
} |
8259 |
if($f->get_submitted_post_value('code_barres') !== null) { |
if($this->f->get_submitted_post_value('code_barres') !== null) { |
8260 |
$code_barres = $f->get_submitted_post_value('code_barres'); |
$code_barres = $this->f->get_submitted_post_value('code_barres'); |
8261 |
} elseif($f->get_submitted_get_value('code_barres') !== null) { |
} elseif($this->f->get_submitted_get_value('code_barres') !== null) { |
8262 |
$code_barres = $f->get_submitted_get_value('code_barres'); |
$code_barres = $this->f->get_submitted_get_value('code_barres'); |
8263 |
} else { |
} else { |
8264 |
$code_barres = ""; |
$code_barres = ""; |
8265 |
} |
} |
8271 |
$liste_champs=array(); |
$liste_champs=array(); |
8272 |
|
|
8273 |
// Si le formulaire a été validé |
// Si le formulaire a été validé |
8274 |
if ($f->get_submitted_post_value('validation') !== null) { |
if ($this->f->get_submitted_post_value('validation') !== null) { |
8275 |
if(!empty($type_mise_a_jour) and !empty($date) and !empty($code_barres)) { |
if(!empty($type_mise_a_jour) and !empty($date) and !empty($code_barres)) { |
8276 |
|
|
|
// Vérification de l'existence de l'instruction |
|
|
$sql = "SELECT instruction |
|
|
FROM ".DB_PREFIXE."instruction |
|
|
INNER JOIN ".DB_PREFIXE."dossier |
|
|
ON dossier.dossier=instruction.dossier |
|
|
INNER JOIN ".DB_PREFIXE."dossier_instruction_type |
|
|
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
|
|
INNER JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille |
|
|
ON dossier_instruction_type.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
|
|
INNER JOIN ".DB_PREFIXE."dossier_autorisation_type |
|
|
ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
|
|
INNER JOIN ".DB_PREFIXE."groupe |
|
|
ON dossier_autorisation_type.groupe = groupe.groupe |
|
|
WHERE code_barres='".$this->f->db->escapesimple($code_barres)."'"; |
|
|
|
|
8277 |
// Ajout d'un filtre sur les groupes auxquels l'utilisateur a accès |
// Ajout d'un filtre sur les groupes auxquels l'utilisateur a accès |
8278 |
$group_clause = array(); |
$group_clause = array(); |
8279 |
foreach ($_SESSION["groupe"] as $key => $value) { |
foreach ($_SESSION["groupe"] as $key => $value) { |
8284 |
$group_clause[$key] .= ")"; |
$group_clause[$key] .= ")"; |
8285 |
} |
} |
8286 |
$conditions = implode(" OR ", $group_clause); |
$conditions = implode(" OR ", $group_clause); |
8287 |
$sql .= " AND (" . $conditions . ")"; |
$groupFilter = " AND (" . $conditions . ")"; |
|
|
|
|
|
|
|
$res = $f->db->query($sql); |
|
|
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
|
|
$f->isDatabaseError($res); |
|
8288 |
|
|
8289 |
if($res->numrows() == 1) { |
$qres = $this->f->get_all_results_from_db_query( |
8290 |
|
sprintf( |
8291 |
|
'SELECT |
8292 |
|
instruction |
8293 |
|
FROM |
8294 |
|
%1$sinstruction |
8295 |
|
INNER JOIN %1$sdossier |
8296 |
|
ON dossier.dossier = instruction.dossier |
8297 |
|
INNER JOIN %1$sdossier_instruction_type |
8298 |
|
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
8299 |
|
INNER JOIN %1$sdossier_autorisation_type_detaille |
8300 |
|
ON dossier_instruction_type.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
8301 |
|
INNER JOIN %1$sdossier_autorisation_type |
8302 |
|
ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
8303 |
|
INNER JOIN %1$sgroupe |
8304 |
|
ON dossier_autorisation_type.groupe = groupe.groupe |
8305 |
|
WHERE |
8306 |
|
code_barres = \'%2$s\' |
8307 |
|
%3$s', |
8308 |
|
DB_PREFIXE, |
8309 |
|
$this->f->db->escapeSimple($code_barres), |
8310 |
|
$groupFilter |
8311 |
|
), |
8312 |
|
array( |
8313 |
|
'origin' => __METHOD__ |
8314 |
|
) |
8315 |
|
); |
8316 |
|
if($qres['row_count'] === 1) { |
8317 |
$liste_champs = explode(";", $type_mise_a_jour); |
$liste_champs = explode(";", $type_mise_a_jour); |
8318 |
|
$row = array_shift($qres['result']); |
8319 |
|
$instr = $this->f->get_inst__om_dbform(array( |
8320 |
|
"obj" => "instruction", |
8321 |
|
"idx" => $row['instruction'], |
8322 |
|
)); |
8323 |
// Mise à jour des dates après l'écran de verification |
// Mise à jour des dates après l'écran de verification |
8324 |
if($f->get_submitted_post_value('is_valid') !== null and $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'], |
|
|
)); |
|
8325 |
$valF = array(); |
$valF = array(); |
8326 |
foreach($instr->champs as $id => $champ) { |
foreach($instr->champs as $id => $champ) { |
8327 |
$valF[$champ] = $instr->val[$id]; |
$valF[$champ] = $instr->val[$id]; |
8364 |
$code_barres = ""; |
$code_barres = ""; |
8365 |
|
|
8366 |
//Désactivation de l'autocommit |
//Désactivation de l'autocommit |
8367 |
$f->db->autoCommit(false); |
$this->f->db->autoCommit(false); |
8368 |
|
|
8369 |
//On modifie les valeurs de l'instruction |
//On modifie les valeurs de l'instruction |
8370 |
$instr->setParameter('maj', 170); |
$instr->setParameter('maj', 170); |
8371 |
$instr->class_actions[170]["identifier"] = |
$instr->class_actions[170]["identifier"] = |
8372 |
"mise à jour des dates (depuis le menu suivi des pièces)"; |
"mise à jour des dates (depuis le menu suivi des pièces)"; |
8373 |
$retour = $instr->modifier($valF, $f->db, DEBUG); |
$retour = $instr->modifier($valF); |
8374 |
|
|
8375 |
//Si une erreur s'est produite, on défait les modifications |
//Si une erreur s'est produite, on défait les modifications |
8376 |
//qui ont été faites |
//qui ont été faites |
8379 |
} |
} |
8380 |
//Sinon, on valide en base de données les modifications |
//Sinon, on valide en base de données les modifications |
8381 |
else { |
else { |
8382 |
$f->db->commit(); |
$this->f->db->commit(); |
8383 |
} |
} |
8384 |
|
|
8385 |
// Variable correct retourné depuis la classe instruction |
// Variable correct retourné depuis la classe instruction |
8401 |
} |
} |
8402 |
} else { |
} else { |
8403 |
// Récupération des infos du dossier |
// Récupération des infos du dossier |
8404 |
$sqlInfo = "SELECT dossier.dossier_libelle, |
$qres = $this->f->get_all_results_from_db_query( |
8405 |
evenement.libelle as evenement, |
sprintf( |
8406 |
autorite_competente.code as autorite_competente_code, |
'SELECT |
8407 |
autorite_competente.libelle as autorite_competente, |
dossier.dossier_libelle, |
8408 |
evenement.type as evenement_type, |
evenement.libelle as evenement, |
8409 |
to_char(date_envoi_signature,'DD/MM/YYYY') as date_envoi_signature, |
autorite_competente.code as autorite_competente_code, |
8410 |
to_char(date_retour_signature,'DD/MM/YYYY') as date_retour_signature, |
autorite_competente.libelle as autorite_competente, |
8411 |
to_char(date_envoi_controle_legalite,'DD/MM/YYYY') as date_envoi_controle_legalite, |
evenement.type as evenement_type, |
8412 |
to_char(date_retour_controle_legalite,'DD/MM/YYYY') as date_retour_controle_legalite, |
to_char(date_envoi_signature,\'DD/MM/YYYY\') as date_envoi_signature, |
8413 |
to_char(date_envoi_rar,'DD/MM/YYYY') as date_envoi_rar, |
to_char(date_retour_signature,\'DD/MM/YYYY\') as date_retour_signature, |
8414 |
to_char(date_retour_rar,'DD/MM/YYYY') as date_retour_rar |
to_char(date_envoi_controle_legalite,\'DD/MM/YYYY\') as date_envoi_controle_legalite, |
8415 |
FROM ".DB_PREFIXE."instruction |
to_char(date_retour_controle_legalite,\'DD/MM/YYYY\') as date_retour_controle_legalite, |
8416 |
INNER JOIN ".DB_PREFIXE."dossier ON |
to_char(date_envoi_rar,\'DD/MM/YYYY\') as date_envoi_rar, |
8417 |
dossier.dossier=instruction.dossier |
to_char(date_retour_rar,\'DD/MM/YYYY\') as date_retour_rar |
8418 |
LEFT JOIN ".DB_PREFIXE."autorite_competente ON |
FROM |
8419 |
dossier.autorite_competente=autorite_competente.autorite_competente |
%1$sinstruction |
8420 |
INNER JOIN ".DB_PREFIXE."evenement ON |
INNER JOIN %1$sdossier |
8421 |
instruction.evenement=evenement.evenement |
ON dossier.dossier=instruction.dossier |
8422 |
WHERE code_barres='".$code_barres."'"; |
LEFT JOIN %1$sautorite_competente |
8423 |
$resInfo = $f->db->query($sqlInfo); |
ON dossier.autorite_competente=autorite_competente.autorite_competente |
8424 |
$f->isDatabaseError($resInfo); |
INNER JOIN %1$sevenement |
8425 |
$infos = $resInfo->fetchRow(DB_FETCHMODE_ASSOC); |
ON instruction.evenement=evenement.evenement |
8426 |
|
WHERE |
8427 |
|
code_barres = \'%2$s\'', |
8428 |
|
DB_PREFIXE, |
8429 |
|
$this->f->db->escapeSimple($code_barres) |
8430 |
|
), |
8431 |
|
array( |
8432 |
|
"origin" => __METHOD__ |
8433 |
|
) |
8434 |
|
); |
8435 |
|
$infos = array_shift($qres['result']); |
8436 |
|
|
8437 |
// Vérification de la non modification des dates de suivi |
// Vérification de la non modification des dates de suivi |
8438 |
foreach(explode(";", $type_mise_a_jour) as $champ) { |
foreach(explode(";", $type_mise_a_jour) as $champ) { |
8439 |
|
if ($champ === 'date_envoi_controle_legalite') { |
8440 |
|
if ($instr->is_sent_to_cl() === true) { |
8441 |
|
$error = __("Les dates de suivis ne peuvent etre modifiees"); |
8442 |
|
$date_error = true; |
8443 |
|
break; |
8444 |
|
} |
8445 |
|
} |
8446 |
if($infos[$champ] != "" AND $infos[$champ] != $date) { |
if($infos[$champ] != "" AND $infos[$champ] != $date) { |
8447 |
$error = _("Les dates de suivis ne peuvent etre modifiees"); |
$error = _("Les dates de suivis ne peuvent etre modifiees"); |
8448 |
$date_error = true; |
$date_error = true; |
8449 |
|
break; |
8450 |
} |
} |
8451 |
} |
} |
8452 |
} |
} |
8464 |
*/ |
*/ |
8465 |
// Affichage du message de validation ou d'erreur |
// Affichage du message de validation ou d'erreur |
8466 |
if (isset($message) && isset($message_class) && $message != "") { |
if (isset($message) && isset($message_class) && $message != "") { |
8467 |
$f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
8468 |
} |
} |
8469 |
// Affichage du message d'erreur |
// Affichage du message d'erreur |
8470 |
if(!empty($error)) { |
if(!empty($error)) { |
8471 |
$f->displayMessage("error", $error); |
$this->f->displayMessage("error", $error); |
8472 |
} |
} |
8473 |
|
|
8474 |
// Affichage du message de validation de la saisie |
// Affichage du message de validation de la saisie |
8475 |
if($correct === true) { |
if($correct === true) { |
8476 |
$f->displayMessage("ok", _("Saisie enregistree")); |
$this->f->displayMessage("ok", _("Saisie enregistree")); |
8477 |
} |
} |
8478 |
// Ouverture du formulaire |
// Ouverture du formulaire |
8479 |
echo "\t<form"; |
echo "\t<form"; |
8526 |
$contenu[1][4] = _("date de retour de controle de legalite"); |
$contenu[1][4] = _("date de retour de controle de legalite"); |
8527 |
|
|
8528 |
$contenu[0][5] = "date_retour_rar"; |
$contenu[0][5] = "date_retour_rar"; |
8529 |
$contenu[1][5] = _("date de retour de l'AR"); |
$contenu[1][5] = __("date de notification du correspondant"); |
8530 |
|
|
8531 |
$form->setSelect("type_mise_a_jour", $contenu); |
$form->setSelect("type_mise_a_jour", $contenu); |
8532 |
|
|
8586 |
$form->setType("autorite_competente", "static"); |
$form->setType("autorite_competente", "static"); |
8587 |
$form->setVal("autorite_competente", $infos['autorite_competente']); |
$form->setVal("autorite_competente", $infos['autorite_competente']); |
8588 |
|
|
8589 |
// Parametrage des libellés d'envoi avec RAR |
// Parametrage des libellés d'envoi avec AR |
8590 |
$form->setLib("date_envoi_rar", _("date_envoi_rar")." :"); |
$form->setLib("date_envoi_rar", __("date_envoi_ar")." :"); |
8591 |
$form->setLib("date_retour_rar", _("date_retour_rar")." :"); |
$form->setLib("date_retour_rar", __("date_notification")." :"); |
8592 |
|
|
8593 |
$form->setLib("date_envoi_signature", _("date_envoi_signature")." :"); |
$form->setLib("date_envoi_signature", _("date_envoi_signature")." :"); |
8594 |
$form->setLib("date_retour_signature", _("date_retour_signature")." :"); |
$form->setLib("date_retour_signature", _("date_retour_signature")." :"); |
8622 |
echo "\t<div class=\"formControls\">\n"; |
echo "\t<div class=\"formControls\">\n"; |
8623 |
// |
// |
8624 |
if(!$date_error) { |
if(!$date_error) { |
8625 |
$f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
$this->f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
8626 |
} |
} |
8627 |
// Si pas sur l'écran de validation |
// Si pas sur l'écran de validation |
8628 |
if(isset($infos)) { |
if(isset($infos)) { |
8643 |
function view_pdf_lettre_rar() { |
function view_pdf_lettre_rar() { |
8644 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
8645 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
8646 |
|
// |
8647 |
|
$this->f->disableLog(); |
8648 |
|
|
8649 |
// XXX APP |
if($this->f->get_submitted_get_value('liste') != null) { |
8650 |
|
$listeCodeBarres = explode(',',$this->f->get_submitted_get_value('liste')); |
|
$f = $this->f; |
|
|
|
|
|
$f->disableLog(); |
|
|
|
|
|
if($f->get_submitted_get_value('liste') != null) { |
|
|
$listeCodeBarres = explode(',',$f->get_submitted_get_value('liste')); |
|
8651 |
|
|
8652 |
// Classe permettant la mise en page de l'édition pdf |
// Classe permettant la mise en page de l'édition pdf |
8653 |
require_once "../obj/pdf_lettre_rar.class.php"; |
require_once "../obj/pdf_lettre_rar.class.php"; |
8654 |
$pdf_lettre_rar = new pdf_lettre_rar('P', 'mm', 'A4'); |
$pdf_lettre_rar = new pdf_lettre_rar('P', 'mm', 'A4'); |
8655 |
// Initialisation de la mise en page |
// Initialisation de la mise en page |
8656 |
$pdf_lettre_rar->init($f); |
$pdf_lettre_rar->init($this->f); |
8657 |
|
|
8658 |
foreach ($listeCodeBarres as $code_barres) { |
foreach ($listeCodeBarres as $code_barres) { |
8659 |
|
|
8660 |
// On récupère le dossier |
// On récupère le dossier |
8661 |
$sql = "SELECT dossier |
$qres = $this->f->get_one_result_from_db_query( |
8662 |
FROM " . DB_PREFIXE . "instruction |
sprintf( |
8663 |
WHERE code_barres = '" . $code_barres . "'"; |
'SELECT |
8664 |
$dossier = $this->db->getOne($sql); |
dossier |
8665 |
$this->f->addToLog(__METHOD__."(): db->getOne(\"".$sql."\")", VERBOSE_MODE); |
FROM |
8666 |
$this->f->isDatabaseError($dossier); |
%1$sinstruction |
8667 |
|
WHERE |
8668 |
|
code_barres = \'%2$s\'', |
8669 |
|
DB_PREFIXE, |
8670 |
|
$this->f->db->escapeSimple($code_barres) |
8671 |
|
), |
8672 |
|
array( |
8673 |
|
"origin" => __METHOD__, |
8674 |
|
) |
8675 |
|
); |
8676 |
|
|
8677 |
$inst_dossier = $this->f->get_inst__om_dbform(array( |
$inst_dossier = $this->f->get_inst__om_dbform(array( |
8678 |
"obj" => "dossier", |
"obj" => "dossier", |
8679 |
"idx" => $dossier, |
"idx" => $qres['result'], |
8680 |
)); |
)); |
8681 |
|
|
8682 |
// En fonction du type de dossier, on récupère un demandeur différent dans les requêtes |
// En fonction du type de dossier, on récupère un demandeur différent dans les requêtes |
8690 |
break; |
break; |
8691 |
case 'ADS': |
case 'ADS': |
8692 |
case 'DPC': |
case 'DPC': |
8693 |
|
case 'CONSULTATION ENTRANTE': |
8694 |
default: |
default: |
8695 |
$sql_demandeur = "((lien_dossier_demandeur.petitionnaire_principal IS TRUE AND demandeur.type_demandeur='petitionnaire') OR demandeur.type_demandeur='delegataire')"; |
$sql_demandeur = "((lien_dossier_demandeur.petitionnaire_principal IS TRUE AND demandeur.type_demandeur='petitionnaire') OR demandeur.type_demandeur='delegataire')"; |
8696 |
break; |
break; |
8697 |
} |
} |
8698 |
|
|
8699 |
// Test si l'evenement est de type arrete et si un délégataire a été nommé |
// Test si l'evenement est de type arrete et si un délégataire a été nommé |
8700 |
$sql = "SELECT |
$qres = $this->f->get_all_results_from_db_query( |
8701 |
|
sprintf( |
8702 |
|
'SELECT |
8703 |
dossier.dossier_libelle, |
dossier.dossier_libelle, |
8704 |
evenement.type, |
evenement.type, |
8705 |
count(lien_dossier_demandeur) as nbdemandeur, |
count(lien_dossier_demandeur) as nbdemandeur, |
8706 |
CASE |
CASE |
8707 |
WHEN division.libelle IS NOT NULL AND phase.code IS NOT NULL |
WHEN division.libelle IS NOT NULL AND phase.code IS NOT NULL |
8708 |
THEN CONCAT(phase.code, ' - ', division.libelle) |
THEN CONCAT(phase.code, \' - \', division.libelle) |
8709 |
ELSE |
ELSE |
8710 |
phase.code |
phase.code |
8711 |
END AS code_phase |
END AS code_phase |
8712 |
FROM ".DB_PREFIXE."instruction |
FROM |
8713 |
LEFT JOIN ".DB_PREFIXE."dossier |
%1$sinstruction |
8714 |
ON instruction.dossier = dossier.dossier |
LEFT JOIN %1$sdossier |
8715 |
LEFT JOIN ".DB_PREFIXE."division |
ON instruction.dossier = dossier.dossier |
8716 |
ON dossier.division = division.division |
LEFT JOIN %1$sdivision |
8717 |
INNER JOIN ".DB_PREFIXE."evenement ON |
ON dossier.division = division.division |
8718 |
instruction.evenement=evenement.evenement |
INNER JOIN %1$sevenement |
8719 |
LEFT JOIN ".DB_PREFIXE."phase |
ON instruction.evenement=evenement.evenement |
8720 |
ON evenement.phase = phase.phase |
LEFT JOIN %1$sphase |
8721 |
inner JOIN ".DB_PREFIXE."lien_dossier_demandeur ON |
ON evenement.phase = phase.phase |
8722 |
instruction.dossier=lien_dossier_demandeur.dossier |
inner JOIN %1$slien_dossier_demandeur |
8723 |
inner join ".DB_PREFIXE."demandeur on |
ON instruction.dossier=lien_dossier_demandeur.dossier |
8724 |
demandeur.demandeur=lien_dossier_demandeur.demandeur |
inner join %1$sdemandeur |
8725 |
WHERE code_barres='".$code_barres."' |
ON demandeur.demandeur=lien_dossier_demandeur.demandeur |
8726 |
AND " . $sql_demandeur . " |
WHERE |
8727 |
GROUP BY dossier.dossier_libelle, evenement.type, phase.code, division.libelle"; |
code_barres = \'%2$s\' |
8728 |
|
AND %3$s |
8729 |
$res = $f->db->query($sql); |
GROUP BY |
8730 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
dossier.dossier_libelle, |
8731 |
$f->isDatabaseError($res); |
evenement.type, |
8732 |
$testDemandeur = $res->fetchrow(DB_FETCHMODE_ASSOC); |
phase.code, |
8733 |
|
division.libelle', |
8734 |
|
DB_PREFIXE, |
8735 |
|
$this->f->db->escapeSimple($code_barres), |
8736 |
|
$sql_demandeur |
8737 |
|
), |
8738 |
|
array( |
8739 |
|
"origin" => __METHOD__ |
8740 |
|
) |
8741 |
|
); |
8742 |
|
$testDemandeur = array_shift($qres['result']); |
8743 |
|
|
8744 |
|
|
8745 |
// Recuperation de l'adresse de destination |
// Recuperation de l'adresse de destination |
|
$sqlAdresse = "SELECT |
|
|
CASE WHEN demandeur.qualite='particulier' |
|
|
THEN TRIM(CONCAT_WS(' ', pc.libelle, demandeur.particulier_nom, demandeur.particulier_prenom)) |
|
|
ELSE TRIM(demandeur.personne_morale_denomination) |
|
|
END as ligne1, |
|
|
CASE WHEN demandeur.qualite='personne_morale' |
|
|
THEN TRIM(demandeur.personne_morale_raison_sociale) |
|
|
ELSE '' |
|
|
END as ligne1_1, |
|
|
CASE WHEN demandeur.qualite='personne_morale' AND (demandeur.personne_morale_nom IS NOT NULL OR demandeur.personne_morale_prenom IS NOT NULL) |
|
|
THEN TRIM(CONCAT_WS(' ', 'rep. par', demandeur.personne_morale_nom, demandeur.personne_morale_prenom)) |
|
|
ELSE '' |
|
|
END as ligne1_2, |
|
|
trim(concat(demandeur.numero,' ',demandeur.voie)) as ligne2, |
|
|
CASE demandeur.complement |
|
|
WHEN null THEN '' |
|
|
ELSE trim(demandeur.complement) |
|
|
END as ligne3, |
|
|
CASE demandeur.lieu_dit |
|
|
WHEN null THEN '' |
|
|
ELSE trim(demandeur.lieu_dit) |
|
|
END as ligne4, |
|
|
CONCAT_WS(' ', demandeur.code_postal, demandeur.localite, |
|
|
(CASE WHEN demandeur.bp IS NOT NULL |
|
|
THEN CONCAT_WS(' ', 'BP', demandeur.bp) |
|
|
ELSE '' |
|
|
END), |
|
|
(CASE WHEN demandeur.cedex IS NOT NULL |
|
|
THEN CONCAT_WS(' ', 'CEDEX', demandeur.cedex) |
|
|
ELSE '' |
|
|
END)) |
|
|
as ligne5, |
|
|
code_barres as code_barres |
|
|
FROM ".DB_PREFIXE."instruction |
|
|
INNER JOIN ".DB_PREFIXE."dossier ON dossier.dossier = instruction.dossier |
|
|
INNER JOIN ".DB_PREFIXE."lien_dossier_demandeur ON dossier.dossier = lien_dossier_demandeur.dossier |
|
|
INNER JOIN ".DB_PREFIXE."demandeur ON lien_dossier_demandeur.demandeur = demandeur.demandeur |
|
|
LEFT OUTER JOIN ".DB_PREFIXE."civilite as pc ON demandeur.particulier_civilite = pc.civilite OR demandeur.personne_morale_civilite = pc.civilite |
|
|
WHERE instruction.code_barres ='".$code_barres."'"; |
|
|
|
|
8746 |
// Envoi pour delegataire ou petitionnaire principal selon le type d'evenement |
// Envoi pour delegataire ou petitionnaire principal selon le type d'evenement |
8747 |
|
$sqlAdresse = " AND demandeur.type_demandeur='petitionnaire' AND lien_dossier_demandeur.petitionnaire_principal IS TRUE"; |
8748 |
if($testDemandeur['type'] != 'arrete' AND $testDemandeur['nbdemandeur'] > 1) { |
if($testDemandeur['type'] != 'arrete' AND $testDemandeur['nbdemandeur'] > 1) { |
8749 |
$sqlAdresse .= " AND demandeur.type_demandeur='delegataire'"; |
$sqlAdresse = " AND demandeur.type_demandeur='delegataire'"; |
|
} else { |
|
|
$sqlAdresse .= " AND demandeur.type_demandeur='petitionnaire' AND lien_dossier_demandeur.petitionnaire_principal IS TRUE"; |
|
8750 |
} |
} |
8751 |
|
|
8752 |
$resAdresse = $f->db->query($sqlAdresse); |
$qres = $this->f->get_all_results_from_db_query( |
8753 |
$adresse_dest = $resAdresse->fetchrow(DB_FETCHMODE_ASSOC); |
sprintf( |
8754 |
$f->addToLog(__METHOD__.": db->query(\"".$sqlAdresse."\")", VERBOSE_MODE); |
'SELECT |
8755 |
$f->isDatabaseError($resAdresse); |
CASE WHEN demandeur.qualite = \'particulier\' |
8756 |
|
THEN TRIM(CONCAT_WS(\' \', pc.libelle, demandeur.particulier_nom, demandeur.particulier_prenom)) |
8757 |
|
ELSE TRIM(demandeur.personne_morale_denomination) |
8758 |
|
END as ligne1, |
8759 |
|
CASE WHEN demandeur.qualite = \'personne_morale\' |
8760 |
|
THEN TRIM(demandeur.personne_morale_raison_sociale) |
8761 |
|
ELSE \'\' |
8762 |
|
END as ligne1_1, |
8763 |
|
CASE WHEN demandeur.qualite = \'personne_morale\' AND (demandeur.personne_morale_nom IS NOT NULL OR demandeur.personne_morale_prenom IS NOT NULL) |
8764 |
|
THEN TRIM(CONCAT_WS(\' \', \'rep. par\', demandeur.personne_morale_nom, demandeur.personne_morale_prenom)) |
8765 |
|
ELSE \'\' |
8766 |
|
END as ligne1_2, |
8767 |
|
trim(concat(demandeur.numero,\' \',demandeur.voie)) as ligne2, |
8768 |
|
CASE demandeur.complement |
8769 |
|
WHEN null THEN \'\' |
8770 |
|
ELSE trim(demandeur.complement) |
8771 |
|
END as ligne3, |
8772 |
|
CASE demandeur.lieu_dit |
8773 |
|
WHEN null THEN \'\' |
8774 |
|
ELSE trim(demandeur.lieu_dit) |
8775 |
|
END as ligne4, |
8776 |
|
CONCAT_WS(\' \', demandeur.code_postal, demandeur.localite, |
8777 |
|
(CASE WHEN demandeur.bp IS NOT NULL |
8778 |
|
THEN CONCAT_WS(\' \', \'BP\', demandeur.bp) |
8779 |
|
ELSE \'\' |
8780 |
|
END), |
8781 |
|
(CASE WHEN demandeur.cedex IS NOT NULL |
8782 |
|
THEN CONCAT_WS(\' \', \'CEDEX\', demandeur.cedex) |
8783 |
|
ELSE \'\' |
8784 |
|
END)) |
8785 |
|
as ligne5, |
8786 |
|
code_barres as code_barres |
8787 |
|
FROM |
8788 |
|
%1$sinstruction |
8789 |
|
INNER JOIN %1$sdossier |
8790 |
|
ON dossier.dossier = instruction.dossier |
8791 |
|
INNER JOIN %1$slien_dossier_demandeur |
8792 |
|
ON dossier.dossier = lien_dossier_demandeur.dossier |
8793 |
|
INNER JOIN %1$sdemandeur |
8794 |
|
ON lien_dossier_demandeur.demandeur = demandeur.demandeur |
8795 |
|
LEFT OUTER JOIN %1$scivilite AS pc |
8796 |
|
ON demandeur.particulier_civilite = pc.civilite |
8797 |
|
OR demandeur.personne_morale_civilite = pc.civilite |
8798 |
|
WHERE |
8799 |
|
instruction.code_barres = \'%2$s\' |
8800 |
|
%3$s', |
8801 |
|
DB_PREFIXE, |
8802 |
|
$this->f->db->escapeSimple($code_barres), |
8803 |
|
$sqlAdresse |
8804 |
|
), |
8805 |
|
array( |
8806 |
|
"origin" => __METHOD__ |
8807 |
|
) |
8808 |
|
); |
8809 |
|
$adresse_dest = array_shift($qres['result']); |
8810 |
|
|
8811 |
// Création adresse destinataire sans ligne vide |
// Création adresse destinataire sans ligne vide |
8812 |
$adresse_destinataire = array(); |
$adresse_destinataire = array(); |
8842 |
} |
} |
8843 |
$pdf_output = $pdf_lettre_rar->output("lettre_rar".date("dmYHis").".pdf","S"); |
$pdf_output = $pdf_lettre_rar->output("lettre_rar".date("dmYHis").".pdf","S"); |
8844 |
$om_edition = $this->f->get_inst__om_edition(); |
$om_edition = $this->f->get_inst__om_edition(); |
8845 |
|
$om_edition->set_object_linked($this); |
8846 |
$om_edition->expose_pdf_output($pdf_output, "lettre_rar".date("dmYHis").".pdf"); |
$om_edition->expose_pdf_output($pdf_output, "lettre_rar".date("dmYHis").".pdf"); |
8847 |
} |
} |
8848 |
} |
} |
9025 |
} |
} |
9026 |
|
|
9027 |
/** |
/** |
9028 |
|
* VIEW - view_rapport_instruction. |
9029 |
|
* |
9030 |
|
* Ouvre le sous-formulaire en ajaxIt dans un overlay. |
9031 |
|
* Cette action est bindée pour utiliser la fonction popUpIt. |
9032 |
|
* |
9033 |
|
* @return void |
9034 |
|
*/ |
9035 |
|
function view_overlay_notification_manuelle() { |
9036 |
|
|
9037 |
|
// Vérification de l'accessibilité sur l'élément |
9038 |
|
$this->checkAccessibility(); |
9039 |
|
|
9040 |
|
printf( |
9041 |
|
'<script type="text/javascript" > |
9042 |
|
overlayIt(\'%1$s\',\'%2$s&objsf=%1$s&idxformulaire=%4$s&retourformulaire=dossier_instruction&obj=%1$s&action=411&idx=%3$s\', 1); |
9043 |
|
</script>', |
9044 |
|
'instruction_notification_manuelle', |
9045 |
|
OM_ROUTE_SOUSFORM, |
9046 |
|
$this->getVal($this->clePrimaire), |
9047 |
|
$this->getVal('dossier') |
9048 |
|
); |
9049 |
|
} |
9050 |
|
|
9051 |
|
/** |
9052 |
|
* VIEW - view_overlay_notification_service_consulte. |
9053 |
|
* |
9054 |
|
* Ouvre le sous-formulaire de notification des services consulte |
9055 |
|
* en ajaxIt dans un overlay. |
9056 |
|
* Cette action est bindée pour utiliser la fonction popUpIt. |
9057 |
|
* |
9058 |
|
* @return void |
9059 |
|
*/ |
9060 |
|
function view_overlay_notification_service_consulte() { |
9061 |
|
|
9062 |
|
// Vérification de l'accessibilité sur l'élément |
9063 |
|
$this->checkAccessibility(); |
9064 |
|
|
9065 |
|
printf( |
9066 |
|
'<script type="text/javascript" > |
9067 |
|
overlayIt(\'%1$s\',\'%2$s&objsf=%1$s&idxformulaire=%4$s&retourformulaire=dossier_instruction&obj=%1$s&action=420&idx=%3$s\', 1); |
9068 |
|
</script>', |
9069 |
|
'instruction_notification_manuelle', |
9070 |
|
OM_ROUTE_SOUSFORM, |
9071 |
|
$this->getVal($this->clePrimaire), |
9072 |
|
$this->getVal('dossier') |
9073 |
|
); |
9074 |
|
} |
9075 |
|
|
9076 |
|
/** |
9077 |
|
* VIEW - overlay_notification_tiers_consulte. |
9078 |
|
* |
9079 |
|
* Ouvre le sous-formulaire de notification des tiers consulte |
9080 |
|
* en ajaxIt dans un overlay. |
9081 |
|
* Cette action est bindée pour utiliser la fonction popUpIt. |
9082 |
|
* |
9083 |
|
* @return void |
9084 |
|
*/ |
9085 |
|
function view_overlay_notification_tiers_consulte() { |
9086 |
|
|
9087 |
|
// Vérification de l'accessibilité sur l'élément |
9088 |
|
$this->checkAccessibility(); |
9089 |
|
|
9090 |
|
printf( |
9091 |
|
'<script type="text/javascript" > |
9092 |
|
overlayIt(\'%1$s\',\'%2$s&objsf=%1$s&idxformulaire=%4$s&retourformulaire=dossier_instruction&obj=%1$s&action=430&idx=%3$s\', 1); |
9093 |
|
</script>', |
9094 |
|
'instruction_notification_manuelle', |
9095 |
|
OM_ROUTE_SOUSFORM, |
9096 |
|
$this->getVal($this->clePrimaire), |
9097 |
|
$this->getVal('dossier') |
9098 |
|
); |
9099 |
|
} |
9100 |
|
|
9101 |
|
/** |
9102 |
|
* VIEW - view_modale_selection_document_signe |
9103 |
|
* |
9104 |
|
* Ouvre le sous-formulaire de notification des services consulte |
9105 |
|
* en ajaxIt dans un overlay. |
9106 |
|
* Cette action est bindée pour utiliser la fonction popUpIt. |
9107 |
|
* |
9108 |
|
* @return void |
9109 |
|
*/ |
9110 |
|
function view_modale_selection_document_signe() { |
9111 |
|
|
9112 |
|
// Vérification de l'accessibilité sur l'élément |
9113 |
|
$this->checkAccessibility(); |
9114 |
|
|
9115 |
|
printf( |
9116 |
|
'<script type="text/javascript" > |
9117 |
|
overlayIt(\'%1$s\',\'%2$s&objsf=%1$s&idxformulaire=%4$s&retourformulaire=dossier_instruction&obj=%1$s&action=115&idx=%3$s\', 1); |
9118 |
|
</script>', |
9119 |
|
'instruction_modale', |
9120 |
|
OM_ROUTE_SOUSFORM, |
9121 |
|
$this->getVal($this->clePrimaire), |
9122 |
|
$this->getVal('dossier') |
9123 |
|
); |
9124 |
|
} |
9125 |
|
|
9126 |
|
/** |
9127 |
* 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 |
9128 |
* pour exclure les dossiers du groupe contentieux. |
* pour exclure les dossiers du groupe contentieux. |
9129 |
* |
* |
9133 |
function get_instruction_by_barcode($barcode) { |
function get_instruction_by_barcode($barcode) { |
9134 |
// Begin |
// Begin |
9135 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
9136 |
|
|
9137 |
// Vérification de l'existence de l'événement d'instruction |
// Vérification de l'existence de l'événement d'instruction |
9138 |
// pour le code-barres donné, en excluant les dossiers liés au groupe CTX |
// pour le code-barres donné, en excluant les dossiers liés au groupe CTX |
9139 |
$sql = "SELECT instruction |
$qres = $this->f->get_one_result_from_db_query( |
9140 |
FROM ".DB_PREFIXE."instruction |
sprintf( |
9141 |
INNER JOIN ".DB_PREFIXE."dossier |
'SELECT |
9142 |
|
instruction |
9143 |
|
FROM |
9144 |
|
%1$sinstruction |
9145 |
|
INNER JOIN %1$sdossier |
9146 |
ON dossier.dossier=instruction.dossier |
ON dossier.dossier=instruction.dossier |
9147 |
INNER JOIN ".DB_PREFIXE."dossier_instruction_type |
INNER JOIN %1$sdossier_instruction_type |
9148 |
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
9149 |
INNER JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille |
INNER JOIN %1$sdossier_autorisation_type_detaille |
9150 |
ON dossier_instruction_type.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
ON dossier_instruction_type.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
9151 |
INNER JOIN ".DB_PREFIXE."dossier_autorisation_type |
INNER JOIN %1$sdossier_autorisation_type |
9152 |
ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
9153 |
INNER JOIN ".DB_PREFIXE."groupe |
INNER JOIN %1$sgroupe |
9154 |
ON dossier_autorisation_type.groupe = groupe.groupe |
ON dossier_autorisation_type.groupe = groupe.groupe |
9155 |
AND groupe.code != 'CTX' |
AND groupe.code != \'CTX\' |
9156 |
WHERE code_barres = '".$this->f->db->escapesimple($barcode)."'"; |
WHERE |
9157 |
$res = $this->f->db->getOne($sql); |
code_barres = \'%2$s\'', |
9158 |
$this->f->addToLog(__METHOD__." : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
DB_PREFIXE, |
9159 |
$this->f->isDatabaseError($res); |
$this->f->db->escapeSimple($barcode) |
9160 |
|
), |
9161 |
|
array( |
9162 |
|
"origin" => __METHOD__, |
9163 |
|
) |
9164 |
|
); |
9165 |
|
|
9166 |
// Retourne résultat |
// Retourne résultat |
9167 |
return $this->end_treatment(__METHOD__, $res); |
return $this->end_treatment(__METHOD__, $qres['result']); |
9168 |
} |
} |
9169 |
|
|
9170 |
/** |
/** |
9182 |
// Begin |
// Begin |
9183 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
9184 |
// Requête |
// Requête |
9185 |
$res = $this->db->autoExecute( |
$res = $this->f->db->autoexecute( |
9186 |
DB_PREFIXE.$this->table, |
DB_PREFIXE.$this->table, |
9187 |
$valF, |
$valF, |
9188 |
DB_AUTOQUERY_UPDATE, |
DB_AUTOQUERY_UPDATE, |
9189 |
$this->getCle($id) |
$this->getCle($id) |
9190 |
); |
); |
9191 |
// S'il y a eu une erreur |
$this->addToLog( |
9192 |
if (database::isError($res, true)) { |
__METHOD__."(): db->autoexecute(\"".DB_PREFIXE.'.'.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($id)."\");", |
9193 |
|
VERBOSE_MODE |
9194 |
|
); |
9195 |
|
if ($this->f->isDatabaseError($res, true) !== false) { |
9196 |
$this->end_treatment(__METHOD__, false); |
$this->end_treatment(__METHOD__, false); |
9197 |
} |
} |
9198 |
// |
// |
9365 |
// 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 |
9366 |
// dites de TREATMENT. |
// dites de TREATMENT. |
9367 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
9368 |
// Définition des paramètres |
$message = __('Erreur de paramétrage :'); |
9369 |
$p_objet = 'param_courriel_de_notification_commune_objet_depuis_instruction'; |
$erreurParametrage = false; |
9370 |
$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 |
|
9371 |
$id_di = $this->getVal('dossier'); |
$id_di = $this->getVal('dossier'); |
|
$id_inst = $this->getVal($this->clePrimaire); |
|
|
// Instanciation du DI |
|
9372 |
$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 |
|
9373 |
$collectivite_di = $di->getVal('om_collectivite'); |
$collectivite_di = $di->getVal('om_collectivite'); |
9374 |
$params_mono = $this->f->getCollectivite($collectivite_di); |
// Récupération de l'url permettant d'accèder à l'instruction et au dossier |
9375 |
// Récupération du paramétrage de la collectivité multi |
$urlAcces = $this->f->get_parametre_notification_url_acces($collectivite_di); |
9376 |
$collectivite_multi = $this->f->get_idx_collectivite_multi(); |
if (empty($urlAcces) && empty(PATH_BASE_URL)) { |
9377 |
$params_multi = $this->f->getCollectivite($collectivite_multi); |
$erreurParametrage = true; |
9378 |
// Vérification de l'objet (obligatoirement multi) |
$message .= '<br>'.__("* l'url de notification n'est pas correctement paramétré"); |
9379 |
$objet = null; |
} |
9380 |
if (isset($params_multi[$p_objet]) === true |
|
9381 |
&& $params_multi[$p_objet] !== '') { |
// Récupération de la liste des mails |
9382 |
$objet = $params_multi[$p_objet]; |
$adresses = $this->f->get_param_courriel_de_notification_commune($collectivite_di); |
9383 |
} |
if (empty($adresses)) { |
9384 |
// Vérification du modèle mono en priorité |
$erreurParametrage = true; |
9385 |
$modele = null; |
$message .= '<br>'.__("* aucun courriel valide de destinataire de la commune"); |
9386 |
if (isset($params_mono[$p_modele]) === true |
} |
9387 |
&& $params_mono[$p_modele] !== '') { |
|
9388 |
$modele = $params_mono[$p_modele]; |
// Vérification du paramétrage des mails |
9389 |
|
$paramMail = $this->f->get_notification_commune_parametre_courriel_type($collectivite_di); |
9390 |
} |
if (empty($paramMail) || empty($paramMail['parametre_courriel_type_message'])) { |
9391 |
// Sinon vérification du modèle multi |
$erreurParametrage = true; |
9392 |
if ($modele === null |
$message .= '<br>'.__("* le modèle du courriel envoyé aux communes est vide"); |
9393 |
&& isset($params_multi[$p_modele]) === true |
} |
9394 |
&& $params_multi[$p_modele] !== '') { |
if (empty($paramMail) || empty($paramMail['parametre_courriel_type_titre'])) { |
9395 |
$modele = $params_multi[$p_modele]; |
$erreurParametrage = true; |
9396 |
} |
$message .= '<br>'.__("* l'objet du courriel envoyé aux communes est vide"); |
9397 |
// Vérification des adresses de courriel mono |
} |
9398 |
$courriels_valides = array(); |
|
9399 |
$courriels_invalides = array(); |
// Si il y a des erreurs de paramétrage on ne déclenche pas la notification et |
9400 |
if (isset($params_mono[$p_courriel]) === true |
// un message a destination de l'utilisateur est affiché |
9401 |
&& $params_mono[$p_courriel] !== '') { |
if ($erreurParametrage) { |
9402 |
// Un mail par ligne |
$message .= '<br>'.__("Veuillez contacter votre administrateur."); |
9403 |
$adresses = explode("\n", $params_mono[$p_courriel]); |
$this->addToMessage($message); |
9404 |
// 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; |
|
|
} |
|
|
} |
|
9405 |
} |
} |
9406 |
// Vérification du paramétrage global : |
|
9407 |
// 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 |
9408 |
if ($objet === null |
foreach ($adresses as $adresse) { |
9409 |
|| $modele === null |
// Ajout de la notif et récupération de son id |
9410 |
|| count($courriels_valides) === 0 |
$destinataire = array( |
9411 |
|| count($courriels_invalides) > 0) { |
'destinataire' => $adresse, |
9412 |
// On construit le message d'erreur adéquat |
'courriel' => $adresse |
9413 |
$this->addToMessage(_('Erreur de paramétrage :')); |
); |
9414 |
if ($objet === null) { |
$idNotif = $this->ajouter_notification( |
9415 |
$this->addToMessage(_("* l'objet du courriel envoyé aux communes est vide")); |
$this->getVal($this->clePrimaire), |
9416 |
} |
$this->f->get_connected_user_login_name(), |
9417 |
if ($modele === null) { |
$destinataire, |
9418 |
$this->addToMessage(_("* le modèle du courriel envoyé aux communes est vide")); |
$collectivite_di |
9419 |
} |
); |
9420 |
if (count($courriels_valides) === 0) { |
if ($idNotif === false) { |
9421 |
$this->addToMessage(_("* aucun courriel valide de destinataire de la commune")); |
$this->addToMessage(__("Veuillez contacter votre administrateur.")); |
9422 |
|
return $this->end_treatment(__METHOD__, false); |
9423 |
} |
} |
9424 |
if (count($courriels_invalides) > 0) { |
// Création de la tache en lui donnant l'id de la notification |
9425 |
$courriels_invalides = implode(', ', $courriels_invalides); |
$notification_by_task = $this->notification_by_task( |
9426 |
$this->addToMessage(_("* un ou plusieurs courriels des destinataires de la commune sont invalides : ").$courriels_invalides); |
$idNotif, |
9427 |
|
$this->getVal('dossier'), |
9428 |
|
'mail', |
9429 |
|
'notification_commune' |
9430 |
|
); |
9431 |
|
if ($notification_by_task === false) { |
9432 |
|
$this->addToMessage(__("Erreur lors de la préparation de la notification des communes.")); |
9433 |
|
$this->addToMessage(__("Veuillez contacter votre administrateur.")); |
9434 |
|
return $this->end_treatment(__METHOD__, false); |
9435 |
} |
} |
|
$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); |
|
9436 |
} |
} |
9437 |
// Ajout du log |
$this->addToMessage(__('La commune a été notifiée.')); |
|
$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); |
|
|
} |
|
|
// Message de validation |
|
|
$this->addToMessage(_('La commune a été notifiée.')); |
|
9438 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
9439 |
} |
} |
9440 |
|
|
9441 |
/** |
/** |
|
* 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; |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
9442 |
* Récupère l'instance de l'instructeur |
* Récupère l'instance de l'instructeur |
9443 |
* |
* |
9444 |
* @param integer $instructeur Identifiant de l'instructeur. |
* @param integer $instructeur Identifiant de l'instructeur. |
9560 |
} |
} |
9561 |
|
|
9562 |
/** |
/** |
9563 |
|
* TREATMENT - envoyer_a_signature_sans_relecture |
9564 |
|
* |
9565 |
|
* Permet d'envoyer le document de l'instruction au parapheur pour signature sans relecture |
9566 |
|
* |
9567 |
|
* @return boolean true si l'envoi a été effectué avec succès false sinon |
9568 |
|
*/ |
9569 |
|
function envoyer_a_signature_sans_relecture() { |
9570 |
|
return $this->envoyer_a_signature(); |
9571 |
|
} |
9572 |
|
|
9573 |
|
/** |
9574 |
|
* TREATMENT - envoyer_a_signature_avec_relecture |
9575 |
|
* |
9576 |
|
* Permet d'envoyer le document de l'instruction au parapheur pour signature avec relecture |
9577 |
|
* |
9578 |
|
* @return boolean true si l'envoi a été effectué avec succès false sinon |
9579 |
|
*/ |
9580 |
|
function envoyer_a_signature_avec_relecture() { |
9581 |
|
$is_forced_view_files = true; |
9582 |
|
return $this->envoyer_a_signature($is_forced_view_files); |
9583 |
|
} |
9584 |
|
|
9585 |
|
/** |
9586 |
|
* TREATMENT - envoyer_a_signature |
9587 |
|
* |
9588 |
|
* Permet d'envoyer le document de l'instruction au parapheur pour signature |
9589 |
|
* |
9590 |
|
* @param boolean $is_forced_view_files Indique si il y a une relecture (true) ou non (false) |
9591 |
|
* |
9592 |
|
* @return boolean true si l'envoi a été effectué avec succès false sinon |
9593 |
|
*/ |
9594 |
|
function envoyer_a_signature($is_forced_view_files = false) { |
9595 |
|
$this->begin_treatment(__METHOD__); |
9596 |
|
$this->correct = true; |
9597 |
|
|
9598 |
|
// Instanciation de l'objet signataire_arrete |
9599 |
|
$inst_signataire_arrete = $this->f->get_inst__om_dbform(array( |
9600 |
|
'obj' => 'signataire_arrete', |
9601 |
|
'idx' => $this->getVal('signataire_arrete'), |
9602 |
|
)); |
9603 |
|
|
9604 |
|
// Instanciation de l'objet dossier |
9605 |
|
$inst_dossier = $this->f->get_inst__om_dbform(array( |
9606 |
|
'obj' => 'dossier', |
9607 |
|
'idx' => $this->getVal('dossier'), |
9608 |
|
)); |
9609 |
|
|
9610 |
|
//Instanciation de la classe electronicsignature |
9611 |
|
$inst_es = $this->get_electronicsignature_instance(); |
9612 |
|
if ($inst_es === false) { |
9613 |
|
$this->correct = false; |
9614 |
|
return $this->end_treatment(__METHOD__, false); |
9615 |
|
} |
9616 |
|
|
9617 |
|
// Vérifie si la notification se fait via l'application ou via le parapheur |
9618 |
|
try { |
9619 |
|
$notification_required = $inst_es->signer_notification_is_delegated(); |
9620 |
|
} catch(electronicsignature_connector_method_not_implemented_exception $_) { |
9621 |
|
// Si la méthode n'existe pas, on considère que la notification est faite par le parapheur |
9622 |
|
$notification_required = false; |
9623 |
|
} |
9624 |
|
|
9625 |
|
// Si la notification est faite par l'application vérifie que l'adresse mail du |
9626 |
|
// signataire est correcte. Si ce n'est pas le cas le document n'est pas envoyé |
9627 |
|
// au parapheur car il ne sera pas accessible sans le lien transmis dans la |
9628 |
|
// notification |
9629 |
|
if ($notification_required === true) { |
9630 |
|
$signer_mail = $inst_signataire_arrete->getVal('email'); |
9631 |
|
$signer_name = trim($inst_signataire_arrete->getVal('prenom').' '.$inst_signataire_arrete->getVal('nom')); |
9632 |
|
|
9633 |
|
$err_msg = __('Le document n\'a pas pu être envoyé en signature car '); |
9634 |
|
|
9635 |
|
if (empty($signer_mail)) { |
9636 |
|
$this->correct = false; |
9637 |
|
$err_detail = sprintf(__("l'email du signataire '%s' est vide."), $signer_name); |
9638 |
|
$this->addToMessage($err_msg.$err_detail); |
9639 |
|
$this->addToLog(__METHOD__.$err_msg.$err_detail.' Instruction : '.$this->getVal($this->clePrimaire), DEBUG_MODE); |
9640 |
|
return $this->end_treatment(__METHOD__, false); |
9641 |
|
} |
9642 |
|
if (! $this->f->checkValidEmailAddress($signer_mail)) { |
9643 |
|
$this->correct = false; |
9644 |
|
$err_detail = sprintf(__("l'email du signataire '%s' est invalide (%s)."), $signer_name, $signer_mail); |
9645 |
|
$this->addToMessage($err_msg.$err_detail); |
9646 |
|
$this->addToLog(__METHOD__.$err_msg.$err_detail.' Instruction : '.$this->getVal($this->clePrimaire), DEBUG_MODE); |
9647 |
|
return $this->end_treatment(__METHOD__, false); |
9648 |
|
} |
9649 |
|
} |
9650 |
|
|
9651 |
|
// Récupération du document à signer |
9652 |
|
$file = $this->f->storage->get($this->getVal('om_fichier_instruction')); |
9653 |
|
if ($file === OP_FAILURE) { |
9654 |
|
$this->correct = false; |
9655 |
|
$this->addToMessage(__("Une erreur est survenue lors de la récupération du contenu du document de l'instruction.")); |
9656 |
|
// Termine le traitement |
9657 |
|
return $this->end_treatment(__METHOD__, false); |
9658 |
|
} |
9659 |
|
|
9660 |
|
// Initialisation des paramètre à passer pour l'envoi en signature |
9661 |
|
$data = array( |
9662 |
|
"om_utilisateur_email" => $this->f->om_utilisateur['email'], |
9663 |
|
"om_utilisateur_nom" => $this->f->om_utilisateur['nom'], |
9664 |
|
"signataire_arrete_email" => $inst_signataire_arrete->getVal('email'), |
9665 |
|
"signataire_arrete_nom" => $inst_signataire_arrete->getVal('nom'), |
9666 |
|
"signataire_arrete_prenom" => $inst_signataire_arrete->getVal('prenom'), |
9667 |
|
// Permet d'envoyer en signature l'instruction le jour de la date limite |
9668 |
|
"date_limite_instruction" => $this->compute_date_limite(1) != null ? $this->compute_date_limite(1) : null, |
9669 |
|
"dossier" => $this->getVal('dossier'), |
9670 |
|
"is_forced_view_files" => $is_forced_view_files, |
9671 |
|
'commentaire_signature' => $is_forced_view_files === true ? __('relecture demandee.') : null |
9672 |
|
); |
9673 |
|
|
9674 |
|
// Initialisation des métadonnées |
9675 |
|
$metadonnee_dossier = $file['metadata']; |
9676 |
|
// récupération de l'extension du fichier |
9677 |
|
$extension = substr($metadonnee_dossier['filename'], strrpos($metadonnee_dossier['filename'], '.')); |
9678 |
|
// Modification du libellé du document transmis au parapheur |
9679 |
|
// pour le mettre sous la forme : instruction_xxx_libelle_lettretype.extension |
9680 |
|
$metadonnee_dossier['filename'] = $this->getDocumentLibelle().$extension; |
9681 |
|
$metadonnee_dossier['titre_document'] = $this->getDocumentTitre(); |
9682 |
|
|
9683 |
|
$metadonnee_dossier['url_di'] = sprintf( |
9684 |
|
'%1$sapp/index.php?module=form&direct_link=true&obj=dossier_instruction&action=3&idx=%2$s&direct_field=dossier&direct_form=document_numerise&direct_action=4&direct_idx=%2$s', |
9685 |
|
$this->f->get_param_base_path_metadata_url_di() !== null ? $this->f->get_param_base_path_metadata_url_di() : PATH_BASE_URL, |
9686 |
|
$this->getVal('dossier') |
9687 |
|
); |
9688 |
|
|
9689 |
|
$optional_data = null; |
9690 |
|
// Si il y a des paramètres supplémentaire spécifié dans le signataire alors on les récupère |
9691 |
|
if ($inst_signataire_arrete->getVal('parametre_parapheur') !== null && $inst_signataire_arrete->getVal('parametre_parapheur') !== '') { |
9692 |
|
$optional_data = json_decode($inst_signataire_arrete->getVal('parametre_parapheur'), true); |
9693 |
|
if (json_last_error() !== JSON_ERROR_NONE) { |
9694 |
|
$this->correct = false; |
9695 |
|
$this->addToMessage(__("Les paramètres supplémentaires envoyés au parapheur ne sont pas au bon format.")); |
9696 |
|
$this->addToLog(__METHOD__."(): ". |
9697 |
|
__("Erreur lors du décodage du format json des paramètres supplémentaires envoyé au parapheur. |
9698 |
|
Tableau : ").var_export($inst_signataire_arrete->getVal('parametre_parapheur'), true) |
9699 |
|
); |
9700 |
|
// Termine le traitement |
9701 |
|
return $this->end_treatment(__METHOD__, false); |
9702 |
|
} |
9703 |
|
} |
9704 |
|
|
9705 |
|
// Appel de la méthode de l'abstracteur send_for_signature() |
9706 |
|
// Cette méthode doit retourner un tableau de valeur |
9707 |
|
try { |
9708 |
|
$result = $inst_es->send_for_signature($data, $file['file_content'], $metadonnee_dossier, $optional_data); |
9709 |
|
} catch (electronicsignature_exception $e) { |
9710 |
|
$this->handle_electronicsignature_exception($e); |
9711 |
|
return $this->end_treatment(__METHOD__, false); |
9712 |
|
} |
9713 |
|
|
9714 |
|
// Après avoir reçu le résultat du parapheur, il faut mettre à jour les champs |
9715 |
|
$valF = array(); |
9716 |
|
|
9717 |
|
// Pour appeler la fonction modifier il faut traiter tous les champs de l'objet |
9718 |
|
foreach($this->champs as $identifiant => $champ) { |
9719 |
|
$valF[$champ] = $this->val[$identifiant]; |
9720 |
|
} |
9721 |
|
// On fait ensuite nos modifications spécifiques |
9722 |
|
$valF['id_parapheur_signature'] = $result['id_parapheur_signature']; |
9723 |
|
$valF['statut_signature'] = $result['statut']; |
9724 |
|
$valF['commentaire_signature'] = isset($result['commentaire_signature']) == true ? $result['commentaire_signature'] : null; |
9725 |
|
$valF['date_envoi_signature'] = date("Y-m-d", strtotime($result['date_envoi_signature'])); |
9726 |
|
$valF['historique_signature'] = $this->get_updated_historique_signature($result); |
9727 |
|
$valF['parapheur_lien_page_signature'] = isset($result['signature_page_url']) ? $result['signature_page_url'] : null; |
9728 |
|
$ret = $this->modifier($valF); |
9729 |
|
|
9730 |
|
if ($ret === false) { |
9731 |
|
$this->correct = false; |
9732 |
|
$this->addToMessage(__("Une erreur est survenue lors de la mise à jour des champs.")); |
9733 |
|
// Termine le traitement |
9734 |
|
return $this->end_treatment(__METHOD__, false); |
9735 |
|
} |
9736 |
|
|
9737 |
|
// Notification du signataire |
9738 |
|
if ($notification_required === true) { |
9739 |
|
if ($this->notify_signer($signer_name, $signer_mail, $data['om_utilisateur_nom']) === false) { |
9740 |
|
$msg = __("Une erreur s'est produite lors de la notification du signataire \"%s (%s)\". Annulation de l'envoi pour signature du document%s."); |
9741 |
|
$this->addToMessage(sprintf($msg, $signer_name, $signer_mail, '')); |
9742 |
|
$this->addToLog(sprintf($msg, $signer_name, $signer_mail, ' : '.$this->getVal($this->clePrimaire)), DEBUG_MODE); |
9743 |
|
// Met à jour les valeurs de l'objet courant pour prendre en compte les modifications faites |
9744 |
|
// precedemment |
9745 |
|
$this->init_record_data($this->getVal($this->clePrimaire)); |
9746 |
|
$this->annuler_envoi_en_signature(); |
9747 |
|
$this->correct = false; |
9748 |
|
return $this->end_treatment(__METHOD__, true); |
9749 |
|
} |
9750 |
|
} |
9751 |
|
|
9752 |
|
// Message |
9753 |
|
$this->addToMessage(__("Le document a été envoyé pour signature dans le parapheur.")); |
9754 |
|
if ($this->f->is_option_enabled('option_afficher_lien_parapheur') === true |
9755 |
|
&& array_key_exists('signature_page_url', $result) === true) { |
9756 |
|
$this->addToMessage(sprintf( |
9757 |
|
'<br> > <a href="%1$s" title="%2$s" target="_blank">%2$s</a>', |
9758 |
|
$result['signature_page_url'], |
9759 |
|
__("Signez directement le document") |
9760 |
|
)); |
9761 |
|
} |
9762 |
|
if ($notification_required !== true) { |
9763 |
|
$this->addToMessage(__("L'envoi de la notification au signataire est effectué par la plateforme.")); |
9764 |
|
} |
9765 |
|
|
9766 |
|
// Tout s'est bien passé, on termine le traitement |
9767 |
|
return $this->end_treatment(__METHOD__, true); |
9768 |
|
} |
9769 |
|
|
9770 |
|
/** |
9771 |
|
* Notifie le signataire d'un document à signer. |
9772 |
|
* Gère l'affichage des messages à destination de l'utilisateur selon l'état du traitement. |
9773 |
|
* En cas d'erreur ajoute une ligne dans les logs de l'application. |
9774 |
|
* |
9775 |
|
* @param string $signer_name Nom du signataire |
9776 |
|
* @param string $signer_mail Mail du signataire |
9777 |
|
* @param string $user_name Nom de l'utilisateur openADS courant |
9778 |
|
* |
9779 |
|
* @return boolean true si succés, false si erreur |
9780 |
|
*/ |
9781 |
|
protected function notify_signer($signer_name, $signer_mail, $user_name) { |
9782 |
|
// message d'erreur |
9783 |
|
$err_msg_log = sprintf( |
9784 |
|
__("Échec de la notification du signataire \"%s (%s)\" lors de l'envoi au parapaheur du document de l'instruction : %s"), |
9785 |
|
$signer_name, |
9786 |
|
$signer_mail, |
9787 |
|
$this->getVal($this->clePrimaire) |
9788 |
|
); |
9789 |
|
$err_msg = sprintf( |
9790 |
|
'%s %s (%s)"', |
9791 |
|
__("Échec de la notification du signataire"), |
9792 |
|
$signer_name, |
9793 |
|
$signer_mail |
9794 |
|
); |
9795 |
|
|
9796 |
|
// vérification des informations requises |
9797 |
|
if (empty($signer_name)) { |
9798 |
|
$err_detail = __("le nom du signataire est vide"); |
9799 |
|
$this->addToLog(__METHOD__.', '.$err_msg_log.', '.$err_detail, DEBUG_MODE); |
9800 |
|
$this->addToMessage($err_msg.', '.$err_detail); |
9801 |
|
return false; |
9802 |
|
} |
9803 |
|
if (empty($signer_mail)) { |
9804 |
|
$err_detail = __("le courriel du signataire est vide"); |
9805 |
|
$this->addToLog(__METHOD__.', '.$err_msg_log.', '.$err_detail, DEBUG_MODE); |
9806 |
|
$this->addToMessage($err_msg.', '.$err_detail); |
9807 |
|
return false; |
9808 |
|
} |
9809 |
|
if (empty($this->getVal('dossier'))) { |
9810 |
|
$err_detail = __("l'identifiant du dossier est vide"); |
9811 |
|
$this->addToLog(__METHOD__.', '.$err_msg_log.', '.$err_detail, DEBUG_MODE); |
9812 |
|
$this->addToMessage($err_msg.', '.$err_detail); |
9813 |
|
return false; |
9814 |
|
} |
9815 |
|
|
9816 |
|
// ajout de la notification à la liste des notifications de l'instruction |
9817 |
|
$instruction_id = $this->getVal($this->clePrimaire); |
9818 |
|
$inst_notif = $this->f->get_inst__om_dbform(array( |
9819 |
|
"obj" => "instruction_notification", |
9820 |
|
"idx" => "]", |
9821 |
|
)); |
9822 |
|
$notif_val = array( |
9823 |
|
'instruction_notification' => null, |
9824 |
|
'instruction' => $instruction_id, |
9825 |
|
'automatique' => true, |
9826 |
|
'emetteur' => $user_name, |
9827 |
|
'date_envoi' => null, |
9828 |
|
'destinataire' => "$signer_name <$signer_mail>", |
9829 |
|
'courriel' => $signer_mail, |
9830 |
|
'date_premier_acces' => null, |
9831 |
|
'statut' => '', |
9832 |
|
'commentaire' => '' |
9833 |
|
); |
9834 |
|
$add_notif = $inst_notif->ajouter($notif_val); |
9835 |
|
if ($add_notif === false) { |
9836 |
|
$err_detail = __("Échec de l'ajout de la notification."); |
9837 |
|
$this->addToLog(__METHOD__.' '.$err_msg_log.'. '.$err_detail.' Notification : '.var_export($notif_val, true), DEBUG_MODE); |
9838 |
|
$this->addToMessage($err_msg); |
9839 |
|
return false; |
9840 |
|
} |
9841 |
|
$notification_id = $inst_notif->getVal($inst_notif->clePrimaire); |
9842 |
|
|
9843 |
|
// ajout d'une tâche de notification (envoi du mail) |
9844 |
|
$notification_task = $this->notification_by_task( |
9845 |
|
$notification_id, |
9846 |
|
$this->getVal('dossier'), |
9847 |
|
'mail', |
9848 |
|
'notification_signataire' |
9849 |
|
); |
9850 |
|
if ($notification_task === false) { |
9851 |
|
$err_detail = sprintf( |
9852 |
|
__("Échec de l'ajout de la tâche de notification (notification %s)."), |
9853 |
|
$notification_id); |
9854 |
|
$this->addToLog(__METHOD__.' '.$err_msg_log.'. '.$err_detail, DEBUG_MODE); |
9855 |
|
$this->addToMessage($err_msg); |
9856 |
|
return false; |
9857 |
|
} |
9858 |
|
|
9859 |
|
// Vérification de la réussite de l'envoi du mail |
9860 |
|
// Fais une requête pour récupérer la liste des notifications de signataire faites par mail |
9861 |
|
// et associées à l'instruction en cours. Récupère uniquement la dernière qui doit être celle |
9862 |
|
// qui viens d'être créée. |
9863 |
|
// Si la tâche d'envoi du mail est en erreur alors on considère que l'envoi du mail a échoué. |
9864 |
|
$qres = $this->f->get_one_result_from_db_query( |
9865 |
|
sprintf( |
9866 |
|
'SELECT |
9867 |
|
state |
9868 |
|
FROM |
9869 |
|
%1$stask |
9870 |
|
WHERE |
9871 |
|
type = \'notification_signataire\' |
9872 |
|
AND category = \'mail\' |
9873 |
|
AND dossier = \'%2$s\' |
9874 |
|
ORDER BY |
9875 |
|
task DESC |
9876 |
|
LIMIT 1', |
9877 |
|
DB_PREFIXE, |
9878 |
|
$this->f->db->escapeSimple($this->getVal('dossier')) |
9879 |
|
), |
9880 |
|
array( |
9881 |
|
'origin' => __METHOD__ |
9882 |
|
) |
9883 |
|
); |
9884 |
|
if ($qres['result'] === 'error') { |
9885 |
|
$err_detail = sprintf( |
9886 |
|
__("Échec de l'envoi du mail de notification (notification %s)."), |
9887 |
|
$notification_id); |
9888 |
|
$this->addToLog(__METHOD__.' '.$err_msg_log.'. '.$err_detail, DEBUG_MODE); |
9889 |
|
$this->addToMessage($err_msg); |
9890 |
|
return false; |
9891 |
|
} |
9892 |
|
|
9893 |
|
// succès de la planification de la notification |
9894 |
|
$this->addToMessage(sprintf( |
9895 |
|
__('Le signataire "%s (%s)" sera notifié prochainement'), |
9896 |
|
$signer_name, |
9897 |
|
$signer_mail)); |
9898 |
|
return true; |
9899 |
|
} |
9900 |
|
|
9901 |
|
/** |
9902 |
|
* Permet de récupérer la bonne date limite en fonction de si l'instruction |
9903 |
|
* est en incomplet notifié ou non. |
9904 |
|
* On peut ajouter des jours à cette date grâce au paramètre "delay". |
9905 |
|
* Cette fonction est utilisée dans un cas spécifique où on veut envoyer |
9906 |
|
* l'instruction en signature le jour de la date limite. |
9907 |
|
* |
9908 |
|
* @param int $delay Le nombre de jour à ajouter à la date limite. |
9909 |
|
* |
9910 |
|
* @return string $date_limite la date limite calculé ou false |
9911 |
|
*/ |
9912 |
|
private function compute_date_limite($delay) { |
9913 |
|
// Instanciation de l'objet dossier |
9914 |
|
$inst_dossier = $this->f->get_inst__om_dbform(array( |
9915 |
|
'obj' => 'dossier', |
9916 |
|
'idx' => $this->getVal('dossier'), |
9917 |
|
)); |
9918 |
|
|
9919 |
|
$date_to_compute = null; |
9920 |
|
if ($inst_dossier->getVal('incomplet_notifie') === 't') { |
9921 |
|
$date_to_compute = $inst_dossier->getVal('date_limite_incompletude'); |
9922 |
|
} else { |
9923 |
|
$date_to_compute = $inst_dossier->getVal('date_limite'); |
9924 |
|
} |
9925 |
|
if ($date_to_compute != null) { |
9926 |
|
return date("Y-m-d", strtotime($date_to_compute."+ $delay days")); |
9927 |
|
} |
9928 |
|
|
9929 |
|
return null; |
9930 |
|
} |
9931 |
|
|
9932 |
|
/** |
9933 |
|
* Permet de récupérer la traduction de la valeur de statut_signature |
9934 |
|
* |
9935 |
|
* @return string la valeur de statut_signature traduite | false |
9936 |
|
*/ |
9937 |
|
function get_trad_for_statut($value_to_trad){ |
9938 |
|
$statut_signature_tab = array( |
9939 |
|
'waiting' => __('en préparation'), |
9940 |
|
'in_progress' => __('en cours de signature'), |
9941 |
|
'canceled' => __('signature annulée'), |
9942 |
|
'expired' => __('délai de signature expiré'), |
9943 |
|
'finished' => __('signé') |
9944 |
|
); |
9945 |
|
if (array_key_exists($value_to_trad, $statut_signature_tab) === true) { |
9946 |
|
return $statut_signature_tab[$value_to_trad]; |
9947 |
|
} |
9948 |
|
|
9949 |
|
return false; |
9950 |
|
} |
9951 |
|
|
9952 |
|
/** |
9953 |
|
* Permet de mettre à jour le tableau json sotcké dans le champ historique_signature |
9954 |
|
* |
9955 |
|
* @return string (json) la valeur de historique_signature mis à jour | false |
9956 |
|
*/ |
9957 |
|
function get_updated_historique_signature($historique_signature_values) { |
9958 |
|
|
9959 |
|
$historique_signature_value_tab = $this->get_historique_signature_decoded(); |
9960 |
|
|
9961 |
|
if ($historique_signature_value_tab === false) { |
9962 |
|
$this->addToLog(__METHOD__."(): erreur historique signature", DEBUG_MODE); |
9963 |
|
return false; |
9964 |
|
} |
9965 |
|
|
9966 |
|
$last_val_historique_signature = array(); |
9967 |
|
|
9968 |
|
// Si la tableau récupéré n'est pas vide alors |
9969 |
|
// on récupère la dernière ligne du tableau |
9970 |
|
if (empty($historique_signature_value_tab) === false) { |
9971 |
|
$last_val_historique_signature = end($historique_signature_value_tab); |
9972 |
|
} |
9973 |
|
|
9974 |
|
$format_date = ''; |
9975 |
|
$format_date_hour = ''; |
9976 |
|
$date_converted=array(); |
9977 |
|
|
9978 |
|
$date_to_convert = array( |
9979 |
|
'date_envoi_signature' => $historique_signature_values['date_envoi_signature'], |
9980 |
|
'date_limite_instruction' => $this->compute_date_limite(0), |
9981 |
|
'date_retour_signature' => $historique_signature_values['date_retour_signature'] |
9982 |
|
); |
9983 |
|
|
9984 |
|
// Conversion des dates en fonction de leur format |
9985 |
|
foreach ($date_to_convert as $key => $value) { |
9986 |
|
$date_converted[$key] = null; |
9987 |
|
if ($value != null) { |
9988 |
|
$format_date = 'd/m/Y'; |
9989 |
|
$format_date_hour = 'd/m/Y H:i:s'; |
9990 |
|
$date_converted[$key] = empty(date_parse($value)['hour']) === false ? date($format_date_hour, strtotime($value)) : date($format_date, strtotime($value)); |
9991 |
|
} |
9992 |
|
} |
9993 |
|
|
9994 |
|
// Ce tableau permet de lister les colonnes de historique_signature et de les rendre traduisibles. |
9995 |
|
// Il faut en effet mettre les gettext avec l'intitulé explicite au moins |
9996 |
|
// une fois afin qu'il puisse être reconnu par le logiciel de traduction. |
9997 |
|
$tab_for_columns_trad = array( |
9998 |
|
__('entry_date'), |
9999 |
|
__('id_parapheur_signature'), |
10000 |
|
__('emetteur'), |
10001 |
|
__('signataire'), |
10002 |
|
__('date_envoi'), |
10003 |
|
__('date_limite'), |
10004 |
|
__('date_retour'), |
10005 |
|
__('statut_signature'), |
10006 |
|
__('commentaire_signature') |
10007 |
|
); |
10008 |
|
|
10009 |
|
array_push($historique_signature_value_tab, array( |
10010 |
|
'entry_date' => date('d/m/Y H:i:s'), |
10011 |
|
'id_parapheur_signature' => $historique_signature_values['id_parapheur_signature'] == null ? (isset($last_val_historique_signature['id_parapheur_signature']) === true ? $last_val_historique_signature['id_parapheur_signature'] : null) : $historique_signature_values['id_parapheur_signature'], |
10012 |
|
'emetteur' => $historique_signature_values['om_utilisateur_email'] == null ? (isset($last_val_historique_signature['emetteur']) === true ? $last_val_historique_signature['emetteur'] : null) : $historique_signature_values['om_utilisateur_email'], |
10013 |
|
'signataire' => $historique_signature_values['signataire_arrete_email'] == null ? (isset($last_val_historique_signature['signataire']) === true ? $last_val_historique_signature['signataire'] : null) : $historique_signature_values['signataire_arrete_email'], |
10014 |
|
'date_envoi' => $historique_signature_values['date_envoi_signature'] == null ? (isset($last_val_historique_signature['date_envoi']) === true ? $last_val_historique_signature['date_envoi'] : null) : $date_converted['date_envoi_signature'], |
10015 |
|
'date_limite' => $historique_signature_values['date_limite_instruction'] == null ? (isset($last_val_historique_signature['date_limite']) === true ? $last_val_historique_signature['date_limite'] : null) : $date_converted['date_limite_instruction'], |
10016 |
|
'date_retour' => $historique_signature_values['date_retour_signature'] == null ? (isset($last_val_historique_signature['date_retour']) === true ? $last_val_historique_signature['date_retour'] : null) : $date_converted['date_retour_signature'], |
10017 |
|
'statut_signature' => $historique_signature_values['statut'] == null ? (isset($last_val_historique_signature['statut_signature']) === true ? $last_val_historique_signature['statut_signature'] : null) : $this->get_trad_for_statut($historique_signature_values['statut']), |
10018 |
|
'commentaire_signature' => isset($historique_signature_values['commentaire_signature']) === false || $historique_signature_values['commentaire_signature'] == null ? null : $historique_signature_values['commentaire_signature'], |
10019 |
|
)); |
10020 |
|
|
10021 |
|
return json_encode($historique_signature_value_tab, JSON_HEX_APOS); |
10022 |
|
} |
10023 |
|
|
10024 |
|
/** |
10025 |
|
* TREATMENT - annuler_envoi_en_signature |
10026 |
|
* |
10027 |
|
* Permet d'annuler l'envoi du document de l'instruction au parapheur pour signature |
10028 |
|
* |
10029 |
|
* @return boolean true si l'annulation a été effectué avec succès false sinon |
10030 |
|
*/ |
10031 |
|
function annuler_envoi_en_signature() { |
10032 |
|
$this->begin_treatment(__METHOD__); |
10033 |
|
$this->correct = true; |
10034 |
|
|
10035 |
|
//Instanciation de la classe electronicsignature |
10036 |
|
$inst_es = $this->get_electronicsignature_instance(); |
10037 |
|
if ($inst_es === false) { |
10038 |
|
$this->correct = false; |
10039 |
|
return $this->end_treatment(__METHOD__, false); |
10040 |
|
} |
10041 |
|
|
10042 |
|
$data = array(); |
10043 |
|
if (! empty($this->getVal('id_parapheur_signature'))) { |
10044 |
|
$data['id_parapheur_signature'] = $this->getVal('id_parapheur_signature'); |
10045 |
|
} else { |
10046 |
|
$this->correct = false; |
10047 |
|
$this->addToMessage(__("Il n'y a pas d'identifiant de parapheur.")); |
10048 |
|
return $this->end_treatment(__METHOD__, false); |
10049 |
|
} |
10050 |
|
|
10051 |
|
// Appel de la méthode de l'abstracteur cancel_send_for_signature() |
10052 |
|
// Cette méthode doit retourner un tableau de valeur |
10053 |
|
try { |
10054 |
|
$result = $inst_es->cancel_send_for_signature($data); |
10055 |
|
} catch (electronicsignature_exception $e) { |
10056 |
|
$this->handle_electronicsignature_exception($e); |
10057 |
|
return $this->end_treatment(__METHOD__, false); |
10058 |
|
} |
10059 |
|
|
10060 |
|
// Après avoir reçu le résultat du parapheur, il faut mettre à jour les champs |
10061 |
|
$valF = array(); |
10062 |
|
|
10063 |
|
// Pour appeler la fonction modifier il faut traiter tous les champs de l'objet |
10064 |
|
foreach($this->champs as $identifiant => $champ) { |
10065 |
|
$valF[$champ] = $this->val[$identifiant]; |
10066 |
|
} |
10067 |
|
// On fait ensuite nos modifications spécifiques |
10068 |
|
$valF['id_parapheur_signature'] = null; |
10069 |
|
$valF['statut_signature'] = $result['statut']; |
10070 |
|
$valF['commentaire_signature'] = isset($result['commentaire_signature']) == true ? $result['commentaire_signature'] : null; |
10071 |
|
$valF['date_envoi_signature'] = null; |
10072 |
|
$valF['historique_signature'] = $this->get_updated_historique_signature($result); |
10073 |
|
|
10074 |
|
$ret = $this->modifier($valF); |
10075 |
|
|
10076 |
|
if ($ret === false) { |
10077 |
|
$this->correct = false; |
10078 |
|
$this->addToMessage(__("Une erreur est survenue lors de la mise à jour des champs.")); |
10079 |
|
// Termine le traitement |
10080 |
|
return $this->end_treatment(__METHOD__, false); |
10081 |
|
} |
10082 |
|
|
10083 |
|
// Message |
10084 |
|
$this->addToMessage(__("L'annulation a été effectuée avec succès.")); |
10085 |
|
|
10086 |
|
// Tout s'est bien passé, on termine le traitement |
10087 |
|
return $this->end_treatment(__METHOD__, true); |
10088 |
|
} |
10089 |
|
|
10090 |
|
|
10091 |
|
/** |
10092 |
|
* Récupère le contenu du champ historique_signature et le converti en tableau |
10093 |
|
* |
10094 |
|
* @return array sinon false en cas d'erreur |
10095 |
|
*/ |
10096 |
|
protected function get_historique_signature_decoded() { |
10097 |
|
$val = str_replace("'", '"', $this->getVal('historique_signature')); |
10098 |
|
if ($val === '' || $val == 'false') { |
10099 |
|
$val = json_encode(array()); |
10100 |
|
} |
10101 |
|
if($this->isJson($val) === false) { |
10102 |
|
return false; |
10103 |
|
} |
10104 |
|
return json_decode($val, true); |
10105 |
|
} |
10106 |
|
|
10107 |
|
/** |
10108 |
|
* Récupère les informations à afficher dans le tableau de suivi à l'aide |
10109 |
|
* d'une requête sql. Stocke ces informations dans un tableau. |
10110 |
|
* Converti le tableau au format json et renvoi le json obtenu. |
10111 |
|
* |
10112 |
|
* Pour identifier quel suivi est affiché (notification des demandeurs, des services ou |
10113 |
|
* de tiers) ce sont les tâches liées aux notifications qui sont utilisés. |
10114 |
|
* La clause where de la requête est construite à partir du tableau contenant les types |
10115 |
|
* de tâches fourni en paramètre. |
10116 |
|
* Il est également possible d'afficher les notifications n'étant pas lié à des tâches. |
10117 |
|
* |
10118 |
|
* Si le suivi concerne la notification des demandeurs via le portail citoyen, |
10119 |
|
* la date de premier accès ne sera pas affichée. |
10120 |
|
* |
10121 |
|
* @param array liste des tâches permettant d'identifier quelles notification afficher |
10122 |
|
* @param boolean permet d'afficher les notifications non liées à des tâches |
10123 |
|
* @return json |
10124 |
|
*/ |
10125 |
|
public function get_json_suivi_notification($typeTache, $nonLieTache = false) { |
10126 |
|
$whereTypeTache = ''; |
10127 |
|
$sqlTaskNull = 'INNER'; |
10128 |
|
|
10129 |
|
// Liste des champs à afficher. Permet également la traduction des noms de colonnes. |
10130 |
|
$listeChampsTrad = array( |
10131 |
|
__('emetteur'), |
10132 |
|
__('date_envoi'), |
10133 |
|
__('destinataire'), |
10134 |
|
__('date_premier_acces'), |
10135 |
|
__('instruction'), |
10136 |
|
__('annexes'), |
10137 |
|
__('statut'), |
10138 |
|
__('commentaire') |
10139 |
|
); |
10140 |
|
$listeChamps = array( |
10141 |
|
'emetteur', |
10142 |
|
'date_envoi', |
10143 |
|
'destinataire', |
10144 |
|
'date_premier_acces', |
10145 |
|
'instruction', |
10146 |
|
'annexes', |
10147 |
|
'statut', |
10148 |
|
'commentaire' |
10149 |
|
); |
10150 |
|
|
10151 |
|
// Défini si on veux que la requête récupère également les notifications qui n'ont pas |
10152 |
|
// de tâches associées. C'est le cas pour les notifications de demandeurs lorsque la |
10153 |
|
// notification du demandeur principal n'a pas pu être envoyée à cause d'un mauvais |
10154 |
|
// paramétrage |
10155 |
|
if(is_bool($nonLieTache) && $nonLieTache === true) { |
10156 |
|
$sqlTaskNull = 'LEFT'; |
10157 |
|
} |
10158 |
|
// Prépare la clause where pour ne récupérer que les notifications liées à certain type de tâches |
10159 |
|
// Permet de différencier les notifications des demandeurs de celle des services et de celles des |
10160 |
|
// tiers consulté |
10161 |
|
if (is_array($typeTache) && $typeTache != array()) { |
10162 |
|
if (is_array($typeTache)) { |
10163 |
|
$whereTypeTache = sprintf( |
10164 |
|
'AND (task.task IS NULL OR (task.task IS NOT NULL AND task.type IN (%1$s)))', |
10165 |
|
"'".implode("', '", $typeTache)."'" |
10166 |
|
); |
10167 |
|
} |
10168 |
|
// La date de premier accès n'a pas besoin d'être renseigné pour |
10169 |
|
// les notifications des demandeurs via le portail citoyen. |
10170 |
|
// Les notifications des demandeurs sont liés à 3 types de tâches |
10171 |
|
// notification_recepisse, notification_instruction, notification_decision |
10172 |
|
// Si le suivi de la notification concerne un de ces types de tâches on |
10173 |
|
// considère que c'est une notification de demandeurs. |
10174 |
|
// Dans ce cas on vérifie si cette notification est paramétrée pour passer |
10175 |
|
// via le portail. Par défaut si rien n'est paramétré on considère que la |
10176 |
|
// notification est faite via le portail |
10177 |
|
if ((in_array('notification_recepisse', $typeTache) || |
10178 |
|
in_array('notification_instruction', $typeTache) || |
10179 |
|
in_array('notification_decision', $typeTache))) { |
10180 |
|
$dossier = $this->getVal('dossier'); |
10181 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite($dossier); |
10182 |
|
$modeNotification = $this->f->get_param_option_notification($collectivite_di); |
10183 |
|
if ($modeNotification === PORTAL) { |
10184 |
|
$listeChamps = array( |
10185 |
|
'emetteur', |
10186 |
|
'date_envoi', |
10187 |
|
'destinataire', |
10188 |
|
'instruction', |
10189 |
|
'annexes', |
10190 |
|
'statut', |
10191 |
|
'commentaire' |
10192 |
|
); |
10193 |
|
} |
10194 |
|
} |
10195 |
|
// Il n'y a pas d'annexe pour la notification des communes donc pas besoin |
10196 |
|
// de les afficher dans le suivi |
10197 |
|
if (in_array('notification_depot_demat', $typeTache)) { |
10198 |
|
$listeChamps = array( |
10199 |
|
'emetteur', |
10200 |
|
'date_envoi', |
10201 |
|
'destinataire', |
10202 |
|
'instruction', |
10203 |
|
'statut', |
10204 |
|
'commentaire' |
10205 |
|
); |
10206 |
|
} |
10207 |
|
} |
10208 |
|
|
10209 |
|
$valSuivi = array(); |
10210 |
|
// Récupération des infos nécessaires à l'affichage du tableau |
10211 |
|
$sql = sprintf( |
10212 |
|
'SELECT DISTINCT |
10213 |
|
instruction_notification.instruction_notification, |
10214 |
|
-- Affiche la mention automatique avec le nom de l emetteur si la notification a été envoyé automatiquement |
10215 |
|
CASE WHEN instruction_notification.automatique = TRUE |
10216 |
|
THEN TRIM(CONCAT(instruction_notification.emetteur, \' \', \'(automatique)\')) |
10217 |
|
ELSE instruction_notification.emetteur |
10218 |
|
END as emetteur, |
10219 |
|
date_envoi, |
10220 |
|
instruction_notification.destinataire, |
10221 |
|
instruction_notification.date_premier_acces, |
10222 |
|
evenement.libelle as instruction, |
10223 |
|
instruction_notification.statut, |
10224 |
|
instruction_notification.commentaire, |
10225 |
|
annexes.instruction_annexe as annexes |
10226 |
|
FROM |
10227 |
|
%1$sinstruction_notification |
10228 |
|
LEFT JOIN %1$sinstruction |
10229 |
|
ON instruction.instruction = instruction_notification.instruction |
10230 |
|
LEFT JOIN %1$sevenement |
10231 |
|
ON instruction.evenement = evenement.evenement |
10232 |
|
LEFT JOIN %1$sinstruction_notification_document |
10233 |
|
ON instruction_notification.instruction_notification = instruction_notification_document.instruction_notification |
10234 |
|
AND instruction_notification_document.annexe = true |
10235 |
|
-- Récupère les tâches liées au notification pour pouvoir par la suite identifier le type de notification |
10236 |
|
%4$s JOIN %1$stask |
10237 |
|
ON instruction_notification.instruction_notification::CHARACTER VARYING = task.object_id |
10238 |
|
AND task.type LIKE \'notification%%\' |
10239 |
|
-- Récupération de la liste des annexes sous la forme d une liste |
10240 |
|
LEFT JOIN ( |
10241 |
|
SELECT |
10242 |
|
instruction_notification, |
10243 |
|
-- Récupère la liste des annexes de la notification |
10244 |
|
-- sous la forme d un json pour récupérer toutes les informatiosn nécessaire |
10245 |
|
-- à l affichage du lien vers les annexes |
10246 |
|
CONCAT( |
10247 |
|
\'[\', |
10248 |
|
STRING_AGG( |
10249 |
|
-- Affiche le nom du fichier selon le type de document/pièce |
10250 |
|
CASE |
10251 |
|
WHEN instruction_notification_document.document_type = \'instruction\' |
10252 |
|
THEN CONCAT( |
10253 |
|
\'{ |
10254 |
|
"obj" : "instruction", |
10255 |
|
"champs" : "om_fichier_instruction", |
10256 |
|
"label" : "\', evenement.libelle, \'", |
10257 |
|
"id" : "\', instruction.instruction,\'" |
10258 |
|
}\' |
10259 |
|
) |
10260 |
|
WHEN instruction_notification_document.document_type = \'consultation\' |
10261 |
|
THEN CONCAT( |
10262 |
|
\'{ |
10263 |
|
"obj" : "consultation", |
10264 |
|
"champs" : "fichier", |
10265 |
|
"label" : "\', CONCAT_WS( \' - \', \'Avis\', service.libelle, to_char(consultation.date_retour,\'DD/MM/YYYY\')), \'", |
10266 |
|
"id" : "\', consultation.consultation, \'" |
10267 |
|
}\' |
10268 |
|
) |
10269 |
|
ELSE |
10270 |
|
CONCAT( |
10271 |
|
\'{ |
10272 |
|
"obj" : "document_numerise", |
10273 |
|
"champs" : "uid", |
10274 |
|
"label" : "\', document_numerise.nom_fichier, \' - \', document_numerise_type.libelle, \'", |
10275 |
|
"id" : "\', document_numerise.document_numerise,\'" |
10276 |
|
}\' |
10277 |
|
) |
10278 |
|
END, |
10279 |
|
\', \'), |
10280 |
|
\']\' |
10281 |
|
) AS instruction_annexe |
10282 |
|
FROM |
10283 |
|
%1$sinstruction_notification_document |
10284 |
|
LEFT JOIN %1$sinstruction |
10285 |
|
ON instruction_notification_document.instruction = instruction.instruction |
10286 |
|
LEFT JOIN %1$sevenement |
10287 |
|
ON instruction.evenement = evenement.evenement |
10288 |
|
LEFT JOIN %1$sconsultation |
10289 |
|
ON instruction_notification_document.document_id = consultation.consultation |
10290 |
|
LEFT JOIN %1$sservice |
10291 |
|
ON consultation.service = service.service |
10292 |
|
LEFT JOIN %1$sdocument_numerise |
10293 |
|
ON instruction_notification_document.document_id = document_numerise.document_numerise |
10294 |
|
LEFT JOIN %1$sdocument_numerise_type |
10295 |
|
ON document_numerise.document_numerise_type = document_numerise_type.document_numerise_type |
10296 |
|
WHERE |
10297 |
|
instruction_notification_document.annexe = \'t\' |
10298 |
|
GROUP BY |
10299 |
|
instruction_notification |
10300 |
|
) AS annexes |
10301 |
|
ON |
10302 |
|
annexes.instruction_notification = instruction_notification.instruction_notification |
10303 |
|
WHERE |
10304 |
|
instruction.instruction = %2$s |
10305 |
|
%3$s |
10306 |
|
ORDER BY |
10307 |
|
date_envoi ASC, instruction_notification.destinataire ASC', |
10308 |
|
DB_PREFIXE, |
10309 |
|
intval($this->getVal('instruction')), |
10310 |
|
$whereTypeTache, |
10311 |
|
$sqlTaskNull |
10312 |
|
); |
10313 |
|
$qres = $this->f->get_all_results_from_db_query($sql, array( |
10314 |
|
"origin" => __METHOD__ |
10315 |
|
) |
10316 |
|
); |
10317 |
|
// Préparation du lien de téléchargement des annexes |
10318 |
|
$htmlList = |
10319 |
|
'<style> |
10320 |
|
#content .gridjs-td a.lien_annexe { |
10321 |
|
text-decoration : underline dotted 1px; |
10322 |
|
} |
10323 |
|
#content a.lien_annexe:hover { |
10324 |
|
text-decoration : underline solid 1px; |
10325 |
|
color : #46aede; |
10326 |
|
} |
10327 |
|
ol {padding-left : 10px;} |
10328 |
|
</style> |
10329 |
|
<ol>%1$s</ol>'; |
10330 |
|
$lienTelechargement = |
10331 |
|
'<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"> |
10332 |
|
Annexe |
10333 |
|
</a>'; |
10334 |
|
// Stockage des infos de chaque notification dans un tableau |
10335 |
|
foreach ($qres['result'] as $row) { |
10336 |
|
$valNotif = array(); |
10337 |
|
foreach($listeChamps as $champ) { |
10338 |
|
$valNotif[$champ] = $row[$champ]; |
10339 |
|
if (($champ === 'date_envoi' |
10340 |
|
|| $champ === 'date_premier_acces') |
10341 |
|
&& $row[$champ] !== null |
10342 |
|
&& $row[$champ] !== '') { |
10343 |
|
// |
10344 |
|
$valNotif[$champ] = date('d/m/Y H:i:s', strtotime($row[$champ])); |
10345 |
|
} else if ($champ === 'annexes') { |
10346 |
|
$listeAnnexe = ''; |
10347 |
|
$infoAnnexes = json_decode($row[$champ], true); |
10348 |
|
if (! empty($infoAnnexes) && json_last_error() === JSON_ERROR_NONE) { |
10349 |
|
// A partir des infos récupérées prépare le code html du lien vers chacune |
10350 |
|
// des annexes et ajoute un élément de liste par annexe |
10351 |
|
foreach($infoAnnexes as $annexe) { |
10352 |
|
$listeAnnexe .= sprintf( |
10353 |
|
'<li>%s</li>', |
10354 |
|
sprintf($lienTelechargement, |
10355 |
|
$annexe['obj'], |
10356 |
|
$annexe['champs'], |
10357 |
|
$annexe['id'], |
10358 |
|
$annexe['label'] |
10359 |
|
) |
10360 |
|
); |
10361 |
|
} |
10362 |
|
// Construction de la liste des annexes |
10363 |
|
$valNotif[$champ] = sprintf( |
10364 |
|
$htmlList, |
10365 |
|
$listeAnnexe |
10366 |
|
); |
10367 |
|
} |
10368 |
|
} |
10369 |
|
} |
10370 |
|
array_push($valSuivi, $valNotif); |
10371 |
|
} |
10372 |
|
|
10373 |
|
// Passage du tableau au format json |
10374 |
|
return json_encode($valSuivi, JSON_HEX_APOS); |
10375 |
|
} |
10376 |
|
|
10377 |
|
/** |
10378 |
|
* Traitement des erreurs retournées par l'abstracteur electronicsignature. |
10379 |
|
* |
10380 |
|
* @param electronicsignature_exception $exception Exception retournée par l'abstracteur. |
10381 |
|
* |
10382 |
|
* @return void |
10383 |
|
*/ |
10384 |
|
public function handle_electronicsignature_exception(electronicsignature_exception $exception) { |
10385 |
|
$this->f->displayMessage('error', $exception->getMessage()); |
10386 |
|
} |
10387 |
|
|
10388 |
|
|
10389 |
|
/** |
10390 |
|
* Retourne une instance du connecteur electronicsignature, et la créer si elle n'existe pas. |
10391 |
|
* |
10392 |
|
* @param boolean $with_handle_error Flag pour afficher ou non le message d'erreur à l'utilisateur. |
10393 |
|
* @return electronicsignature Instance de l'abstracteur. |
10394 |
|
*/ |
10395 |
|
public function get_electronicsignature_instance($with_handle_error = true) { |
10396 |
|
if(isset($this->electronicsignature_instance)) { |
10397 |
|
return $this->electronicsignature_instance; |
10398 |
|
} |
10399 |
|
// Instanciation du connecteur electronicsignature |
10400 |
|
try { |
10401 |
|
require_once "electronicsignature.class.php"; |
10402 |
|
$collectivites = array("collectivite_idx" => $this->get_dossier_instruction_om_collectivite(), "collectivite_multi_idx" => $this->f->get_idx_collectivite_multi()); |
10403 |
|
$this->electronicsignature_instance = new electronicsignature($collectivites); |
10404 |
|
} catch (electronicsignature_exception $e) { |
10405 |
|
if ($with_handle_error === true) { |
10406 |
|
$this->handle_electronicsignature_exception($e); |
10407 |
|
} |
10408 |
|
return false; |
10409 |
|
} |
10410 |
|
return $this->electronicsignature_instance; |
10411 |
|
} |
10412 |
|
|
10413 |
|
/** |
10414 |
|
* TREATMENT - envoyer_au_controle_de_legalite |
10415 |
|
* |
10416 |
|
* Ajoute la tâche envoi_CL. |
10417 |
|
* C'est le traitement de la tâche qui mettra à jour la date d'envoi au contrôle de légalité. |
10418 |
|
* |
10419 |
|
* @return [type] [description] |
10420 |
|
*/ |
10421 |
|
function envoyer_au_controle_de_legalite() { |
10422 |
|
$this->begin_treatment(__METHOD__); |
10423 |
|
$this->correct = true; |
10424 |
|
|
10425 |
|
// |
10426 |
|
if ($this->can_be_sended_to_cl() === true) { |
10427 |
|
// Création de la task 'envoi_CL' |
10428 |
|
$inst_task = $this->f->get_inst__om_dbform(array( |
10429 |
|
"obj" => "task", |
10430 |
|
"idx" => 0, |
10431 |
|
)); |
10432 |
|
$task_val = array( |
10433 |
|
'type' => 'envoi_CL', |
10434 |
|
'object_id' => $this->getVal('instruction'), |
10435 |
|
'dossier' => $this->getVal('dossier'), |
10436 |
|
); |
10437 |
|
// Change l'état de la tâche de notification en fonction de l'état de |
10438 |
|
// transmission du dossier d'instruction |
10439 |
|
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
10440 |
|
if ($this->f->is_option_mode_service_consulte_enabled() === false |
10441 |
|
&& ($inst_di->getVal('etat_transmission_platau') == 'non_transmissible' |
10442 |
|
|| $inst_di->getVal('etat_transmission_platau') == 'transmis_mais_non_transmissible')) { |
10443 |
|
// |
10444 |
|
$task_val['state'] = $inst_task::STATUS_DRAFT; |
10445 |
|
} |
10446 |
|
$add_task = $inst_task->add_task(array('val' => $task_val)); |
10447 |
|
if ($add_task === false) { |
10448 |
|
$this->addToMessage(sprintf('%s %s', |
10449 |
|
__("Une erreur s'est produite lors de la création tâche."), |
10450 |
|
__("Veuillez contacter votre administrateur.") |
10451 |
|
)); |
10452 |
|
$this->correct = false; |
10453 |
|
return $this->end_treatment(__METHOD__, false); |
10454 |
|
} |
10455 |
|
// Mise à jour du champs 'envoye_cl_platau' |
10456 |
|
$instr_val = array( |
10457 |
|
'envoye_cl_platau' => 't', |
10458 |
|
); |
10459 |
|
$res = $this->f->db->autoExecute( |
10460 |
|
DB_PREFIXE.$this->table, |
10461 |
|
$instr_val, |
10462 |
|
DB_AUTOQUERY_UPDATE, |
10463 |
|
$this->getCle($this->getVal($this->clePrimaire)) |
10464 |
|
); |
10465 |
|
$this->addToLog(__METHOD__."(): db->autoexecute(\"".DB_PREFIXE.'.'.$this->table."\", ".print_r($instr_val, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($this->clePrimaire)."\");", VERBOSE_MODE); |
10466 |
|
if ($this->f->isDatabaseError($res, true) === true) { |
10467 |
|
$this->addToMessage(sprintf('%s %s', |
10468 |
|
__("Une erreur s'est produite lors de la mise à jour de l'instruction."), |
10469 |
|
__("Veuillez contacter votre administrateur.") |
10470 |
|
)); |
10471 |
|
$this->correct = false; |
10472 |
|
return $this->end_treatment(__METHOD__, false); |
10473 |
|
} |
10474 |
|
// Message de validation à l'utilisateur |
10475 |
|
$this->addToMessage(__('Votre demande de transfert au contrôle de légalité à bien été prise en compte.')); |
10476 |
|
$this->addToMessage(__("La date d'envoi au contrôle de légalité sera mise à jour ultérieurement.")); |
10477 |
|
} |
10478 |
|
// |
10479 |
|
return $this->end_treatment(__METHOD__, true); |
10480 |
|
} |
10481 |
|
|
10482 |
|
|
10483 |
|
/** |
10484 |
* Retourne le lien de retour (VIEW formulaire et VIEW sousformulaire). |
* Retourne le lien de retour (VIEW formulaire et VIEW sousformulaire). |
10485 |
* |
* |
10486 |
* @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 |
10524 |
return $href; |
return $href; |
10525 |
} |
} |
10526 |
|
|
10527 |
}// fin classe |
public function view_json_data() { |
10528 |
|
$this->checkAccessibility(); |
10529 |
|
$this->f->disableLog(); |
10530 |
|
$view = $this->get_json_data(); |
10531 |
|
printf(json_encode($view)); |
10532 |
|
} |
10533 |
|
|
10534 |
|
public function get_json_data() { |
10535 |
|
$val = array_combine($this->champs, $this->val); |
10536 |
|
foreach ($val as $key => $value) { |
10537 |
|
$val[$key] = strip_tags($value); |
10538 |
|
} |
10539 |
|
$val['tacite'] = 'f'; |
10540 |
|
$inst_ad = $this->f->get_inst__om_dbform(array( |
10541 |
|
"obj" => "avis_decision", |
10542 |
|
"idx" => $val['avis_decision'], |
10543 |
|
)); |
10544 |
|
if (preg_match('/[tT]acite/', $inst_ad->getVal('libelle')) === 1) { |
10545 |
|
$val['tacite'] = 't'; |
10546 |
|
} |
10547 |
|
return $val; |
10548 |
|
} |
10549 |
|
|
10550 |
|
/** |
10551 |
|
* Permet de récupérer l'identifiant de l'instruction sur le dossier, ayant |
10552 |
|
* comme événement lié le suivant définit dans l'événement de l'instruction |
10553 |
|
* instanciée. |
10554 |
|
* |
10555 |
|
* @param string $next_type Correspond aux trois déclenchement automatique |
10556 |
|
* de création d'instruction paramétré sur un événement. |
10557 |
|
* @param integer $instruction Identifiant de l'instruction à instancier. |
10558 |
|
* @return mixed Identifiant de l'instruction recherchée ou false. |
10559 |
|
*/ |
10560 |
|
public function get_related_instructions_next($next_type = 'retour_signature', $instruction = null) { |
10561 |
|
if (in_array($next_type, array('retour_signature', 'retour_ar', 'suivant_tacite', )) === false) { |
10562 |
|
return false; |
10563 |
|
} |
10564 |
|
$result = array(); |
10565 |
|
$evenements = array(); |
10566 |
|
if ($instruction === null) { |
10567 |
|
$instruction = $this->getVal($this->clePrimaire); |
10568 |
|
$evenement = $this->getVal('evenement'); |
10569 |
|
$dossier = $this->getVal('dossier'); |
10570 |
|
} else { |
10571 |
|
$inst = $this->f->get_inst__om_dbform(array( |
10572 |
|
"obj" => "instruction", |
10573 |
|
"idx" => $instruction, |
10574 |
|
)); |
10575 |
|
$evenement = $inst->getVal('evenement'); |
10576 |
|
$dossier = $inst->getVal('dossier'); |
10577 |
|
} |
10578 |
|
// Récupération de l'identifiant de l'événement paramétré comme suivant |
10579 |
|
// sur l'instruction instanciée |
10580 |
|
$qres = $this->f->get_one_result_from_db_query( |
10581 |
|
sprintf( |
10582 |
|
'SELECT |
10583 |
|
evenement_%3$s |
10584 |
|
FROM |
10585 |
|
%1$sevenement |
10586 |
|
WHERE |
10587 |
|
evenement = %2$s', |
10588 |
|
DB_PREFIXE, |
10589 |
|
intval($evenement), |
10590 |
|
$next_type |
10591 |
|
), |
10592 |
|
array( |
10593 |
|
"origin" => __METHOD__, |
10594 |
|
"force_return" => true, |
10595 |
|
) |
10596 |
|
); |
10597 |
|
if ($qres["code"] !== "OK") { |
10598 |
|
return false; |
10599 |
|
} |
10600 |
|
$ev_next = $qres["result"]; |
10601 |
|
// Récupération de l'instruction dans le dossier utilisant l'événement |
10602 |
|
// suivant identifié dans la requête précédente |
10603 |
|
$qres = $this->f->get_one_result_from_db_query( |
10604 |
|
sprintf( |
10605 |
|
'SELECT |
10606 |
|
MAX(instruction.instruction) as instruction |
10607 |
|
FROM |
10608 |
|
%1$sinstruction |
10609 |
|
WHERE |
10610 |
|
dossier = \'%3$s\' |
10611 |
|
AND evenement = %2$s', |
10612 |
|
DB_PREFIXE, |
10613 |
|
intval($ev_next), |
10614 |
|
$this->f->db->escapeSimple($dossier) |
10615 |
|
), |
10616 |
|
array( |
10617 |
|
"origin" => __METHOD__, |
10618 |
|
"force_return" => true, |
10619 |
|
) |
10620 |
|
); |
10621 |
|
if ($qres["code"] !== "OK") { |
10622 |
|
return false; |
10623 |
|
} |
10624 |
|
return $qres["result"]; |
10625 |
|
} |
10626 |
|
|
10627 |
|
public function get_related_instructions($instruction = null) { |
10628 |
|
$result = array(); |
10629 |
|
$evenements = array(); |
10630 |
|
if ($instruction === null) { |
10631 |
|
$instruction = $this->getVal($this->clePrimaire); |
10632 |
|
$evenement = $this->getVal('evenement'); |
10633 |
|
$dossier = $this->getVal('dossier'); |
10634 |
|
} else { |
10635 |
|
$inst = $this->f->get_inst__om_dbform(array( |
10636 |
|
"obj" => "instruction", |
10637 |
|
"idx" => $instruction, |
10638 |
|
)); |
10639 |
|
$evenement = $inst->getVal('evenement'); |
10640 |
|
$dossier = $inst->getVal('dossier'); |
10641 |
|
} |
10642 |
|
// |
10643 |
|
$qres = $this->f->get_one_result_from_db_query( |
10644 |
|
sprintf( |
10645 |
|
'SELECT |
10646 |
|
evenement |
10647 |
|
FROM |
10648 |
|
%1$sevenement |
10649 |
|
WHERE |
10650 |
|
evenement_retour_ar = %2$s |
10651 |
|
OR evenement_retour_signature = %2$s', |
10652 |
|
DB_PREFIXE, |
10653 |
|
intval($evenement) |
10654 |
|
), |
10655 |
|
array( |
10656 |
|
"origin" => __METHOD__, |
10657 |
|
"force_return" => true, |
10658 |
|
) |
10659 |
|
); |
10660 |
|
if ($qres["code"] !== "OK") { |
10661 |
|
return false; |
10662 |
|
} |
10663 |
|
$ev_parent = $qres["result"]; |
10664 |
|
// |
10665 |
|
$qres = $this->f->get_one_result_from_db_query( |
10666 |
|
sprintf( |
10667 |
|
'SELECT |
10668 |
|
MAX(instruction.instruction) as instruction |
10669 |
|
FROM |
10670 |
|
%1$sinstruction |
10671 |
|
WHERE |
10672 |
|
dossier = \'%3$s\' |
10673 |
|
AND evenement = %2$s', |
10674 |
|
DB_PREFIXE, |
10675 |
|
intval($ev_parent), |
10676 |
|
$this->f->db->escapeSimple($dossier) |
10677 |
|
), |
10678 |
|
array( |
10679 |
|
"origin" => __METHOD__, |
10680 |
|
"force_return" => true, |
10681 |
|
) |
10682 |
|
); |
10683 |
|
if ($qres["code"] !== "OK") { |
10684 |
|
return false; |
10685 |
|
} |
10686 |
|
$result[] = $qres["result"]; |
10687 |
|
// |
10688 |
|
$qres = $this->f->get_one_result_from_db_query( |
10689 |
|
sprintf( |
10690 |
|
'SELECT |
10691 |
|
evenement_retour_ar |
10692 |
|
FROM |
10693 |
|
%1$sevenement |
10694 |
|
WHERE |
10695 |
|
evenement = %2$d |
10696 |
|
AND evenement_retour_ar != %3$d', |
10697 |
|
DB_PREFIXE, |
10698 |
|
intval($ev_parent), |
10699 |
|
intval($evenement) |
10700 |
|
), |
10701 |
|
array( |
10702 |
|
"origin" => __METHOD__, |
10703 |
|
"force_return" => true, |
10704 |
|
) |
10705 |
|
); |
10706 |
|
if ($qres["code"] !== "OK") { |
10707 |
|
return false; |
10708 |
|
} |
10709 |
|
$evenements[] = $qres["result"]; |
10710 |
|
// |
10711 |
|
$qres = $this->f->get_one_result_from_db_query( |
10712 |
|
sprintf( |
10713 |
|
'SELECT |
10714 |
|
evenement_retour_signature |
10715 |
|
FROM |
10716 |
|
%1$sevenement |
10717 |
|
WHERE |
10718 |
|
evenement = %2$s |
10719 |
|
AND evenement_retour_signature != %3$s |
10720 |
|
', |
10721 |
|
DB_PREFIXE, |
10722 |
|
intval($ev_parent), |
10723 |
|
intval($evenement) |
10724 |
|
), |
10725 |
|
array( |
10726 |
|
"origin" => __METHOD__, |
10727 |
|
"force_return" => true, |
10728 |
|
) |
10729 |
|
); |
10730 |
|
if ($qres["code"] !== "OK") { |
10731 |
|
return false; |
10732 |
|
} |
10733 |
|
$evenements[] = $qres["result"]; |
10734 |
|
foreach ($evenements as $value) { |
10735 |
|
if ($value !== null) { |
10736 |
|
$qres = $this->f->get_one_result_from_db_query( |
10737 |
|
sprintf( |
10738 |
|
'SELECT |
10739 |
|
MAX(instruction.instruction) as instruction |
10740 |
|
FROM |
10741 |
|
%1$sinstruction |
10742 |
|
WHERE |
10743 |
|
dossier = \'%3$s\' |
10744 |
|
AND evenement = %2$s', |
10745 |
|
DB_PREFIXE, |
10746 |
|
intval($value), |
10747 |
|
$this->f->db->escapeSimple($dossier) |
10748 |
|
), |
10749 |
|
array( |
10750 |
|
"origin" => __METHOD__, |
10751 |
|
"force_return" => true, |
10752 |
|
) |
10753 |
|
); |
10754 |
|
if ($qres["code"] !== "OK") { |
10755 |
|
return false; |
10756 |
|
} |
10757 |
|
$result[] = $qres["result"]; |
10758 |
|
} |
10759 |
|
} |
10760 |
|
return $result; |
10761 |
|
} |
10762 |
|
|
10763 |
|
protected function getDocumentType($champ = null) { |
10764 |
|
$evenementId = $this->getVal('evenement'); |
10765 |
|
if (! empty($evenementId)) { |
10766 |
|
$evenement = $this->f->findObjectById('evenement', $evenementId); |
10767 |
|
if (! empty($evenement)) { |
10768 |
|
return __("Instruction").':'.$evenement->getVal('libelle'); |
10769 |
|
} |
10770 |
|
} |
10771 |
|
return parent::getDocumentType(); |
10772 |
|
} |
10773 |
|
|
10774 |
|
/** |
10775 |
|
* Récupère à l'aide d'une requête sql la liste des demandeurs |
10776 |
|
* pouvant être notifié. C'est à dire les demandeurs acceptant |
10777 |
|
* les notifications et pour lesquels une adresse mail existe. |
10778 |
|
* |
10779 |
|
* Dans le cas, d'une notification pour le portail citoyen, seul |
10780 |
|
* le pétitionnaire principal doit être notifier et uniquement si |
10781 |
|
* il a une adress mail et qu'il accepte les notifications. |
10782 |
|
* |
10783 |
|
* @param string identifiant du dossier |
10784 |
|
* @param boolean true si il faut récupérer la liste des demandeurs notifiable |
10785 |
|
* pour une notification de categorie portail |
10786 |
|
* @return array liste des demandeurs pouvant être notifié |
10787 |
|
*/ |
10788 |
|
protected function get_demandeurs_notifiable($idDossier = null, $portail = false) { |
10789 |
|
if ($idDossier === null) { |
10790 |
|
$idDossier = $this->getVal('dossier'); |
10791 |
|
} |
10792 |
|
// Ajoute une condition sur le where pour ne récupérer que le pétitionnaire principal |
10793 |
|
// pour une notification depuis le portail citoyen |
10794 |
|
$sqlPetitionnairePrincipal = ''; |
10795 |
|
// Gestion des champs nécessaires pour la notification d'un demandeur |
10796 |
|
$condition_demandeur = "AND demandeur.notification = 't' |
10797 |
|
AND demandeur.courriel IS NOT NULL"; |
10798 |
|
if ($portail === true) { |
10799 |
|
$sqlPetitionnairePrincipal = 'AND lien_dossier_demandeur.petitionnaire_principal = true'; |
10800 |
|
$condition_demandeur = "AND ( |
10801 |
|
(notification = 't' AND courriel IS NOT NULL) |
10802 |
|
OR demande.source_depot = 'portal' |
10803 |
|
)"; |
10804 |
|
} |
10805 |
|
|
10806 |
|
$listeDemandeursNotifiable = array(); |
10807 |
|
|
10808 |
|
// Requête de récupération des demandeurs |
10809 |
|
$qres = $this->f->get_all_results_from_db_query( |
10810 |
|
sprintf( |
10811 |
|
'SELECT |
10812 |
|
demandeur.demandeur, |
10813 |
|
CASE |
10814 |
|
WHEN demandeur.qualite=\'particulier\' |
10815 |
|
THEN TRIM(CONCAT(demandeur.particulier_nom, \' \', demandeur.particulier_prenom, \' \', demandeur.courriel)) |
10816 |
|
ELSE |
10817 |
|
TRIM(CONCAT(demandeur.personne_morale_raison_sociale, \' \', demandeur.personne_morale_denomination, \' \', demandeur.courriel)) |
10818 |
|
END AS destinataire, |
10819 |
|
demandeur.courriel, |
10820 |
|
petitionnaire_principal |
10821 |
|
FROM |
10822 |
|
%1$sdossier |
10823 |
|
INNER JOIN %1$slien_dossier_demandeur |
10824 |
|
ON dossier.dossier = lien_dossier_demandeur.dossier |
10825 |
|
INNER JOIN %1$sdemandeur |
10826 |
|
ON lien_dossier_demandeur.demandeur = demandeur.demandeur |
10827 |
|
-- Récupération de la plus ancienne demande associée au dossier (la demande |
10828 |
|
-- de création du dossier) |
10829 |
|
INNER JOIN ( |
10830 |
|
SELECT |
10831 |
|
demande, |
10832 |
|
dossier_instruction, |
10833 |
|
source_depot |
10834 |
|
FROM |
10835 |
|
%1$sdemande |
10836 |
|
WHERE |
10837 |
|
dossier_instruction = \'%2$s\' |
10838 |
|
ORDER BY |
10839 |
|
demande ASC |
10840 |
|
LIMIT 1 |
10841 |
|
) as demande |
10842 |
|
ON dossier.dossier = demande.dossier_instruction |
10843 |
|
WHERE |
10844 |
|
dossier.dossier = \'%2$s\' |
10845 |
|
%3$s |
10846 |
|
%4$s', |
10847 |
|
DB_PREFIXE, |
10848 |
|
$this->f->db->escapeSimple($idDossier), |
10849 |
|
$condition_demandeur, |
10850 |
|
$sqlPetitionnairePrincipal |
10851 |
|
), |
10852 |
|
array( |
10853 |
|
"origin" => __METHOD__ |
10854 |
|
) |
10855 |
|
); |
10856 |
|
// Récupération des infos des demandeurs et stockage dans un tableau |
10857 |
|
// ayant pour clé les id des demandeurs |
10858 |
|
foreach ($qres['result'] as $row) { |
10859 |
|
$listeDemandeursNotifiable[$row['demandeur']] = $row; |
10860 |
|
} |
10861 |
|
|
10862 |
|
return $listeDemandeursNotifiable; |
10863 |
|
} |
10864 |
|
|
10865 |
|
/** |
10866 |
|
* Renvoie la liste des notifications liées à l'instruction |
10867 |
|
* |
10868 |
|
* @param integer id de l'instruction dont on cherche les notifications |
10869 |
|
* @return array liste des instruction_notification liés à l'instruction |
10870 |
|
*/ |
10871 |
|
public function get_instruction_notification($id_instruction, $typeNotification = null, $nonLieTache = false) { |
10872 |
|
$whereTypeTache = ''; |
10873 |
|
$sqlTaskNull = 'INNER'; |
10874 |
|
// Défini si on veux que la requête récupère également les notifications qui n'ont pas |
10875 |
|
// de tâches associées. C'est le cas pour les notifications de demandeurs lorsque la |
10876 |
|
// notification du demandeur principal n'a pas pu être envoyée à cause d'un mauvais |
10877 |
|
// paramétrage |
10878 |
|
if(is_bool($nonLieTache) && $nonLieTache === true) { |
10879 |
|
$sqlTaskNull = 'LEFT'; |
10880 |
|
} |
10881 |
|
if ($typeNotification != null) { |
10882 |
|
if (is_array($typeNotification)) { |
10883 |
|
$whereTypeTache = sprintf( |
10884 |
|
'AND (task.type IN (%1$s))', |
10885 |
|
"'".implode("', '", $typeNotification)."'" |
10886 |
|
); |
10887 |
|
} else { |
10888 |
|
$whereTypeTache = sprintf( |
10889 |
|
'AND (task.type = \'%1$s\')', |
10890 |
|
$typeNotification |
10891 |
|
); |
10892 |
|
} |
10893 |
|
} |
10894 |
|
$listeInstrNotif = array(); |
10895 |
|
$qres = $this->f->get_all_results_from_db_query( |
10896 |
|
sprintf(' |
10897 |
|
SELECT |
10898 |
|
instruction_notification.instruction_notification |
10899 |
|
FROM |
10900 |
|
%1$sinstruction_notification |
10901 |
|
%4$s JOIN %1$stask |
10902 |
|
ON instruction_notification.instruction_notification::CHARACTER VARYING = task.object_id |
10903 |
|
%3$s |
10904 |
|
WHERE |
10905 |
|
instruction = %2$s', |
10906 |
|
DB_PREFIXE, |
10907 |
|
intval($id_instruction), |
10908 |
|
$whereTypeTache, |
10909 |
|
$sqlTaskNull |
10910 |
|
), |
10911 |
|
array( |
10912 |
|
"origin" => __METHOD__ |
10913 |
|
) |
10914 |
|
); |
10915 |
|
foreach ($qres['result'] as $row) { |
10916 |
|
$listeInstrNotif[] = $row['instruction_notification']; |
10917 |
|
} |
10918 |
|
return $listeInstrNotif; |
10919 |
|
} |
10920 |
|
|
10921 |
|
/** |
10922 |
|
* Crée une clé d'accès unique permettant à un utilisateur |
10923 |
|
* anonyme de récupérer le document. |
10924 |
|
* |
10925 |
|
* @return string clé d'accès du document |
10926 |
|
*/ |
10927 |
|
protected function getCleAccesDocument() { |
10928 |
|
// Initialisation d'un tableau |
10929 |
|
$number_list = array(); |
10930 |
|
|
10931 |
|
// Génération aléatoire d'un nombre sur 4 caractères, 4 fois |
10932 |
|
for ($i = 0; $i < 4; $i++) { |
10933 |
|
$number_list[] = str_pad(mt_rand(0, 9999), 4, 0, STR_PAD_LEFT); |
10934 |
|
} |
10935 |
|
|
10936 |
|
// Transformation en chaîne tout en séparant les nombres par un "-" |
10937 |
|
$result = implode('-', $number_list); |
10938 |
|
|
10939 |
|
// Vérifie si la clé existe déjà et si c'est le cas génére une nouvelle clé |
10940 |
|
if ($this->getUidDocumentInstructionWithKey($result) != null) { |
10941 |
|
return $this->getCleAccesDocument(); |
10942 |
|
} |
10943 |
|
|
10944 |
|
// |
10945 |
|
return $result; |
10946 |
|
} |
10947 |
|
|
10948 |
|
/** |
10949 |
|
* Récupère une clé et renvoie l'uid du document liée à cette |
10950 |
|
* clé. Si la clé n'existe pas renvoie null. |
10951 |
|
* |
10952 |
|
* @param string $cleGen clé dont on cherche l'instruction |
10953 |
|
* @return integer|null |
10954 |
|
*/ |
10955 |
|
protected function getUidDocumentInstructionWithKey($cleGen) { |
10956 |
|
$qres = $this->f->get_one_result_from_db_query( |
10957 |
|
sprintf( |
10958 |
|
'SELECT |
10959 |
|
instruction.om_fichier_instruction |
10960 |
|
FROM |
10961 |
|
%1$sinstruction_notification_document |
10962 |
|
LEFT JOIN %1$sinstruction |
10963 |
|
ON instruction_notification_document.instruction = instruction.instruction |
10964 |
|
WHERE |
10965 |
|
instruction_notification_document.cle = \'%2$s\'', |
10966 |
|
DB_PREFIXE, |
10967 |
|
$this->f->db->escapeSimple($cleGen) |
10968 |
|
), |
10969 |
|
array( |
10970 |
|
"origin" => __METHOD__, |
10971 |
|
) |
10972 |
|
); |
10973 |
|
|
10974 |
|
return $qres['result']; |
10975 |
|
} |
10976 |
|
|
10977 |
|
/** |
10978 |
|
* Récupère une clé, fait une requête pour récupérer l'id de la notification liée a cette clé. |
10979 |
|
* Récupère l'instance de instruction_notification dont l'id a été récupéré et la renvoie. |
10980 |
|
* |
10981 |
|
* @param string $cleGen |
10982 |
|
* @return instruction_notification |
10983 |
|
*/ |
10984 |
|
protected function getInstanceNotificationWithKey($key) { |
10985 |
|
$qres = $this->f->get_one_result_from_db_query( |
10986 |
|
sprintf( |
10987 |
|
'SELECT |
10988 |
|
instruction_notification |
10989 |
|
FROM |
10990 |
|
%1$sinstruction_notification_document |
10991 |
|
WHERE |
10992 |
|
cle = \'%2$s\'', |
10993 |
|
DB_PREFIXE, |
10994 |
|
$this->f->db->escapeSimple($key) |
10995 |
|
), |
10996 |
|
array( |
10997 |
|
"origin" => __METHOD__, |
10998 |
|
) |
10999 |
|
); |
11000 |
|
|
11001 |
|
// Récupération de l'instance de notification |
11002 |
|
$instNotif = $this->f->get_inst__om_dbform(array( |
11003 |
|
"obj" => "instruction_notification", |
11004 |
|
"idx" => $qres['result'], |
11005 |
|
)); |
11006 |
|
return $instNotif; |
11007 |
|
} |
11008 |
|
|
11009 |
|
|
11010 |
|
/** |
11011 |
|
* Affiche la page de téléchargement du document de la notification. |
11012 |
|
* |
11013 |
|
* @param boolean $content_only Affiche le contenu seulement. |
11014 |
|
* |
11015 |
|
* @return void |
11016 |
|
*/ |
11017 |
|
public function view_telecharger_document_anonym() { |
11018 |
|
// Par défaut on considère qu'on va afficher le formulaire |
11019 |
|
$idx = 0; |
11020 |
|
// Flag d'erreur |
11021 |
|
$error = false; |
11022 |
|
// Message d'erreur |
11023 |
|
$message = ''; |
11024 |
|
|
11025 |
|
// Paramètres GET : récupération de la clé d'accès |
11026 |
|
$cle_acces_document = $this->f->get_submitted_get_value('key'); |
11027 |
|
$cle_acces_document = $this->f->db->escapeSimple($cle_acces_document); |
11028 |
|
// Vérification de l'existence de la clé et récupération de l'uid du fichier |
11029 |
|
$uidFichier = $this->getUidDocumentInstructionWithKey($cle_acces_document); |
11030 |
|
if ($uidFichier != null) { |
11031 |
|
// Récupération du document |
11032 |
|
$file = $this->f->storage->get($uidFichier); |
11033 |
|
|
11034 |
|
// Headers |
11035 |
|
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 |
11036 |
|
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date dans le passé |
11037 |
|
header("Content-Type: ".$file['metadata']['mimetype']); |
11038 |
|
header("Accept-Ranges: bytes"); |
11039 |
|
header("Content-Disposition: inline; filename=\"".$file['metadata']['filename']."\";" ); |
11040 |
|
// Affichage du document |
11041 |
|
echo $file['file_content']; |
11042 |
|
|
11043 |
|
// Récupération de la date de premier accès et maj du suivi uniquement |
11044 |
|
// si la date de 1er accès n'a pas encore été remplis |
11045 |
|
$inst_notif = $this->getInstanceNotificationWithKey($cle_acces_document); |
11046 |
|
if ($inst_notif->getVal('date_premier_acces') == null || |
11047 |
|
$inst_notif->getVal('date_premier_acces') == '') { |
11048 |
|
$notif_val = array(); |
11049 |
|
foreach ($inst_notif->champs as $champ) { |
11050 |
|
$notif_val[$champ] = $inst_notif->getVal($champ); |
11051 |
|
} |
11052 |
|
$notif_val['date_premier_acces'] = date("d/m/Y H:i:s"); |
11053 |
|
$notif_val['statut'] = 'vu'; |
11054 |
|
$notif_val['commentaire'] = 'Le document a été vu'; |
11055 |
|
$suivi_notif = $inst_notif->modifier($notif_val); |
11056 |
|
} |
11057 |
|
|
11058 |
|
} else { |
11059 |
|
// Page vide 404 |
11060 |
|
printf('Ressource inexistante'); |
11061 |
|
header('HTTP/1.0 404 Not Found'); |
11062 |
|
} |
11063 |
|
} |
11064 |
|
|
11065 |
|
/** |
11066 |
|
* Récupère le titre du document envoyé au parapheur |
11067 |
|
*/ |
11068 |
|
protected function getDocumentTitre($champ = null) { |
11069 |
|
$title = $this->getTitle(); |
11070 |
|
$dossier = $this->getDossier(); |
11071 |
|
return $dossier.' '.$title; |
11072 |
|
} |
11073 |
|
|
11074 |
|
/** |
11075 |
|
* Compose le nom du document à transmettre au parapheur. |
11076 |
|
* Le nom ets composé de cette manière : |
11077 |
|
* instruction_xxx_libelle_de_la_lettre_type_associee |
11078 |
|
* ou xxx correspond au numéro de l'instruction |
11079 |
|
*/ |
11080 |
|
protected function getDocumentLibelle() { |
11081 |
|
// Récupère le champ instruction |
11082 |
|
$instruction = $this->getVal("instruction"); |
11083 |
|
|
11084 |
|
// Requête sql servant à récupérer le titre du document |
11085 |
|
// TO_CHAR() introduit un espace avant l'affichage du nombre |
11086 |
|
// comme les espaces sont remplacé par des '_' dans le retour de la fonction |
11087 |
|
// il n'est pas nécessaire de mettre un '_' après le mot instruction. |
11088 |
|
$documentLibelle = $this->f->get_one_result_from_db_query( |
11089 |
|
sprintf( |
11090 |
|
'SELECT |
11091 |
|
CONCAT( |
11092 |
|
\'instruction\', |
11093 |
|
TO_CHAR(instruction.instruction, \'000\'), |
11094 |
|
\'_\', |
11095 |
|
LOWER(om_lettretype.libelle) |
11096 |
|
) AS nom_fichier |
11097 |
|
FROM |
11098 |
|
%1$sinstruction |
11099 |
|
LEFT JOIN %1$som_lettretype |
11100 |
|
ON om_lettretype.id = instruction.lettretype |
11101 |
|
WHERE |
11102 |
|
instruction = %2$d', |
11103 |
|
DB_PREFIXE, |
11104 |
|
intval($instruction) |
11105 |
|
), |
11106 |
|
array( |
11107 |
|
"origin" => __METHOD__, |
11108 |
|
) |
11109 |
|
); |
11110 |
|
|
11111 |
|
$documentLibelle = $documentLibelle['result']; |
11112 |
|
|
11113 |
|
// Transforamtion des ' ' en '_', des accents en lettres sans accents et des |
11114 |
|
// caractères spéciaux en '_' |
11115 |
|
// La méthode normalize_string est utilisé pour gérer les accents |
11116 |
|
$documentLibelle = $this->f->normalize_string($documentLibelle); |
11117 |
|
// TODO : comparer cette liste et celle de la méthode normalize_string |
11118 |
|
// pour éviter les doublons + vérifier qu'il n'y a pas de doublons dans cette |
11119 |
|
// liste |
11120 |
|
$invalid = array('Œ'=>'oe', 'œ'=>'oe', 'Ÿ'=>'y', 'ü'=>'u', |
11121 |
|
'¢' => '_', 'ß' => '_', '¥' => '_', '£' => '_', '™' => '_', '©' => '_', |
11122 |
|
'®' => '_', 'ª' => '_', '×' => '_', '÷' => '_', '±' => '_', '²' => '_', |
11123 |
|
'³' => '_', '¼' => '_', '½' => '_', '¾' => '_', 'µ' => '_', '¿' => '_', |
11124 |
|
'¶' => '_', '·' => '_', '¸' => '_', 'º' => '_', '°' => '_', '¯' => '_', |
11125 |
|
'§' => '_', '…' => '_', '¤' => '_', '¦' => '_', '≠' => '_', '¬' => '_', |
11126 |
|
'ˆ' => '_', '¨' => '_', '‰' => '_', '¤' => '_', '€' => '_', '$' => '_', |
11127 |
|
'«' => '_', '»' => '_', '‹' => '_', '›' => '_', 'ƒ' => '_', '¥' => '_', |
11128 |
|
'‘‘' => '_', '‚' => '_', '!' => '_', '¡' => '_', '¢' => '_', '£' => '_', |
11129 |
|
'?' => '_', '[' => '_', ']' => '_', '´' => '_', '`' => '_', '^' => '_', |
11130 |
|
'~' => '_', '˜' => '_', '#' => '_', '*' => '_', '.' => '_', ':' => '_', |
11131 |
|
';' => '_', '•' => '_', '¯' => '_', '‾' => '_', '–' => '_', '–' => '_', |
11132 |
|
'—' => '_', '_' => '_', '|' => '_', '¦' => '_', '‡' => '_', '§' => '_', |
11133 |
|
'¶' => '_', '©' => '_', '®' => '_', '™' => '_', '&' => '_', '@' => '_', |
11134 |
|
'/' => '_', '\\' => '_', '◊' => '_', '♠' => '_', '♣' => '_', '♥' => '_', |
11135 |
|
'♦' => '_', '←' => '_', '↑' => '_', '→' => '_', '↓' => '_', '↔' => '_', |
11136 |
|
'°' => '_', 'µ' => '_', '<' => '_', '>' => '_', '≤' => '_', '≥' => '_', |
11137 |
|
'=' => '_', '≈' => '_', '≠' => '_', '≡' => '_', '±' => '_', '−' => '_', |
11138 |
|
'+' => '_', '×' => '_', '÷' => '_', '⁄' => '_', '%' => '_', '‰' => '_', |
11139 |
|
'¼' => '_', '½' => '_', '¾' => '_', '¹' => '_', '²' => '_', '³' => '_', |
11140 |
|
'' => '_', 'º' => '_', 'ª' => '_', 'ƒ' => '_', '′' => '_', '″' => '_', |
11141 |
|
'∂' => '_', '∏' => '_', '∑' => '_', '√' => '_', '∞' => '_', '¬' => '_', |
11142 |
|
'∩' => '_', '∫' => '_', 'α' => '_', 'Α' => '_', 'β' => '_', 'Β' => '_', |
11143 |
|
'γ' => '_', 'Γ' => '_', 'δ' => '_', 'Δ' => '_', 'ε' => '_', 'Ε' => '_', |
11144 |
|
'ζ' => '_', 'Ζ' => '_', 'η' => '_', 'Η' => '_', 'θ' => '_', 'Θ' => '_', |
11145 |
|
'ι' => '_', 'Ι' => '_', 'κ' => '_', 'Κ' => '_', 'λ' => '_', 'Λ' => '_', |
11146 |
|
'μ' => '_', 'Μ' => '_', 'ν' => '_', 'Ν' => '_', 'ξ' => '_', 'Ξ' => '_', |
11147 |
|
'ο' => '_', 'Ο' => '_', 'π' => '_', 'Π' => '_', 'ρ' => '_', 'Ρ' => '_', |
11148 |
|
'σ' => '_', 'ς' => '_', 'Σ' => '_', 'τ' => '_', 'Τ' => '_', 'υ' => '_', |
11149 |
|
'Υ' => '_', 'φ' => '_', 'Φ' => '_', 'χ' => '_', 'Χ' => '_', 'ψ' => '_', |
11150 |
|
'Ψ' => '_', 'ω' => '_', 'Ω' => '_', ',' => '_', ' ' => '_' |
11151 |
|
); |
11152 |
|
|
11153 |
|
return str_replace(array_keys($invalid), array_values($invalid), $documentLibelle); |
11154 |
|
} |
11155 |
|
|
11156 |
|
/** |
11157 |
|
* Surcharge permettant de ne pas afficher le fil d'Ariane dans |
11158 |
|
* l'overlay de notification des demandeurs. |
11159 |
|
*/ |
11160 |
|
function getSubFormTitle($ent) { |
11161 |
|
$actionSansPath = array('411', '420', '430'); |
11162 |
|
if (in_array($this->getParameter('maj'), $actionSansPath)) { |
11163 |
|
return ''; |
11164 |
|
} |
11165 |
|
return parent::getSubFormTitle($ent); |
11166 |
|
} |
11167 |
|
|
11168 |
|
/** |
11169 |
|
* Traitement de la notification automatique des tiers consulté. |
11170 |
|
* |
11171 |
|
* Récupère la liste des adresses mails des tiers notifiables. Pour chaque adresses |
11172 |
|
* récupérées ajoute une notification et une tâche de notification par mail. |
11173 |
|
* La création de la tâche de notification par mail déclenchera l'envoi du mail |
11174 |
|
* et la mise à jour du suivi. |
11175 |
|
* |
11176 |
|
* Les tiers notifiables sont ceux : |
11177 |
|
* - n’ayant pas un ID PLAT’AU correspondant à l’ID PLAT’AU du service consultant |
11178 |
|
* - ayant une habilitation dont le type est listé dans les paramètres de |
11179 |
|
* notification de l’événement, |
11180 |
|
* - intervenant sur la commune ou le département du dossier |
11181 |
|
* - ayant au moins une adresse mail valide |
11182 |
|
* |
11183 |
|
* @param evenement instance de l'événement associée à l'instruction |
11184 |
|
* @param dossier instance du dossier de l'instruction |
11185 |
|
* @return boolean indique si le traitement à réussi |
11186 |
|
*/ |
11187 |
|
protected function traitement_notification_automatique_tiers_consulte($evenement, $dossier) { |
11188 |
|
// Récupération de l'identifiant plat'au du service consultant |
11189 |
|
$consultationEntrante = $dossier->get_inst_consultation_entrante(); |
11190 |
|
// Récupération de la liste des types d'habilitations autorisées pour |
11191 |
|
// cette notification |
11192 |
|
$typesHabilitationsNotifiable = $evenement->get_types_habilitation_notifiable(); |
11193 |
|
// Récupération du département et de la commune du dossier |
11194 |
|
$commune = $dossier->getVal('commune'); |
11195 |
|
// Le département est récupéré à partir de la commune du dossier donc si la |
11196 |
|
// commune n'a pas pu être récupéré on ne récupère pas non plus le département. |
11197 |
|
$idDepartement = null; |
11198 |
|
if (! empty($commune)) { |
11199 |
|
$departement = $dossier->get_inst_departement_dossier(); |
11200 |
|
$idDepartement = $departement->getVal($departement->clePrimaire); |
11201 |
|
} |
11202 |
|
// Récupération des courriels des tiers notifiables |
11203 |
|
$tiersANotifier = $this->get_courriels_tiers_notifiable( |
11204 |
|
$typesHabilitationsNotifiable, |
11205 |
|
$consultationEntrante->getVal('service_consultant_id'), |
11206 |
|
$commune, |
11207 |
|
$idDepartement |
11208 |
|
); |
11209 |
|
// Traitement de chacune des listes de diffusion pour extraire les |
11210 |
|
// courriels, vérifier la validité des courriels et envoyer la |
11211 |
|
// notification |
11212 |
|
$notificationSend = false; |
11213 |
|
if (empty($tiersANotifier)) { |
11214 |
|
$this->addToLog( |
11215 |
|
sprintf( |
11216 |
|
'%s() : %s %s : %s', |
11217 |
|
__METHOD__, |
11218 |
|
__("La récupération des tiers à échoué."), |
11219 |
|
__('Paramétrage'), |
11220 |
|
var_export( |
11221 |
|
array( |
11222 |
|
'types_habilitations_notifiable' => $typesHabilitationsNotifiable, |
11223 |
|
'service_consultant' => $consultationEntrante->getVal('service_consultant_id'), |
11224 |
|
'id_commune' => $commune, |
11225 |
|
'id_departement' => $idDepartement |
11226 |
|
), |
11227 |
|
true |
11228 |
|
) |
11229 |
|
), |
11230 |
|
DEBUG_MODE |
11231 |
|
); |
11232 |
|
return false; |
11233 |
|
} |
11234 |
|
foreach($tiersANotifier as $tierANotifier) { |
11235 |
|
// Découpe la liste de diffusion pour stocker les adresses mails |
11236 |
|
// des tiers dans un tableau |
11237 |
|
$courriels = |
11238 |
|
array_filter( |
11239 |
|
array_map( |
11240 |
|
'trim', |
11241 |
|
preg_split("/\r\n|\n|\r/", $tierANotifier['liste_diffusion']))); |
11242 |
|
|
11243 |
|
foreach ($courriels as $courriel) { |
11244 |
|
// Pour chaque adresse mail vérifie si l'adresse est valide |
11245 |
|
if (! $this->f->checkValidEmailAddress($courriel)) { |
11246 |
|
continue; |
11247 |
|
} |
11248 |
|
$destinataire = array( |
11249 |
|
'destinataire' => $tierANotifier['libelle'].' : '.$courriel, |
11250 |
|
'courriel' => $courriel |
11251 |
|
); |
11252 |
|
// Si l'adresse est valide ajoute une nouvelle notification |
11253 |
|
// et une tâche d'envoi de mails |
11254 |
|
$idNotif = $this->ajouter_notification( |
11255 |
|
$this->getVal($this->clePrimaire), |
11256 |
|
$this->f->get_connected_user_login_name(), |
11257 |
|
$destinataire, |
11258 |
|
$this->get_dossier_instruction_om_collectivite(), |
11259 |
|
array(), |
11260 |
|
true |
11261 |
|
); |
11262 |
|
if ($idNotif === false) { |
11263 |
|
$this->addToLog( |
11264 |
|
__METHOD__. |
11265 |
|
__("L'ajout de la notification a échoué."), |
11266 |
|
DEBUG_MODE |
11267 |
|
); |
11268 |
|
return false; |
11269 |
|
} |
11270 |
|
// Création de la tache en lui donnant l'id de la notification |
11271 |
|
$notification_by_task = $this->notification_by_task( |
11272 |
|
$idNotif, |
11273 |
|
$dossier->getVal('dossier'), |
11274 |
|
'mail', |
11275 |
|
'notification_tiers_consulte' |
11276 |
|
); |
11277 |
|
if ($notification_by_task === false) { |
11278 |
|
$this->addToLog( |
11279 |
|
__METHOD__. |
11280 |
|
__("L'ajout de la tâche de notification a échoué."), |
11281 |
|
DEBUG_MODE |
11282 |
|
); |
11283 |
|
$this->addToMessage( |
11284 |
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
11285 |
|
); |
11286 |
|
return false; |
11287 |
|
} |
11288 |
|
$notificationSend = true; |
11289 |
|
} |
11290 |
|
} |
11291 |
|
// Si aucune notification n'a été envoyé car il n'y a pas de courriels |
11292 |
|
// valide, affiche un message dans les logs pour avoir un suivi. |
11293 |
|
if (! $notificationSend) { |
11294 |
|
$this->addToLog( |
11295 |
|
sprintf( |
11296 |
|
'%s %s : %s %s : %s', |
11297 |
|
__METHOD__, |
11298 |
|
__("Il n'y a pas de tiers notifiable pour l'instruction"), |
11299 |
|
$evenement->getVal('libelle'), |
11300 |
|
__("du dossier"), |
11301 |
|
$this->getVal('dossier') |
11302 |
|
), |
11303 |
|
DEBUG_MODE |
11304 |
|
); |
11305 |
|
} |
11306 |
|
return true; |
11307 |
|
} |
11308 |
|
|
11309 |
|
/** |
11310 |
|
* Récupère, à l'aide d'une requête, la liste de diffusion des tiers |
11311 |
|
* respectant les conditions suvantes : |
11312 |
|
* - le tiers consulté dois accepté les notifications |
11313 |
|
* - la liste de diffusion ne dois pas être vide |
11314 |
|
* - l'uid du tiers consulté ne dois pas être celui passé en paramètre |
11315 |
|
* si pas d'uid passé en paramètre alors on ne filtre pas selon l'uid |
11316 |
|
* du tiers |
11317 |
|
* - le type d'habilitation des tiers dois appartenir à la liste |
11318 |
|
* fournie en paramètre |
11319 |
|
* - le tiers dois être associé à la commune ou au département passé |
11320 |
|
* en paramètre |
11321 |
|
* |
11322 |
|
* @param array $typesHabilitations tableau contenant la liste des types d'habilitation |
11323 |
|
* pouvant être notifiée |
11324 |
|
* @param integer $idPlautau uid de l'acteur plat'au du dossier qui ne dois pas être notifié |
11325 |
|
* @param integer $commune identifiant de la commune du dossier |
11326 |
|
* @param integer $departement identifiant du département du dossier |
11327 |
|
* |
11328 |
|
* @return array listes de diffusion des tiers notifiable |
11329 |
|
*/ |
11330 |
|
protected function get_courriels_tiers_notifiable(array $typesHabilitations, $idPlatau, $commune, $departement) { |
11331 |
|
// Si paramètre non renseigné alors ne renvoie rien |
11332 |
|
if (empty($typesHabilitations) || empty($commune) || empty($departement)) { |
11333 |
|
return false; |
11334 |
|
} |
11335 |
|
// Si il n'y a pas d'acteur associé au dossier alors on ne filtre pas sur l'uid de l'acteur |
11336 |
|
$filtreServiceConsulteDI = ''; |
11337 |
|
if (! empty($idPlatau)) { |
11338 |
|
$filtreServiceConsulteDI = sprintf( |
11339 |
|
"-- Filtre les tiers ayant une ligne correspondante a l uid platau du service |
11340 |
|
-- en charge du dossier |
11341 |
|
AND (tiers_consulte.uid_platau_acteur !~ ('\y' || '%s' || '\y') |
11342 |
|
OR tiers_consulte.uid_platau_acteur IS NULL)", |
11343 |
|
$this->f->db->escapeSimple($idPlatau) |
11344 |
|
); |
11345 |
|
} |
11346 |
|
$rst = $this->f->get_all_results_from_db_query( |
11347 |
|
sprintf( |
11348 |
|
'SELECT |
11349 |
|
-- Tiers notifiables lié à la commune du dossier |
11350 |
|
tiers_consulte.liste_diffusion, |
11351 |
|
tiers_consulte.libelle |
11352 |
|
FROM |
11353 |
|
%1$shabilitation_tiers_consulte |
11354 |
|
LEFT JOIN %1$stiers_consulte |
11355 |
|
ON habilitation_tiers_consulte.tiers_consulte = tiers_consulte.tiers_consulte |
11356 |
|
LEFT JOIN %1$slien_habilitation_tiers_consulte_commune |
11357 |
|
ON habilitation_tiers_consulte.habilitation_tiers_consulte = lien_habilitation_tiers_consulte_commune.habilitation_tiers_consulte |
11358 |
|
-- Conservation uniquement des tiers acteur de dossiers |
11359 |
|
JOIN %1$slien_dossier_tiers |
11360 |
|
ON tiers_consulte.tiers_consulte = lien_dossier_tiers.tiers |
11361 |
|
WHERE |
11362 |
|
tiers_consulte.accepte_notification_email IS TRUE |
11363 |
|
AND tiers_consulte.liste_diffusion IS NOT NULL |
11364 |
|
%3$s |
11365 |
|
AND habilitation_tiers_consulte.type_habilitation_tiers_consulte IN (%2$s) |
11366 |
|
AND lien_habilitation_tiers_consulte_commune.commune = %4$d |
11367 |
|
-- Filtre sur les tiers acteur du dossier |
11368 |
|
AND lien_dossier_tiers.dossier = \'%6$s\' |
11369 |
|
UNION |
11370 |
|
SELECT |
11371 |
|
-- Tiers notifiables lié au département du dossier |
11372 |
|
tiers_consulte.liste_diffusion, |
11373 |
|
tiers_consulte.libelle |
11374 |
|
FROM |
11375 |
|
%1$shabilitation_tiers_consulte |
11376 |
|
LEFT JOIN %1$stiers_consulte |
11377 |
|
ON habilitation_tiers_consulte.tiers_consulte = tiers_consulte.tiers_consulte |
11378 |
|
LEFT JOIN %1$slien_habilitation_tiers_consulte_departement |
11379 |
|
ON habilitation_tiers_consulte.habilitation_tiers_consulte = lien_habilitation_tiers_consulte_departement.habilitation_tiers_consulte |
11380 |
|
-- Conservation uniquement des tiers acteur de dossiers |
11381 |
|
JOIN %1$slien_dossier_tiers |
11382 |
|
ON tiers_consulte.tiers_consulte = lien_dossier_tiers.tiers |
11383 |
|
WHERE |
11384 |
|
tiers_consulte.accepte_notification_email IS TRUE |
11385 |
|
AND tiers_consulte.liste_diffusion IS NOT NULL |
11386 |
|
%3$s |
11387 |
|
AND habilitation_tiers_consulte.type_habilitation_tiers_consulte IN (%2$s) |
11388 |
|
AND lien_habilitation_tiers_consulte_departement.departement = %5$d |
11389 |
|
-- Filtre sur les tiers acteur du dossier |
11390 |
|
AND lien_dossier_tiers.dossier = \'%6$s\'', |
11391 |
|
DB_PREFIXE, |
11392 |
|
implode(', ', $typesHabilitations), |
11393 |
|
$filtreServiceConsulteDI, |
11394 |
|
intval($commune), |
11395 |
|
intval($departement), |
11396 |
|
$this->f->db->escapeSimple($this->getVal('dossier')) |
11397 |
|
), |
11398 |
|
array( |
11399 |
|
"origin" => __METHOD__ |
11400 |
|
) |
11401 |
|
); |
11402 |
|
// Faire un order by sur un union ne fonctionne pas. A la place |
11403 |
|
// c'est le tableau des résultats qui est ordonné. |
11404 |
|
usort($rst['result'], function($a, $b) { |
11405 |
|
return strcmp($a['libelle'], $b['libelle']); |
11406 |
|
}); |
11407 |
|
return $rst['result']; |
11408 |
|
} |
11409 |
|
|
11410 |
|
/** |
11411 |
|
* Gestion spécifique de l'affichage des documents dans le tableau des |
11412 |
|
* documents d'instruction. |
11413 |
|
* Prend en compte qu'une instruction peut également avoir un document lié |
11414 |
|
* dans la table storage. |
11415 |
|
* |
11416 |
|
* @return void |
11417 |
|
*/ |
11418 |
|
public function view_telecharger_editions() { |
11419 |
|
// Récupère l'identifiant du document dans l'URL appelant l'action |
11420 |
|
$idx = $this->f->get_submitted_get_value('idx'); |
11421 |
|
$obj = $this->table; |
11422 |
|
$champ = 'om_fichier_instruction'; |
11423 |
|
// Cas d'un document historisé (dans la table storage) |
11424 |
|
if (strpos($idx, 'STORAGE_') !== false) { |
11425 |
|
$idx = substr($idx, 8); |
11426 |
|
$obj = 'storage'; |
11427 |
|
$champ = 'uid'; |
11428 |
|
} |
11429 |
|
// Ouvre le document |
11430 |
|
$lien = '../app/index.php?module=form&snippet=file&obj='.$obj.'&champ='.$champ.'&id='.$idx; |
11431 |
|
header("Location: ".$lien); |
11432 |
|
} |
11433 |
|
} |