1 |
<?php |
<?php |
2 |
/** |
/** |
3 |
|
* DBFORM - 'instruction' - Surcharge gen. |
4 |
|
* |
5 |
* specific : |
* specific : |
6 |
* - cle secondaire |
* - cle secondaire |
7 |
* destruction autorisée que pour le dernier evenement |
* destruction autorisée que pour le dernier evenement |
14 |
* - function mois_date : pour ajouter des mois a une date |
* - function mois_date : pour ajouter des mois a une date |
15 |
* [add months (delay) and calculation final date] |
* [add months (delay) and calculation final date] |
16 |
* - voir script_lang.js : bible ... |
* - voir script_lang.js : bible ... |
17 |
* |
* |
18 |
* @package openfoncier |
* @package openfoncier |
19 |
* @version SVN : $Id$ |
* @version SVN : $Id$ |
20 |
*/ |
*/ |
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 |
function __construct($id, &$db, $debug) { |
/** |
103 |
$this->constructeur($id, $db, $debug); |
* 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 |
// {{{ Gestion de la confidentialité des données spécifiques |
// {{{ Gestion de la confidentialité des données spécifiques |
111 |
|
|
128 |
"is_editable", |
"is_editable", |
129 |
"is_finalizable_without_bypass", |
"is_finalizable_without_bypass", |
130 |
"can_user_access_dossier_contexte_modification", |
"can_user_access_dossier_contexte_modification", |
131 |
|
"is_evenement_modifiable", |
132 |
); |
); |
133 |
$this->class_actions[1]["portlet"]["libelle"] = _("Modifier"); |
$this->class_actions[1]["portlet"]["libelle"] = _("Modifier"); |
134 |
|
|
137 |
$this->class_actions[2]["condition"] = array( |
$this->class_actions[2]["condition"] = array( |
138 |
"is_deletable", |
"is_deletable", |
139 |
"is_finalizable_without_bypass", |
"is_finalizable_without_bypass", |
140 |
"can_user_access_dossier_contexte_modification" |
"can_user_access_dossier_contexte_modification", |
141 |
|
"is_evenement_supprimable", |
142 |
); |
); |
143 |
$this->class_actions[2]["portlet"]["libelle"] = _("Supprimer"); |
$this->class_actions[2]["portlet"]["libelle"] = _("Supprimer"); |
144 |
|
|
186 |
"is_unfinalizable", |
"is_unfinalizable", |
187 |
"is_unfinalizable_without_bypass", |
"is_unfinalizable_without_bypass", |
188 |
"can_user_access_dossier_contexte_modification", |
"can_user_access_dossier_contexte_modification", |
189 |
|
"is_not_sent_for_signature", |
190 |
|
), |
191 |
|
); |
192 |
|
|
193 |
|
// ACTION - 115 - Modification d'un document généré par une instruction |
194 |
|
// Permet à un instructeur de modifier un document généré par une instruction |
195 |
|
$this->class_actions[115] = array( |
196 |
|
"identifier" => "modale_selection_document_signe", |
197 |
|
"portlet" => array( |
198 |
|
"type" => "action-self", |
199 |
|
"libelle" => _("Remplacer par le document signé"), |
200 |
|
"order" => 115, |
201 |
|
"class" => "selection-document-signé", |
202 |
|
), |
203 |
|
"view" => "view_modale_selection_document_signe", |
204 |
|
"permission_suffix" => "selection_document_signe", |
205 |
|
"condition" => array( |
206 |
|
"is_finalized", |
207 |
|
"is_not_date_retour_signature_set", |
208 |
), |
), |
209 |
); |
); |
210 |
|
|
278 |
"permission_suffix" => "consulter", |
"permission_suffix" => "consulter", |
279 |
); |
); |
280 |
|
|
281 |
|
// ACTION - 175 - edit_by_notification_task |
282 |
|
// Action à utiliser lors de la mise à jour des instructions par notification |
283 |
|
$this->class_actions[175] = array( |
284 |
|
"identifier" => "edit_by_notification_task", |
285 |
|
"view" => "formulaire", |
286 |
|
"permission_suffix" => "modifier", |
287 |
|
"crud" => "update", |
288 |
|
); |
289 |
|
|
290 |
// ACTION - 180 - pdf_lettre_rar |
// ACTION - 180 - pdf_lettre_rar |
291 |
// Génère PDF sur bordereaux de lettres RAR |
// Génère PDF sur bordereaux de lettres AR |
292 |
$this->class_actions[180] = array( |
$this->class_actions[180] = array( |
293 |
"identifier" => "pdf_lettre_rar", |
"identifier" => "pdf_lettre_rar", |
294 |
"view" => "view_pdf_lettre_rar", |
"view" => "view_pdf_lettre_rar", |
335 |
"view" => "view_generate_suivi_bordereaux", |
"view" => "view_generate_suivi_bordereaux", |
336 |
"permission_suffix" => "consulter", |
"permission_suffix" => "consulter", |
337 |
); |
); |
338 |
|
|
339 |
|
// ACTION - 777 - pdf_temp |
340 |
|
// Crée un PDF temporaire et affiche son contenu en base64 |
341 |
|
$this->class_actions[777] = array( |
342 |
|
"identifier" => "pdf_temp", |
343 |
|
"view" => "view_pdf_temp", |
344 |
|
"permission_suffix" => "modifier", |
345 |
|
"condition" => array("can_user_access_dossier_contexte_modification"), |
346 |
|
); |
347 |
|
|
348 |
|
// ACTION - 701 |
349 |
|
$this->class_actions[701] = array( |
350 |
|
"identifier" => "enable-edition-integrale", |
351 |
|
"portlet" => array( |
352 |
|
"type" => "action-direct-with-confirmation", |
353 |
|
"libelle" => _("Rédaction libre"), |
354 |
|
"order" => 50, |
355 |
|
"class" => "redac-libre-16", |
356 |
|
), |
357 |
|
"view" => "formulaire", |
358 |
|
"method" => "enable_edition_integrale", |
359 |
|
"permission_suffix" => "modifier", |
360 |
|
"condition" => array( |
361 |
|
"is_editable", |
362 |
|
"is_finalizable_without_bypass", |
363 |
|
"can_user_access_dossier_contexte_modification", |
364 |
|
"is_edition_integrale_not_enabled", |
365 |
|
"is_option_redaction_libre_enabled", |
366 |
|
"has_an_edition", |
367 |
|
), |
368 |
|
); |
369 |
|
// ACTION - 702 |
370 |
|
$this->class_actions[702] = array( |
371 |
|
"identifier" => "disable-edition-integrale", |
372 |
|
"portlet" => array( |
373 |
|
"type" => "action-direct-with-confirmation", |
374 |
|
"libelle" => _("Rédaction par compléments"), |
375 |
|
"order" => 50, |
376 |
|
"class" => "redac-complement-16", |
377 |
|
), |
378 |
|
"view" => "formulaire", |
379 |
|
"method" => "disable_edition_integrale", |
380 |
|
"permission_suffix" => "modifier", |
381 |
|
"condition" => array( |
382 |
|
"is_editable", |
383 |
|
"is_finalizable_without_bypass", |
384 |
|
"can_user_access_dossier_contexte_modification", |
385 |
|
"is_edition_integrale_enabled", |
386 |
|
"is_option_redaction_libre_enabled", |
387 |
|
"has_an_edition", |
388 |
|
), |
389 |
|
); |
390 |
|
// ACTION - 300 - evenement_has_an_edition_json |
391 |
|
// |
392 |
|
$this->class_actions[300] = array( |
393 |
|
"identifier" => "evenement_has_an_edition_json", |
394 |
|
"view" => "view_evenement_has_an_edition_json", |
395 |
|
"permission_suffix" => "consulter", |
396 |
|
); |
397 |
|
|
398 |
|
// ACTION - 301 - evenement_has_a_commentaire |
399 |
|
// |
400 |
|
$this->class_actions[301] = array( |
401 |
|
"identifier" => "evenement_has_a_commentaire_json", |
402 |
|
"view" => "view_evenement_has_a_commentaire_json", |
403 |
|
"permission_suffix" => "consulter", |
404 |
|
); |
405 |
|
|
406 |
|
// ACTION - 400 - Envoyer en signature |
407 |
|
// Cet évenement permet d'envoyer le document au parapheur pour signature |
408 |
|
$this->class_actions[400] = array( |
409 |
|
"identifier" => "envoyer_a_signature", |
410 |
|
"portlet" => array( |
411 |
|
"libelle" => _("Envoyer à signature"), |
412 |
|
"type" => "action-direct-with-confirmation", |
413 |
|
"class" => "envoyer_a_signature-16", |
414 |
|
), |
415 |
|
"view" => "formulaire", |
416 |
|
"method" => "envoyer_a_signature_sans_relecture", |
417 |
|
"condition" => array( |
418 |
|
"can_be_signed", |
419 |
|
), |
420 |
|
"permission_suffix" => "envoyer_a_signature", |
421 |
|
); |
422 |
|
|
423 |
|
// ACTION - 402 - Envoyer en signature avec relecture |
424 |
|
// Cet évenement permet d'envoyer le document au parapheur pour signature |
425 |
|
$this->class_actions[402] = array( |
426 |
|
"identifier" => "envoyer_a_signature_relecture", |
427 |
|
"portlet" => array( |
428 |
|
"libelle" => __("Envoyer à signature avec relecture"), |
429 |
|
"type" => "action-direct-with-confirmation", |
430 |
|
"class" => "envoyer_a_signature-16", |
431 |
|
), |
432 |
|
"view" => "formulaire", |
433 |
|
"method" => "envoyer_a_signature_avec_relecture", |
434 |
|
"condition" => array( |
435 |
|
"can_be_signed", |
436 |
|
"is_parapheur_relecture_parameter_enabled" |
437 |
|
), |
438 |
|
"permission_suffix" => "envoyer_a_signature", |
439 |
|
); |
440 |
|
|
441 |
|
// ACTION - 404 - Annuler l'envoi en signature |
442 |
|
// Cet évenement permet d'annuler l'envoi en signature du document au parapheur |
443 |
|
$this->class_actions[404] = array( |
444 |
|
"identifier" => "annuler_envoi_signature", |
445 |
|
"portlet" => array( |
446 |
|
"libelle" => __("Annuler l'envoi en signature"), |
447 |
|
"type" => "action-direct-with-confirmation", |
448 |
|
"class" => "annuler_envoi_signature-16", |
449 |
|
), |
450 |
|
"view" => "formulaire", |
451 |
|
"method" => "annuler_envoi_en_signature", |
452 |
|
"condition" => array( |
453 |
|
"is_sent_for_signature", |
454 |
|
"is_parapheur_annulation_parameter_enabled" |
455 |
|
), |
456 |
|
"permission_suffix" => "envoyer_a_signature", |
457 |
|
); |
458 |
|
|
459 |
|
// |
460 |
|
$this->class_actions[401] = array( |
461 |
|
"identifier" => "preview_edition", |
462 |
|
"view" => "formulaire", |
463 |
|
"permission_suffix" => "tab", |
464 |
|
); |
465 |
|
|
466 |
|
// ACTION - 410 - Notifier les pétitionnaires (mail ou autre) |
467 |
|
$this->class_actions[410] = array( |
468 |
|
"identifier" => "overlay_notification_manuelle", |
469 |
|
"portlet" => array( |
470 |
|
"libelle" => __("Notifier les pétitionnaires"), |
471 |
|
"type" => "action-self", |
472 |
|
"class" => "notifier_commune-16", |
473 |
|
), |
474 |
|
"condition" => array( |
475 |
|
"is_notifiable_by_task_manual", |
476 |
|
"is_not_portail_notification_sans_annexe" |
477 |
|
), |
478 |
|
"view" => "view_overlay_notification_manuelle", |
479 |
|
"permission_suffix" => "modifier", |
480 |
|
); |
481 |
|
|
482 |
|
// ACTION - 411 - Notifier les pétitionnaires (portail citoyen) |
483 |
|
$this->class_actions[411] = array( |
484 |
|
"identifier" => "notification_manuelle_portal", |
485 |
|
"portlet" => array( |
486 |
|
"libelle" => __("Notifier les pétitionnaires"), |
487 |
|
"type" => "action-direct-with-confirmation", |
488 |
|
"class" => "notifier_commune-16", |
489 |
|
), |
490 |
|
"condition" => array( |
491 |
|
"is_notifiable_by_task_manual", |
492 |
|
"is_portail_notification_sans_annexe" |
493 |
|
), |
494 |
|
"method" => "notifier_demandeur_principal", |
495 |
|
"permission_suffix" => "modifier", |
496 |
|
); |
497 |
|
|
498 |
|
// ACTION - 420 - Notifier les services consultés (mail) |
499 |
|
$this->class_actions[420] = array( |
500 |
|
"identifier" => "overlay_notification_service_consulte", |
501 |
|
"portlet" => array( |
502 |
|
"libelle" => __("Notifier les services consultés"), |
503 |
|
"type" => "action-self", |
504 |
|
"class" => "notifier_commune-16", |
505 |
|
), |
506 |
|
"condition" => array( |
507 |
|
"is_service_notifiable" |
508 |
|
), |
509 |
|
"view" => "view_overlay_notification_service_consulte", |
510 |
|
"permission_suffix" => "tab", |
511 |
|
); |
512 |
|
|
513 |
|
// ACTION - 430 - Notifier les tiers consultés (mail) |
514 |
|
$this->class_actions[430] = array( |
515 |
|
"identifier" => "overlay_notification_tiers_consulte", |
516 |
|
"portlet" => array( |
517 |
|
"libelle" => __("Notifier les tiers consultés"), |
518 |
|
"type" => "action-self", |
519 |
|
"class" => "notifier_commune-16", |
520 |
|
), |
521 |
|
"condition" => array( |
522 |
|
"is_tiers_notifiable" |
523 |
|
), |
524 |
|
"view" => "view_overlay_notification_tiers_consulte", |
525 |
|
"permission_suffix" => "tab", |
526 |
|
); |
527 |
|
|
528 |
|
// |
529 |
|
$this->class_actions[403] = array( |
530 |
|
"identifier" => "envoyer_au_controle_de_legalite", |
531 |
|
"portlet" => array( |
532 |
|
"libelle" => __("Envoyer au contrôle de légalité"), |
533 |
|
"type" => "action-direct-with-confirmation", |
534 |
|
"class" => "envoyer_au_controle_de_legalite-16", |
535 |
|
), |
536 |
|
"view" => "formulaire", |
537 |
|
"method" => "envoyer_au_controle_de_legalite", |
538 |
|
"condition" => array( |
539 |
|
"can_be_sended_to_cl" |
540 |
|
), |
541 |
|
"permission_suffix" => "envoyer_au_controle_de_legalite", |
542 |
|
); |
543 |
|
|
544 |
|
// |
545 |
|
$this->class_actions[998] = array( |
546 |
|
"identifier" => "json_data", |
547 |
|
"view" => "view_json_data", |
548 |
|
"permission_suffix" => "consulter", |
549 |
|
); |
550 |
|
} |
551 |
|
|
552 |
|
/** |
553 |
|
* Clause select pour la requête de sélection des données de l'enregistrement. |
554 |
|
* |
555 |
|
* @return array |
556 |
|
*/ |
557 |
|
function get_var_sql_forminc__champs() { |
558 |
|
return array( |
559 |
|
"instruction", |
560 |
|
"destinataire", |
561 |
|
"instruction.evenement", |
562 |
|
"instruction.commentaire", |
563 |
|
"date_evenement", |
564 |
|
"instruction.lettretype", |
565 |
|
"signataire_arrete", |
566 |
|
"flag_edition_integrale", |
567 |
|
"om_final_instruction_utilisateur", |
568 |
|
"date_finalisation_courrier", |
569 |
|
"date_envoi_signature", |
570 |
|
"date_envoi_rar", |
571 |
|
"date_envoi_controle_legalite", |
572 |
|
|
573 |
|
"date_retour_signature", |
574 |
|
"date_retour_rar", |
575 |
|
"date_retour_controle_legalite", |
576 |
|
|
577 |
|
"numero_arrete", |
578 |
|
|
579 |
|
"complement_om_html", |
580 |
|
"'' as bible_auto", |
581 |
|
"'' as bible", |
582 |
|
"complement2_om_html", |
583 |
|
"'' as bible2", |
584 |
|
"complement3_om_html", |
585 |
|
"'' as bible3", |
586 |
|
"complement4_om_html", |
587 |
|
"'' as bible4", |
588 |
|
|
589 |
|
"titre_om_htmletat", |
590 |
|
"corps_om_htmletatex", |
591 |
|
|
592 |
|
"'' as btn_preview", |
593 |
|
"'' as btn_redaction", |
594 |
|
|
595 |
|
"'' as btn_refresh", |
596 |
|
"'' as live_preview", |
597 |
|
|
598 |
|
"dossier", |
599 |
|
"instruction.action", |
600 |
|
"instruction.delai", |
601 |
|
"instruction.etat", |
602 |
|
"instruction.autorite_competente", |
603 |
|
"instruction.accord_tacite", |
604 |
|
"instruction.delai_notification", |
605 |
|
"instruction.avis_decision", |
606 |
|
"archive_delai", |
607 |
|
"archive_accord_tacite", |
608 |
|
"archive_etat", |
609 |
|
"archive_avis", |
610 |
|
"archive_date_complet", |
611 |
|
"archive_date_rejet", |
612 |
|
"archive_date_limite", |
613 |
|
"archive_date_notification_delai", |
614 |
|
"archive_date_decision", |
615 |
|
"archive_date_validite", |
616 |
|
"archive_date_achevement", |
617 |
|
"archive_date_conformite", |
618 |
|
"archive_date_chantier", |
619 |
|
"archive_date_dernier_depot", |
620 |
|
"date_depot", |
621 |
|
"date_depot_mairie", |
622 |
|
"complement5_om_html", |
623 |
|
"'' as bible5", |
624 |
|
"complement6_om_html", |
625 |
|
"'' as bible6", |
626 |
|
"complement7_om_html", |
627 |
|
"'' as bible7", |
628 |
|
"complement8_om_html", |
629 |
|
"'' as bible8", |
630 |
|
"complement9_om_html", |
631 |
|
"'' as bible9", |
632 |
|
"complement10_om_html", |
633 |
|
"'' as bible10", |
634 |
|
"complement11_om_html", |
635 |
|
"'' as bible11", |
636 |
|
"complement12_om_html", |
637 |
|
"complement13_om_html", |
638 |
|
"complement14_om_html", |
639 |
|
"complement15_om_html", |
640 |
|
"archive_incompletude", |
641 |
|
"archive_incomplet_notifie", |
642 |
|
"archive_evenement_suivant_tacite", |
643 |
|
"archive_evenement_suivant_tacite_incompletude", |
644 |
|
"archive_etat_pendant_incompletude", |
645 |
|
"archive_date_limite_incompletude", |
646 |
|
"archive_delai_incompletude", |
647 |
|
"archive_autorite_competente", |
648 |
|
"code_barres", |
649 |
|
"om_fichier_instruction", |
650 |
|
"om_final_instruction", |
651 |
|
"om_fichier_instruction_dossier_final", |
652 |
|
"document_numerise", |
653 |
|
"duree_validite_parametrage", |
654 |
|
"duree_validite", |
655 |
|
"created_by_commune", |
656 |
|
"archive_date_cloture_instruction", |
657 |
|
"archive_date_premiere_visite", |
658 |
|
"archive_date_derniere_visite", |
659 |
|
"archive_date_contradictoire", |
660 |
|
"archive_date_retour_contradictoire", |
661 |
|
"archive_date_ait", |
662 |
|
"archive_date_transmission_parquet", |
663 |
|
"archive_dossier_instruction_type", |
664 |
|
"archive_date_affichage", |
665 |
|
"pec_metier", |
666 |
|
"archive_pec_metier", |
667 |
|
"archive_a_qualifier", |
668 |
|
"id_parapheur_signature", |
669 |
|
"statut_signature", |
670 |
|
"commentaire_signature", |
671 |
|
"historique_signature", |
672 |
|
"'' as suivi_notification", |
673 |
|
"'' as suivi_notification_service", |
674 |
|
"'' as suivi_notification_tiers", |
675 |
|
"'' as suivi_notification_commune", |
676 |
|
|
677 |
|
"'' as preview_edition", |
678 |
|
"envoye_cl_platau", |
679 |
|
"'' as log_instruction" |
680 |
|
); |
681 |
|
} |
682 |
|
|
683 |
|
/** |
684 |
|
* CONDITION - is_edition_integrale_enabled |
685 |
|
* |
686 |
|
* Vérifie que la rédaction libre est activée sur l'instruction en cours. |
687 |
|
* |
688 |
|
* @return boolean |
689 |
|
*/ |
690 |
|
function is_edition_integrale_enabled() { |
691 |
|
if ($this->getVal("flag_edition_integrale") == 't') { |
692 |
|
return true; |
693 |
|
} |
694 |
|
return false; |
695 |
|
} |
696 |
|
|
697 |
|
/** |
698 |
|
* CONDITION - is_edition_integrale_not_enabled |
699 |
|
* |
700 |
|
* Vérifie que la rédaction libre est désactivée sur l'instruction en cours. |
701 |
|
* |
702 |
|
* @return boolean |
703 |
|
*/ |
704 |
|
function is_edition_integrale_not_enabled() { |
705 |
|
return !$this->is_edition_integrale_enabled(); |
706 |
|
} |
707 |
|
|
708 |
|
/** |
709 |
|
* CONDITION - is_option_redaction_libre_enabled |
710 |
|
* |
711 |
|
* Vérifie que l'option de rédaction libre est activée. |
712 |
|
* |
713 |
|
* @return boolean |
714 |
|
*/ |
715 |
|
function is_option_redaction_libre_enabled() { |
716 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite(); |
717 |
|
return $this->f->is_option_redaction_libre_enabled($collectivite_di); |
718 |
|
} |
719 |
|
|
720 |
|
/** |
721 |
|
* CONDITION - is_option_parapheur_relecture_enabled |
722 |
|
* |
723 |
|
* Vérifie que l'option de relecture lors de l'envoi en signature est activée. |
724 |
|
* |
725 |
|
* @return boolean |
726 |
|
*/ |
727 |
|
function is_parapheur_relecture_parameter_enabled() { |
728 |
|
//Instanciation de la classe electronicsignature |
729 |
|
$inst_es = $this->get_electronicsignature_instance(); |
730 |
|
if ($inst_es === false) { |
731 |
|
return false; |
732 |
|
} |
733 |
|
|
734 |
|
if ($inst_es->get_conf('is_forced_view_files') !== 'true' && $inst_es->get_conf('is_forced_view_files') !== true) { |
735 |
|
return false; |
736 |
|
} |
737 |
|
|
738 |
|
return true; |
739 |
|
} |
740 |
|
|
741 |
|
/** |
742 |
|
* CONDITION - is_parapheur_annulation_parameter_enabled |
743 |
|
* |
744 |
|
* Vérifie que l'option d'annulation de l'envoi en signature est activée. |
745 |
|
* |
746 |
|
* @return boolean |
747 |
|
*/ |
748 |
|
function is_parapheur_annulation_parameter_enabled() { |
749 |
|
//Instanciation de la classe electronicsignature |
750 |
|
$inst_es = $this->get_electronicsignature_instance(); |
751 |
|
if ($inst_es === false) { |
752 |
|
return false; |
753 |
|
} |
754 |
|
|
755 |
|
if ($inst_es->get_conf('cancel_send') !== 'true' && $inst_es->get_conf('cancel_send') !== true) { |
756 |
|
return false; |
757 |
|
} |
758 |
|
|
759 |
|
return true; |
760 |
|
} |
761 |
|
|
762 |
|
|
763 |
|
/** |
764 |
|
* CONDITION - is_sent_for_signature |
765 |
|
* |
766 |
|
* Vérifie que l'instruction a été envoyé à signature |
767 |
|
* |
768 |
|
* @return boolean |
769 |
|
*/ |
770 |
|
function is_sent_for_signature() { |
771 |
|
// Si un parapheur a été configuré |
772 |
|
// et que le champ id_parapheur_signature n'est pas vide |
773 |
|
// que le status est différent de "canceled" ou "expired" |
774 |
|
// alors l'évènement a été envoyé en signature |
775 |
|
if ($this->has_connector_electronicsignature() === true |
776 |
|
&& empty($this->getVal("id_parapheur_signature")) === false |
777 |
|
&& ($this->getVal("statut_signature") != "canceled" |
778 |
|
&& $this->getVal("statut_signature") != "expired" |
779 |
|
&& $this->getVal("statut_signature") != "finished")) { |
780 |
|
// |
781 |
|
return true; |
782 |
|
} |
783 |
|
|
784 |
|
return false; |
785 |
|
} |
786 |
|
|
787 |
|
/** |
788 |
|
* CONDITION - is_not_sent_for_signature |
789 |
|
* |
790 |
|
* Vérifie que l'instruction n'a pas été envoyé à signature |
791 |
|
* |
792 |
|
* @return boolean |
793 |
|
*/ |
794 |
|
function is_not_sent_for_signature() { |
795 |
|
// Contrôle si l'utilisateur possède un bypass |
796 |
|
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_definaliser_bypass"); |
797 |
|
if ($bypass == true) { |
798 |
|
return true; |
799 |
|
} |
800 |
|
|
801 |
|
return !$this->is_sent_for_signature(); |
802 |
|
} |
803 |
|
|
804 |
|
|
805 |
|
/** |
806 |
|
* CONDITION - is_signed |
807 |
|
* |
808 |
|
* Vérifie que l'instruction a été signé |
809 |
|
* |
810 |
|
* @return boolean |
811 |
|
*/ |
812 |
|
function is_signed() { |
813 |
|
// Si un parapheur a été configuré |
814 |
|
// et que le champ id_parapheur_signature n'est pas vide |
815 |
|
// et que le statut est égal à "finished" |
816 |
|
// alors le document de l'instruciton à été signé |
817 |
|
if ($this->has_connector_electronicsignature() === true |
818 |
|
&& empty($this->getVal("id_parapheur_signature")) === false |
819 |
|
&& $this->getVal("statut_signature") == "finished") { |
820 |
|
// |
821 |
|
return true; |
822 |
|
} |
823 |
|
|
824 |
|
return false; |
825 |
|
} |
826 |
|
|
827 |
|
|
828 |
|
/** |
829 |
|
* is_sent_to_cl |
830 |
|
* |
831 |
|
* Vérifie que l'instruction a été envoyé au contrôle de légalité |
832 |
|
* |
833 |
|
* @return boolean |
834 |
|
*/ |
835 |
|
function is_sent_to_cl() { |
836 |
|
// Si la case à cocher de l'instruction envoye_cl_platau est à "t" |
837 |
|
if ($this->getVal('envoye_cl_platau') === 't') { |
838 |
|
// |
839 |
|
return true; |
840 |
|
} |
841 |
|
// |
842 |
|
return false; |
843 |
|
} |
844 |
|
|
845 |
|
/** |
846 |
|
* CONDITION - is_portail_notification |
847 |
|
* |
848 |
|
* Vérifie si la notification est une notification de catégorie portail |
849 |
|
* |
850 |
|
* @return boolean |
851 |
|
*/ |
852 |
|
function is_portail_notification_sans_annexe() { |
853 |
|
$collectiviteDi = $this->get_dossier_instruction_om_collectivite(); |
854 |
|
$ev = $this->get_inst_evenement($this->getVal('evenement')); |
855 |
|
if (($this->f->get_param_option_notification($collectiviteDi) === null || |
856 |
|
$this->f->get_param_option_notification($collectiviteDi) === PORTAL) |
857 |
|
&& $ev->getVal('notification') != 'notification_manuelle_annexe' |
858 |
|
&& $ev->getVal('notification') != 'notification_manuelle_annexe_signature_requise' |
859 |
|
) { |
860 |
|
return true; |
861 |
|
} |
862 |
|
return false; |
863 |
|
} |
864 |
|
|
865 |
|
/** |
866 |
|
* CONDITION - is_not_portail_notification |
867 |
|
* |
868 |
|
* Vérifie si la notification n'est pas une notification de catégorie portail |
869 |
|
* |
870 |
|
* @return boolean |
871 |
|
*/ |
872 |
|
function is_not_portail_notification_sans_annexe() { |
873 |
|
return (! $this->is_portail_notification_sans_annexe()); |
874 |
|
} |
875 |
|
|
876 |
|
/** |
877 |
|
* CONDITION - can_be_signed |
878 |
|
* |
879 |
|
* Vérifie que le document de l'instruction peut être envoyé au parapheur pour signature |
880 |
|
* |
881 |
|
* @return boolean |
882 |
|
*/ |
883 |
|
function can_be_signed() { |
884 |
|
// Instanciation de l'objet signataire_arrete |
885 |
|
$inst_signataire_arrete = $this->f->get_inst__om_dbform(array( |
886 |
|
"obj" => "signataire_arrete", |
887 |
|
"idx" => $this->getVal("signataire_arrete"), |
888 |
|
)); |
889 |
|
// Si un parapheur a été configuré, que le document est finalisé, que le signataire |
890 |
|
// possède une adresse email, on vérifie le champ id_parapheur_signature |
891 |
|
// S'il est vide l'évènement peut être envoyé en signature |
892 |
|
// S'il ne l'est pas, alors on vérifie le champ statut_signature |
893 |
|
// Si la valeur de ce champ est égal à "canceled" ou "expired" |
894 |
|
// alors l'évènement peut être envoyé en signature |
895 |
|
if ($this->has_connector_electronicsignature() === true |
896 |
|
&& $this->getVal("om_final_instruction") == 't' |
897 |
|
&& empty($inst_signataire_arrete->getVal('email')) === false) { |
898 |
|
// |
899 |
|
if (empty($this->getVal("id_parapheur_signature")) === true |
900 |
|
|| $this->getVal("statut_signature") == "canceled" |
901 |
|
|| $this->getVal("statut_signature") == "expired") { |
902 |
|
// |
903 |
|
return true; |
904 |
|
} |
905 |
|
} |
906 |
|
|
907 |
|
$this->addToLog(__METHOD__."() has_connector_electronicsignature: ".var_export($this->has_connector_electronicsignature(), true), EXTRA_VERBOSE_MODE); |
908 |
|
$this->addToLog(__METHOD__."() om_final_instruction: ".var_export($this->getVal("om_final_instruction"), true), EXTRA_VERBOSE_MODE); |
909 |
|
$this->addToLog(__METHOD__."() email: ".var_export($inst_signataire_arrete->getVal('email'), true), EXTRA_VERBOSE_MODE); |
910 |
|
$this->addToLog(__METHOD__."() id_parapheur_signature: ".var_export($this->getVal("id_parapheur_signature"), true), EXTRA_VERBOSE_MODE); |
911 |
|
$this->addToLog(__METHOD__."() statut_signature: ".var_export($this->getVal("statut_signature"), true), EXTRA_VERBOSE_MODE); |
912 |
|
|
913 |
|
return false; |
914 |
|
} |
915 |
|
|
916 |
|
/** |
917 |
|
* CONDITION - has_connector_electronicsignature |
918 |
|
* |
919 |
|
* Vérifie qu'un parapheur est paramétré |
920 |
|
* |
921 |
|
* @return boolean |
922 |
|
*/ |
923 |
|
function has_connector_electronicsignature() { |
924 |
|
$inst_es = $this->get_electronicsignature_instance(false); |
925 |
|
if ($inst_es === false) { |
926 |
|
return false; |
927 |
|
} |
928 |
|
return true; |
929 |
|
} |
930 |
|
|
931 |
|
/** |
932 |
|
* CONDITION - can_display_parapheur |
933 |
|
* |
934 |
|
* Vérifie que le fieldset "Suivi Parapheur" soit affichable |
935 |
|
* |
936 |
|
* @return boolean |
937 |
|
*/ |
938 |
|
function can_display_parapheur() { |
939 |
|
$evenement_id = $this->getVal("evenement"); |
940 |
|
$inst_evenement = $this->get_inst_evenement($evenement_id); |
941 |
|
if ($this->has_connector_electronicsignature() === true |
942 |
|
&& $inst_evenement->getVal('lettretype') !== '' |
943 |
|
&& $inst_evenement->getVal('lettretype') !== null |
944 |
|
&& (empty($this->getVal("id_parapheur_signature")) === false |
945 |
|
|| empty($this->getVal("historique_signature")) === false)) { |
946 |
|
// |
947 |
|
return true; |
948 |
|
} |
949 |
|
|
950 |
|
return false; |
951 |
|
} |
952 |
|
|
953 |
|
/** |
954 |
|
* CONDITION - can_display_notification |
955 |
|
* |
956 |
|
* Vérifie que le champs "Suivi notification" est affichable |
957 |
|
* |
958 |
|
* @return boolean |
959 |
|
*/ |
960 |
|
function can_display_notification_demandeur() { |
961 |
|
// Le suivi des notification est affiché si l'événement est notifiable |
962 |
|
// et si des notifications ont été envoyées |
963 |
|
$evenement_id = $this->getVal("evenement"); |
964 |
|
$inst_evenement = $this->get_inst_evenement($evenement_id); |
965 |
|
if ($inst_evenement->getVal('notification') != null && |
966 |
|
$inst_evenement->getVal('notification') != '') { |
967 |
|
// Des notifications ont été envoyé si il existe au moins une notification |
968 |
|
// liées à l'instruction |
969 |
|
$idsNotifs = $this->get_instruction_notification( |
970 |
|
$this->getVal($this->clePrimaire), |
971 |
|
array( |
972 |
|
'notification_recepisse', |
973 |
|
'notification_instruction', |
974 |
|
'notification_decision', |
975 |
|
), |
976 |
|
true |
977 |
|
); |
978 |
|
if (isset($idsNotifs) && $idsNotifs !== array()) { |
979 |
|
return true; |
980 |
|
} |
981 |
|
} |
982 |
|
return false; |
983 |
|
} |
984 |
|
|
985 |
|
/** |
986 |
|
* CONDITION - can_display_notification |
987 |
|
* |
988 |
|
* Vérifie que le champs "suivi_notification_service" est affichable |
989 |
|
* |
990 |
|
* @return boolean |
991 |
|
*/ |
992 |
|
function can_display_notification_service() { |
993 |
|
// Le suivi des notification est affiché si l'événement est notifiable |
994 |
|
// et si des notifications ont été envoyées |
995 |
|
$evenement_id = $this->getVal("evenement"); |
996 |
|
$inst_evenement = $this->get_inst_evenement($evenement_id); |
997 |
|
if ($this->get_boolean_from_pgsql_value($inst_evenement->getVal('notification_service')) == true) { |
998 |
|
// Des notifications ont été envoyé si il existe au moins une notification |
999 |
|
// de type notification_service_consulte liées à l'instruction |
1000 |
|
$idsNotifs = $this->get_instruction_notification( |
1001 |
|
$this->getVal($this->clePrimaire), |
1002 |
|
'notification_service_consulte' |
1003 |
|
); |
1004 |
|
if (isset($idsNotifs) && $idsNotifs !== array()) { |
1005 |
|
return true; |
1006 |
|
} |
1007 |
|
} |
1008 |
|
return false; |
1009 |
|
} |
1010 |
|
|
1011 |
|
|
1012 |
|
/** |
1013 |
|
* CONDITION - can_display_notification_tiers |
1014 |
|
* |
1015 |
|
* Vérifie que le champs "suivi_notification_tiers" est affichable |
1016 |
|
* |
1017 |
|
* @return boolean |
1018 |
|
*/ |
1019 |
|
function can_display_notification_tiers() { |
1020 |
|
// Le suivi des notification est affiché si l'événement est notifiable |
1021 |
|
// et si des notifications ont été envoyées |
1022 |
|
$evenement_id = $this->getVal("evenement"); |
1023 |
|
$inst_evenement = $this->get_inst_evenement($evenement_id); |
1024 |
|
if (! empty($inst_evenement->getVal('notification_tiers'))) { |
1025 |
|
// Des notifications ont été envoyé si il existe au moins une notification |
1026 |
|
// de type notification_tiers_consulte liées à l'instruction |
1027 |
|
$idsNotifs = $this->get_instruction_notification( |
1028 |
|
$this->getVal($this->clePrimaire), |
1029 |
|
'notification_tiers_consulte' |
1030 |
|
); |
1031 |
|
if (isset($idsNotifs) && $idsNotifs !== array()) { |
1032 |
|
return true; |
1033 |
|
} |
1034 |
|
} |
1035 |
|
return false; |
1036 |
|
} |
1037 |
|
|
1038 |
|
/** |
1039 |
|
* CONDITION - can_display_notification_commune |
1040 |
|
* |
1041 |
|
* Vérifie que le champs "suivi_notification_commune" est affichable |
1042 |
|
* |
1043 |
|
* @return boolean |
1044 |
|
*/ |
1045 |
|
function can_display_notification_commune() { |
1046 |
|
// Le suivi des notification si il existe au moins une notification |
1047 |
|
// de type notification_depot_demat liées à l'instruction |
1048 |
|
$idsNotifs = $this->get_instruction_notification( |
1049 |
|
$this->getVal($this->clePrimaire), |
1050 |
|
array('notification_depot_demat', 'notification_commune') |
1051 |
|
); |
1052 |
|
if (isset($idsNotifs) && $idsNotifs !== array()) { |
1053 |
|
return true; |
1054 |
|
} |
1055 |
|
return false; |
1056 |
|
} |
1057 |
|
|
1058 |
|
/** |
1059 |
|
* TREATMENT - disable_edition_integrale. |
1060 |
|
* |
1061 |
|
* Cette methode permet de passer la consultation en "lu" |
1062 |
|
* |
1063 |
|
* @return boolean true si maj effectué false sinon |
1064 |
|
*/ |
1065 |
|
function disable_edition_integrale() { |
1066 |
|
// Cette méthode permet d'exécuter une routine en début des méthodes |
1067 |
|
// dites de TREATMENT. |
1068 |
|
$this->begin_treatment(__METHOD__); |
1069 |
|
$this->correct = true; |
1070 |
|
$valF = array( |
1071 |
|
"flag_edition_integrale" => false, |
1072 |
|
"titre_om_htmletat" => null, |
1073 |
|
"corps_om_htmletatex" => null, |
1074 |
|
); |
1075 |
|
$res = $this->f->db->autoExecute( |
1076 |
|
DB_PREFIXE.$this->table, |
1077 |
|
$valF, |
1078 |
|
DB_AUTOQUERY_UPDATE, |
1079 |
|
$this->clePrimaire."=".$this->getVal($this->clePrimaire) |
1080 |
|
); |
1081 |
|
if ($this->f->isDatabaseError($res, true)) { |
1082 |
|
// Appel de la methode de recuperation des erreurs |
1083 |
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
1084 |
|
$this->correct = false; |
1085 |
|
// Termine le traitement |
1086 |
|
return $this->end_treatment(__METHOD__, false); |
1087 |
|
} else { |
1088 |
|
$this->addToMessage(_("Rédaction par compléments activé.")); |
1089 |
|
return $this->end_treatment(__METHOD__, true); |
1090 |
|
} |
1091 |
|
|
1092 |
|
// Termine le traitement |
1093 |
|
return $this->end_treatment(__METHOD__, false); |
1094 |
} |
} |
1095 |
|
|
1096 |
|
/** |
1097 |
|
* TREATMENT - enable_edition_integrale. |
1098 |
|
* |
1099 |
|
* Cette methode permet de passer la consultation en "lu" |
1100 |
|
* |
1101 |
|
* @return boolean true si maj effectué false sinon |
1102 |
|
*/ |
1103 |
|
function enable_edition_integrale() { |
1104 |
|
// Cette méthode permet d'exécuter une routine en début des méthodes |
1105 |
|
// dites de TREATMENT. |
1106 |
|
$this->begin_treatment(__METHOD__); |
1107 |
|
$this->correct = true; |
1108 |
|
|
1109 |
|
// Récupère la collectivite du dossier d'instruction |
1110 |
|
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
1111 |
|
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
1112 |
|
// |
1113 |
|
$params = array( |
1114 |
|
"specific" => array( |
1115 |
|
"corps" => array( |
1116 |
|
"mode" => "get", |
1117 |
|
) |
1118 |
|
), |
1119 |
|
); |
1120 |
|
$result = $this->compute_pdf_output('lettretype', $this->getVal('lettretype'), $collectivite, null, $params); |
1121 |
|
$corps = $result['pdf_output']; |
1122 |
|
// |
1123 |
|
$params = array( |
1124 |
|
"specific" => array( |
1125 |
|
"titre" => array( |
1126 |
|
"mode" => "get", |
1127 |
|
) |
1128 |
|
), |
1129 |
|
); |
1130 |
|
$result = $this->compute_pdf_output('lettretype', $this->getVal('lettretype'), $collectivite, null, $params); |
1131 |
|
$titre = $result['pdf_output']; |
1132 |
|
// |
1133 |
|
$valF = array( |
1134 |
|
"flag_edition_integrale" => true, |
1135 |
|
"titre_om_htmletat" => $titre, |
1136 |
|
"corps_om_htmletatex" => $corps, |
1137 |
|
); |
1138 |
|
$res = $this->f->db->autoExecute( |
1139 |
|
DB_PREFIXE.$this->table, |
1140 |
|
$valF, |
1141 |
|
DB_AUTOQUERY_UPDATE, |
1142 |
|
$this->clePrimaire."=".$this->getVal($this->clePrimaire) |
1143 |
|
); |
1144 |
|
if ($this->f->isDatabaseError($res, true)) { |
1145 |
|
// Appel de la methode de recuperation des erreurs |
1146 |
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
1147 |
|
$this->correct = false; |
1148 |
|
// Termine le traitement |
1149 |
|
return $this->end_treatment(__METHOD__, false); |
1150 |
|
} else { |
1151 |
|
$this->addToMessage(_("Rédaction libre activé.")); |
1152 |
|
return $this->end_treatment(__METHOD__, true); |
1153 |
|
} |
1154 |
|
|
1155 |
|
// Termine le traitement |
1156 |
|
return $this->end_treatment(__METHOD__, false); |
1157 |
|
} |
1158 |
|
|
1159 |
/** |
/** |
1160 |
* Cette méthode permet de récupérer le dossier d'autorisation d'un dossier |
* Cette méthode permet de récupérer le dossier d'autorisation d'un dossier |
1168 |
$sql = "select dossier_autorisation from ".DB_PREFIXE."dossier "; |
$sql = "select dossier_autorisation from ".DB_PREFIXE."dossier "; |
1169 |
$sql .= " where dossier='".$id."'"; |
$sql .= " where dossier='".$id."'"; |
1170 |
// |
// |
1171 |
$dossier_autorisation = $this->db->getOne($sql); |
$dossier_autorisation = $this->f->db->getone($sql); |
1172 |
$this->addToLog("getNumDemandeAutorFromDossier(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
1173 |
database::isError($dossier_autorisation); |
$this->f->isDatabaseError($dossier_autorisation); |
1174 |
// |
// |
1175 |
return $dossier_autorisation; |
return $dossier_autorisation; |
1176 |
} |
} |
1178 |
// }}} |
// }}} |
1179 |
|
|
1180 |
function setType(&$form, $maj) { |
function setType(&$form, $maj) { |
1181 |
// |
// Récupération du mode de l'action |
1182 |
parent::setType($form, $maj); |
$crud = $this->get_action_crud($maj); |
1183 |
// On cache tous les champs |
// Récupère la collectivité du dossier d'instruction |
1184 |
// XXX |
$collectivite_di = $this->get_dossier_instruction_om_collectivite(); |
|
$form->setType('complement5_om_html', 'hidden'); |
|
|
$form->setType('bible5', 'hidden'); |
|
|
$form->setType('complement6_om_html', 'hidden'); |
|
|
$form->setType('bible6', 'hidden'); |
|
|
$form->setType('complement7_om_html', 'hidden'); |
|
|
$form->setType('bible7', 'hidden'); |
|
|
$form->setType('complement8_om_html', 'hidden'); |
|
|
$form->setType('bible8', 'hidden'); |
|
|
$form->setType('complement9_om_html', 'hidden'); |
|
|
$form->setType('bible9', 'hidden'); |
|
|
$form->setType('complement10_om_html', 'hidden'); |
|
|
$form->setType('bible10', 'hidden'); |
|
|
$form->setType('complement11_om_html', 'hidden'); |
|
|
$form->setType('bible11', 'hidden'); |
|
|
$form->setType('complement12_om_html', 'hidden'); |
|
|
$form->setType('bible12', 'hidden'); |
|
|
$form->setType('complement13_om_html', 'hidden'); |
|
|
$form->setType('bible13', 'hidden'); |
|
|
$form->setType('complement14_om_html', 'hidden'); |
|
|
$form->setType('bible14', 'hidden'); |
|
|
$form->setType('complement15_om_html', 'hidden'); |
|
|
$form->setType('bible15', 'hidden'); |
|
|
// |
|
|
$form->setType('delai', 'hidden'); |
|
|
$form->setType('etat', 'hidden'); |
|
|
$form->setType('accord_tacite', 'hidden'); |
|
|
$form->setType('action', 'hidden'); |
|
|
$form->setType('delai_notification', 'hidden'); |
|
|
$form->setType('avis_decision', 'hidden'); |
|
|
$form->setType('autorite_competente', 'hidden'); |
|
|
// |
|
|
$form->setType('archive_delai', 'hidden'); |
|
|
$form->setType('archive_etat', 'hidden'); |
|
|
$form->setType('archive_accord_tacite', 'hidden'); |
|
|
$form->setType('archive_avis', 'hidden'); |
|
|
$form->setType('archive_date_complet', 'hiddendate'); |
|
|
$form->setType('archive_date_dernier_depot', 'hiddendate'); |
|
|
$form->setType('archive_date_rejet', 'hiddendate'); |
|
|
$form->setType('archive_date_limite', 'hiddendate'); |
|
|
$form->setType('archive_date_notification_delai', 'hiddendate'); |
|
|
$form->setType('archive_date_decision', 'hiddendate'); |
|
|
$form->setType('archive_date_validite', 'hiddendate'); |
|
|
$form->setType('archive_date_achevement', 'hiddendate'); |
|
|
$form->setType('archive_date_conformite', 'hiddendate'); |
|
|
$form->setType('archive_date_chantier', 'hiddendate'); |
|
|
$form->setType('archive_autorite_competente','hidden'); |
|
|
$form->setType('date_depot','hidden'); |
|
|
// |
|
|
$form->setType('numero_arrete', 'hidden'); |
|
|
// |
|
|
$form->setType('code_barres', 'hidden'); |
|
|
|
|
|
// |
|
|
$form->setType('archive_incompletude','hidden'); |
|
|
$form->setType('archive_incomplet_notifie','hidden'); |
|
|
$form->setType('archive_evenement_suivant_tacite','hidden'); |
|
|
$form->setType('archive_evenement_suivant_tacite_incompletude','hidden'); |
|
|
$form->setType('archive_etat_pendant_incompletude','hidden'); |
|
|
$form->setType('archive_date_limite_incompletude','hiddendate'); |
|
|
$form->setType('archive_delai_incompletude','hidden'); |
|
1185 |
|
|
1186 |
// |
// Cache tous les champs |
1187 |
$form->setType('archive_date_cloture_instruction','hidden'); |
foreach ($this->champs as $value) { |
1188 |
$form->setType('archive_date_premiere_visite','hidden'); |
$form->setType($value, 'hidden'); |
1189 |
$form->setType('archive_date_derniere_visite','hidden'); |
} |
|
$form->setType('archive_date_contradictoire','hidden'); |
|
|
$form->setType('archive_date_retour_contradictoire','hidden'); |
|
|
$form->setType('archive_date_ait','hiddendate'); |
|
|
$form->setType('archive_date_transmission_parquet','hidden'); |
|
1190 |
|
|
1191 |
// |
// Les champs historique_signature et statut_signature ne sont pas saisissable dans tous les cas |
1192 |
$form->setType('duree_validite','hidden'); |
if ($this->can_display_parapheur() === true && $maj == 3) { |
1193 |
$form->setType('duree_validite_parametrage','hidden'); |
$form->setType('statut_signature', 'selectstatic'); |
1194 |
|
$form->setType('historique_signature', 'jsontotab'); |
1195 |
|
if ($this->getVal('commentaire_signature') == null) { |
1196 |
|
$form->setType('commentaire_signature', 'hidden'); |
1197 |
|
} else { |
1198 |
|
$form->setType('commentaire_signature', 'hiddenstatic'); |
1199 |
|
} |
1200 |
|
} |
1201 |
|
|
1202 |
// |
// Le champ de suivi des notifications des demandeurs n'est pas affichable dans tous les cas |
1203 |
$form->setType('created_by_commune','hidden'); |
if ($maj == 3 && $this->can_display_notification_demandeur() === true) { |
1204 |
// |
$form->setType('suivi_notification', 'jsontotab'); |
|
// gestion du champ "finalisé par" |
|
|
if ($this->getVal("om_final_instruction") == 't') { |
|
|
$form->setType('om_final_instruction_utilisateur', 'static'); |
|
|
} else { |
|
|
$form->setType('om_final_instruction_utilisateur', 'hidden'); |
|
1205 |
} |
} |
1206 |
// |
// Le champ de suivi des notifications des services n'est pas affichable dans tous les cas |
1207 |
if ($maj < 2 || $maj == 125) { //ajouter, modifier et suivi des dates |
if ($maj == 3 && $this->can_display_notification_service() === true) { |
1208 |
$form->setType('destinataire', 'hidden'); |
$form->setType('suivi_notification_service', 'jsontotab'); |
1209 |
$form->setType('lettretype', 'hiddenstatic'); |
} |
1210 |
$form->setType('complement_om_html', 'html'); |
// Le champ de suivi des notifications des tiers n'est pas affichable dans tous les cas |
1211 |
$form->setType('complement2_om_html', 'html'); |
if ($maj == 3 && $this->can_display_notification_tiers() === true) { |
1212 |
$form->setType('complement3_om_html', 'html'); |
$form->setType('suivi_notification_tiers', 'jsontotab'); |
1213 |
$form->setType('complement4_om_html', 'html'); |
} |
1214 |
$form->setType('bible_auto', 'httpclick'); |
// Le champ de suivi des notifications des communes n'est pas affichable dans tous les cas |
1215 |
$form->setType('bible', 'httpclick'); |
if ($maj == 3 && $this->can_display_notification_commune() === true) { |
1216 |
$form->setType('bible2', 'httpclick'); |
$form->setType('suivi_notification_commune', 'jsontotab'); |
1217 |
$form->setType('bible3', 'httpclick'); |
} |
1218 |
$form->setType('bible4', 'httpclick'); |
|
1219 |
$form->setType('dossier', 'hidden'); |
// MODE AJOUTER |
1220 |
$form->setType('libelle', 'hiddenstatic'); |
if ($this->getParameter('maj') == 0) { |
1221 |
$form->setType('signataire_arrete','select'); |
$form->setType('commentaire', 'textareahidden'); |
1222 |
$form->setType('date_envoi_signature','datedisabled'); |
// Si l'option est active passage du champ date en lecture seule |
1223 |
$form->setType('date_retour_signature','datedisabled'); |
if ($this->f->is_option_date_evenement_instruction_lecture_seule($collectivite_di) === true) { |
1224 |
$form->setType('date_envoi_rar','datedisabled'); |
$form->setType("date_evenement", "hiddenstaticdate"); |
1225 |
$form->setType('date_retour_rar','datedisabled'); |
} else { |
1226 |
$form->setType('date_envoi_controle_legalite','datedisabled'); |
$form->setType("date_evenement", "date"); |
1227 |
$form->setType('date_retour_controle_legalite','datedisabled'); |
} |
1228 |
$form->setType('date_finalisation_courrier','datedisabled'); |
if ($this->is_in_context_of_foreign_key("evenement", $this->getParameter("retourformulaire"))) { |
1229 |
|
$form->setType("evenement", "selecthiddenstatic"); |
1230 |
if($maj==0){ // ajouter |
} else { |
1231 |
$form->setType('instruction', 'hidden'); |
$form->setType("evenement", "select"); |
1232 |
$form->setType('lettretype', 'hidden'); |
} |
1233 |
$form->setType('evenement', 'select'); |
if ($this->is_in_context_of_foreign_key("signataire_arrete", $this->getParameter("retourformulaire"))) { |
1234 |
$form->setType('date_evenement', 'date2'); |
$form->setType("signataire_arrete", "selecthiddenstatic"); |
1235 |
}else{ // modifier et suivi des dates |
} else { |
1236 |
$form->setType('instruction', 'hiddenstatic'); |
$form->setType("signataire_arrete", "select"); |
1237 |
$form->setType('evenement', 'selecthiddenstatic'); |
} |
1238 |
//$form->setType('date_evenement', 'hiddenstaticdate'); |
if ($this->is_option_redaction_libre_enabled() === true) { |
1239 |
$form->setType('date_evenement', 'date2'); |
$form->setType("flag_edition_integrale", "select"); |
1240 |
|
} |
1241 |
|
} |
1242 |
|
|
1243 |
|
// MODE MODIFIER |
1244 |
|
if ($this->getParameter('maj') == 1) { |
1245 |
|
// Si l'option est active passage du champ date en lecture seule |
1246 |
|
if ($this->f->is_option_date_evenement_instruction_lecture_seule($collectivite_di) === true) { |
1247 |
|
$form->setType("date_evenement", "hiddenstaticdate"); |
1248 |
|
} else { |
1249 |
|
$form->setType("date_evenement", "date"); |
1250 |
|
} |
1251 |
|
$form->setType("evenement", "selecthiddenstatic"); |
1252 |
|
if ($this->has_an_edition() === true) { |
1253 |
|
$form->setType('lettretype', 'hiddenstatic'); |
1254 |
|
if ($this->is_in_context_of_foreign_key("signataire_arrete", $this->getParameter("retourformulaire"))) { |
1255 |
|
$form->setType("signataire_arrete", "selecthiddenstatic"); |
1256 |
|
} else { |
1257 |
|
$form->setType("signataire_arrete", "select"); |
1258 |
|
} |
1259 |
|
if ($this->getVal("flag_edition_integrale") == "t") { |
1260 |
|
$form->setType("titre_om_htmletat", "htmlEtat"); |
1261 |
|
$form->setType("corps_om_htmletatex", "htmlEtatEx"); |
1262 |
|
} else { |
1263 |
|
$form->setType("complement_om_html", "html"); |
1264 |
|
$form->setType("complement2_om_html", "html"); |
1265 |
|
$form->setType("complement3_om_html", "html"); |
1266 |
|
$form->setType("complement4_om_html", "html"); |
1267 |
|
$form->setType('bible_auto', 'httpclick'); |
1268 |
|
$form->setType('bible', 'httpclick'); |
1269 |
|
$form->setType('bible2', 'httpclick'); |
1270 |
|
$form->setType('bible3', 'httpclick'); |
1271 |
|
$form->setType('bible4', 'httpclick'); |
1272 |
|
} |
1273 |
|
if ($this->f->is_option_preview_pdf_enabled($collectivite_di) === true) { |
1274 |
|
// |
1275 |
|
$form->setType('btn_refresh', 'httpclickbutton'); |
1276 |
|
$form->setType('btn_preview', 'httpclickbutton'); |
1277 |
|
$form->setType('btn_redaction', 'httpclickbutton'); |
1278 |
|
// /!\ le type du champs est utilisé dans un selecteur dans le jscript.js |
1279 |
|
// pour identifiant le champ de prévisualisation et régler sa taille à |
1280 |
|
// l'affichage du champ. En cas de modification, le selecteur doit également |
1281 |
|
// être mis à jour |
1282 |
|
$form->setType('live_preview', 'previsualiser_pdf'); |
1283 |
|
} |
1284 |
|
|
1285 |
// necessaire pour calcul de date en modification |
// necessaire pour calcul de date en modification |
1286 |
//$form->setType('delai', 'hiddenstatic'); |
//$form->setType('delai', 'hiddenstatic'); |
1287 |
// les administrateurs technique et fonctionnel peuvent |
// les administrateurs technique et fonctionnel peuvent |
1288 |
// modifier tous les champs de date |
// modifier tous les champs de date |
1289 |
// si l'instruction a déjà été finalisée au moins une fois |
// si l'instruction a déjà été finalisée au moins une fois |
1290 |
if (($this->f->isAccredited(array(get_class($this), get_class($this)."modification_dates"), "OR") |
if (($this->f->isAccredited(array($this->get_absolute_class_name(), $this->get_absolute_class_name()."modification_dates"), "OR") |
1291 |
|| $this->f->isAccredited(array('instruction', 'instruction_modification_dates'), "OR")) |
|| $this->f->isAccredited(array('instruction', 'instruction_modification_dates'), "OR")) |
1292 |
&& $this->getVal("date_finalisation_courrier") != '') { |
&& $this->getVal("date_finalisation_courrier") != '') { |
1293 |
|
// |
1294 |
$form->setType('date_envoi_signature', 'date'); |
$form->setType('date_envoi_signature', 'date'); |
1295 |
$form->setType('date_retour_signature', 'date'); |
$form->setType('date_retour_signature', 'date'); |
1296 |
|
if ($this->is_sent_for_signature() === true |
1297 |
|
&& $this->is_signed() === true) { |
1298 |
|
// |
1299 |
|
$form->setType("date_envoi_signature", "datereadonly"); |
1300 |
|
$form->setType("date_retour_signature", "datereadonly"); |
1301 |
|
} |
1302 |
$form->setType('date_envoi_rar', 'date'); |
$form->setType('date_envoi_rar', 'date'); |
1303 |
$form->setType('date_retour_rar', 'date'); |
$form->setType('date_retour_rar', 'date'); |
1304 |
$form->setType('date_envoi_controle_legalite', 'date'); |
$form->setType('date_envoi_controle_legalite', 'date'); |
1305 |
|
if ($this->is_sent_to_cl() === true) { |
1306 |
|
$form->setType("date_envoi_controle_legalite", "datedisabled"); |
1307 |
|
} |
1308 |
$form->setType('date_retour_controle_legalite', 'date'); |
$form->setType('date_retour_controle_legalite', 'date'); |
1309 |
$form->setType('date_finalisation_courrier', 'date'); |
$form->setType('date_finalisation_courrier', 'date'); |
|
// suivi des dates |
|
|
if ($maj == 125) { |
|
|
$form->setType('date_evenement', 'hiddenstaticdate'); |
|
|
$form->setType('complement_om_html', 'hiddenstatic'); |
|
|
$form->setType('complement2_om_html', 'hiddenstatic'); |
|
|
$form->setType('complement3_om_html', 'hiddenstatic'); |
|
|
$form->setType('complement4_om_html', 'hiddenstatic'); |
|
|
$form->setType('bible_auto', 'hidden'); |
|
|
$form->setType('bible', 'hidden'); |
|
|
$form->setType('bible2', 'hidden'); |
|
|
$form->setType('bible3', 'hidden'); |
|
|
$form->setType('bible4', 'hidden'); |
|
|
$form->setType('signataire_arrete','selecthiddenstatic'); |
|
|
$form->setType('om_final_instruction_utilisateur', 'hiddenstatic'); |
|
|
} |
|
1310 |
} |
} |
1311 |
} |
} |
|
} elseif($maj==2){ |
|
|
$form->setType('dossier', 'hidden'); |
|
|
$form->setType('bible_auto', 'hidden'); |
|
|
$form->setType('bible', 'hidden'); |
|
|
$form->setType('bible2', 'hidden'); |
|
|
$form->setType('bible3', 'hidden'); |
|
|
$form->setType('bible4', 'hidden'); |
|
|
}else { |
|
|
$form->setType('destinataire', 'hidden'); |
|
|
$form->setType('dossier', 'hidden'); |
|
|
$form->setType('bible_auto', 'hidden'); |
|
|
$form->setType('bible', 'hidden'); |
|
|
$form->setType('bible2', 'hidden'); |
|
|
$form->setType('bible3', 'hidden'); |
|
|
$form->setType('bible4', 'hidden'); |
|
|
} |
|
|
|
|
|
//Cache les champs pour la finalisation |
|
|
$form->setType('om_fichier_instruction', 'hidden'); |
|
|
$form->setType('om_final_instruction', 'hidden'); |
|
|
// Cache le document arrêté |
|
|
$form->setType('document_numerise', 'hidden'); |
|
|
|
|
|
//Masquer les champs date_envoi_controle_legalite et |
|
|
//date_retour_controle_legalite si ce n'est pas un arrêté et si ce n'est |
|
|
//pas un utilisateur ayant le droit spécifique |
|
|
if ( !is_numeric($this->getVal("avis_decision"))&& |
|
|
!$this->f->isAccredited(array("instruction", "instruction_modification_dates"), "OR")){ |
|
|
|
|
|
$form->setType("date_envoi_controle_legalite", "hiddendate"); |
|
|
$form->setType("date_retour_controle_legalite", "hiddendate"); |
|
1312 |
} |
} |
1313 |
|
|
1314 |
// Pour les actions finalize, unfinalize et notifier_commune |
// MODE CONSULTER + SUPPRIMER + SUIVI DES DATES 125 + NOTIFICATION MANUELLE |
1315 |
if($maj == 100 || $maj == 110 || $maj == 210) { |
if ($this->getParameter('maj') == 3 |
1316 |
// |
|| $this->getParameter('maj') == 2 |
1317 |
foreach ($this->champs as $value) { |
|| $this->getParameter('maj') == 125 |
1318 |
// Cache tous les champs |
|| $this->getParameter('maj') == 410) { |
1319 |
$form->setType($value, 'hidden'); |
// |
1320 |
|
$form->setType("date_evenement", "datestatic"); |
1321 |
|
$form->setType("evenement", "selecthiddenstatic"); |
1322 |
|
if ($this->has_an_edition() === true) { |
1323 |
|
$form->setType('lettretype', 'hiddenstatic'); |
1324 |
|
$form->setType("signataire_arrete", "selecthiddenstatic"); |
1325 |
|
if ($this->getVal("om_final_instruction") == 't') { |
1326 |
|
$form->setType('om_final_instruction_utilisateur', 'textareastatic'); |
1327 |
|
} else { |
1328 |
|
$form->setType('om_final_instruction_utilisateur', 'hidden'); |
1329 |
|
} |
1330 |
|
} |
1331 |
|
if ($this->evenement_has_a_commentaire($this->getVal('evenement')) === true ) { |
1332 |
|
$form->setType('commentaire', 'textareastatic'); |
1333 |
|
} |
1334 |
|
} |
1335 |
|
|
1336 |
|
// MODE CONSULTER + SUPPRIMER + NOTIFICATION MANUELLE |
1337 |
|
if ($this->getParameter('maj') == 3 |
1338 |
|
|| $this->getParameter('maj') == 2 |
1339 |
|
|| $this->getParameter('maj') == 410) { |
1340 |
|
// Si il n'y a pas de lettre type (edition) associé à l'événement |
1341 |
|
// les dates de suivi ne sont pas affichée |
1342 |
|
if ($this->has_an_edition() === true) { |
1343 |
|
$form->setType('date_envoi_signature', 'datestatic'); |
1344 |
|
$form->setType('date_retour_signature', 'datestatic'); |
1345 |
|
$form->setType('date_envoi_rar', 'datestatic'); |
1346 |
|
$form->setType('date_retour_rar', 'datestatic'); |
1347 |
|
$form->setType('date_envoi_controle_legalite', 'datestatic'); |
1348 |
|
$form->setType('date_retour_controle_legalite', 'datestatic'); |
1349 |
|
$form->setType('date_finalisation_courrier', 'datestatic'); |
1350 |
|
if ($this->getVal("flag_edition_integrale") == "t") { |
1351 |
|
$form->setType("titre_om_htmletat", "htmlstatic"); |
1352 |
|
$form->setType("corps_om_htmletatex", "htmlstatic"); |
1353 |
|
} else { |
1354 |
|
$form->setType("complement_om_html", "htmlstatic"); |
1355 |
|
$form->setType("complement2_om_html", "htmlstatic"); |
1356 |
|
$form->setType("complement3_om_html", "htmlstatic"); |
1357 |
|
$form->setType("complement4_om_html", "htmlstatic"); |
1358 |
|
} |
1359 |
|
} |
1360 |
|
} |
1361 |
|
|
1362 |
|
// MODE SUIVI DES DATES 125 |
1363 |
|
if ($this->getParameter('maj') == 125) { |
1364 |
|
$form->setType("date_evenement", "hiddenstaticdate"); |
1365 |
|
$form->setType('om_final_instruction_utilisateur', 'hiddenstatic'); |
1366 |
|
$form->setType('date_envoi_signature', 'date'); |
1367 |
|
$form->setType('date_retour_signature', 'date'); |
1368 |
|
if ($this->is_sent_for_signature() === true |
1369 |
|
|| $this->is_signed() === true) { |
1370 |
|
// |
1371 |
|
$form->setType("date_envoi_signature", "datereadonly"); |
1372 |
|
$form->setType("date_retour_signature", "datereadonly"); |
1373 |
|
} |
1374 |
|
$form->setType('date_envoi_rar', 'date'); |
1375 |
|
$form->setType('date_retour_rar', 'date'); |
1376 |
|
$form->setType('date_envoi_controle_legalite', 'date'); |
1377 |
|
if ($this->is_sent_to_cl() === true) { |
1378 |
|
$form->setType("date_envoi_controle_legalite", "datedisabled"); |
1379 |
|
} |
1380 |
|
$form->setType('date_retour_controle_legalite', 'date'); |
1381 |
|
$form->setType('date_finalisation_courrier', 'date'); |
1382 |
|
} |
1383 |
|
|
1384 |
|
if ($maj == 401) { |
1385 |
|
foreach ($this->champs as $champ) { |
1386 |
|
$form->setType($champ, 'hidden'); |
1387 |
|
} |
1388 |
|
$form->setType('preview_edition', 'previsualiser'); |
1389 |
|
} |
1390 |
|
|
1391 |
|
// Si l'instruction a été envoyé au contrôle de légalité et que la |
1392 |
|
// tâche envoi_cl lié n'a pas encore été traité il faut indiquer à |
1393 |
|
// l'utilisateur que l'envoi au cl est en cours de traitement. |
1394 |
|
if ($this->is_sent_to_cl() === true |
1395 |
|
&& empty($this->getVal('date_envoi_controle_legalite')) |
1396 |
|
&& $maj == 3) { |
1397 |
|
$form->setType("date_envoi_controle_legalite", "hiddenstatic"); |
1398 |
|
} |
1399 |
|
} |
1400 |
|
|
1401 |
|
function setOnchange(&$form,$maj){ |
1402 |
|
parent::setOnchange($form,$maj); |
1403 |
|
|
1404 |
|
// MODE AJOUTER |
1405 |
|
if ($this->getParameter('maj') == 0) { |
1406 |
|
$form->setOnchange( |
1407 |
|
"evenement", |
1408 |
|
"manage_instruction_evenement_lettretype(this.value, '".addslashes($this->getParameter('idxformulaire'))."'); |
1409 |
|
manage_instruction_evenement_commentaire(this.value, '".addslashes($this->getParameter('idxformulaire'))."');" |
1410 |
|
); |
1411 |
|
} |
1412 |
|
} |
1413 |
|
|
1414 |
|
function evenement_has_an_edition($evenement_id) { |
1415 |
|
$evenement = $this->get_inst_evenement($evenement_id); |
1416 |
|
$lettretype = $evenement->getVal('lettretype'); |
1417 |
|
if ($lettretype !== '' && $lettretype !== null) { |
1418 |
|
return true; |
1419 |
|
} |
1420 |
|
return false; |
1421 |
|
} |
1422 |
|
|
1423 |
|
function view_evenement_has_an_edition_json() { |
1424 |
|
$json_return = array( |
1425 |
|
"lettretype" => $this->evenement_has_an_edition($this->f->get_submitted_get_value('evenement_id')), |
1426 |
|
"option_redaction_libre_enabled" => $this->is_option_redaction_libre_enabled(), |
1427 |
|
); |
1428 |
|
echo json_encode($json_return); |
1429 |
|
} |
1430 |
|
|
1431 |
|
function evenement_has_a_commentaire($evenement_id) { |
1432 |
|
$evenement = $this->get_inst_evenement($evenement_id); |
1433 |
|
return $this->get_boolean_from_pgsql_value($evenement->getVal('commentaire')); |
1434 |
|
} |
1435 |
|
|
1436 |
|
function view_evenement_has_a_commentaire_json() { |
1437 |
|
$json_return = array( |
1438 |
|
"commentaire" => $this->evenement_has_a_commentaire($this->f->get_submitted_get_value('evenement_id')) |
1439 |
|
); |
1440 |
|
echo json_encode($json_return); |
1441 |
|
} |
1442 |
|
|
1443 |
|
|
1444 |
|
/** |
1445 |
|
* CONDITION - can_be_sended_to_cl |
1446 |
|
* |
1447 |
|
* Vérifie que le contrôle de légalité est disponible |
1448 |
|
* |
1449 |
|
* @return boolean |
1450 |
|
*/ |
1451 |
|
function can_be_sended_to_cl() { |
1452 |
|
// Si l'instruction a une édition |
1453 |
|
// et que l'événement est paramétré pour envoyer le contrôle de légalité |
1454 |
|
// par Plat'AU |
1455 |
|
// et que la date de retour signature est renseignée |
1456 |
|
// et que la date d'envoi au contrôle légalité n'est pas renseignée |
1457 |
|
// et qu'il n'existe pas de task envoi_CL en cours (!= done ou canceled) |
1458 |
|
if ($this->has_an_edition() === true) { |
1459 |
|
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
1460 |
|
$inst_evenement = $this->get_inst_evenement($this->getVal('evenement')); |
1461 |
|
if ($inst_evenement->getVal('envoi_cl_platau') === 't' |
1462 |
|
&& empty($this->getVal('date_retour_signature')) === false |
1463 |
|
&& empty($this->getVal('date_envoi_controle_legalite')) === true |
1464 |
|
&& $this->getVal('envoye_cl_platau') === 'f' |
1465 |
|
&& $this->f->is_type_dossier_platau($inst_di->getVal('dossier_autorisation')) === true |
1466 |
|
&& $inst_di->getVal('etat_transmission_platau') !== 'jamais_transmissible') { |
1467 |
|
// |
1468 |
|
return true; |
1469 |
} |
} |
1470 |
} |
} |
1471 |
|
// |
1472 |
|
return false; |
1473 |
|
} |
1474 |
|
|
1475 |
|
/** |
1476 |
|
* |
1477 |
|
* @return string |
1478 |
|
*/ |
1479 |
|
function get_var_sql_forminc__sql_signataire_arrete() { |
1480 |
|
return sprintf( |
1481 |
|
"SELECT |
1482 |
|
signataire_arrete.signataire_arrete, |
1483 |
|
CONCAT_WS( |
1484 |
|
' - ', |
1485 |
|
CONCAT_WS(' ', signataire_arrete.prenom, signataire_arrete.nom), |
1486 |
|
signataire_habilitation.libelle, |
1487 |
|
signataire_arrete.description |
1488 |
|
) |
1489 |
|
FROM |
1490 |
|
%1\$ssignataire_arrete |
1491 |
|
LEFT JOIN %1\$ssignataire_habilitation |
1492 |
|
ON signataire_arrete.signataire_habilitation = signataire_habilitation.signataire_habilitation |
1493 |
|
WHERE |
1494 |
|
((signataire_arrete.om_validite_debut IS NULL |
1495 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1496 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE)) |
1497 |
|
OR (signataire_arrete.om_validite_debut <= CURRENT_DATE |
1498 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1499 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE))) |
1500 |
|
ORDER BY |
1501 |
|
signataire_arrete.prenom, |
1502 |
|
signataire_arrete.nom", |
1503 |
|
DB_PREFIXE |
1504 |
|
); |
1505 |
|
} |
1506 |
|
|
1507 |
|
/** |
1508 |
|
* |
1509 |
|
* @return string |
1510 |
|
*/ |
1511 |
|
function get_var_sql_forminc__sql_signataire_arrete_by_id() { |
1512 |
|
return sprintf( |
1513 |
|
"SELECT |
1514 |
|
signataire_arrete.signataire_arrete, |
1515 |
|
CONCAT_WS( |
1516 |
|
' - ', |
1517 |
|
CONCAT_WS(' ', signataire_arrete.prenom, signataire_arrete.nom), |
1518 |
|
signataire_habilitation.libelle, |
1519 |
|
signataire_arrete.description |
1520 |
|
) |
1521 |
|
FROM |
1522 |
|
%1\$ssignataire_arrete |
1523 |
|
LEFT JOIN %1\$ssignataire_habilitation |
1524 |
|
ON signataire_arrete.signataire_habilitation = signataire_habilitation.signataire_habilitation |
1525 |
|
WHERE |
1526 |
|
signataire_arrete.signataire_arrete = <idx>", |
1527 |
|
DB_PREFIXE |
1528 |
|
); |
1529 |
} |
} |
1530 |
|
|
1531 |
function setSelect(&$form, $maj,&$db,$debug) { |
/** |
1532 |
|
* |
1533 |
|
* @return string |
1534 |
|
*/ |
1535 |
|
function get_var_sql_forminc__sql_signataire_arrete_by_di() { |
1536 |
|
return sprintf( |
1537 |
|
"SELECT |
1538 |
|
signataire_arrete.signataire_arrete, |
1539 |
|
CONCAT_WS( |
1540 |
|
' - ', |
1541 |
|
CONCAT_WS(' ', signataire_arrete.prenom, signataire_arrete.nom), |
1542 |
|
signataire_habilitation.libelle, |
1543 |
|
signataire_arrete.description |
1544 |
|
) |
1545 |
|
FROM |
1546 |
|
%1\$ssignataire_arrete |
1547 |
|
LEFT JOIN %1\$som_collectivite |
1548 |
|
ON signataire_arrete.om_collectivite = om_collectivite.om_collectivite |
1549 |
|
LEFT JOIN %1\$ssignataire_habilitation |
1550 |
|
ON signataire_arrete.signataire_habilitation = signataire_habilitation.signataire_habilitation |
1551 |
|
WHERE |
1552 |
|
((signataire_arrete.om_validite_debut IS NULL |
1553 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1554 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE)) |
1555 |
|
OR (signataire_arrete.om_validite_debut <= CURRENT_DATE |
1556 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1557 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE))) |
1558 |
|
AND (om_collectivite.niveau = '2' |
1559 |
|
OR signataire_arrete.om_collectivite = <collectivite_di>) |
1560 |
|
ORDER BY |
1561 |
|
signataire_arrete.prenom, signataire_arrete.nom", |
1562 |
|
DB_PREFIXE |
1563 |
|
); |
1564 |
|
} |
1565 |
|
|
1566 |
|
/** |
1567 |
|
* |
1568 |
|
* @return string |
1569 |
|
*/ |
1570 |
|
function get_var_sql_forminc__sql_signataire_arrete_defaut() { |
1571 |
|
return sprintf( |
1572 |
|
"SELECT |
1573 |
|
signataire_arrete.signataire_arrete, |
1574 |
|
CONCAT_WS( |
1575 |
|
' - ', |
1576 |
|
CONCAT_WS(' ', signataire_arrete.prenom, signataire_arrete.nom), |
1577 |
|
signataire_habilitation.libelle, |
1578 |
|
signataire_arrete.description |
1579 |
|
) |
1580 |
|
FROM |
1581 |
|
%1\$ssignataire_arrete |
1582 |
|
LEFT JOIN %1\$ssignataire_habilitation |
1583 |
|
ON signataire_arrete.signataire_habilitation = signataire_habilitation.signataire_habilitation |
1584 |
|
WHERE |
1585 |
|
((signataire_arrete.om_validite_debut IS NULL |
1586 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1587 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE)) |
1588 |
|
OR (signataire_arrete.om_validite_debut <= CURRENT_DATE |
1589 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1590 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE))) |
1591 |
|
AND signataire_arrete.defaut IS TRUE |
1592 |
|
ORDER BY |
1593 |
|
signataire_arrete.prenom, signataire_arrete.nom", |
1594 |
|
DB_PREFIXE |
1595 |
|
); |
1596 |
|
} |
1597 |
|
|
1598 |
|
/** |
1599 |
|
* |
1600 |
|
* @return string |
1601 |
|
*/ |
1602 |
|
function get_var_sql_forminc__sql_signataire_arrete_defaut_by_di() { |
1603 |
|
return sprintf( |
1604 |
|
"SELECT |
1605 |
|
signataire_arrete.signataire_arrete, |
1606 |
|
CONCAT_WS( |
1607 |
|
' - ', |
1608 |
|
CONCAT_WS(' ', signataire_arrete.prenom, signataire_arrete.nom), |
1609 |
|
signataire_habilitation.libelle, |
1610 |
|
signataire_arrete.description |
1611 |
|
) |
1612 |
|
FROM |
1613 |
|
%1\$ssignataire_arrete |
1614 |
|
LEFT JOIN %1\$ssignataire_habilitation |
1615 |
|
ON signataire_arrete.signataire_habilitation = signataire_habilitation.signataire_habilitation |
1616 |
|
LEFT JOIN %1\$som_collectivite |
1617 |
|
ON signataire_arrete.om_collectivite = om_collectivite.om_collectivite |
1618 |
|
WHERE |
1619 |
|
((signataire_arrete.om_validite_debut IS NULL |
1620 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1621 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE)) |
1622 |
|
OR (signataire_arrete.om_validite_debut <= CURRENT_DATE |
1623 |
|
AND (signataire_arrete.om_validite_fin IS NULL |
1624 |
|
OR signataire_arrete.om_validite_fin > CURRENT_DATE))) |
1625 |
|
AND signataire_arrete.defaut IS TRUE |
1626 |
|
AND (om_collectivite.niveau = '2' |
1627 |
|
OR signataire_arrete.om_collectivite = <collectivite_di>) |
1628 |
|
ORDER BY |
1629 |
|
signataire_arrete.prenom, |
1630 |
|
signataire_arrete.nom", |
1631 |
|
DB_PREFIXE |
1632 |
|
); |
1633 |
|
} |
1634 |
|
|
1635 |
|
/** |
1636 |
|
* SETTER_FORM - setSelect. |
1637 |
|
* |
1638 |
|
* @return void |
1639 |
|
*/ |
1640 |
|
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
1641 |
|
//parent::setSelect($form, $maj); |
1642 |
/** |
/** |
1643 |
* 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 |
1644 |
* dossier est mauvaise pour les performances, car la requête qui |
* dossier est mauvaise pour les performances, car la requête qui |
1646 |
* 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 |
1647 |
* select |
* select |
1648 |
*/ |
*/ |
|
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"); |
|
|
|
|
1649 |
//// action |
//// action |
1650 |
//$this->init_select($form, $db, $maj, $debug, "action", |
//$this->init_select($form, $this->f->db, $maj, null, "action", |
1651 |
// $sql_action, $sql_action_by_id, false); |
// $sql_action, $sql_action_by_id, false); |
1652 |
|
|
1653 |
//// avis_decision |
//// avis_decision |
1654 |
//$this->init_select($form, $db, $maj, $debug, "avis_decision", |
//$this->init_select($form, $this->f->db, $maj, null, "avis_decision", |
1655 |
// $sql_avis_decision, $sql_avis_decision_by_id, false); |
// $sql_avis_decision, $sql_avis_decision_by_id, false); |
1656 |
|
|
1657 |
//// dossier |
//// dossier |
1658 |
//$this->init_select($form, $db, $maj, $debug, "dossier", |
//$this->init_select($form, $this->f->db, $maj, null, "dossier", |
1659 |
// $sql_dossier, $sql_dossier_by_id, false); |
// $sql_dossier, $sql_dossier_by_id, false); |
1660 |
|
|
1661 |
//// etat |
//// etat |
1662 |
//$this->init_select($form, $db, $maj, $debug, "etat", |
//$this->init_select($form, $this->f->db, $maj, null, "etat", |
1663 |
// $sql_etat, $sql_etat_by_id, false); |
// $sql_etat, $sql_etat_by_id, false); |
1664 |
|
|
1665 |
//// evenement |
//// evenement |
1666 |
//$this->init_select($form, $db, $maj, $debug, "evenement", |
//$this->init_select($form, $this->f->db, $maj, null, "evenement", |
1667 |
// $sql_evenement, $sql_evenement_by_id, false); |
// $sql_evenement, $sql_evenement_by_id, false); |
1668 |
|
|
1669 |
// signataire_arrete |
// signataire_arrete |
1670 |
// si contexte DI |
// si contexte DI |
1671 |
if ($this->getParameter("retourformulaire") == "dossier" |
if ($this->getParameter("retourformulaire") == "dossier" |
1672 |
|| $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") { |
|
1673 |
// 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 |
1674 |
require_once "../obj/dossier_instruction.class.php"; |
$di = $this->f->get_inst__om_dbform(array( |
1675 |
$di = new dossier_instruction($this->getParameter('idxformulaire'), $db, $debug); |
"obj" => "dossier_instruction", |
1676 |
$sql_signataire_arrete_by_di = str_replace('<collectivite_di>', $di->getVal("om_collectivite"), $sql_signataire_arrete_by_di); |
"idx" => $this->getParameter('idxformulaire'), |
1677 |
$this->init_select($form, $db, $maj, $debug, "signataire_arrete", |
)); |
1678 |
$sql_signataire_arrete_by_di, $sql_signataire_arrete_by_id, true); |
$sql_signataire_arrete_by_di = str_replace( |
1679 |
|
'<collectivite_di>', |
1680 |
|
$di->getVal("om_collectivite"), |
1681 |
|
$this->get_var_sql_forminc__sql("signataire_arrete_by_di") |
1682 |
|
); |
1683 |
|
$this->init_select( |
1684 |
|
$form, |
1685 |
|
$this->f->db, |
1686 |
|
$maj, |
1687 |
|
null, |
1688 |
|
"signataire_arrete", |
1689 |
|
$sql_signataire_arrete_by_di, |
1690 |
|
$this->get_var_sql_forminc__sql("signataire_arrete_by_id"), |
1691 |
|
true |
1692 |
|
); |
1693 |
} else { |
} else { |
1694 |
$this->init_select($form, $db, $maj, $debug, "signataire_arrete", |
$this->init_select( |
1695 |
$sql_signataire_arrete, $sql_signataire_arrete_by_id, true); |
$form, |
1696 |
|
$this->f->db, |
1697 |
|
$maj, |
1698 |
|
null, |
1699 |
|
"signataire_arrete", |
1700 |
|
$this->get_var_sql_forminc__sql("signataire_arrete"), |
1701 |
|
$this->get_var_sql_forminc__sql("signataire_arrete_by_id"), |
1702 |
|
true |
1703 |
|
); |
1704 |
} |
} |
1705 |
|
|
1706 |
/** |
/** |
1725 |
INNER JOIN ".DB_PREFIXE."transition |
INNER JOIN ".DB_PREFIXE."transition |
1726 |
ON evenement.evenement = transition.evenement |
ON evenement.evenement = transition.evenement |
1727 |
AND dossier.etat=transition.etat |
AND dossier.etat=transition.etat |
1728 |
WHERE dossier.dossier='".$this->idxformulaire."' "; |
WHERE dossier.dossier='".$this->getParameter("idxformulaire")."' "; |
1729 |
|
|
1730 |
// Si changement de décision par instructeur commune |
// Si changement de décision par instructeur commune |
1731 |
if($this->f->isUserInstructeur() === true |
if($this->f->isUserInstructeur() === true |
1732 |
&& $this->getDivisionFromDossier($this->idxformulaire) != $_SESSION["division"] |
&& $this->getDivisionFromDossier($this->getParameter("idxformulaire")) != $_SESSION["division"] |
1733 |
&& $this->isInstrCanChangeDecision($this->idxformulaire) === true) { |
&& $this->isInstrCanChangeDecision($this->getParameter("idxformulaire")) === true) { |
1734 |
$sql .= "AND evenement.type IN ('arrete', 'changement_decision') "; |
$sql .= "AND evenement.type IN ('arrete', 'changement_decision') "; |
1735 |
} |
} |
1736 |
$sql .= "ORDER BY evenement.libelle, evenement.action"; |
$sql .= "ORDER BY evenement.libelle, evenement.action"; |
1737 |
$res = $db->query($sql); |
$res = $this->f->db->query($sql); |
1738 |
$this->addToLog("setSelect(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
1739 |
if (database::isError($res)) { |
$this->f->isDatabaseError($res); |
|
die($res->getMessage()); |
|
|
} |
|
1740 |
// Remplissage du tableau du select |
// Remplissage du tableau du select |
1741 |
$contenu = array( |
$contenu = array( |
1742 |
0 => array("",), |
0 => array("",), |
1747 |
$contenu[1][] = $row[1]; |
$contenu[1][] = $row[1]; |
1748 |
} |
} |
1749 |
$form->setSelect("evenement", $contenu); |
$form->setSelect("evenement", $contenu); |
1750 |
|
|
1751 |
} else { |
} else { |
1752 |
$sql = "SELECT |
$sql = "SELECT |
1753 |
evenement.libelle as lib |
evenement.libelle as lib |
1754 |
FROM ".DB_PREFIXE."evenement |
FROM ".DB_PREFIXE."evenement |
1755 |
WHERE evenement.evenement=".$this->getVal("evenement").""; |
WHERE evenement.evenement=".$this->getVal("evenement").""; |
1756 |
$res = $db->getone($sql); |
$res = $this->f->db->getone($sql); |
1757 |
$this->addToLog("setSelect(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
1758 |
if (database::isError($res)) { |
$this->f->isDatabaseError($res); |
|
die($res->getMessage()); |
|
|
} |
|
1759 |
// |
// |
1760 |
$contenu = array( |
$contenu = array( |
1761 |
0 => array($this->getVal("evenement"),), |
0 => array($this->getVal("evenement"),), |
1782 |
// lien bible4 |
// lien bible4 |
1783 |
$contenu = array(_("bible")); |
$contenu = array(_("bible")); |
1784 |
$form->setSelect("bible4",$contenu); |
$form->setSelect("bible4",$contenu); |
1785 |
|
|
1786 |
|
if ($maj == 1) { |
1787 |
|
$base64 = $this->init_pdf_temp(); |
1788 |
|
$form->setSelect('live_preview', array('base64'=>$base64)); |
1789 |
|
$form->setSelect("btn_refresh", array(_('Prévisualiser'))); |
1790 |
|
$form->setSelect("btn_preview", array(_('Prévisualiser >>'))); |
1791 |
|
$form->setSelect("btn_redaction", array(_('<< Rédiger'))); |
1792 |
|
} |
1793 |
|
|
1794 |
|
// Selection du type de rédaction à l'ajout |
1795 |
|
$content = array( |
1796 |
|
0 => array('f', 't', ), |
1797 |
|
1 => array(_('Rédaction par compléments'), _('Rédaction libre'), ), |
1798 |
|
); |
1799 |
|
$form->setSelect('flag_edition_integrale', $content); |
1800 |
|
|
1801 |
|
$contenu = array(); |
1802 |
|
foreach(array('waiting', 'in_progress', 'canceled', 'expired', 'finished') as $value) { |
1803 |
|
$contenu[0][] = $value; |
1804 |
|
$contenu[1][] = $this->get_trad_for_statut($value); |
1805 |
|
} |
1806 |
|
$form->setSelect('statut_signature', $contenu); |
1807 |
|
|
1808 |
|
|
1809 |
|
if ($maj == 401) { |
1810 |
|
$file = $this->f->storage->get($this->getVal('om_fichier_instruction')); |
1811 |
|
$form->setSelect('preview_edition', array( |
1812 |
|
'base64' => base64_encode($file['file_content']), |
1813 |
|
'mimetype' => $file['metadata']['mimetype'], |
1814 |
|
'label' => 'instruction_'.$this->getVal($this->clePrimaire), |
1815 |
|
'href' => sprintf( |
1816 |
|
'../app/index.php?module=form&snippet=file&obj=instruction&champ=om_fichier_instruction&id=%1$s', |
1817 |
|
$this->getVal($this->clePrimaire) |
1818 |
|
) |
1819 |
|
)); |
1820 |
|
} |
1821 |
} |
} |
1822 |
|
|
1823 |
function cleSecondaire($id, &$db, $val, $DEBUG) { |
function cleSecondaire($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
1824 |
// |
// |
1825 |
parent::cleSecondaire($id, $db, $val, $DEBUG); |
// Vérifie uniquementla cle secondaire : demande |
1826 |
|
$this->rechercheTable($this->f->db, "demande", "instruction_recepisse", $id); |
1827 |
|
|
1828 |
$id = $this->getVal($this->clePrimaire); |
$id = $this->getVal($this->clePrimaire); |
1829 |
|
|
1835 |
LEFT JOIN ".DB_PREFIXE."demande |
LEFT JOIN ".DB_PREFIXE."demande |
1836 |
ON demande.demande_type = demande_type.demande_type |
ON demande.demande_type = demande_type.demande_type |
1837 |
WHERE demande.instruction_recepisse = ".$id; |
WHERE demande.instruction_recepisse = ".$id; |
1838 |
$res = $this->db->getOne($sql); |
$res = $this->f->db->getone($sql); |
1839 |
$this->addToLog("cleSecondaire(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
1840 |
if (database::isError($res)) { |
$this->f->isDatabaseError($res); |
|
die($res->getMessage()); |
|
|
} |
|
1841 |
|
|
1842 |
// 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 |
1843 |
//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 |
1849 |
$sql = "SELECT demande |
$sql = "SELECT demande |
1850 |
FROM ".DB_PREFIXE."demande |
FROM ".DB_PREFIXE."demande |
1851 |
WHERE instruction_recepisse = ".$id; |
WHERE instruction_recepisse = ".$id; |
1852 |
$res = $this->db->getOne($sql); |
$res = $this->f->db->getone($sql); |
1853 |
$this->addToLog("cleSecondaire(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
1854 |
if (database::isError($res)) { |
$this->f->isDatabaseError($res); |
|
die($res->getMessage()); |
|
|
} |
|
1855 |
|
|
1856 |
//Si c'est un événement d'instruction lié à une demande |
//Si c'est un événement d'instruction lié à une demande |
1857 |
if ($res != null || $res != ""){ |
if ($res != null || $res != ""){ |
1858 |
|
$demande = $this->f->get_inst__om_dbform(array( |
1859 |
require_once "../obj/demande.class.php"; |
"obj" => "demande", |
1860 |
$demande = new demande($res, $this->db, DEBUG); |
"idx" => $res, |
1861 |
|
)); |
1862 |
|
|
1863 |
//On met à jour la demande en supprimant la liaison vers |
//On met à jour la demande en supprimant la liaison vers |
1864 |
//l'événement d'instruction |
//l'événement d'instruction |
1869 |
} |
} |
1870 |
$valF['date_demande']=$demande->dateDBToForm($valF['date_demande']); |
$valF['date_demande']=$demande->dateDBToForm($valF['date_demande']); |
1871 |
$valF['instruction_recepisse']=NULL; |
$valF['instruction_recepisse']=NULL; |
1872 |
$ret = $demande->modifier($valF, $this->db, DEBUG); |
$ret = $demande->modifier($valF); |
1873 |
} |
} |
1874 |
|
|
1875 |
/** |
/** |
1882 |
// concerne le dossier en cours |
// concerne le dossier en cours |
1883 |
$sql = "SELECT max(instruction) |
$sql = "SELECT max(instruction) |
1884 |
FROM ".DB_PREFIXE."instruction |
FROM ".DB_PREFIXE."instruction |
1885 |
WHERE dossier ='".$this->idxformulaire."'"; |
WHERE dossier ='".$this->getParameter("idxformulaire")."'"; |
1886 |
$dernierevenement = $db->getOne($sql); |
$dernierevenement = $this->f->db->getone($sql); |
1887 |
$this->addToLog("setSelect(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
1888 |
if (database::isError($dernierevenement)) { |
$this->f->isDatabaseError($dernierevenement); |
|
die($dernierevenement->getMessage()); |
|
|
} |
|
1889 |
// Si on se trouve effectivement sur le dernier evenement d'instruction |
// Si on se trouve effectivement sur le dernier evenement d'instruction |
1890 |
if ($dernierevenement == $id) { |
if ($dernierevenement == $id) { |
1891 |
// Alors on valide la suppression |
// Alors on valide la suppression |
1907 |
|
|
1908 |
//Si le retourformulaire est "dossier_instruction" |
//Si le retourformulaire est "dossier_instruction" |
1909 |
if ($this->getParameter("retourformulaire") == "dossier" |
if ($this->getParameter("retourformulaire") == "dossier" |
1910 |
|| $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") { |
|
1911 |
|
|
1912 |
// 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 |
1913 |
if($this->valF[$champ] != "" AND !$this->f->user_is_admin) { |
if($this->valF[$champ] != "" AND !$this->f->user_is_admin) { |
1923 |
return true; |
return true; |
1924 |
} |
} |
1925 |
|
|
1926 |
/*Met des valeurs par défaut dans certains des sous-formulaire*/ |
/** |
1927 |
function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire){ |
* SETTER_FORM - setValsousformulaire (setVal). |
1928 |
|
* |
1929 |
|
* @return void |
1930 |
|
*/ |
1931 |
|
function setValsousformulaire(&$form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire, &$dnu1 = null, $dnu2 = null) { |
1932 |
|
// parent::setValsousformulaire($form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire); |
1933 |
|
// |
1934 |
|
$this->retourformulaire = $retourformulaire; |
1935 |
// |
// |
|
$this->retourformulaire=$retourformulaire; |
|
|
$this->idxformulaire=$idxformulaire; |
|
|
// Ajout |
|
1936 |
if ($maj == 0) { |
if ($maj == 0) { |
1937 |
$form->setVal("destinataire", $idxformulaire); |
$form->setVal("destinataire", $this->getParameter("idxformulaire")); |
1938 |
$form->setVal("dossier", $idxformulaire); |
$form->setVal("dossier", $this->getParameter("idxformulaire")); |
1939 |
|
} |
1940 |
|
|
1941 |
|
// Si l'instruction a été envoyé au contrôle de légalité et que la |
1942 |
|
// tâche envoi_cl lié n'a pas encore été traité il faut indiquer à |
1943 |
|
// l'utilisateur que l'envoi au cl est en cours de traitement. |
1944 |
|
if ($this->is_sent_to_cl() === true |
1945 |
|
&& empty($this->getVal('date_envoi_controle_legalite')) |
1946 |
|
&& $maj == 3) { |
1947 |
|
$form->setVal("date_envoi_controle_legalite", __("En cours de traitement.")); |
1948 |
} |
} |
1949 |
// |
// |
1950 |
$this->set_form_default_values($form, $maj, $validation); |
$this->set_form_default_values($form, $maj, $validation); |
1951 |
} |
} |
1952 |
|
|
1953 |
/** |
/** |
1954 |
* Permet de pré-remplir les valeurs des formulaires. |
* SETTER_FORM - set_form_default_values (setVal). |
1955 |
* |
* |
1956 |
* @param [object] $form formulaire |
* @return void |
|
* @param [integer] $maj mode |
|
|
* @param [integer] $validation validation |
|
1957 |
*/ |
*/ |
1958 |
function set_form_default_values(&$form, $maj, $validation) { |
function set_form_default_values(&$form, $maj, $validation) { |
1959 |
|
// |
|
// Ajout |
|
1960 |
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"); |
|
1961 |
// si contexte DI |
// si contexte DI |
1962 |
if ($this->getParameter("retourformulaire") == "dossier" |
if ($this->getParameter("retourformulaire") == "dossier" |
1963 |
|| $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") { |
|
1964 |
// 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 |
1965 |
require_once "../obj/dossier_instruction.class.php"; |
$di = $this->f->get_inst__om_dbform(array( |
1966 |
$di = new dossier_instruction($this->getParameter('idxformulaire'), $db, DEBUG); |
"obj" => "dossier_instruction", |
1967 |
$sql = str_replace('<collectivite_di>', $di->getVal("om_collectivite"), $sql_signataire_arrete_defaut_by_di); |
"idx" => $this->getParameter("idxformulaire"), |
1968 |
|
)); |
1969 |
|
$sql = str_replace( |
1970 |
|
"<collectivite_di>", |
1971 |
|
$di->getVal("om_collectivite"), |
1972 |
|
$this->get_var_sql_forminc__sql("signataire_arrete_defaut_by_di") |
1973 |
|
); |
1974 |
} else { |
} else { |
1975 |
$sql = $sql_signataire_arrete_defaut; |
$sql = $this->get_var_sql_forminc__sql("signataire_arrete_defaut"); |
1976 |
} |
} |
|
// Date du jour |
|
|
$form->setVal("date_evenement", date('Y-m-d')); |
|
|
|
|
|
// Exécution de la requête |
|
1977 |
$res = $this->f->db->query($sql); |
$res = $this->f->db->query($sql); |
1978 |
$this->f->addToLog("setVal(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__."(): db->query(\"".$sql."\")", VERBOSE_MODE); |
1979 |
if ( database::isError($res)){ |
$this->f->isDatabaseError($res); |
|
die(); |
|
|
} |
|
|
|
|
1980 |
$row = $res->fetchrow(DB_FETCHMODE_ASSOC); |
$row = $res->fetchrow(DB_FETCHMODE_ASSOC); |
1981 |
|
if (isset($row["signataire_arrete"]) |
1982 |
if (isset($row['signataire_arrete']) && is_numeric($row['signataire_arrete'])){ |
&& is_numeric($row["signataire_arrete"])) { |
1983 |
$form->setVal("signataire_arrete",$row['signataire_arrete']); |
// |
1984 |
|
$form->setVal("signataire_arrete", $row["signataire_arrete"]); |
1985 |
} |
} |
1986 |
|
// Date du jour |
1987 |
|
$form->setVal("date_evenement", date("Y-m-d")); |
1988 |
} |
} |
1989 |
|
// |
|
// Ajout et modification |
|
1990 |
if ($maj == 0 || $maj == 1 || $maj == 125) { |
if ($maj == 0 || $maj == 1 || $maj == 125) { |
1991 |
$form->setVal("bible_auto","bible_auto()"); |
$form->setVal("bible_auto", "bible_auto()"); |
1992 |
$form->setVal("bible","bible(1)"); |
$form->setVal("bible", "bible(1)"); |
1993 |
$form->setVal("bible2","bible(2)"); |
$form->setVal("bible2", "bible(2)"); |
1994 |
$form->setVal("bible3","bible(3)"); |
$form->setVal("bible3", "bible(3)"); |
1995 |
$form->setVal("bible4","bible(4)"); |
$form->setVal("bible4", "bible(4)"); |
1996 |
|
} |
1997 |
|
// |
1998 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite(); |
1999 |
|
if ($maj == 1 |
2000 |
|
&& $this->f->is_option_preview_pdf_enabled($collectivite_di) === true |
2001 |
|
&& $this->has_an_edition() === true) { |
2002 |
|
// |
2003 |
|
$form->setVal("live_preview", $this->getVal($this->clePrimaire)); |
2004 |
|
$form->setVal("btn_refresh", "reload_pdf_viewer()"); |
2005 |
|
$form->setVal("btn_preview", "show_instr_preview()"); |
2006 |
|
$form->setVal("btn_redaction", "show_instr_redaction()"); |
2007 |
|
} |
2008 |
|
|
2009 |
|
// Gestion de l'affichage des suivis de notification des demandeurs, des services, des tiers et |
2010 |
|
// des communes |
2011 |
|
if ($maj == 3) { |
2012 |
|
if ($this->can_display_notification_demandeur()) { |
2013 |
|
$typeNotification = array( |
2014 |
|
'notification_recepisse', |
2015 |
|
'notification_instruction', |
2016 |
|
'notification_decision', |
2017 |
|
); |
2018 |
|
$form->setVal("suivi_notification", $this->get_json_suivi_notification($typeNotification, true)); |
2019 |
|
} |
2020 |
|
if ($this->can_display_notification_service()) { |
2021 |
|
$form->setVal("suivi_notification_service", $this->get_json_suivi_notification(array('notification_service_consulte'))); |
2022 |
|
} |
2023 |
|
if ($this->can_display_notification_tiers()) { |
2024 |
|
$form->setVal("suivi_notification_tiers", $this->get_json_suivi_notification(array('notification_tiers_consulte'))); |
2025 |
|
} |
2026 |
|
if ($this->can_display_notification_commune()) { |
2027 |
|
$form->setVal("suivi_notification_commune", $this->get_json_suivi_notification(array('notification_depot_demat', 'notification_commune'))); |
2028 |
|
} |
2029 |
} |
} |
2030 |
} |
} |
2031 |
|
|
|
|
|
2032 |
function setLayout(&$form, $maj){ |
function setLayout(&$form, $maj){ |
2033 |
if ( $maj < 2 OR $maj == 3 OR $maj == 125 ) { |
// En consultation, pour les dossiers qui n'ont pas été transmis par le portail |
2034 |
/*Champ sur lequel s'ouvre le bloc 1 */ |
// citoyen, si la notification des demandeurs est activée sur l'évenement |
2035 |
$form->setBloc('evenement','D',"","col_12"); |
// d'instruction et que le paramétrage du demandeur principal n'est pas |
2036 |
|
// correct alors un message a destination de l'instructeur est affiché. |
2037 |
|
if ($maj == 3) { |
2038 |
|
// Si le dossier n'a pas été déposé sur le portail citoyen (ou si |
2039 |
|
// la requête permettant de savoir le type de demande à échouée) et si |
2040 |
|
// la notification se fait par mail vérifie si il y a des erreurs de |
2041 |
|
// paramétrage et si c'est le cas on affiche un message d'information |
2042 |
|
$collectivite = $this->get_dossier_instruction_om_collectivite($this->getVal('dossier')); |
2043 |
|
$categorieNotif = $this->f->get_param_option_notification($collectivite); |
2044 |
|
if (($this->dossier_depose_sur_portail() == null || |
2045 |
|
! $this->dossier_depose_sur_portail()) && |
2046 |
|
(! empty($categorieNotif) || |
2047 |
|
$categorieNotif == 'mail')) { |
2048 |
|
$erreurParam = $this->get_info_notification_fail(); |
2049 |
|
// Récupération de l'évenement d'instruction |
2050 |
|
$instEV = $this->get_inst_evenement(); |
2051 |
|
if (! empty($instEV->getVal('notification')) && $erreurParam != array()) { |
2052 |
|
$class = 'text-info ui-state-highlight ui-state-info'; |
2053 |
|
$message = __("Attention l'envoi de notification automatique n'est pas possible."); |
2054 |
|
$this->f->display_panel_information( |
2055 |
|
$class, |
2056 |
|
$message, |
2057 |
|
$erreurParam, |
2058 |
|
__('Veuillez corriger les informations suivantes.'), |
2059 |
|
'erreur_param_notif' |
2060 |
|
); |
2061 |
|
} |
2062 |
|
} |
2063 |
|
} |
2064 |
|
$form->setBloc('evenement','D',"","sousform-instruction-action-".$maj); |
2065 |
|
|
2066 |
$form->setFieldset('evenement','D',_('Evenement')); |
$form->setFieldset('evenement','D',_('Evenement')); |
2067 |
$form->setFieldset('om_final_instruction_utilisateur','F',''); |
$form->setFieldset('om_final_instruction_utilisateur','F',''); |
2068 |
|
|
2069 |
$form->setBloc('om_final_instruction_utilisateur','F'); |
$form->setBloc('om_final_instruction_utilisateur','F'); |
2070 |
|
|
2071 |
$form->setBloc('date_finalisation_courrier','D',"","col_12"); |
$form->setBloc('date_finalisation_courrier','D',"",""); |
2072 |
|
|
2073 |
$form->setFieldset('date_finalisation_courrier','D',_('Dates')); |
$form->setFieldset('date_finalisation_courrier','D',_('Dates')); |
2074 |
$form->setBloc('date_finalisation_courrier','D',"","col_6"); |
$form->setBloc('date_finalisation_courrier','D',"","col_6"); |
2075 |
$form->setBloc('date_envoi_controle_legalite','F'); |
$form->setBloc('date_envoi_controle_legalite','F'); |
2076 |
|
|
2077 |
$form->setBloc('signataire_arrete','D',"","col_6"); |
$form->setBloc('date_retour_signature','D',"","col_6"); |
2078 |
$form->setBloc('date_retour_controle_legalite','F'); |
$form->setBloc('date_retour_controle_legalite','F'); |
2079 |
$form->setFieldset('date_retour_controle_legalite','F',''); |
$form->setFieldset('date_retour_controle_legalite','F',''); |
2080 |
|
|
2081 |
$form->setBloc('date_retour_controle_legalite','F'); |
$form->setBloc('date_retour_controle_legalite','F'); |
2082 |
|
|
2083 |
|
$form->setBloc('statut_signature','D'); |
2084 |
|
$form->setFieldset('statut_signature','D','Suivi Parapheur'); |
2085 |
|
$form->setBloc('commentaire_signature','F'); |
2086 |
|
$form->setBloc('historique_signature','D'); |
2087 |
|
$form->setFieldset('historique_signature', 'DF', __("Historique"), "collapsible, startClosed"); |
2088 |
|
$form->setBloc('historique_signature','F'); |
2089 |
|
$form->setFieldset('historique_signature','F'); |
2090 |
|
|
2091 |
|
$form->setFieldset('suivi_notification', 'D', __("Suivi notification"), "collapsible"); |
2092 |
|
$form->setFieldset('suivi_notification','F'); |
2093 |
|
$form->setFieldset('suivi_notification_service', 'D', __("Suivi notification service"), "collapsible"); |
2094 |
|
$form->setFieldset('suivi_notification_service','F'); |
2095 |
|
$form->setFieldset('suivi_notification_tiers', 'D', __("Suivi notification tiers"), "collapsible"); |
2096 |
|
$form->setFieldset('suivi_notification_tiers','F'); |
2097 |
|
$form->setFieldset('suivi_notification_commune', 'D', __("Suivi notification commune"), "collapsible"); |
2098 |
|
$form->setFieldset('suivi_notification_commune','F'); |
2099 |
|
|
2100 |
|
if ($maj == 1) { |
2101 |
|
// Récupère la collectivité du dossier d'instruction |
2102 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite(); |
2103 |
|
|
2104 |
$form->setBloc('complement_om_html','D',"","col_12"); |
// |
2105 |
|
if ($this->f->is_option_preview_pdf_enabled($collectivite_di) === true |
2106 |
|
&& $this->has_an_edition() === true) { |
2107 |
|
// |
2108 |
|
$form->setBloc('complement_om_html','D',"","container_instr_edition"); |
2109 |
|
$form->setBloc('complement_om_html','D',"","hidelabel box_instr_edition redaction_instr_edition"); |
2110 |
|
$form->setBloc('complement_om_html','D',"","box_instr_edition_main"); |
2111 |
|
$form->setFieldset('complement_om_html','D',_('Complement')); |
2112 |
|
$form->setFieldset('bible','F',''); |
2113 |
|
$form->setFieldset('complement2_om_html','D',_('Complement 2')); |
2114 |
|
$form->setFieldset('bible2','F',''); |
2115 |
|
$form->setFieldset('complement3_om_html','D',_('Complement 3')); |
2116 |
|
$form->setFieldset('bible3','F',''); |
2117 |
|
$form->setFieldset('complement4_om_html','D',_('Complement 4')); |
2118 |
|
$form->setFieldset('bible4','F',''); |
2119 |
|
$form->setFieldset('titre_om_htmletat','DF',_('Titre'), 'startClosed'); |
2120 |
|
$form->setFieldset('corps_om_htmletatex','DF',_('Corps')); |
2121 |
|
$form->setBloc('corps_om_htmletatex','F'); |
2122 |
|
$form->setBloc('btn_preview','DF',"","box_instr_edition_btn"); |
2123 |
|
$form->setBloc('btn_preview','F'); |
2124 |
|
$form->setBloc('btn_redaction','D', '',"hidelabel box_instr_edition preview_instr_edition"); |
2125 |
|
$form->setBloc('btn_redaction','DF',"","box_instr_edition_btn"); |
2126 |
|
$form->setFieldset('btn_refresh','D',_('Prévisualisation'), "box_instr_edition_main"); |
2127 |
|
$form->setFieldset('live_preview','F'); |
2128 |
|
$form->setBloc('live_preview','F'); |
2129 |
|
$form->setBloc('live_preview','F'); |
2130 |
|
} else { |
2131 |
|
$form->setBloc('complement_om_html','D',"","hidelabel"); |
2132 |
|
$form->setFieldset('complement_om_html','D',_('Complement')); |
2133 |
|
$form->setFieldset('bible','F',''); |
2134 |
|
$form->setFieldset('complement2_om_html','D',_('Complement 2')); |
2135 |
|
$form->setFieldset('bible2','F',''); |
2136 |
|
$form->setFieldset('complement3_om_html','D',_('Complement 3')); |
2137 |
|
$form->setFieldset('bible3','F',''); |
2138 |
|
$form->setFieldset('complement4_om_html','D',_('Complement 4')); |
2139 |
|
$form->setFieldset('bible4','F',''); |
2140 |
|
$form->setFieldset('titre_om_htmletat','DF',_('Titre'), 'startClosed'); |
2141 |
|
$form->setFieldset('corps_om_htmletatex','DF',_('Corps')); |
2142 |
|
$form->setBloc('corps_om_htmletatex','F'); |
2143 |
|
} |
2144 |
|
} else { |
2145 |
|
$form->setBloc('complement_om_html','D',"","hidelabel"); |
2146 |
$form->setFieldset('complement_om_html','D',_('Complement')); |
$form->setFieldset('complement_om_html','D',_('Complement')); |
2147 |
$form->setFieldset('bible','F',''); |
$form->setFieldset('bible','F',''); |
|
$form->setBloc('bible','F'); |
|
|
|
|
|
$form->setBloc('complement2_om_html','D',"","col_12"); |
|
2148 |
$form->setFieldset('complement2_om_html','D',_('Complement 2')); |
$form->setFieldset('complement2_om_html','D',_('Complement 2')); |
2149 |
$form->setFieldset('bible2','F',''); |
$form->setFieldset('bible2','F',''); |
|
$form->setBloc('bible2','F'); |
|
|
|
|
|
$form->setBloc('complement3_om_html','D',"","col_12"); |
|
2150 |
$form->setFieldset('complement3_om_html','D',_('Complement 3')); |
$form->setFieldset('complement3_om_html','D',_('Complement 3')); |
2151 |
$form->setFieldset('bible3','F',''); |
$form->setFieldset('bible3','F',''); |
|
$form->setBloc('bible3','F'); |
|
|
|
|
|
$form->setBloc('complement4_om_html','D',"","col_12"); |
|
2152 |
$form->setFieldset('complement4_om_html','D',_('Complement 4')); |
$form->setFieldset('complement4_om_html','D',_('Complement 4')); |
2153 |
$form->setFieldset('bible4','F',''); |
$form->setFieldset('bible4','F',''); |
2154 |
$form->setBloc('bible4','F'); |
$form->setFieldset('titre_om_htmletat','DF',_('Titre'), 'startClosed'); |
2155 |
|
$form->setFieldset('corps_om_htmletatex','DF',_('Corps')); |
2156 |
|
$form->setBloc('corps_om_htmletatex','F'); |
2157 |
} |
} |
2158 |
} |
} |
2159 |
|
|
2166 |
$form->setLib('bible2', ""); |
$form->setLib('bible2', ""); |
2167 |
$form->setLib('bible3', ""); |
$form->setLib('bible3', ""); |
2168 |
$form->setLib('bible4', ""); |
$form->setLib('bible4', ""); |
2169 |
|
$form->setLib('btn_refresh', ""); |
2170 |
|
$form->setLib('btn_preview', ""); |
2171 |
|
$form->setLib('btn_redaction', ""); |
2172 |
|
$form->setLib('live_preview', ""); |
2173 |
$form->setLib('om_final_instruction_utilisateur', _("finalise par")); |
$form->setLib('om_final_instruction_utilisateur', _("finalise par")); |
2174 |
|
$form->setLib('date_envoi_rar', __("date_envoi_ar")); |
2175 |
|
$form->setLib('date_retour_rar', __("date_notification")); |
2176 |
|
$form->setLib('statut_signature', __("statut")); |
2177 |
|
$form->setLib('commentaire_signature', __("commentaire")); |
2178 |
|
$form->setLib('historique_signature', ''); |
2179 |
|
$form->setLib('suivi_notification', ''); |
2180 |
|
$form->setLib('suivi_notification_service', ''); |
2181 |
|
$form->setLib('suivi_notification_tiers', ''); |
2182 |
|
$form->setLib('suivi_notification_commune', ''); |
2183 |
|
$form->setLib('preview_edition', ""); |
2184 |
|
|
2185 |
|
// Ajout d'une infobulle d'aide lorsque le formulaire est en mode |
2186 |
|
// ajout et que l'option de rédaction libre est activée sur la |
2187 |
|
// collectivité du dossier |
2188 |
|
if ($maj === '0' && $this->is_option_redaction_libre_enabled() === true) { |
2189 |
|
// |
2190 |
|
$help_text_template = '%s <span class="info-16" title="%s"></span>'; |
2191 |
|
$help_text = _("Attention: le passage du mode 'Rédaction libre' à celui de 'Rédaction par compléments' fait perdre toute la rédaction manuelle effectuée."); |
2192 |
|
$form->setLib('flag_edition_integrale', sprintf($help_text_template, _("Type de rédaction"), $help_text)); |
2193 |
|
} |
2194 |
|
else { |
2195 |
|
$form->setLib('flag_edition_integrale', _("Type de rédaction")); |
2196 |
|
} |
2197 |
|
|
2198 |
|
// Ajout d'une infobulle d'aide lorsque le formulaire est en mode |
2199 |
|
// modification et que l'option de prévisualisation de l'édition est |
2200 |
|
// activée sur la collectivité du dossier |
2201 |
|
if ($maj === '1' |
2202 |
|
&& $this->f->is_option_preview_pdf_enabled($this->get_dossier_instruction_om_collectivite()) === true) { |
2203 |
|
// |
2204 |
|
$help_text_template = '%s <span class="info-16" title="%s"></span>'; |
2205 |
|
$help_text = _("Attention la modification de la valeur de ce champ n'est pas prise en compte dans la prévisualisation. Pour que cette valeur soit mise à jour, il suffit de valider le formulaire."); |
2206 |
|
$form->setLib('date_evenement', sprintf($help_text_template, _('date_evenement'), $help_text)); |
2207 |
|
$form->setLib('signataire_arrete', sprintf($help_text_template, _('signataire_arrete'), $help_text)); |
2208 |
|
} |
2209 |
} |
} |
2210 |
|
|
2211 |
function triggerajouter($id, &$db, $val, $DEBUG) { |
/** |
2212 |
|
* TRIGGER - triggerajouter. |
2213 |
|
* |
2214 |
|
* @return boolean |
2215 |
|
*/ |
2216 |
|
function triggerajouter($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
2217 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
2218 |
/** |
/** |
2219 |
* 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 |
2220 |
* et dossier pour les stocker dans l'instruction : |
* et dossier pour les stocker dans l'instruction : |
2227 |
* - delai_notification |
* - delai_notification |
2228 |
* - lettretype |
* - lettretype |
2229 |
* - autorite_competente |
* - autorite_competente |
2230 |
|
* - pec_metier |
2231 |
* - complement_om_html |
* - complement_om_html |
2232 |
* - complement2_om_html |
* - complement2_om_html |
2233 |
* - complement3_om_html |
* - complement3_om_html |
2252 |
// 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é |
2253 |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
2254 |
WHERE evenement=".$this->valF['evenement']; |
WHERE evenement=".$this->valF['evenement']; |
2255 |
$res = $db->query($sql); |
$res = $this->f->db->query($sql); |
2256 |
$this->addToLog("triggerajouter(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
2257 |
if (database::isError($res)) { |
$this->f->isDatabaseError($res); |
|
die($res->getMessage()); |
|
|
} |
|
2258 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
2259 |
// Récupération de l'identifiant de l'action |
// Récupération de l'identifiant de l'action |
2260 |
// si une action est paramétrée dans l'événement |
// si une action est paramétrée dans l'événement |
2288 |
} |
} |
2289 |
// Récupération de la valeur de la lettre type |
// Récupération de la valeur de la lettre type |
2290 |
$this->valF['lettretype']=$row['lettretype']; |
$this->valF['lettretype']=$row['lettretype']; |
2291 |
|
// Récupération de la valeur de la prise en compte métier |
2292 |
|
// si la prise en compte métier est paramétrée dans l'événement |
2293 |
|
$this->valF['pec_metier'] = NULL; |
2294 |
|
if(isset($row['pec_metier']) === true and empty($row['pec_metier']) === false) { |
2295 |
|
$this->valF['pec_metier'] = $row['pec_metier']; |
2296 |
|
} |
2297 |
} |
} |
2298 |
// 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 |
2299 |
$sql = "SELECT * FROM ".DB_PREFIXE."dossier |
$sql = "SELECT * FROM ".DB_PREFIXE."dossier |
2300 |
WHERE dossier='".$this->valF['dossier']."'"; |
WHERE dossier='".$this->valF['dossier']."'"; |
2301 |
$res = $db->query($sql); |
$res = $this->f->db->query($sql); |
2302 |
$this->addToLog("triggerajouter(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
2303 |
if (database::isError($res)) { |
$this->f->isDatabaseError($res); |
|
die($res->getMessage()); |
|
|
} |
|
2304 |
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
2305 |
$this->updateArchiveData($row); |
$this->updateArchiveData($row); |
2306 |
|
|
2312 |
LEFT JOIN ".DB_PREFIXE."dossier |
LEFT JOIN ".DB_PREFIXE."dossier |
2313 |
ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
2314 |
WHERE dossier.dossier='".$this->valF['dossier']."'"; |
WHERE dossier.dossier='".$this->valF['dossier']."'"; |
2315 |
$duree_validite_parametrage = $db->getOne($sql); |
$duree_validite_parametrage = $this->f->db->getone($sql); |
2316 |
$this->addToLog("triggerajouter(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
2317 |
database::isError($duree_validite_parametrage); |
$this->f->isDatabaseError($duree_validite_parametrage); |
2318 |
if ($duree_validite_parametrage != '') { |
if ($duree_validite_parametrage != '') { |
2319 |
$this->valF['duree_validite_parametrage']= $duree_validite_parametrage; |
$this->valF['duree_validite_parametrage']= $duree_validite_parametrage; |
2320 |
} |
} |
2326 |
$this->valF["code_barres"] = $idTypeCourrier . $idCourrier; |
$this->valF["code_barres"] = $idTypeCourrier . $idCourrier; |
2327 |
} |
} |
2328 |
|
|
2329 |
// Test si une restriction est valide |
/** |
2330 |
// return boolean |
* Test si une restriction est valide. |
2331 |
|
* |
2332 |
|
* @return boolean |
2333 |
|
*/ |
2334 |
function restrictionIsValid($restriction){ |
function restrictionIsValid($restriction){ |
2335 |
if($this->restriction_valid != null) { |
if($this->restriction_valid != null) { |
2336 |
return $this->restriction_valid; |
return $this->restriction_valid; |
2515 |
$sql = "SELECT retour |
$sql = "SELECT retour |
2516 |
FROM ".DB_PREFIXE."evenement |
FROM ".DB_PREFIXE."evenement |
2517 |
WHERE evenement = ".$evenement; |
WHERE evenement = ".$evenement; |
2518 |
$retour = $this->db->getOne($sql); |
$retour = $this->f->db->getone($sql); |
2519 |
$this->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
2520 |
if (database::isError($retour)) { |
$this->f->isDatabaseError($retour); |
|
die($retour->getMessage()); |
|
|
} |
|
2521 |
if ($retour == 't') { |
if ($retour == 't') { |
2522 |
return true; |
return true; |
2523 |
} else { |
} else { |
2544 |
WHERE |
WHERE |
2545 |
evenement =".$evenement; |
evenement =".$evenement; |
2546 |
|
|
2547 |
$restriction = $this->db->getOne($sql); |
$restriction = $this->f->db->getone($sql); |
2548 |
$this->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
2549 |
if (database::isError($restriction)) { |
$this->f->isDatabaseError($restriction); |
|
die($restriction->getMessage()); |
|
|
} |
|
2550 |
return $restriction; |
return $restriction; |
2551 |
} |
} |
2552 |
|
|
2628 |
"regle_date_retour_contradictoire", |
"regle_date_retour_contradictoire", |
2629 |
"regle_date_ait", |
"regle_date_ait", |
2630 |
"regle_date_transmission_parquet", |
"regle_date_transmission_parquet", |
2631 |
|
"regle_date_affichage", |
2632 |
); |
); |
2633 |
// Tableau des champs de type numérique |
// Tableau des champs de type numérique |
2634 |
$rule_type_numeric = array( |
$rule_type_numeric = array( |
2640 |
); |
); |
2641 |
// Tableau des champs de type booléen |
// Tableau des champs de type booléen |
2642 |
$rule_type_bool = array( |
$rule_type_bool = array( |
2643 |
|
"regle_a_qualifier", |
2644 |
|
"regle_incompletude", |
2645 |
|
"regle_incomplet_notifie", |
2646 |
|
"regle_evenement_suivant_tacite_incompletude", |
2647 |
); |
); |
2648 |
// Tableau des champs spécifiques |
// Tableau des champs spécifiques |
2649 |
$rule_type_specific = array( |
$rule_type_specific = array( |
2651 |
"regle_etat", |
"regle_etat", |
2652 |
"regle_accord_tacite", |
"regle_accord_tacite", |
2653 |
"regle_avis", |
"regle_avis", |
2654 |
|
"regle_pec_metier", |
2655 |
|
"regle_etat_pendant_incompletude", |
2656 |
); |
); |
2657 |
// Tableau des champs de données techniques |
// Tableau des champs de données techniques |
2658 |
$rule_type_technical_data = array( |
$rule_type_technical_data = array( |
2662 |
'regle_donnees_techniques4', |
'regle_donnees_techniques4', |
2663 |
'regle_donnees_techniques5', |
'regle_donnees_techniques5', |
2664 |
); |
); |
2665 |
|
// Tableau des champs simple |
2666 |
|
$rule_type_simple = array( |
2667 |
|
"regle_dossier_instruction_type", |
2668 |
|
); |
2669 |
|
|
2670 |
// Définit le type du champ |
// Définit le type du champ |
2671 |
if (in_array($rule_name, $rule_type_date) == true) { |
if (in_array($rule_name, $rule_type_date) == true) { |
2686 |
if (in_array($rule_name, $rule_type_technical_data) === true) { |
if (in_array($rule_name, $rule_type_technical_data) === true) { |
2687 |
$type = 'text'; |
$type = 'text'; |
2688 |
} |
} |
2689 |
|
if (in_array($rule_name, $rule_type_simple) === true) { |
2690 |
|
$type = 'simple'; |
2691 |
|
} |
2692 |
|
|
2693 |
// 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 |
2694 |
// Récupère directement la valeur de l'opérande |
// Récupère directement la valeur de l'opérande |
2695 |
if ($type === 'specific' || $type === 'bool') { |
if ($type === 'specific') { |
2696 |
// |
// |
2697 |
return $this->get_value_for_rule($rule); |
return $this->get_value_for_rule($rule); |
2698 |
} |
} |
2767 |
// Retourne la chaîne de caractère |
// Retourne la chaîne de caractère |
2768 |
return $res_text; |
return $res_text; |
2769 |
} |
} |
2770 |
|
if ($type === 'simple' || $type === 'bool') { |
2771 |
|
// Retourne la valeur du champs rule |
2772 |
|
return $rule; |
2773 |
|
} |
2774 |
} |
} |
2775 |
|
|
2776 |
|
|
2813 |
$donnees_techniques = $this->getDonneesTechniques(); |
$donnees_techniques = $this->getDonneesTechniques(); |
2814 |
} |
} |
2815 |
// |
// |
2816 |
require_once "../obj/donnees_techniques.class.php"; |
$this->inst_donnees_techniques = $this->f->get_inst__om_dbform(array( |
2817 |
$this->inst_donnees_techniques = new donnees_techniques($donnees_techniques); |
"obj" => "donnees_techniques", |
2818 |
|
"idx" => $donnees_techniques, |
2819 |
|
)); |
2820 |
} |
} |
2821 |
// |
// |
2822 |
return $this->inst_donnees_techniques; |
return $this->inst_donnees_techniques; |
2834 |
$sql = "SELECT donnees_techniques |
$sql = "SELECT donnees_techniques |
2835 |
FROM ".DB_PREFIXE."donnees_techniques |
FROM ".DB_PREFIXE."donnees_techniques |
2836 |
WHERE dossier_instruction ='".$this->valF["dossier"]."'"; |
WHERE dossier_instruction ='".$this->valF["dossier"]."'"; |
2837 |
$donnees_techniques = $this->db->getOne($sql); |
$donnees_techniques = $this->f->db->getone($sql); |
2838 |
$this->f->addToLog("getStatut() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
2839 |
if ( database::isError($donnees_techniques)){ |
$this->f->isDatabaseError($donnees_techniques); |
|
die(); |
|
|
} |
|
|
|
|
2840 |
return $donnees_techniques; |
return $donnees_techniques; |
2841 |
} |
} |
2842 |
|
|
|
|
|
2843 |
/** |
/** |
2844 |
* TRIGGER - triggerajouterapres. |
* TRIGGER - triggerajouterapres. |
2845 |
* |
* |
2850 |
* |
* |
2851 |
* @return boolean |
* @return boolean |
2852 |
*/ |
*/ |
2853 |
function triggerajouterapres($id, &$db, $val, $DEBUG) { |
function triggerajouterapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
2854 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
2855 |
|
|
2856 |
// 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 |
2857 |
$inst_di = $this->get_inst_dossier($this->valF['dossier']); |
$inst_di = $this->get_inst_dossier($this->valF['dossier']); |
|
|
|
2858 |
// Instance de la classe evenement |
// Instance de la classe evenement |
2859 |
$inst_evenement = $this->get_inst_evenement($this->valF['evenement']); |
$inst_evenement = $this->get_inst_evenement($this->valF['evenement']); |
2860 |
|
// Instance de l'état courant du dossier d'instruction |
2861 |
|
$inst_current_etat = $this->f->get_inst__om_dbform(array( |
2862 |
|
"obj" => "etat", |
2863 |
|
"idx" => $inst_di->get_id_etat(), |
2864 |
|
)); |
2865 |
|
|
2866 |
/** |
/** |
2867 |
* Mise à jour des valeurs du dossier en fonction des valeurs calculées |
* Mise à jour des valeurs du dossier en fonction des valeurs calculées |
2869 |
*/ |
*/ |
2870 |
// état de complétude actuel du dossier |
// état de complétude actuel du dossier |
2871 |
$incompletude = ($inst_di->getVal('incompletude') == 't' ? true : false); |
$incompletude = ($inst_di->getVal('incompletude') == 't' ? true : false); |
2872 |
|
// L'événement suivant tacite paramétré est destiné à la gestion de l'incomplétude |
2873 |
|
$ev_suiv_tacite_incompletude = false; |
2874 |
// Initialisation |
// Initialisation |
2875 |
$valF = ""; |
$valF = array(); |
2876 |
$valF_dt = ""; |
$valF_dt = array(); |
2877 |
// |
// |
|
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; |
|
|
} |
|
|
} |
|
2878 |
// Récupération des paramètres de l'action |
// Récupération des paramètres de l'action |
2879 |
$sql = "SELECT * FROM ".DB_PREFIXE."action |
$sql = "SELECT * FROM ".DB_PREFIXE."action |
2880 |
WHERE action='".$this->valF['action']."'"; |
WHERE action='".$this->valF['action']."'"; |
2881 |
$res = $db->query($sql); |
$res = $this->f->db->query($sql); |
2882 |
$this->addToLog("triggerajouterapres(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
2883 |
if (database::isError($res)) { |
$this->f->isDatabaseError($res); |
|
die($res->getMessage()); |
|
|
} |
|
2884 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
2885 |
|
|
2886 |
// pour chacune des regles, on applique la regle |
// pour chacune des regles, on applique la regle |
2933 |
$valF['autorite_competente'] = $this->regle($row['regle_autorite_competente'], 'regle_autorite_competente'); |
$valF['autorite_competente'] = $this->regle($row['regle_autorite_competente'], 'regle_autorite_competente'); |
2934 |
} |
} |
2935 |
if ($row['regle_etat'] != '') { |
if ($row['regle_etat'] != '') { |
2936 |
// 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'); |
|
|
} |
|
2937 |
} |
} |
2938 |
if ($row['regle_date_cloture_instruction'] !== '') { |
if ($row['regle_date_cloture_instruction'] !== '') { |
2939 |
$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'); |
2971 |
if ($row['regle_date_transmission_parquet'] !== '') { |
if ($row['regle_date_transmission_parquet'] !== '') { |
2972 |
$valF['date_transmission_parquet'] = $this->regle($row['regle_date_transmission_parquet'], 'regle_date_transmission_parquet'); |
$valF['date_transmission_parquet'] = $this->regle($row['regle_date_transmission_parquet'], 'regle_date_transmission_parquet'); |
2973 |
} |
} |
2974 |
|
if ($row['regle_dossier_instruction_type'] !== '') { |
2975 |
|
$valF['dossier_instruction_type'] = $this->regle($row['regle_dossier_instruction_type'], 'regle_dossier_instruction_type'); |
2976 |
|
} |
2977 |
|
// La date d'affichage est modifiée seulement si le champ n'est pas |
2978 |
|
// renseigné |
2979 |
|
if ($row['regle_date_affichage'] !== '' |
2980 |
|
&& ($inst_di->getVal('date_affichage') === '' |
2981 |
|
|| $inst_di->getVal('date_affichage') === null)) { |
2982 |
|
// |
2983 |
|
$valF['date_affichage'] = $this->regle($row['regle_date_affichage'], 'regle_date_affichage'); |
2984 |
|
} |
2985 |
|
// |
2986 |
|
if ($row['regle_pec_metier'] != '') { |
2987 |
|
$valF['pec_metier'] = $this->regle($row['regle_pec_metier'], 'regle_pec_metier'); |
2988 |
|
} |
2989 |
|
if ($row['regle_a_qualifier'] != '') { |
2990 |
|
$valF['a_qualifier'] = $this->regle($row['regle_a_qualifier'], 'regle_a_qualifier'); |
2991 |
|
} |
2992 |
|
// |
2993 |
|
if ($row['regle_incompletude'] != '') { |
2994 |
|
$valF['incompletude'] = $this->regle($row['regle_incompletude'], 'regle_incompletude'); |
2995 |
|
} |
2996 |
|
if ($row['regle_incomplet_notifie'] != '') { |
2997 |
|
$valF['incomplet_notifie'] = $this->regle($row['regle_incomplet_notifie'], 'regle_incomplet_notifie'); |
2998 |
|
} |
2999 |
|
if ($row['regle_etat_pendant_incompletude'] != '') { |
3000 |
|
$valF['etat_pendant_incompletude'] = $this->regle($row['regle_etat_pendant_incompletude'], 'regle_etat_pendant_incompletude'); |
3001 |
|
} |
3002 |
|
if ($row['regle_evenement_suivant_tacite_incompletude'] != '') { |
3003 |
|
$resti = $this->regle($row['regle_evenement_suivant_tacite_incompletude'], 'regle_evenement_suivant_tacite_incompletude'); |
3004 |
|
if (strtolower($resti) === 't' || strtolower($resti) === 'true') { |
3005 |
|
$ev_suiv_tacite_incompletude = true; |
3006 |
|
} |
3007 |
|
} |
3008 |
} |
} |
3009 |
|
|
3010 |
// Si l'événement a un événement suivant tacite |
// Si l'événement a un événement suivant tacite |
3011 |
if($inst_evenement->getVal('evenement_suivant_tacite') != '') { |
if($inst_evenement->getVal('evenement_suivant_tacite') != '') { |
3012 |
// 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 |
3013 |
// dans le champ evenement_suivant_tacite du dossier |
// pas associé de le même façon au dossier d'instruction |
3014 |
if ($incompletude == false OR $inst_evenement->getVal('type') != "incompletude") { |
if ($ev_suiv_tacite_incompletude === false) { |
|
// |
|
3015 |
$valF['evenement_suivant_tacite'] = $inst_evenement->getVal('evenement_suivant_tacite'); |
$valF['evenement_suivant_tacite'] = $inst_evenement->getVal('evenement_suivant_tacite'); |
3016 |
} else { |
} |
3017 |
// Sinon l'événement tacite est stocké dans le champ |
if ($ev_suiv_tacite_incompletude === true) { |
|
// evenement_suivant_tacite_incompletude du dossier |
|
3018 |
$valF['evenement_suivant_tacite_incompletude'] = $inst_evenement->getVal('evenement_suivant_tacite'); |
$valF['evenement_suivant_tacite_incompletude'] = $inst_evenement->getVal('evenement_suivant_tacite'); |
3019 |
} |
} |
3020 |
} |
} |
3021 |
// 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 |
3022 |
if ($valF_dt != "") { |
if (count($valF_dt) > 0) { |
3023 |
$dt_id = $this->getDonneesTechniques(); |
$dt_id = $this->getDonneesTechniques(); |
3024 |
// On met à jour le dossier |
// On met à jour le dossier |
3025 |
$cle = " donnees_techniques='".$dt_id."'"; |
$cle = " donnees_techniques='".$dt_id."'"; |
3026 |
$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); |
3027 |
$this->addToLog("triggerajouterapres(): db->autoexecute(\"".DB_PREFIXE."donnees_techniques\", ".print_r($valF_dt, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
$this->addToLog( |
3028 |
if (database::isError($res1)) { |
__METHOD__."(): db->autoexecute(\"".DB_PREFIXE."donnees_techniques\", ".print_r($valF_dt, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", |
3029 |
die($res->getMessage()); |
VERBOSE_MODE |
3030 |
} |
); |
3031 |
|
$this->f->isDatabaseError($res1); |
3032 |
// Affichage d'informations à l'utilisateur |
// Affichage d'informations à l'utilisateur |
3033 |
$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')."]"); |
3034 |
} |
} |
3035 |
// 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 |
3036 |
if ($valF != "") { |
if (count($valF) > 0) { |
3037 |
// On met à jour le dossier |
// |
3038 |
$cle = " dossier='".$this->valF['dossier']."'"; |
$inst_dossier = $this->f->get_inst__om_dbform(array( |
3039 |
$res1 = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle); |
"obj" => "dossier", |
3040 |
$this->addToLog("triggerajouterapres(): db->autoexecute(\"".DB_PREFIXE."dossier\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
"idx" => $this->valF['dossier'], |
3041 |
if (database::isError($res1)) { |
)); |
3042 |
die($res->getMessage()); |
$valF['instruction'] = $id; |
3043 |
|
$valF['crud'] = 'create'; |
3044 |
|
$update_by_instruction = $inst_dossier->update_by_instruction($valF); |
3045 |
|
if ($update_by_instruction === false) { |
3046 |
|
$this->cleanMessage(); |
3047 |
|
$this->addToMessage(sprintf('%s %s', __("Une erreur s'est produite lors de la mise à jour du dossier d'instruction."), __("Veuillez contacter votre administrateur."))); |
3048 |
|
return false; |
3049 |
} |
} |
3050 |
// Affichage d'informations à l'utilisateur |
// Affichage d'informations à l'utilisateur |
3051 |
$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')."]"); |
3052 |
} |
} |
3053 |
|
|
3054 |
/** |
/** |
3084 |
$this->addToMessage(_("Notification (105) du référentiel ERP OK.")); |
$this->addToMessage(_("Notification (105) du référentiel ERP OK.")); |
3085 |
} |
} |
3086 |
|
|
3087 |
|
// Si le mode en rédaction intégrale est activé |
3088 |
|
if (isset($this->valF['flag_edition_integrale']) === true |
3089 |
|
&& $this->valF['flag_edition_integrale'] === true) { |
3090 |
|
$redactionIntegraleValF = array(); |
3091 |
|
|
3092 |
|
// Récupère la collectivite du dossier d'instruction |
3093 |
|
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
3094 |
|
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
3095 |
|
// Récupère le corps de la lettre type |
3096 |
|
$params = array( |
3097 |
|
"specific" => array( |
3098 |
|
"corps" => array( |
3099 |
|
"mode" => "get", |
3100 |
|
) |
3101 |
|
), |
3102 |
|
); |
3103 |
|
$result = $this->compute_pdf_output('lettretype', $this->valF['lettretype'], $collectivite, $id, $params); |
3104 |
|
$redactionIntegraleValF['corps_om_htmletatex'] = $result['pdf_output']; |
3105 |
|
// Récupère le titre de la lettre type |
3106 |
|
$params = array( |
3107 |
|
"specific" => array( |
3108 |
|
"titre" => array( |
3109 |
|
"mode" => "get", |
3110 |
|
) |
3111 |
|
), |
3112 |
|
); |
3113 |
|
$result = $this->compute_pdf_output('lettretype', $this->valF['lettretype'], $collectivite, $id, $params); |
3114 |
|
$redactionIntegraleValF['titre_om_htmletat'] = $result['pdf_output']; |
3115 |
|
|
3116 |
|
// mise à jour en base de données |
3117 |
|
$res = $this->f->db->autoExecute( |
3118 |
|
DB_PREFIXE.$this->table, |
3119 |
|
$redactionIntegraleValF, |
3120 |
|
DB_AUTOQUERY_UPDATE, |
3121 |
|
$this->clePrimaire."=".$id |
3122 |
|
); |
3123 |
|
$this->addToLog(__METHOD__."(): db->autoexecute(\"".DB_PREFIXE.'.'.$this->table."\", ".print_r($redactionIntegraleValF, true).", DB_AUTOQUERY_UPDATE, \"".$this->clePrimaire."=".$id."\");", VERBOSE_MODE); |
3124 |
|
if ($this->f->isDatabaseError($res, true) === true) { |
3125 |
|
return false; |
3126 |
|
} |
3127 |
|
} |
3128 |
|
|
3129 |
|
/** |
3130 |
|
* Finalisation automatique de l'instruction si le paramétrage de l'événement l'autorise |
3131 |
|
*/ |
3132 |
|
// Si la finalisation automatique de l'événement est activée |
3133 |
|
// ET si l'instruction n'a pas déjà été finalisée |
3134 |
|
// ET s'il existe une lettre type associée |
3135 |
|
if ($inst_evenement->getVal('finaliser_automatiquement') === 't' |
3136 |
|
&& $inst_evenement->getVal('om_final_instruction') !== 't' |
3137 |
|
&& $inst_evenement->getVal('lettretype') !== '' |
3138 |
|
&& $inst_evenement->getVal('lettretype') !== null) { |
3139 |
|
|
3140 |
|
// On instancie l'instruction |
3141 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
3142 |
|
"obj" => "instruction", |
3143 |
|
"idx" => $this->valF[$this->clePrimaire], |
3144 |
|
)); |
3145 |
|
|
3146 |
|
// On finalise l'instruction dans le contexte de finalisation : action 100 |
3147 |
|
$inst_instruction->setParameter('maj', 100); |
3148 |
|
$finalize = $inst_instruction->finalize($inst_instruction->valF); |
3149 |
|
|
3150 |
|
// Une erreur de finalisation renvoie 'false' : ajout dans les logs |
3151 |
|
// et dans le message d'erreur |
3152 |
|
if ($finalize === false) { |
3153 |
|
$this->f->addToLog(__METHOD__."() : ERROR - Impossible de finaliser l'instruction.", DEBUG_MODE); |
3154 |
|
$this->addToMessage(_("Erreur lors de la finalisation de l'instruction. Contactez votre administrateur.")); |
3155 |
|
return false; |
3156 |
|
} |
3157 |
|
} |
3158 |
|
|
3159 |
|
/** |
3160 |
|
* Finalisation automatique des instructions tacites ou retours. |
3161 |
|
*/ |
3162 |
|
// Si l'option de finalisation automatique des instructions tacites ou |
3163 |
|
// retours est activée et l'événement d'instruction a une lettre type |
3164 |
|
// associée |
3165 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite($val['dossier']); |
3166 |
|
if ($this->f->is_option_finalisation_auto_enabled($collectivite_di) === true |
3167 |
|
&& $inst_evenement->getVal('lettretype') !== '' |
3168 |
|
&& $inst_evenement->getVal('lettretype') !== null) { |
3169 |
|
|
3170 |
|
// Rècupère l'identifiant de l'événement |
3171 |
|
$evenement_id = $inst_evenement->getVal($inst_evenement->clePrimaire); |
3172 |
|
|
3173 |
|
// Si l'événement d'instruction est identifié comme un événement |
3174 |
|
// retour |
3175 |
|
// OU l'événement d'instruction est l'événement suivant tacite du |
3176 |
|
// dossier d'instruction (incomplétude prise en compte) |
3177 |
|
// ET l'événement d'instruction n'a pas déjà été finalisé |
3178 |
|
if (($inst_evenement->getVal("retour") === 't' |
3179 |
|
|| ($inst_di->getVal('evenement_suivant_tacite_incompletude') === $evenement_id |
3180 |
|
|| $inst_di->getVal('evenement_suivant_tacite') === $evenement_id)) |
3181 |
|
&& ($inst_evenement->getVal('om_final_instruction') !== 't')) { |
3182 |
|
|
3183 |
|
// Finalise l'instruction |
3184 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
3185 |
|
"obj" => "instruction", |
3186 |
|
"idx" => $this->valF[$this->clePrimaire], |
3187 |
|
)); |
3188 |
|
$inst_instruction->setParameter('maj', 100); |
3189 |
|
$finalize = $inst_instruction->finalize($inst_instruction->valF); |
3190 |
|
if ($finalize === false) { |
3191 |
|
// |
3192 |
|
return false; |
3193 |
|
} |
3194 |
|
} |
3195 |
|
} |
3196 |
|
|
3197 |
|
/** |
3198 |
|
* Mise à jour de la version de clôture *version_clos* du dossier si et |
3199 |
|
* seulement si l'instruction met à jour l'état du dossier. |
3200 |
|
*/ |
3201 |
|
if (isset($valF['etat']) === true |
3202 |
|
&& $valF['etat'] !== null |
3203 |
|
&& $valF['etat'] !== '') { |
3204 |
|
// Instanciation de l'état appliqué sur le dossier par l'instruction |
3205 |
|
$inst_etat = $this->f->get_inst__om_dbform(array( |
3206 |
|
"obj" => "etat", |
3207 |
|
"idx" => $valF['etat'], |
3208 |
|
)); |
3209 |
|
// |
3210 |
|
$update_version_clos = null; |
3211 |
|
// En cas d'instruction qui clôture le dossier |
3212 |
|
if ($inst_etat->getVal('statut') === 'cloture') { |
3213 |
|
$update_version_clos = $inst_di->update_version_clos('up'); |
3214 |
|
} |
3215 |
|
// En cas d'instruction qui rouvre le dossier |
3216 |
|
if ($inst_current_etat->getVal('statut') === 'cloture' |
3217 |
|
&& $inst_etat->getVal('statut') !== 'cloture') { |
3218 |
|
// |
3219 |
|
$update_version_clos = $inst_di->update_version_clos('down'); |
3220 |
|
// |
3221 |
|
$params = array( |
3222 |
|
'di_reopened' => true, |
3223 |
|
); |
3224 |
|
} |
3225 |
|
// |
3226 |
|
if ($update_version_clos === false) { |
3227 |
|
$this->f->addToLog(sprintf( |
3228 |
|
"%s() : ERREUR - %s %s", |
3229 |
|
__METHOD__, |
3230 |
|
sprintf( |
3231 |
|
__("Impossible de mettre à jour la version de clôture du dossier d'instruction %s."), |
3232 |
|
$inst_di->getVal($inst_di->clePrimaire) |
3233 |
|
), |
3234 |
|
sprintf( |
3235 |
|
__("L'instruction tente d'appliquer l'état %s."), |
3236 |
|
$inst_etat->getVal($inst_etat->clePrimaire) |
3237 |
|
) |
3238 |
|
)); |
3239 |
|
$this->addToMessage(sprintf( |
3240 |
|
"%s %s", |
3241 |
|
__("Erreur lors de la mise à jour de la version de clôture du dossier d'instruction."), |
3242 |
|
__("Veuillez contacter votre administrateur.") |
3243 |
|
)); |
3244 |
|
return false; |
3245 |
|
} |
3246 |
|
} |
3247 |
|
|
3248 |
|
/** |
3249 |
|
* Notification automatique |
3250 |
|
*/ |
3251 |
|
// Notification automatique à l'ajout de l'instruction si la notification |
3252 |
|
// automatique est choisie et qu'il n'y a pas de lettretype associée à l'événement |
3253 |
|
if ($inst_evenement->getVal('notification') === 'notification_automatique' && |
3254 |
|
($inst_evenement->getVal('lettretype') === null || |
3255 |
|
$inst_evenement->getVal('lettretype') === '')) { |
3256 |
|
// Message à afficher dans les logs pour indiquer quelle notification a échouée |
3257 |
|
$msgLog = sprintf( |
3258 |
|
'%s %s : %d', |
3259 |
|
__('Erreur lors de la notification automatique du(des) pétitionnaire(s).'), |
3260 |
|
__('Instruction notifiée'), |
3261 |
|
$id |
3262 |
|
); |
3263 |
|
|
3264 |
|
// Récupération de la liste des demandeurs à notifier et de la catégorie |
3265 |
|
$categorie = $this->f->get_param_option_notification($collectivite_di); |
3266 |
|
$isPortal = $categorie == null || $categorie == '' || $categorie == PORTAL ? true : false; |
3267 |
|
$demandeursANotifie = $this->get_demandeurs_notifiable( |
3268 |
|
$this->valF['dossier'], |
3269 |
|
$isPortal |
3270 |
|
); |
3271 |
|
|
3272 |
|
// Création d'une notification et d'une tâche pour chaque demandeur à notifier |
3273 |
|
$demandeurPrincipalNotifie = false; |
3274 |
|
foreach ($demandeursANotifie as $demandeur) { |
3275 |
|
// Identifie si le demandeur principal a été notifié ou pas |
3276 |
|
// et récupère ses informations |
3277 |
|
if ($demandeur['petitionnaire_principal'] == 't') { |
3278 |
|
$demandeurPrincipalNotifie = true; |
3279 |
|
// Si le demandeur principal est notifiable mais qu'il y a des erreurs dans |
3280 |
|
// son paramétrage, on effectue pas le traitement et on passe à l'itération |
3281 |
|
// suivante. On le considère également comme non notifié pour gérer l'envoie |
3282 |
|
// des messages d'erreurs |
3283 |
|
// Si la demande a été déposée via le portail alors le paramétrage n'a pas |
3284 |
|
// d'impact sur la notification |
3285 |
|
$erreursParam = $this->get_info_notification_fail($val['dossier']); |
3286 |
|
if (! $this->dossier_depose_sur_portail($val['dossier']) && $erreursParam != array()) { |
3287 |
|
$demandeurPrincipalNotifie = false; |
3288 |
|
continue; |
3289 |
|
} |
3290 |
|
} |
3291 |
|
// Ajout de la notif et récupération de son id |
3292 |
|
$idNotif = $this->ajouter_notification( |
3293 |
|
$this->valF[$this->clePrimaire], |
3294 |
|
$this->f->get_connected_user_login_name(), |
3295 |
|
$demandeur, |
3296 |
|
$collectivite_di, |
3297 |
|
array(), |
3298 |
|
true |
3299 |
|
); |
3300 |
|
if ($idNotif === false) { |
3301 |
|
$this->addToLog( |
3302 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
3303 |
|
DEBUG_MODE |
3304 |
|
); |
3305 |
|
return false; |
3306 |
|
} |
3307 |
|
// Création de la tache en lui donnant l'id de la notification |
3308 |
|
$notification_by_task = $this->notification_by_task( |
3309 |
|
$idNotif, |
3310 |
|
$this->valF['dossier'], |
3311 |
|
$categorie |
3312 |
|
); |
3313 |
|
if ($notification_by_task === false) { |
3314 |
|
$this->addToLog( |
3315 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
3316 |
|
DEBUG_MODE |
3317 |
|
); |
3318 |
|
$this->addToMessage( |
3319 |
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
3320 |
|
); |
3321 |
|
return false; |
3322 |
|
} |
3323 |
|
} |
3324 |
|
// Pour la notification par mail ou la notification via portal si le dossier a |
3325 |
|
// été déposés via portal, si le demandeur principal n'est pas notifiable, |
3326 |
|
// on créé une nouvelle notification en erreur avec en commentaire la raison pour |
3327 |
|
// laquelle le demandeur principal n'a pas pu être notifié |
3328 |
|
$depotPortal = $this->dossier_depose_sur_portail(); |
3329 |
|
if (! $demandeurPrincipalNotifie && ($isPortal === false || $depotPortal === true)) { |
3330 |
|
// Précision dans les logs que le pétitionnaire principal n'est pas notifiable. |
3331 |
|
// ' ' permet de mettre un espace entre les 2 msg de log. |
3332 |
|
$msgLog .= sprintf(' %s', __('Le pétitionnaire principale n\'est pas notifiable.')); |
3333 |
|
// Analyse pour savoir pourquoi le demandeur principal n'est pas notifiable |
3334 |
|
$erreursParam = $this->get_info_notification_fail($val['dossier']); |
3335 |
|
$demandeurPrincipal = $this->get_info_petitionnaire_principal_dossier($val['dossier']); |
3336 |
|
// Ajout de la notif et récupération de son id |
3337 |
|
$idNotif = $this->ajouter_notification( |
3338 |
|
$this->valF[$this->clePrimaire], |
3339 |
|
$this->f->get_connected_user_login_name(), |
3340 |
|
$demandeurPrincipal, |
3341 |
|
$collectivite_di, |
3342 |
|
array(), |
3343 |
|
true, |
3344 |
|
'Echec', |
3345 |
|
implode(' ', $erreursParam) |
3346 |
|
); |
3347 |
|
if ($idNotif === false) { |
3348 |
|
$this->addToLog( |
3349 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
3350 |
|
DEBUG_MODE |
3351 |
|
); |
3352 |
|
$this->addToMessage( |
3353 |
|
__('Erreur : la création de la notification a échouée.'). |
3354 |
|
__("Veuillez contacter votre administrateur.") |
3355 |
|
); |
3356 |
|
return false; |
3357 |
|
} |
3358 |
|
// Prépare un message d'alerte à destination de l'instructeur pour l'informer |
3359 |
|
// de l'échec de la notification |
3360 |
|
$dossier_message = $this->get_inst_dossier_message(0); |
3361 |
|
$dossier_message_val = array( |
3362 |
|
'dossier' => $val['dossier'], |
3363 |
|
'type' => _('erreur expedition'), |
3364 |
|
'emetteur' => $this->f->get_connected_user_login_name().' (automatique)', |
3365 |
|
'login' => $_SESSION['login'], |
3366 |
|
'date_emission' => date('Y-m-d H:i:s'), |
3367 |
|
'contenu' => _('Échec lors de la notification de l\'instruction '). |
3368 |
|
$inst_evenement->getVal('libelle'). |
3369 |
|
'.<br>'. |
3370 |
|
implode("\n", $erreursParam). |
3371 |
|
'<br>'. |
3372 |
|
_('Veuillez corriger ces informations avant de renvoyer la notification.') |
3373 |
|
); |
3374 |
|
$add = $dossier_message->add_notification_message($dossier_message_val, true); |
3375 |
|
// Si une erreur se produit pendant l'ajout |
3376 |
|
if ($add !== true) { |
3377 |
|
$this->addToLog(__METHOD__."(): Le message d'alerte concernant l'echec de l'envoi de la notification n'a pas pu être envoyé.", DEBUG_MODE); |
3378 |
|
return false; |
3379 |
|
} |
3380 |
|
} |
3381 |
|
$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."))); |
3382 |
|
} |
3383 |
|
|
3384 |
|
// Notification automatique en cas de dépôt de dossier dématérialisé |
3385 |
|
// Vérifie si l'option de notification est active et si il s'agit bien d'une |
3386 |
|
// instruction de récépissé |
3387 |
|
if ( |
3388 |
|
$this->f->is_option_notification_depot_demat_enabled($collectivite_di) |
3389 |
|
&& $this->is_instruction_recepisse() |
3390 |
|
) { |
3391 |
|
// Message à afficher dans les logs pour indiquer quelle notification a échouée |
3392 |
|
$msgLog = sprintf( |
3393 |
|
__('Erreur lors de la notification de dépôt du dossier dématérialisé : %s.'), |
3394 |
|
$val['dossier'] |
3395 |
|
); |
3396 |
|
// Récupère l'instance de la demande |
3397 |
|
$demande = $inst_di->get_inst_demande(); |
3398 |
|
// Vérifie que le dossier a été déposé via platau ou portal |
3399 |
|
if ( |
3400 |
|
($demande->getVal('source_depot') == PLATAU || |
3401 |
|
$demande->getVal('source_depot') == PORTAL) |
3402 |
|
) { |
3403 |
|
// Récupère la liste des mails fournis en paramètre. Si aucun adresse n'a été récupéré |
3404 |
|
// l'envoi de la notification n'est pas effectué et un message d'erreur est affiché. |
3405 |
|
$listeEmails = $this->f->get_param_courriel_de_notification_commune($collectivite_di); |
3406 |
|
if (empty($listeEmails)) { |
3407 |
|
$this->addToLog( |
3408 |
|
sprintf( |
3409 |
|
'%s(): %s %s', |
3410 |
|
__METHOD__, |
3411 |
|
$msgLog, |
3412 |
|
__('Aucun courriel paramétré.') |
3413 |
|
), |
3414 |
|
DEBUG_MODE |
3415 |
|
); |
3416 |
|
} else { |
3417 |
|
foreach ($listeEmails as $email) { |
3418 |
|
// Ajout de la notif et récupération de son id |
3419 |
|
$destinataire = array( |
3420 |
|
'destinataire' => $email, |
3421 |
|
'courriel' => $email |
3422 |
|
); |
3423 |
|
$idNotif = $this->ajouter_notification( |
3424 |
|
$this->valF[$this->clePrimaire], |
3425 |
|
$this->f->get_connected_user_login_name(), |
3426 |
|
$destinataire, |
3427 |
|
$collectivite_di, |
3428 |
|
array(), |
3429 |
|
true |
3430 |
|
); |
3431 |
|
if ($idNotif === false) { |
3432 |
|
$this->addToLog( |
3433 |
|
sprintf('%s(): %s', __METHOD__, $msgLog), |
3434 |
|
DEBUG_MODE |
3435 |
|
); |
3436 |
|
return false; |
3437 |
|
} |
3438 |
|
// Création de la tache en lui donnant l'id de la notification |
3439 |
|
$notification_by_task = $this->notification_by_task( |
3440 |
|
$idNotif, |
3441 |
|
$this->valF['dossier'], |
3442 |
|
'mail', |
3443 |
|
'notification_depot_demat' |
3444 |
|
); |
3445 |
|
if ($notification_by_task === false) { |
3446 |
|
$this->addToMessage( |
3447 |
|
__("Erreur lors de la génération de la notification de dépot de dossier par voie dématérialisée.") |
3448 |
|
); |
3449 |
|
$this->addToLog( |
3450 |
|
sprintf('%s(): %s', __METHOD__, $msgLog), |
3451 |
|
DEBUG_MODE |
3452 |
|
); |
3453 |
|
return false; |
3454 |
|
} |
3455 |
|
} |
3456 |
|
} |
3457 |
|
} |
3458 |
|
} |
3459 |
|
|
3460 |
|
/** |
3461 |
|
* Mise à jour de la date de dernière modification du dossier |
3462 |
|
*/ |
3463 |
|
$inst_di->update_last_modification_date(); |
3464 |
|
|
3465 |
/** |
/** |
3466 |
* Mise à jour des données du DA. |
* Mise à jour des données du DA. |
3467 |
*/ |
*/ |
|
// |
|
3468 |
$inst_da = $inst_di->get_inst_dossier_autorisation(); |
$inst_da = $inst_di->get_inst_dossier_autorisation(); |
3469 |
// |
$params['di_id'] = $this->valF['dossier']; |
3470 |
if ($inst_da->majDossierAutorisation() === false) { |
if ($inst_da->majDossierAutorisation($params) === false) { |
3471 |
$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.")); |
3472 |
$this->correct = false; |
$this->correct = false; |
3473 |
return false; |
return false; |
3480 |
return $this->add_log_to_dossier($id, array_merge($val, $this->valF)); |
return $this->add_log_to_dossier($id, array_merge($val, $this->valF)); |
3481 |
} |
} |
3482 |
|
|
3483 |
function triggermodifierapres($id,&$db,$val,$DEBUG) { |
/** |
3484 |
/** |
* Cette méthode vérifie si toutes les conditions de l'envoi de la notification |
3485 |
* L'objectif ici est d'effectuer les recalculs de date dans le dossier |
* sont remplies. |
3486 |
* si la date de l'evenement est modifiee |
* Les conditions vérifiées sont les suivantes : |
3487 |
*/ |
* - Le petitionnaire principal doit accepter les notifications |
3488 |
// Initialisation |
* - Le pétitionnaire principal doit avoir une adresse mail renseignée |
3489 |
$valF = ""; |
* - Le pétitionnaire principal doit avoir une adresse mail correcte |
3490 |
$valF_dt = ""; |
* Pour chaque vérification effectué un message d'erreur est ajouté si la |
3491 |
// Initialisation du type d'événement |
* condition n'est pas remplie. |
3492 |
$type_evmt = ""; |
* Renvoie le message d'erreur en sortie. |
3493 |
// Récupération de l'action correspondante à l'événement |
* |
3494 |
$sql = "SELECT action |
* @param string identifiant du dossier sur lequel les notifications ont échouée |
3495 |
FROM ".DB_PREFIXE."evenement |
* @return string |
3496 |
WHERE evenement=".$this->valF['evenement']; |
*/ |
3497 |
$action = $db->getOne($sql); |
protected function get_info_notification_fail($dossier = null) { |
3498 |
$this->addToLog("triggermodifierapres(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
// Utilise l'identifiant du dossier passé en paramètre et si aucun dossier n'a été récupéré |
3499 |
if (database::isError($action)) { |
// utilise celui associé à l'instruction |
3500 |
die($action->getMessage()); |
if ($dossier == null) { |
3501 |
|
$dossier = $this->getVal('dossier'); |
3502 |
|
} |
3503 |
|
// Tableau contenant la liste des messages d'erreur |
3504 |
|
$errorMessage = array(); |
3505 |
|
// Récupère les informations du demandeurs principal |
3506 |
|
$infoPetitionnaire = $this->get_info_petitionnaire_principal_dossier($dossier); |
3507 |
|
// Vérifie si le pétitionnaire principal à bien la case "accepte les notification" cochée |
3508 |
|
if (isset($infoPetitionnaire['notification']) && $infoPetitionnaire['notification'] != 't') { |
3509 |
|
$errorMessage[] = __('Le pétitionnaire principal n\'accepte pas les notifications.'); |
3510 |
|
} |
3511 |
|
// Vérifie si l'adresse mail du pétitionnaire principale est renseignée |
3512 |
|
if (isset($infoPetitionnaire['courriel']) && ! empty($infoPetitionnaire['courriel'])) { |
3513 |
|
// Vérifie si le format de l'adresse mail est pas correct et, si ce n'est pas le cas, informe l'utilisateur |
3514 |
|
// qu'il doit le corriger avant de pouvoir ajouter l'nstruction |
3515 |
|
if (! $this->f->checkValidEmailAddress($infoPetitionnaire['courriel'])) { |
3516 |
|
$errorMessage[] = __('Le courriel du pétitionnaire principal n\'est pas correct : '). |
3517 |
|
$infoPetitionnaire['courriel']. |
3518 |
|
'.'; |
3519 |
|
} |
3520 |
|
} else { |
3521 |
|
// Si le courriel du pétitionnaire principal |
3522 |
|
$errorMessage[] = __('Le courriel du pétitionnaire principal n\'est pas renseigné.'); |
3523 |
} |
} |
3524 |
|
|
3525 |
// Récupération des paramètres de l'action |
return $errorMessage; |
3526 |
$sql = "SELECT * FROM ".DB_PREFIXE."action |
} |
3527 |
WHERE action='".$action."'"; |
|
3528 |
$res = $db->query($sql); |
/** |
3529 |
$this->addToLog("triggermodifierapres(): db->query(\"".$sql."\");", VERBOSE_MODE); |
* Méthode servant à vérifier si un dossier a été déposé sur |
3530 |
if (database::isError($res)) { |
* le portail citoyen ou pas. |
3531 |
die($res->getMessage()); |
* La verification se fait via une requête sql dans laquelle |
3532 |
|
* on va chercher un dossier ayant pour id l'identifiant de |
3533 |
|
* dossier associé à l'instruction et pour lequel la demande |
3534 |
|
* associée la plus ancienne est une demande de création de |
3535 |
|
* dossier via portail |
3536 |
|
* |
3537 |
|
* @param string identifiant du dossier. Si non renseigné c'est le dossier |
3538 |
|
* associé à l'instruction qui est utilisé |
3539 |
|
* @return boolean|void true : dossier déposé via portail, false : dossier |
3540 |
|
* non déposé via portail et null : erreur de base de données. |
3541 |
|
*/ |
3542 |
|
protected function dossier_depose_sur_portail($dossier = null) { |
3543 |
|
if (empty($dossier)) { |
3544 |
|
$dossier = $this->getVal('dossier'); |
3545 |
|
} |
3546 |
|
$qres = $this->f->get_one_result_from_db_query( |
3547 |
|
sprintf( |
3548 |
|
'SELECT |
3549 |
|
dossier |
3550 |
|
FROM |
3551 |
|
%1$sdossier |
3552 |
|
-- Récuperation de la première demande associée au dossier |
3553 |
|
LEFT JOIN ( |
3554 |
|
SELECT |
3555 |
|
demande, |
3556 |
|
dossier_instruction, |
3557 |
|
source_depot |
3558 |
|
FROM |
3559 |
|
%1$sdemande |
3560 |
|
WHERE |
3561 |
|
dossier_instruction = \'%2$s\' |
3562 |
|
ORDER BY |
3563 |
|
demande ASC |
3564 |
|
LIMIT 1 |
3565 |
|
) as demande ON dossier.dossier = demande.dossier_instruction |
3566 |
|
WHERE |
3567 |
|
dossier.dossier = \'%2$s\' |
3568 |
|
AND demande.source_depot = \'portal\'', |
3569 |
|
DB_PREFIXE, |
3570 |
|
$this->f->db->escapeSimple($dossier) |
3571 |
|
), |
3572 |
|
array( |
3573 |
|
"origin" => __METHOD__, |
3574 |
|
"force_return" => true, |
3575 |
|
) |
3576 |
|
); |
3577 |
|
if ($qres["code"] !== "OK") { |
3578 |
|
$this->addToMessage(__('Erreur : La vérification du mode de dépôt du dossier à échoué')); |
3579 |
|
return; |
3580 |
} |
} |
3581 |
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 |
3582 |
// application des regles sur le courrier + delai |
return ! empty($qres["result"]); |
3583 |
if(preg_match("/date_evenement/",$row['regle_date_limite'])){ |
} |
3584 |
$valF['date_limite']= $this->regle($row['regle_date_limite'], 'regle_date_limite'); |
|
3585 |
} |
public function is_service_notifiable() { |
3586 |
if(preg_match("/date_evenement/",$row['regle_date_complet'])){ |
$evenement = $this->get_inst_evenement($this->getVal('evenement')); |
3587 |
$valF['date_complet']= $this->regle($row['regle_date_complet'], 'regle_date_complet'); |
|
3588 |
} |
// Si l'instruction a une édition non finalisé quel que soit |
3589 |
if(preg_match("/date_evenement/",$row['regle_date_dernier_depot'])){ |
// le type de notification, il n'est pas notifiable |
3590 |
$valF['date_dernier_depot']= $this->regle($row['regle_date_dernier_depot'], 'regle_date_dernier_depot'); |
if ($this->has_an_edition() === true) { |
3591 |
} |
if ($this->is_unfinalizable_without_bypass() === false) { |
3592 |
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'); |
|
3593 |
} |
} |
3594 |
if(preg_match("/date_evenement/",$row['regle_date_retour_contradictoire'])){ |
} |
3595 |
$valF['date_retour_contradictoire']= $this->regle($row['regle_date_retour_contradictoire'], 'regle_date_retour_contradictoire'); |
// Vérifie si la notification des tiers est active pour l'évènement |
3596 |
|
return $this->get_boolean_from_pgsql_value($evenement->getVal('notification_service')); |
3597 |
|
} |
3598 |
|
|
3599 |
|
public function is_tiers_notifiable() { |
3600 |
|
$evenement = $this->get_inst_evenement($this->getVal('evenement')); |
3601 |
|
|
3602 |
|
// Si l'instruction a une édition non finalisé quel que soit |
3603 |
|
// le type de notification, il n'est pas notifiable |
3604 |
|
if ($this->has_an_edition() === true) { |
3605 |
|
if ($this->is_unfinalizable_without_bypass() === false) { |
3606 |
|
return false; |
3607 |
} |
} |
3608 |
if(preg_match("/date_evenement/",$row['regle_date_ait'])){ |
} |
3609 |
$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 |
3610 |
|
return ! empty($evenement->getVal('notification_tiers')); |
3611 |
|
} |
3612 |
|
|
3613 |
|
/** |
3614 |
|
* Méthode permettant de savoir si une instruction peut |
3615 |
|
* être notifiée manuellement selon les différents types |
3616 |
|
* de notification. |
3617 |
|
* |
3618 |
|
* Si l'instruction a une édition non finalisée alors elle n'est pas |
3619 |
|
* manuellement notifiable. |
3620 |
|
* Si l'instruction est associé à un événement de notification pour |
3621 |
|
* lequel un retour signature est recquis, elle n'est notifiable que |
3622 |
|
* si la date de retour de signature est remplie. |
3623 |
|
* Par défaut si le type de notification n'est pas connu alors l'instruction |
3624 |
|
* n'est pas notifiable. |
3625 |
|
* Pour tous les autres cas l'instruction est manuellement notifiable. |
3626 |
|
* |
3627 |
|
* @return boolean true : notifiable | false : non notifiable |
3628 |
|
*/ |
3629 |
|
public function is_notifiable_by_task_manual() { |
3630 |
|
$ev = $this->get_inst_evenement($this->getVal('evenement')); |
3631 |
|
|
3632 |
|
// Si l'instruction a une édition non finalisé quel que soit |
3633 |
|
// le type de notification, il n'est pas notifiable |
3634 |
|
if ($this->has_an_edition() === true) { |
3635 |
|
if ($this->is_unfinalizable_without_bypass() === false) { |
3636 |
|
return false; |
3637 |
} |
} |
3638 |
if(preg_match("/date_evenement/",$row['regle_date_transmission_parquet'])){ |
} |
3639 |
$valF['date_transmission_parquet']= $this->regle($row['regle_date_transmission_parquet'], 'regle_date_transmission_parquet'); |
|
3640 |
|
// Gestion des différents cas selon la valeur du champs notification |
3641 |
|
if ($ev->getVal('notification') == 'notification_manuelle' || |
3642 |
|
$ev->getVal('notification') == 'notification_manuelle_annexe' || |
3643 |
|
$ev->getVal('notification') == 'notification_automatique' |
3644 |
|
) { |
3645 |
|
return true; |
3646 |
|
} elseif (($ev->getVal('notification') == 'notification_auto_signature_requise' || |
3647 |
|
$ev->getVal('notification') == 'notification_manuelle_signature_requise' || |
3648 |
|
$ev->getVal('notification') == 'notification_manuelle_annexe_signature_requise') && |
3649 |
|
$this->getVal('date_retour_signature') != null && |
3650 |
|
$this->getVal('date_retour_signature') != '' |
3651 |
|
) { |
3652 |
|
return true ; |
3653 |
|
} |
3654 |
|
return false; |
3655 |
|
} |
3656 |
|
|
3657 |
|
/** |
3658 |
|
* Crée une instance et une tache de notification pour le demandeur |
3659 |
|
* principal. |
3660 |
|
* |
3661 |
|
* @return boolean true si le traitement à réussi |
3662 |
|
*/ |
3663 |
|
protected function notifier_demandeur_principal() { |
3664 |
|
$this->begin_treatment(__METHOD__); |
3665 |
|
$message = ''; |
3666 |
|
// Récupération des informations concernant le demandeur |
3667 |
|
$dossier = $this->getVal('dossier'); |
3668 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite($dossier); |
3669 |
|
$demandeur = $this->get_demandeurs_notifiable( |
3670 |
|
$dossier, |
3671 |
|
true |
3672 |
|
); |
3673 |
|
if ($demandeur !== array()) { |
3674 |
|
$destinataire = array_values($demandeur); |
3675 |
|
// Ajout de la notif et récupération de son id |
3676 |
|
$idNotification = $this->ajouter_notification( |
3677 |
|
$this->getVal($this->clePrimaire), |
3678 |
|
$this->f->get_connected_user_login_name(), |
3679 |
|
$destinataire[0], |
3680 |
|
$collectivite_di, |
3681 |
|
array(), |
3682 |
|
true |
3683 |
|
); |
3684 |
|
if ($idNotification === false) { |
3685 |
|
return $this->end_treatment(__METHOD__, false); |
3686 |
} |
} |
3687 |
if ($row['regle_donnees_techniques1'] !== '') { |
// Création de la tâche en lui donnant l'id de la notification |
3688 |
$valF_dt[$row['cible_regle_donnees_techniques1']] = $this->regle($row['regle_donnees_techniques1'], 'regle_donnees_techniques1'); |
$notification_by_task = $this->notification_by_task($idNotification, $dossier); |
3689 |
|
if ($notification_by_task === false) { |
3690 |
|
$this->addToMessage( |
3691 |
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
3692 |
|
); |
3693 |
|
return $this->end_treatment(__METHOD__, false); |
3694 |
} |
} |
3695 |
if ($row['regle_donnees_techniques2'] !== '') { |
$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."))); |
3696 |
$valF_dt[$row['cible_regle_donnees_techniques2']] = $this->regle($row['regle_donnees_techniques2'], 'regle_donnees_techniques2'); |
return $this->end_treatment(__METHOD__, true); |
3697 |
|
} |
3698 |
|
$this->addToMessage( __("Le demandeur principal n'est pas notifiable.")); |
3699 |
|
return $this->end_treatment(__METHOD__, false); |
3700 |
|
} |
3701 |
|
|
3702 |
|
public function notification_by_task($object_id, $dossier, $category = null, $type = null) { |
3703 |
|
// Par défaut le type est portal |
3704 |
|
if ($category === null) { |
3705 |
|
$category = PORTAL; |
3706 |
|
} |
3707 |
|
// Si le type n'est pas correctement spécifié, alors il est calculé |
3708 |
|
if ($type !== 'notification_recepisse' |
3709 |
|
&& $type !== 'notification_instruction' |
3710 |
|
&& $type !== 'notification_decision' |
3711 |
|
&& $type !== 'notification_service_consulte' |
3712 |
|
&& $type !== 'notification_tiers_consulte' |
3713 |
|
&& $type !== 'notification_depot_demat' |
3714 |
|
&& $type !== 'notification_commune') { |
3715 |
|
// |
3716 |
|
$type = 'notification_instruction'; |
3717 |
|
// Vérifie si l'instruction est un récépissé |
3718 |
|
if ($this->is_instruction_recepisse()) { |
3719 |
|
$type = 'notification_recepisse'; |
3720 |
|
|
3721 |
|
} |
3722 |
|
// Vérifie si l'instruction est une décision |
3723 |
|
if ($type !== 'notification_recepisse') { |
3724 |
|
$avis_decision = $this->getVal('avis_decision') !== null ? $this->getVal('avis_decision') : $this->valF['avis_decision']; |
3725 |
|
if ($avis_decision !== null && $avis_decision !== '') { |
3726 |
|
$type = 'notification_decision'; |
3727 |
|
} |
3728 |
} |
} |
3729 |
if ($row['regle_donnees_techniques3'] !== '') { |
} |
3730 |
$valF_dt[$row['cible_regle_donnees_techniques3']] = $this->regle($row['regle_donnees_techniques3'], 'regle_donnees_techniques3'); |
// Préparation de la tache de notification |
3731 |
|
$inst_task = $this->f->get_inst__om_dbform(array( |
3732 |
|
"obj" => "task", |
3733 |
|
"idx" => 0, |
3734 |
|
)); |
3735 |
|
$task_val = array( |
3736 |
|
'type' => $type, |
3737 |
|
'object_id' => $object_id, |
3738 |
|
'dossier' => $dossier, |
3739 |
|
'category' => $category, |
3740 |
|
); |
3741 |
|
|
3742 |
|
$add_task = $inst_task->add_task(array('val' => $task_val)); |
3743 |
|
if ($add_task === false) { |
3744 |
|
$this->addToLog( |
3745 |
|
sprintf( |
3746 |
|
'%s(): %s %s : %s', |
3747 |
|
__METHOD__, |
3748 |
|
__('Echec de l\'ajout de la tâche de notification.'), |
3749 |
|
__('Paramétrage de la tâche'), |
3750 |
|
var_export($task_val, true) |
3751 |
|
), |
3752 |
|
DEBUG_MODE |
3753 |
|
); |
3754 |
|
return false; |
3755 |
|
} |
3756 |
|
|
3757 |
|
return true; |
3758 |
|
} |
3759 |
|
|
3760 |
|
/** |
3761 |
|
* Cette méthode permet de savoir si l'instruction est une instruction |
3762 |
|
* de recepisse (instruction lié à l'ajout du dossier). |
3763 |
|
* |
3764 |
|
* Pour cela, on récupère la liste des actions qui ont menées à la création |
3765 |
|
* de l'instruction. Si une de ces actions est lié à un objet "demande" on |
3766 |
|
* en deduis que c'est l'ajout d'une demande qui a déclenché la création de |
3767 |
|
* l'instruction et donc qu'il s'agit d'un recepisse. |
3768 |
|
* |
3769 |
|
* @return boolean |
3770 |
|
*/ |
3771 |
|
protected function is_instruction_recepisse() { |
3772 |
|
// Récupère la liste des actions qui ont mené à la création de |
3773 |
|
// l'instruction |
3774 |
|
$trace = debug_backtrace(); |
3775 |
|
// Parcours la liste des actions et si une de ces actions est lié |
3776 |
|
// à la classe demande on cosidère que l'instruction est un recepisse |
3777 |
|
foreach ($trace as $key => $value) { |
3778 |
|
if (isset($trace[$key]['class']) === true |
3779 |
|
&& empty($trace[$key]['class']) === false) { |
3780 |
|
if (strtolower($trace[$key]['class']) === 'demande') { |
3781 |
|
return true; |
3782 |
|
} |
3783 |
} |
} |
3784 |
if ($row['regle_donnees_techniques4'] !== '') { |
} |
3785 |
$valF_dt[$row['cible_regle_donnees_techniques4']] = $this->regle($row['regle_donnees_techniques4'], 'regle_donnees_techniques4'); |
return false; |
3786 |
|
} |
3787 |
|
|
3788 |
|
/** |
3789 |
|
* A partir des informations passée en argument ajoute un nouvel élément |
3790 |
|
* dans la table instruction_notification. |
3791 |
|
* Avant l'ajout vérifie en utilisant l'id de la collectivité passée en |
3792 |
|
* paramètre si le paramétrage attendus est ok. |
3793 |
|
* Ajoute également un nouvel élement dans instruction_notification_document |
3794 |
|
* si l'instruction possède une lettretype. |
3795 |
|
* Si un identifiant d'une instruction annexe est donnée ajoute un deuxième |
3796 |
|
* élement dans la table instruction_notification_document qui correspondra |
3797 |
|
* à l'annexe de la notification. |
3798 |
|
* |
3799 |
|
* @param integer identifiant de l'instruction notifiée |
3800 |
|
* @param string information concernant l'emetteur |
3801 |
|
* @param array tableau contenant 2 entrées |
3802 |
|
* - destinatire : nom, prenom ou raison sociale, dénomination et courriel |
3803 |
|
* - courriel : adresse mail de la personne à notifier |
3804 |
|
* @param integer identifiant de la collectivité permettant de récupèrer les |
3805 |
|
* paramètres à valider |
3806 |
|
* @param boolean indique si la notification est automatique ou manuelle |
3807 |
|
* @param integer identifiant d'une instruction dont l'édition sera annexé |
3808 |
|
* à la notification |
3809 |
|
* |
3810 |
|
* @return integer|boolean identifiant de la notification créée si le traitement |
3811 |
|
* a réussie, false sinon. |
3812 |
|
*/ |
3813 |
|
protected function ajouter_notification( |
3814 |
|
$idInstruction, |
3815 |
|
$emetteur, |
3816 |
|
$destinataire, |
3817 |
|
$collectiviteId, |
3818 |
|
$annexes = array(), |
3819 |
|
$demandeAuto = false, |
3820 |
|
$statut = 'en cours d\'envoi', |
3821 |
|
$commentaire = 'Notification en cours de traitement' |
3822 |
|
) { |
3823 |
|
// Vérification que les paramètres nécessaires à l'envoi de la notification existe avant |
3824 |
|
// de créer la notification |
3825 |
|
if (! $this->is_parametrage_notification_correct($collectiviteId)) { |
3826 |
|
$msgErreur = __("Erreur de paramétrage. L'url d'accès au(x) document(s) notifié(s) n'est pas paramétrée."); |
3827 |
|
$this->addToMessage($msgErreur); |
3828 |
|
$this->addToLog( |
3829 |
|
sprintf('%s() : %s', __METHOD__, $msgErreur), |
3830 |
|
DEBUG_MODE |
3831 |
|
); |
3832 |
|
return false; |
3833 |
|
} |
3834 |
|
// Préparation de la notification |
3835 |
|
$inst_notif = $this->f->get_inst__om_dbform(array( |
3836 |
|
"obj" => "instruction_notification", |
3837 |
|
"idx" => "]", |
3838 |
|
)); |
3839 |
|
$notif_val = array( |
3840 |
|
'instruction_notification' => null, |
3841 |
|
'instruction' => $idInstruction, |
3842 |
|
'automatique' => $demandeAuto, |
3843 |
|
'emetteur' => $emetteur, |
3844 |
|
'date_envoi' => null, |
3845 |
|
'destinataire' => $destinataire['destinataire'], |
3846 |
|
'courriel' => $destinataire['courriel'], |
3847 |
|
'date_premier_acces' => null, |
3848 |
|
'statut' => $statut, |
3849 |
|
'commentaire' => $commentaire |
3850 |
|
); |
3851 |
|
|
3852 |
|
// Création de la notification |
3853 |
|
$add_notif = $inst_notif->ajouter($notif_val); |
3854 |
|
if ($add_notif === false) { |
3855 |
|
$this->addToMessage(__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).")); |
3856 |
|
$this->addToLog( |
3857 |
|
sprintf( |
3858 |
|
'%s() : %s %s : %s', |
3859 |
|
__METHOD__, |
3860 |
|
__("Echec de l'ajout de la notification en base de données."), |
3861 |
|
__('Paramétrage de la notification'), |
3862 |
|
var_export($notif_val, true) |
3863 |
|
), |
3864 |
|
DEBUG_MODE |
3865 |
|
); |
3866 |
|
return false; |
3867 |
|
} |
3868 |
|
|
3869 |
|
// Si il y a une lettretype finalisé stockage de la clé d'accès au documents |
3870 |
|
if ($this->evenement_has_an_edition($this->getVal('evenement')) === true) { |
3871 |
|
$add_notif_doc = $this->ajouter_notification_document( |
3872 |
|
$inst_notif->getVal($inst_notif->clePrimaire), |
3873 |
|
$this->getVal($this->clePrimaire), |
3874 |
|
'instruction' |
3875 |
|
); |
3876 |
|
if ($add_notif_doc === false) { |
3877 |
|
$this->addToMessage(__("Erreur lors de la génération de la notification du document.")); |
3878 |
|
return false; |
3879 |
} |
} |
3880 |
if ($row['regle_donnees_techniques5'] !== '') { |
} |
3881 |
$valF_dt[$row['cible_regle_donnees_techniques5']] = $this->regle($row['regle_donnees_techniques5'], 'regle_donnees_techniques5'); |
// Si une annexe a été choisie stockage de la clé d'accès à l'annexe |
3882 |
|
if (! empty($annexes) && is_array($annexes)) { |
3883 |
|
$add_notif_annexe = $this->ajouter_notification_document_multiple( |
3884 |
|
$inst_notif->getVal($inst_notif->clePrimaire), |
3885 |
|
$annexes |
3886 |
|
); |
3887 |
|
if ($add_notif_annexe === false) { |
3888 |
|
$this->addToMessage(__("Erreur lors de la génération de la notification de l'annexe.")); |
3889 |
|
return false; |
3890 |
} |
} |
3891 |
} |
} |
3892 |
// Si des valeurs de données techniques ont été calculées alors on met à jour l'enregistrement |
|
3893 |
if ($valF_dt != "") { |
// Renvoie l'id de la nouvelle instance de instruction_notification |
3894 |
$dt_id = $this->getDonneesTechniques(); |
return $inst_notif->getVal($inst_notif->clePrimaire); |
3895 |
// On met à jour le dossier |
} |
3896 |
$cle = " donnees_techniques='".$dt_id."'"; |
|
3897 |
$res1 = $db->autoExecute(DB_PREFIXE.'donnees_techniques', $valF_dt, DB_AUTOQUERY_UPDATE, $cle); |
/** |
3898 |
$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 |
3899 |
if (database::isError($res1)) { |
* instance dans la table instruction_notification_document lié a la |
3900 |
die($res->getMessage()); |
* notification dont l'id est passé en paramètre. |
3901 |
|
* |
3902 |
|
* @param array tableau contenant les informations nécessaires pour créer les annexes |
3903 |
|
* |
3904 |
|
* @return integer|boolean identifiant de la notification créée si le traitement |
3905 |
|
* a réussie, false sinon. |
3906 |
|
*/ |
3907 |
|
protected function ajouter_notification_document_multiple($idNotification, $listeDocument) { |
3908 |
|
foreach ($listeDocument as $paramDoc) { |
3909 |
|
if (! $this->ajouter_notification_document($idNotification, $paramDoc['id'], $paramDoc['tableDocument'], $paramDoc['isAnnexe'])) { |
3910 |
|
$this->addToMessage(__("Erreur lors de la génération des documents à notifier.")); |
3911 |
|
return false; |
3912 |
} |
} |
|
// Affichage d'informations à l'utilisateur |
|
|
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
|
3913 |
} |
} |
3914 |
// Si des valeurs ont été calculées alors on met à jour l'enregistrement |
return true; |
3915 |
if ($valF != "") { |
} |
3916 |
// On met à jour le dossier |
|
3917 |
$cle = " dossier='".$this->valF['dossier']."'"; |
/** |
3918 |
$res1 = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle); |
* Ajoute un élément dans la table instruction_notification_document en utilisant |
3919 |
$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 |
3920 |
if (database::isError($res1)) { |
* |
3921 |
die($res->getMessage()); |
* @param integer $idNotification : id de la notification à laquelle on associe le document |
3922 |
|
* @param integer $idDocument : id de l'objet auquel est rattaché le document |
3923 |
|
* @param string $tableDocument : nom de la table a laquelle est rattaché le document |
3924 |
|
* @param boolean $isAnnexe : indique si le document est une annexe ou pas |
3925 |
|
* |
3926 |
|
* @return boolean indique si le traitement a réussi |
3927 |
|
*/ |
3928 |
|
protected function ajouter_notification_document($idNotification, $idDocument, $tableDocument, $isAnnexe = false) { |
3929 |
|
$inst_notif_doc = $this->f->get_inst__om_dbform(array( |
3930 |
|
"obj" => "instruction_notification_document", |
3931 |
|
"idx" => "]", |
3932 |
|
)); |
3933 |
|
// l'attribut instruction doit obligatoirement être renseigné |
3934 |
|
// pour éviter toutes confusion avec d'autres instruction l'id |
3935 |
|
// 0 est donné au document n'appartenant pas aux instructions |
3936 |
|
$notif_doc_val = array( |
3937 |
|
'instruction_notification_document' => null, |
3938 |
|
'instruction_notification' => $idNotification, |
3939 |
|
'instruction' => $tableDocument == 'instruction' ? $idDocument : 0, |
3940 |
|
'document_type' => $tableDocument, |
3941 |
|
'document_id' => $idDocument, |
3942 |
|
'cle' => $this->getCleAccesDocument(), |
3943 |
|
'annexe' => $isAnnexe |
3944 |
|
); |
3945 |
|
|
3946 |
|
$add_notif_doc = $inst_notif_doc->ajouter($notif_doc_val); |
3947 |
|
if ($add_notif_doc === false) { |
3948 |
|
$this->addToLog( |
3949 |
|
sprintf( |
3950 |
|
'%s() : %s %s : %s', |
3951 |
|
__METHOD__, |
3952 |
|
__('Echec de l\'ajout du paramétrage du document notifié en base de données.'), |
3953 |
|
__('Paramétrage du document'), |
3954 |
|
var_export($notif_doc_val, true) |
3955 |
|
), |
3956 |
|
DEBUG_MODE |
3957 |
|
); |
3958 |
|
return false; |
3959 |
|
} |
3960 |
|
return true; |
3961 |
|
} |
3962 |
|
|
3963 |
|
/** |
3964 |
|
* Vérifie si le paramétrage de la notification des demandeurs est correct. |
3965 |
|
* |
3966 |
|
* @param integer identifiant de la collectivité |
3967 |
|
* @return boolean |
3968 |
|
*/ |
3969 |
|
protected function is_parametrage_notification_correct($collectiviteId) { |
3970 |
|
$categorie = $this->f->get_param_option_notification($collectiviteId); |
3971 |
|
$urlAccesNotif = $this->f->get_parametre_notification_url_acces($collectiviteId); |
3972 |
|
if ($categorie == 'mail' && $urlAccesNotif == null) { |
3973 |
|
return false; |
3974 |
|
} |
3975 |
|
return true; |
3976 |
|
} |
3977 |
|
|
3978 |
|
/** |
3979 |
|
* TRIGGER - triggermodifierapres. |
3980 |
|
* |
3981 |
|
* @return boolean |
3982 |
|
*/ |
3983 |
|
function triggermodifierapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
3984 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
3985 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite($val['dossier']); |
3986 |
|
$message = ''; |
3987 |
|
|
3988 |
|
// Définit si le dossier d'instruction doit être mis à jour |
3989 |
|
$update_dossier = true; |
3990 |
|
// Les actions de mise à jour des dates ne doivent pas appliquer |
3991 |
|
// l'action de l'événement et donc ne pas mettre à jour le dossier |
3992 |
|
if ($this->getParameter("maj") == 125 |
3993 |
|
|| $this->getParameter("maj") == 170 |
3994 |
|
|| $this->getParameter("maj") == 175) { |
3995 |
|
$update_dossier = false; |
3996 |
|
} |
3997 |
|
|
3998 |
|
// Traitement en cas de mise à jour du dossier |
3999 |
|
if ($update_dossier === true) { |
4000 |
|
/** |
4001 |
|
* L'objectif ici est d'effectuer les recalculs de date dans le dossier |
4002 |
|
* si la date de l'evenement est modifiee |
4003 |
|
*/ |
4004 |
|
// Initialisation |
4005 |
|
$valF = array(); |
4006 |
|
$valF_dt = array(); |
4007 |
|
// Initialisation du type d'événement |
4008 |
|
$type_evmt = ""; |
4009 |
|
// Récupération de l'action correspondante à l'événement |
4010 |
|
$sql = "SELECT action |
4011 |
|
FROM ".DB_PREFIXE."evenement |
4012 |
|
WHERE evenement=".$this->valF['evenement']; |
4013 |
|
$action = $this->f->db->getone($sql); |
4014 |
|
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
4015 |
|
$this->f->isDatabaseError($action); |
4016 |
|
|
4017 |
|
// Récupération des paramètres de l'action |
4018 |
|
$sql = "SELECT * FROM ".DB_PREFIXE."action |
4019 |
|
WHERE action='".$action."'"; |
4020 |
|
$res = $this->f->db->query($sql); |
4021 |
|
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
4022 |
|
$this->f->isDatabaseError($res); |
4023 |
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
4024 |
|
// application des regles sur le courrier + delai |
4025 |
|
if(preg_match("/date_evenement/",$row['regle_date_limite'])){ |
4026 |
|
$valF['date_limite']= $this->regle($row['regle_date_limite'], 'regle_date_limite'); |
4027 |
|
} |
4028 |
|
if(preg_match("/date_evenement/",$row['regle_date_complet'])){ |
4029 |
|
$valF['date_complet']= $this->regle($row['regle_date_complet'], 'regle_date_complet'); |
4030 |
|
} |
4031 |
|
if(preg_match("/date_evenement/",$row['regle_date_dernier_depot'])){ |
4032 |
|
$valF['date_dernier_depot']= $this->regle($row['regle_date_dernier_depot'], 'regle_date_dernier_depot'); |
4033 |
|
} |
4034 |
|
if(preg_match("/date_evenement/",$row['regle_date_notification_delai'])){ |
4035 |
|
$valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai'], 'regle_date_notification_delai'); |
4036 |
|
} |
4037 |
|
if(preg_match("/date_evenement/",$row['regle_date_decision'])){ |
4038 |
|
$valF['date_decision']= $this->regle($row['regle_date_decision'], 'regle_date_decision'); |
4039 |
|
} |
4040 |
|
if(preg_match("/date_evenement/",$row['regle_date_rejet'])){ |
4041 |
|
$valF['date_rejet']= $this->regle($row['regle_date_rejet'], 'regle_date_rejet'); |
4042 |
|
} |
4043 |
|
if(preg_match("/date_evenement/",$row['regle_date_validite'])){ |
4044 |
|
$valF['date_validite']= $this->regle($row['regle_date_validite'], 'regle_date_validite'); |
4045 |
|
} |
4046 |
|
if(preg_match("/date_evenement/",$row['regle_date_chantier'])){ |
4047 |
|
$valF['date_chantier']= $this->regle($row['regle_date_chantier'], 'regle_date_chantier'); |
4048 |
|
} |
4049 |
|
if(preg_match("/date_evenement/",$row['regle_date_achevement'])){ |
4050 |
|
$valF['date_achevement']= $this->regle($row['regle_date_achevement'], 'regle_date_achevement'); |
4051 |
|
} |
4052 |
|
if(preg_match("/date_evenement/",$row['regle_date_conformite'])){ |
4053 |
|
$valF['date_conformite']= $this->regle($row['regle_date_conformite'], 'regle_date_conformite'); |
4054 |
|
} |
4055 |
|
if(preg_match("/date_evenement/",$row['regle_date_cloture_instruction'])){ |
4056 |
|
$valF['date_cloture_instruction']= $this->regle($row['regle_date_cloture_instruction'], 'regle_date_cloture_instruction'); |
4057 |
|
} |
4058 |
|
if(preg_match("/date_evenement/",$row['regle_date_premiere_visite'])){ |
4059 |
|
$valF['date_premiere_visite']= $this->regle($row['regle_date_premiere_visite'], 'regle_date_premiere_visite'); |
4060 |
|
} |
4061 |
|
if(preg_match("/date_evenement/",$row['regle_date_derniere_visite'])){ |
4062 |
|
$valF['date_derniere_visite']= $this->regle($row['regle_date_derniere_visite'], 'regle_date_derniere_visite'); |
4063 |
|
} |
4064 |
|
if(preg_match("/date_evenement/",$row['regle_date_contradictoire'])){ |
4065 |
|
$valF['date_contradictoire']= $this->regle($row['regle_date_contradictoire'], 'regle_date_contradictoire'); |
4066 |
|
} |
4067 |
|
if(preg_match("/date_evenement/",$row['regle_date_retour_contradictoire'])){ |
4068 |
|
$valF['date_retour_contradictoire']= $this->regle($row['regle_date_retour_contradictoire'], 'regle_date_retour_contradictoire'); |
4069 |
|
} |
4070 |
|
if(preg_match("/date_evenement/",$row['regle_date_ait'])){ |
4071 |
|
$valF['date_ait']= $this->regle($row['regle_date_ait'], 'regle_date_ait'); |
4072 |
|
} |
4073 |
|
if(preg_match("/date_evenement/",$row['regle_date_transmission_parquet'])){ |
4074 |
|
$valF['date_transmission_parquet']= $this->regle($row['regle_date_transmission_parquet'], 'regle_date_transmission_parquet'); |
4075 |
|
} |
4076 |
|
if ($row['regle_donnees_techniques1'] !== '') { |
4077 |
|
$valF_dt[$row['cible_regle_donnees_techniques1']] = $this->regle($row['regle_donnees_techniques1'], 'regle_donnees_techniques1'); |
4078 |
|
} |
4079 |
|
if ($row['regle_donnees_techniques2'] !== '') { |
4080 |
|
$valF_dt[$row['cible_regle_donnees_techniques2']] = $this->regle($row['regle_donnees_techniques2'], 'regle_donnees_techniques2'); |
4081 |
|
} |
4082 |
|
if ($row['regle_donnees_techniques3'] !== '') { |
4083 |
|
$valF_dt[$row['cible_regle_donnees_techniques3']] = $this->regle($row['regle_donnees_techniques3'], 'regle_donnees_techniques3'); |
4084 |
|
} |
4085 |
|
if ($row['regle_donnees_techniques4'] !== '') { |
4086 |
|
$valF_dt[$row['cible_regle_donnees_techniques4']] = $this->regle($row['regle_donnees_techniques4'], 'regle_donnees_techniques4'); |
4087 |
|
} |
4088 |
|
if ($row['regle_donnees_techniques5'] !== '') { |
4089 |
|
$valF_dt[$row['cible_regle_donnees_techniques5']] = $this->regle($row['regle_donnees_techniques5'], 'regle_donnees_techniques5'); |
4090 |
|
} |
4091 |
|
if ($row['regle_dossier_instruction_type'] !== '') { |
4092 |
|
$valF['dossier_instruction_type'] = $this->regle($row['regle_dossier_instruction_type'], 'regle_dossier_instruction_type'); |
4093 |
|
} |
4094 |
|
} |
4095 |
|
// Si des valeurs de données techniques ont été calculées alors on met à jour l'enregistrement |
4096 |
|
if (count($valF_dt) > 0) { |
4097 |
|
$dt_id = $this->getDonneesTechniques(); |
4098 |
|
// On met à jour le dossier |
4099 |
|
$cle = " donnees_techniques='".$dt_id."'"; |
4100 |
|
$res1 = $this->f->db->autoExecute(DB_PREFIXE.'donnees_techniques', $valF_dt, DB_AUTOQUERY_UPDATE, $cle); |
4101 |
|
$this->addToLog( |
4102 |
|
__METHOD__."(): db->autoexecute(\"".DB_PREFIXE."donnees_techniques\", ".print_r($valF_dt, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", |
4103 |
|
VERBOSE_MODE |
4104 |
|
); |
4105 |
|
$this->f->isDatabaseError($res1); |
4106 |
|
// Affichage d'informations à l'utilisateur |
4107 |
|
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$this->f->db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
4108 |
|
} |
4109 |
|
// Si des valeurs ont été calculées alors on met à jour l'enregistrement |
4110 |
|
if (count($valF) > 0) { |
4111 |
|
$inst_dossier = $this->f->get_inst__om_dbform(array( |
4112 |
|
"obj" => "dossier", |
4113 |
|
"idx" => $this->valF['dossier'], |
4114 |
|
)); |
4115 |
|
$valF['instruction'] = $id; |
4116 |
|
$valF['crud'] = 'update'; |
4117 |
|
$update_by_instruction = $inst_dossier->update_by_instruction($valF); |
4118 |
|
if ($update_by_instruction === false) { |
4119 |
|
$this->cleanMessage(); |
4120 |
|
$this->addToMessage(sprintf('%s %s', __("Une erreur s'est produite lors de la mise à jour du dossier d'instruction."), __("Veuillez contacter votre administrateur."))); |
4121 |
|
return false; |
4122 |
|
} |
4123 |
|
// Affichage d'informations à l'utilisateur |
4124 |
|
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$this->f->db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
4125 |
} |
} |
|
// Affichage d'informations à l'utilisateur |
|
|
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
|
4126 |
} |
} |
4127 |
|
|
4128 |
$restriction = $this->get_restriction($val['evenement']); |
$restriction = $this->get_restriction($val['evenement']); |
4132 |
// 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é |
4133 |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
4134 |
WHERE evenement=".$this->valF['evenement']; |
WHERE evenement=".$this->valF['evenement']; |
4135 |
$res = $db->query($sql); |
$res = $this->f->db->query($sql); |
4136 |
$this->addToLog("triggermodifierapres(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
4137 |
if (database::isError($res)) { |
$this->f->isDatabaseError($res); |
|
die($res->getMessage()); |
|
|
} |
|
4138 |
$current_id = $this->getVal($this->clePrimaire); |
$current_id = $this->getVal($this->clePrimaire); |
4139 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
4140 |
// 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 |
4141 |
if ($this->getVal('date_retour_signature') == "" AND |
if ($this->getVal('date_retour_signature') == "" AND |
4142 |
$this->valF['date_retour_signature'] != "" AND |
$this->valF['date_retour_signature'] != "" AND |
4143 |
$row['evenement_retour_signature'] != "") { |
$row['evenement_retour_signature'] != "") { |
4144 |
$new_instruction = new instruction("]", $db, $DEBUG); |
$new_instruction = $this->f->get_inst__om_dbform(array( |
4145 |
|
"obj" => "instruction", |
4146 |
|
"idx" => "]", |
4147 |
|
)); |
4148 |
// Création d'un tableau avec la liste des champs de l'instruction |
// Création d'un tableau avec la liste des champs de l'instruction |
4149 |
foreach($new_instruction->champs as $champ) { |
foreach($new_instruction->champs as $champ) { |
4150 |
$valNewInstr[$champ] = ""; |
$valNewInstr[$champ] = ""; |
4162 |
$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']); |
4163 |
$new_instruction->setParameter("maj", 0); |
$new_instruction->setParameter("maj", 0); |
4164 |
$new_instruction->class_actions[0]["identifier"] = |
$new_instruction->class_actions[0]["identifier"] = |
4165 |
"retour signature de l'instruction $current_id"; |
sprintf( |
4166 |
$retour = $new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
__("Ajout suite au retour signature de l'instruction %s"), |
4167 |
|
$current_id |
4168 |
|
); |
4169 |
|
$retour = $new_instruction->ajouter($valNewInstr); |
4170 |
|
|
4171 |
//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 |
4172 |
//de restriction |
//de restriction |
4173 |
if ($retour == false && !$new_instruction->restriction_valid){ |
if ($retour == false && !$new_instruction->restriction_valid){ |
4174 |
$error_message = $this->get_restriction_error_message($restriction); |
$error_message = $this->get_restriction_error_message($restriction); |
4175 |
$this->f->displayMessage("error", $error_message); |
$this->f->displayMessage("error", $error_message); |
4176 |
$this->addToLog("triggermodifierapres() : evenement retour ". |
$this->addToLog(__METHOD__."(): evenement retour ". |
4177 |
"instruction ".$this->valF[$this->clePrimaire]." : ". |
"instruction ".$this->valF[$this->clePrimaire]." : ". |
4178 |
$new_instruction->msg); |
$new_instruction->msg); |
4179 |
} |
} |
4189 |
$this->valF['date_retour_rar'] != "") { |
$this->valF['date_retour_rar'] != "") { |
4190 |
|
|
4191 |
if($row['evenement_retour_ar'] != "") { |
if($row['evenement_retour_ar'] != "") { |
4192 |
$new_instruction = new instruction("]", $db, $DEBUG); |
$new_instruction = $this->f->get_inst__om_dbform(array( |
4193 |
|
"obj" => "instruction", |
4194 |
|
"idx" => "]", |
4195 |
|
)); |
4196 |
// Création d'un tableau avec la liste des champs de l'instruction |
// Création d'un tableau avec la liste des champs de l'instruction |
4197 |
foreach($new_instruction->champs as $champ) { |
foreach($new_instruction->champs as $champ) { |
4198 |
$valNewInstr[$champ] = ""; |
$valNewInstr[$champ] = ""; |
4210 |
$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']); |
4211 |
$new_instruction->setParameter("maj", 0); |
$new_instruction->setParameter("maj", 0); |
4212 |
$new_instruction->class_actions[0]["identifier"] = |
$new_instruction->class_actions[0]["identifier"] = |
4213 |
"retour RAR de l'instruction $current_id"; |
sprintf(__("Ajout suite à la notification de l'instruction %s"), $current_id); |
4214 |
$retour = $new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
$retour = $new_instruction->ajouter($valNewInstr); |
4215 |
|
|
4216 |
//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 |
4217 |
//de restriction |
//de restriction |
4219 |
$error_message = $this->get_restriction_error_message($restriction); |
$error_message = $this->get_restriction_error_message($restriction); |
4220 |
$this->f->displayMessage("error", $error_message); |
$this->f->displayMessage("error", $error_message); |
4221 |
$this->addToLog( |
$this->addToLog( |
4222 |
"triggermodifierapres() : evenement retour instruction ". |
__METHOD__."(): evenement retour instruction ". |
4223 |
$this->valF[$this->clePrimaire]." : ". |
$this->valF[$this->clePrimaire]." : ". |
4224 |
$new_instruction->msg |
$new_instruction->msg |
4225 |
); |
); |
4231 |
return false; |
return false; |
4232 |
} |
} |
4233 |
} |
} |
4234 |
// Mise à jour du flag incomplet_notifie dans dossier si la |
} |
4235 |
// date limite d'instruction n'est pas dépassée |
} |
4236 |
if($row['type']=='incompletude' && |
} |
4237 |
($this->valF['archive_date_notification_delai'] >= $this->valF['date_retour_rar'] || |
|
4238 |
$this->valF['archive_date_notification_delai'] == "")) { |
// Traitement en cas de mise à jour du dossier |
4239 |
$valFIncomp['incomplet_notifie'] = true; |
if ($update_dossier === true) { |
4240 |
$cle = " dossier='".$val['dossier']."'"; |
/** |
4241 |
$resIncomp = $db->autoExecute( |
* Mise à jour de la date de dernière modification du dossier |
4242 |
DB_PREFIXE.'dossier', |
* d'instruction |
4243 |
$valFIncomp, |
*/ |
4244 |
DB_AUTOQUERY_UPDATE, |
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
4245 |
$cle |
$inst_di->update_last_modification_date(); |
4246 |
|
|
4247 |
|
// Mise à jour des données du dossier d'autorisation |
4248 |
|
$da = $this->f->get_inst__om_dbform(array( |
4249 |
|
"obj" => "dossier_autorisation", |
4250 |
|
"idx" => $this->getNumDemandeAutorFromDossier($this->valF['dossier']), |
4251 |
|
)); |
4252 |
|
$params = array( |
4253 |
|
'di_id' => $this->getVal('dossier'), |
4254 |
|
); |
4255 |
|
if($da->majDossierAutorisation($params) === false) { |
4256 |
|
$this->addToMessage(_("Erreur lors de la mise a jour des donnees du dossier d'autorisation. Contactez votre administrateur.")); |
4257 |
|
$this->correct = false; |
4258 |
|
return false; |
4259 |
|
} |
4260 |
|
} |
4261 |
|
|
4262 |
|
// mise à jour des métadonnées issues des dates de suivi |
4263 |
|
$dateRetourSignatureModified = ($this->valF['date_retour_signature'] != $this->getVal('date_retour_signature')); |
4264 |
|
$dateRetourRARModified = ($this->valF['date_retour_rar'] != $this->getVal('date_retour_rar')); |
4265 |
|
if ($dateRetourSignatureModified || $dateRetourRARModified) { |
4266 |
|
|
4267 |
|
// Calculs des nouvelles métadonnées |
4268 |
|
$metadata = $this->getMetadata("om_fichier_instruction"); |
4269 |
|
|
4270 |
|
// On vérifie si l'instruction à finaliser a un événement de type arrete |
4271 |
|
$sql = "SELECT type FROM ".DB_PREFIXE."evenement WHERE evenement = ".$this->getVal("evenement"); |
4272 |
|
$typeEvenement = $this->f->db->getOne($sql); |
4273 |
|
$this->addToLog(__METHOD__."(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
4274 |
|
if ($this->f->isDatabaseError($typeEvenement, true) === true) { |
4275 |
|
$this->correct = false; |
4276 |
|
$this->addToMessage(__("Erreur de traitement de fichier.")); |
4277 |
|
$this->addToLog(__METHOD__."() erreur BDD: ".var_export($typeEvenement->getMessage(), true), DEBUG_MODE); |
4278 |
|
return false; |
4279 |
|
} |
4280 |
|
|
4281 |
|
// Si l'événement est de type arrete, on ajoute les métadonnées spécifiques |
4282 |
|
if ($typeEvenement == 'arrete'){ |
4283 |
|
$metadata = array_merge($metadata, $this->getMetadata("arrete")); |
4284 |
|
} |
4285 |
|
|
4286 |
|
// Filtre pour conserver uniquement les métadonnées liées aux dates |
4287 |
|
$metadataToKeep = array( |
4288 |
|
"statutAutorisation", |
4289 |
|
"dateEvenementDocument", |
4290 |
|
'date_cloture_metier', |
4291 |
|
"NotificationArrete", |
4292 |
|
"dateNotificationArrete", |
4293 |
|
"controleLegalite", |
4294 |
|
"dateSignature", |
4295 |
|
"nomSignataire", |
4296 |
|
"qualiteSignataire", |
4297 |
|
"dateControleLegalite", |
4298 |
|
); |
4299 |
|
$metadata = array_filter( |
4300 |
|
$metadata, |
4301 |
|
function($key) use ($metadataToKeep) { return in_array($key, $metadataToKeep); }, |
4302 |
|
ARRAY_FILTER_USE_KEY |
4303 |
|
); |
4304 |
|
|
4305 |
|
// Mise à jour des métadonnées du document en GED |
4306 |
|
$docUid = $this->getVal("om_fichier_instruction"); |
4307 |
|
$operationOrUID = $this->f->storage->update_metadata($docUid, $metadata); |
4308 |
|
if ($operationOrUID == 'OP_FAILURE') { |
4309 |
|
$this->correct = false; |
4310 |
|
$this->addToMessage(__("Erreur de traitement de fichier.")); |
4311 |
|
$this->addToLog(__METHOD__."() failed to update metadata: ".var_export($operationOrUID, true), DEBUG_MODE); |
4312 |
|
return false; |
4313 |
|
} |
4314 |
|
|
4315 |
|
// mise à jour de l'UID du document en BDD |
4316 |
|
else { |
4317 |
|
$valF = array('om_fichier_instruction' => $operationOrUID); |
4318 |
|
$res = $this->f->db->autoExecute(DB_PREFIXE.$this->table, $valF, DB_AUTOQUERY_UPDATE, $this->getCle($id)); |
4319 |
|
$this->addToLog(__METHOD__.'() : db->autoExecute("'.DB_PREFIXE.$this->table.'", '.print_r($valF, true).', DB_AUTOQUERY_UPDATE, "'.$this->getCle($id).'")', VERBOSE_MODE); |
4320 |
|
if ($this->f->isDatabaseError($res, true) === true) { |
4321 |
|
$this->correct = false; |
4322 |
|
$this->addToMessage(__("Erreur de traitement de fichier.")); |
4323 |
|
$this->addToLog(__METHOD__."() erreur BDD: ".var_export($res->getMessage(), true), DEBUG_MODE); |
4324 |
|
return false; |
4325 |
|
} |
4326 |
|
$this->addToMessage(__("La mise a jour du document s'est effectuee avec succes.")); |
4327 |
|
} |
4328 |
|
} |
4329 |
|
|
4330 |
|
// Déclenchement des notifications automatique après finalisation et |
4331 |
|
// retour de signature |
4332 |
|
if ($dateRetourSignatureModified === true |
4333 |
|
&& $this->valF['date_retour_signature'] !== '' |
4334 |
|
&& $this->valF['date_retour_signature'] !== null) { |
4335 |
|
|
4336 |
|
// Message à afficher dans les logs pour indiquer quelle notification a échouée |
4337 |
|
$msgLog = sprintf( |
4338 |
|
'%s %s : %d', |
4339 |
|
__('Erreur lors de la notification automatique du(des) pétitionnaire(s) après retour signature.'), |
4340 |
|
__('Instruction notifiée'), |
4341 |
|
$id |
4342 |
|
); |
4343 |
|
|
4344 |
|
// Récupération de l'instance de l'événement pour accéder au paramètrage |
4345 |
|
// des notifications |
4346 |
|
$ev = $this->get_inst_evenement($this->valF['evenement']); |
4347 |
|
// Si la notification automatique des tiers consulté est active |
4348 |
|
// déclenche le traitement de notification. |
4349 |
|
// Ce traitement va envoyer des courriels de notification à tous les tiers concernés |
4350 |
|
$typeNotifTiers = $ev->getVal('notification_tiers'); |
4351 |
|
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
4352 |
|
if ($typeNotifTiers === 'notification_automatique') { |
4353 |
|
if ($this->traitement_notification_automatique_tiers_consulte($ev, $inst_di) === false) { |
4354 |
|
$this->addToMessage(__('Le traitement de la notification automatique de tiers à échoué.')); |
4355 |
|
$this->correct = false; |
4356 |
|
} |
4357 |
|
} |
4358 |
|
|
4359 |
|
if ($ev->getVal('notification') === 'notification_auto_signature_requise') { |
4360 |
|
// Récupération de la liste des demandeurs à notifier et de la catégorie |
4361 |
|
$categorie = $this->f->get_param_option_notification($collectivite_di); |
4362 |
|
$isPortal = $categorie == null || $categorie == '' || $categorie == PORTAL ? true : false; |
4363 |
|
$demandeursANotifie = $this->get_demandeurs_notifiable( |
4364 |
|
$this->valF['dossier'], |
4365 |
|
$isPortal |
4366 |
|
); |
4367 |
|
|
4368 |
|
// Création d'une notification et d'une tâche pour chaque demandeur à notifier |
4369 |
|
$demandeurPrincipalNotifie = false; |
4370 |
|
foreach ($demandeursANotifie as $demandeur) { |
4371 |
|
// Identifie si le demandeur principal a été notifié ou pas |
4372 |
|
// et récupère ses informations |
4373 |
|
if ($demandeur['petitionnaire_principal'] == 't') { |
4374 |
|
$demandeurPrincipalNotifie = true; |
4375 |
|
// Si le demandeur principal est notifiable mais qu'il y a des erreurs dans |
4376 |
|
// son paramétrage, on effectue pas le traitement et on passe à l'itération |
4377 |
|
// suivante. On le considère également comme non notifié pour gérer l'envoie |
4378 |
|
// des messages d'erreurs |
4379 |
|
// Si la demande a été déposée via le portail alors le paramétrage n'a pas |
4380 |
|
// d'impact sur la notification |
4381 |
|
$erreursParam = $this->get_info_notification_fail(); |
4382 |
|
if (! $this->dossier_depose_sur_portail() && $erreursParam != array()) { |
4383 |
|
$demandeurPrincipalNotifie = false; |
4384 |
|
continue; |
4385 |
|
} |
4386 |
|
} |
4387 |
|
// Ajout de la notif et récupération de son id |
4388 |
|
$idNotif = $this->ajouter_notification( |
4389 |
|
$this->valF[$this->clePrimaire], |
4390 |
|
$this->f->get_connected_user_login_name(), |
4391 |
|
$demandeur, |
4392 |
|
$collectivite_di, |
4393 |
|
array(), |
4394 |
|
true |
4395 |
|
); |
4396 |
|
if ($idNotif === false) { |
4397 |
|
$this->addToLog( |
4398 |
|
sprintf('%s() : %s',__METHOD__, $msgLog), |
4399 |
|
DEBUG_MODE |
4400 |
); |
); |
4401 |
|
return false; |
4402 |
|
} |
4403 |
|
// Création de la tache en lui donnant l'id de la notification |
4404 |
|
$notification_by_task = $this->notification_by_task( |
4405 |
|
$idNotif, |
4406 |
|
$this->valF['dossier'], |
4407 |
|
$categorie |
4408 |
|
); |
4409 |
|
if ($notification_by_task === false) { |
4410 |
$this->addToLog( |
$this->addToLog( |
4411 |
"triggersupprimer(): db->autoexecute(\"". |
sprintf('%s() : %s',__METHOD__, $msgLog), |
4412 |
DB_PREFIXE."dossier\", ".print_r($valFIncomp, true). |
DEBUG_MODE |
|
", DB_AUTOQUERY_UPDATE, \"".$cle."\");", |
|
|
VERBOSE_MODE |
|
4413 |
); |
); |
4414 |
if (database::isError($resIncomp)) { |
$this->addToMessage( |
4415 |
die($resIncomp->getMessage()); |
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
4416 |
} |
); |
4417 |
|
return false; |
4418 |
} |
} |
4419 |
} |
} |
4420 |
|
// Pour la notification par mail ou la notification via portal si le dossier a |
4421 |
|
// été déposés via portal, si le demandeur principal n'est pas notifiable, |
4422 |
|
// on créé une nouvelle notification en erreur avec en commentaire la raison pour |
4423 |
|
// laquelle le demandeur principal n'a pas pu être notifié |
4424 |
|
$depotPortal = $this->dossier_depose_sur_portail(); |
4425 |
|
if (! $demandeurPrincipalNotifie && ($isPortal === false || $depotPortal === true)) { |
4426 |
|
// Précise dans les logs que le pétitionnaire principal n'a pas été notifié |
4427 |
|
$msgLog .= sprintf(' %s', __('Le pétitionnaire principale n\'est pas notifiable.')); |
4428 |
|
// Analyse pour savoir pourquoi le demandeur principal n'est pas notifiable |
4429 |
|
$erreursParam = $this->get_info_notification_fail(); |
4430 |
|
$demandeurPrincipal = $this->get_info_petitionnaire_principal_dossier($this->getVal('dossier')); |
4431 |
|
// Ajout de la notif et récupération de son id |
4432 |
|
$idNotif = $this->ajouter_notification( |
4433 |
|
$this->valF[$this->clePrimaire], |
4434 |
|
$this->f->get_connected_user_login_name(), |
4435 |
|
$demandeurPrincipal, |
4436 |
|
$collectivite_di, |
4437 |
|
array(), |
4438 |
|
true, |
4439 |
|
'Echec', |
4440 |
|
implode(' ', $erreursParam) |
4441 |
|
); |
4442 |
|
if ($idNotif === false) { |
4443 |
|
$this->addToLog( |
4444 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
4445 |
|
DEBUG_MODE |
4446 |
|
); |
4447 |
|
$this->addToMessage( |
4448 |
|
__('Erreur : la création de la notification a échouée.'). |
4449 |
|
__("Veuillez contacter votre administrateur.") |
4450 |
|
); |
4451 |
|
return false; |
4452 |
|
} |
4453 |
|
// Prépare un message d'alerte à destination de l'instructeur pour l'informer |
4454 |
|
// de l'échec de la notification |
4455 |
|
$dossier_message = $this->get_inst_dossier_message(0); |
4456 |
|
$dossier_message_val = array( |
4457 |
|
'dossier' => $this->getVal('dossier'), |
4458 |
|
'type' => _('erreur expedition'), |
4459 |
|
'emetteur' => $this->f->get_connected_user_login_name(), |
4460 |
|
'login' => $_SESSION['login'], |
4461 |
|
'date_emission' => date('Y-m-d H:i:s'), |
4462 |
|
'contenu' => _('Échec lors de la notification de l\'instruction '). |
4463 |
|
$ev->getVal('libelle'). |
4464 |
|
'.<br>'. |
4465 |
|
implode("\n", $erreursParam). |
4466 |
|
'<br>'. |
4467 |
|
_('Veuillez corriger ces informations avant de renvoyer la notification.') |
4468 |
|
); |
4469 |
|
$add = $dossier_message->add_notification_message($dossier_message_val, true); |
4470 |
|
// Si une erreur se produit pendant l'ajout |
4471 |
|
if ($add !== true) { |
4472 |
|
$this->addToLog( |
4473 |
|
sprintf( |
4474 |
|
'%s() : %s', |
4475 |
|
__METHOD__, |
4476 |
|
__("Le message d'alerte concernant l'echec de l'envoi de la notification n'a pas pu être envoyé.") |
4477 |
|
), |
4478 |
|
DEBUG_MODE |
4479 |
|
); |
4480 |
|
return false; |
4481 |
|
} |
4482 |
|
} |
4483 |
|
$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."))); |
4484 |
} |
} |
4485 |
} |
} |
4486 |
|
|
|
// Mise à jour des données du dossier d'autorisation |
|
|
require_once "../obj/dossier_autorisation.class.php"; |
|
|
$da = new dossier_autorisation($this->getNumDemandeAutorFromDossier($this->valF['dossier']), $this->db, DEBUG); |
|
|
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; |
|
|
} |
|
4487 |
return $this->add_log_to_dossier($id, $val); |
return $this->add_log_to_dossier($id, $val); |
4488 |
} |
} |
4489 |
|
|
4490 |
function triggersupprimer($id,&$db,$val,$DEBUG) { |
/** |
4491 |
|
* TRIGGER - triggersupprimer. |
4492 |
|
* |
4493 |
|
* @return boolean |
4494 |
|
*/ |
4495 |
|
function triggersupprimer($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
4496 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
4497 |
/** |
/** |
4498 |
* 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 |
4499 |
* archive dans le dossier d'instruction avant de supprimer l'événement |
* archive dans le dossier d'instruction avant de supprimer l'événement |
4500 |
* d'instruction |
* d'instruction si les valeurs du dossier sont différentes |
4501 |
*/ |
*/ |
4502 |
|
$valF = array(); |
4503 |
// Mise à jour des 4 valeurs modifiées par l'action |
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
4504 |
$valF['delai'] = $val['archive_delai']; |
foreach ($inst_di->champs as $key => $champ) { |
4505 |
$valF['accord_tacite'] = $val['archive_accord_tacite']; |
// Si le champ du DI à une archive dans l'instruction |
4506 |
$valF['etat'] = $val['archive_etat']; |
if (isset($val[sprintf('archive_%s', $champ)]) === true) { |
4507 |
if ($val['archive_avis'] != '') { |
// Si la valeur entre le champ du DI et son archive dans instruction |
4508 |
$valF['avis_decision'] = $val['archive_avis']; |
// est différente |
4509 |
} else { |
if ($inst_di->getVal($champ) !== $val[sprintf('archive_%s', $champ)]) { |
4510 |
$valF['avis_decision'] = null; |
$val[sprintf('archive_%s', $champ)] === '' ? $valF[$champ] = null : $valF[$champ] = $val[sprintf('archive_%s', $champ)]; |
4511 |
} |
} |
4512 |
// Mise à jour des dates avec la valeur présente dans le formulaire |
} |
|
// de suppression. Si la valeur de la date est vide alors on fixe |
|
|
// à la valeur null |
|
|
if ($val['archive_date_complet'] != '') { |
|
|
$valF['date_complet'] = $val['archive_date_complet']; |
|
|
} 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; |
|
4513 |
} |
} |
4514 |
$valF['date_cloture_instruction'] = null; |
// Spécificité du champ avis_decision dont le champ archive est nommé |
4515 |
if ($val['archive_date_cloture_instruction'] !== '') { |
// différemment |
4516 |
$valF['date_cloture_instruction'] = $val['archive_date_cloture_instruction']; |
if ($inst_di->getVal('avis_decision') !== $val['archive_avis']) { |
4517 |
|
$val['archive_avis'] === '' ? $valF['avis_decision'] = null : $valF['avis_decision'] = $val['archive_avis']; |
4518 |
|
} |
4519 |
|
// Spécificité de la date d'affichage dont la valeur n'ai jamais modifiée |
4520 |
|
// par l'archive |
4521 |
|
unset($valF['date_affichage']); |
4522 |
|
|
4523 |
|
/** |
4524 |
|
* Mise à jour de la version de clôture *version_clos* du dossier si et |
4525 |
|
* seulement si l'instruction met à jour l'état du dossier. |
4526 |
|
*/ |
4527 |
|
if (isset($valF['etat']) === true |
4528 |
|
&& $valF['etat'] !== null |
4529 |
|
&& $valF['etat'] !== '') { |
4530 |
|
// Récupère l'état actuel du dossier d'instruction |
4531 |
|
$inst_current_etat = $this->f->get_inst__om_dbform(array( |
4532 |
|
"obj" => "etat", |
4533 |
|
"idx" => $inst_di->get_id_etat(), |
4534 |
|
)); |
4535 |
|
// Instanciation de l'état archivé appliqué sur le dossier |
4536 |
|
$inst_etat = $this->f->get_inst__om_dbform(array( |
4537 |
|
"obj" => "etat", |
4538 |
|
"idx" => $valF['etat'], |
4539 |
|
)); |
4540 |
|
// |
4541 |
|
$update_version_clos = null; |
4542 |
|
// En cas de clôture du dossier par l'état archivé |
4543 |
|
if ($inst_etat->getVal('statut') === 'cloture') { |
4544 |
|
$update_version_clos = $inst_di->update_version_clos('up'); |
4545 |
|
} |
4546 |
|
// En cas de réouverture du dossier par l'état archivé |
4547 |
|
if ($inst_current_etat->getVal('statut') === 'cloture' |
4548 |
|
&& $inst_etat->getVal('statut') !== 'cloture') { |
4549 |
|
// |
4550 |
|
$update_version_clos = $inst_di->update_version_clos('down'); |
4551 |
|
// |
4552 |
|
$this->set_att_di_reopened(true); |
4553 |
|
} |
4554 |
|
// |
4555 |
|
if ($update_version_clos === false) { |
4556 |
|
$this->f->addToLog(sprintf( |
4557 |
|
"%s() : ERREUR - %s %s", |
4558 |
|
__METHOD__, |
4559 |
|
sprintf( |
4560 |
|
__("Impossible de mettre à jour la version de clôture du dossier d'instruction %s."), |
4561 |
|
$inst_di->getVal($inst_di->clePrimaire) |
4562 |
|
), |
4563 |
|
sprintf( |
4564 |
|
__("L'instruction tente d'appliquer l'état %s."), |
4565 |
|
$inst_etat->getVal($inst_etat->clePrimaire) |
4566 |
|
) |
4567 |
|
)); |
4568 |
|
$this->addToMessage(sprintf( |
4569 |
|
"%s %s", |
4570 |
|
__("Erreur lors de la mise à jour de la version de clôture du dossier d'instruction."), |
4571 |
|
__("Veuillez contacter votre administrateur.") |
4572 |
|
)); |
4573 |
|
return false; |
4574 |
|
} |
4575 |
} |
} |
4576 |
// Dates concernant les dossiers contentieux |
// On supprime toutes les notications liées à l'instruction |
4577 |
// Date de première visite |
$notifASupprimer = $this->get_instruction_notification( |
4578 |
$valF['date_premiere_visite'] = null; |
$this->getVal($this->clePrimaire), |
4579 |
if ($val['archive_date_premiere_visite'] !== '') { |
array( |
4580 |
$valF['date_premiere_visite'] = $val['archive_date_premiere_visite']; |
'notification_recepisse', |
4581 |
} |
'notification_instruction', |
4582 |
// Date de dernière visite |
'notification_decision', |
4583 |
$valF['date_derniere_visite'] = null; |
'notification_service_consulte', |
4584 |
if ($val['archive_date_derniere_visite'] !== '') { |
'notification_tiers_consulte', |
4585 |
$valF['date_derniere_visite'] = $val['archive_date_derniere_visite']; |
'notification_depot_demat', |
4586 |
} |
'notification_commune' |
4587 |
// Date contradictoire |
), |
4588 |
$valF['date_contradictoire'] = null; |
true |
4589 |
if ($val['archive_date_contradictoire'] !== '') { |
); |
4590 |
$valF['date_contradictoire'] = $val['archive_date_contradictoire']; |
|
4591 |
} |
foreach ($notifASupprimer as $idNotif) { |
4592 |
// Date de retour contradictoire |
$inst_notif = $this->f->get_inst__om_dbform(array( |
4593 |
$valF['date_retour_contradictoire'] = null; |
"obj" => "instruction_notification", |
4594 |
if ($val['archive_date_retour_contradictoire'] !== '') { |
"idx" => $idNotif, |
4595 |
$valF['date_retour_contradictoire'] = $val['archive_date_retour_contradictoire']; |
)); |
4596 |
} |
$val_notif = array(); |
4597 |
// Date de l'AIT |
foreach ($inst_notif->champs as $champ) { |
4598 |
$valF['date_ait'] = null; |
$val_notif[$champ] = $inst_notif->getVal($champ); |
4599 |
if ($val['archive_date_ait'] !== '') { |
} |
4600 |
$valF['date_ait'] = $val['archive_date_ait']; |
// La suppression des notifications entrainera la suppression des tâches qui y sont |
4601 |
} |
// liées |
4602 |
// Date de transmission au parquet |
$supprNotif = $inst_notif->supprimer($val_notif); |
4603 |
$valF['date_transmission_parquet'] = null; |
if ($supprNotif == false) { |
4604 |
if ($val['archive_date_transmission_parquet'] !== '') { |
$this->addToMessage(sprintf( |
4605 |
$valF['date_transmission_parquet'] = $val['archive_date_transmission_parquet']; |
"%s %s", |
4606 |
|
__("Erreur lors de la suppression des notifications de l'instruction."), |
4607 |
|
__("Veuillez contacter votre administrateur.") |
4608 |
|
)); |
4609 |
|
return false; |
4610 |
|
} |
4611 |
} |
} |
4612 |
|
|
4613 |
// On met à jour le dossier |
// On met à jour le dossier |
4614 |
$cle = " dossier='".$val['dossier']."'"; |
$valF['instruction'] = $id; |
4615 |
$res = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle); |
$valF['crud'] = 'delete'; |
4616 |
$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); |
4617 |
if (database::isError($res)) { |
if ($update_by_instruction === false) { |
4618 |
die($res->getMessage()); |
$this->cleanMessage(); |
4619 |
|
$this->addToMessage(sprintf('%s %s', __("Une erreur s'est produite lors de la mise à jour du dossier d'instruction."), __("Veuillez contacter votre administrateur."))); |
4620 |
|
return false; |
4621 |
} |
} |
4622 |
|
|
4623 |
// Affichage d'informations à l'utilisateur |
// Affichage d'informations à l'utilisateur |
4624 |
$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')."]"); |
4625 |
|
|
4626 |
// 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 |
4627 |
} |
} |
4628 |
|
|
4629 |
function triggersupprimerapres($id,&$db,$val,$DEBUG) { |
/** |
4630 |
|
* TRIGGER - triggersupprimerapres. |
4631 |
|
* |
4632 |
|
* @return boolean |
4633 |
|
*/ |
4634 |
|
function triggersupprimerapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
4635 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
4636 |
|
/** |
4637 |
|
* Mise à jour de la date de dernière modification du dossier |
4638 |
|
* d'instruction |
4639 |
|
*/ |
4640 |
|
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
4641 |
|
$inst_di->update_last_modification_date(); |
4642 |
|
|
4643 |
// Mise à jour des données du dossier d'autorisation |
/** |
4644 |
require_once "../obj/dossier_autorisation.class.php"; |
* Mise à jour des données du dossier d'autorisation |
4645 |
$da = new dossier_autorisation($this->getNumDemandeAutorFromDossier($val["dossier"]), $this->db, DEBUG); |
*/ |
4646 |
if($da->majDossierAutorisation() === false) { |
$da = $this->f->get_inst__om_dbform(array( |
4647 |
|
"obj" => "dossier_autorisation", |
4648 |
|
"idx" => $this->getNumDemandeAutorFromDossier($val["dossier"]), |
4649 |
|
)); |
4650 |
|
$params = array( |
4651 |
|
'di_id' => $this->getVal('dossier'), |
4652 |
|
'di_reopened' => $this->get_att_di_reopened(), |
4653 |
|
); |
4654 |
|
if($da->majDossierAutorisation($params) === false) { |
4655 |
$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.")); |
4656 |
$this->correct = false; |
$this->correct = false; |
4657 |
return false; |
return false; |
4658 |
} |
} |
4659 |
|
|
4660 |
|
/** |
4661 |
|
* Gestion des tâches pour la dématérialisation |
4662 |
|
*/ |
4663 |
|
$inst_task_empty = $this->f->get_inst__om_dbform(array( |
4664 |
|
"obj" => "task", |
4665 |
|
"idx" => 0, |
4666 |
|
)); |
4667 |
|
foreach ($inst_di->task_types as $task_type) { |
4668 |
|
$task_exists = $inst_task_empty->task_exists($task_type, $id); |
4669 |
|
if ($task_exists !== false) { |
4670 |
|
$inst_task = $this->f->get_inst__om_dbform(array( |
4671 |
|
"obj" => "task", |
4672 |
|
"idx" => $task_exists, |
4673 |
|
)); |
4674 |
|
if ($inst_task->getVal('state') === $inst_task::STATUS_NEW || $inst_task->getVal('state') === $inst_task::STATUS_DRAFT) { |
4675 |
|
$task_val = array( |
4676 |
|
'state' => $inst_task::STATUS_CANCELED, |
4677 |
|
); |
4678 |
|
$update_task = $inst_task->update_task(array('val' => $task_val)); |
4679 |
|
if ($update_task === false) { |
4680 |
|
$this->addToMessage(sprintf('%s %s', |
4681 |
|
sprintf(__("Une erreur s'est produite lors de la modification de la tâche %."), $inst_task->getVal($inst_task->clePrimaire)), |
4682 |
|
__("Veuillez contacter votre administrateur.") |
4683 |
|
)); |
4684 |
|
$this->correct = false; |
4685 |
|
return false; |
4686 |
|
} |
4687 |
|
} |
4688 |
|
} |
4689 |
|
} |
4690 |
|
|
4691 |
|
// |
4692 |
$val['evenement'] = $this->getVal('evenement'); |
$val['evenement'] = $this->getVal('evenement'); |
4693 |
return $this->add_log_to_dossier($id, $val); |
return $this->add_log_to_dossier($id, $val); |
4694 |
} |
} |
4695 |
|
|
4696 |
/** |
/** |
4697 |
|
* Permet de mettre la valeur passée en paramètre dans l'attribut de classe |
4698 |
|
* "di_reopened". |
4699 |
|
* |
4700 |
|
* @param boolean $val |
4701 |
|
*/ |
4702 |
|
function set_att_di_reopened($val) { |
4703 |
|
$this->di_reopened = $val; |
4704 |
|
} |
4705 |
|
|
4706 |
|
/** |
4707 |
|
* Permet de récupérer la valeur de l'attribut de classe "di_reopened". |
4708 |
|
* |
4709 |
|
* @return boolean |
4710 |
|
*/ |
4711 |
|
function get_att_di_reopened() { |
4712 |
|
return $this->di_reopened; |
4713 |
|
} |
4714 |
|
|
4715 |
|
/** |
4716 |
* Permet de composer un message d'erreur sur restriction non valide en |
* Permet de composer un message d'erreur sur restriction non valide en |
4717 |
* fonction du contexte. |
* fonction du contexte. |
4718 |
* |
* |
4751 |
} |
} |
4752 |
|
|
4753 |
/** |
/** |
4754 |
* Vérifie la restriction sur l'événement. |
* Surcharge de la méthode verifier() de la classe om_dbform pour y ajouter |
4755 |
* |
* les vérifications suivantes : |
4756 |
* @param array $val valeurs du formulaire |
* - Si l'instruction à un événement associé et que cet événement à des restrictions : |
4757 |
* @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 |
4758 |
* @param boolean $DEBUG NA |
* le message d'erreur associé à la restriction |
4759 |
|
* 2. vérifie si les restrictions sont respectées. Si ce n'est pas le cas bloque l'ajout |
4760 |
|
* et / ou la modification et affiche un message d'erreur |
4761 |
|
* - |
4762 |
|
* - |
4763 |
|
* - |
4764 |
|
* - |
4765 |
|
* - |
4766 |
|
* - |
4767 |
|
* |
4768 |
|
* @param array val : tableau contenant les valeurs issues du formulaire. |
4769 |
|
* @param - dnu1 : Paramètre déprécié et non utilisé. |
4770 |
|
* @param - dnu2 : Paramètre déprécié et non utilisé. |
4771 |
* |
* |
4772 |
* @return [type] [description] |
* @return void |
4773 |
*/ |
*/ |
4774 |
function verifier($val = array(), &$db, $DEBUG) { |
function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
4775 |
parent::verifier($val, $db, $DEBUG); |
parent::verifier($val); |
4776 |
|
// |
4777 |
if ( isset($val['evenement']) && is_numeric($val['evenement'])){ |
if ( isset($val['evenement']) && is_numeric($val['evenement'])){ |
4778 |
$restriction = $this->get_restriction($val['evenement']); |
$restriction = $this->get_restriction($val['evenement']); |
4779 |
|
|
4850 |
} |
} |
4851 |
|
|
4852 |
} |
} |
4853 |
|
|
4854 |
|
/** |
4855 |
|
* Récupère et stocket dans un tableau toutes les infos du pétitionnaire |
4856 |
|
* principal du dossier auquel appartiens l'instruction. |
4857 |
|
* Renvoie un tableau contenant les informations du pétitionnaire principal. |
4858 |
|
* |
4859 |
|
* Si l'identifiant de l'instruction n'a pas pu etre récupéré renvoie false |
4860 |
|
* et affiche un message dans les logs. |
4861 |
|
* En cas d'erreur de base de donnée renvoie false et affiche un message d'erreur. |
4862 |
|
* |
4863 |
|
* @param string identifiant du dossier |
4864 |
|
* @return array|boolean |
4865 |
|
*/ |
4866 |
|
protected function get_info_petitionnaire_principal_dossier($dossier = null) { |
4867 |
|
// Si l'identifiant de l'instruction n'a pas été fournit on récupère celui de |
4868 |
|
// l'objet courant |
4869 |
|
if (empty($dossier)) { |
4870 |
|
$dossier = $this->getVal('dossier'); |
4871 |
|
// Si la récupération de l'identifiant de l'instruction a échoué la méthode renvoie |
4872 |
|
// false et on affiche un message d'erreur dans les logs |
4873 |
|
if (empty($dossier)) { |
4874 |
|
$this->addToLog(__METHOD__.' : L\'identifiant du dossier n\'a pas pu être récupéré'); |
4875 |
|
return false; |
4876 |
|
} |
4877 |
|
} |
4878 |
|
|
4879 |
|
// Requête sql servant à récupérer toutes les informations relatives au demandeurs |
4880 |
|
// principal |
4881 |
|
$qres = $this->f->get_all_results_from_db_query( |
4882 |
|
sprintf( |
4883 |
|
'SELECT |
4884 |
|
-- Récupère toutes les informations du demandeur principal |
4885 |
|
demandeur.*, |
4886 |
|
CASE |
4887 |
|
WHEN demandeur.qualite=\'particulier\' |
4888 |
|
THEN TRIM(CONCAT(demandeur.particulier_nom, \' \', demandeur.particulier_prenom, \' \', demandeur.courriel)) |
4889 |
|
ELSE |
4890 |
|
TRIM(CONCAT(demandeur.personne_morale_raison_sociale, \' \', demandeur.personne_morale_denomination, \' \', demandeur.courriel)) |
4891 |
|
END AS destinataire |
4892 |
|
FROM |
4893 |
|
%1$sdossier |
4894 |
|
LEFT JOIN %1$slien_dossier_demandeur |
4895 |
|
ON lien_dossier_demandeur.dossier = dossier.dossier |
4896 |
|
LEFT JOIN %1$sdemandeur |
4897 |
|
ON demandeur.demandeur = lien_dossier_demandeur.demandeur |
4898 |
|
WHERE |
4899 |
|
dossier.dossier = \'%2$s\' |
4900 |
|
AND lien_dossier_demandeur.petitionnaire_principal IS TRUE', |
4901 |
|
DB_PREFIXE, |
4902 |
|
$this->f->db->escapeSimple($dossier) |
4903 |
|
), |
4904 |
|
array( |
4905 |
|
"origin" => __METHOD__, |
4906 |
|
) |
4907 |
|
); |
4908 |
|
if (is_array($qres["result"]) === true |
4909 |
|
&& array_key_exists(0, $qres["result"]) === true) { |
4910 |
|
// |
4911 |
|
return $qres["result"][0]; |
4912 |
|
} |
4913 |
|
return null; |
4914 |
|
} |
4915 |
|
|
4916 |
|
|
4917 |
|
|
4918 |
/** |
/** |
4919 |
* Finalisation des documents. |
* Finalisation des documents. |
4946 |
|
|
4947 |
// |
// |
4948 |
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
4949 |
|
|
4950 |
|
// |
4951 |
|
$params = array( |
4952 |
|
"specific" => array(), |
4953 |
|
); |
4954 |
|
// Si la rédaction libre est activée sur l'instruction |
4955 |
|
if ($this->getVal("flag_edition_integrale") == 't') { |
4956 |
|
$params["specific"]["corps"] = array( |
4957 |
|
"mode" => "set", |
4958 |
|
"value" => $this->getVal("corps_om_htmletatex"), |
4959 |
|
); |
4960 |
|
$params["specific"]["titre"] = array( |
4961 |
|
"mode" => "set", |
4962 |
|
"value" => $this->getVal("titre_om_htmletat"), |
4963 |
|
); |
4964 |
|
} |
4965 |
// Génération du PDF |
// Génération du PDF |
4966 |
$result = $this->compute_pdf_output('lettretype', $this->getVal('lettretype'), $collectivite); |
$result = $this->compute_pdf_output('lettretype', $this->getVal('lettretype'), $collectivite, null, $params); |
4967 |
$pdf_output = $result['pdf_output']; |
$pdf_output = $result['pdf_output']; |
4968 |
|
|
4969 |
//Métadonnées du document |
//Métadonnées du document |
4970 |
$metadata = array( |
$metadata = array( |
4971 |
'filename' => 'instruction_'.$id_inst.'.pdf', |
'filename' => 'instruction_'.$id_inst.'.pdf', |
4980 |
$sql = "SELECT type |
$sql = "SELECT type |
4981 |
FROM ".DB_PREFIXE."evenement |
FROM ".DB_PREFIXE."evenement |
4982 |
WHERE evenement = ".$this->getVal("evenement"); |
WHERE evenement = ".$this->getVal("evenement"); |
4983 |
$typeEvenement = $this->db->getOne($sql); |
$typeEvenement = $this->f->db->getOne($sql); |
4984 |
$this->addToLog(__METHOD__."(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
4985 |
if ($this->f->isDatabaseError($typeEvenement, true) === true) { |
if ($this->f->isDatabaseError($typeEvenement, true) === true) { |
4986 |
$this->correct = false; |
$this->correct = false; |
4997 |
|
|
4998 |
$metadata = array_merge($metadata, $spe_metadata, $arrete_metadata); |
$metadata = array_merge($metadata, $spe_metadata, $arrete_metadata); |
4999 |
|
|
5000 |
|
/* |
5001 |
|
// transforme le tableau de métadonnées en objet |
5002 |
|
$mdf = new MetadataFactory(); |
5003 |
|
$md = $mdf->build('Instruction', $metadata); |
5004 |
|
*/ |
5005 |
|
|
5006 |
// Si le document a déjà été finalisé on le met à jour |
// Si le document a déjà été finalisé on le met à jour |
5007 |
// en conservant son UID |
// en conservant son UID |
5008 |
if ($this->getVal("om_fichier_instruction") != ''){ |
if ($this->getVal("om_fichier_instruction") != ''){ |
5011 |
} |
} |
5012 |
// 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 |
5013 |
else { |
else { |
5014 |
$uid = $this->f->storage->create($pdf_output, $metadata); |
$uid = $this->f->storage->create($pdf_output, $metadata, "from_content", $this->table.".om_fichier_instruction"); |
5015 |
} |
} |
5016 |
} |
} |
5017 |
|
|
5028 |
if ($uid == '' || $uid == 'OP_FAILURE' ) { |
if ($uid == '' || $uid == 'OP_FAILURE' ) { |
5029 |
$this->correct = false; |
$this->correct = false; |
5030 |
$this->addToMessage($file_msg_error); |
$this->addToMessage($file_msg_error); |
5031 |
$this->addToLog(sprintf($log_msg_error, $id_inst, $uid)); |
$this->addToLog(sprintf($log_msg_error, $id_inst, $uid), DEBUG_MODE); |
5032 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
5033 |
} |
} |
5034 |
|
|
5065 |
$val['archive_date_retour_contradictoire'] = $this->dateDBToForm($val['archive_date_retour_contradictoire']); |
$val['archive_date_retour_contradictoire'] = $this->dateDBToForm($val['archive_date_retour_contradictoire']); |
5066 |
$val['archive_date_ait'] = $this->dateDBToForm($val['archive_date_ait']); |
$val['archive_date_ait'] = $this->dateDBToForm($val['archive_date_ait']); |
5067 |
$val['archive_date_transmission_parquet'] = $this->dateDBToForm($val['archive_date_transmission_parquet']); |
$val['archive_date_transmission_parquet'] = $this->dateDBToForm($val['archive_date_transmission_parquet']); |
5068 |
|
$val['archive_date_affichage'] = $this->dateDBToForm($val['archive_date_affichage']); |
5069 |
$this->setvalF($val); |
$this->setvalF($val); |
5070 |
|
|
5071 |
// Verification de la validite des donnees |
// Verification de la validite des donnees |
5072 |
$this->verifier($this->val, $this->db, DEBUG); |
$this->verifier($this->val); |
5073 |
// Si les verifications precedentes sont correctes, on procede a |
// Si les verifications precedentes sont correctes, on procede a |
5074 |
// la modification, sinon on ne fait rien et on retourne une erreur |
// la modification, sinon on ne fait rien et on retourne une erreur |
5075 |
if ($this->correct === true) { |
if ($this->correct === true) { |
5103 |
|
|
5104 |
// Execution de la requête de modification des donnees de l'attribut |
// Execution de la requête de modification des donnees de l'attribut |
5105 |
// valF de l'objet dans l'attribut table de l'objet |
// valF de l'objet dans l'attribut table de l'objet |
5106 |
$res = $this->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
$res = $this->f->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
5107 |
DB_AUTOQUERY_UPDATE, $this->getCle($id_inst)); |
DB_AUTOQUERY_UPDATE, $this->getCle($id_inst)); |
5108 |
$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); |
5109 |
// |
// |
5124 |
} |
} |
5125 |
// L'appel de verifier() a déjà positionné correct à false |
// L'appel de verifier() a déjà positionné correct à false |
5126 |
// et défini un message d'erreur. |
// et défini un message d'erreur. |
5127 |
$this->addToLog(sprintf($log_msg_error, $id_inst, $uid)); |
$this->addToLog(sprintf($log_msg_error, $id_inst, $uid), DEBUG_MODE); |
5128 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
5129 |
} |
} |
5130 |
|
|
5132 |
* 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 |
5133 |
* @return string numéro de dossier d'instruction |
* @return string numéro de dossier d'instruction |
5134 |
*/ |
*/ |
5135 |
protected function getDossier() { |
protected function getDossier($champ = null) { |
5136 |
if(empty($this->specificMetadata)) { |
if(empty($this->specificMetadata)) { |
5137 |
$this->getSpecificMetadata(); |
$this->getSpecificMetadata(); |
5138 |
} |
} |
5231 |
// Requête sql |
// Requête sql |
5232 |
$sql = "SELECT libelle FROM ".DB_PREFIXE."evenement |
$sql = "SELECT libelle FROM ".DB_PREFIXE."evenement |
5233 |
WHERE evenement=".$evenement; |
WHERE evenement=".$evenement; |
5234 |
$evenement_libelle = $this->db->getOne($sql); |
$evenement_libelle = $this->f->db->getone($sql); |
5235 |
$this->addToLog("getTitle(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
5236 |
if (database::isError($evenement_libelle)) { |
$this->f->isDatabaseError($evenement_libelle); |
|
die(); |
|
|
} |
|
|
|
|
5237 |
// Retourne le libelle de l'événement |
// Retourne le libelle de l'événement |
5238 |
return $evenement_libelle; |
return $evenement_libelle; |
5239 |
} |
} |
5290 |
LEFT JOIN ".DB_PREFIXE."groupe |
LEFT JOIN ".DB_PREFIXE."groupe |
5291 |
ON dossier_autorisation_type.groupe = groupe.groupe |
ON dossier_autorisation_type.groupe = groupe.groupe |
5292 |
WHERE dossier.dossier = '".$dossier."'"; |
WHERE dossier.dossier = '".$dossier."'"; |
5293 |
$res = $this->db->query($sql); |
$res = $this->f->db->query($sql); |
5294 |
$this->f->addToLog("getSpecificMetadata() : db->query(".$sql.")", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
5295 |
if ( database::isError($res)){ |
$this->f->isDatabaseError($res); |
|
die(); |
|
|
} |
|
|
|
|
5296 |
//Le résultat est récupéré dans un objet |
//Le résultat est récupéré dans un objet |
5297 |
$row =& $res->fetchRow(DB_FETCHMODE_OBJECT); |
$row =& $res->fetchRow(DB_FETCHMODE_OBJECT); |
5298 |
|
|
5332 |
ON |
ON |
5333 |
dossier.etat = etat.etat |
dossier.etat = etat.etat |
5334 |
WHERE dossier ='".$idx."'"; |
WHERE dossier ='".$idx."'"; |
5335 |
$statut = $this->db->getOne($sql); |
$statut = $this->f->db->getone($sql); |
5336 |
$this->f->addToLog("getStatutAutorisationDossier() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
5337 |
if ( database::isError($statut)){ |
$this->f->isDatabaseError($statut); |
|
die(); |
|
|
} |
|
5338 |
} |
} |
5339 |
return $statut; |
return $statut; |
5340 |
} |
} |
5351 |
// 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 |
5352 |
$sql = "SELECT * FROM ".DB_PREFIXE."dossier |
$sql = "SELECT * FROM ".DB_PREFIXE."dossier |
5353 |
WHERE dossier='".$this->valF['dossier']."'"; |
WHERE dossier='".$this->valF['dossier']."'"; |
5354 |
$res = $this->db->query($sql); |
$res = $this->f->db->query($sql); |
5355 |
$this->addToLog("get_dossier_actual(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
5356 |
$this->f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
5357 |
|
|
5358 |
// |
// |
5384 |
$return['archive_date_limite_incompletude'] = $row['date_limite_incompletude']; |
$return['archive_date_limite_incompletude'] = $row['date_limite_incompletude']; |
5385 |
$return['archive_delai_incompletude'] = $row['delai_incompletude']; |
$return['archive_delai_incompletude'] = $row['delai_incompletude']; |
5386 |
$return['archive_autorite_competente'] = $row['autorite_competente']; |
$return['archive_autorite_competente'] = $row['autorite_competente']; |
5387 |
|
$return['archive_dossier_instruction_type'] = $row['dossier_instruction_type']; |
5388 |
$return['duree_validite'] = $row['duree_validite']; |
$return['duree_validite'] = $row['duree_validite']; |
5389 |
$return['date_depot'] = $row['date_depot']; |
$return['date_depot'] = $row['date_depot']; |
5390 |
|
$return['date_depot_mairie'] = $row['date_depot_mairie']; |
5391 |
$return['archive_date_cloture_instruction'] = $row['date_cloture_instruction']; |
$return['archive_date_cloture_instruction'] = $row['date_cloture_instruction']; |
5392 |
$return['archive_date_premiere_visite'] = $row['date_premiere_visite']; |
$return['archive_date_premiere_visite'] = $row['date_premiere_visite']; |
5393 |
$return['archive_date_derniere_visite'] = $row['date_derniere_visite']; |
$return['archive_date_derniere_visite'] = $row['date_derniere_visite']; |
5395 |
$return['archive_date_retour_contradictoire'] = $row['date_retour_contradictoire']; |
$return['archive_date_retour_contradictoire'] = $row['date_retour_contradictoire']; |
5396 |
$return['archive_date_ait'] = $row['date_ait']; |
$return['archive_date_ait'] = $row['date_ait']; |
5397 |
$return['archive_date_transmission_parquet'] = $row['date_transmission_parquet']; |
$return['archive_date_transmission_parquet'] = $row['date_transmission_parquet']; |
5398 |
|
$return['archive_date_affichage'] = $row['date_affichage']; |
5399 |
|
$return['archive_pec_metier'] = $row['pec_metier']; |
5400 |
|
$return['archive_a_qualifier'] = $row['a_qualifier']; |
5401 |
} |
} |
5402 |
|
|
5403 |
// Retour de la fonction |
// Retour de la fonction |
5425 |
ON instruction.evenement = evenement.evenement |
ON instruction.evenement = evenement.evenement |
5426 |
WHERE instruction.instruction = $idx"; |
WHERE instruction.instruction = $idx"; |
5427 |
$this->f->addToLog("checkEvenementNonVerrouillable() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog("checkEvenementNonVerrouillable() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
5428 |
$res = $this->db->getOne($sql); |
$res = $this->f->db->getOne($sql); |
5429 |
$this->f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
5430 |
|
|
5431 |
// Si le retour de la requête est true |
// Si le retour de la requête est true |
5513 |
if ($row['date_depot'] != '') { |
if ($row['date_depot'] != '') { |
5514 |
$this->valF['date_depot']= $row['date_depot']; |
$this->valF['date_depot']= $row['date_depot']; |
5515 |
} |
} |
5516 |
|
if ($row['date_depot_mairie'] != '') { |
5517 |
|
$this->valF['date_depot_mairie']= $row['date_depot_mairie']; |
5518 |
|
} |
5519 |
// Dates concernant les dossiers contentieux |
// Dates concernant les dossiers contentieux |
5520 |
if ($row['date_cloture_instruction'] != '') { |
if ($row['date_cloture_instruction'] != '') { |
5521 |
$this->valF['archive_date_cloture_instruction']= $row['date_cloture_instruction']; |
$this->valF['archive_date_cloture_instruction']= $row['date_cloture_instruction']; |
5538 |
if ($row['date_transmission_parquet'] != '') { |
if ($row['date_transmission_parquet'] != '') { |
5539 |
$this->valF['archive_date_transmission_parquet']= $row['date_transmission_parquet']; |
$this->valF['archive_date_transmission_parquet']= $row['date_transmission_parquet']; |
5540 |
} |
} |
5541 |
|
// |
5542 |
|
if ($row['dossier_instruction_type'] != '') { |
5543 |
|
$this->valF['archive_dossier_instruction_type']= $row['dossier_instruction_type']; |
5544 |
|
} |
5545 |
|
if ($row['date_affichage'] != '') { |
5546 |
|
$this->valF['archive_date_affichage']= $row['date_affichage']; |
5547 |
|
} |
5548 |
|
if (isset($row['pec_metier']) === true && $row['pec_metier'] != '') { |
5549 |
|
$this->valF['archive_pec_metier']= $row['pec_metier']; |
5550 |
|
} |
5551 |
|
if (isset($row['a_qualifier']) === true && $row['a_qualifier'] != '') { |
5552 |
|
$this->valF['archive_a_qualifier']= $row['a_qualifier']; |
5553 |
|
} |
5554 |
} |
} |
5555 |
|
|
5556 |
// {{{ |
// {{{ |
5682 |
"datecontrolelegalite"=>"", "ap_numrue"=>"", "ap_nomdelavoie"=>"", |
"datecontrolelegalite"=>"", "ap_numrue"=>"", "ap_nomdelavoie"=>"", |
5683 |
"ap_codepostal"=>"", "ap_ville"=>""); |
"ap_codepostal"=>"", "ap_ville"=>""); |
5684 |
|
|
5685 |
$sqlArrete = "SELECT signataire_arrete.nom as \"nomsignataire\", |
$sqlArrete = "SELECT |
5686 |
|
signataire_arrete.prenom || ' ' ||signataire_arrete.nom as \"nomsignataire\", |
5687 |
signataire_arrete.qualite as \"qualitesignataire\", |
signataire_arrete.qualite as \"qualitesignataire\", |
5688 |
instruction.etat as \"decisionarrete\", |
instruction.etat as \"decisionarrete\", |
5689 |
instruction.date_retour_rar as \"datenotification\", |
instruction.date_retour_rar as \"datenotification\", |
5701 |
LEFT JOIN ".DB_PREFIXE."donnees_techniques ON |
LEFT JOIN ".DB_PREFIXE."donnees_techniques ON |
5702 |
donnees_techniques.dossier_instruction = dossier.dossier |
donnees_techniques.dossier_instruction = dossier.dossier |
5703 |
WHERE instruction.instruction = ".$this->getVal("instruction"); |
WHERE instruction.instruction = ".$this->getVal("instruction"); |
5704 |
$resArrete = $this->db->query($sqlArrete); |
$resArrete = $this->f->db->query($sqlArrete); |
5705 |
$this->f->addToLog("getArreteMetadata(): db->query(\"".$sqlArrete."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->query(\"".$sqlArrete."\");", VERBOSE_MODE); |
5706 |
if ( database::isError($resArrete)){ |
$this->f->isDatabaseError($resArrete); |
|
die(); |
|
|
} |
|
|
|
|
5707 |
$this->metadonneesArrete = $resArrete->fetchRow(DB_FETCHMODE_ASSOC); |
$this->metadonneesArrete = $resArrete->fetchRow(DB_FETCHMODE_ASSOC); |
5708 |
} |
} |
5709 |
|
|
5718 |
// Récupère la valeur du champ lettretype |
// Récupère la valeur du champ lettretype |
5719 |
$lettretype = $this->getVal("lettretype"); |
$lettretype = $this->getVal("lettretype"); |
5720 |
// Si le champ est vide |
// Si le champ est vide |
5721 |
if (empty($lettretype)) { |
if ($lettretype !== '' && $lettretype !== null) { |
5722 |
// |
// |
5723 |
return false; |
return true; |
5724 |
} |
} |
5725 |
|
|
5726 |
// |
// |
5727 |
return true; |
return false; |
5728 |
|
} |
5729 |
|
|
5730 |
|
/** |
5731 |
|
* CONDITION - is_modifiable. |
5732 |
|
* |
5733 |
|
* Controle si l'évenement est modifiable. |
5734 |
|
* |
5735 |
|
* @return boolean |
5736 |
|
*/ |
5737 |
|
function is_evenement_modifiable() { |
5738 |
|
$evenement = $this->get_inst_evenement($this->getVal('evenement')); |
5739 |
|
return ! $this->get_boolean_from_pgsql_value($evenement->getVal('non_modifiable')); |
5740 |
} |
} |
5741 |
|
|
5742 |
/** |
/** |
5747 |
* @return boolean |
* @return boolean |
5748 |
*/ |
*/ |
5749 |
function is_editable() { |
function is_editable() { |
5750 |
|
|
5751 |
|
// XXX |
5752 |
|
// 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é) |
5753 |
|
// Si cette tâche identifiée est DONE alors la suppression/modification de cette intruction est impossible |
5754 |
|
|
5755 |
// Contrôle si l'utilisateur possède un bypass |
// Contrôle si l'utilisateur possède un bypass |
5756 |
$bypass = $this->f->isAccredited(get_class($this)."_modifier_bypass"); |
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_modifier_bypass"); |
5757 |
// |
// |
5758 |
if ($bypass == true) { |
if ($bypass == true) { |
5759 |
// |
// |
5776 |
return true; |
return true; |
5777 |
} |
} |
5778 |
|
|
|
// 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; |
|
|
} |
|
|
|
|
5779 |
// Si l'utilisateur est instructeur de la commune du dossier et que |
// Si l'utilisateur est instructeur de la commune du dossier et que |
5780 |
// l'instruction est créée par un instructeur de la commune |
// l'instruction est créée par un instructeur de la commune |
5781 |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
5788 |
} |
} |
5789 |
|
|
5790 |
/** |
/** |
5791 |
|
* Vérifie si l'événement est supprimable ou pas. |
5792 |
|
* |
5793 |
|
* @return boolean |
5794 |
|
*/ |
5795 |
|
function is_evenement_supprimable() { |
5796 |
|
// Controle si l'évenement est supprimable |
5797 |
|
$evenement = $this->get_inst_evenement($this->getVal('evenement')); |
5798 |
|
return ! $this->get_boolean_from_pgsql_value($evenement->getVal('non_supprimable')); |
5799 |
|
} |
5800 |
|
|
5801 |
|
/** |
5802 |
* CONDITION - is_deletable. |
* CONDITION - is_deletable. |
5803 |
* |
* |
5804 |
* Condition pour lma modification. |
* Condition pour la suppression. |
5805 |
* |
* |
5806 |
* @return boolean |
* @return boolean |
5807 |
*/ |
*/ |
5808 |
function is_deletable() { |
function is_deletable() { |
5809 |
// Contrôle si l'utilisateur possède un bypass |
|
5810 |
$bypass = $this->f->isAccredited(get_class($this)."_supprimer_bypass"); |
// XXX |
5811 |
|
// 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é) |
5812 |
|
// Si cette tâche identifiée est DONE alors la suppression/modification de cette intruction est impossible |
5813 |
|
|
5814 |
|
// Contrôle si l'utilisateur possède un bypass intégral |
5815 |
|
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_supprimer_bypass"); |
5816 |
// |
// |
5817 |
if ($bypass == true) { |
if ($bypass == true) { |
5818 |
|
|
5821 |
} |
} |
5822 |
|
|
5823 |
// Si l'utilisateur est un intructeur qui ne correspond pas à la |
// Si l'utilisateur est un intructeur qui ne correspond pas à la |
5824 |
// division du dossier |
// division du dossier et si l'utilisateur n'a pas la permission bypass |
5825 |
if ($this->is_instructeur_from_division_dossier() !== true) { |
// de la division |
5826 |
|
if ($this->is_instructeur_from_division_dossier() === false |
5827 |
|
&& $this->f->isAccredited($this->get_absolute_class_name()."_supprimer_bypass_division") === false) { |
5828 |
|
|
5829 |
// |
// |
5830 |
return false; |
return false; |
5833 |
// l'événement est-il le dernier ? |
// l'événement est-il le dernier ? |
5834 |
$dernier_evenement = false; |
$dernier_evenement = false; |
5835 |
// instanciation dossier |
// instanciation dossier |
5836 |
require_once "../obj/dossier.class.php"; |
$dossier = $this->f->get_inst__om_dbform(array( |
5837 |
$dossier = new dossier($this->getVal('dossier'), $this->db, DEBUG); |
"obj" => "dossier", |
5838 |
|
"idx" => $this->getVal('dossier'), |
5839 |
|
)); |
5840 |
// récupération dernier événement |
// récupération dernier événement |
5841 |
$id_dernier_evenement = $dossier->get_dernier_evenement(); |
$id_dernier_evenement = $dossier->get_dernier_evenement(); |
5842 |
if ($id_dernier_evenement == $this->getVal($this->clePrimaire)) { |
if ($id_dernier_evenement == $this->getVal($this->clePrimaire)) { |
5887 |
*/ |
*/ |
5888 |
function is_addable() { |
function is_addable() { |
5889 |
// Contrôle si l'utilisateur possède un bypass |
// Contrôle si l'utilisateur possède un bypass |
5890 |
$bypass = $this->f->isAccredited(get_class($this)."_ajouter_bypass"); |
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_ajouter_bypass"); |
5891 |
// |
// |
5892 |
if ($bypass == true) { |
if ($bypass == true) { |
5893 |
|
|
5915 |
*/ |
*/ |
5916 |
function is_finalizable() { |
function is_finalizable() { |
5917 |
// Contrôle si l'utilisateur possède un bypass |
// Contrôle si l'utilisateur possède un bypass |
5918 |
$bypass = $this->f->isAccredited(get_class($this)."_finaliser_bypass"); |
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_finaliser_bypass"); |
5919 |
// |
// |
5920 |
if ($bypass == true) { |
if ($bypass == true) { |
5921 |
// |
// |
5938 |
return true; |
return true; |
5939 |
} |
} |
5940 |
|
|
|
// 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; |
|
|
} |
|
|
|
|
5941 |
// Si l'utilisateur est instructeur de la commune du dossier et que |
// Si l'utilisateur est instructeur de la commune du dossier et que |
5942 |
// l'instruction est créée par un instructeur de la commune |
// l'instruction est créée par un instructeur de la commune |
5943 |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
5980 |
*/ |
*/ |
5981 |
function is_unfinalizable(){ |
function is_unfinalizable(){ |
5982 |
// Contrôle si l'utilisateur possède un bypass |
// Contrôle si l'utilisateur possède un bypass |
5983 |
$bypass = $this->f->isAccredited(get_class($this)."_definaliser_bypass"); |
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_definaliser_bypass"); |
5984 |
// |
// |
5985 |
if ($bypass == true) { |
if ($bypass == true) { |
5986 |
// |
// |
6003 |
return true; |
return true; |
6004 |
} |
} |
6005 |
|
|
|
// 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; |
|
|
} |
|
|
|
|
6006 |
// Si l'utilisateur est instructeur de la commune du dossier et que |
// Si l'utilisateur est instructeur de la commune du dossier et que |
6007 |
// l'instruction est créée par un instructeur de la commune |
// l'instruction est créée par un instructeur de la commune |
6008 |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
6051 |
|
|
6052 |
|
|
6053 |
// 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 |
6054 |
$sql = |
// /!\ Requête lié à celles du widget indiquant les dossiers éligible au changement |
6055 |
"SELECT |
// de décision : |
6056 |
|
// * dossier_instruction.class.php : view_widget_dossiers_evenement_retour_finalise() |
6057 |
|
// * dossier_instruction.inc.php : si le paramètre filtre_decision = true |
6058 |
|
$sql = sprintf( |
6059 |
|
'SELECT |
6060 |
dossier.dossier |
dossier.dossier |
6061 |
FROM |
FROM |
6062 |
".DB_PREFIXE."dossier |
%1$sdossier |
6063 |
JOIN ".DB_PREFIXE."instruction ON instruction.instruction = ( |
JOIN %1$setat |
6064 |
SELECT instruction |
ON dossier.etat = etat.etat AND etat.statut = \'encours\' |
6065 |
FROM ".DB_PREFIXE."instruction |
JOIN %1$slien_dossier_demandeur |
6066 |
JOIN ".DB_PREFIXE."evenement on instruction.evenement=evenement.evenement |
ON dossier.dossier = lien_dossier_demandeur.dossier AND lien_dossier_demandeur.petitionnaire_principal IS TRUE |
6067 |
WHERE instruction.dossier = dossier.dossier |
JOIN %1$sdossier_instruction_type |
6068 |
AND evenement.retour IS FALSE |
ON dossier.dossier_instruction_type=dossier_instruction_type.dossier_instruction_type |
6069 |
ORDER BY date_evenement DESC, instruction DESC |
JOIN %1$sinstruction |
6070 |
LIMIT 1 |
-- Recherche de la dernière instruction qui ne soit pas liée à un événement retour |
6071 |
) |
ON instruction.instruction = ( |
6072 |
JOIN ".DB_PREFIXE."evenement ON instruction.evenement=evenement.evenement |
SELECT instruction |
6073 |
JOIN ".DB_PREFIXE."instructeur ON dossier.instructeur=instructeur.instructeur |
FROM %1$sinstruction |
6074 |
JOIN ".DB_PREFIXE."om_utilisateur ON instructeur.om_utilisateur=om_utilisateur.om_utilisateur |
JOIN %1$sevenement ON instruction.evenement=evenement.evenement |
6075 |
JOIN ".DB_PREFIXE."om_collectivite ON om_collectivite.om_collectivite=om_utilisateur.om_collectivite |
AND evenement.retour IS FALSE |
6076 |
JOIN ".DB_PREFIXE."etat ON dossier.etat = etat.etat |
WHERE instruction.dossier = dossier.dossier |
6077 |
|
ORDER BY date_evenement DESC, instruction DESC |
6078 |
|
LIMIT 1 |
6079 |
|
) |
6080 |
|
-- On ne garde que les dossiers pour lesquels la dernière instruction est finalisée |
6081 |
|
-- ou alors pour laquelle l instruction a été ajouté par la commune et est |
6082 |
|
-- non signée, non notifié, etc. |
6083 |
|
AND (instruction.om_final_instruction IS TRUE |
6084 |
|
OR instruction.created_by_commune IS TRUE) |
6085 |
|
AND instruction.date_retour_signature IS NULL |
6086 |
|
AND instruction.date_envoi_rar IS NULL |
6087 |
|
AND instruction.date_retour_rar IS NULL |
6088 |
|
AND instruction.date_envoi_controle_legalite IS NULL |
6089 |
|
AND instruction.date_retour_controle_legalite IS NULL |
6090 |
|
-- On vérifie que l instruction soit un arrêté ou un changement de décision |
6091 |
|
JOIN %1$sevenement |
6092 |
|
ON instruction.evenement=evenement.evenement |
6093 |
|
AND (evenement.type = \'arrete\' |
6094 |
|
OR evenement.type = \'changement_decision\') |
6095 |
|
-- Recherche les informations du pétitionnaire principal pour l affichage |
6096 |
|
JOIN %1$sdemandeur |
6097 |
|
ON lien_dossier_demandeur.demandeur = demandeur.demandeur |
6098 |
|
-- Recherche la collectivité rattachée à l instructeur |
6099 |
|
JOIN %1$sinstructeur |
6100 |
|
ON dossier.instructeur=instructeur.instructeur |
6101 |
|
JOIN %1$sdivision |
6102 |
|
ON instructeur.division=division.division |
6103 |
|
JOIN %1$sdirection |
6104 |
|
ON division.direction=direction.direction |
6105 |
|
JOIN %1$som_collectivite |
6106 |
|
ON direction.om_collectivite=om_collectivite.om_collectivite |
6107 |
WHERE |
WHERE |
6108 |
|
-- Vérification que la décision a été prise par l agglo |
6109 |
( |
om_collectivite.niveau = \'2\' |
6110 |
evenement.type = 'arrete' AND |
AND dossier.dossier = \'%2$s\' |
6111 |
( |
', |
6112 |
instruction.om_final_instruction IS TRUE |
DB_PREFIXE, |
6113 |
OR instruction.created_by_commune IS TRUE |
$idx |
6114 |
) 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' |
|
|
"; |
|
6115 |
|
|
6116 |
|
|
6117 |
// Si collectivité de l'utilisateur niveau mono alors filtre sur celle-ci |
// Si collectivité de l'utilisateur niveau mono alors filtre sur celle-ci |
6118 |
if ($this->f->isCollectiviteMono($_SESSION['collectivite']) === true) { |
if ($this->f->isCollectiviteMono($_SESSION['collectivite']) === true) { |
6119 |
$sql .= " AND dossier.om_collectivite=".$_SESSION['collectivite']; |
$sql .= sprintf( |
6120 |
} |
' AND dossier.om_collectivite=%1$s', |
6121 |
$res = $this->db->getone($sql); |
$_SESSION['collectivite'] |
6122 |
if (database::isError($res)) { |
); |
|
die(); |
|
6123 |
} |
} |
6124 |
|
$res = $this->f->db->getone($sql); |
6125 |
|
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
6126 |
|
$this->f->isDatabaseError($res); |
6127 |
// Si le dossier n'est pas sujet au changement de decision |
// Si le dossier n'est pas sujet au changement de decision |
6128 |
if($res == null) { |
if($res == null) { |
6129 |
return false; |
return false; |
6150 |
} |
} |
6151 |
|
|
6152 |
// Contrôle si l'utilisateur possède un bypass |
// Contrôle si l'utilisateur possède un bypass |
6153 |
$bypass = $this->f->isAccredited(get_class($this)."_modification_dates_bypass"); |
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_modification_dates_bypass"); |
6154 |
if ($bypass === true) { |
if ($bypass === true) { |
6155 |
return true; |
return true; |
6156 |
} |
} |
6157 |
|
|
6158 |
// 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 |
6159 |
|
// un utilisateur lié à un instructeur |
6160 |
|
$perm_moni_dates_d_closed = $this->f->isAccredited($this->get_absolute_class_name()."_modification_dates_cloture"); |
6161 |
|
|
6162 |
|
// On vérifie en premier lieu que le DI n'est pas clôturé et que |
6163 |
|
// l'utilisateur ne possède pas la permission de modifier le suivi des |
6164 |
|
// dates sur un dossier clôturé |
6165 |
$inst_dossier = $this->get_inst_dossier(); |
$inst_dossier = $this->get_inst_dossier(); |
6166 |
if ($inst_dossier->getStatut() === 'cloture') { |
if ($inst_dossier->getStatut() === 'cloture' |
6167 |
|
&& $perm_moni_dates_d_closed === false) { |
6168 |
// |
// |
6169 |
return false; |
return false; |
6170 |
} |
} |
6213 |
|
|
6214 |
|
|
6215 |
/** |
/** |
6216 |
|
* CONDITION - is_finalized. |
6217 |
|
* |
6218 |
|
* Condition pour vérifier si une instruction est finalisée. |
6219 |
|
* |
6220 |
|
* @return boolean |
6221 |
|
*/ |
6222 |
|
public function is_finalized() { |
6223 |
|
|
6224 |
|
return $this->getVal('om_final_instruction') === "t"; |
6225 |
|
} |
6226 |
|
|
6227 |
|
/** |
6228 |
|
* CONDITION - is_not_date_retour_signature_set. |
6229 |
|
* |
6230 |
|
* Condition pour vérifier si une date de retour signature n'est pas définie. |
6231 |
|
* |
6232 |
|
* @return boolean |
6233 |
|
*/ |
6234 |
|
public function is_not_date_retour_signature_set() { |
6235 |
|
|
6236 |
|
return $this->getVal('date_retour_signature') == null; |
6237 |
|
|
6238 |
|
} |
6239 |
|
|
6240 |
|
|
6241 |
|
/** |
6242 |
* TREATMENT - finalize. |
* TREATMENT - finalize. |
6243 |
* |
* |
6244 |
* Permet de finaliser un enregistrement. |
* Permet de finaliser un enregistrement. |
6252 |
// 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 |
6253 |
// dites de TREATMENT. |
// dites de TREATMENT. |
6254 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
6255 |
|
$message = ''; |
6256 |
|
$ev = $this->get_inst_evenement($this->getVal('evenement')); |
6257 |
|
|
6258 |
|
// Controle du signataire |
6259 |
|
if (! $this->controle_signataire($ev)) { |
6260 |
|
$this->addToMessage(__("Le document ne peut pas être finalisé car aucun signataire n'a été sélectionné.")); |
6261 |
|
// Termine le traitement |
6262 |
|
return $this->end_treatment(__METHOD__, false); |
6263 |
|
} |
6264 |
|
|
6265 |
// Traitement de la finalisation |
// Traitement de la finalisation |
6266 |
$ret = $this->manage_finalizing("finalize", $val); |
$ret = $this->manage_finalizing("finalize", $val); |
6272 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
6273 |
} |
} |
6274 |
|
|
6275 |
|
// Envoi des notifications aux demandeurs si la notification est automatique |
6276 |
|
// et que la signature n'est pas requise |
6277 |
|
if ($ev->getVal('notification') === 'notification_automatique') { |
6278 |
|
// Préparation du message de log en cas d'erreur de notification |
6279 |
|
$msgLog = sprintf( |
6280 |
|
'%s %s : %d', |
6281 |
|
__('Erreur lors de la notification automatique du(des) pétitionnaire(s) suite à la finalisation de l\'instruction.'), |
6282 |
|
__('Instruction notifiée'), |
6283 |
|
$this->getVal($this->clePrimaire) |
6284 |
|
); |
6285 |
|
// Récupération de la catégorie et envoie des notifications au(x) demandeur(s) |
6286 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite($this->getVal('dossier')); |
6287 |
|
// Récupération de la liste des demandeurs à notifier et de la catégorie |
6288 |
|
$categorie = $this->f->get_param_option_notification($collectivite_di); |
6289 |
|
$isPortal = $categorie == null || $categorie == '' || $categorie == PORTAL ? true : false; |
6290 |
|
$demandeursANotifie = $this->get_demandeurs_notifiable( |
6291 |
|
$this->getVal('dossier'), |
6292 |
|
$isPortal |
6293 |
|
); |
6294 |
|
|
6295 |
|
// Création d'une notification et d'une tâche pour chaque demandeur à notifier |
6296 |
|
$demandeurPrincipalNotifie = false; |
6297 |
|
if (count($demandeursANotifie) > 0) { |
6298 |
|
foreach ($demandeursANotifie as $demandeur) { |
6299 |
|
// Identifie si le demandeur principal a été notifié ou pas |
6300 |
|
// et récupère ses informations |
6301 |
|
if ($demandeur['petitionnaire_principal'] == 't') { |
6302 |
|
$demandeurPrincipalNotifie = true; |
6303 |
|
// Si le demandeur principal est notifiable mais qu'il y a des erreurs dans |
6304 |
|
// son paramétrage, on effectue pas le traitement et on passe à l'itération |
6305 |
|
// suivante. On le considère également comme non notifié pour gérer l'envoie |
6306 |
|
// des messages d'erreurs |
6307 |
|
// Si la demande a été déposée via le portail alors le paramétrage n'a pas |
6308 |
|
// d'impact sur la notification |
6309 |
|
$erreursParam = $this->get_info_notification_fail(); |
6310 |
|
if (! $this->dossier_depose_sur_portail() && $erreursParam != array()) { |
6311 |
|
$demandeurPrincipalNotifie = false; |
6312 |
|
continue; |
6313 |
|
} |
6314 |
|
} |
6315 |
|
// Ajout de la notif et récupération de son id |
6316 |
|
$idNotif = $this->ajouter_notification( |
6317 |
|
$this->getVal($this->clePrimaire), |
6318 |
|
$this->f->get_connected_user_login_name(), |
6319 |
|
$demandeur, |
6320 |
|
$collectivite_di, |
6321 |
|
array(), |
6322 |
|
true |
6323 |
|
); |
6324 |
|
if ($idNotif === false) { |
6325 |
|
// Termine le traitement |
6326 |
|
$this->addToLog( |
6327 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
6328 |
|
DEBUG_MODE |
6329 |
|
); |
6330 |
|
return $this->end_treatment(__METHOD__, false); |
6331 |
|
} |
6332 |
|
$notification_by_task = $this->notification_by_task( |
6333 |
|
$idNotif, |
6334 |
|
$this->getVal('dossier'), |
6335 |
|
$categorie |
6336 |
|
); |
6337 |
|
if ($notification_by_task === false) { |
6338 |
|
$this->addToLog( |
6339 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
6340 |
|
DEBUG_MODE |
6341 |
|
); |
6342 |
|
$this->addToMessage( |
6343 |
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
6344 |
|
); |
6345 |
|
// Termine le traitement |
6346 |
|
return $this->end_treatment(__METHOD__, false); |
6347 |
|
} |
6348 |
|
$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."))); |
6349 |
|
} |
6350 |
|
} |
6351 |
|
// Pour la notification par mail ou la notification via portal si le dossier a |
6352 |
|
// été déposés via portal, si le demandeur principal n'est pas notifiable, |
6353 |
|
// on créé une nouvelle notification en erreur avec en commentaire la raison pour |
6354 |
|
// laquelle le demandeur principal n'a pas pu être notifié |
6355 |
|
$depotPortal = $this->dossier_depose_sur_portail(); |
6356 |
|
if (! $demandeurPrincipalNotifie && ($isPortal === false || $depotPortal === true)) { |
6357 |
|
// Préparation des logs pour indiquer que le pétitionnaire principale n'est pas notifiable |
6358 |
|
$msgLog .= sprintf(' %s', __('Le pétitionnaire principale n\'est pas notifiable.')); |
6359 |
|
// Analyse pour savoir pourquoi le demandeur principal n'est pas notifiable |
6360 |
|
$erreursParam = $this->get_info_notification_fail(); |
6361 |
|
$demandeurPrincipal = $this->get_info_petitionnaire_principal_dossier($this->getVal('dossier')); |
6362 |
|
// Ajout de la notif et récupération de son id |
6363 |
|
$idNotif = $this->ajouter_notification( |
6364 |
|
$this->valF[$this->clePrimaire], |
6365 |
|
$this->f->get_connected_user_login_name(), |
6366 |
|
$demandeurPrincipal, |
6367 |
|
$collectivite_di, |
6368 |
|
array(), |
6369 |
|
true, |
6370 |
|
'Echec', |
6371 |
|
implode(' ', $erreursParam) |
6372 |
|
); |
6373 |
|
if ($idNotif === false) { |
6374 |
|
$this->addToMessage( |
6375 |
|
__('Erreur : la création de la notification a échouée.'). |
6376 |
|
__("Veuillez contacter votre administrateur.") |
6377 |
|
); |
6378 |
|
$this->addToLog( |
6379 |
|
sprintf('%s() : %s', __METHOD__, $msgLog), |
6380 |
|
DEBUG_MODE |
6381 |
|
); |
6382 |
|
return false; |
6383 |
|
} |
6384 |
|
// Prépare un message d'alerte à destination de l'instructeur pour l'informer |
6385 |
|
// de l'échec de la notification |
6386 |
|
$dossier_message = $this->get_inst_dossier_message(0); |
6387 |
|
$dossier_message_val = array( |
6388 |
|
'dossier' => $this->getVal('dossier'), |
6389 |
|
'type' => _('erreur expedition'), |
6390 |
|
'emetteur' => $this->f->get_connected_user_login_name(), |
6391 |
|
'login' => $_SESSION['login'], |
6392 |
|
'date_emission' => date('Y-m-d H:i:s'), |
6393 |
|
'contenu' => _('Échec lors de la notification de l\'instruction '). |
6394 |
|
$ev->getVal('libelle'). |
6395 |
|
'.<br>'. |
6396 |
|
implode("\n", $erreursParam). |
6397 |
|
'<br>'. |
6398 |
|
_('Veuillez corriger ces informations avant de renvoyer la notification.') |
6399 |
|
); |
6400 |
|
$add = $dossier_message->add_notification_message($dossier_message_val, true); |
6401 |
|
// Si une erreur se produit pendant l'ajout |
6402 |
|
if ($add !== true) { |
6403 |
|
$this->addToLog(__METHOD__."(): Le message d'alerte concernant l'echec de l'envoi de la notification n'a pas pu être envoyé.", DEBUG_MODE); |
6404 |
|
return false; |
6405 |
|
} |
6406 |
|
} |
6407 |
|
} |
6408 |
|
|
6409 |
// Termine le traitement |
// Termine le traitement |
6410 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
6411 |
} |
} |
6412 |
|
|
6413 |
/** |
/** |
6414 |
|
* Récupère l'instance de dossier message. |
6415 |
|
* |
6416 |
|
* @param string $dossier_message Identifiant du message. |
6417 |
|
* |
6418 |
|
* @return object |
6419 |
|
*/ |
6420 |
|
private function get_inst_dossier_message($dossier_message = null) { |
6421 |
|
// |
6422 |
|
return $this->get_inst_common("dossier_message", $dossier_message); |
6423 |
|
} |
6424 |
|
|
6425 |
|
/** |
6426 |
|
* Vérifie si le signataire est obligatoire pour finaliser |
6427 |
|
* le document apartir du paramétrage de l'événement. |
6428 |
|
* Si c'est le cas, vérifie si il y a bien un signataire |
6429 |
|
* renseigné. |
6430 |
|
* Si c'est le cas renvoie true, sinon renvoie false. |
6431 |
|
* |
6432 |
|
* @param evenement évenement de l'instruction permettant de |
6433 |
|
* récupérer le paramétrage |
6434 |
|
* @return boolean |
6435 |
|
*/ |
6436 |
|
protected function controle_signataire($evenement) { |
6437 |
|
// Vérifie si le signataire est obligatoire et si c'est le cas |
6438 |
|
// vérifie si il y a bien un signataire pour le document |
6439 |
|
if ($evenement->is_signataire_obligatoire() && |
6440 |
|
($this->getVal('signataire_arrete') === null || |
6441 |
|
$this->getVal('signataire_arrete') === '')) { |
6442 |
|
return false; |
6443 |
|
} |
6444 |
|
return true; |
6445 |
|
} |
6446 |
|
|
6447 |
|
/** |
6448 |
* TREATMENT - unfinalize. |
* TREATMENT - unfinalize. |
6449 |
* |
* |
6450 |
* Permet de définaliser un enregistrement. |
* Permet de définaliser un enregistrement. |
6487 |
&& $this->getVal("om_final_instruction") != null) { |
&& $this->getVal("om_final_instruction") != null) { |
6488 |
|
|
6489 |
// Ouvre le document |
// Ouvre le document |
6490 |
$lien = '../spg/file.php?obj='.$this->table.'&'. |
$lien = '../app/index.php?module=form&snippet=file&obj='.$this->table.'&'. |
6491 |
'champ=om_fichier_instruction&id='.$this->getVal($this->clePrimaire); |
'champ=om_fichier_instruction&id='.$this->getVal($this->clePrimaire); |
6492 |
// |
// |
6493 |
header("Location: ".$lien); |
header("Location: ".$lien); |
6506 |
"mode" => "previsualisation", |
"mode" => "previsualisation", |
6507 |
), |
), |
6508 |
); |
); |
6509 |
|
// Si la rédaction libre est activée sur l'instruction |
6510 |
|
if ($this->getVal("flag_edition_integrale") == 't') { |
6511 |
|
$params["specific"]["corps"] = array( |
6512 |
|
"mode" => "set", |
6513 |
|
"value" => $this->getVal("corps_om_htmletatex"), |
6514 |
|
); |
6515 |
|
$params["specific"]["titre"] = array( |
6516 |
|
"mode" => "set", |
6517 |
|
"value" => $this->getVal("titre_om_htmletat"), |
6518 |
|
); |
6519 |
|
} |
6520 |
|
|
6521 |
// Génération du PDF |
// Génération du PDF |
6522 |
$result = $this->compute_pdf_output('lettretype', $this->getVal("lettretype"), $collectivite, null, $params); |
$result = $this->compute_pdf_output('lettretype', $this->getVal("lettretype"), $collectivite, null, $params); |
6531 |
/** |
/** |
6532 |
* Récupère la collectivité du dossier d'instruction. |
* Récupère la collectivité du dossier d'instruction. |
6533 |
* |
* |
6534 |
|
* @param string $dossier_instruction_id Identifiant du DI. |
6535 |
|
* |
6536 |
* @return integer |
* @return integer |
6537 |
*/ |
*/ |
6538 |
function get_dossier_instruction_om_collectivite() { |
function get_dossier_instruction_om_collectivite($dossier_instruction_id = null) { |
6539 |
|
|
6540 |
|
// Si l'identifiant n'est pas renseigné |
6541 |
|
if ($dossier_instruction_id === null) { |
6542 |
|
// Récupère la valeur |
6543 |
|
if ($this->getVal('dossier') !== null && $this->getVal('dossier') !== '') { |
6544 |
|
$dossier_instruction_id = $this->getVal('dossier'); |
6545 |
|
} elseif ($this->getParameter('idxformulaire') !== null |
6546 |
|
&& $this->getParameter('idxformulaire') !== '') { |
6547 |
|
// |
6548 |
|
$dossier_instruction_id = $this->getParameter('idxformulaire'); |
6549 |
|
} elseif ($this->f->get_submitted_get_value('idxformulaire') !== null |
6550 |
|
&& $this->f->get_submitted_get_value('idxformulaire') !== '') { |
6551 |
|
// |
6552 |
|
$dossier_instruction_id = $this->f->get_submitted_get_value('idxformulaire'); |
6553 |
|
} |
6554 |
|
} |
6555 |
|
|
6556 |
// |
// |
6557 |
require_once "../obj/dossier_instruction.class.php"; |
$dossier_instruction = $this->f->get_inst__om_dbform(array( |
6558 |
$dossier_instruction = new dossier_instruction($this->getVal('dossier'), $this->f->db, false); |
"obj" => "dossier_instruction", |
6559 |
|
"idx" => $dossier_instruction_id, |
6560 |
|
)); |
6561 |
|
|
6562 |
// |
// |
6563 |
return $dossier_instruction->getVal('om_collectivite'); |
return $dossier_instruction->getVal('om_collectivite'); |
6574 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
6575 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
6576 |
|
|
|
// XXX APP |
|
|
|
|
|
$f = $this->f; |
|
|
|
|
6577 |
/** |
/** |
6578 |
* Affichage de la structure HTML |
* Affichage de la structure HTML |
6579 |
*/ |
*/ |
6580 |
// |
// |
6581 |
if ($f->isAjaxRequest()) { |
if ($this->f->isAjaxRequest()) { |
6582 |
// |
// |
6583 |
header("Content-type: text/html; charset=".HTTPCHARSET.""); |
header("Content-type: text/html; charset=".HTTPCHARSET.""); |
6584 |
} else { |
} else { |
6585 |
// |
// |
6586 |
$f->setFlag("htmlonly"); |
$this->f->setFlag("htmlonly"); |
6587 |
$f->display(); |
$this->f->display(); |
6588 |
} |
} |
6589 |
// |
// |
6590 |
$f->displayStartContent(); |
$this->f->displayStartContent(); |
6591 |
// |
// |
6592 |
$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")); |
6593 |
$f->displayTitle(); |
$this->f->displayTitle(); |
6594 |
|
|
6595 |
/** |
/** |
6596 |
* |
* |
6597 |
*/ |
*/ |
6598 |
// |
// |
6599 |
($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 = ""); |
6600 |
$evenement = intval($evenement); |
$evenement = intval($evenement); |
6601 |
// |
// |
6602 |
($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 = ""); |
6603 |
// Récupération du code du type de DA |
// Récupération du code du type de DA |
6604 |
$code_da_type = ''; |
$code_da_type = ''; |
6605 |
if (preg_match('/[A-Za-z]{2,3}/', $idx, $matches) !== false) { |
if (preg_match('/[A-Za-z]{2,3}/', $idx, $matches) !== false) { |
6606 |
$code_da_type = $matches[0]; |
$code_da_type = $matches[0]; |
6607 |
} |
} |
6608 |
// |
// |
6609 |
($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"); |
6610 |
|
|
6611 |
// Récupération de la collectivité du dossier |
// Récupération de la collectivité du dossier |
6612 |
require_once "../obj/dossier.class.php"; |
$dossier = $this->f->get_inst__om_dbform(array( |
6613 |
$dossier = new dossier($idx, $f->db, DEBUG); |
"obj" => "dossier", |
6614 |
|
"idx" => $idx, |
6615 |
|
)); |
6616 |
|
|
6617 |
/** |
/** |
6618 |
* |
* |
6624 |
ON bible.dossier_autorisation_type=dossier_autorisation_type.dossier_autorisation_type |
ON bible.dossier_autorisation_type=dossier_autorisation_type.dossier_autorisation_type |
6625 |
LEFT JOIN ".DB_PREFIXE."om_collectivite |
LEFT JOIN ".DB_PREFIXE."om_collectivite |
6626 |
ON bible.om_collectivite = om_collectivite.om_collectivite |
ON bible.om_collectivite = om_collectivite.om_collectivite |
6627 |
WHERE evenement=".$evenement." |
WHERE (evenement=".$evenement." OR evenement IS NULL) |
6628 |
AND complement=".$complement." |
AND (complement=".$complement." OR complement IS NULL) |
6629 |
AND (bible.dossier_autorisation_type IS NULL |
AND (bible.dossier_autorisation_type IS NULL |
6630 |
OR dossier_autorisation_type.code ='".$code_da_type."') |
OR dossier_autorisation_type.code ='".$code_da_type."') |
6631 |
AND (om_collectivite.niveau = '2' |
AND (om_collectivite.niveau = '2' |
6632 |
OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").") |
OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").") |
6633 |
ORDER BY bible_lib ASC"; |
ORDER BY bible_lib ASC"; |
6634 |
$res = $f->db->query($sql); |
$res = $this->f->db->query($sql); |
6635 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\");", VERBOSE_MODE); |
6636 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
6637 |
// |
// |
6638 |
echo "<form method=\"post\" name=\"f3\" action=\"#\">\n"; |
echo "<form method=\"post\" name=\"f3\" action=\"#\">\n"; |
6639 |
// |
// |
6665 |
echo "\t</table>\n"; |
echo "\t</table>\n"; |
6666 |
// |
// |
6667 |
echo "<div class=\"formControls\">\n"; |
echo "<div class=\"formControls\">\n"; |
6668 |
$f->layout->display_form_button(array( |
$this->f->layout->display_form_button(array( |
6669 |
"value" => _("Valider"), |
"value" => _("Valider"), |
6670 |
"onclick" => "bible_return('f2', 'complement".($complement == "1" ? "" : $complement)."_om_html'); return false;", |
"onclick" => "bible_return('f2', 'complement".($complement == "1" ? "" : $complement)."_om_html'); return false;", |
6671 |
)); |
)); |
6672 |
$f->displayLinkJsCloseWindow(); |
$this->f->displayLinkJsCloseWindow(); |
6673 |
echo "</div>\n"; |
echo "</div>\n"; |
6674 |
|
|
6675 |
} else { |
} else { |
6676 |
// |
// |
6677 |
$message_class = "error"; |
$message_class = "error"; |
6678 |
$message = _("Aucun element dans la bible pour l'evenement")." : ".$evenement; |
$message = _("Aucun element dans la bible pour l'evenement")." : ".$evenement; |
6679 |
$f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
6680 |
// |
// |
6681 |
echo "<div class=\"formControls\">\n"; |
echo "<div class=\"formControls\">\n"; |
6682 |
$f->displayLinkJsCloseWindow(); |
$this->f->displayLinkJsCloseWindow(); |
6683 |
echo "</div>\n"; |
echo "</div>\n"; |
6684 |
} |
} |
6685 |
// |
// |
6689 |
* Affichage de la structure HTML |
* Affichage de la structure HTML |
6690 |
*/ |
*/ |
6691 |
// |
// |
6692 |
$f->displayEndContent(); |
$this->f->displayEndContent(); |
6693 |
} |
} |
6694 |
|
|
6695 |
/** |
/** |
6702 |
function view_bible_auto() { |
function view_bible_auto() { |
6703 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
6704 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
|
|
|
|
// XXX APP |
|
|
|
|
|
$f = $this->f; |
|
|
|
|
6705 |
// |
// |
6706 |
$f->disableLog(); |
$this->f->disableLog(); |
6707 |
|
|
6708 |
$formatDate="AAAA-MM-JJ"; |
$formatDate="AAAA-MM-JJ"; |
6709 |
|
|
6710 |
// Récupération des paramètres |
// Récupération des paramètres |
6711 |
$idx = $f->get_submitted_get_value('idx'); |
$idx = $this->f->get_submitted_get_value('idx'); |
6712 |
$evenement = $f->get_submitted_get_value('ev'); |
$evenement = $this->f->get_submitted_get_value('ev'); |
6713 |
|
|
6714 |
// Initialisation de la variable de retour |
// Initialisation de la variable de retour |
6715 |
$retour['complement_om_html'] = ''; |
$retour['complement_om_html'] = ''; |
6717 |
$retour['complement3_om_html'] = ''; |
$retour['complement3_om_html'] = ''; |
6718 |
$retour['complement4_om_html'] = ''; |
$retour['complement4_om_html'] = ''; |
6719 |
// Vérification d'une consultation liée à l'événement |
// Vérification d'une consultation liée à l'événement |
6720 |
$consultation = $f->db->getOne( |
$consultation = $this->f->db->getOne( |
6721 |
"select consultation from ".DB_PREFIXE."evenement where evenement=".$evenement |
"select consultation from ".DB_PREFIXE."evenement where evenement=".$evenement |
6722 |
); |
); |
6723 |
$f->isDatabaseError($consultation); |
$this->f->isDatabaseError($consultation); |
6724 |
// Si consultation liée, récupération du retour d'avis |
// Si consultation liée, récupération du retour d'avis |
6725 |
if($consultation=='Oui'){ |
if($consultation=='Oui'){ |
6726 |
$sql="select date_retour,avis_consultation.libelle as avis_consultation, |
$sql = sprintf( |
6727 |
service.libelle as service |
'(SELECT |
6728 |
from ".DB_PREFIXE."consultation inner join ".DB_PREFIXE."service |
date_retour, |
6729 |
on consultation.service =service.service |
avis_consultation.libelle as avis_consultation, |
6730 |
left join ".DB_PREFIXE."avis_consultation on |
COALESCE(service.libelle, tiers_consulte.libelle) as service |
6731 |
consultation.avis_consultation = avis_consultation.avis_consultation |
FROM |
6732 |
where dossier ='".$idx."'"; |
%1$sconsultation |
6733 |
$res = $f->db->query($sql); |
LEFT JOIN %1$stiers_consulte ON consultation.tiers_consulte = tiers_consulte.tiers_consulte |
6734 |
$f->isDatabaseError($res); |
LEFT JOIN %1$sservice ON consultation.service = service.service |
6735 |
|
LEFT JOIN %1$savis_consultation ON consultation.avis_consultation = avis_consultation.avis_consultation |
6736 |
|
WHERE |
6737 |
|
dossier = \'%2$s\' |
6738 |
|
AND consultation.visible)', |
6739 |
|
DB_PREFIXE, |
6740 |
|
$this->f->db->escapeSimple($idx) |
6741 |
|
); |
6742 |
|
$res = $this->f->db->query($sql); |
6743 |
|
$this->f->isDatabaseError($res); |
6744 |
// Récupération des consultations |
// Récupération des consultations |
6745 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
6746 |
$correct=false; |
$correct=false; |
6765 |
$temp=$temp." du ".$date_retour_f; |
$temp=$temp." du ".$date_retour_f; |
6766 |
} |
} |
6767 |
// Concaténation des retours d'avis de consultation |
// Concaténation des retours d'avis de consultation |
6768 |
$retour['complement_om_html'] .= $temp; |
$retour['complement_om_html'] .= $temp . "<br/><br/>"; |
6769 |
} // while |
} // while |
6770 |
|
|
6771 |
} // consultation |
} // consultation |
6772 |
// Récupération des bibles automatiques pour le champ complement_om_html |
// Récupération des bibles automatiques pour le champ complement_om_html |
6773 |
$retour['complement_om_html'] .= $this->getBible($f, $evenement, $idx, '1'); |
$retour['complement_om_html'] .= $this->getBible($evenement, $idx, '1'); |
6774 |
// Récupération des bibles automatiques pour le champ complement2_om_html |
// Récupération des bibles automatiques pour le champ complement2_om_html |
6775 |
$retour['complement2_om_html'] .= $this->getBible($f, $evenement, $idx, '2'); |
$retour['complement2_om_html'] .= $this->getBible($evenement, $idx, '2'); |
6776 |
// Récupération des bibles automatiques pour le champ complement3_om_html |
// Récupération des bibles automatiques pour le champ complement3_om_html |
6777 |
$retour['complement3_om_html'] .= $this->getBible($f, $evenement, $idx, '3'); |
$retour['complement3_om_html'] .= $this->getBible($evenement, $idx, '3'); |
6778 |
// Récupération des bibles automatiques pour le champ complement4_om_html |
// Récupération des bibles automatiques pour le champ complement4_om_html |
6779 |
$retour['complement4_om_html'] .= $this->getBible($f, $evenement, $idx, '4'); |
$retour['complement4_om_html'] .= $this->getBible($evenement, $idx, '4'); |
6780 |
|
|
6781 |
|
|
6782 |
|
|
6784 |
} |
} |
6785 |
|
|
6786 |
/** |
/** |
6787 |
|
* VIEW - view_pdf_temp |
6788 |
|
* |
6789 |
|
* @return void |
6790 |
|
*/ |
6791 |
|
function view_pdf_temp() { |
6792 |
|
$this->checkAccessibility(); |
6793 |
|
// Utilisation de $_POST pour ne pas que les textes soient altérés. |
6794 |
|
$this->f->set_submitted_value(); |
6795 |
|
$merge_fields = array(); |
6796 |
|
// |
6797 |
|
if (array_key_exists('c1', $_POST) === true) { |
6798 |
|
$merge_fields['[complement_instruction]'] = $_POST['c1']; |
6799 |
|
$merge_fields['[complement1_instruction]'] = $_POST['c1']; |
6800 |
|
} |
6801 |
|
if (array_key_exists('c2', $_POST) === true) { |
6802 |
|
$merge_fields['[complement2_instruction]'] = $_POST['c2']; |
6803 |
|
} |
6804 |
|
if (array_key_exists('c3', $_POST) === true) { |
6805 |
|
$merge_fields['[complement3_instruction]'] = $_POST['c3']; |
6806 |
|
} |
6807 |
|
if (array_key_exists('c4', $_POST) === true) { |
6808 |
|
$merge_fields['[complement4_instruction]'] = $_POST['c4']; |
6809 |
|
} |
6810 |
|
$params = array( |
6811 |
|
"watermark" => true, |
6812 |
|
"specific" => array( |
6813 |
|
"merge_fields" => $merge_fields, |
6814 |
|
), |
6815 |
|
); |
6816 |
|
// |
6817 |
|
if (array_key_exists('corps', $_POST) === true) { |
6818 |
|
$params["specific"]["corps"] = array( |
6819 |
|
"mode" => "set", |
6820 |
|
"value" => $_POST['corps'], |
6821 |
|
); |
6822 |
|
} |
6823 |
|
if (array_key_exists('titre', $_POST) === true) { |
6824 |
|
$params["specific"]["titre"] = array( |
6825 |
|
"mode" => "set", |
6826 |
|
"value" => $_POST['titre'], |
6827 |
|
); |
6828 |
|
} |
6829 |
|
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
6830 |
|
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
6831 |
|
$result = $this->compute_pdf_output('lettretype', $this->getVal('lettretype'), $collectivite, null, $params); |
6832 |
|
$retour = array( |
6833 |
|
'base' => base64_encode($result['pdf_output']), |
6834 |
|
); |
6835 |
|
echo json_encode($retour); |
6836 |
|
} |
6837 |
|
|
6838 |
|
/** |
6839 |
|
* Dans le contexte de prévisualisation des éditions, génère le rendu du |
6840 |
|
* PDF sans prise en compte de la valeur des compléments et le retourne en |
6841 |
|
* base 64. |
6842 |
|
* |
6843 |
|
* @return string Rendu PDF converti en base 64. |
6844 |
|
*/ |
6845 |
|
function init_pdf_temp() { |
6846 |
|
$params = array( |
6847 |
|
"watermark" => true, |
6848 |
|
); |
6849 |
|
// Si la rédaction libre est activée sur l'instruction |
6850 |
|
if ($this->getVal("flag_edition_integrale") == 't') { |
6851 |
|
$params["specific"]["corps"] = array( |
6852 |
|
"mode" => "set", |
6853 |
|
"value" => $this->getVal("corps_om_htmletatex"), |
6854 |
|
); |
6855 |
|
$params["specific"]["titre"] = array( |
6856 |
|
"mode" => "set", |
6857 |
|
"value" => $this->getVal("titre_om_htmletat"), |
6858 |
|
); |
6859 |
|
} |
6860 |
|
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
6861 |
|
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
6862 |
|
$result = $this->compute_pdf_output('lettretype', $this->getVal('lettretype'), $collectivite, null, $params); |
6863 |
|
|
6864 |
|
return base64_encode($result['pdf_output']); |
6865 |
|
} |
6866 |
|
|
6867 |
|
/** |
6868 |
* Récupération des éléments de bible. |
* Récupération des éléments de bible. |
6869 |
* |
* |
|
* @param utils $f handler de om_application |
|
6870 |
* @param integer $event id de l'événement |
* @param integer $event id de l'événement |
6871 |
* @param string $idx id du dossier |
* @param string $idx id du dossier |
6872 |
* @param integer $compnb numéro du champ complement |
* @param integer $compnb numéro du champ complement |
6873 |
* |
* |
6874 |
* @return string Chaîne de texte à insérer dans le champ complement |
* @return string Chaîne de texte à insérer dans le champ complement |
6875 |
*/ |
*/ |
6876 |
function getBible($f, $event, $idx, $compnb) { |
function getBible($event, $idx, $compnb) { |
6877 |
// Récupération de la collectivité du dossier |
// Récupération de la collectivité du dossier |
6878 |
require_once "../obj/dossier.class.php"; |
$dossier = $this->f->get_inst__om_dbform(array( |
6879 |
$dossier = new dossier($idx, $f->db, DEBUG); |
"obj" => "dossier", |
6880 |
|
"idx" => $idx, |
6881 |
|
)); |
6882 |
// Récupération du code du type de DA |
// Récupération du code du type de DA |
6883 |
$code_da_type = ''; |
$code_da_type = ''; |
6884 |
if (preg_match('/[A-Za-z]{2,3}/', $idx, $matches) !== false) { |
if (preg_match('/[A-Za-z]{2,3}/', $idx, $matches) !== false) { |
6892 |
LEFT JOIN |
LEFT JOIN |
6893 |
".DB_PREFIXE."om_collectivite |
".DB_PREFIXE."om_collectivite |
6894 |
ON bible.om_collectivite = om_collectivite.om_collectivite |
ON bible.om_collectivite = om_collectivite.om_collectivite |
6895 |
WHERE evenement =".$event." and |
WHERE (evenement =".$event." or evenement IS NULL) and |
6896 |
complement=".$compnb." and |
(complement=".$compnb." OR complement IS NULL) and |
6897 |
automatique='Oui' and |
automatique='Oui' and |
6898 |
(dossier_autorisation_type.code ='".$code_da_type."' or |
(dossier_autorisation_type.code ='".$code_da_type."' or |
6899 |
bible.dossier_autorisation_type IS NULL) and |
bible.dossier_autorisation_type IS NULL) and |
6900 |
(om_collectivite.niveau = '2' OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").")"; |
(om_collectivite.niveau = '2' OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").")"; |
6901 |
|
|
6902 |
$res = $f->db->query($sql); |
$res = $this->f->db->query($sql); |
6903 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
6904 |
$temp = ""; |
$temp = ""; |
6905 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
6906 |
// Remplacement des retours à la ligne par des br |
// Remplacement des retours à la ligne par des br |
6907 |
$temp .= preg_replace( |
$temp .= preg_replace( |
6908 |
'#(\\\r|\\\r\\\n|\\\n)#', '<br/>', $row['contenu'] |
'#(\\\r|\\\r\\\n|\\\n)#', '<br/>', $row['contenu'] |
6909 |
); |
); |
6910 |
|
// Ajout d'un saut de ligne entre chaque bible. |
6911 |
|
$temp .= '<br/>'; |
6912 |
} // fin while |
} // fin while |
6913 |
return $temp; |
return $temp; |
6914 |
} |
} |
6926 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
6927 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
6928 |
|
|
|
// XXX APP |
|
|
|
|
|
$f = $this->f; |
|
|
|
|
6929 |
/** |
/** |
6930 |
* Validation du formulaire |
* Validation du formulaire |
6931 |
*/ |
*/ |
6932 |
// Si le formulaire a été validé |
// Si le formulaire a été validé |
6933 |
if ($f->get_submitted_post_value("validation") !== null) { |
if ($this->f->get_submitted_post_value("validation") !== null) { |
6934 |
// Si un bordereau à été sélectionné |
// Si un bordereau à été sélectionné |
6935 |
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") == "" ) { |
6936 |
// Si aucun bordereau n'a été sélectionné |
// Si aucun bordereau n'a été sélectionné |
6937 |
$message_class = "error"; |
$message_class = "error"; |
6938 |
$message = _("Veuillez selectionner un bordereau."); |
$message = _("Veuillez selectionner un bordereau."); |
6939 |
} |
} |
6940 |
// Sinon si les dates ne sont pas valide |
// Sinon si les dates ne sont pas valide |
6941 |
elseif (($f->get_submitted_post_value("date_bordereau_debut") !== null |
elseif (($this->f->get_submitted_post_value("date_bordereau_debut") !== null |
6942 |
&& $f->get_submitted_post_value("date_bordereau_debut") == "") |
&& $this->f->get_submitted_post_value("date_bordereau_debut") == "") |
6943 |
|| ($f->get_submitted_post_value("date_bordereau_fin") !== null |
|| ($this->f->get_submitted_post_value("date_bordereau_fin") !== null |
6944 |
&& $f->get_submitted_post_value("date_bordereau_fin") == "")) { |
&& $this->f->get_submitted_post_value("date_bordereau_fin") == "")) { |
6945 |
// Si aucune date n'a été saisie |
// Si aucune date n'a été saisie |
6946 |
$message_class = "error"; |
$message_class = "error"; |
6947 |
$message = _("Veuillez saisir une date valide."); |
$message = _("Veuillez saisir une date valide."); |
6948 |
} |
} |
6949 |
|
// Sinon si les dates ne sont pas valides |
6950 |
|
elseif ($this->f->get_submitted_post_value("bordereau") === "bordereau_avis_maire_prefet" |
6951 |
|
&& $this->f->getParameter("id_evenement_bordereau_avis_maire_prefet") == null) { |
6952 |
|
// Si aucune date n'a été saisie |
6953 |
|
$message_class = "error"; |
6954 |
|
$message = _("Erreur de parametrage. Contactez votre administrateur."); |
6955 |
|
} |
6956 |
// Affiche le message de validation |
// Affiche le message de validation |
6957 |
else { |
else { |
6958 |
// 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 |
6959 |
$sql = "SELECT om_etat.libelle |
$sql = "SELECT om_etat.libelle |
6960 |
FROM ".DB_PREFIXE."om_etat |
FROM ".DB_PREFIXE."om_etat |
6961 |
WHERE om_etat.id = '".$f->get_submitted_post_value("bordereau")."'"; |
WHERE om_etat.id = '".$this->f->get_submitted_post_value("bordereau")."'"; |
6962 |
$res = $f->db->getone($sql); |
$res = $this->f->db->getone($sql); |
6963 |
$f->addToLog(__METHOD__.": db->getone(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->getone(\"".$sql."\")", VERBOSE_MODE); |
6964 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
6965 |
// |
// |
6966 |
$message_class = "valid"; |
$message_class = "valid"; |
6967 |
$message = _("Cliquez sur le lien ci-dessous pour telecharger votre bordereau"); |
$message = _("Cliquez sur le lien ci-dessous pour telecharger votre bordereau"); |
6968 |
$message .= " : <br/><br/>"; |
$message .= " : <br/><br/>"; |
6969 |
$message .= "<a class='om-prev-icon pdf-16'"; |
$message .= "<a class='om-prev-icon pdf-16'"; |
6970 |
$message .= " title=\""._("Bordereau")."\""; |
$message .= " title=\""._("Bordereau")."\""; |
6971 |
$message .= "href='../scr/form.php?obj=instruction"; |
$message .= "href='".OM_ROUTE_FORM."&obj=instruction"; |
6972 |
$message .= "&action=220"; |
$message .= "&action=220"; |
6973 |
$message .= "&idx=0"; |
$message .= "&idx=0"; |
6974 |
$message .= "&type_bordereau=".$f->get_submitted_post_value("bordereau"); |
$message .= "&type_bordereau=".$this->f->get_submitted_post_value("bordereau"); |
6975 |
$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"); |
6976 |
$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"); |
6977 |
// Si l'utilisateur est MULTI alors on ajoute le paramètre collectivite |
// Si l'utilisateur est MULTI alors on ajoute le paramètre collectivite |
6978 |
if ($f->get_submitted_post_value("om_collectivite") !== null) { |
if ($this->f->get_submitted_post_value("om_collectivite") !== null) { |
6979 |
$message .= "&collectivite=".$f->get_submitted_post_value("om_collectivite"); |
$message .= "&collectivite=".$this->f->get_submitted_post_value("om_collectivite"); |
6980 |
} |
} |
6981 |
$message .= "'"." target='_blank'>"; |
$message .= "'"." target='_blank'>"; |
6982 |
$message .= $res." "._("du")." ".$f->get_submitted_post_value("date_bordereau_debut") |
$message .= $res." "._("du")." ".$this->f->get_submitted_post_value("date_bordereau_debut") |
6983 |
." "._("au")." ".$f->get_submitted_post_value("date_bordereau_fin"); |
." "._("au")." ".$this->f->get_submitted_post_value("date_bordereau_fin"); |
6984 |
$message .= "</a>"; |
$message .= "</a>"; |
6985 |
} |
} |
6986 |
} |
} |
6990 |
*/ |
*/ |
6991 |
// Affichage du message de validation ou d'erreur |
// Affichage du message de validation ou d'erreur |
6992 |
if (isset($message) && isset($message_class) && $message != "") { |
if (isset($message) && isset($message_class) && $message != "") { |
6993 |
$f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
6994 |
} |
} |
|
// Inclusion de la classe de gestion des formulaires |
|
|
require_once "../obj/om_formulaire.class.php"; |
|
6995 |
// Ouverture du formulaire |
// Ouverture du formulaire |
6996 |
printf("\t<form"); |
printf("\t<form"); |
6997 |
printf(" method=\"post\""); |
printf(" method=\"post\""); |
7000 |
printf(">\n"); |
printf(">\n"); |
7001 |
// Paramétrage des champs du formulaire |
// Paramétrage des champs du formulaire |
7002 |
$champs = array("date_bordereau_debut", "date_bordereau_fin", "bordereau"); |
$champs = array("date_bordereau_debut", "date_bordereau_fin", "bordereau"); |
7003 |
// 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 |
7004 |
// collectivité dans le formulaire |
// collectivité dans le formulaire |
7005 |
if($_SESSION["niveau"] == 2) { |
if ($_SESSION["niveau"] == 2) { |
7006 |
array_push($champs, "om_collectivite"); |
array_push($champs, "om_collectivite"); |
7007 |
} |
} |
7008 |
// Création d'un nouvel objet de type formulaire |
// Création d'un nouvel objet de type formulaire |
7009 |
$form = new formulaire(NULL, 0, 0, $champs); |
$form = $this->f->get_inst__om_formulaire(array( |
7010 |
|
"validation" => 0, |
7011 |
|
"maj" => 0, |
7012 |
|
"champs" => $champs, |
7013 |
|
)); |
7014 |
// Paramétrage du champ date_bordereau_debut |
// Paramétrage du champ date_bordereau_debut |
7015 |
$form->setLib("date_bordereau_debut", _("date_bordereau_debut")); |
$form->setLib("date_bordereau_debut", _("date_bordereau_debut")); |
7016 |
$form->setType("date_bordereau_debut", "date"); |
$form->setType("date_bordereau_debut", "date"); |
7032 |
$form->setType("bordereau", "select"); |
$form->setType("bordereau", "select"); |
7033 |
$form->setRequired("bordereau"); |
$form->setRequired("bordereau"); |
7034 |
// Valeurs des champs |
// Valeurs des champs |
7035 |
if ($f->get_submitted_post_value("validation") !== null) { |
if ($this->f->get_submitted_post_value("validation") !== null) { |
7036 |
$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")); |
7037 |
$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")); |
7038 |
$form->setVal("bordereau", $f->get_submitted_post_value("bordereau")); |
$form->setVal("bordereau", $this->f->get_submitted_post_value("bordereau")); |
7039 |
$form->setVal("om_collectivite", $f->get_submitted_post_value("om_collectivite")); |
$form->setVal("om_collectivite", $this->f->get_submitted_post_value("om_collectivite")); |
7040 |
} |
} |
7041 |
// 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 |
7042 |
// 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 |
7045 |
FROM ".DB_PREFIXE."om_etat |
FROM ".DB_PREFIXE."om_etat |
7046 |
WHERE om_etat.id LIKE 'bordereau_%' |
WHERE om_etat.id LIKE 'bordereau_%' |
7047 |
ORDER BY om_etat.id"; |
ORDER BY om_etat.id"; |
7048 |
$res = $f->db->query($sql); |
$res = $this->f->db->query($sql); |
7049 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
7050 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
7051 |
// Données du select |
// Données du select |
7052 |
$contenu = array( |
$contenu = array( |
7053 |
0 => array("", ), |
0 => array("", ), |
7058 |
$contenu[1][] = $row['libelle']; |
$contenu[1][] = $row['libelle']; |
7059 |
} |
} |
7060 |
$form->setSelect("bordereau", $contenu); |
$form->setSelect("bordereau", $contenu); |
7061 |
// |
// |
7062 |
if($_SESSION["niveau"] == 2) { |
if ($_SESSION["niveau"] == 2) { |
7063 |
$form->setLib("om_collectivite", _("collectivite")); |
$form->setLib("om_collectivite", _("collectivite")); |
7064 |
$form->setType("om_collectivite", "select"); |
$form->setType("om_collectivite", "select"); |
7065 |
|
|
7066 |
// 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 |
7067 |
// de niveau 1 |
// de niveau 1 |
7068 |
$sql = "SELECT om_collectivite, libelle |
$sql = "SELECT om_collectivite, libelle |
7069 |
FROM ".DB_PREFIXE."om_collectivite |
FROM ".DB_PREFIXE."om_collectivite |
7070 |
WHERE niveau = '1' ORDER BY libelle"; |
WHERE niveau = '1' ORDER BY libelle"; |
7071 |
$res = $f->db->query($sql); |
$res = $this->f->db->query($sql); |
7072 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
7073 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
7074 |
// La valeur par défaut du select est Toutes |
// La valeur par défaut du select est Toutes |
7075 |
$list_collectivites = array( |
$list_collectivites = array( |
7076 |
0 => array("", ), |
0 => array("", ), |
7077 |
1 => array(_("toutes")) |
1 => array(_("toutes")) |
7078 |
); |
); |
|
|
|
|
$id_colls = ""; |
|
|
// On stocke dans $id_colls l'id de toutes les collectivités de niveau 1 séparées |
|
|
// par des virgules, pour un traitement plus facile dans la requête de sous-état |
|
|
while ($row =& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
|
|
if ($id_colls != "") { |
|
|
$id_colls .= ","; |
|
|
} |
|
|
$id_colls .= $row['om_collectivite']; |
|
|
$list_collectivites[0][] = $row['om_collectivite']; |
|
|
$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); |
|
|
} |
|
7079 |
|
|
7080 |
|
$id_colls = ""; |
7081 |
|
// On stocke dans $id_colls l'id de toutes les collectivités de niveau 1 séparées |
7082 |
|
// par des virgules, pour un traitement plus facile dans la requête de sous-état |
7083 |
|
while ($row =& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
7084 |
|
if ($id_colls != "") { |
7085 |
|
$id_colls .= ","; |
7086 |
|
} |
7087 |
|
$id_colls .= $row['om_collectivite']; |
7088 |
|
$list_collectivites[0][] = $row['om_collectivite']; |
7089 |
|
$list_collectivites[1][] = $row['libelle']; |
7090 |
|
} |
7091 |
|
// On affecte la liste d'identifiants à l'option Toutes |
7092 |
|
$list_collectivites[0][0] = $id_colls ; |
7093 |
|
$form->setSelect("om_collectivite", $list_collectivites); |
7094 |
|
} |
7095 |
// Affichage du formulaire |
// Affichage du formulaire |
7096 |
$form->entete(); |
$form->entete(); |
7097 |
$form->afficher($champs, 0, false, false); |
$form->afficher($champs, 0, false, false); |
7098 |
$form->enpied(); |
$form->enpied(); |
7099 |
// Affichage du bouton |
// Affichage du bouton |
7100 |
printf("\t<div class=\"formControls\">\n"); |
printf("\t<div class=\"formControls\">\n"); |
7101 |
$f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
$this->f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
7102 |
printf("\t</div>\n"); |
printf("\t</div>\n"); |
7103 |
// Fermeture du formulaire |
// Fermeture du formulaire |
7104 |
printf("\t</form>\n"); |
printf("\t</form>\n"); |
|
|
|
7105 |
} |
} |
7106 |
|
|
7107 |
|
|
7130 |
/** |
/** |
7131 |
* VIEW - view_suivi_envoi_lettre_rar. |
* VIEW - view_suivi_envoi_lettre_rar. |
7132 |
* |
* |
7133 |
* Vu pour imprimer les RAR. |
* Vue pour imprimer les AR. |
7134 |
* |
* |
7135 |
* @return void |
* @return void |
7136 |
*/ |
*/ |
7138 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
7139 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
7140 |
|
|
|
// XXX APP |
|
|
|
|
|
$f = $this->f; |
|
|
|
|
7141 |
// |
// |
7142 |
if ($f->get_submitted_post_value("date") !== null) { |
if ($this->f->get_submitted_post_value("date") !== null) { |
7143 |
$date = $f->get_submitted_post_value("date"); |
$date = $this->f->get_submitted_post_value("date"); |
7144 |
} else { |
} else { |
7145 |
$date = ""; |
$date = ""; |
7146 |
} |
} |
7147 |
// |
// |
7148 |
if ($f->get_submitted_post_value("liste_code_barres_instruction") !== null) { |
if ($this->f->get_submitted_post_value("liste_code_barres_instruction") !== null) { |
7149 |
$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"); |
7150 |
} else { |
} else { |
7151 |
$liste_code_barres_instruction = ""; |
$liste_code_barres_instruction = ""; |
7152 |
} |
} |
7172 |
* Validation du formulaire |
* Validation du formulaire |
7173 |
*/ |
*/ |
7174 |
// Si le formulaire a été validé |
// Si le formulaire a été validé |
7175 |
if ($f->get_submitted_post_value('validation') !== null) { |
if ($this->f->get_submitted_post_value('validation') !== null) { |
7176 |
// |
// |
7177 |
if (empty($date) || empty($liste_code_barres_instruction)) { |
if (empty($date) || empty($liste_code_barres_instruction)) { |
7178 |
// |
// |
7180 |
$message = _("Tous les champs doivent etre remplis."); |
$message = _("Tous les champs doivent etre remplis."); |
7181 |
} else { |
} else { |
7182 |
// Création d'un tableau d'instruction |
// Création d'un tableau d'instruction |
7183 |
$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")); |
7184 |
// |
// |
7185 |
foreach ($liste as $code_barres) { |
foreach ($liste as $code_barres) { |
7186 |
// On enlève les éventuels espaces saisis |
// On enlève les éventuels espaces saisis |
7202 |
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 |
7203 |
INNER JOIN ".DB_PREFIXE."groupe |
INNER JOIN ".DB_PREFIXE."groupe |
7204 |
ON dossier_autorisation_type.groupe = groupe.groupe |
ON dossier_autorisation_type.groupe = groupe.groupe |
|
AND groupe.code != 'CTX' |
|
7205 |
WHERE code_barres='".$this->f->db->escapesimple($code_barres)."'"; |
WHERE code_barres='".$this->f->db->escapesimple($code_barres)."'"; |
7206 |
$nbInstr = $f->db->getone($sql); |
|
7207 |
$f->addToLog(__METHOD__.": db->getone(\"".$sql."\")", VERBOSE_MODE); |
// Ajout d'un filtre sur les groupes auxquels l'utilisateur a accès |
7208 |
$f->isDatabaseError($nbInstr); |
$group_clause = array(); |
7209 |
|
foreach ($_SESSION["groupe"] as $key => $value) { |
7210 |
|
$group_clause[$key] = "(groupe.code = '".$key."'"; |
7211 |
|
if($value["confidentiel"] !== true) { |
7212 |
|
$group_clause[$key] .= " AND dossier_autorisation_type.confidentiel IS NOT TRUE"; |
7213 |
|
} |
7214 |
|
$group_clause[$key] .= ")"; |
7215 |
|
} |
7216 |
|
$conditions = implode(" OR ", $group_clause); |
7217 |
|
$sql .= " AND (" . $conditions . ")"; |
7218 |
|
|
7219 |
|
$nbInstr = $this->f->db->getone($sql); |
7220 |
|
$this->f->addToLog(__METHOD__.": db->getone(\"".$sql."\")", VERBOSE_MODE); |
7221 |
|
$this->f->isDatabaseError($nbInstr); |
7222 |
// |
// |
7223 |
if ($nbInstr == "1") { |
if ($nbInstr == "1") { |
7224 |
// Récupération de la date d'envoi de l'instruction bippé |
// Récupération de la date d'envoi de l'instruction bippé |
7225 |
$sql = "SELECT to_char(date_envoi_rar,'DD/MM/YYYY') as date_envoi_rar, instruction FROM ".DB_PREFIXE."instruction WHERE code_barres='".$code_barres."'"; |
$sql = "SELECT to_char(date_envoi_rar,'DD/MM/YYYY') as date_envoi_rar, instruction FROM ".DB_PREFIXE."instruction WHERE code_barres='".$code_barres."'"; |
7226 |
$res = $f->db->query($sql); |
$res = $this->f->db->query($sql); |
7227 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
7228 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
7229 |
$row =& $res->fetchRow(DB_FETCHMODE_ASSOC); |
$row =& $res->fetchRow(DB_FETCHMODE_ASSOC); |
7230 |
// Si pas de date ou correspond à la date du formulaire on |
// Si pas de date ou correspond à la date du formulaire on |
7231 |
// effectue le traitement |
// effectue le traitement |
7232 |
if ($row["date_envoi_rar"] == "" || $row["date_envoi_rar"] == $date) { |
if ($row["date_envoi_rar"] == "" || $row["date_envoi_rar"] == $date) { |
7233 |
|
$instr = $this->f->get_inst__om_dbform(array( |
7234 |
require_once '../obj/instruction.class.php'; |
"obj" => "instruction", |
7235 |
require_once '../obj/dossier.class.php'; |
"idx" => $row['instruction'], |
7236 |
|
)); |
|
$instr = new instruction($row['instruction'], $f->db, DEBUG); |
|
7237 |
$valF = array(); |
$valF = array(); |
7238 |
foreach($instr->champs as $id => $champ) { |
foreach($instr->champs as $id => $champ) { |
7239 |
$valF[$champ] = $instr->val[$id]; |
$valF[$champ] = $instr->val[$id]; |
7242 |
# Si on peut consulter les dossiers et que le dossier n'existe pas déjà dans la liste |
# Si on peut consulter les dossiers et que le dossier n'existe pas déjà dans la liste |
7243 |
if ($isAccredited === true |
if ($isAccredited === true |
7244 |
&& array_key_exists($instr->getVal("dossier"), $dossierTab) === false) { |
&& array_key_exists($instr->getVal("dossier"), $dossierTab) === false) { |
7245 |
$dossier = new dossier($instr->getVal("dossier")); |
$dossier = $this->f->get_inst__om_dbform(array( |
7246 |
|
"obj" => "dossier", |
7247 |
|
"idx" => $instr->getVal("dossier"), |
7248 |
|
)); |
7249 |
if ($dossier->is_user_from_allowed_collectivite()){ |
if ($dossier->is_user_from_allowed_collectivite()){ |
7250 |
$dossierTab[$instr->getVal("dossier")] = $dossier; |
$dossierTab[$instr->getVal("dossier")] = $dossier; |
7251 |
} else { |
} else { |
7299 |
$instr->setParameter('maj', 1); |
$instr->setParameter('maj', 1); |
7300 |
$instr->class_actions[1]["identifier"] = |
$instr->class_actions[1]["identifier"] = |
7301 |
"envoi lettre RAR (depuis le menu suivi des pièces)"; |
"envoi lettre RAR (depuis le menu suivi des pièces)"; |
7302 |
if ($instr->modifier($valF, $f->db, DEBUG) == true) { |
if ($instr->modifier($valF) == true) { |
7303 |
$id4Gen[] = $code_barres; |
$id4Gen[] = $code_barres; |
7304 |
$nbLettres ++; |
$nbLettres ++; |
7305 |
} else { |
} else { |
7354 |
*/ |
*/ |
7355 |
// Affichage du message de validation ou d'erreur |
// Affichage du message de validation ou d'erreur |
7356 |
if (isset($message) && isset($message_class) && $message != "") { |
if (isset($message) && isset($message_class) && $message != "") { |
7357 |
$f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
7358 |
} |
} |
7359 |
// Affichage du message d'erreur |
// Affichage du message d'erreur |
7360 |
if(!empty($error)) { |
if(!empty($error)) { |
7361 |
$f->displayMessage("error", $error); |
$this->f->displayMessage("error", $error); |
7362 |
} |
} |
7363 |
// Affichage du message de validation de la saisie |
// Affichage du message de validation de la saisie |
7364 |
if ($nbLettres > 0) { |
if ($nbLettres > 0) { |
7370 |
echo _("Cliquez sur le lien ci-dessous pour telecharger votre document"); |
echo _("Cliquez sur le lien ci-dessous pour telecharger votre document"); |
7371 |
echo " : \n<br/><br/>"; |
echo " : \n<br/><br/>"; |
7372 |
echo "\n<a class='om-prev-icon pdf-16'"; |
echo "\n<a class='om-prev-icon pdf-16'"; |
7373 |
echo "\n title=\""._("imprimer les RAR")."\""; |
echo "\n title=\""._("imprimer les AR")."\""; |
7374 |
echo "\n href=\"../scr/form.php?obj=instruction&action=180&idx=0&liste=".implode(",",$id4Gen)."\""; |
echo "\n href=\"".OM_ROUTE_FORM."&obj=instruction&action=180&idx=0&liste=".implode(",",$id4Gen)."\""; |
7375 |
echo "\n target='_blank'>"; |
echo "\n target='_blank'>"; |
7376 |
echo _("Telecharger le document pour")." ".$nbLettres." "._("RAR"); |
echo _("Telecharger le document pour")." ".$nbLettres." "._("AR"); |
7377 |
echo "\n</a>"; |
echo "\n</a>"; |
7378 |
echo "\n</span>"; |
echo "\n</span>"; |
7379 |
echo "\n</p>"; |
echo "\n</p>"; |
7395 |
echo "\n<br/>"; |
echo "\n<br/>"; |
7396 |
} |
} |
7397 |
foreach ($dossierTab as $dossier) { |
foreach ($dossierTab as $dossier) { |
7398 |
|
|
7399 |
|
$inst_da = $this->get_inst_common("dossier_autorisation", $dossier->getVal('dossier_autorisation')); |
7400 |
|
$inst_datd = $this->get_inst_common("dossier_autorisation_type_detaille", $inst_da->getVal('dossier_autorisation_type_detaille')); |
7401 |
|
$code_datd = $inst_datd->getVal('code'); |
7402 |
|
|
7403 |
|
$obj = "dossier_instruction"; |
7404 |
|
if ($code_datd === 'REC' OR $code_datd === 'REG') { |
7405 |
|
$obj = "dossier_contentieux_tous_recours"; |
7406 |
|
} |
7407 |
|
if ($code_datd === 'IN') { |
7408 |
|
$obj = "dossier_contentieux_toutes_infractions"; |
7409 |
|
} |
7410 |
|
|
7411 |
echo "\n<div class=\"bloc group\">"; |
echo "\n<div class=\"bloc group\">"; |
7412 |
echo "\n<div class=\"field field-type-text\">"; |
echo "\n<div class=\"field field-type-text\">"; |
7413 |
|
|
7414 |
echo "\n<p>"; |
echo "\n<p>"; |
7415 |
echo "\n<span class='text'>"; |
echo "\n<span class='text'>"; |
7416 |
echo "\n<a class=\"om-icon om-icon-16 consult-16\" title=\"" . _('Consulter') . "\""; |
echo "\n<a class=\"om-icon om-icon-16 consult-16\" title=\"" . _('Consulter') . "\""; |
7417 |
echo "\n href=\"../scr/form.php?obj=dossier_instruction&action=3&idx="; |
echo "\n href=\"".OM_ROUTE_FORM."&obj=dossier_instruction&action=3&idx="; |
7418 |
echo $dossier->getVal("dossier"); |
echo $dossier->getVal("dossier"); |
7419 |
echo "\">"; |
echo "\">"; |
7420 |
echo "\n</a>"; |
echo "\n</a>"; |
7421 |
|
|
7422 |
echo "\n<a title=\""._("Consulter")."\" style=\"vertical-align:middle;\""; |
echo "\n<a title=\""._("Consulter")."\" style=\"vertical-align:middle;\""; |
7423 |
echo " href=\"../scr/form.php?obj=dossier_instruction&action=3&idx="; |
echo " href=\"".OM_ROUTE_FORM."&obj="; |
7424 |
|
echo $obj; |
7425 |
|
echo "&action=3&idx="; |
7426 |
echo $dossier->getVal("dossier"); |
echo $dossier->getVal("dossier"); |
7427 |
echo "\">"; |
echo "\">"; |
7428 |
echo $dossier->getVal("dossier_libelle"); |
echo $dossier->getVal("dossier_libelle"); |
7439 |
echo "\n</div>"; |
echo "\n</div>"; |
7440 |
echo "\n</div>"; |
echo "\n</div>"; |
7441 |
} |
} |
|
// Inclusion de la classe de gestion des formulaires |
|
|
require_once "../obj/om_formulaire.class.php"; |
|
7442 |
// Ouverture du formulaire |
// Ouverture du formulaire |
7443 |
echo "\t<form"; |
echo "\t<form"; |
7444 |
echo " method=\"post\""; |
echo " method=\"post\""; |
7448 |
// Paramétrage des champs du formulaire |
// Paramétrage des champs du formulaire |
7449 |
$champs = array("date", "liste_code_barres_instruction"); |
$champs = array("date", "liste_code_barres_instruction"); |
7450 |
// Création d'un nouvel objet de type formulaire |
// Création d'un nouvel objet de type formulaire |
7451 |
$form = new formulaire(NULL, 0, 0, $champs); |
$form = $this->f->get_inst__om_formulaire(array( |
7452 |
|
"validation" => 0, |
7453 |
|
"maj" => 0, |
7454 |
|
"champs" => $champs, |
7455 |
|
)); |
7456 |
// Paramétrage du champ date du formulaire |
// Paramétrage du champ date du formulaire |
7457 |
$form->setLib("date", _("Date")."* :"); |
$form->setLib("date", _("Date")."* :"); |
7458 |
$form->setType("date", "date"); |
$form->setType("date", "date"); |
7472 |
$form->enpied(); |
$form->enpied(); |
7473 |
// Affichage du bouton |
// Affichage du bouton |
7474 |
echo "\t<div class=\"formControls\">\n"; |
echo "\t<div class=\"formControls\">\n"; |
7475 |
$f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
$this->f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
7476 |
echo "\t</div>\n"; |
echo "\t</div>\n"; |
7477 |
// Fermeture du formulaire |
// Fermeture du formulaire |
7478 |
echo "\t</form>\n"; |
echo "\t</form>\n"; |
7489 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
7490 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
7491 |
|
|
|
// XXX APP |
|
|
|
|
|
$f = $this->f; |
|
|
|
|
7492 |
// Récupération des valeur passées en POST ou GET |
// Récupération des valeur passées en POST ou GET |
7493 |
if($f->get_submitted_post_value("type_mise_a_jour") !== null) { |
if($this->f->get_submitted_post_value("type_mise_a_jour") !== null) { |
7494 |
$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"); |
7495 |
} elseif($f->get_submitted_get_value('type_mise_a_jour') !== null) { |
} elseif($this->f->get_submitted_get_value('type_mise_a_jour') !== null) { |
7496 |
$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'); |
7497 |
} else { |
} else { |
7498 |
$type_mise_a_jour = ""; |
$type_mise_a_jour = ""; |
7499 |
} |
} |
7500 |
if($f->get_submitted_post_value('date') !== null) { |
if($this->f->get_submitted_post_value('date') !== null) { |
7501 |
$date = $f->get_submitted_post_value('date'); |
$date = $this->f->get_submitted_post_value('date'); |
7502 |
} elseif($f->get_submitted_get_value('date') !== null) { |
} elseif($this->f->get_submitted_get_value('date') !== null) { |
7503 |
$date = $f->get_submitted_get_value('date'); |
$date = $this->f->get_submitted_get_value('date'); |
7504 |
} else { |
} else { |
7505 |
$date = ""; |
$date = ""; |
7506 |
} |
} |
7507 |
if($f->get_submitted_post_value('code_barres') !== null) { |
if($this->f->get_submitted_post_value('code_barres') !== null) { |
7508 |
$code_barres = $f->get_submitted_post_value('code_barres'); |
$code_barres = $this->f->get_submitted_post_value('code_barres'); |
7509 |
} elseif($f->get_submitted_get_value('code_barres') !== null) { |
} elseif($this->f->get_submitted_get_value('code_barres') !== null) { |
7510 |
$code_barres = $f->get_submitted_get_value('code_barres'); |
$code_barres = $this->f->get_submitted_get_value('code_barres'); |
7511 |
} else { |
} else { |
7512 |
$code_barres = ""; |
$code_barres = ""; |
7513 |
} |
} |
7519 |
$liste_champs=array(); |
$liste_champs=array(); |
7520 |
|
|
7521 |
// Si le formulaire a été validé |
// Si le formulaire a été validé |
7522 |
if ($f->get_submitted_post_value('validation') !== null) { |
if ($this->f->get_submitted_post_value('validation') !== null) { |
7523 |
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)) { |
7524 |
|
|
7525 |
// Vérification de l'existence de l'instruction |
// Vérification de l'existence de l'instruction |
7535 |
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 |
7536 |
INNER JOIN ".DB_PREFIXE."groupe |
INNER JOIN ".DB_PREFIXE."groupe |
7537 |
ON dossier_autorisation_type.groupe = groupe.groupe |
ON dossier_autorisation_type.groupe = groupe.groupe |
|
AND groupe.code != 'CTX' |
|
7538 |
WHERE code_barres='".$this->f->db->escapesimple($code_barres)."'"; |
WHERE code_barres='".$this->f->db->escapesimple($code_barres)."'"; |
7539 |
$res = $f->db->query($sql); |
|
7540 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
// Ajout d'un filtre sur les groupes auxquels l'utilisateur a accès |
7541 |
$f->isDatabaseError($res); |
$group_clause = array(); |
7542 |
|
foreach ($_SESSION["groupe"] as $key => $value) { |
7543 |
|
$group_clause[$key] = "(groupe.code = '".$key."'"; |
7544 |
|
if($value["confidentiel"] !== true) { |
7545 |
|
$group_clause[$key] .= " AND dossier_autorisation_type.confidentiel IS NOT TRUE"; |
7546 |
|
} |
7547 |
|
$group_clause[$key] .= ")"; |
7548 |
|
} |
7549 |
|
$conditions = implode(" OR ", $group_clause); |
7550 |
|
$sql .= " AND (" . $conditions . ")"; |
7551 |
|
|
7552 |
|
|
7553 |
|
$res = $this->f->db->query($sql); |
7554 |
|
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
7555 |
|
$this->f->isDatabaseError($res); |
7556 |
|
|
7557 |
if($res->numrows() == 1) { |
if($res->numrows() == 1) { |
7558 |
$liste_champs = explode(";", $type_mise_a_jour); |
$liste_champs = explode(";", $type_mise_a_jour); |
7559 |
|
$row =& $res->fetchRow(DB_FETCHMODE_ASSOC); |
7560 |
|
$instr = $this->f->get_inst__om_dbform(array( |
7561 |
|
"obj" => "instruction", |
7562 |
|
"idx" => $row['instruction'], |
7563 |
|
)); |
7564 |
// Mise à jour des dates après l'écran de verification |
// Mise à jour des dates après l'écran de verification |
7565 |
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") { |
|
require_once '../obj/instruction.class.php'; |
|
|
$row =& $res->fetchRow(DB_FETCHMODE_ASSOC); |
|
|
$instr = new instruction($row['instruction'], $f->db, DEBUG); |
|
7566 |
$valF = array(); |
$valF = array(); |
7567 |
foreach($instr->champs as $id => $champ) { |
foreach($instr->champs as $id => $champ) { |
7568 |
$valF[$champ] = $instr->val[$id]; |
$valF[$champ] = $instr->val[$id]; |
7605 |
$code_barres = ""; |
$code_barres = ""; |
7606 |
|
|
7607 |
//Désactivation de l'autocommit |
//Désactivation de l'autocommit |
7608 |
$f->db->autoCommit(false); |
$this->f->db->autoCommit(false); |
7609 |
|
|
7610 |
//On modifie les valeurs de l'instruction |
//On modifie les valeurs de l'instruction |
7611 |
$instr->setParameter('maj', 170); |
$instr->setParameter('maj', 170); |
7612 |
$instr->class_actions[170]["identifier"] = |
$instr->class_actions[170]["identifier"] = |
7613 |
"mise à jour des dates (depuis le menu suivi des pièces)"; |
"mise à jour des dates (depuis le menu suivi des pièces)"; |
7614 |
$retour = $instr->modifier($valF, $f->db, DEBUG); |
$retour = $instr->modifier($valF); |
7615 |
|
|
7616 |
//Si une erreur s'est produite, on défait les modifications |
//Si une erreur s'est produite, on défait les modifications |
7617 |
//qui ont été faites |
//qui ont été faites |
7620 |
} |
} |
7621 |
//Sinon, on valide en base de données les modifications |
//Sinon, on valide en base de données les modifications |
7622 |
else { |
else { |
7623 |
$f->db->commit(); |
$this->f->db->commit(); |
7624 |
} |
} |
7625 |
|
|
7626 |
// Variable correct retourné depuis la classe instruction |
// Variable correct retourné depuis la classe instruction |
7661 |
INNER JOIN ".DB_PREFIXE."evenement ON |
INNER JOIN ".DB_PREFIXE."evenement ON |
7662 |
instruction.evenement=evenement.evenement |
instruction.evenement=evenement.evenement |
7663 |
WHERE code_barres='".$code_barres."'"; |
WHERE code_barres='".$code_barres."'"; |
7664 |
$resInfo = $f->db->query($sqlInfo); |
$resInfo = $this->f->db->query($sqlInfo); |
7665 |
$f->isDatabaseError($resInfo); |
$this->f->isDatabaseError($resInfo); |
7666 |
$infos = $resInfo->fetchRow(DB_FETCHMODE_ASSOC); |
$infos = $resInfo->fetchRow(DB_FETCHMODE_ASSOC); |
7667 |
|
|
7668 |
// Vérification de la non modification des dates de suivi |
// Vérification de la non modification des dates de suivi |
7669 |
foreach(explode(";", $type_mise_a_jour) as $champ) { |
foreach(explode(";", $type_mise_a_jour) as $champ) { |
7670 |
|
if ($champ === 'date_envoi_controle_legalite') { |
7671 |
|
if ($instr->is_sent_to_cl() === true) { |
7672 |
|
$error = __("Les dates de suivis ne peuvent etre modifiees"); |
7673 |
|
$date_error = true; |
7674 |
|
break; |
7675 |
|
} |
7676 |
|
} |
7677 |
if($infos[$champ] != "" AND $infos[$champ] != $date) { |
if($infos[$champ] != "" AND $infos[$champ] != $date) { |
7678 |
$error = _("Les dates de suivis ne peuvent etre modifiees"); |
$error = _("Les dates de suivis ne peuvent etre modifiees"); |
7679 |
$date_error = true; |
$date_error = true; |
7680 |
|
break; |
7681 |
} |
} |
7682 |
} |
} |
7683 |
} |
} |
7695 |
*/ |
*/ |
7696 |
// Affichage du message de validation ou d'erreur |
// Affichage du message de validation ou d'erreur |
7697 |
if (isset($message) && isset($message_class) && $message != "") { |
if (isset($message) && isset($message_class) && $message != "") { |
7698 |
$f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
7699 |
} |
} |
7700 |
// Affichage du message d'erreur |
// Affichage du message d'erreur |
7701 |
if(!empty($error)) { |
if(!empty($error)) { |
7702 |
$f->displayMessage("error", $error); |
$this->f->displayMessage("error", $error); |
7703 |
} |
} |
7704 |
|
|
7705 |
// Affichage du message de validation de la saisie |
// Affichage du message de validation de la saisie |
7706 |
if($correct === true) { |
if($correct === true) { |
7707 |
$f->displayMessage("ok", _("Saisie enregistree")); |
$this->f->displayMessage("ok", _("Saisie enregistree")); |
7708 |
} |
} |
|
// Inclusion de la classe de gestion des formulaires |
|
|
require_once "../obj/om_formulaire.class.php"; |
|
7709 |
// Ouverture du formulaire |
// Ouverture du formulaire |
7710 |
echo "\t<form"; |
echo "\t<form"; |
7711 |
echo " method=\"post\""; |
echo " method=\"post\""; |
7723 |
$champs = array("type_mise_a_jour", "date", "code_barres"); |
$champs = array("type_mise_a_jour", "date", "code_barres"); |
7724 |
} |
} |
7725 |
// Création d'un nouvel objet de type formulaire |
// Création d'un nouvel objet de type formulaire |
7726 |
$form = new formulaire(NULL, 0, 0, $champs); |
$form = $this->f->get_inst__om_formulaire(array( |
7727 |
|
"validation" => 0, |
7728 |
|
"maj" => 0, |
7729 |
|
"champs" => $champs, |
7730 |
|
)); |
7731 |
// Paramétrage des champs du formulaire |
// Paramétrage des champs du formulaire |
7732 |
// Parametrage du champ type_mise_a_jour |
// Parametrage du champ type_mise_a_jour |
7733 |
$form->setLib("type_mise_a_jour", _("Date a mettre a jour")."* :"); |
$form->setLib("type_mise_a_jour", _("Date a mettre a jour")."* :"); |
7757 |
$contenu[1][4] = _("date de retour de controle de legalite"); |
$contenu[1][4] = _("date de retour de controle de legalite"); |
7758 |
|
|
7759 |
$contenu[0][5] = "date_retour_rar"; |
$contenu[0][5] = "date_retour_rar"; |
7760 |
$contenu[1][5] = _("date de retour de l'AR"); |
$contenu[1][5] = __("date de notification du correspondant"); |
7761 |
|
|
7762 |
$form->setSelect("type_mise_a_jour", $contenu); |
$form->setSelect("type_mise_a_jour", $contenu); |
7763 |
|
|
7817 |
$form->setType("autorite_competente", "static"); |
$form->setType("autorite_competente", "static"); |
7818 |
$form->setVal("autorite_competente", $infos['autorite_competente']); |
$form->setVal("autorite_competente", $infos['autorite_competente']); |
7819 |
|
|
7820 |
// Parametrage des libellés d'envoi avec RAR |
// Parametrage des libellés d'envoi avec AR |
7821 |
$form->setLib("date_envoi_rar", _("date_envoi_rar")." :"); |
$form->setLib("date_envoi_rar", __("date_envoi_ar")." :"); |
7822 |
$form->setLib("date_retour_rar", _("date_retour_rar")." :"); |
$form->setLib("date_retour_rar", __("date_notification")." :"); |
7823 |
|
|
7824 |
$form->setLib("date_envoi_signature", _("date_envoi_signature")." :"); |
$form->setLib("date_envoi_signature", _("date_envoi_signature")." :"); |
7825 |
$form->setLib("date_retour_signature", _("date_retour_signature")." :"); |
$form->setLib("date_retour_signature", _("date_retour_signature")." :"); |
7853 |
echo "\t<div class=\"formControls\">\n"; |
echo "\t<div class=\"formControls\">\n"; |
7854 |
// |
// |
7855 |
if(!$date_error) { |
if(!$date_error) { |
7856 |
$f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
$this->f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
7857 |
} |
} |
7858 |
// Si pas sur l'écran de validation |
// Si pas sur l'écran de validation |
7859 |
if(isset($infos)) { |
if(isset($infos)) { |
7860 |
echo "<a class=\"retour\" href=\"../scr/form.php?obj=instruction_suivi_mise_a_jour_des_dates&action=170&idx=0"; |
echo "<a class=\"retour\" href=\"".OM_ROUTE_FORM."&obj=instruction_suivi_mise_a_jour_des_dates&action=170&idx=0"; |
7861 |
echo "&type_mise_a_jour=".$type_mise_a_jour."&date=".$date."&code_barres=".$code_barres; |
echo "&type_mise_a_jour=".$type_mise_a_jour."&date=".$date."&code_barres=".$code_barres; |
7862 |
echo "\">Retour</a>"; |
echo "\">Retour</a>"; |
7863 |
} |
} |
7874 |
function view_pdf_lettre_rar() { |
function view_pdf_lettre_rar() { |
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 |
|
// |
7878 |
|
$this->f->disableLog(); |
7879 |
|
|
7880 |
// XXX APP |
if($this->f->get_submitted_get_value('liste') != null) { |
7881 |
|
$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')); |
|
7882 |
|
|
7883 |
// Classe permettant la mise en page de l'édition pdf |
// Classe permettant la mise en page de l'édition pdf |
7884 |
require_once "../obj/pdf_lettre_rar.class.php"; |
require_once "../obj/pdf_lettre_rar.class.php"; |
7885 |
$pdf_lettre_rar = new pdf_lettre_rar('P', 'mm', 'A4'); |
$pdf_lettre_rar = new pdf_lettre_rar('P', 'mm', 'A4'); |
7886 |
// Initialisation de la mise en page |
// Initialisation de la mise en page |
7887 |
$pdf_lettre_rar->init($f); |
$pdf_lettre_rar->init($this->f); |
7888 |
|
|
7889 |
foreach ($listeCodeBarres as $code_barres) { |
foreach ($listeCodeBarres as $code_barres) { |
7890 |
|
|
7891 |
|
// On récupère le dossier |
7892 |
|
$sql = "SELECT dossier |
7893 |
|
FROM " . DB_PREFIXE . "instruction |
7894 |
|
WHERE code_barres = '" . $code_barres . "'"; |
7895 |
|
$dossier = $this->f->db->getOne($sql); |
7896 |
|
$this->f->addToLog(__METHOD__."(): db->getOne(\"".$sql."\")", VERBOSE_MODE); |
7897 |
|
$this->f->isDatabaseError($dossier); |
7898 |
|
$inst_dossier = $this->f->get_inst__om_dbform(array( |
7899 |
|
"obj" => "dossier", |
7900 |
|
"idx" => $dossier, |
7901 |
|
)); |
7902 |
|
|
7903 |
|
// En fonction du type de dossier, on récupère un demandeur différent dans les requêtes |
7904 |
|
$groupe = $inst_dossier->get_type_affichage_formulaire(); |
7905 |
|
switch ($groupe) { |
7906 |
|
case 'CTX IN': |
7907 |
|
$sql_demandeur = "(lien_dossier_demandeur.petitionnaire_principal IS TRUE AND demandeur.type_demandeur='plaignant')"; |
7908 |
|
break; |
7909 |
|
case 'CTX RE': |
7910 |
|
$sql_demandeur = "(lien_dossier_demandeur.petitionnaire_principal IS TRUE AND demandeur.type_demandeur='requerant')"; |
7911 |
|
break; |
7912 |
|
case 'ADS': |
7913 |
|
case 'DPC': |
7914 |
|
case 'CONSULTATION ENTRANTE': |
7915 |
|
default: |
7916 |
|
$sql_demandeur = "((lien_dossier_demandeur.petitionnaire_principal IS TRUE AND demandeur.type_demandeur='petitionnaire') OR demandeur.type_demandeur='delegataire')"; |
7917 |
|
break; |
7918 |
|
} |
7919 |
|
|
7920 |
// 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é |
7921 |
$sql = "SELECT |
$sql = "SELECT |
7922 |
dossier.dossier_libelle, |
dossier.dossier_libelle, |
7942 |
inner join ".DB_PREFIXE."demandeur on |
inner join ".DB_PREFIXE."demandeur on |
7943 |
demandeur.demandeur=lien_dossier_demandeur.demandeur |
demandeur.demandeur=lien_dossier_demandeur.demandeur |
7944 |
WHERE code_barres='".$code_barres."' |
WHERE code_barres='".$code_barres."' |
7945 |
AND ((lien_dossier_demandeur.petitionnaire_principal IS TRUE AND demandeur.type_demandeur='petitionnaire') |
AND " . $sql_demandeur . " |
|
OR demandeur.type_demandeur='delegataire') |
|
7946 |
GROUP BY dossier.dossier_libelle, evenement.type, phase.code, division.libelle"; |
GROUP BY dossier.dossier_libelle, evenement.type, phase.code, division.libelle"; |
7947 |
|
|
7948 |
$res = $f->db->query($sql); |
$res = $this->f->db->query($sql); |
7949 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
7950 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
7951 |
$testDemandeur = $res->fetchrow(DB_FETCHMODE_ASSOC); |
$testDemandeur = $res->fetchrow(DB_FETCHMODE_ASSOC); |
7952 |
|
|
7953 |
|
|
7996 |
if($testDemandeur['type'] != 'arrete' AND $testDemandeur['nbdemandeur'] > 1) { |
if($testDemandeur['type'] != 'arrete' AND $testDemandeur['nbdemandeur'] > 1) { |
7997 |
$sqlAdresse .= " AND demandeur.type_demandeur='delegataire'"; |
$sqlAdresse .= " AND demandeur.type_demandeur='delegataire'"; |
7998 |
} else { |
} else { |
7999 |
$sqlAdresse .= " AND lien_dossier_demandeur.petitionnaire_principal IS TRUE AND demandeur.type_demandeur='petitionnaire'"; |
$sqlAdresse .= " AND demandeur.type_demandeur='petitionnaire' AND lien_dossier_demandeur.petitionnaire_principal IS TRUE"; |
8000 |
} |
} |
8001 |
|
|
8002 |
$resAdresse = $f->db->query($sqlAdresse); |
$resAdresse = $this->f->db->query($sqlAdresse); |
8003 |
$adresse_dest = $resAdresse->fetchrow(DB_FETCHMODE_ASSOC); |
$adresse_dest = $resAdresse->fetchrow(DB_FETCHMODE_ASSOC); |
8004 |
$f->addToLog(__METHOD__.": db->query(\"".$sqlAdresse."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->query(\"".$sqlAdresse."\")", VERBOSE_MODE); |
8005 |
$f->isDatabaseError($resAdresse); |
$this->f->isDatabaseError($resAdresse); |
8006 |
|
|
8007 |
// Création adresse destinataire sans ligne vide |
// Création adresse destinataire sans ligne vide |
8008 |
$adresse_destinataire = array(); |
$adresse_destinataire = array(); |
8032 |
$specifique_content[] = $testDemandeur['dossier_libelle']; |
$specifique_content[] = $testDemandeur['dossier_libelle']; |
8033 |
$specifique_content[] = "|||||".$adresse_dest['code_barres']."|||||"; |
$specifique_content[] = "|||||".$adresse_dest['code_barres']."|||||"; |
8034 |
unset($adresse_dest['code_barres']); |
unset($adresse_dest['code_barres']); |
|
|
|
8035 |
// Ajout d'une page aux pdf |
// Ajout d'une page aux pdf |
8036 |
$pdf_lettre_rar->addLetter($adresse_destinataire, $specifique_content, $testDemandeur['code_phase']); |
$pdf_lettre_rar->addLetter($adresse_destinataire, $specifique_content, $testDemandeur['code_phase']); |
8037 |
|
|
8038 |
} |
} |
8039 |
$pdf_output = $pdf_lettre_rar->output("lettre_rar".date("dmYHis").".pdf","S"); |
$pdf_output = $pdf_lettre_rar->output("lettre_rar".date("dmYHis").".pdf","S"); |
8040 |
require_once PATH_OPENMAIRIE."om_edition.class.php"; |
$om_edition = $this->f->get_inst__om_edition(); |
|
$om_edition = new edition(); |
|
8041 |
$om_edition->expose_pdf_output($pdf_output, "lettre_rar".date("dmYHis").".pdf"); |
$om_edition->expose_pdf_output($pdf_output, "lettre_rar".date("dmYHis").".pdf"); |
8042 |
} |
} |
8043 |
} |
} |
8100 |
$message .= "<a class='om-prev-icon pdf-16'"; |
$message .= "<a class='om-prev-icon pdf-16'"; |
8101 |
$message .= " id=\"generer_bordereau_envoi_maire\""; |
$message .= " id=\"generer_bordereau_envoi_maire\""; |
8102 |
$message .= " title=\""._("Bordereau")."\""; |
$message .= " title=\""._("Bordereau")."\""; |
8103 |
$message .= " href='../scr/form.php?obj=instruction"; |
$message .= " href='".OM_ROUTE_FORM."&obj=instruction"; |
8104 |
$message .= "&action=200"; |
$message .= "&action=200"; |
8105 |
$message .= "&idx=".$id_instruction."'"; |
$message .= "&idx=".$id_instruction."'"; |
8106 |
$message .= " target='_blank'>"; |
$message .= " target='_blank'>"; |
8141 |
$this->f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
8142 |
} |
} |
8143 |
|
|
|
// Inclusion de la classe de gestion des formulaires |
|
|
require_once "../obj/om_formulaire.class.php"; |
|
8144 |
// Ouverture du formulaire |
// Ouverture du formulaire |
8145 |
$datasubmit = $this->getDataSubmit(); |
$datasubmit = $this->getDataSubmit(); |
8146 |
echo "\n<!-- ########## START DBFORM ########## -->\n"; |
echo "\n<!-- ########## START DBFORM ########## -->\n"; |
8157 |
$champs = array("code_barres","date"); |
$champs = array("code_barres","date"); |
8158 |
|
|
8159 |
// Création d'un nouvel objet de type formulaire |
// Création d'un nouvel objet de type formulaire |
8160 |
$form = new formulaire(NULL, 0, 0, $champs); |
$form = $this->f->get_inst__om_formulaire(array( |
8161 |
|
"validation" => 0, |
8162 |
|
"maj" => 0, |
8163 |
|
"champs" => $champs, |
8164 |
|
)); |
8165 |
|
|
8166 |
$template_required_label = '%s *'; |
$template_required_label = '%s *'; |
8167 |
// Parametrage du champ code_barres |
// Parametrage du champ code_barres |
8220 |
} |
} |
8221 |
|
|
8222 |
/** |
/** |
8223 |
|
* VIEW - view_rapport_instruction. |
8224 |
|
* |
8225 |
|
* Ouvre le sous-formulaire en ajaxIt dans un overlay. |
8226 |
|
* Cette action est bindée pour utiliser la fonction popUpIt. |
8227 |
|
* |
8228 |
|
* @return void |
8229 |
|
*/ |
8230 |
|
function view_overlay_notification_manuelle() { |
8231 |
|
|
8232 |
|
// Vérification de l'accessibilité sur l'élément |
8233 |
|
$this->checkAccessibility(); |
8234 |
|
|
8235 |
|
printf( |
8236 |
|
'<script type="text/javascript" > |
8237 |
|
overlayIt(\'%1$s\',\'%2$s&objsf=%1$s&idxformulaire=%4$s&retourformulaire=dossier_instruction&obj=%1$s&action=411&idx=%3$s\', 1); |
8238 |
|
</script>', |
8239 |
|
'instruction_notification_manuelle', |
8240 |
|
OM_ROUTE_SOUSFORM, |
8241 |
|
$this->getVal($this->clePrimaire), |
8242 |
|
$this->getVal('dossier') |
8243 |
|
); |
8244 |
|
} |
8245 |
|
|
8246 |
|
/** |
8247 |
|
* VIEW - view_overlay_notification_service_consulte. |
8248 |
|
* |
8249 |
|
* Ouvre le sous-formulaire de notification des services consulte |
8250 |
|
* en ajaxIt dans un overlay. |
8251 |
|
* Cette action est bindée pour utiliser la fonction popUpIt. |
8252 |
|
* |
8253 |
|
* @return void |
8254 |
|
*/ |
8255 |
|
function view_overlay_notification_service_consulte() { |
8256 |
|
|
8257 |
|
// Vérification de l'accessibilité sur l'élément |
8258 |
|
$this->checkAccessibility(); |
8259 |
|
|
8260 |
|
printf( |
8261 |
|
'<script type="text/javascript" > |
8262 |
|
overlayIt(\'%1$s\',\'%2$s&objsf=%1$s&idxformulaire=%4$s&retourformulaire=dossier_instruction&obj=%1$s&action=420&idx=%3$s\', 1); |
8263 |
|
</script>', |
8264 |
|
'instruction_notification_manuelle', |
8265 |
|
OM_ROUTE_SOUSFORM, |
8266 |
|
$this->getVal($this->clePrimaire), |
8267 |
|
$this->getVal('dossier') |
8268 |
|
); |
8269 |
|
} |
8270 |
|
|
8271 |
|
/** |
8272 |
|
* VIEW - overlay_notification_tiers_consulte. |
8273 |
|
* |
8274 |
|
* Ouvre le sous-formulaire de notification des tiers consulte |
8275 |
|
* en ajaxIt dans un overlay. |
8276 |
|
* Cette action est bindée pour utiliser la fonction popUpIt. |
8277 |
|
* |
8278 |
|
* @return void |
8279 |
|
*/ |
8280 |
|
function view_overlay_notification_tiers_consulte() { |
8281 |
|
|
8282 |
|
// Vérification de l'accessibilité sur l'élément |
8283 |
|
$this->checkAccessibility(); |
8284 |
|
|
8285 |
|
printf( |
8286 |
|
'<script type="text/javascript" > |
8287 |
|
overlayIt(\'%1$s\',\'%2$s&objsf=%1$s&idxformulaire=%4$s&retourformulaire=dossier_instruction&obj=%1$s&action=430&idx=%3$s\', 1); |
8288 |
|
</script>', |
8289 |
|
'instruction_notification_manuelle', |
8290 |
|
OM_ROUTE_SOUSFORM, |
8291 |
|
$this->getVal($this->clePrimaire), |
8292 |
|
$this->getVal('dossier') |
8293 |
|
); |
8294 |
|
} |
8295 |
|
|
8296 |
|
/** |
8297 |
|
* VIEW - view_modale_selection_document_signe |
8298 |
|
* |
8299 |
|
* Ouvre le sous-formulaire de notification des services consulte |
8300 |
|
* en ajaxIt dans un overlay. |
8301 |
|
* Cette action est bindée pour utiliser la fonction popUpIt. |
8302 |
|
* |
8303 |
|
* @return void |
8304 |
|
*/ |
8305 |
|
function view_modale_selection_document_signe() { |
8306 |
|
|
8307 |
|
// Vérification de l'accessibilité sur l'élément |
8308 |
|
$this->checkAccessibility(); |
8309 |
|
|
8310 |
|
printf( |
8311 |
|
'<script type="text/javascript" > |
8312 |
|
overlayIt(\'%1$s\',\'%2$s&objsf=%1$s&idxformulaire=%4$s&retourformulaire=dossier_instruction&obj=%1$s&action=115&idx=%3$s\', 1); |
8313 |
|
</script>', |
8314 |
|
'instruction_modale', |
8315 |
|
OM_ROUTE_SOUSFORM, |
8316 |
|
$this->getVal($this->clePrimaire), |
8317 |
|
$this->getVal('dossier') |
8318 |
|
); |
8319 |
|
} |
8320 |
|
|
8321 |
|
/** |
8322 |
* 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 |
8323 |
* pour exclure les dossiers du groupe contentieux. |
* pour exclure les dossiers du groupe contentieux. |
8324 |
* |
* |
8366 |
// Begin |
// Begin |
8367 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
8368 |
// Requête |
// Requête |
8369 |
$res = $this->db->autoExecute( |
$res = $this->f->db->autoexecute( |
8370 |
DB_PREFIXE.$this->table, |
DB_PREFIXE.$this->table, |
8371 |
$valF, |
$valF, |
8372 |
DB_AUTOQUERY_UPDATE, |
DB_AUTOQUERY_UPDATE, |
8373 |
$this->getCle($id) |
$this->getCle($id) |
8374 |
); |
); |
8375 |
// S'il y a eu une erreur |
$this->addToLog( |
8376 |
if (database::isError($res, true)) { |
__METHOD__."(): db->autoexecute(\"".DB_PREFIXE.'.'.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($id)."\");", |
8377 |
|
VERBOSE_MODE |
8378 |
|
); |
8379 |
|
if ($this->f->isDatabaseError($res, true) !== false) { |
8380 |
$this->end_treatment(__METHOD__, false); |
$this->end_treatment(__METHOD__, false); |
8381 |
} |
} |
8382 |
// |
// |
8388 |
* validation du formulaire d'ajout. |
* validation du formulaire d'ajout. |
8389 |
* @param array $val tableau des valeurs retournées par le formulaire |
* @param array $val tableau des valeurs retournées par le formulaire |
8390 |
*/ |
*/ |
8391 |
function setValFAjout($val) { |
function setValFAjout($val = array()) { |
8392 |
// Mise à jour du flag created_by_commune lors d'un changement de décision |
// Mise à jour du flag created_by_commune lors d'un changement de décision |
8393 |
// par un utilisateur de commune sur un dossier instruit par la comcom |
// par un utilisateur de commune sur un dossier instruit par la comcom |
8394 |
if ($this->isInstrCanChangeDecision($this->valF["dossier"])) { |
if ($this->isInstrCanChangeDecision($this->valF["dossier"])) { |
8395 |
$this->valF['created_by_commune'] = true; |
$this->valF['created_by_commune'] = true; |
8396 |
} |
} |
8397 |
|
|
8398 |
|
// |
8399 |
|
if ($this->evenement_has_an_edition($this->valF['evenement']) === false) { |
8400 |
|
if (isset($this->valF['flag_edition_integrale']) === true) { |
8401 |
|
unset($this->valF['flag_edition_integrale']); |
8402 |
|
} |
8403 |
|
if (isset($this->valF['signataire_arrete']) === true) { |
8404 |
|
unset($this->valF['signataire_arrete']); |
8405 |
|
} |
8406 |
|
} |
8407 |
} |
} |
8408 |
|
|
8409 |
|
|
8549 |
// 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 |
8550 |
// dites de TREATMENT. |
// dites de TREATMENT. |
8551 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
8552 |
// Définition des paramètres |
$message = __('Erreur de paramétrage :'); |
8553 |
$p_objet = 'param_courriel_de_notification_commune_objet_depuis_instruction'; |
$erreurParametrage = false; |
8554 |
$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 |
|
8555 |
$id_di = $this->getVal('dossier'); |
$id_di = $this->getVal('dossier'); |
|
$id_inst = $this->getVal($this->clePrimaire); |
|
|
// Instanciation du DI |
|
8556 |
$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 |
|
8557 |
$collectivite_di = $di->getVal('om_collectivite'); |
$collectivite_di = $di->getVal('om_collectivite'); |
8558 |
$params_mono = $this->f->getCollectivite($collectivite_di); |
// Récupération de l'url permettant d'accèder à l'instruction et au dossier |
8559 |
// Récupération du paramétrage de la collectivité multi |
$urlAcces = $this->f->get_parametre_notification_url_acces($collectivite_di); |
8560 |
$collectivite_multi = $this->f->get_idx_collectivite_multi(); |
if (empty($urlAcces) && empty(PATH_BASE_URL)) { |
8561 |
$params_multi = $this->f->getCollectivite($collectivite_multi); |
$erreurParametrage = true; |
8562 |
// Vérification de l'objet (obligatoirement multi) |
$message .= '<br>'.__("* l'url de notification n'est pas correctement paramétré"); |
8563 |
$objet = null; |
} |
8564 |
if (isset($params_multi[$p_objet]) === true |
|
8565 |
&& $params_multi[$p_objet] !== '') { |
// Récupération de la liste des mails |
8566 |
$objet = $params_multi[$p_objet]; |
$adresses = $this->f->get_param_courriel_de_notification_commune($collectivite_di); |
8567 |
} |
if (empty($adresses)) { |
8568 |
// Vérification du modèle mono en priorité |
$erreurParametrage = true; |
8569 |
$modele = null; |
$message .= '<br>'.__("* aucun courriel valide de destinataire de la commune"); |
8570 |
if (isset($params_mono[$p_modele]) === true |
} |
8571 |
&& $params_mono[$p_modele] !== '') { |
|
8572 |
$modele = $params_mono[$p_modele]; |
// Vérification du paramétrage des mails |
8573 |
|
$paramMail = $this->f->get_notification_commune_parametre_courriel_type($collectivite_di); |
8574 |
} |
if (empty($paramMail) || empty($paramMail['parametre_courriel_type_message'])) { |
8575 |
// Sinon vérification du modèle multi |
$erreurParametrage = true; |
8576 |
if ($modele === null |
$message .= '<br>'.__("* le modèle du courriel envoyé aux communes est vide"); |
8577 |
&& isset($params_multi[$p_modele]) === true |
} |
8578 |
&& $params_multi[$p_modele] !== '') { |
if (empty($paramMail) || empty($paramMail['parametre_courriel_type_titre'])) { |
8579 |
$modele = $params_multi[$p_modele]; |
$erreurParametrage = true; |
8580 |
} |
$message .= '<br>'.__("* l'objet du courriel envoyé aux communes est vide"); |
8581 |
// Vérification des adresses de courriel mono |
} |
8582 |
$courriels_valides = array(); |
|
8583 |
$courriels_invalides = array(); |
// Si il y a des erreurs de paramétrage on ne déclenche pas la notification et |
8584 |
if (isset($params_mono[$p_courriel]) === true |
// un message a destination de l'utilisateur est affiché |
8585 |
&& $params_mono[$p_courriel] !== '') { |
if ($erreurParametrage) { |
8586 |
// Un mail par ligne |
$message .= '<br>'.__("Veuillez contacter votre administrateur."); |
8587 |
$adresses = explode("\n", $params_mono[$p_courriel]); |
$this->addToMessage($message); |
8588 |
// 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; |
|
|
} |
|
|
} |
|
8589 |
} |
} |
8590 |
// Vérification du paramétrage global : |
|
8591 |
// 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 |
8592 |
if ($objet === null |
foreach ($adresses as $adresse) { |
8593 |
|| $modele === null |
// Ajout de la notif et récupération de son id |
8594 |
|| count($courriels_valides) === 0 |
$destinataire = array( |
8595 |
|| count($courriels_invalides) > 0) { |
'destinataire' => $adresse, |
8596 |
// On construit le message d'erreur adéquat |
'courriel' => $adresse |
8597 |
$this->addToMessage(_('Erreur de paramétrage :')); |
); |
8598 |
if ($objet === null) { |
$idNotif = $this->ajouter_notification( |
8599 |
$this->addToMessage(_("* l'objet du courriel envoyé aux communes est vide")); |
$this->getVal($this->clePrimaire), |
8600 |
} |
$this->f->get_connected_user_login_name(), |
8601 |
if ($modele === null) { |
$destinataire, |
8602 |
$this->addToMessage(_("* le modèle du courriel envoyé aux communes est vide")); |
$collectivite_di |
8603 |
} |
); |
8604 |
if (count($courriels_valides) === 0) { |
if ($idNotif === false) { |
8605 |
$this->addToMessage(_("* aucun courriel valide de destinataire de la commune")); |
$this->addToMessage(__("Veuillez contacter votre administrateur.")); |
8606 |
|
return $this->end_treatment(__METHOD__, false); |
8607 |
} |
} |
8608 |
if (count($courriels_invalides) > 0) { |
// Création de la tache en lui donnant l'id de la notification |
8609 |
$courriels_invalides = implode(', ', $courriels_invalides); |
$notification_by_task = $this->notification_by_task( |
8610 |
$this->addToMessage(_("* un ou plusieurs courriels des destinataires de la commune sont invalides : ").$courriels_invalides); |
$idNotif, |
8611 |
|
$this->getVal('dossier'), |
8612 |
|
'mail', |
8613 |
|
'notification_commune' |
8614 |
|
); |
8615 |
|
if ($notification_by_task === false) { |
8616 |
|
$this->addToMessage(__("Erreur lors de la préparation de la notification des communes.")); |
8617 |
|
$this->addToMessage(__("Veuillez contacter votre administrateur.")); |
8618 |
|
return $this->end_treatment(__METHOD__, false); |
8619 |
} |
} |
|
$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); |
|
8620 |
} |
} |
8621 |
// 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.')); |
|
8622 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
8623 |
} |
} |
8624 |
|
|
8625 |
/** |
/** |
|
* 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.'spg/direct_link.php?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; |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
8626 |
* Récupère l'instance de l'instructeur |
* Récupère l'instance de l'instructeur |
8627 |
* |
* |
8628 |
* @param integer $instructeur Identifiant de l'instructeur. |
* @param integer $instructeur Identifiant de l'instructeur. |
8710 |
$this->f->get_submitted_get_value('idxformulaire') : $id_dossier = ""); |
$this->f->get_submitted_get_value('idxformulaire') : $id_dossier = ""); |
8711 |
// |
// |
8712 |
if ($id_dossier !== "") { |
if ($id_dossier !== "") { |
8713 |
require_once "../obj/dossier_instruction.class.php"; |
$dossier = $this->f->get_inst__om_dbform(array( |
8714 |
$dossier = new dossier_instruction($id_dossier, $f->db, DEBUG); |
"obj" => "dossier_instruction", |
8715 |
|
"idx" => $id_dossier, |
8716 |
|
)); |
8717 |
// |
// |
8718 |
return $dossier->can_user_access_dossier(); |
return $dossier->can_user_access_dossier(); |
8719 |
} |
} |
8733 |
$id_dossier = $this->getVal('dossier'); |
$id_dossier = $this->getVal('dossier'); |
8734 |
// |
// |
8735 |
if ($id_dossier !== "" && $id_dossier !== null) { |
if ($id_dossier !== "" && $id_dossier !== null) { |
8736 |
require_once "../obj/dossier_instruction.class.php"; |
$dossier = $this->f->get_inst__om_dbform(array( |
8737 |
$dossier = new dossier_instruction($id_dossier, $f->db, DEBUG); |
"obj" => "dossier_instruction", |
8738 |
|
"idx" => $id_dossier, |
8739 |
|
)); |
8740 |
// |
// |
8741 |
return $dossier->can_user_access_dossier(); |
return $dossier->can_user_access_dossier(); |
8742 |
} |
} |
8743 |
return false; |
return false; |
8744 |
} |
} |
8745 |
|
|
8746 |
}// fin classe |
/** |
8747 |
|
* TREATMENT - envoyer_a_signature_sans_relecture |
8748 |
|
* |
8749 |
|
* Permet d'envoyer le document de l'instruction au parapheur pour signature sans relecture |
8750 |
|
* |
8751 |
|
* @return boolean true si l'envoi a été effectué avec succès false sinon |
8752 |
|
*/ |
8753 |
|
function envoyer_a_signature_sans_relecture() { |
8754 |
|
return $this->envoyer_a_signature(); |
8755 |
|
} |
8756 |
|
|
8757 |
|
/** |
8758 |
|
* TREATMENT - envoyer_a_signature_avec_relecture |
8759 |
|
* |
8760 |
|
* Permet d'envoyer le document de l'instruction au parapheur pour signature avec relecture |
8761 |
|
* |
8762 |
|
* @return boolean true si l'envoi a été effectué avec succès false sinon |
8763 |
|
*/ |
8764 |
|
function envoyer_a_signature_avec_relecture() { |
8765 |
|
$is_forced_view_files = true; |
8766 |
|
return $this->envoyer_a_signature($is_forced_view_files); |
8767 |
|
} |
8768 |
|
|
8769 |
|
/** |
8770 |
|
* TREATMENT - envoyer_a_signature |
8771 |
|
* |
8772 |
|
* Permet d'envoyer le document de l'instruction au parapheur pour signature |
8773 |
|
* |
8774 |
|
* @param boolean $is_forced_view_files Indique si il y a une relecture (true) ou non (false) |
8775 |
|
* |
8776 |
|
* @return boolean true si l'envoi a été effectué avec succès false sinon |
8777 |
|
*/ |
8778 |
|
function envoyer_a_signature($is_forced_view_files = false) { |
8779 |
|
$this->begin_treatment(__METHOD__); |
8780 |
|
$this->correct = true; |
8781 |
|
|
8782 |
|
// Instanciation de l'objet signataire_arrete |
8783 |
|
$inst_signataire_arrete = $this->f->get_inst__om_dbform(array( |
8784 |
|
'obj' => 'signataire_arrete', |
8785 |
|
'idx' => $this->getVal('signataire_arrete'), |
8786 |
|
)); |
8787 |
|
|
8788 |
|
// Instanciation de l'objet dossier |
8789 |
|
$inst_dossier = $this->f->get_inst__om_dbform(array( |
8790 |
|
'obj' => 'dossier', |
8791 |
|
'idx' => $this->getVal('dossier'), |
8792 |
|
)); |
8793 |
|
|
8794 |
|
// Récupération du document à signer |
8795 |
|
$file = $this->f->storage->get($this->getVal('om_fichier_instruction')); |
8796 |
|
if ($file === OP_FAILURE) { |
8797 |
|
$this->correct = false; |
8798 |
|
$this->addToMessage(__("Une erreur est survenue lors de la récupération du contenu du document de l'instruction.")); |
8799 |
|
// Termine le traitement |
8800 |
|
return $this->end_treatment(__METHOD__, false); |
8801 |
|
} |
8802 |
|
|
8803 |
|
// Initialisation des paramètre à passer pour l'envoi en signature |
8804 |
|
$data = array( |
8805 |
|
"om_utilisateur_email" => $this->f->om_utilisateur['email'], |
8806 |
|
"om_utilisateur_nom" => $this->f->om_utilisateur['nom'], |
8807 |
|
"signataire_arrete_email" => $inst_signataire_arrete->getVal('email'), |
8808 |
|
"signataire_arrete_nom" => $inst_signataire_arrete->getVal('nom'), |
8809 |
|
"signataire_arrete_prenom" => $inst_signataire_arrete->getVal('prenom'), |
8810 |
|
// Permet d'envoyer en signature l'instruction le jour de la date limite |
8811 |
|
"date_limite_instruction" => $this->compute_date_limite(1), |
8812 |
|
"dossier" => $this->getVal('dossier'), |
8813 |
|
"is_forced_view_files" => $is_forced_view_files, |
8814 |
|
'commentaire_signature' => $is_forced_view_files === true ? __('relecture demandee.') : null |
8815 |
|
); |
8816 |
|
|
8817 |
|
// Initialisation des métadonnées |
8818 |
|
$metadonnee_dossier = $file['metadata']; |
8819 |
|
// récupération de l'extension du fichier |
8820 |
|
$extension = substr($metadonnee_dossier['filename'], strrpos($metadonnee_dossier['filename'], '.')); |
8821 |
|
// Modification du libellé du document transmis au parapheur |
8822 |
|
// pour le mettre sous la forme : instruction_xxx_libelle_lettretype.extension |
8823 |
|
$metadonnee_dossier['filename'] = $this->getDocumentLibelle().$extension; |
8824 |
|
$metadonnee_dossier['titre_document'] = $this->getDocumentTitre(); |
8825 |
|
|
8826 |
|
$metadonnee_dossier['url_di'] = sprintf( |
8827 |
|
'%sapp/index.php?module=form&direct_link=true&obj=dossier_instruction&action=3&direct_field=dossier&direct_form=instruction&direct_action=3&direct_idx=%s', |
8828 |
|
$this->f->get_param_base_path_metadata_url_di() !== null ? $this->f->get_param_base_path_metadata_url_di() : PATH_BASE_URL, |
8829 |
|
$this->getVal($this->clePrimaire) |
8830 |
|
); |
8831 |
|
|
8832 |
|
$optional_data = null; |
8833 |
|
// Si il y a des paramètres supplémentaire spécifié dans le signataire alors on les récupère |
8834 |
|
if ($inst_signataire_arrete->getVal('parametre_parapheur') !== null && $inst_signataire_arrete->getVal('parametre_parapheur') !== '') { |
8835 |
|
$optional_data = json_decode($inst_signataire_arrete->getVal('parametre_parapheur'), true); |
8836 |
|
if (json_last_error() !== JSON_ERROR_NONE) { |
8837 |
|
$this->correct = false; |
8838 |
|
$this->addToMessage(__("Les paramètres supplémentaires envoyés au parapheur ne sont pas au bon format.")); |
8839 |
|
$this->addToLog(__METHOD__."(): ". |
8840 |
|
__("Erreur lors du décodage du format json des paramètres supplémentaires envoyé au parapheur. |
8841 |
|
Tableau : ").var_export($inst_signataire_arrete->getVal('parametre_parapheur'), true) |
8842 |
|
); |
8843 |
|
// Termine le traitement |
8844 |
|
return $this->end_treatment(__METHOD__, false); |
8845 |
|
} |
8846 |
|
} |
8847 |
|
|
8848 |
|
//Instanciation de la classe electronicsignature |
8849 |
|
$inst_es = $this->get_electronicsignature_instance(); |
8850 |
|
if ($inst_es === false) { |
8851 |
|
$this->correct = false; |
8852 |
|
return $this->end_treatment(__METHOD__, false); |
8853 |
|
} |
8854 |
|
|
8855 |
|
// Appel de la méthode de l'abstracteur send_for_signature() |
8856 |
|
// Cette méthode doit retourner un tableau de valeur |
8857 |
|
try { |
8858 |
|
$result = $inst_es->send_for_signature($data, $file['file_content'], $metadonnee_dossier, $optional_data); |
8859 |
|
} catch (electronicsignature_exception $e) { |
8860 |
|
$this->handle_electronicsignature_exception($e); |
8861 |
|
return $this->end_treatment(__METHOD__, false); |
8862 |
|
} |
8863 |
|
|
8864 |
|
// Après avoir reçu le résultat du parapheur, il faut mettre à jour les champs |
8865 |
|
$valF = array(); |
8866 |
|
|
8867 |
|
// Pour appeler la fonction modifier il faut traiter tous les champs de l'objet |
8868 |
|
foreach($this->champs as $identifiant => $champ) { |
8869 |
|
$valF[$champ] = $this->val[$identifiant]; |
8870 |
|
} |
8871 |
|
// On fait ensuite nos modifications spécifiques |
8872 |
|
$valF['id_parapheur_signature'] = $result['id_parapheur_signature']; |
8873 |
|
$valF['statut_signature'] = $result['statut']; |
8874 |
|
$valF['commentaire_signature'] = isset($result['commentaire_signature']) == true ? $result['commentaire_signature'] : null; |
8875 |
|
$valF['date_envoi_signature'] = date("Y-m-d", strtotime($result['date_envoi_signature'])); |
8876 |
|
$valF['historique_signature'] = $this->get_updated_historique_signature($result); |
8877 |
|
|
8878 |
|
$ret = $this->modifier($valF); |
8879 |
|
|
8880 |
|
if ($ret === false) { |
8881 |
|
$this->correct = false; |
8882 |
|
$this->addToMessage(__("Une erreur est survenue lors de la mise à jour des champs.")); |
8883 |
|
// Termine le traitement |
8884 |
|
return $this->end_treatment(__METHOD__, false); |
8885 |
|
} |
8886 |
|
|
8887 |
|
// Message |
8888 |
|
$this->addToMessage(__("Le document a été envoyé pour signature dans le parapheur.")); |
8889 |
|
if (array_key_exists('signature_page_url', $result) === true) { |
8890 |
|
$this->addToMessage(sprintf( |
8891 |
|
'<br> > <a href="%1$s" title="%2$s" target="_blank">%2$s</a>', |
8892 |
|
$result['signature_page_url'], |
8893 |
|
__("Signez directement le document") |
8894 |
|
)); |
8895 |
|
} |
8896 |
|
|
8897 |
|
// Tout s'est bien passé, on termine le traitement |
8898 |
|
return $this->end_treatment(__METHOD__, true); |
8899 |
|
} |
8900 |
|
|
8901 |
|
/** |
8902 |
|
* Permet de récupérer la bonne date limite en fonction de si l'instruction |
8903 |
|
* est en incomplet notifié ou non. |
8904 |
|
* On peut ajouter des jours à cette date grâce au paramètre "delay". |
8905 |
|
* Cette fonction est utilisée dans un cas spécifique où on veut envoyer |
8906 |
|
* l'instruction en signature le jour de la date limite. |
8907 |
|
* |
8908 |
|
* @param int $delay Le nombre de jour à ajouter à la date limite. |
8909 |
|
* |
8910 |
|
* @return string $date_limite la date limite calculé ou false |
8911 |
|
*/ |
8912 |
|
private function compute_date_limite($delay) { |
8913 |
|
// Instanciation de l'objet dossier |
8914 |
|
$inst_dossier = $this->f->get_inst__om_dbform(array( |
8915 |
|
'obj' => 'dossier', |
8916 |
|
'idx' => $this->getVal('dossier'), |
8917 |
|
)); |
8918 |
|
|
8919 |
|
$date_to_compute = null; |
8920 |
|
if ($inst_dossier->getVal('incomplet_notifie') === 't') { |
8921 |
|
$date_to_compute = $inst_dossier->getVal('date_limite_incompletude'); |
8922 |
|
} else { |
8923 |
|
$date_to_compute = $inst_dossier->getVal('date_limite'); |
8924 |
|
} |
8925 |
|
|
8926 |
|
$date_limite = date("Y-m-d", strtotime($date_to_compute."+ $delay days")); |
8927 |
|
|
8928 |
|
return $date_limite; |
8929 |
|
} |
8930 |
|
|
8931 |
|
/** |
8932 |
|
* Permet de récupérer la traduction de la valeur de statut_signature |
8933 |
|
* |
8934 |
|
* @return string la valeur de statut_signature traduite | false |
8935 |
|
*/ |
8936 |
|
function get_trad_for_statut($value_to_trad){ |
8937 |
|
$statut_signature_tab = array( |
8938 |
|
'waiting' => __('en préparation'), |
8939 |
|
'in_progress' => __('en cours de signature'), |
8940 |
|
'canceled' => __('signature annulée'), |
8941 |
|
'expired' => __('délai de signature expiré'), |
8942 |
|
'finished' => __('signé') |
8943 |
|
); |
8944 |
|
if (array_key_exists($value_to_trad, $statut_signature_tab) === true) { |
8945 |
|
return $statut_signature_tab[$value_to_trad]; |
8946 |
|
} |
8947 |
|
|
8948 |
|
return false; |
8949 |
|
} |
8950 |
|
|
8951 |
|
/** |
8952 |
|
* Permet de mettre à jour le tableau json sotcké dans le champ historique_signature |
8953 |
|
* |
8954 |
|
* @return string (json) la valeur de historique_signature mis à jour | false |
8955 |
|
*/ |
8956 |
|
function get_updated_historique_signature($historique_signature_values) { |
8957 |
|
|
8958 |
|
$historique_signature_value_tab = $this->get_historique_signature_decoded(); |
8959 |
|
|
8960 |
|
if ($historique_signature_value_tab === false) { |
8961 |
|
$this->addToLog(__METHOD__."(): erreur historique signature", DEBUG_MODE); |
8962 |
|
return false; |
8963 |
|
} |
8964 |
|
|
8965 |
|
$last_val_historique_signature = array(); |
8966 |
|
|
8967 |
|
// Si la tableau récupéré n'est pas vide alors |
8968 |
|
// on récupère la dernière ligne du tableau |
8969 |
|
if (empty($historique_signature_value_tab) === false) { |
8970 |
|
$last_val_historique_signature = end($historique_signature_value_tab); |
8971 |
|
} |
8972 |
|
|
8973 |
|
$format_date = ''; |
8974 |
|
$format_date_hour = ''; |
8975 |
|
$date_converted=array(); |
8976 |
|
|
8977 |
|
$date_to_convert = array( |
8978 |
|
'date_envoi_signature' => $historique_signature_values['date_envoi_signature'], |
8979 |
|
'date_limite_instruction' => $this->compute_date_limite(0), |
8980 |
|
'date_retour_signature' => $historique_signature_values['date_retour_signature'] |
8981 |
|
); |
8982 |
|
|
8983 |
|
// Conversion des dates en fonction de leur format |
8984 |
|
foreach ($date_to_convert as $key => $value) { |
8985 |
|
$date_converted[$key] = null; |
8986 |
|
if ($value != null) { |
8987 |
|
$format_date = 'd/m/Y'; |
8988 |
|
$format_date_hour = 'd/m/Y H:i:s'; |
8989 |
|
$date_converted[$key] = empty(date_parse($value)['hour']) === false ? date($format_date_hour, strtotime($value)) : date($format_date, strtotime($value)); |
8990 |
|
} |
8991 |
|
} |
8992 |
|
|
8993 |
|
// Ce tableau permet de lister les colonnes de historique_signature et de les rendre traduisibles. |
8994 |
|
// Il faut en effet mettre les gettext avec l'intitulé explicite au moins |
8995 |
|
// une fois afin qu'il puisse être reconnu par le logiciel de traduction. |
8996 |
|
$tab_for_columns_trad = array( |
8997 |
|
__('entry_date'), |
8998 |
|
__('id_parapheur_signature'), |
8999 |
|
__('emetteur'), |
9000 |
|
__('signataire'), |
9001 |
|
__('date_envoi'), |
9002 |
|
__('date_limite'), |
9003 |
|
__('date_retour'), |
9004 |
|
__('statut_signature'), |
9005 |
|
__('commentaire_signature') |
9006 |
|
); |
9007 |
|
|
9008 |
|
array_push($historique_signature_value_tab, array( |
9009 |
|
'entry_date' => date('d/m/Y H:i:s'), |
9010 |
|
'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'], |
9011 |
|
'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'], |
9012 |
|
'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'], |
9013 |
|
'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'], |
9014 |
|
'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'], |
9015 |
|
'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'], |
9016 |
|
'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']), |
9017 |
|
'commentaire_signature' => isset($historique_signature_values['commentaire_signature']) === false || $historique_signature_values['commentaire_signature'] == null ? null : $historique_signature_values['commentaire_signature'], |
9018 |
|
)); |
9019 |
|
|
9020 |
|
return json_encode($historique_signature_value_tab, JSON_HEX_APOS); |
9021 |
|
} |
9022 |
|
|
9023 |
|
/** |
9024 |
|
* TREATMENT - annuler_envoi_en_signature |
9025 |
|
* |
9026 |
|
* Permet d'annuler l'envoi du document de l'instruction au parapheur pour signature |
9027 |
|
* |
9028 |
|
* @return boolean true si l'annulation a été effectué avec succès false sinon |
9029 |
|
*/ |
9030 |
|
function annuler_envoi_en_signature() { |
9031 |
|
$this->begin_treatment(__METHOD__); |
9032 |
|
$this->correct = true; |
9033 |
|
|
9034 |
|
//Instanciation de la classe electronicsignature |
9035 |
|
$inst_es = $this->get_electronicsignature_instance(); |
9036 |
|
if ($inst_es === false) { |
9037 |
|
$this->correct = false; |
9038 |
|
return $this->end_treatment(__METHOD__, false); |
9039 |
|
} |
9040 |
|
|
9041 |
|
$data = array(); |
9042 |
|
if (! empty($this->getVal('id_parapheur_signature'))) { |
9043 |
|
$data['id_parapheur_signature'] = $this->getVal('id_parapheur_signature'); |
9044 |
|
} else { |
9045 |
|
$this->correct = false; |
9046 |
|
$this->addToMessage(__("Il n'y a pas d'identifiant de parapheur.")); |
9047 |
|
return $this->end_treatment(__METHOD__, false); |
9048 |
|
} |
9049 |
|
|
9050 |
|
// Appel de la méthode de l'abstracteur cancel_send_for_signature() |
9051 |
|
// Cette méthode doit retourner un tableau de valeur |
9052 |
|
try { |
9053 |
|
$result = $inst_es->cancel_send_for_signature($data); |
9054 |
|
} catch (electronicsignature_exception $e) { |
9055 |
|
$this->handle_electronicsignature_exception($e); |
9056 |
|
return $this->end_treatment(__METHOD__, false); |
9057 |
|
} |
9058 |
|
|
9059 |
|
// Après avoir reçu le résultat du parapheur, il faut mettre à jour les champs |
9060 |
|
$valF = array(); |
9061 |
|
|
9062 |
|
// Pour appeler la fonction modifier il faut traiter tous les champs de l'objet |
9063 |
|
foreach($this->champs as $identifiant => $champ) { |
9064 |
|
$valF[$champ] = $this->val[$identifiant]; |
9065 |
|
} |
9066 |
|
// On fait ensuite nos modifications spécifiques |
9067 |
|
$valF['id_parapheur_signature'] = null; |
9068 |
|
$valF['statut_signature'] = $result['statut']; |
9069 |
|
$valF['commentaire_signature'] = isset($result['commentaire_signature']) == true ? $result['commentaire_signature'] : null; |
9070 |
|
$valF['date_envoi_signature'] = null; |
9071 |
|
$valF['historique_signature'] = $this->get_updated_historique_signature($result); |
9072 |
|
|
9073 |
|
$ret = $this->modifier($valF); |
9074 |
|
|
9075 |
|
if ($ret === false) { |
9076 |
|
$this->correct = false; |
9077 |
|
$this->addToMessage(__("Une erreur est survenue lors de la mise à jour des champs.")); |
9078 |
|
// Termine le traitement |
9079 |
|
return $this->end_treatment(__METHOD__, false); |
9080 |
|
} |
9081 |
|
|
9082 |
|
// Message |
9083 |
|
$this->addToMessage(__("L'annulation a été effectuée avec succès.")); |
9084 |
|
|
9085 |
|
// Tout s'est bien passé, on termine le traitement |
9086 |
|
return $this->end_treatment(__METHOD__, true); |
9087 |
|
} |
9088 |
|
|
9089 |
|
|
9090 |
|
/** |
9091 |
|
* Récupère le contenu du champ historique_signature et le converti en tableau |
9092 |
|
* |
9093 |
|
* @return array sinon false en cas d'erreur |
9094 |
|
*/ |
9095 |
|
protected function get_historique_signature_decoded() { |
9096 |
|
$val = str_replace("'", '"', $this->getVal('historique_signature')); |
9097 |
|
if ($val === '' || $val == 'false') { |
9098 |
|
$val = json_encode(array()); |
9099 |
|
} |
9100 |
|
if($this->isJson($val) === false) { |
9101 |
|
return false; |
9102 |
|
} |
9103 |
|
return json_decode($val, true); |
9104 |
|
} |
9105 |
|
|
9106 |
|
/** |
9107 |
|
* Récupère les informations à afficher dans le tableau de suivi à l'aide |
9108 |
|
* d'une requête sql. Stocke ces informations dans un tableau. |
9109 |
|
* Converti le tableau au format json et renvoi le json obtenu. |
9110 |
|
* |
9111 |
|
* Pour identifier quel suivi est affiché (notification des demandeurs, des services ou |
9112 |
|
* de tiers) ce sont les tâches liées aux notifications qui sont utilisés. |
9113 |
|
* La clause where de la requête est construite à partir du tableau contenant les types |
9114 |
|
* de tâches fourni en paramètre. |
9115 |
|
* Il est également possible d'afficher les notifications n'étant pas lié à des tâches. |
9116 |
|
* |
9117 |
|
* Si le suivi concerne la notification des demandeurs via le portail citoyen, |
9118 |
|
* la date de premier accès ne sera pas affichée. |
9119 |
|
* |
9120 |
|
* @param array liste des tâches permettant d'identifier quelles notification afficher |
9121 |
|
* @param boolean permet d'afficher les notifications non liées à des tâches |
9122 |
|
* @return json |
9123 |
|
*/ |
9124 |
|
protected function get_json_suivi_notification($typeTache, $nonLieTache = false) { |
9125 |
|
$whereTypeTache = ''; |
9126 |
|
$sqlTaskNull = ''; |
9127 |
|
|
9128 |
|
// Liste des champs à afficher. Permet également la traduction des noms de colonnes. |
9129 |
|
$listeChampsTrad = array( |
9130 |
|
__('emetteur'), |
9131 |
|
__('date_envoi'), |
9132 |
|
__('destinataire'), |
9133 |
|
__('date_premier_acces'), |
9134 |
|
__('instruction'), |
9135 |
|
__('annexes'), |
9136 |
|
__('statut'), |
9137 |
|
__('commentaire') |
9138 |
|
); |
9139 |
|
$listeChamps = array( |
9140 |
|
'emetteur', |
9141 |
|
'date_envoi', |
9142 |
|
'destinataire', |
9143 |
|
'date_premier_acces', |
9144 |
|
'instruction', |
9145 |
|
'annexes', |
9146 |
|
'statut', |
9147 |
|
'commentaire' |
9148 |
|
); |
9149 |
|
|
9150 |
|
// Défini si on veux que la requête récupère également les notifications qui n'ont pas |
9151 |
|
// de tâches associées. C'est le cas pour les notifications de demandeurs lorsque la |
9152 |
|
// notification du demandeur principal n'a pas pu être envoyée à cause d'un mauvais |
9153 |
|
// paramétrage |
9154 |
|
if(is_bool($nonLieTache) && $nonLieTache === true) { |
9155 |
|
$sqlTaskNull = 'OR task.type is null'; |
9156 |
|
} |
9157 |
|
// Prépare la clause where pour ne récupérer que les notifications liées à certain type de tâches |
9158 |
|
// Permet de différencier les notifications des demandeurs de celle des services et de celles des |
9159 |
|
// tiers consulté |
9160 |
|
if (is_array($typeTache) && $typeTache != array()) { |
9161 |
|
if (is_array($typeTache)) { |
9162 |
|
$whereTypeTache = sprintf( |
9163 |
|
'AND (task.type IN (%1$s) %2$s)', |
9164 |
|
"'".implode("', '", $typeTache)."'", |
9165 |
|
$sqlTaskNull |
9166 |
|
); |
9167 |
|
} |
9168 |
|
// La date de premier accès n'a pas besoin d'être renseigné pour |
9169 |
|
// les notifications des demandeurs via le portail citoyen. |
9170 |
|
// Les notifications des demandeurs sont liés à 3 types de tâches |
9171 |
|
// notification_recepisse, notification_instruction, notification_decision |
9172 |
|
// Si le suivi de la notification concerne un de ces types de tâches on |
9173 |
|
// considère que c'est une notification de demandeurs. |
9174 |
|
// Dans ce cas on vérifie si cette notification est paramétrée pour passer |
9175 |
|
// via le portail. Par défaut si rien n'est paramétré on considère que la |
9176 |
|
// notification est faite via le portail |
9177 |
|
if ((in_array('notification_recepisse', $typeTache) || |
9178 |
|
in_array('notification_instruction', $typeTache) || |
9179 |
|
in_array('notification_decision', $typeTache))) { |
9180 |
|
$dossier = $this->getVal('dossier'); |
9181 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite($dossier); |
9182 |
|
$modeNotification = $this->f->get_param_option_notification($collectivite_di); |
9183 |
|
if (empty($modeNotification) || $modeNotification == PORTAL) { |
9184 |
|
$listeChamps = array( |
9185 |
|
'emetteur', |
9186 |
|
'date_envoi', |
9187 |
|
'destinataire', |
9188 |
|
'instruction', |
9189 |
|
'annexes', |
9190 |
|
'statut', |
9191 |
|
'commentaire' |
9192 |
|
); |
9193 |
|
} |
9194 |
|
} |
9195 |
|
// Il n'y a pas d'annexe pour la notification des communes donc pas besoin |
9196 |
|
// de les afficher dans le suivi |
9197 |
|
if (in_array('notification_depot_demat', $typeTache)) { |
9198 |
|
$listeChamps = array( |
9199 |
|
'emetteur', |
9200 |
|
'date_envoi', |
9201 |
|
'destinataire', |
9202 |
|
'instruction', |
9203 |
|
'statut', |
9204 |
|
'commentaire' |
9205 |
|
); |
9206 |
|
} |
9207 |
|
} |
9208 |
|
|
9209 |
|
$valSuivi = array(); |
9210 |
|
// Récupération des infos nécessaires à l'affichage du tableau |
9211 |
|
$sql = sprintf( |
9212 |
|
'SELECT DISTINCT |
9213 |
|
instruction_notification.instruction_notification, |
9214 |
|
-- Affiche la mention automatique avec le nom de l emetteur si la notification a été envoyé automatiquement |
9215 |
|
CASE WHEN instruction_notification.automatique = TRUE |
9216 |
|
THEN TRIM(CONCAT(instruction_notification.emetteur, \' \', \'(automatique)\')) |
9217 |
|
ELSE instruction_notification.emetteur |
9218 |
|
END as emetteur, |
9219 |
|
date_envoi, |
9220 |
|
instruction_notification.destinataire, |
9221 |
|
instruction_notification.date_premier_acces, |
9222 |
|
evenement.libelle as instruction, |
9223 |
|
instruction_notification.statut, |
9224 |
|
instruction_notification.commentaire, |
9225 |
|
annexes.instruction_annexe as annexes |
9226 |
|
FROM |
9227 |
|
%1$sinstruction_notification |
9228 |
|
LEFT JOIN %1$sinstruction |
9229 |
|
ON instruction.instruction = instruction_notification.instruction |
9230 |
|
LEFT JOIN %1$sevenement |
9231 |
|
ON instruction.evenement = evenement.evenement |
9232 |
|
LEFT JOIN %1$sinstruction_notification_document |
9233 |
|
ON instruction_notification.instruction_notification = instruction_notification_document.instruction_notification |
9234 |
|
AND instruction_notification_document.annexe = true |
9235 |
|
-- Récupère les tâches liées au notification pour pouvoir par la suite identifier le type de notification |
9236 |
|
LEFT JOIN %1$stask |
9237 |
|
ON instruction_notification.instruction_notification::CHARACTER VARYING = task.object_id |
9238 |
|
-- Récupération de la liste des annexes sous la forme d une liste |
9239 |
|
LEFT JOIN ( |
9240 |
|
SELECT |
9241 |
|
instruction_notification, |
9242 |
|
-- Récupère la liste des annexes de la notification |
9243 |
|
-- sous la forme d un json pour récupérer toutes les informatiosn nécessaire |
9244 |
|
-- à l affichage du lien vers les annexes |
9245 |
|
CONCAT( |
9246 |
|
\'[\', |
9247 |
|
STRING_AGG( |
9248 |
|
-- Affiche le nom du fichier selon le type de document/pièce |
9249 |
|
CASE |
9250 |
|
WHEN instruction_notification_document.document_type = \'instruction\' |
9251 |
|
THEN CONCAT( |
9252 |
|
\'{ |
9253 |
|
"obj" : "instruction", |
9254 |
|
"champs" : "om_fichier_instruction", |
9255 |
|
"label" : "\', evenement.libelle, \'", |
9256 |
|
"id" : "\', instruction.instruction,\'" |
9257 |
|
}\' |
9258 |
|
) |
9259 |
|
WHEN instruction_notification_document.document_type = \'consultation\' |
9260 |
|
THEN CONCAT( |
9261 |
|
\'{ |
9262 |
|
"obj" : "consultation", |
9263 |
|
"champs" : "fichier", |
9264 |
|
"label" : "Avis - \', service.libelle, \'", |
9265 |
|
"id" : "\', consultation.consultation,\'" |
9266 |
|
}\' |
9267 |
|
) |
9268 |
|
ELSE |
9269 |
|
CONCAT( |
9270 |
|
\'{ |
9271 |
|
"obj" : "document_numerise", |
9272 |
|
"champs" : "uid", |
9273 |
|
"label" : "\', document_numerise.nom_fichier, \' - \', document_numerise_type.libelle, \'", |
9274 |
|
"id" : "\', document_numerise.document_numerise,\'" |
9275 |
|
}\' |
9276 |
|
) |
9277 |
|
END, |
9278 |
|
\', \'), |
9279 |
|
\']\' |
9280 |
|
) AS instruction_annexe |
9281 |
|
FROM |
9282 |
|
%1$sinstruction_notification_document |
9283 |
|
LEFT JOIN %1$sinstruction |
9284 |
|
ON instruction_notification_document.instruction = instruction.instruction |
9285 |
|
LEFT JOIN %1$sevenement |
9286 |
|
ON instruction.evenement = evenement.evenement |
9287 |
|
LEFT JOIN %1$sconsultation |
9288 |
|
ON instruction_notification_document.document_id = consultation.consultation |
9289 |
|
LEFT JOIN %1$sservice |
9290 |
|
ON consultation.service = service.service |
9291 |
|
LEFT JOIN %1$sdocument_numerise |
9292 |
|
ON instruction_notification_document.document_id = document_numerise.document_numerise |
9293 |
|
LEFT JOIN %1$sdocument_numerise_type |
9294 |
|
ON document_numerise.document_numerise_type = document_numerise_type.document_numerise_type |
9295 |
|
WHERE |
9296 |
|
instruction_notification_document.annexe = \'t\' |
9297 |
|
GROUP BY |
9298 |
|
instruction_notification |
9299 |
|
) AS annexes |
9300 |
|
ON |
9301 |
|
annexes.instruction_notification = instruction_notification.instruction_notification |
9302 |
|
WHERE |
9303 |
|
instruction.instruction = %2$s |
9304 |
|
%3$s |
9305 |
|
ORDER BY |
9306 |
|
date_envoi ASC, instruction_notification.destinataire ASC', |
9307 |
|
DB_PREFIXE, |
9308 |
|
$this->getVal('instruction'), |
9309 |
|
$whereTypeTache |
9310 |
|
); |
9311 |
|
$res = $this->f->db->query($sql); |
9312 |
|
$this->f->addToLog(__METHOD__."(): db->query(\"".$sql."\")", VERBOSE_MODE); |
9313 |
|
$this->f->isDatabaseError($res); |
9314 |
|
// Préparation du lien de téléchargement des annexes |
9315 |
|
$htmlList = |
9316 |
|
'<style> |
9317 |
|
#content .gridjs-td a.lien_annexe { |
9318 |
|
text-decoration : underline dotted 1px; |
9319 |
|
} |
9320 |
|
#content a.lien_annexe:hover { |
9321 |
|
text-decoration : underline solid 1px; |
9322 |
|
color : #46aede; |
9323 |
|
} |
9324 |
|
ol {padding-left : 10px;} |
9325 |
|
</style> |
9326 |
|
<ol>%1$s</ol>'; |
9327 |
|
$lienTelechargement = |
9328 |
|
'<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"> |
9329 |
|
Annexe |
9330 |
|
</a>'; |
9331 |
|
// Stockage des infos de chaque notification dans un tableau |
9332 |
|
while( $row =& $res->fetchrow(DB_FETCHMODE_ASSOC) ) { |
9333 |
|
$valNotif = array(); |
9334 |
|
foreach($listeChamps as $champ) { |
9335 |
|
$valNotif[$champ] = $row[$champ]; |
9336 |
|
if (($champ === 'date_envoi' |
9337 |
|
|| $champ === 'date_premier_acces') |
9338 |
|
&& $row[$champ] !== null |
9339 |
|
&& $row[$champ] !== '') { |
9340 |
|
// |
9341 |
|
$valNotif[$champ] = date('d/m/Y H:i:s', strtotime($row[$champ])); |
9342 |
|
} else if ($champ === 'annexes') { |
9343 |
|
$listeAnnexe = ''; |
9344 |
|
$infoAnnexes = json_decode($row[$champ], true); |
9345 |
|
if (! empty($infoAnnexes) && json_last_error() === JSON_ERROR_NONE) { |
9346 |
|
// A partir des infos récupérées prépare le code html du lien vers chacune |
9347 |
|
// des annexes et ajoute un élément de liste par annexe |
9348 |
|
foreach($infoAnnexes as $annexe) { |
9349 |
|
$listeAnnexe .= sprintf( |
9350 |
|
'<li>%s</li>', |
9351 |
|
sprintf($lienTelechargement, |
9352 |
|
$annexe['obj'], |
9353 |
|
$annexe['champs'], |
9354 |
|
$annexe['id'], |
9355 |
|
$annexe['label'] |
9356 |
|
) |
9357 |
|
); |
9358 |
|
} |
9359 |
|
// Construction de la liste des annexes |
9360 |
|
$valNotif[$champ] = sprintf( |
9361 |
|
$htmlList, |
9362 |
|
$listeAnnexe |
9363 |
|
); |
9364 |
|
} |
9365 |
|
} |
9366 |
|
} |
9367 |
|
array_push($valSuivi, $valNotif); |
9368 |
|
} |
9369 |
|
|
9370 |
|
// Passage du tableau au format json |
9371 |
|
return json_encode($valSuivi, JSON_HEX_APOS); |
9372 |
|
} |
9373 |
|
|
9374 |
|
/** |
9375 |
|
* Traitement des erreurs retournées par l'abstracteur electronicsignature. |
9376 |
|
* |
9377 |
|
* @param electronicsignature_exception $exception Exception retournée par l'abstracteur. |
9378 |
|
* |
9379 |
|
* @return void |
9380 |
|
*/ |
9381 |
|
public function handle_electronicsignature_exception(electronicsignature_exception $exception) { |
9382 |
|
$this->f->displayMessage('error', $exception->getMessage()); |
9383 |
|
} |
9384 |
|
|
9385 |
|
|
9386 |
|
/** |
9387 |
|
* Retourne une instance du connecteur electronicsignature, et la créer si elle n'existe pas. |
9388 |
|
* |
9389 |
|
* @param boolean $with_handle_error Flag pour afficher ou non le message d'erreur à l'utilisateur. |
9390 |
|
* @return electronicsignature Instance de l'abstracteur. |
9391 |
|
*/ |
9392 |
|
public function get_electronicsignature_instance($with_handle_error = true) { |
9393 |
|
if(isset($this->electronicsignature_instance)) { |
9394 |
|
return $this->electronicsignature_instance; |
9395 |
|
} |
9396 |
|
// Instanciation du connecteur electronicsignature |
9397 |
|
try { |
9398 |
|
require_once "electronicsignature.class.php"; |
9399 |
|
$collectivites = array("collectivite_idx" => $this->get_dossier_instruction_om_collectivite(), "collectivite_multi_idx" => $this->f->get_idx_collectivite_multi()); |
9400 |
|
$this->electronicsignature_instance = new electronicsignature($collectivites); |
9401 |
|
} catch (electronicsignature_exception $e) { |
9402 |
|
if ($with_handle_error === true) { |
9403 |
|
$this->handle_electronicsignature_exception($e); |
9404 |
|
} |
9405 |
|
return false; |
9406 |
|
} |
9407 |
|
return $this->electronicsignature_instance; |
9408 |
|
} |
9409 |
|
|
9410 |
|
/** |
9411 |
|
* TREATMENT - envoyer_au_controle_de_legalite |
9412 |
|
* |
9413 |
|
* Ajoute la tâche envoi_CL. |
9414 |
|
* C'est le traitement de la tâche qui mettra à jour la date d'envoi au contrôle de légalité. |
9415 |
|
* |
9416 |
|
* @return [type] [description] |
9417 |
|
*/ |
9418 |
|
function envoyer_au_controle_de_legalite() { |
9419 |
|
$this->begin_treatment(__METHOD__); |
9420 |
|
$this->correct = true; |
9421 |
|
|
9422 |
|
// |
9423 |
|
if ($this->can_be_sended_to_cl() === true) { |
9424 |
|
// Création de la task 'envoi_CL' |
9425 |
|
$inst_task = $this->f->get_inst__om_dbform(array( |
9426 |
|
"obj" => "task", |
9427 |
|
"idx" => 0, |
9428 |
|
)); |
9429 |
|
$task_val = array( |
9430 |
|
'type' => 'envoi_CL', |
9431 |
|
'object_id' => $this->getVal('instruction'), |
9432 |
|
'dossier' => $this->getVal('dossier'), |
9433 |
|
); |
9434 |
|
// Change l'état de la tâche de notification en fonction de l'état de |
9435 |
|
// transmission du dossier d'instruction |
9436 |
|
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
9437 |
|
if ($this->f->is_option_mode_service_consulte_enabled() === false |
9438 |
|
&& ($inst_di->getVal('etat_transmission_platau') == 'non_transmissible' |
9439 |
|
|| $inst_di->getVal('etat_transmission_platau') == 'transmis_mais_non_transmissible')) { |
9440 |
|
// |
9441 |
|
$task_val['state'] = $inst_task::STATUS_DRAFT; |
9442 |
|
} |
9443 |
|
$add_task = $inst_task->add_task(array('val' => $task_val)); |
9444 |
|
if ($add_task === false) { |
9445 |
|
$this->addToMessage(sprintf('%s %s', |
9446 |
|
__("Une erreur s'est produite lors de la création tâche."), |
9447 |
|
__("Veuillez contacter votre administrateur.") |
9448 |
|
)); |
9449 |
|
$this->correct = false; |
9450 |
|
return $this->end_treatment(__METHOD__, false); |
9451 |
|
} |
9452 |
|
// Mise à jour du champs 'envoye_cl_platau' |
9453 |
|
$instr_val = array( |
9454 |
|
'envoye_cl_platau' => 't', |
9455 |
|
); |
9456 |
|
$res = $this->f->db->autoExecute( |
9457 |
|
DB_PREFIXE.$this->table, |
9458 |
|
$instr_val, |
9459 |
|
DB_AUTOQUERY_UPDATE, |
9460 |
|
$this->getCle($this->getVal($this->clePrimaire)) |
9461 |
|
); |
9462 |
|
$this->addToLog(__METHOD__."(): db->autoexecute(\"".DB_PREFIXE.'.'.$this->table."\", ".print_r($instr_val, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($this->clePrimaire)."\");", VERBOSE_MODE); |
9463 |
|
if ($this->f->isDatabaseError($res, true) === true) { |
9464 |
|
$this->addToMessage(sprintf('%s %s', |
9465 |
|
__("Une erreur s'est produite lors de la mise à jour de l'instruction."), |
9466 |
|
__("Veuillez contacter votre administrateur.") |
9467 |
|
)); |
9468 |
|
$this->correct = false; |
9469 |
|
return $this->end_treatment(__METHOD__, false); |
9470 |
|
} |
9471 |
|
// Message de validation à l'utilisateur |
9472 |
|
$this->addToMessage(__('Votre demande de transfert au contrôle de légalité à bien été prise en compte.')); |
9473 |
|
$this->addToMessage(__("La date d'envoi au contrôle de légalité sera mise à jour ultérieurement.")); |
9474 |
|
} |
9475 |
|
// |
9476 |
|
return $this->end_treatment(__METHOD__, true); |
9477 |
|
} |
9478 |
|
|
9479 |
|
|
9480 |
|
/** |
9481 |
|
* Retourne le lien de retour (VIEW formulaire et VIEW sousformulaire). |
9482 |
|
* |
9483 |
|
* @param string $view Appel dans le contexte de la vue 'formulaire' ou de |
9484 |
|
* la vue 'sousformulaire'. |
9485 |
|
* |
9486 |
|
* @return string |
9487 |
|
*/ |
9488 |
|
function get_back_link($view = "formulaire") { |
9489 |
|
// |
9490 |
|
$href = parent::get_back_link($view); |
9491 |
|
// |
9492 |
|
$crud = $this->get_action_crud(); |
9493 |
|
|
9494 |
|
// Redirection vers le formulaire de modification à la validation du |
9495 |
|
// formulaire d'ajout si l'événement associé possède une lettre type |
9496 |
|
if (($crud === 'create' |
9497 |
|
|| ($crud === null |
9498 |
|
&& $this->getParameter('maj') == 0)) |
9499 |
|
&& $this->correct == true |
9500 |
|
&& $this->evenement_has_an_edition($this->valF['evenement']) === true) { |
9501 |
|
|
9502 |
|
// On instancie l'instruction |
9503 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
9504 |
|
"obj" => "instruction", |
9505 |
|
"idx" => $this->valF[$this->clePrimaire], |
9506 |
|
)); |
9507 |
|
|
9508 |
|
// Si l'instruction n'est pas finalisée automatiquement |
9509 |
|
if ($inst_instruction->getVal('om_final_instruction') !== 't') { |
9510 |
|
$href = str_replace("&action=3", "&action=1", $href); |
9511 |
|
// |
9512 |
|
if (strpos($href, "&retour=tab") !== false) { |
9513 |
|
$href = str_replace("&retour=tab", "&retour= form", $href); |
9514 |
|
} else { |
9515 |
|
$href .= "&retour=form"; |
9516 |
|
} |
9517 |
|
} |
9518 |
|
} |
9519 |
|
|
9520 |
|
// |
9521 |
|
return $href; |
9522 |
|
} |
9523 |
|
|
9524 |
|
public function view_json_data() { |
9525 |
|
$this->checkAccessibility(); |
9526 |
|
$this->f->disableLog(); |
9527 |
|
$view = $this->get_json_data(); |
9528 |
|
printf(json_encode($view)); |
9529 |
|
} |
9530 |
|
|
9531 |
|
public function get_json_data() { |
9532 |
|
$val = array_combine($this->champs, $this->val); |
9533 |
|
foreach ($val as $key => $value) { |
9534 |
|
$val[$key] = strip_tags($value); |
9535 |
|
} |
9536 |
|
$val['tacite'] = 'f'; |
9537 |
|
$inst_ad = $this->f->get_inst__om_dbform(array( |
9538 |
|
"obj" => "avis_decision", |
9539 |
|
"idx" => $val['avis_decision'], |
9540 |
|
)); |
9541 |
|
if (preg_match('/[tT]acite/', $inst_ad->getVal('libelle')) === 1) { |
9542 |
|
$val['tacite'] = 't'; |
9543 |
|
} |
9544 |
|
return $val; |
9545 |
|
} |
9546 |
|
|
9547 |
|
/** |
9548 |
|
* Permet de récupérer l'identifiant de l'instruction sur le dossier, ayant |
9549 |
|
* comme événement lié le suivant définit dans l'événement de l'instruction |
9550 |
|
* instanciée. |
9551 |
|
* |
9552 |
|
* @param string $next_type Correspond aux trois déclenchement automatique |
9553 |
|
* de création d'instruction paramétré sur un événement. |
9554 |
|
* @param integer $instruction Identifiant de l'instruction à instancier. |
9555 |
|
* @return mixed Identifiant de l'instruction recherchée ou false. |
9556 |
|
*/ |
9557 |
|
public function get_related_instructions_next($next_type = 'retour_signature', $instruction = null) { |
9558 |
|
if (in_array($next_type, array('retour_signature', 'retour_ar', 'suivant_tacite', )) === false) { |
9559 |
|
return false; |
9560 |
|
} |
9561 |
|
$result = array(); |
9562 |
|
$evenements = array(); |
9563 |
|
if ($instruction === null) { |
9564 |
|
$instruction = $this->getVal($this->clePrimaire); |
9565 |
|
$evenement = $this->getVal('evenement'); |
9566 |
|
$dossier = $this->getVal('dossier'); |
9567 |
|
} else { |
9568 |
|
$inst = $this->f->get_inst__om_dbform(array( |
9569 |
|
"obj" => "instruction", |
9570 |
|
"idx" => $instruction, |
9571 |
|
)); |
9572 |
|
$evenement = $inst->getVal('evenement'); |
9573 |
|
$dossier = $inst->getVal('dossier'); |
9574 |
|
} |
9575 |
|
// Récupération de l'identifiant de l'événement paramétré comme suivant |
9576 |
|
// sur l'instruction instanciée |
9577 |
|
$qres = $this->f->get_one_result_from_db_query( |
9578 |
|
sprintf( |
9579 |
|
'SELECT |
9580 |
|
evenement_%3$s |
9581 |
|
FROM |
9582 |
|
%1$sevenement |
9583 |
|
WHERE |
9584 |
|
evenement = %2$s', |
9585 |
|
DB_PREFIXE, |
9586 |
|
intval($evenement), |
9587 |
|
$next_type |
9588 |
|
), |
9589 |
|
array( |
9590 |
|
"origin" => __METHOD__, |
9591 |
|
"force_return" => true, |
9592 |
|
) |
9593 |
|
); |
9594 |
|
if ($qres["code"] !== "OK") { |
9595 |
|
return false; |
9596 |
|
} |
9597 |
|
$ev_next = $qres["result"]; |
9598 |
|
// Récupération de l'instruction dans le dossier utilisant l'événement |
9599 |
|
// suivant identifié dans la requête précédente |
9600 |
|
$qres = $this->f->get_one_result_from_db_query( |
9601 |
|
sprintf( |
9602 |
|
'SELECT |
9603 |
|
MAX(instruction.instruction) as instruction |
9604 |
|
FROM |
9605 |
|
%1$sinstruction |
9606 |
|
WHERE |
9607 |
|
dossier = \'%3$s\' |
9608 |
|
AND evenement = %2$s', |
9609 |
|
DB_PREFIXE, |
9610 |
|
intval($ev_next), |
9611 |
|
$dossier |
9612 |
|
), |
9613 |
|
array( |
9614 |
|
"origin" => __METHOD__, |
9615 |
|
"force_return" => true, |
9616 |
|
) |
9617 |
|
); |
9618 |
|
if ($qres["code"] !== "OK") { |
9619 |
|
return false; |
9620 |
|
} |
9621 |
|
return $qres["result"]; |
9622 |
|
} |
9623 |
|
|
9624 |
|
public function get_related_instructions($instruction = null) { |
9625 |
|
$result = array(); |
9626 |
|
$evenements = array(); |
9627 |
|
if ($instruction === null) { |
9628 |
|
$instruction = $this->getVal($this->clePrimaire); |
9629 |
|
$evenement = $this->getVal('evenement'); |
9630 |
|
$dossier = $this->getVal('dossier'); |
9631 |
|
} else { |
9632 |
|
$inst = $this->f->get_inst__om_dbform(array( |
9633 |
|
"obj" => "instruction", |
9634 |
|
"idx" => $instruction, |
9635 |
|
)); |
9636 |
|
$evenement = $inst->getVal('evenement'); |
9637 |
|
$dossier = $inst->getVal('dossier'); |
9638 |
|
} |
9639 |
|
// |
9640 |
|
$qres = $this->f->get_one_result_from_db_query( |
9641 |
|
sprintf( |
9642 |
|
'SELECT |
9643 |
|
evenement |
9644 |
|
FROM |
9645 |
|
%1$sevenement |
9646 |
|
WHERE |
9647 |
|
evenement_retour_ar = %2$s |
9648 |
|
OR evenement_retour_signature = %2$s', |
9649 |
|
DB_PREFIXE, |
9650 |
|
intval($evenement) |
9651 |
|
), |
9652 |
|
array( |
9653 |
|
"origin" => __METHOD__, |
9654 |
|
"force_return" => true, |
9655 |
|
) |
9656 |
|
); |
9657 |
|
if ($qres["code"] !== "OK") { |
9658 |
|
return false; |
9659 |
|
} |
9660 |
|
$ev_parent = $qres["result"]; |
9661 |
|
// |
9662 |
|
$qres = $this->f->get_one_result_from_db_query( |
9663 |
|
sprintf( |
9664 |
|
'SELECT |
9665 |
|
MAX(instruction.instruction) as instruction |
9666 |
|
FROM |
9667 |
|
%1$sinstruction |
9668 |
|
WHERE |
9669 |
|
dossier = \'%3$s\' |
9670 |
|
AND evenement = %2$s', |
9671 |
|
DB_PREFIXE, |
9672 |
|
intval($ev_parent), |
9673 |
|
$this->f->db->escapeSimple($dossier) |
9674 |
|
), |
9675 |
|
array( |
9676 |
|
"origin" => __METHOD__, |
9677 |
|
"force_return" => true, |
9678 |
|
) |
9679 |
|
); |
9680 |
|
if ($qres["code"] !== "OK") { |
9681 |
|
return false; |
9682 |
|
} |
9683 |
|
$result[] = $qres["result"]; |
9684 |
|
// |
9685 |
|
$qres = $this->f->get_one_result_from_db_query( |
9686 |
|
sprintf( |
9687 |
|
'SELECT |
9688 |
|
evenement_retour_ar |
9689 |
|
FROM |
9690 |
|
%1$sevenement |
9691 |
|
WHERE |
9692 |
|
evenement = %2$s |
9693 |
|
AND evenement_retour_ar != %3$s', |
9694 |
|
DB_PREFIXE, |
9695 |
|
intval($ev_parent), |
9696 |
|
intval($evenement) |
9697 |
|
), |
9698 |
|
array( |
9699 |
|
"origin" => __METHOD__, |
9700 |
|
"force_return" => true, |
9701 |
|
) |
9702 |
|
); |
9703 |
|
if ($qres["code"] !== "OK") { |
9704 |
|
return false; |
9705 |
|
} |
9706 |
|
$evenements[] = $qres["result"]; |
9707 |
|
// |
9708 |
|
$qres = $this->f->get_one_result_from_db_query( |
9709 |
|
sprintf( |
9710 |
|
'SELECT |
9711 |
|
evenement_retour_signature |
9712 |
|
FROM |
9713 |
|
%1$sevenement |
9714 |
|
WHERE |
9715 |
|
evenement = %2$s |
9716 |
|
AND evenement_retour_signature != %3$s |
9717 |
|
', |
9718 |
|
DB_PREFIXE, |
9719 |
|
intval($ev_parent), |
9720 |
|
intval($evenement) |
9721 |
|
), |
9722 |
|
array( |
9723 |
|
"origin" => __METHOD__, |
9724 |
|
"force_return" => true, |
9725 |
|
) |
9726 |
|
); |
9727 |
|
if ($qres["code"] !== "OK") { |
9728 |
|
return false; |
9729 |
|
} |
9730 |
|
$evenements[] = $qres["result"]; |
9731 |
|
foreach ($evenements as $value) { |
9732 |
|
if ($value !== null) { |
9733 |
|
$qres = $this->f->get_one_result_from_db_query( |
9734 |
|
sprintf( |
9735 |
|
'SELECT |
9736 |
|
MAX(instruction.instruction) as instruction |
9737 |
|
FROM |
9738 |
|
%1$sinstruction |
9739 |
|
WHERE |
9740 |
|
dossier = \'%3$s\' |
9741 |
|
AND evenement = %2$s', |
9742 |
|
DB_PREFIXE, |
9743 |
|
intval($value), |
9744 |
|
$this->f->db->escapeSimple($dossier) |
9745 |
|
), |
9746 |
|
array( |
9747 |
|
"origin" => __METHOD__, |
9748 |
|
"force_return" => true, |
9749 |
|
) |
9750 |
|
); |
9751 |
|
if ($qres["code"] !== "OK") { |
9752 |
|
return false; |
9753 |
|
} |
9754 |
|
$result[] = $qres["result"]; |
9755 |
|
} |
9756 |
|
} |
9757 |
|
return $result; |
9758 |
|
} |
9759 |
|
|
9760 |
|
protected function getDocumentType($champ = null) { |
9761 |
|
$evenementId = $this->getVal('evenement'); |
9762 |
|
if (! empty($evenementId)) { |
9763 |
|
$evenement = $this->f->findObjectById('evenement', $evenementId); |
9764 |
|
if (! empty($evenement)) { |
9765 |
|
return __("Instruction").':'.$evenement->getVal('libelle'); |
9766 |
|
} |
9767 |
|
} |
9768 |
|
return parent::getDocumentType(); |
9769 |
|
} |
9770 |
|
|
9771 |
|
/** |
9772 |
|
* Récupère à l'aide d'une requête sql la liste des demandeurs |
9773 |
|
* pouvant être notifié. C'est à dire les demandeurs acceptant |
9774 |
|
* les notifications et pour lesquels une adresse mail existe. |
9775 |
|
* |
9776 |
|
* Dans le cas, d'une notification pour le portail citoyen, seul |
9777 |
|
* le pétitionnaire principal doit être notifier et uniquement si |
9778 |
|
* il a une adress mail et qu'il accepte les notifications. |
9779 |
|
* |
9780 |
|
* @param string identifiant du dossier |
9781 |
|
* @param boolean true si il faut récupérer la liste des demandeurs notifiable |
9782 |
|
* pour une notification de categorie portail |
9783 |
|
* @return array liste des demandeurs pouvant être notifié |
9784 |
|
*/ |
9785 |
|
protected function get_demandeurs_notifiable($idDossier = null, $portail = false) { |
9786 |
|
if ($idDossier === null) { |
9787 |
|
$idDossier = $this->getVal('dossier'); |
9788 |
|
} |
9789 |
|
// Ajoute une condition sur le where pour ne récupérer que le pétitionnaire principal |
9790 |
|
// pour une notification depuis le portail citoyen |
9791 |
|
$sqlPetitionnairePrincipal = ''; |
9792 |
|
// Gestion des champs nécessaires pour la notification d'un demandeur |
9793 |
|
$condition_demandeur = "AND demandeur.notification = 't' |
9794 |
|
AND demandeur.courriel IS NOT NULL"; |
9795 |
|
if ($portail === true) { |
9796 |
|
$sqlPetitionnairePrincipal = 'AND lien_dossier_demandeur.petitionnaire_principal = true'; |
9797 |
|
$condition_demandeur = "AND ( |
9798 |
|
(notification = 't' AND courriel IS NOT NULL) |
9799 |
|
OR demande.source_depot = 'portal' |
9800 |
|
)"; |
9801 |
|
} |
9802 |
|
|
9803 |
|
$listeDemandeursNotifiable = array(); |
9804 |
|
|
9805 |
|
// Requête de récupération des demandeurs |
9806 |
|
$sql = sprintf( |
9807 |
|
'SELECT |
9808 |
|
demandeur.demandeur, |
9809 |
|
CASE |
9810 |
|
WHEN demandeur.qualite=\'particulier\' |
9811 |
|
THEN TRIM(CONCAT(demandeur.particulier_nom, \' \', demandeur.particulier_prenom, \' \', demandeur.courriel)) |
9812 |
|
ELSE |
9813 |
|
TRIM(CONCAT(demandeur.personne_morale_raison_sociale, \' \', demandeur.personne_morale_denomination, \' \', demandeur.courriel)) |
9814 |
|
END AS destinataire, |
9815 |
|
demandeur.courriel, |
9816 |
|
petitionnaire_principal |
9817 |
|
FROM |
9818 |
|
%1$sdossier |
9819 |
|
INNER JOIN %1$slien_dossier_demandeur |
9820 |
|
ON dossier.dossier = lien_dossier_demandeur.dossier |
9821 |
|
INNER JOIN %1$sdemandeur |
9822 |
|
ON lien_dossier_demandeur.demandeur = demandeur.demandeur |
9823 |
|
-- Récupération de la plus ancienne demande associée au dossier (la demande |
9824 |
|
-- de création du dossier) |
9825 |
|
INNER JOIN ( |
9826 |
|
SELECT |
9827 |
|
demande, |
9828 |
|
dossier_instruction, |
9829 |
|
source_depot |
9830 |
|
FROM |
9831 |
|
%1$sdemande |
9832 |
|
WHERE |
9833 |
|
dossier_instruction = \'%2$s\' |
9834 |
|
ORDER BY |
9835 |
|
demande ASC |
9836 |
|
LIMIT 1 |
9837 |
|
) as demande |
9838 |
|
ON dossier.dossier = demande.dossier_instruction |
9839 |
|
WHERE |
9840 |
|
dossier.dossier = \'%2$s\' |
9841 |
|
%3$s |
9842 |
|
%4$s', |
9843 |
|
DB_PREFIXE, |
9844 |
|
$idDossier, |
9845 |
|
$condition_demandeur, |
9846 |
|
$sqlPetitionnairePrincipal |
9847 |
|
); |
9848 |
|
$res = $this->f->db->query($sql); |
9849 |
|
$this->f->addToLog(__METHOD__."(): db->query(\"".$sql."\")", VERBOSE_MODE); |
9850 |
|
$this->f->isDatabaseError($res); |
9851 |
|
// Récupération des infos des demandeurs et stockage dans un tableau |
9852 |
|
// ayant pour clé les id des demandeurs |
9853 |
|
while($row = $res->fetchrow(DB_FETCHMODE_ASSOC)) { |
9854 |
|
$listeDemandeursNotifiable[$row['demandeur']] = $row; |
9855 |
|
} |
9856 |
|
|
9857 |
|
return $listeDemandeursNotifiable; |
9858 |
|
} |
9859 |
|
|
9860 |
|
/** |
9861 |
|
* Renvoie la liste des notifications liées à l'instruction |
9862 |
|
* |
9863 |
|
* @param integer id de l'instruction dont on cherche les notifications |
9864 |
|
* @return array liste des instruction_notification liés à l'instruction |
9865 |
|
*/ |
9866 |
|
public function get_instruction_notification($id_instruction, $typeNotification = null, $nonLieTache = false) { |
9867 |
|
$whereTypeTache = ''; |
9868 |
|
$sqlTaskNull = ''; |
9869 |
|
// Défini si on veux que la requête récupère également les notifications qui n'ont pas |
9870 |
|
// de tâches associées. C'est le cas pour les notifications de demandeurs lorsque la |
9871 |
|
// notification du demandeur principal n'a pas pu être envoyée à cause d'un mauvais |
9872 |
|
// paramétrage |
9873 |
|
if(is_bool($nonLieTache) && $nonLieTache === true) { |
9874 |
|
$sqlTaskNull = 'OR task.type is null'; |
9875 |
|
} |
9876 |
|
if ($typeNotification != null) { |
9877 |
|
if (is_array($typeNotification)) { |
9878 |
|
$whereTypeTache = sprintf( |
9879 |
|
'AND (task.type IN (%1$s) %2$s)', |
9880 |
|
"'".implode("', '", $typeNotification)."'", |
9881 |
|
$sqlTaskNull |
9882 |
|
); |
9883 |
|
} else { |
9884 |
|
$whereTypeTache = sprintf( |
9885 |
|
'AND (task.type = \'%1$s\' %2$s)', |
9886 |
|
$typeNotification, |
9887 |
|
$sqlTaskNull |
9888 |
|
); |
9889 |
|
} |
9890 |
|
} |
9891 |
|
$listeInstrNotif = array(); |
9892 |
|
$sql = sprintf(' |
9893 |
|
SELECT |
9894 |
|
instruction_notification.instruction_notification |
9895 |
|
FROM |
9896 |
|
%1$sinstruction_notification |
9897 |
|
LEFT JOIN %1$stask |
9898 |
|
ON instruction_notification.instruction_notification::CHARACTER VARYING = task.object_id |
9899 |
|
WHERE |
9900 |
|
instruction = %2$s |
9901 |
|
%3$s', |
9902 |
|
DB_PREFIXE, |
9903 |
|
$id_instruction, |
9904 |
|
$whereTypeTache |
9905 |
|
); |
9906 |
|
$res = $this->f->db->query($sql); |
9907 |
|
$this->f->addToLog(__METHOD__."(): db->query(\"".$sql."\")", VERBOSE_MODE); |
9908 |
|
$this->f->isDatabaseError($res); |
9909 |
|
while ($row = $res->fetchrow(DB_FETCHMODE_ASSOC)) { |
9910 |
|
$listeInstrNotif[] = $row['instruction_notification']; |
9911 |
|
} |
9912 |
|
return $listeInstrNotif; |
9913 |
|
} |
9914 |
|
|
9915 |
|
/** |
9916 |
|
* Crée une clé d'accès unique permettant à un utilisateur |
9917 |
|
* anonyme de récupérer le document. |
9918 |
|
* |
9919 |
|
* @return string clé d'accès du document |
9920 |
|
*/ |
9921 |
|
protected function getCleAccesDocument() { |
9922 |
|
// Initialisation d'un tableau |
9923 |
|
$number_list = array(); |
9924 |
|
|
9925 |
|
// Génération aléatoire d'un nombre sur 4 caractères, 4 fois |
9926 |
|
for ($i = 0; $i < 4; $i++) { |
9927 |
|
$number_list[] = str_pad(mt_rand(0, 9999), 4, 0, STR_PAD_LEFT); |
9928 |
|
} |
9929 |
|
|
9930 |
|
// Transformation en chaîne tout en séparant les nombres par un "-" |
9931 |
|
$result = implode('-', $number_list); |
9932 |
|
|
9933 |
|
// Vérifie si la clé existe déjà et si c'est le cas génére une nouvelle clé |
9934 |
|
if ($this->getUidDocumentInstructionWithKey($result) != null) { |
9935 |
|
return $this->getCleAccesDocument(); |
9936 |
|
} |
9937 |
|
|
9938 |
|
// |
9939 |
|
return $result; |
9940 |
|
} |
9941 |
|
|
9942 |
|
/** |
9943 |
|
* Récupère une clé et renvoie l'uid du document liée à cette |
9944 |
|
* clé. Si la clé n'existe pas renvoie null. |
9945 |
|
* |
9946 |
|
* @param string $cleGen clé dont on cherche l'instruction |
9947 |
|
* @return integer|null |
9948 |
|
*/ |
9949 |
|
protected function getUidDocumentInstructionWithKey($cleGen) { |
9950 |
|
$query = sprintf( |
9951 |
|
'SELECT |
9952 |
|
instruction.om_fichier_instruction |
9953 |
|
FROM |
9954 |
|
%1$sinstruction_notification_document |
9955 |
|
LEFT JOIN %1$sinstruction ON instruction_notification_document.instruction = instruction.instruction |
9956 |
|
WHERE |
9957 |
|
instruction_notification_document.cle = \'%2$s\'', |
9958 |
|
DB_PREFIXE, |
9959 |
|
$this->f->db->escapeSimple($cleGen) |
9960 |
|
); |
9961 |
|
|
9962 |
|
$res = $this->f->db->getOne($query); |
9963 |
|
$this->addToLog(__METHOD__.": db->getOne(\"".$query."\");", VERBOSE_MODE); |
9964 |
|
$this->f->isDatabaseError($res); |
9965 |
|
return $res; |
9966 |
|
} |
9967 |
|
|
9968 |
|
/** |
9969 |
|
* Récupère une clé, fait une requête pour récupérer l'id de la notification liée a cette clé. |
9970 |
|
* Récupère l'instance de instruction_notification dont l'id a été récupéré et la renvoie. |
9971 |
|
* |
9972 |
|
* @param string $cleGen |
9973 |
|
* @return instruction_notification |
9974 |
|
*/ |
9975 |
|
protected function getInstanceNotificationWithKey($key) { |
9976 |
|
$sql = sprintf( |
9977 |
|
"SELECT |
9978 |
|
instruction_notification |
9979 |
|
FROM |
9980 |
|
%1\$sinstruction_notification_document |
9981 |
|
WHERE |
9982 |
|
cle = '%2\$s'", |
9983 |
|
DB_PREFIXE, |
9984 |
|
$this->f->db->escapeSimple($key) |
9985 |
|
); |
9986 |
|
$res = $this->f->db->getOne($sql); |
9987 |
|
$this->addToLog(__METHOD__.": db->getOne(\"".$sql."\");", VERBOSE_MODE); |
9988 |
|
$this->f->isDatabaseError($res); |
9989 |
|
|
9990 |
|
// Récupération de l'instance de notification |
9991 |
|
$instNotif = $this->f->get_inst__om_dbform(array( |
9992 |
|
"obj" => "instruction_notification", |
9993 |
|
"idx" => $res, |
9994 |
|
)); |
9995 |
|
return $instNotif; |
9996 |
|
} |
9997 |
|
|
9998 |
|
|
9999 |
|
/** |
10000 |
|
* Affiche la page de téléchargement du document de la notification. |
10001 |
|
* |
10002 |
|
* @param boolean $content_only Affiche le contenu seulement. |
10003 |
|
* |
10004 |
|
* @return void |
10005 |
|
*/ |
10006 |
|
public function view_telecharger_document_anonym() { |
10007 |
|
// Par défaut on considère qu'on va afficher le formulaire |
10008 |
|
$idx = 0; |
10009 |
|
// Flag d'erreur |
10010 |
|
$error = false; |
10011 |
|
// Message d'erreur |
10012 |
|
$message = ''; |
10013 |
|
|
10014 |
|
// Paramètres GET : récupération de la clé d'accès |
10015 |
|
$cle_acces_document = $this->f->get_submitted_get_value('key'); |
10016 |
|
$cle_acces_document = $this->f->db->escapeSimple($cle_acces_document); |
10017 |
|
// Vérification de l'existence de la clé et récupération de l'uid du fichier |
10018 |
|
$uidFichier = $this->getUidDocumentInstructionWithKey($cle_acces_document); |
10019 |
|
if ($uidFichier != null) { |
10020 |
|
// Récupération du document |
10021 |
|
$file = $this->f->storage->get($uidFichier); |
10022 |
|
|
10023 |
|
// Headers |
10024 |
|
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 |
10025 |
|
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date dans le passé |
10026 |
|
header("Content-Type: ".$file['metadata']['mimetype']); |
10027 |
|
header("Accept-Ranges: bytes"); |
10028 |
|
header("Content-Disposition: inline; filename=\"".$file['metadata']['filename']."\";" ); |
10029 |
|
// Affichage du document |
10030 |
|
echo $file['file_content']; |
10031 |
|
|
10032 |
|
// Récupération de la date de premier accès et maj du suivi uniquement |
10033 |
|
// si la date de 1er accès n'a pas encore été remplis |
10034 |
|
$inst_notif = $this->getInstanceNotificationWithKey($cle_acces_document); |
10035 |
|
if ($inst_notif->getVal('date_premier_acces') == null || |
10036 |
|
$inst_notif->getVal('date_premier_acces') == '') { |
10037 |
|
$notif_val = array(); |
10038 |
|
foreach ($inst_notif->champs as $champ) { |
10039 |
|
$notif_val[$champ] = $inst_notif->getVal($champ); |
10040 |
|
} |
10041 |
|
$notif_val['date_premier_acces'] = date("d/m/Y H:i:s"); |
10042 |
|
$notif_val['statut'] = 'vu'; |
10043 |
|
$notif_val['commentaire'] = 'Le document a été vu'; |
10044 |
|
$suivi_notif = $inst_notif->modifier($notif_val); |
10045 |
|
} |
10046 |
|
|
10047 |
|
} else { |
10048 |
|
// Page vide 404 |
10049 |
|
printf('Ressource inexistante'); |
10050 |
|
header('HTTP/1.0 404 Not Found'); |
10051 |
|
} |
10052 |
|
} |
10053 |
|
|
10054 |
|
/** |
10055 |
|
* Récupère le titre du document envoyé au parapheur |
10056 |
|
*/ |
10057 |
|
protected function getDocumentTitre($champ = null) { |
10058 |
|
$title = $this->getTitle(); |
10059 |
|
$dossier = $this->getDossier(); |
10060 |
|
return $dossier.' '.$title; |
10061 |
|
} |
10062 |
|
|
10063 |
|
/** |
10064 |
|
* Compose le nom du document à transmettre au parapheur. |
10065 |
|
* Le nom ets composé de cette manière : |
10066 |
|
* instruction_xxx_libelle_de_la_lettre_type_associee |
10067 |
|
* ou xxx correspond au numéro de l'instruction |
10068 |
|
*/ |
10069 |
|
protected function getDocumentLibelle() { |
10070 |
|
// Récupère le champ instruction |
10071 |
|
$instruction = $this->getVal("instruction"); |
10072 |
|
|
10073 |
|
// Requête sql servant à récupérer le titre du document |
10074 |
|
// TO_CHAR() introduit un espace avant l'affichage du nombre |
10075 |
|
// comme les espaces sont remplacé par des '_' dans le retour de la fonction |
10076 |
|
// il n'est pas nécessaire de mettre un '_' après le mot instruction. |
10077 |
|
$sql = sprintf( |
10078 |
|
'SELECT |
10079 |
|
CONCAT( |
10080 |
|
\'instruction\', |
10081 |
|
TO_CHAR(instruction.instruction, \'000\'), |
10082 |
|
\'_\', |
10083 |
|
LOWER(om_lettretype.libelle) |
10084 |
|
) as nom_fichier |
10085 |
|
FROM |
10086 |
|
%1$sinstruction |
10087 |
|
LEFT JOIN %1$som_lettretype ON om_lettretype.id = instruction.lettretype |
10088 |
|
WHERE |
10089 |
|
instruction = %2$s', |
10090 |
|
DB_PREFIXE, |
10091 |
|
$instruction |
10092 |
|
); |
10093 |
|
$documentLibelle = $this->f->db->getone($sql); |
10094 |
|
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
10095 |
|
$this->f->isDatabaseError($documentLibelle); |
10096 |
|
|
10097 |
|
// Transforamtion des ' ' en '_', des accents en lettres sans accents et des |
10098 |
|
// caractères spéciaux en '_' |
10099 |
|
// La méthode normalize_string est utilisé pour gérer les accents |
10100 |
|
$documentLibelle = $this->f->normalize_string($documentLibelle); |
10101 |
|
// TODO : comparer cette liste et celle de la méthode normalize_string |
10102 |
|
// pour éviter les doublons + vérifier qu'il n'y a pas de doublons dans cette |
10103 |
|
// liste |
10104 |
|
$invalid = array('Œ'=>'oe', 'œ'=>'oe', 'Ÿ'=>'y', 'ü'=>'u', |
10105 |
|
'¢' => '_', 'ß' => '_', '¥' => '_', '£' => '_', '™' => '_', '©' => '_', |
10106 |
|
'®' => '_', 'ª' => '_', '×' => '_', '÷' => '_', '±' => '_', '²' => '_', |
10107 |
|
'³' => '_', '¼' => '_', '½' => '_', '¾' => '_', 'µ' => '_', '¿' => '_', |
10108 |
|
'¶' => '_', '·' => '_', '¸' => '_', 'º' => '_', '°' => '_', '¯' => '_', |
10109 |
|
'§' => '_', '…' => '_', '¤' => '_', '¦' => '_', '≠' => '_', '¬' => '_', |
10110 |
|
'ˆ' => '_', '¨' => '_', '‰' => '_', '¤' => '_', '€' => '_', '$' => '_', |
10111 |
|
'«' => '_', '»' => '_', '‹' => '_', '›' => '_', 'ƒ' => '_', '¥' => '_', |
10112 |
|
'‘‘' => '_', '‚' => '_', '!' => '_', '¡' => '_', '¢' => '_', '£' => '_', |
10113 |
|
'?' => '_', '[' => '_', ']' => '_', '´' => '_', '`' => '_', '^' => '_', |
10114 |
|
'~' => '_', '˜' => '_', '#' => '_', '*' => '_', '.' => '_', ':' => '_', |
10115 |
|
';' => '_', '•' => '_', '¯' => '_', '‾' => '_', '–' => '_', '–' => '_', |
10116 |
|
'—' => '_', '_' => '_', '|' => '_', '¦' => '_', '‡' => '_', '§' => '_', |
10117 |
|
'¶' => '_', '©' => '_', '®' => '_', '™' => '_', '&' => '_', '@' => '_', |
10118 |
|
'/' => '_', '\\' => '_', '◊' => '_', '♠' => '_', '♣' => '_', '♥' => '_', |
10119 |
|
'♦' => '_', '←' => '_', '↑' => '_', '→' => '_', '↓' => '_', '↔' => '_', |
10120 |
|
'°' => '_', 'µ' => '_', '<' => '_', '>' => '_', '≤' => '_', '≥' => '_', |
10121 |
|
'=' => '_', '≈' => '_', '≠' => '_', '≡' => '_', '±' => '_', '−' => '_', |
10122 |
|
'+' => '_', '×' => '_', '÷' => '_', '⁄' => '_', '%' => '_', '‰' => '_', |
10123 |
|
'¼' => '_', '½' => '_', '¾' => '_', '¹' => '_', '²' => '_', '³' => '_', |
10124 |
|
'' => '_', 'º' => '_', 'ª' => '_', 'ƒ' => '_', '′' => '_', '″' => '_', |
10125 |
|
'∂' => '_', '∏' => '_', '∑' => '_', '√' => '_', '∞' => '_', '¬' => '_', |
10126 |
|
'∩' => '_', '∫' => '_', 'α' => '_', 'Α' => '_', 'β' => '_', 'Β' => '_', |
10127 |
|
'γ' => '_', 'Γ' => '_', 'δ' => '_', 'Δ' => '_', 'ε' => '_', 'Ε' => '_', |
10128 |
|
'ζ' => '_', 'Ζ' => '_', 'η' => '_', 'Η' => '_', 'θ' => '_', 'Θ' => '_', |
10129 |
|
'ι' => '_', 'Ι' => '_', 'κ' => '_', 'Κ' => '_', 'λ' => '_', 'Λ' => '_', |
10130 |
|
'μ' => '_', 'Μ' => '_', 'ν' => '_', 'Ν' => '_', 'ξ' => '_', 'Ξ' => '_', |
10131 |
|
'ο' => '_', 'Ο' => '_', 'π' => '_', 'Π' => '_', 'ρ' => '_', 'Ρ' => '_', |
10132 |
|
'σ' => '_', 'ς' => '_', 'Σ' => '_', 'τ' => '_', 'Τ' => '_', 'υ' => '_', |
10133 |
|
'Υ' => '_', 'φ' => '_', 'Φ' => '_', 'χ' => '_', 'Χ' => '_', 'ψ' => '_', |
10134 |
|
'Ψ' => '_', 'ω' => '_', 'Ω' => '_', ',' => '_', ' ' => '_' |
10135 |
|
); |
10136 |
|
|
10137 |
|
return str_replace(array_keys($invalid), array_values($invalid), $documentLibelle); |
10138 |
|
} |
10139 |
|
|
10140 |
?> |
/** |
10141 |
|
* Surcharge permettant de ne pas afficher le fil d'Ariane dans |
10142 |
|
* l'overlay de notification des demandeurs. |
10143 |
|
*/ |
10144 |
|
function getSubFormTitle($ent) { |
10145 |
|
$actionSansPath = array('411', '420', '430'); |
10146 |
|
if (in_array($this->getParameter('maj'), $actionSansPath)) { |
10147 |
|
return ''; |
10148 |
|
} |
10149 |
|
return parent::getSubFormTitle($ent); |
10150 |
|
} |
10151 |
|
|
10152 |
|
/** |
10153 |
|
* Traitement de la notification automatique des tiers consulté. |
10154 |
|
* |
10155 |
|
* Récupère la liste des adresses mails des tiers notifiables. Pour chaque adresses |
10156 |
|
* récupérées ajoute une notification et une tâche de notification par mail. |
10157 |
|
* La création de la tâche de notification par mail déclenchera l'envoi du mail |
10158 |
|
* et la mise à jour du suivi. |
10159 |
|
* |
10160 |
|
* Les tiers notifiables sont ceux : |
10161 |
|
* - n’ayant pas un ID PLAT’AU correspondant à l’ID PLAT’AU du service consultant |
10162 |
|
* - ayant une habilitation dont le type est listé dans les paramètres de |
10163 |
|
* notification de l’événement, |
10164 |
|
* - intervenant sur la commune ou le département du dossier |
10165 |
|
* - ayant au moins une adresse mail valide |
10166 |
|
* |
10167 |
|
* @param evenement instance de l'événement associée à l'instruction |
10168 |
|
* @param dossier instance du dossier de l'instruction |
10169 |
|
* @return boolean indique si le traitement à réussi |
10170 |
|
*/ |
10171 |
|
protected function traitement_notification_automatique_tiers_consulte($evenement, $dossier) { |
10172 |
|
// Récupération de l'identifiant plat'au du service consultant |
10173 |
|
$consultationEntrante = $dossier->get_inst_consultation_entrante(); |
10174 |
|
// Récupération de la liste des types d'habilitations autorisées pour |
10175 |
|
// cette notification |
10176 |
|
$typesHabilitationsNotifiable = $evenement->get_types_habilitation_notifiable(); |
10177 |
|
// Récupération du département et de la commune du dossier |
10178 |
|
$commune = $dossier->getVal('commune'); |
10179 |
|
// Le département est récupéré à partir de la commune du dossier donc si la |
10180 |
|
// commune n'a pas pu être récupéré on ne récupère pas non plus le département. |
10181 |
|
$idDepartement = null; |
10182 |
|
if (! empty($commune)) { |
10183 |
|
$departement = $dossier->get_inst_departement_dossier(); |
10184 |
|
$idDepartement = $departement->getVal($departement->clePrimaire); |
10185 |
|
} |
10186 |
|
// Récupération des courriels des tiers notifiables |
10187 |
|
$tiersANotifier = $this->get_courriels_tiers_notifiable( |
10188 |
|
$typesHabilitationsNotifiable, |
10189 |
|
$consultationEntrante->getVal('service_consultant_id'), |
10190 |
|
$commune, |
10191 |
|
$idDepartement |
10192 |
|
); |
10193 |
|
// Traitement de chacune des listes de diffusion pour extraire les |
10194 |
|
// courriels, vérifier la validité des courriels et envoyer la |
10195 |
|
// notification |
10196 |
|
$notificationSend = false; |
10197 |
|
if (empty($tiersANotifier)) { |
10198 |
|
$this->addToLog( |
10199 |
|
sprintf( |
10200 |
|
'%s() : %s %s : ', |
10201 |
|
__METHOD__, |
10202 |
|
__("La récupération des tiers à échoué."), |
10203 |
|
__('Paramétrage'), |
10204 |
|
var_export( |
10205 |
|
array( |
10206 |
|
'types_habilitations_notifiable' => $typesHabilitationsNotifiable, |
10207 |
|
'service_consultant' => $consultationEntrante->getVal('service_consultant_id'), |
10208 |
|
'id_commune' => $commune, |
10209 |
|
'id_departement' => $idDepartement |
10210 |
|
), |
10211 |
|
true |
10212 |
|
) |
10213 |
|
), |
10214 |
|
DEBUG_MODE |
10215 |
|
); |
10216 |
|
return false; |
10217 |
|
} |
10218 |
|
foreach($tiersANotifier as $tierANotifier) { |
10219 |
|
// Découpe la liste de diffusion pour stocker les adresses mails |
10220 |
|
// des tiers dans un tableau |
10221 |
|
$courriels = |
10222 |
|
array_filter( |
10223 |
|
array_map( |
10224 |
|
'trim', |
10225 |
|
preg_split("/\r\n|\n|\r/", $tierANotifier['liste_diffusion']))); |
10226 |
|
|
10227 |
|
foreach ($courriels as $courriel) { |
10228 |
|
// Pour chaque adresse mail vérifie si l'adresse est valide |
10229 |
|
if (! $this->f->checkValidEmailAddress($courriel)) { |
10230 |
|
continue; |
10231 |
|
} |
10232 |
|
$destinataire = array( |
10233 |
|
'destinataire' => $tierANotifier['libelle'].' : '.$courriel, |
10234 |
|
'courriel' => $courriel |
10235 |
|
); |
10236 |
|
// Si l'adresse est valide ajoute une nouvelle notification |
10237 |
|
// et une tâche d'envoi de mails |
10238 |
|
$idNotif = $this->ajouter_notification( |
10239 |
|
$this->getVal($this->clePrimaire), |
10240 |
|
$this->f->get_connected_user_login_name(), |
10241 |
|
$destinataire, |
10242 |
|
$this->get_dossier_instruction_om_collectivite(), |
10243 |
|
array(), |
10244 |
|
true |
10245 |
|
); |
10246 |
|
if ($idNotif === false) { |
10247 |
|
$this->addToLog( |
10248 |
|
__METHOD__. |
10249 |
|
__("L'ajout de la notification a échoué."), |
10250 |
|
DEBUG_MODE |
10251 |
|
); |
10252 |
|
return false; |
10253 |
|
} |
10254 |
|
// Création de la tache en lui donnant l'id de la notification |
10255 |
|
$notification_by_task = $this->notification_by_task( |
10256 |
|
$idNotif, |
10257 |
|
$dossier->getVal('dossier'), |
10258 |
|
'mail', |
10259 |
|
'notification_tiers_consulte' |
10260 |
|
); |
10261 |
|
if ($notification_by_task === false) { |
10262 |
|
$this->addToLog( |
10263 |
|
__METHOD__. |
10264 |
|
__("L'ajout de la tâche de notification a échoué."), |
10265 |
|
DEBUG_MODE |
10266 |
|
); |
10267 |
|
$this->addToMessage( |
10268 |
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
10269 |
|
); |
10270 |
|
return false; |
10271 |
|
} |
10272 |
|
$notificationSend = true; |
10273 |
|
} |
10274 |
|
} |
10275 |
|
// Si aucune notification n'a été envoyé car il n'y a pas de courriels |
10276 |
|
// valide, affiche un message dans les logs pour avoir un suivi. |
10277 |
|
if (! $notificationSend) { |
10278 |
|
$this->addToLog( |
10279 |
|
sprintf( |
10280 |
|
'%s %s : %s %s : %s', |
10281 |
|
__METHOD__, |
10282 |
|
__("Il n'y a pas de tiers notifiable pour l'instruction"), |
10283 |
|
$evenement->getVal('libelle'), |
10284 |
|
__("du dossier"), |
10285 |
|
$this->getVal('dossier') |
10286 |
|
), |
10287 |
|
DEBUG_MODE |
10288 |
|
); |
10289 |
|
} |
10290 |
|
return true; |
10291 |
|
} |
10292 |
|
|
10293 |
|
/** |
10294 |
|
* Récupère, à l'aide d'une requête, la liste de diffusion des tiers |
10295 |
|
* respectant les conditions suvantes : |
10296 |
|
* - le tiers consulté dois accepté les notifications |
10297 |
|
* - la liste de diffusion ne dois pas être vide |
10298 |
|
* - l'uid du tiers consulté ne dois pas être celui passé en paramètre |
10299 |
|
* si pas d'uid passé en paramètre alors on ne filtre pas selon l'uid |
10300 |
|
* du tiers |
10301 |
|
* - le type d'habilitation des tiers dois appartenir à la liste |
10302 |
|
* fournie en paramètre |
10303 |
|
* - le tiers dois être associé à la commune ou au département passé |
10304 |
|
* en paramètre |
10305 |
|
* |
10306 |
|
* @param array $typesHabilitations tableau contenant la liste des types d'habilitation |
10307 |
|
* pouvant être notifiée |
10308 |
|
* @param integer $idPlautau uid de l'acteur plat'au du dossier qui ne dois pas être notifié |
10309 |
|
* @param integer $commune identifiant de la commune du dossier |
10310 |
|
* @param integer $departement identifiant du département du dossier |
10311 |
|
* |
10312 |
|
* @return array listes de diffusion des tiers notifiable |
10313 |
|
*/ |
10314 |
|
protected function get_courriels_tiers_notifiable(array $typesHabilitations, $idPlatau, $commune, $departement) { |
10315 |
|
// Si paramètre non renseigné alors ne renvoie rien |
10316 |
|
if (empty($typesHabilitations) || empty($commune) || empty($departement)) { |
10317 |
|
return false; |
10318 |
|
} |
10319 |
|
// Si il n'y a pas d'acteur associé au dossier alors on ne filtre pas sur l'uid de l'acteur |
10320 |
|
$filtreServiceConsulteDI = ''; |
10321 |
|
if (! empty($idPlatau)) { |
10322 |
|
$filtreServiceConsulteDI = sprintf( |
10323 |
|
'AND (tiers_consulte.uid_platau_acteur != \'%s\' |
10324 |
|
OR tiers_consulte.uid_platau_acteur IS NULL)', |
10325 |
|
$this->f->db->escapeSimple($idPlatau) |
10326 |
|
); |
10327 |
|
} |
10328 |
|
$rst = $this->f->get_all_results_from_db_query( |
10329 |
|
sprintf( |
10330 |
|
'SELECT |
10331 |
|
tiers_consulte.liste_diffusion, |
10332 |
|
tiers_consulte.libelle |
10333 |
|
FROM |
10334 |
|
%1$shabilitation_tiers_consulte |
10335 |
|
LEFT JOIN %1$stiers_consulte |
10336 |
|
ON habilitation_tiers_consulte.tiers_consulte = tiers_consulte.tiers_consulte |
10337 |
|
LEFT JOIN %1$slien_habilitation_tiers_consulte_commune |
10338 |
|
ON habilitation_tiers_consulte.habilitation_tiers_consulte = lien_habilitation_tiers_consulte_commune.habilitation_tiers_consulte |
10339 |
|
LEFT JOIN %1$slien_habilitation_tiers_consulte_departement |
10340 |
|
ON habilitation_tiers_consulte.habilitation_tiers_consulte = lien_habilitation_tiers_consulte_departement.habilitation_tiers_consulte |
10341 |
|
WHERE |
10342 |
|
tiers_consulte.accepte_notification_email IS TRUE |
10343 |
|
AND tiers_consulte.liste_diffusion IS NOT NULL |
10344 |
|
%3$s |
10345 |
|
AND habilitation_tiers_consulte.type_habilitation_tiers_consulte IN (%2$s) |
10346 |
|
AND ( |
10347 |
|
lien_habilitation_tiers_consulte_commune.commune = %4$d |
10348 |
|
OR lien_habilitation_tiers_consulte_departement.departement = %5$d |
10349 |
|
) |
10350 |
|
ORDER BY |
10351 |
|
tiers_consulte.libelle |
10352 |
|
', |
10353 |
|
DB_PREFIXE, |
10354 |
|
implode(', ', $typesHabilitations), |
10355 |
|
$filtreServiceConsulteDI, |
10356 |
|
intval($commune), |
10357 |
|
intval($departement) |
10358 |
|
), |
10359 |
|
array( |
10360 |
|
"origin" => __METHOD__ |
10361 |
|
) |
10362 |
|
); |
10363 |
|
return $rst['result']; |
10364 |
|
} |
10365 |
|
} |