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 |
|
|
261 |
); |
); |
262 |
|
|
263 |
// ACTION - 180 - pdf_lettre_rar |
// ACTION - 180 - pdf_lettre_rar |
264 |
// Génère PDF sur bordereaux de lettres RAR |
// Génère PDF sur bordereaux de lettres AR |
265 |
$this->class_actions[180] = array( |
$this->class_actions[180] = array( |
266 |
"identifier" => "pdf_lettre_rar", |
"identifier" => "pdf_lettre_rar", |
267 |
"view" => "view_pdf_lettre_rar", |
"view" => "view_pdf_lettre_rar", |
317 |
"permission_suffix" => "modifier", |
"permission_suffix" => "modifier", |
318 |
"condition" => array("can_user_access_dossier_contexte_modification"), |
"condition" => array("can_user_access_dossier_contexte_modification"), |
319 |
); |
); |
320 |
|
|
321 |
|
// ACTION - 701 |
322 |
|
$this->class_actions[701] = array( |
323 |
|
"identifier" => "enable-edition-integrale", |
324 |
|
"portlet" => array( |
325 |
|
"type" => "action-direct-with-confirmation", |
326 |
|
"libelle" => _("Rédaction libre"), |
327 |
|
"order" => 50, |
328 |
|
"class" => "redac-libre-16", |
329 |
|
), |
330 |
|
"view" => "formulaire", |
331 |
|
"method" => "enable_edition_integrale", |
332 |
|
"permission_suffix" => "modifier", |
333 |
|
"condition" => array( |
334 |
|
"is_editable", |
335 |
|
"is_finalizable_without_bypass", |
336 |
|
"can_user_access_dossier_contexte_modification", |
337 |
|
"is_edition_integrale_not_enabled", |
338 |
|
"is_option_redaction_libre_enabled", |
339 |
|
"has_an_edition", |
340 |
|
), |
341 |
|
); |
342 |
|
// ACTION - 702 |
343 |
|
$this->class_actions[702] = array( |
344 |
|
"identifier" => "disable-edition-integrale", |
345 |
|
"portlet" => array( |
346 |
|
"type" => "action-direct-with-confirmation", |
347 |
|
"libelle" => _("Rédaction par compléments"), |
348 |
|
"order" => 50, |
349 |
|
"class" => "redac-complement-16", |
350 |
|
), |
351 |
|
"view" => "formulaire", |
352 |
|
"method" => "disable_edition_integrale", |
353 |
|
"permission_suffix" => "modifier", |
354 |
|
"condition" => array( |
355 |
|
"is_editable", |
356 |
|
"is_finalizable_without_bypass", |
357 |
|
"can_user_access_dossier_contexte_modification", |
358 |
|
"is_edition_integrale_enabled", |
359 |
|
"is_option_redaction_libre_enabled", |
360 |
|
"has_an_edition", |
361 |
|
), |
362 |
|
); |
363 |
|
// ACTION - 300 - evenement_has_an_edition_json |
364 |
|
// |
365 |
|
$this->class_actions[300] = array( |
366 |
|
"identifier" => "evenement_has_an_edition_json", |
367 |
|
"view" => "view_evenement_has_an_edition_json", |
368 |
|
"permission_suffix" => "consulter", |
369 |
|
); |
370 |
|
|
371 |
|
// ACTION - 301 - evenement_has_a_commentaire |
372 |
|
// |
373 |
|
$this->class_actions[301] = array( |
374 |
|
"identifier" => "evenement_has_a_commentaire_json", |
375 |
|
"view" => "view_evenement_has_a_commentaire_json", |
376 |
|
"permission_suffix" => "consulter", |
377 |
|
); |
378 |
|
|
379 |
|
// ACTION - 400 - Envoyer en signature |
380 |
|
// Cet évenement permet d'envoyer le document au parapheur pour signature |
381 |
|
$this->class_actions[400] = array( |
382 |
|
"identifier" => "envoyer_a_signature", |
383 |
|
"portlet" => array( |
384 |
|
"libelle" => _("Envoyer à signature"), |
385 |
|
"type" => "action-direct-with-confirmation", |
386 |
|
"class" => "envoyer_a_signature-16", |
387 |
|
), |
388 |
|
"view" => "formulaire", |
389 |
|
"method" => "envoyer_a_signature_sans_relecture", |
390 |
|
"condition" => array( |
391 |
|
"can_be_signed", |
392 |
|
), |
393 |
|
"permission_suffix" => "envoyer_a_signature", |
394 |
|
); |
395 |
|
|
396 |
|
// ACTION - 402 - Envoyer en signature avec relecture |
397 |
|
// Cet évenement permet d'envoyer le document au parapheur pour signature |
398 |
|
$this->class_actions[402] = array( |
399 |
|
"identifier" => "envoyer_a_signature_relecture", |
400 |
|
"portlet" => array( |
401 |
|
"libelle" => __("Envoyer à signature avec relecture"), |
402 |
|
"type" => "action-direct-with-confirmation", |
403 |
|
"class" => "envoyer_a_signature-16", |
404 |
|
), |
405 |
|
"view" => "formulaire", |
406 |
|
"method" => "envoyer_a_signature_avec_relecture", |
407 |
|
"condition" => array( |
408 |
|
"can_be_signed", |
409 |
|
"is_parapheur_relecture_parameter_enabled" |
410 |
|
), |
411 |
|
"permission_suffix" => "envoyer_a_signature", |
412 |
|
); |
413 |
|
|
414 |
|
// |
415 |
|
$this->class_actions[401] = array( |
416 |
|
"identifier" => "preview_edition", |
417 |
|
"view" => "formulaire", |
418 |
|
"permission_suffix" => "tab", |
419 |
|
); |
420 |
|
|
421 |
|
// ACTION - 410 - Notifier les pétitionnaires (mail ou autre) |
422 |
|
$this->class_actions[410] = array( |
423 |
|
"identifier" => "overlay_notification_manuelle", |
424 |
|
"portlet" => array( |
425 |
|
"libelle" => __("Notifier les pétitionnaires"), |
426 |
|
"type" => "action-self", |
427 |
|
"class" => "notifier_commune-16", |
428 |
|
), |
429 |
|
"condition" => array( |
430 |
|
"is_notifiable_by_task_manual", |
431 |
|
"is_not_portail_notification_sans_annexe" |
432 |
|
), |
433 |
|
"view" => "view_overlay_notification_manuelle", |
434 |
|
"permission_suffix" => "modifier", |
435 |
|
); |
436 |
|
|
437 |
|
// ACTION - 410 - Notifier les pétitionnaires (portail citoyen) |
438 |
|
$this->class_actions[411] = array( |
439 |
|
"identifier" => "notification_manuelle_portal", |
440 |
|
"portlet" => array( |
441 |
|
"libelle" => __("Notifier les pétitionnaires"), |
442 |
|
"type" => "action-direct-with-confirmation", |
443 |
|
"class" => "notifier_commune-16", |
444 |
|
), |
445 |
|
"condition" => array( |
446 |
|
"is_notifiable_by_task_manual", |
447 |
|
"is_portail_notification_sans_annexe" |
448 |
|
), |
449 |
|
"method" => "notifier_demandeur_principal", |
450 |
|
"permission_suffix" => "modifier", |
451 |
|
); |
452 |
|
|
453 |
|
// |
454 |
|
$this->class_actions[998] = array( |
455 |
|
"identifier" => "json_data", |
456 |
|
"view" => "view_json_data", |
457 |
|
"permission_suffix" => "consulter", |
458 |
|
); |
459 |
|
} |
460 |
|
|
461 |
|
/** |
462 |
|
* Clause select pour la requête de sélection des données de l'enregistrement. |
463 |
|
* |
464 |
|
* @return array |
465 |
|
*/ |
466 |
|
function get_var_sql_forminc__champs() { |
467 |
|
return array( |
468 |
|
"instruction", |
469 |
|
"destinataire", |
470 |
|
"instruction.evenement", |
471 |
|
"instruction.commentaire", |
472 |
|
"date_evenement", |
473 |
|
"instruction.lettretype", |
474 |
|
"signataire_arrete", |
475 |
|
"flag_edition_integrale", |
476 |
|
"om_final_instruction_utilisateur", |
477 |
|
"date_finalisation_courrier", |
478 |
|
"date_envoi_signature", |
479 |
|
"date_envoi_rar", |
480 |
|
"date_envoi_controle_legalite", |
481 |
|
|
482 |
|
"date_retour_signature", |
483 |
|
"date_retour_rar", |
484 |
|
"date_retour_controle_legalite", |
485 |
|
|
486 |
|
"numero_arrete", |
487 |
|
|
488 |
|
"complement_om_html", |
489 |
|
"'' as bible_auto", |
490 |
|
"'' as bible", |
491 |
|
"complement2_om_html", |
492 |
|
"'' as bible2", |
493 |
|
"complement3_om_html", |
494 |
|
"'' as bible3", |
495 |
|
"complement4_om_html", |
496 |
|
"'' as bible4", |
497 |
|
|
498 |
|
"titre_om_htmletat", |
499 |
|
"corps_om_htmletatex", |
500 |
|
|
501 |
|
"'' as btn_preview", |
502 |
|
"'' as btn_redaction", |
503 |
|
|
504 |
|
"'' as btn_refresh", |
505 |
|
"'' as live_preview", |
506 |
|
|
507 |
|
"dossier", |
508 |
|
"instruction.action", |
509 |
|
"instruction.delai", |
510 |
|
"instruction.etat", |
511 |
|
"instruction.autorite_competente", |
512 |
|
"instruction.accord_tacite", |
513 |
|
"instruction.delai_notification", |
514 |
|
"instruction.avis_decision", |
515 |
|
"archive_delai", |
516 |
|
"archive_accord_tacite", |
517 |
|
"archive_etat", |
518 |
|
"archive_avis", |
519 |
|
"archive_date_complet", |
520 |
|
"archive_date_rejet", |
521 |
|
"archive_date_limite", |
522 |
|
"archive_date_notification_delai", |
523 |
|
"archive_date_decision", |
524 |
|
"archive_date_validite", |
525 |
|
"archive_date_achevement", |
526 |
|
"archive_date_conformite", |
527 |
|
"archive_date_chantier", |
528 |
|
"archive_date_dernier_depot", |
529 |
|
"date_depot", |
530 |
|
"date_depot_mairie", |
531 |
|
"complement5_om_html", |
532 |
|
"'' as bible5", |
533 |
|
"complement6_om_html", |
534 |
|
"'' as bible6", |
535 |
|
"complement7_om_html", |
536 |
|
"'' as bible7", |
537 |
|
"complement8_om_html", |
538 |
|
"'' as bible8", |
539 |
|
"complement9_om_html", |
540 |
|
"'' as bible9", |
541 |
|
"complement10_om_html", |
542 |
|
"'' as bible10", |
543 |
|
"complement11_om_html", |
544 |
|
"'' as bible11", |
545 |
|
"complement12_om_html", |
546 |
|
"complement13_om_html", |
547 |
|
"complement14_om_html", |
548 |
|
"complement15_om_html", |
549 |
|
"archive_incompletude", |
550 |
|
"archive_incomplet_notifie", |
551 |
|
"archive_evenement_suivant_tacite", |
552 |
|
"archive_evenement_suivant_tacite_incompletude", |
553 |
|
"archive_etat_pendant_incompletude", |
554 |
|
"archive_date_limite_incompletude", |
555 |
|
"archive_delai_incompletude", |
556 |
|
"archive_autorite_competente", |
557 |
|
"code_barres", |
558 |
|
"om_fichier_instruction", |
559 |
|
"om_final_instruction", |
560 |
|
"om_fichier_instruction_dossier_final", |
561 |
|
"document_numerise", |
562 |
|
"duree_validite_parametrage", |
563 |
|
"duree_validite", |
564 |
|
"created_by_commune", |
565 |
|
"archive_date_cloture_instruction", |
566 |
|
"archive_date_premiere_visite", |
567 |
|
"archive_date_derniere_visite", |
568 |
|
"archive_date_contradictoire", |
569 |
|
"archive_date_retour_contradictoire", |
570 |
|
"archive_date_ait", |
571 |
|
"archive_date_transmission_parquet", |
572 |
|
"archive_dossier_instruction_type", |
573 |
|
"archive_date_affichage", |
574 |
|
"pec_metier", |
575 |
|
"archive_pec_metier", |
576 |
|
"archive_a_qualifier", |
577 |
|
"id_parapheur_signature", |
578 |
|
"statut_signature", |
579 |
|
"commentaire_signature", |
580 |
|
"historique_signature", |
581 |
|
"'' as suivi_notification", |
582 |
|
|
583 |
|
|
584 |
|
"'' as preview_edition", |
585 |
|
); |
586 |
|
} |
587 |
|
|
588 |
|
/** |
589 |
|
* CONDITION - is_edition_integrale_enabled |
590 |
|
* |
591 |
|
* Vérifie que la rédaction libre est activée sur l'instruction en cours. |
592 |
|
* |
593 |
|
* @return boolean |
594 |
|
*/ |
595 |
|
function is_edition_integrale_enabled() { |
596 |
|
if ($this->getVal("flag_edition_integrale") == 't') { |
597 |
|
return true; |
598 |
|
} |
599 |
|
return false; |
600 |
|
} |
601 |
|
|
602 |
|
/** |
603 |
|
* CONDITION - is_edition_integrale_not_enabled |
604 |
|
* |
605 |
|
* Vérifie que la rédaction libre est désactivée sur l'instruction en cours. |
606 |
|
* |
607 |
|
* @return boolean |
608 |
|
*/ |
609 |
|
function is_edition_integrale_not_enabled() { |
610 |
|
return !$this->is_edition_integrale_enabled(); |
611 |
|
} |
612 |
|
|
613 |
|
/** |
614 |
|
* CONDITION - is_option_redaction_libre_enabled |
615 |
|
* |
616 |
|
* Vérifie que l'option de rédaction libre est activée. |
617 |
|
* |
618 |
|
* @return boolean |
619 |
|
*/ |
620 |
|
function is_option_redaction_libre_enabled() { |
621 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite(); |
622 |
|
return $this->f->is_option_redaction_libre_enabled($collectivite_di); |
623 |
|
} |
624 |
|
|
625 |
|
/** |
626 |
|
* CONDITION - is_option_parapheur_relecture_enabled |
627 |
|
* |
628 |
|
* Vérifie que l'option de relecture lors de l'envoi en signature est activée. |
629 |
|
* |
630 |
|
* @return boolean |
631 |
|
*/ |
632 |
|
function is_parapheur_relecture_parameter_enabled() { |
633 |
|
//Instanciation de la classe electronicsignature |
634 |
|
$inst_es = $this->get_electronicsignature_instance(); |
635 |
|
if ($inst_es === false) { |
636 |
|
return false; |
637 |
|
} |
638 |
|
|
639 |
|
if ($inst_es->get_conf('is_forced_view_files') !== 'true' && $inst_es->get_conf('is_forced_view_files') !== true) { |
640 |
|
return false; |
641 |
|
} |
642 |
|
|
643 |
|
return true; |
644 |
|
} |
645 |
|
|
646 |
|
|
647 |
|
/** |
648 |
|
* CONDITION - is_sent_for_signature |
649 |
|
* |
650 |
|
* Vérifie que l'instruction a été envoyé à signature |
651 |
|
* |
652 |
|
* @return boolean |
653 |
|
*/ |
654 |
|
function is_sent_for_signature() { |
655 |
|
// Si un parapheur a été configuré |
656 |
|
// et que le champ id_parapheur_signature n'est pas vide |
657 |
|
// que le status est différent de "canceled" ou "expired" |
658 |
|
// alors l'évènement a été envoyé en signature |
659 |
|
if ($this->has_connector_electronicsignature() === true |
660 |
|
&& empty($this->getVal("id_parapheur_signature")) === false |
661 |
|
&& ($this->getVal("statut_signature") != "canceled" |
662 |
|
|| $this->getVal("statut_signature") != "expired" |
663 |
|
|| $this->getVal("statut_signature") != "finished")) { |
664 |
|
// |
665 |
|
return true; |
666 |
|
} |
667 |
|
|
668 |
|
return false; |
669 |
|
} |
670 |
|
|
671 |
|
/** |
672 |
|
* CONDITION - is_not_sent_for_signature |
673 |
|
* |
674 |
|
* Vérifie que l'instruction n'a pas été envoyé à signature |
675 |
|
* |
676 |
|
* @return boolean |
677 |
|
*/ |
678 |
|
function is_not_sent_for_signature() { |
679 |
|
// Contrôle si l'utilisateur possède un bypass |
680 |
|
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_definaliser_bypass"); |
681 |
|
if ($bypass == true) { |
682 |
|
return true; |
683 |
|
} |
684 |
|
|
685 |
|
return !$this->is_sent_for_signature(); |
686 |
|
} |
687 |
|
|
688 |
|
|
689 |
|
/** |
690 |
|
* CONDITION - is_signed |
691 |
|
* |
692 |
|
* Vérifie que l'instruction a été signé |
693 |
|
* |
694 |
|
* @return boolean |
695 |
|
*/ |
696 |
|
function is_signed() { |
697 |
|
// Si un parapheur a été configuré |
698 |
|
// et que le champ id_parapheur_signature n'est pas vide |
699 |
|
// et que le statut est égal à "finished" |
700 |
|
// alors le document de l'instruciton à été signé |
701 |
|
if ($this->has_connector_electronicsignature() === true |
702 |
|
&& empty($this->getVal("id_parapheur_signature")) === false |
703 |
|
&& $this->getVal("statut_signature") == "finished") { |
704 |
|
// |
705 |
|
return true; |
706 |
|
} |
707 |
|
|
708 |
|
return false; |
709 |
|
} |
710 |
|
|
711 |
|
/** |
712 |
|
* CONDITION - is_portail_notification |
713 |
|
* |
714 |
|
* Vérifie si la notification est une notification de catégorie portail |
715 |
|
* |
716 |
|
* @return boolean |
717 |
|
*/ |
718 |
|
function is_portail_notification_sans_annexe() { |
719 |
|
$collectiviteDi = $this->get_dossier_instruction_om_collectivite(); |
720 |
|
$ev = $this->get_inst_evenement($this->getVal('evenement')); |
721 |
|
if (($this->f->get_param_option_notification($collectiviteDi) === null || |
722 |
|
$this->f->get_param_option_notification($collectiviteDi) === 'portal') |
723 |
|
&& $ev->getVal('notification') != 'notification_manuelle_annexe' |
724 |
|
&& $ev->getVal('notification') != 'notification_manuelle_annexe_signature_requise' |
725 |
|
) { |
726 |
|
return true; |
727 |
|
} |
728 |
|
return false; |
729 |
|
} |
730 |
|
|
731 |
|
/** |
732 |
|
* CONDITION - is_not_portail_notification |
733 |
|
* |
734 |
|
* Vérifie si la notification n'est pas une notification de catégorie portail |
735 |
|
* |
736 |
|
* @return boolean |
737 |
|
*/ |
738 |
|
function is_not_portail_notification_sans_annexe() { |
739 |
|
return (! $this->is_portail_notification_sans_annexe()); |
740 |
|
} |
741 |
|
|
742 |
|
/** |
743 |
|
* CONDITION - can_be_signed |
744 |
|
* |
745 |
|
* Vérifie que le document de l'instruction peut être envoyé au parapheur pour signature |
746 |
|
* |
747 |
|
* @return boolean |
748 |
|
*/ |
749 |
|
function can_be_signed() { |
750 |
|
// Instanciation de l'objet signataire_arrete |
751 |
|
$inst_signataire_arrete = $this->f->get_inst__om_dbform(array( |
752 |
|
"obj" => "signataire_arrete", |
753 |
|
"idx" => $this->getVal("signataire_arrete"), |
754 |
|
)); |
755 |
|
// Si un parapheur a été configuré, que le document est finalisé, que le signataire |
756 |
|
// possède une adresse email, on vérifie le champ id_parapheur_signature |
757 |
|
// S'il est vide l'évènement peut être envoyé en signature |
758 |
|
// S'il ne l'est pas, alors on vérifie le champ statut_signature |
759 |
|
// Si la valeur de ce champ est égal à "canceled" ou "expired" |
760 |
|
// alors l'évènement peut être envoyé en signature |
761 |
|
if ($this->has_connector_electronicsignature() === true |
762 |
|
&& $this->getVal("om_final_instruction") == 't' |
763 |
|
&& empty($inst_signataire_arrete->getVal('email')) === false) { |
764 |
|
// |
765 |
|
if (empty($this->getVal("id_parapheur_signature")) === true |
766 |
|
|| $this->getVal("statut_signature") == "canceled" |
767 |
|
|| $this->getVal("statut_signature") == "expired") { |
768 |
|
// |
769 |
|
return true; |
770 |
|
} |
771 |
|
} |
772 |
|
|
773 |
|
$this->addToLog(__METHOD__."() has_connector_electronicsignature: ".var_export($this->has_connector_electronicsignature(), true), EXTRA_VERBOSE_MODE); |
774 |
|
$this->addToLog(__METHOD__."() om_final_instruction: ".var_export($this->getVal("om_final_instruction"), true), EXTRA_VERBOSE_MODE); |
775 |
|
$this->addToLog(__METHOD__."() email: ".var_export($inst_signataire_arrete->getVal('email'), true), EXTRA_VERBOSE_MODE); |
776 |
|
$this->addToLog(__METHOD__."() id_parapheur_signature: ".var_export($this->getVal("id_parapheur_signature"), true), EXTRA_VERBOSE_MODE); |
777 |
|
$this->addToLog(__METHOD__."() statut_signature: ".var_export($this->getVal("statut_signature"), true), EXTRA_VERBOSE_MODE); |
778 |
|
|
779 |
|
return false; |
780 |
|
} |
781 |
|
|
782 |
|
/** |
783 |
|
* CONDITION - has_connector_electronicsignature |
784 |
|
* |
785 |
|
* Vérifie qu'un parapheur est paramétré |
786 |
|
* |
787 |
|
* @return boolean |
788 |
|
*/ |
789 |
|
function has_connector_electronicsignature() { |
790 |
|
$inst_es = $this->get_electronicsignature_instance(false); |
791 |
|
if ($inst_es === false) { |
792 |
|
return false; |
793 |
|
} |
794 |
|
return true; |
795 |
|
} |
796 |
|
|
797 |
|
/** |
798 |
|
* CONDITION - can_display_parapheur |
799 |
|
* |
800 |
|
* Vérifie que le fieldset "Suivi Parapheur" soit affichable |
801 |
|
* |
802 |
|
* @return boolean |
803 |
|
*/ |
804 |
|
function can_display_parapheur() { |
805 |
|
$evenement_id = $this->getVal("evenement"); |
806 |
|
$inst_evenement = $this->get_inst_evenement($evenement_id); |
807 |
|
if ($this->has_connector_electronicsignature() === true |
808 |
|
&& $inst_evenement->getVal('lettretype') !== '' |
809 |
|
&& $inst_evenement->getVal('lettretype') !== null |
810 |
|
&& (empty($this->getVal("id_parapheur_signature")) === false |
811 |
|
|| empty($this->getVal("historique_signature")) === false)) { |
812 |
|
// |
813 |
|
return true; |
814 |
|
} |
815 |
|
|
816 |
|
return false; |
817 |
|
} |
818 |
|
|
819 |
|
/** |
820 |
|
* CONDITION - can_display_notification |
821 |
|
* |
822 |
|
* Vérifie que le fieldset "Suivi notification" soit affichable |
823 |
|
* |
824 |
|
* @return boolean |
825 |
|
*/ |
826 |
|
function can_display_notification() { |
827 |
|
// Le suivi des notification est affiché si l'événement est notifiable |
828 |
|
// et si des notifications ont été envoyées |
829 |
|
$evenement_id = $this->getVal("evenement"); |
830 |
|
$inst_evenement = $this->get_inst_evenement($evenement_id); |
831 |
|
if ($inst_evenement->getVal('notification') != null && |
832 |
|
$inst_evenement->getVal('notification') != '') { |
833 |
|
// Des notifications ont été envoyé si il existe au moins une notification |
834 |
|
// liées à l'instruction |
835 |
|
$idsNotifs = $this->get_instruction_notification($this->getVal($this->clePrimaire)); |
836 |
|
if (isset($idsNotifs) && $idsNotifs !== array()) { |
837 |
|
return true; |
838 |
|
} |
839 |
|
} |
840 |
|
return false; |
841 |
|
} |
842 |
|
|
843 |
|
/** |
844 |
|
* TREATMENT - disable_edition_integrale. |
845 |
|
* |
846 |
|
* Cette methode permet de passer la consultation en "lu" |
847 |
|
* |
848 |
|
* @return boolean true si maj effectué false sinon |
849 |
|
*/ |
850 |
|
function disable_edition_integrale() { |
851 |
|
// Cette méthode permet d'exécuter une routine en début des méthodes |
852 |
|
// dites de TREATMENT. |
853 |
|
$this->begin_treatment(__METHOD__); |
854 |
|
$this->correct = true; |
855 |
|
$valF = array( |
856 |
|
"flag_edition_integrale" => false, |
857 |
|
"titre_om_htmletat" => null, |
858 |
|
"corps_om_htmletatex" => null, |
859 |
|
); |
860 |
|
$res = $this->f->db->autoExecute( |
861 |
|
DB_PREFIXE.$this->table, |
862 |
|
$valF, |
863 |
|
DB_AUTOQUERY_UPDATE, |
864 |
|
$this->clePrimaire."=".$this->getVal($this->clePrimaire) |
865 |
|
); |
866 |
|
if ($this->f->isDatabaseError($res, true)) { |
867 |
|
// Appel de la methode de recuperation des erreurs |
868 |
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
869 |
|
$this->correct = false; |
870 |
|
// Termine le traitement |
871 |
|
return $this->end_treatment(__METHOD__, false); |
872 |
|
} else { |
873 |
|
$this->addToMessage(_("Rédaction par compléments activé.")); |
874 |
|
return $this->end_treatment(__METHOD__, true); |
875 |
|
} |
876 |
|
|
877 |
|
// Termine le traitement |
878 |
|
return $this->end_treatment(__METHOD__, false); |
879 |
} |
} |
880 |
|
|
881 |
|
/** |
882 |
|
* TREATMENT - enable_edition_integrale. |
883 |
|
* |
884 |
|
* Cette methode permet de passer la consultation en "lu" |
885 |
|
* |
886 |
|
* @return boolean true si maj effectué false sinon |
887 |
|
*/ |
888 |
|
function enable_edition_integrale() { |
889 |
|
// Cette méthode permet d'exécuter une routine en début des méthodes |
890 |
|
// dites de TREATMENT. |
891 |
|
$this->begin_treatment(__METHOD__); |
892 |
|
$this->correct = true; |
893 |
|
|
894 |
|
// Récupère la collectivite du dossier d'instruction |
895 |
|
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
896 |
|
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
897 |
|
// |
898 |
|
$params = array( |
899 |
|
"specific" => array( |
900 |
|
"corps" => array( |
901 |
|
"mode" => "get", |
902 |
|
) |
903 |
|
), |
904 |
|
); |
905 |
|
$result = $this->compute_pdf_output('lettretype', $this->getVal('lettretype'), $collectivite, null, $params); |
906 |
|
$corps = $result['pdf_output']; |
907 |
|
// |
908 |
|
$params = array( |
909 |
|
"specific" => array( |
910 |
|
"titre" => array( |
911 |
|
"mode" => "get", |
912 |
|
) |
913 |
|
), |
914 |
|
); |
915 |
|
$result = $this->compute_pdf_output('lettretype', $this->getVal('lettretype'), $collectivite, null, $params); |
916 |
|
$titre = $result['pdf_output']; |
917 |
|
// |
918 |
|
$valF = array( |
919 |
|
"flag_edition_integrale" => true, |
920 |
|
"titre_om_htmletat" => $titre, |
921 |
|
"corps_om_htmletatex" => $corps, |
922 |
|
); |
923 |
|
$res = $this->f->db->autoExecute( |
924 |
|
DB_PREFIXE.$this->table, |
925 |
|
$valF, |
926 |
|
DB_AUTOQUERY_UPDATE, |
927 |
|
$this->clePrimaire."=".$this->getVal($this->clePrimaire) |
928 |
|
); |
929 |
|
if ($this->f->isDatabaseError($res, true)) { |
930 |
|
// Appel de la methode de recuperation des erreurs |
931 |
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
932 |
|
$this->correct = false; |
933 |
|
// Termine le traitement |
934 |
|
return $this->end_treatment(__METHOD__, false); |
935 |
|
} else { |
936 |
|
$this->addToMessage(_("Rédaction libre activé.")); |
937 |
|
return $this->end_treatment(__METHOD__, true); |
938 |
|
} |
939 |
|
|
940 |
|
// Termine le traitement |
941 |
|
return $this->end_treatment(__METHOD__, false); |
942 |
|
} |
943 |
|
|
944 |
/** |
/** |
945 |
* 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 |
953 |
$sql = "select dossier_autorisation from ".DB_PREFIXE."dossier "; |
$sql = "select dossier_autorisation from ".DB_PREFIXE."dossier "; |
954 |
$sql .= " where dossier='".$id."'"; |
$sql .= " where dossier='".$id."'"; |
955 |
// |
// |
956 |
$dossier_autorisation = $this->db->getOne($sql); |
$dossier_autorisation = $this->f->db->getOne($sql); |
957 |
$this->addToLog("getNumDemandeAutorFromDossier(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
$this->addToLog("getNumDemandeAutorFromDossier(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
958 |
database::isError($dossier_autorisation); |
database::isError($dossier_autorisation); |
959 |
// |
// |
963 |
// }}} |
// }}} |
964 |
|
|
965 |
function setType(&$form, $maj) { |
function setType(&$form, $maj) { |
966 |
// |
// Récupération du mode de l'action |
967 |
parent::setType($form, $maj); |
$crud = $this->get_action_crud($maj); |
968 |
// On cache tous les champs |
// Récupère la collectivité du dossier d'instruction |
969 |
// 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'); |
|
970 |
|
|
971 |
// |
// Cache tous les champs |
972 |
$form->setType('archive_date_cloture_instruction','hidden'); |
foreach ($this->champs as $value) { |
973 |
$form->setType('archive_date_premiere_visite','hidden'); |
$form->setType($value, 'hidden'); |
974 |
$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'); |
|
975 |
|
|
976 |
// |
// Les champs historique_signature et statut_signature ne sont pas saisissable dans tous les cas |
977 |
$form->setType('duree_validite','hidden'); |
if ($this->can_display_parapheur() === true && $maj == 3) { |
978 |
$form->setType('duree_validite_parametrage','hidden'); |
$form->setType('statut_signature', 'selectstatic'); |
979 |
|
$form->setType('historique_signature', 'jsontotab'); |
980 |
|
if ($this->getVal('commentaire_signature') == null) { |
981 |
|
$form->setType('commentaire_signature', 'hidden'); |
982 |
|
} else { |
983 |
|
$form->setType('commentaire_signature', 'hiddenstatic'); |
984 |
|
} |
985 |
|
} |
986 |
|
|
987 |
// |
// Le champ de suivi des notifications n'est pas affichable dans tous les cas |
988 |
$form->setType('created_by_commune','hidden'); |
if ($this->can_display_notification() === true && $maj == 3) { |
989 |
// |
$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'); |
|
990 |
} |
} |
|
// |
|
|
if ($maj < 2 || $maj == 125) { //ajouter, modifier et suivi des dates |
|
|
$form->setType('destinataire', 'hidden'); |
|
|
$form->setType('lettretype', 'hiddenstatic'); |
|
|
$form->setType('complement_om_html', 'html'); |
|
|
$form->setType('complement2_om_html', 'html'); |
|
|
$form->setType('complement3_om_html', 'html'); |
|
|
$form->setType('complement4_om_html', 'html'); |
|
|
$form->setType('bible_auto', 'httpclick'); |
|
|
$form->setType('bible', 'httpclick'); |
|
|
$form->setType('bible2', 'httpclick'); |
|
|
$form->setType('bible3', 'httpclick'); |
|
|
$form->setType('bible4', 'httpclick'); |
|
|
$form->setType('btn_refresh', 'hidden'); |
|
|
$form->setType('live_preview', 'hidden'); |
|
|
$form->setType('dossier', 'hidden'); |
|
|
$form->setType('libelle', 'hiddenstatic'); |
|
|
$form->setType('signataire_arrete','select'); |
|
|
$form->setType('date_envoi_signature','datedisabled'); |
|
|
$form->setType('date_retour_signature','datedisabled'); |
|
|
$form->setType('date_envoi_rar','datedisabled'); |
|
|
$form->setType('date_retour_rar','datedisabled'); |
|
|
$form->setType('date_envoi_controle_legalite','datedisabled'); |
|
|
$form->setType('date_retour_controle_legalite','datedisabled'); |
|
|
$form->setType('date_finalisation_courrier','datedisabled'); |
|
|
|
|
|
if($maj==0){ // ajouter |
|
|
$form->setType('instruction', 'hidden'); |
|
|
$form->setType('lettretype', 'hidden'); |
|
|
$form->setType('evenement', 'select'); |
|
|
$form->setType('date_evenement', 'date2'); |
|
|
}else{ // modifier et suivi des dates |
|
|
$form->setType('instruction', 'hiddenstatic'); |
|
|
$form->setType('evenement', 'selecthiddenstatic'); |
|
|
//$form->setType('date_evenement', 'hiddenstaticdate'); |
|
|
$form->setType('date_evenement', 'date2'); |
|
991 |
|
|
992 |
// Récupère la collectivité du dossier d'instruction |
// MODE AJOUTER |
993 |
$collectivite_di = $this->get_dossier_instruction_om_collectivite(); |
if ($this->getParameter('maj') == 0) { |
994 |
|
$form->setType('commentaire', 'textareahidden'); |
995 |
|
// Si l'option est active passage du champ date en lecture seule |
996 |
|
if ($this->f->is_option_date_evenement_instruction_lecture_seule($collectivite_di) === true) { |
997 |
|
$form->setType("date_evenement", "hiddenstaticdate"); |
998 |
|
} else { |
999 |
|
$form->setType("date_evenement", "date"); |
1000 |
|
} |
1001 |
|
if ($this->is_in_context_of_foreign_key("evenement", $this->getParameter("retourformulaire"))) { |
1002 |
|
$form->setType("evenement", "selecthiddenstatic"); |
1003 |
|
} else { |
1004 |
|
$form->setType("evenement", "select"); |
1005 |
|
} |
1006 |
|
if ($this->is_in_context_of_foreign_key("signataire_arrete", $this->getParameter("retourformulaire"))) { |
1007 |
|
$form->setType("signataire_arrete", "selecthiddenstatic"); |
1008 |
|
} else { |
1009 |
|
$form->setType("signataire_arrete", "select"); |
1010 |
|
} |
1011 |
|
if ($this->is_option_redaction_libre_enabled() === true) { |
1012 |
|
$form->setType("flag_edition_integrale", "select"); |
1013 |
|
} |
1014 |
|
} |
1015 |
|
|
1016 |
// |
// MODE MODIFIER |
1017 |
if ($this->f->is_option_preview_pdf_enabled($collectivite_di) === true |
if ($this->getParameter('maj') == 1) { |
1018 |
&& $this->has_an_edition() === true) { |
// Si l'option est active passage du champ date en lecture seule |
1019 |
$form->setType('btn_refresh', 'httpclick'); |
if ($this->f->is_option_date_evenement_instruction_lecture_seule($collectivite_di) === true) { |
1020 |
|
$form->setType("date_evenement", "hiddenstaticdate"); |
1021 |
|
} else { |
1022 |
|
$form->setType("date_evenement", "date"); |
1023 |
|
} |
1024 |
|
$form->setType("evenement", "selecthiddenstatic"); |
1025 |
|
if ($this->has_an_edition() === true) { |
1026 |
|
$form->setType('lettretype', 'hiddenstatic'); |
1027 |
|
if ($this->is_in_context_of_foreign_key("signataire_arrete", $this->getParameter("retourformulaire"))) { |
1028 |
|
$form->setType("signataire_arrete", "selecthiddenstatic"); |
1029 |
|
} else { |
1030 |
|
$form->setType("signataire_arrete", "select"); |
1031 |
|
} |
1032 |
|
if ($this->getVal("flag_edition_integrale") == "t") { |
1033 |
|
$form->setType("titre_om_htmletat", "htmlEtat"); |
1034 |
|
$form->setType("corps_om_htmletatex", "htmlEtatEx"); |
1035 |
|
} else { |
1036 |
|
$form->setType("complement_om_html", "html"); |
1037 |
|
$form->setType("complement2_om_html", "html"); |
1038 |
|
$form->setType("complement3_om_html", "html"); |
1039 |
|
$form->setType("complement4_om_html", "html"); |
1040 |
|
$form->setType('bible_auto', 'httpclick'); |
1041 |
|
$form->setType('bible', 'httpclick'); |
1042 |
|
$form->setType('bible2', 'httpclick'); |
1043 |
|
$form->setType('bible3', 'httpclick'); |
1044 |
|
$form->setType('bible4', 'httpclick'); |
1045 |
|
} |
1046 |
|
if ($this->f->is_option_preview_pdf_enabled($collectivite_di) === true) { |
1047 |
|
// |
1048 |
|
$form->setType('btn_refresh', 'httpclickbutton'); |
1049 |
|
$form->setType('btn_preview', 'httpclickbutton'); |
1050 |
|
$form->setType('btn_redaction', 'httpclickbutton'); |
1051 |
$form->setType('live_preview', 'pdf'); |
$form->setType('live_preview', 'pdf'); |
1052 |
} |
} |
1053 |
|
|
1054 |
// necessaire pour calcul de date en modification |
// necessaire pour calcul de date en modification |
1055 |
//$form->setType('delai', 'hiddenstatic'); |
//$form->setType('delai', 'hiddenstatic'); |
1056 |
// les administrateurs technique et fonctionnel peuvent |
// les administrateurs technique et fonctionnel peuvent |
1057 |
// modifier tous les champs de date |
// modifier tous les champs de date |
1058 |
// 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 |
1059 |
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") |
1060 |
|| $this->f->isAccredited(array('instruction', 'instruction_modification_dates'), "OR")) |
|| $this->f->isAccredited(array('instruction', 'instruction_modification_dates'), "OR")) |
1061 |
&& $this->getVal("date_finalisation_courrier") != '') { |
&& $this->getVal("date_finalisation_courrier") != '') { |
1062 |
|
// |
1063 |
$form->setType('date_envoi_signature', 'date'); |
$form->setType('date_envoi_signature', 'date'); |
1064 |
$form->setType('date_retour_signature', 'date'); |
$form->setType('date_retour_signature', 'date'); |
1065 |
|
if ($this->is_sent_for_signature() === true |
1066 |
|
&& $this->is_signed() === true) { |
1067 |
|
// |
1068 |
|
$form->setType("date_envoi_signature", "datereadonly"); |
1069 |
|
$form->setType("date_retour_signature", "datereadonly"); |
1070 |
|
} |
1071 |
$form->setType('date_envoi_rar', 'date'); |
$form->setType('date_envoi_rar', 'date'); |
1072 |
$form->setType('date_retour_rar', 'date'); |
$form->setType('date_retour_rar', 'date'); |
1073 |
$form->setType('date_envoi_controle_legalite', 'date'); |
$form->setType('date_envoi_controle_legalite', 'date'); |
1074 |
$form->setType('date_retour_controle_legalite', 'date'); |
$form->setType('date_retour_controle_legalite', 'date'); |
1075 |
$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('live_preview', 'hidden'); |
|
|
$form->setType('signataire_arrete','selecthiddenstatic'); |
|
|
$form->setType('om_final_instruction_utilisateur', 'hiddenstatic'); |
|
|
} |
|
1076 |
} |
} |
1077 |
} |
} |
|
} 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'); |
|
|
$form->setType('btn_refresh', 'hidden'); |
|
|
$form->setType('live_preview', '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'); |
|
|
$form->setType('btn_refresh', 'hidden'); |
|
|
$form->setType('live_preview', '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"); |
|
1078 |
} |
} |
1079 |
|
|
1080 |
// Pour les actions finalize, unfinalize et notifier_commune |
// MODE CONSULTER + SUPPRIMER + SUIVI DES DATES 125 + NOTIFICATION MANUELLE |
1081 |
if($maj == 100 || $maj == 110 || $maj == 210) { |
if ($this->getParameter('maj') == 3 |
1082 |
// |
|| $this->getParameter('maj') == 2 |
1083 |
foreach ($this->champs as $value) { |
|| $this->getParameter('maj') == 125 |
1084 |
// Cache tous les champs |
|| $this->getParameter('maj') == 410) { |
1085 |
$form->setType($value, 'hidden'); |
// |
1086 |
|
$form->setType("date_evenement", "datestatic"); |
1087 |
|
$form->setType("evenement", "selecthiddenstatic"); |
1088 |
|
if ($this->has_an_edition() === true) { |
1089 |
|
$form->setType('lettretype', 'hiddenstatic'); |
1090 |
|
$form->setType("signataire_arrete", "selecthiddenstatic"); |
1091 |
|
if ($this->getVal("om_final_instruction") == 't') { |
1092 |
|
$form->setType('om_final_instruction_utilisateur', 'textareastatic'); |
1093 |
|
} else { |
1094 |
|
$form->setType('om_final_instruction_utilisateur', 'hidden'); |
1095 |
|
} |
1096 |
|
} |
1097 |
|
if ($this->evenement_has_a_commentaire($this->getVal('evenement')) === true ) { |
1098 |
|
$form->setType('commentaire', 'textareastatic'); |
1099 |
|
} |
1100 |
|
} |
1101 |
|
|
1102 |
|
// MODE CONSULTER + SUPPRIMER + NOTIFICATION MANUELLE |
1103 |
|
if ($this->getParameter('maj') == 3 |
1104 |
|
|| $this->getParameter('maj') == 2 |
1105 |
|
|| $this->getParameter('maj') == 410) { |
1106 |
|
// Si il n'y a pas de lettre type (edition) associé à l'événement |
1107 |
|
// les dates de suivi ne sont pas affichée |
1108 |
|
if ($this->has_an_edition() === true) { |
1109 |
|
$form->setType('date_envoi_signature', 'datestatic'); |
1110 |
|
$form->setType('date_retour_signature', 'datestatic'); |
1111 |
|
$form->setType('date_envoi_rar', 'datestatic'); |
1112 |
|
$form->setType('date_retour_rar', 'datestatic'); |
1113 |
|
$form->setType('date_envoi_controle_legalite', 'datestatic'); |
1114 |
|
$form->setType('date_retour_controle_legalite', 'datestatic'); |
1115 |
|
$form->setType('date_finalisation_courrier', 'datestatic'); |
1116 |
|
if ($this->getVal("flag_edition_integrale") == "t") { |
1117 |
|
$form->setType("titre_om_htmletat", "htmlstatic"); |
1118 |
|
$form->setType("corps_om_htmletatex", "htmlstatic"); |
1119 |
|
} else { |
1120 |
|
$form->setType("complement_om_html", "htmlstatic"); |
1121 |
|
$form->setType("complement2_om_html", "htmlstatic"); |
1122 |
|
$form->setType("complement3_om_html", "htmlstatic"); |
1123 |
|
$form->setType("complement4_om_html", "htmlstatic"); |
1124 |
|
} |
1125 |
} |
} |
1126 |
} |
} |
1127 |
|
|
1128 |
|
// MODE SUIVI DES DATES 125 |
1129 |
|
if ($this->getParameter('maj') == 125) { |
1130 |
|
$form->setType("date_evenement", "hiddenstaticdate"); |
1131 |
|
$form->setType('om_final_instruction_utilisateur', 'hiddenstatic'); |
1132 |
|
$form->setType('date_envoi_signature', 'date'); |
1133 |
|
$form->setType('date_retour_signature', 'date'); |
1134 |
|
if ($this->is_sent_for_signature() === true |
1135 |
|
|| $this->is_signed() === true) { |
1136 |
|
// |
1137 |
|
$form->setType("date_envoi_signature", "datereadonly"); |
1138 |
|
$form->setType("date_retour_signature", "datereadonly"); |
1139 |
|
} |
1140 |
|
$form->setType('date_envoi_rar', 'date'); |
1141 |
|
$form->setType('date_retour_rar', 'date'); |
1142 |
|
$form->setType('date_envoi_controle_legalite', 'date'); |
1143 |
|
$form->setType('date_retour_controle_legalite', 'date'); |
1144 |
|
$form->setType('date_finalisation_courrier', 'date'); |
1145 |
|
} |
1146 |
|
|
1147 |
|
if ($maj == 401) { |
1148 |
|
foreach ($this->champs as $champ) { |
1149 |
|
$form->setType($champ, 'hidden'); |
1150 |
|
} |
1151 |
|
$form->setType('preview_edition', 'pdf'); |
1152 |
|
} |
1153 |
|
} |
1154 |
|
|
1155 |
|
function setOnchange(&$form,$maj){ |
1156 |
|
parent::setOnchange($form,$maj); |
1157 |
|
|
1158 |
|
// MODE AJOUTER |
1159 |
|
if ($this->getParameter('maj') == 0) { |
1160 |
|
$form->setOnchange( |
1161 |
|
"evenement", |
1162 |
|
"manage_instruction_evenement_lettretype(this.value, '".addslashes($this->getParameter('idxformulaire'))."'); |
1163 |
|
manage_instruction_evenement_commentaire(this.value, '".addslashes($this->getParameter('idxformulaire'))."');" |
1164 |
|
); |
1165 |
|
} |
1166 |
|
} |
1167 |
|
|
1168 |
|
function evenement_has_an_edition($evenement_id) { |
1169 |
|
$evenement = $this->get_inst_evenement($evenement_id); |
1170 |
|
$lettretype = $evenement->getVal('lettretype'); |
1171 |
|
if ($lettretype !== '' && $lettretype !== null) { |
1172 |
|
return true; |
1173 |
|
} |
1174 |
|
return false; |
1175 |
|
} |
1176 |
|
|
1177 |
|
function view_evenement_has_an_edition_json() { |
1178 |
|
$json_return = array( |
1179 |
|
"lettretype" => $this->evenement_has_an_edition($this->f->get_submitted_get_value('evenement_id')), |
1180 |
|
"option_redaction_libre_enabled" => $this->is_option_redaction_libre_enabled(), |
1181 |
|
); |
1182 |
|
echo json_encode($json_return); |
1183 |
|
} |
1184 |
|
|
1185 |
|
function evenement_has_a_commentaire($evenement_id) { |
1186 |
|
$evenement = $this->get_inst_evenement($evenement_id); |
1187 |
|
return $this->get_boolean_from_pgsql_value($evenement->getVal('commentaire')); |
1188 |
|
} |
1189 |
|
|
1190 |
|
function view_evenement_has_a_commentaire_json() { |
1191 |
|
$json_return = array( |
1192 |
|
"commentaire" => $this->evenement_has_a_commentaire($this->f->get_submitted_get_value('evenement_id')) |
1193 |
|
); |
1194 |
|
echo json_encode($json_return); |
1195 |
} |
} |
1196 |
|
|
1197 |
function setSelect(&$form, $maj, &$db = null, $debug = null) { |
/** |
1198 |
|
* |
1199 |
|
* @return string |
1200 |
|
*/ |
1201 |
|
function get_var_sql_forminc__sql_signataire_arrete() { |
1202 |
|
return "SELECT |
1203 |
|
signataire_arrete.signataire_arrete, |
1204 |
|
CONCAT(signataire_arrete.prenom, ' ', signataire_arrete.nom) |
1205 |
|
FROM ".DB_PREFIXE."signataire_arrete |
1206 |
|
WHERE ((signataire_arrete.om_validite_debut IS NULL AND (signataire_arrete.om_validite_fin IS NULL OR signataire_arrete.om_validite_fin > CURRENT_DATE)) OR (signataire_arrete.om_validite_debut <= CURRENT_DATE AND (signataire_arrete.om_validite_fin IS NULL OR signataire_arrete.om_validite_fin > CURRENT_DATE))) |
1207 |
|
ORDER BY signataire_arrete.prenom, signataire_arrete.nom"; |
1208 |
|
} |
1209 |
|
|
1210 |
|
/** |
1211 |
|
* |
1212 |
|
* @return string |
1213 |
|
*/ |
1214 |
|
function get_var_sql_forminc__sql_signataire_arrete_by_id() { |
1215 |
|
return "SELECT |
1216 |
|
signataire_arrete.signataire_arrete, |
1217 |
|
CONCAT(signataire_arrete.prenom, ' ', signataire_arrete.nom) |
1218 |
|
FROM ".DB_PREFIXE."signataire_arrete |
1219 |
|
WHERE signataire_arrete.signataire_arrete = <idx>"; |
1220 |
|
} |
1221 |
|
|
1222 |
|
/** |
1223 |
|
* |
1224 |
|
* @return string |
1225 |
|
*/ |
1226 |
|
function get_var_sql_forminc__sql_signataire_arrete_by_di() { |
1227 |
|
return "SELECT |
1228 |
|
signataire_arrete.signataire_arrete, |
1229 |
|
CONCAT(signataire_arrete.prenom, ' ', signataire_arrete.nom) |
1230 |
|
FROM ".DB_PREFIXE."signataire_arrete |
1231 |
|
LEFT JOIN ".DB_PREFIXE."om_collectivite ON signataire_arrete.om_collectivite = om_collectivite.om_collectivite |
1232 |
|
WHERE ((signataire_arrete.om_validite_debut IS NULL AND (signataire_arrete.om_validite_fin IS NULL OR signataire_arrete.om_validite_fin > CURRENT_DATE)) OR (signataire_arrete.om_validite_debut <= CURRENT_DATE AND (signataire_arrete.om_validite_fin IS NULL OR signataire_arrete.om_validite_fin > CURRENT_DATE))) |
1233 |
|
AND (om_collectivite.niveau = '2' OR signataire_arrete.om_collectivite = <collectivite_di>) |
1234 |
|
ORDER BY signataire_arrete.prenom, signataire_arrete.nom"; |
1235 |
|
} |
1236 |
|
|
1237 |
|
/** |
1238 |
|
* |
1239 |
|
* @return string |
1240 |
|
*/ |
1241 |
|
function get_var_sql_forminc__sql_signataire_arrete_defaut() { |
1242 |
|
return "SELECT |
1243 |
|
signataire_arrete.signataire_arrete, |
1244 |
|
CONCAT(signataire_arrete.prenom, ' ', signataire_arrete.nom) |
1245 |
|
FROM ".DB_PREFIXE."signataire_arrete |
1246 |
|
WHERE ((signataire_arrete.om_validite_debut IS NULL AND (signataire_arrete.om_validite_fin IS NULL OR signataire_arrete.om_validite_fin > CURRENT_DATE)) OR (signataire_arrete.om_validite_debut <= CURRENT_DATE AND (signataire_arrete.om_validite_fin IS NULL OR signataire_arrete.om_validite_fin > CURRENT_DATE))) AND signataire_arrete.defaut IS TRUE |
1247 |
|
ORDER BY signataire_arrete.prenom, signataire_arrete.nom"; |
1248 |
|
} |
1249 |
|
|
1250 |
|
/** |
1251 |
|
* |
1252 |
|
* @return string |
1253 |
|
*/ |
1254 |
|
function get_var_sql_forminc__sql_signataire_arrete_defaut_by_di() { |
1255 |
|
return "SELECT |
1256 |
|
signataire_arrete.signataire_arrete, |
1257 |
|
CONCAT(signataire_arrete.prenom, ' ', signataire_arrete.nom) |
1258 |
|
FROM ".DB_PREFIXE."signataire_arrete |
1259 |
|
LEFT JOIN ".DB_PREFIXE."om_collectivite ON signataire_arrete.om_collectivite = om_collectivite.om_collectivite |
1260 |
|
WHERE ((signataire_arrete.om_validite_debut IS NULL AND (signataire_arrete.om_validite_fin IS NULL OR signataire_arrete.om_validite_fin > CURRENT_DATE)) OR (signataire_arrete.om_validite_debut <= CURRENT_DATE AND (signataire_arrete.om_validite_fin IS NULL OR signataire_arrete.om_validite_fin > CURRENT_DATE))) AND signataire_arrete.defaut IS TRUE |
1261 |
|
AND (om_collectivite.niveau = '2' OR signataire_arrete.om_collectivite = <collectivite_di>) |
1262 |
|
ORDER BY signataire_arrete.prenom, signataire_arrete.nom"; |
1263 |
|
} |
1264 |
|
|
1265 |
|
/** |
1266 |
|
* SETTER_FORM - setSelect. |
1267 |
|
* |
1268 |
|
* @return void |
1269 |
|
*/ |
1270 |
|
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
1271 |
|
//parent::setSelect($form, $maj); |
1272 |
/** |
/** |
1273 |
* 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 |
1274 |
* dossier est mauvaise pour les performances, car la requête qui |
* dossier est mauvaise pour les performances, car la requête qui |
1276 |
* 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 |
1277 |
* select |
* select |
1278 |
*/ |
*/ |
|
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"); |
|
|
|
|
1279 |
//// action |
//// action |
1280 |
//$this->init_select($form, $db, $maj, $debug, "action", |
//$this->init_select($form, $this->f->db, $maj, null, "action", |
1281 |
// $sql_action, $sql_action_by_id, false); |
// $sql_action, $sql_action_by_id, false); |
1282 |
|
|
1283 |
//// avis_decision |
//// avis_decision |
1284 |
//$this->init_select($form, $db, $maj, $debug, "avis_decision", |
//$this->init_select($form, $this->f->db, $maj, null, "avis_decision", |
1285 |
// $sql_avis_decision, $sql_avis_decision_by_id, false); |
// $sql_avis_decision, $sql_avis_decision_by_id, false); |
1286 |
|
|
1287 |
//// dossier |
//// dossier |
1288 |
//$this->init_select($form, $db, $maj, $debug, "dossier", |
//$this->init_select($form, $this->f->db, $maj, null, "dossier", |
1289 |
// $sql_dossier, $sql_dossier_by_id, false); |
// $sql_dossier, $sql_dossier_by_id, false); |
1290 |
|
|
1291 |
//// etat |
//// etat |
1292 |
//$this->init_select($form, $db, $maj, $debug, "etat", |
//$this->init_select($form, $this->f->db, $maj, null, "etat", |
1293 |
// $sql_etat, $sql_etat_by_id, false); |
// $sql_etat, $sql_etat_by_id, false); |
1294 |
|
|
1295 |
//// evenement |
//// evenement |
1296 |
//$this->init_select($form, $db, $maj, $debug, "evenement", |
//$this->init_select($form, $this->f->db, $maj, null, "evenement", |
1297 |
// $sql_evenement, $sql_evenement_by_id, false); |
// $sql_evenement, $sql_evenement_by_id, false); |
1298 |
|
|
1299 |
// signataire_arrete |
// signataire_arrete |
1309 |
|| $this->getParameter("retourformulaire") == "dossier_contentieux_mes_recours" |
|| $this->getParameter("retourformulaire") == "dossier_contentieux_mes_recours" |
1310 |
|| $this->getParameter("retourformulaire") == "dossier_contentieux_tous_recours") { |
|| $this->getParameter("retourformulaire") == "dossier_contentieux_tous_recours") { |
1311 |
// 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 |
1312 |
require_once "../obj/dossier_instruction.class.php"; |
$di = $this->f->get_inst__om_dbform(array( |
1313 |
$di = new dossier_instruction($this->getParameter('idxformulaire'), $db, $debug); |
"obj" => "dossier_instruction", |
1314 |
$sql_signataire_arrete_by_di = str_replace('<collectivite_di>', $di->getVal("om_collectivite"), $sql_signataire_arrete_by_di); |
"idx" => $this->getParameter('idxformulaire'), |
1315 |
$this->init_select($form, $db, $maj, $debug, "signataire_arrete", |
)); |
1316 |
$sql_signataire_arrete_by_di, $sql_signataire_arrete_by_id, true); |
$sql_signataire_arrete_by_di = str_replace( |
1317 |
|
'<collectivite_di>', |
1318 |
|
$di->getVal("om_collectivite"), |
1319 |
|
$this->get_var_sql_forminc__sql("signataire_arrete_by_di") |
1320 |
|
); |
1321 |
|
$this->init_select( |
1322 |
|
$form, |
1323 |
|
$this->f->db, |
1324 |
|
$maj, |
1325 |
|
null, |
1326 |
|
"signataire_arrete", |
1327 |
|
$sql_signataire_arrete_by_di, |
1328 |
|
$this->get_var_sql_forminc__sql("signataire_arrete_by_id"), |
1329 |
|
true |
1330 |
|
); |
1331 |
} else { |
} else { |
1332 |
$this->init_select($form, $db, $maj, $debug, "signataire_arrete", |
$this->init_select( |
1333 |
$sql_signataire_arrete, $sql_signataire_arrete_by_id, true); |
$form, |
1334 |
|
$this->f->db, |
1335 |
|
$maj, |
1336 |
|
null, |
1337 |
|
"signataire_arrete", |
1338 |
|
$this->get_var_sql_forminc__sql("signataire_arrete"), |
1339 |
|
$this->get_var_sql_forminc__sql("signataire_arrete_by_id"), |
1340 |
|
true |
1341 |
|
); |
1342 |
} |
} |
1343 |
|
|
1344 |
/** |
/** |
1363 |
INNER JOIN ".DB_PREFIXE."transition |
INNER JOIN ".DB_PREFIXE."transition |
1364 |
ON evenement.evenement = transition.evenement |
ON evenement.evenement = transition.evenement |
1365 |
AND dossier.etat=transition.etat |
AND dossier.etat=transition.etat |
1366 |
WHERE dossier.dossier='".$this->idxformulaire."' "; |
WHERE dossier.dossier='".$this->getParameter("idxformulaire")."' "; |
1367 |
|
|
1368 |
// Si changement de décision par instructeur commune |
// Si changement de décision par instructeur commune |
1369 |
if($this->f->isUserInstructeur() === true |
if($this->f->isUserInstructeur() === true |
1370 |
&& $this->getDivisionFromDossier($this->idxformulaire) != $_SESSION["division"] |
&& $this->getDivisionFromDossier($this->getParameter("idxformulaire")) != $_SESSION["division"] |
1371 |
&& $this->isInstrCanChangeDecision($this->idxformulaire) === true) { |
&& $this->isInstrCanChangeDecision($this->getParameter("idxformulaire")) === true) { |
1372 |
$sql .= "AND evenement.type IN ('arrete', 'changement_decision') "; |
$sql .= "AND evenement.type IN ('arrete', 'changement_decision') "; |
1373 |
} |
} |
1374 |
$sql .= "ORDER BY evenement.libelle, evenement.action"; |
$sql .= "ORDER BY evenement.libelle, evenement.action"; |
1375 |
$res = $db->query($sql); |
$res = $this->f->db->query($sql); |
1376 |
$this->addToLog("setSelect(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog("setSelect(): db->query(\"".$sql."\");", VERBOSE_MODE); |
1377 |
if (database::isError($res)) { |
if (database::isError($res)) { |
1378 |
die($res->getMessage()); |
die($res->getMessage()); |
1387 |
$contenu[1][] = $row[1]; |
$contenu[1][] = $row[1]; |
1388 |
} |
} |
1389 |
$form->setSelect("evenement", $contenu); |
$form->setSelect("evenement", $contenu); |
1390 |
|
|
1391 |
} else { |
} else { |
1392 |
$sql = "SELECT |
$sql = "SELECT |
1393 |
evenement.libelle as lib |
evenement.libelle as lib |
1394 |
FROM ".DB_PREFIXE."evenement |
FROM ".DB_PREFIXE."evenement |
1395 |
WHERE evenement.evenement=".$this->getVal("evenement").""; |
WHERE evenement.evenement=".$this->getVal("evenement").""; |
1396 |
$res = $db->getone($sql); |
$res = $this->f->db->getone($sql); |
1397 |
$this->addToLog("setSelect(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog("setSelect(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
1398 |
if (database::isError($res)) { |
if (database::isError($res)) { |
1399 |
die($res->getMessage()); |
die($res->getMessage()); |
1428 |
if ($maj == 1) { |
if ($maj == 1) { |
1429 |
$base64 = $this->init_pdf_temp(); |
$base64 = $this->init_pdf_temp(); |
1430 |
$form->setSelect('live_preview', array('base64'=>$base64)); |
$form->setSelect('live_preview', array('base64'=>$base64)); |
1431 |
$form->setSelect("btn_refresh", array(_('Actualiser'))); |
$form->setSelect("btn_refresh", array(_('Prévisualiser'))); |
1432 |
|
$form->setSelect("btn_preview", array(_('Prévisualiser >>'))); |
1433 |
|
$form->setSelect("btn_redaction", array(_('<< Rédiger'))); |
1434 |
|
} |
1435 |
|
|
1436 |
|
// Selection du type de rédaction à l'ajout |
1437 |
|
$content = array( |
1438 |
|
0 => array('f', 't', ), |
1439 |
|
1 => array(_('Rédaction par compléments'), _('Rédaction libre'), ), |
1440 |
|
); |
1441 |
|
$form->setSelect('flag_edition_integrale', $content); |
1442 |
|
|
1443 |
|
$contenu = array(); |
1444 |
|
foreach(array('waiting', 'in_progress', 'canceled', 'expired', 'finished') as $value) { |
1445 |
|
$contenu[0][] = $value; |
1446 |
|
$contenu[1][] = $this->get_trad_for_statut($value); |
1447 |
|
} |
1448 |
|
$form->setSelect('statut_signature', $contenu); |
1449 |
|
|
1450 |
|
|
1451 |
|
if ($maj == 401) { |
1452 |
|
$file = $this->f->storage->get($this->getVal('om_fichier_instruction')); |
1453 |
|
$base64 = base64_encode($file['file_content']); |
1454 |
|
$form->setSelect('preview_edition', array('base64' => $base64)); |
1455 |
} |
} |
1456 |
} |
} |
1457 |
|
|
1458 |
function cleSecondaire($id, &$db = null, $val = array(), $DEBUG = null) { |
function cleSecondaire($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
1459 |
// |
// |
1460 |
parent::cleSecondaire($id, $db, $val, $DEBUG); |
// Vérifie uniquementla cle secondaire : demande |
1461 |
|
$this->rechercheTable($this->f->db, "demande", "instruction_recepisse", $id); |
1462 |
|
|
1463 |
$id = $this->getVal($this->clePrimaire); |
$id = $this->getVal($this->clePrimaire); |
1464 |
|
|
1470 |
LEFT JOIN ".DB_PREFIXE."demande |
LEFT JOIN ".DB_PREFIXE."demande |
1471 |
ON demande.demande_type = demande_type.demande_type |
ON demande.demande_type = demande_type.demande_type |
1472 |
WHERE demande.instruction_recepisse = ".$id; |
WHERE demande.instruction_recepisse = ".$id; |
1473 |
$res = $this->db->getOne($sql); |
$res = $this->f->db->getOne($sql); |
1474 |
$this->addToLog("cleSecondaire(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog("cleSecondaire(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
1475 |
if (database::isError($res)) { |
if (database::isError($res)) { |
1476 |
die($res->getMessage()); |
die($res->getMessage()); |
1486 |
$sql = "SELECT demande |
$sql = "SELECT demande |
1487 |
FROM ".DB_PREFIXE."demande |
FROM ".DB_PREFIXE."demande |
1488 |
WHERE instruction_recepisse = ".$id; |
WHERE instruction_recepisse = ".$id; |
1489 |
$res = $this->db->getOne($sql); |
$res = $this->f->db->getOne($sql); |
1490 |
$this->addToLog("cleSecondaire(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog("cleSecondaire(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
1491 |
if (database::isError($res)) { |
if (database::isError($res)) { |
1492 |
die($res->getMessage()); |
die($res->getMessage()); |
1494 |
|
|
1495 |
//Si c'est un événement d'instruction lié à une demande |
//Si c'est un événement d'instruction lié à une demande |
1496 |
if ($res != null || $res != ""){ |
if ($res != null || $res != ""){ |
1497 |
|
$demande = $this->f->get_inst__om_dbform(array( |
1498 |
require_once "../obj/demande.class.php"; |
"obj" => "demande", |
1499 |
$demande = new demande($res, $this->db, DEBUG); |
"idx" => $res, |
1500 |
|
)); |
1501 |
|
|
1502 |
//On met à jour la demande en supprimant la liaison vers |
//On met à jour la demande en supprimant la liaison vers |
1503 |
//l'événement d'instruction |
//l'événement d'instruction |
1508 |
} |
} |
1509 |
$valF['date_demande']=$demande->dateDBToForm($valF['date_demande']); |
$valF['date_demande']=$demande->dateDBToForm($valF['date_demande']); |
1510 |
$valF['instruction_recepisse']=NULL; |
$valF['instruction_recepisse']=NULL; |
1511 |
$ret = $demande->modifier($valF, $this->db, DEBUG); |
$ret = $demande->modifier($valF); |
1512 |
} |
} |
1513 |
|
|
1514 |
/** |
/** |
1521 |
// concerne le dossier en cours |
// concerne le dossier en cours |
1522 |
$sql = "SELECT max(instruction) |
$sql = "SELECT max(instruction) |
1523 |
FROM ".DB_PREFIXE."instruction |
FROM ".DB_PREFIXE."instruction |
1524 |
WHERE dossier ='".$this->idxformulaire."'"; |
WHERE dossier ='".$this->getParameter("idxformulaire")."'"; |
1525 |
$dernierevenement = $db->getOne($sql); |
$dernierevenement = $this->f->db->getOne($sql); |
1526 |
$this->addToLog("setSelect(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog("setSelect(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
1527 |
if (database::isError($dernierevenement)) { |
if (database::isError($dernierevenement)) { |
1528 |
die($dernierevenement->getMessage()); |
die($dernierevenement->getMessage()); |
1572 |
return true; |
return true; |
1573 |
} |
} |
1574 |
|
|
1575 |
/*Met des valeurs par défaut dans certains des sous-formulaire*/ |
/** |
1576 |
function setValsousformulaire(&$form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire, &$db = null, $DEBUG = null) { |
* SETTER_FORM - setValsousformulaire (setVal). |
1577 |
|
* |
1578 |
|
* @return void |
1579 |
|
*/ |
1580 |
|
function setValsousformulaire(&$form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire, &$dnu1 = null, $dnu2 = null) { |
1581 |
|
// parent::setValsousformulaire($form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire); |
1582 |
|
// |
1583 |
|
$this->retourformulaire = $retourformulaire; |
1584 |
// |
// |
|
$this->retourformulaire=$retourformulaire; |
|
|
$this->idxformulaire=$idxformulaire; |
|
|
// Ajout |
|
1585 |
if ($maj == 0) { |
if ($maj == 0) { |
1586 |
$form->setVal("destinataire", $idxformulaire); |
$form->setVal("destinataire", $this->getParameter("idxformulaire")); |
1587 |
$form->setVal("dossier", $idxformulaire); |
$form->setVal("dossier", $this->getParameter("idxformulaire")); |
1588 |
} |
} |
1589 |
// |
// |
1590 |
$this->set_form_default_values($form, $maj, $validation); |
$this->set_form_default_values($form, $maj, $validation); |
1591 |
} |
} |
1592 |
|
|
1593 |
/** |
/** |
1594 |
* Permet de pré-remplir les valeurs des formulaires. |
* SETTER_FORM - set_form_default_values (setVal). |
1595 |
* |
* |
1596 |
* @param [object] $form formulaire |
* @return void |
|
* @param [integer] $maj mode |
|
|
* @param [integer] $validation validation |
|
1597 |
*/ |
*/ |
1598 |
function set_form_default_values(&$form, $maj, $validation) { |
function set_form_default_values(&$form, $maj, $validation) { |
1599 |
|
// |
|
// Ajout |
|
1600 |
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"); |
|
1601 |
// si contexte DI |
// si contexte DI |
1602 |
if ($this->getParameter("retourformulaire") == "dossier" |
if ($this->getParameter("retourformulaire") == "dossier" |
1603 |
|| $this->getParameter("retourformulaire") == "dossier_instruction" |
|| $this->getParameter("retourformulaire") == "dossier_instruction" |
1610 |
|| $this->getParameter("retourformulaire") == "dossier_contentieux_mes_recours" |
|| $this->getParameter("retourformulaire") == "dossier_contentieux_mes_recours" |
1611 |
|| $this->getParameter("retourformulaire") == "dossier_contentieux_tous_recours") { |
|| $this->getParameter("retourformulaire") == "dossier_contentieux_tous_recours") { |
1612 |
// 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 |
1613 |
require_once "../obj/dossier_instruction.class.php"; |
$di = $this->f->get_inst__om_dbform(array( |
1614 |
$di = new dossier_instruction($this->getParameter('idxformulaire'), $db, DEBUG); |
"obj" => "dossier_instruction", |
1615 |
$sql = str_replace('<collectivite_di>', $di->getVal("om_collectivite"), $sql_signataire_arrete_defaut_by_di); |
"idx" => $this->getParameter("idxformulaire"), |
1616 |
|
)); |
1617 |
|
$sql = str_replace( |
1618 |
|
"<collectivite_di>", |
1619 |
|
$di->getVal("om_collectivite"), |
1620 |
|
$this->get_var_sql_forminc__sql("signataire_arrete_defaut_by_di") |
1621 |
|
); |
1622 |
} else { |
} else { |
1623 |
$sql = $sql_signataire_arrete_defaut; |
$sql = $this->get_var_sql_forminc__sql("signataire_arrete_defaut"); |
1624 |
} |
} |
|
// Date du jour |
|
|
$form->setVal("date_evenement", date('Y-m-d')); |
|
|
|
|
|
// Exécution de la requête |
|
1625 |
$res = $this->f->db->query($sql); |
$res = $this->f->db->query($sql); |
1626 |
$this->f->addToLog("setVal(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__."(): db->query(\"".$sql."\")", VERBOSE_MODE); |
1627 |
if ( database::isError($res)){ |
$this->f->isDatabaseError($res); |
|
die(); |
|
|
} |
|
|
|
|
1628 |
$row = $res->fetchrow(DB_FETCHMODE_ASSOC); |
$row = $res->fetchrow(DB_FETCHMODE_ASSOC); |
1629 |
|
if (isset($row["signataire_arrete"]) |
1630 |
if (isset($row['signataire_arrete']) && is_numeric($row['signataire_arrete'])){ |
&& is_numeric($row["signataire_arrete"])) { |
1631 |
$form->setVal("signataire_arrete",$row['signataire_arrete']); |
// |
1632 |
|
$form->setVal("signataire_arrete", $row["signataire_arrete"]); |
1633 |
} |
} |
1634 |
|
// Date du jour |
1635 |
|
$form->setVal("date_evenement", date("Y-m-d")); |
1636 |
} |
} |
1637 |
|
// |
|
// Ajout et modification |
|
1638 |
if ($maj == 0 || $maj == 1 || $maj == 125) { |
if ($maj == 0 || $maj == 1 || $maj == 125) { |
1639 |
$form->setVal("bible_auto","bible_auto()"); |
$form->setVal("bible_auto", "bible_auto()"); |
1640 |
$form->setVal("bible","bible(1)"); |
$form->setVal("bible", "bible(1)"); |
1641 |
$form->setVal("bible2","bible(2)"); |
$form->setVal("bible2", "bible(2)"); |
1642 |
$form->setVal("bible3","bible(3)"); |
$form->setVal("bible3", "bible(3)"); |
1643 |
$form->setVal("bible4","bible(4)"); |
$form->setVal("bible4", "bible(4)"); |
1644 |
} |
} |
1645 |
|
// |
|
// Récupère la collectivité du dossier d'instruction |
|
1646 |
$collectivite_di = $this->get_dossier_instruction_om_collectivite(); |
$collectivite_di = $this->get_dossier_instruction_om_collectivite(); |
1647 |
|
if ($maj == 1 |
1648 |
// Modification |
&& $this->f->is_option_preview_pdf_enabled($collectivite_di) === true |
|
if ($maj == 1 && $this->f->is_option_preview_pdf_enabled($collectivite_di) === true |
|
1649 |
&& $this->has_an_edition() === true) { |
&& $this->has_an_edition() === true) { |
1650 |
$form->setVal("live_preview",$this->getVal($this->clePrimaire)); |
// |
1651 |
$form->setVal("btn_refresh","reload_pdf_viewer()"); |
$form->setVal("live_preview", $this->getVal($this->clePrimaire)); |
1652 |
|
$form->setVal("btn_refresh", "reload_pdf_viewer()"); |
1653 |
|
$form->setVal("btn_preview", "show_instr_preview()"); |
1654 |
|
$form->setVal("btn_redaction", "show_instr_redaction()"); |
1655 |
} |
} |
|
} |
|
1656 |
|
|
1657 |
|
if ($maj == 3 |
1658 |
|
&& $this->can_display_notification() |
1659 |
|
) { |
1660 |
|
$form->setVal("suivi_notification", $this->get_json_suivi_notification()); |
1661 |
|
} |
1662 |
|
} |
1663 |
|
|
1664 |
function setLayout(&$form, $maj){ |
function setLayout(&$form, $maj){ |
1665 |
if ( $maj < 2 OR $maj == 3 OR $maj == 125 ) { |
$form->setBloc('evenement','D',"","sousform-instruction-action-".$maj); |
|
/*Champ sur lequel s'ouvre le bloc 1 */ |
|
|
$form->setBloc('evenement','D',"","col_12"); |
|
1666 |
|
|
1667 |
$form->setFieldset('evenement','D',_('Evenement')); |
$form->setFieldset('evenement','D',_('Evenement')); |
1668 |
$form->setFieldset('om_final_instruction_utilisateur','F',''); |
$form->setFieldset('om_final_instruction_utilisateur','F',''); |
1669 |
|
|
1670 |
$form->setBloc('om_final_instruction_utilisateur','F'); |
$form->setBloc('om_final_instruction_utilisateur','F'); |
1671 |
|
|
1672 |
$form->setBloc('date_finalisation_courrier','D',"","col_12"); |
$form->setBloc('date_finalisation_courrier','D',"",""); |
1673 |
|
|
1674 |
$form->setFieldset('date_finalisation_courrier','D',_('Dates')); |
$form->setFieldset('date_finalisation_courrier','D',_('Dates')); |
1675 |
$form->setBloc('date_finalisation_courrier','D',"","col_6"); |
$form->setBloc('date_finalisation_courrier','D',"","col_6"); |
1676 |
$form->setBloc('date_envoi_controle_legalite','F'); |
$form->setBloc('date_envoi_controle_legalite','F'); |
1677 |
|
|
1678 |
$form->setBloc('signataire_arrete','D',"","col_6"); |
$form->setBloc('date_retour_signature','D',"","col_6"); |
1679 |
$form->setBloc('date_retour_controle_legalite','F'); |
$form->setBloc('date_retour_controle_legalite','F'); |
1680 |
$form->setFieldset('date_retour_controle_legalite','F',''); |
$form->setFieldset('date_retour_controle_legalite','F',''); |
1681 |
|
|
1682 |
$form->setBloc('date_retour_controle_legalite','F'); |
$form->setBloc('date_retour_controle_legalite','F'); |
1683 |
|
|
1684 |
if ($maj == 1) { |
$form->setBloc('statut_signature','D'); |
1685 |
// Récupère la collectivité du dossier d'instruction |
$form->setFieldset('statut_signature','D','Suivi Parapheur'); |
1686 |
$collectivite_di = $this->get_dossier_instruction_om_collectivite(); |
$form->setBloc('commentaire_signature','F'); |
1687 |
|
$form->setBloc('historique_signature','D'); |
1688 |
|
$form->setFieldset('historique_signature', 'DF', __("Historique"), "collapsible, startClosed"); |
1689 |
|
$form->setBloc('historique_signature','F'); |
1690 |
|
$form->setFieldset('historique_signature','F'); |
1691 |
|
|
1692 |
|
$form->setFieldset('suivi_notification', 'D', __("Suivi notification"), "collapsible"); |
1693 |
|
$form->setFieldset('suivi_notification','F'); |
1694 |
|
|
1695 |
|
if ($maj == 1) { |
1696 |
|
// Récupère la collectivité du dossier d'instruction |
1697 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite(); |
1698 |
|
|
1699 |
|
// |
1700 |
|
if ($this->f->is_option_preview_pdf_enabled($collectivite_di) === true |
1701 |
|
&& $this->has_an_edition() === true) { |
1702 |
// |
// |
1703 |
if ($this->f->is_option_preview_pdf_enabled($collectivite_di) === true |
$form->setBloc('complement_om_html','D',"","container_instr_edition"); |
1704 |
&& $this->has_an_edition() === true) { |
$form->setBloc('complement_om_html','D',"","hidelabel box_instr_edition redaction_instr_edition"); |
1705 |
$form->setBloc('complement_om_html','D',"","col_12 container_preview_pdf"); |
$form->setBloc('complement_om_html','D',"","box_instr_edition_main"); |
1706 |
$form->setBloc('complement_om_html','D',"","col_6 hidelabel"); |
$form->setFieldset('complement_om_html','D',_('Complement')); |
1707 |
$form->setFieldset('complement_om_html','D',_('Complement')); |
$form->setFieldset('bible','F',''); |
1708 |
$form->setFieldset('bible','F',''); |
$form->setFieldset('complement2_om_html','D',_('Complement 2')); |
1709 |
$form->setFieldset('complement2_om_html','D',_('Complement 2')); |
$form->setFieldset('bible2','F',''); |
1710 |
$form->setFieldset('bible2','F',''); |
$form->setFieldset('complement3_om_html','D',_('Complement 3')); |
1711 |
$form->setFieldset('complement3_om_html','D',_('Complement 3')); |
$form->setFieldset('bible3','F',''); |
1712 |
$form->setFieldset('bible3','F',''); |
$form->setFieldset('complement4_om_html','D',_('Complement 4')); |
1713 |
$form->setFieldset('complement4_om_html','D',_('Complement 4')); |
$form->setFieldset('bible4','F',''); |
1714 |
$form->setFieldset('bible4','F',''); |
$form->setFieldset('titre_om_htmletat','DF',_('Titre'), 'startClosed'); |
1715 |
$form->setBloc('bible4','F'); |
$form->setFieldset('corps_om_htmletatex','DF',_('Corps')); |
1716 |
$form->setBloc('btn_refresh','D',"","col_6 hidelabel"); |
$form->setBloc('corps_om_htmletatex','F'); |
1717 |
$form->setFieldset('btn_refresh','D',_('Prévisualisation')); |
$form->setBloc('btn_preview','DF',"","box_instr_edition_btn"); |
1718 |
$form->setFieldset('live_preview','F'); |
$form->setBloc('btn_preview','F'); |
1719 |
$form->setBloc('live_preview','F'); |
$form->setBloc('btn_redaction','D', '',"hidelabel box_instr_edition preview_instr_edition"); |
1720 |
$form->setBloc('live_preview','F'); |
$form->setBloc('btn_redaction','DF',"","box_instr_edition_btn"); |
1721 |
} else { |
$form->setFieldset('btn_refresh','D',_('Prévisualisation'), "box_instr_edition_main"); |
1722 |
$form->setBloc('complement_om_html','D',"","col_12 hidelabel"); |
$form->setFieldset('live_preview','F'); |
1723 |
$form->setFieldset('complement_om_html','D',_('Complement')); |
$form->setBloc('live_preview','F'); |
1724 |
$form->setFieldset('bible','F',''); |
$form->setBloc('live_preview','F'); |
|
$form->setFieldset('complement2_om_html','D',_('Complement 2')); |
|
|
$form->setFieldset('bible2','F',''); |
|
|
$form->setFieldset('complement3_om_html','D',_('Complement 3')); |
|
|
$form->setFieldset('bible3','F',''); |
|
|
$form->setFieldset('complement4_om_html','D',_('Complement 4')); |
|
|
$form->setFieldset('bible4','F',''); |
|
|
$form->setBloc('bible4','F'); |
|
|
} |
|
1725 |
} else { |
} else { |
1726 |
$form->setBloc('complement_om_html','D',"","col_12 hidelabel"); |
$form->setBloc('complement_om_html','D',"","hidelabel"); |
1727 |
$form->setFieldset('complement_om_html','D',_('Complement')); |
$form->setFieldset('complement_om_html','D',_('Complement')); |
1728 |
$form->setFieldset('bible','F',''); |
$form->setFieldset('bible','F',''); |
1729 |
$form->setFieldset('complement2_om_html','D',_('Complement 2')); |
$form->setFieldset('complement2_om_html','D',_('Complement 2')); |
1732 |
$form->setFieldset('bible3','F',''); |
$form->setFieldset('bible3','F',''); |
1733 |
$form->setFieldset('complement4_om_html','D',_('Complement 4')); |
$form->setFieldset('complement4_om_html','D',_('Complement 4')); |
1734 |
$form->setFieldset('bible4','F',''); |
$form->setFieldset('bible4','F',''); |
1735 |
$form->setBloc('bible4','F'); |
$form->setFieldset('titre_om_htmletat','DF',_('Titre'), 'startClosed'); |
1736 |
|
$form->setFieldset('corps_om_htmletatex','DF',_('Corps')); |
1737 |
|
$form->setBloc('corps_om_htmletatex','F'); |
1738 |
} |
} |
1739 |
|
} else { |
1740 |
|
$form->setBloc('complement_om_html','D',"","hidelabel"); |
1741 |
|
$form->setFieldset('complement_om_html','D',_('Complement')); |
1742 |
|
$form->setFieldset('bible','F',''); |
1743 |
|
$form->setFieldset('complement2_om_html','D',_('Complement 2')); |
1744 |
|
$form->setFieldset('bible2','F',''); |
1745 |
|
$form->setFieldset('complement3_om_html','D',_('Complement 3')); |
1746 |
|
$form->setFieldset('bible3','F',''); |
1747 |
|
$form->setFieldset('complement4_om_html','D',_('Complement 4')); |
1748 |
|
$form->setFieldset('bible4','F',''); |
1749 |
|
$form->setFieldset('titre_om_htmletat','DF',_('Titre'), 'startClosed'); |
1750 |
|
$form->setFieldset('corps_om_htmletatex','DF',_('Corps')); |
1751 |
|
$form->setBloc('corps_om_htmletatex','F'); |
1752 |
} |
} |
1753 |
} |
} |
1754 |
|
|
1762 |
$form->setLib('bible3', ""); |
$form->setLib('bible3', ""); |
1763 |
$form->setLib('bible4', ""); |
$form->setLib('bible4', ""); |
1764 |
$form->setLib('btn_refresh', ""); |
$form->setLib('btn_refresh', ""); |
1765 |
|
$form->setLib('btn_preview', ""); |
1766 |
|
$form->setLib('btn_redaction', ""); |
1767 |
$form->setLib('live_preview', ""); |
$form->setLib('live_preview', ""); |
1768 |
$form->setLib('om_final_instruction_utilisateur', _("finalise par")); |
$form->setLib('om_final_instruction_utilisateur', _("finalise par")); |
1769 |
|
$form->setLib('date_envoi_rar', __("date_envoi_ar")); |
1770 |
|
$form->setLib('date_retour_rar', __("date_notification")); |
1771 |
|
$form->setLib('statut_signature', __("statut")); |
1772 |
|
$form->setLib('commentaire_signature', __("commentaire")); |
1773 |
|
$form->setLib('historique_signature', ''); |
1774 |
|
$form->setLib('suivi_notification', ''); |
1775 |
|
$form->setLib('preview_edition', ""); |
1776 |
|
|
1777 |
|
// Ajout d'une infobulle d'aide lorsque le formulaire est en mode |
1778 |
|
// ajout et que l'option de rédaction libre est activée sur la |
1779 |
|
// collectivité du dossier |
1780 |
|
if ($maj === '0' && $this->is_option_redaction_libre_enabled() === true) { |
1781 |
|
// |
1782 |
|
$help_text_template = '%s <span class="info-16" title="%s"></span>'; |
1783 |
|
$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."); |
1784 |
|
$form->setLib('flag_edition_integrale', sprintf($help_text_template, _("Type de rédaction"), $help_text)); |
1785 |
|
} |
1786 |
|
else { |
1787 |
|
$form->setLib('flag_edition_integrale', _("Type de rédaction")); |
1788 |
|
} |
1789 |
|
|
1790 |
|
// Ajout d'une infobulle d'aide lorsque le formulaire est en mode |
1791 |
|
// modification et que l'option de prévisualisation de l'édition est |
1792 |
|
// activée sur la collectivité du dossier |
1793 |
|
if ($maj === '1' |
1794 |
|
&& $this->f->is_option_preview_pdf_enabled($this->get_dossier_instruction_om_collectivite()) === true) { |
1795 |
|
// |
1796 |
|
$help_text_template = '%s <span class="info-16" title="%s"></span>'; |
1797 |
|
$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."); |
1798 |
|
$form->setLib('date_evenement', sprintf($help_text_template, _('date_evenement'), $help_text)); |
1799 |
|
$form->setLib('signataire_arrete', sprintf($help_text_template, _('signataire_arrete'), $help_text)); |
1800 |
|
} |
1801 |
} |
} |
1802 |
|
|
1803 |
function triggerajouter($id, &$db = null, $val = array(), $DEBUG = null) { |
/** |
1804 |
|
* TRIGGER - triggerajouter. |
1805 |
|
* |
1806 |
|
* @return boolean |
1807 |
|
*/ |
1808 |
|
function triggerajouter($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
1809 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
1810 |
/** |
/** |
1811 |
* 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 |
1812 |
* et dossier pour les stocker dans l'instruction : |
* et dossier pour les stocker dans l'instruction : |
1819 |
* - delai_notification |
* - delai_notification |
1820 |
* - lettretype |
* - lettretype |
1821 |
* - autorite_competente |
* - autorite_competente |
1822 |
|
* - pec_metier |
1823 |
* - complement_om_html |
* - complement_om_html |
1824 |
* - complement2_om_html |
* - complement2_om_html |
1825 |
* - complement3_om_html |
* - complement3_om_html |
1844 |
// 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é |
1845 |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
1846 |
WHERE evenement=".$this->valF['evenement']; |
WHERE evenement=".$this->valF['evenement']; |
1847 |
$res = $db->query($sql); |
$res = $this->f->db->query($sql); |
1848 |
$this->addToLog("triggerajouter(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
1849 |
if (database::isError($res)) { |
if (database::isError($res)) { |
1850 |
die($res->getMessage()); |
die($res->getMessage()); |
1851 |
} |
} |
1882 |
} |
} |
1883 |
// Récupération de la valeur de la lettre type |
// Récupération de la valeur de la lettre type |
1884 |
$this->valF['lettretype']=$row['lettretype']; |
$this->valF['lettretype']=$row['lettretype']; |
1885 |
|
// Récupération de la valeur de la prise en compte métier |
1886 |
|
// si la prise en compte métier est paramétrée dans l'événement |
1887 |
|
$this->valF['pec_metier'] = NULL; |
1888 |
|
if(isset($row['pec_metier']) === true and empty($row['pec_metier']) === false) { |
1889 |
|
$this->valF['pec_metier'] = $row['pec_metier']; |
1890 |
|
} |
1891 |
} |
} |
1892 |
// 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 |
1893 |
$sql = "SELECT * FROM ".DB_PREFIXE."dossier |
$sql = "SELECT * FROM ".DB_PREFIXE."dossier |
1894 |
WHERE dossier='".$this->valF['dossier']."'"; |
WHERE dossier='".$this->valF['dossier']."'"; |
1895 |
$res = $db->query($sql); |
$res = $this->f->db->query($sql); |
1896 |
$this->addToLog("triggerajouter(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
1897 |
if (database::isError($res)) { |
if (database::isError($res)) { |
1898 |
die($res->getMessage()); |
die($res->getMessage()); |
1899 |
} |
} |
1908 |
LEFT JOIN ".DB_PREFIXE."dossier |
LEFT JOIN ".DB_PREFIXE."dossier |
1909 |
ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
1910 |
WHERE dossier.dossier='".$this->valF['dossier']."'"; |
WHERE dossier.dossier='".$this->valF['dossier']."'"; |
1911 |
$duree_validite_parametrage = $db->getOne($sql); |
$duree_validite_parametrage = $this->f->db->getOne($sql); |
1912 |
$this->addToLog("triggerajouter(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
1913 |
database::isError($duree_validite_parametrage); |
database::isError($duree_validite_parametrage); |
1914 |
if ($duree_validite_parametrage != '') { |
if ($duree_validite_parametrage != '') { |
1915 |
$this->valF['duree_validite_parametrage']= $duree_validite_parametrage; |
$this->valF['duree_validite_parametrage']= $duree_validite_parametrage; |
2108 |
$sql = "SELECT retour |
$sql = "SELECT retour |
2109 |
FROM ".DB_PREFIXE."evenement |
FROM ".DB_PREFIXE."evenement |
2110 |
WHERE evenement = ".$evenement; |
WHERE evenement = ".$evenement; |
2111 |
$retour = $this->db->getOne($sql); |
$retour = $this->f->db->getOne($sql); |
2112 |
$this->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE); |
2113 |
if (database::isError($retour)) { |
if (database::isError($retour)) { |
2114 |
die($retour->getMessage()); |
die($retour->getMessage()); |
2139 |
WHERE |
WHERE |
2140 |
evenement =".$evenement; |
evenement =".$evenement; |
2141 |
|
|
2142 |
$restriction = $this->db->getOne($sql); |
$restriction = $this->f->db->getOne($sql); |
2143 |
$this->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE); |
2144 |
if (database::isError($restriction)) { |
if (database::isError($restriction)) { |
2145 |
die($restriction->getMessage()); |
die($restriction->getMessage()); |
2225 |
"regle_date_retour_contradictoire", |
"regle_date_retour_contradictoire", |
2226 |
"regle_date_ait", |
"regle_date_ait", |
2227 |
"regle_date_transmission_parquet", |
"regle_date_transmission_parquet", |
2228 |
|
"regle_date_affichage", |
2229 |
); |
); |
2230 |
// Tableau des champs de type numérique |
// Tableau des champs de type numérique |
2231 |
$rule_type_numeric = array( |
$rule_type_numeric = array( |
2237 |
); |
); |
2238 |
// Tableau des champs de type booléen |
// Tableau des champs de type booléen |
2239 |
$rule_type_bool = array( |
$rule_type_bool = array( |
2240 |
|
"regle_a_qualifier", |
2241 |
|
"regle_incompletude", |
2242 |
|
"regle_incomplet_notifie", |
2243 |
|
"regle_evenement_suivant_tacite_incompletude", |
2244 |
); |
); |
2245 |
// Tableau des champs spécifiques |
// Tableau des champs spécifiques |
2246 |
$rule_type_specific = array( |
$rule_type_specific = array( |
2248 |
"regle_etat", |
"regle_etat", |
2249 |
"regle_accord_tacite", |
"regle_accord_tacite", |
2250 |
"regle_avis", |
"regle_avis", |
2251 |
|
"regle_pec_metier", |
2252 |
|
"regle_etat_pendant_incompletude", |
2253 |
); |
); |
2254 |
// Tableau des champs de données techniques |
// Tableau des champs de données techniques |
2255 |
$rule_type_technical_data = array( |
$rule_type_technical_data = array( |
2259 |
'regle_donnees_techniques4', |
'regle_donnees_techniques4', |
2260 |
'regle_donnees_techniques5', |
'regle_donnees_techniques5', |
2261 |
); |
); |
2262 |
|
// Tableau des champs simple |
2263 |
|
$rule_type_simple = array( |
2264 |
|
"regle_dossier_instruction_type", |
2265 |
|
); |
2266 |
|
|
2267 |
// Définit le type du champ |
// Définit le type du champ |
2268 |
if (in_array($rule_name, $rule_type_date) == true) { |
if (in_array($rule_name, $rule_type_date) == true) { |
2283 |
if (in_array($rule_name, $rule_type_technical_data) === true) { |
if (in_array($rule_name, $rule_type_technical_data) === true) { |
2284 |
$type = 'text'; |
$type = 'text'; |
2285 |
} |
} |
2286 |
|
if (in_array($rule_name, $rule_type_simple) === true) { |
2287 |
|
$type = 'simple'; |
2288 |
|
} |
2289 |
|
|
2290 |
// 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 |
2291 |
// Récupère directement la valeur de l'opérande |
// Récupère directement la valeur de l'opérande |
2292 |
if ($type === 'specific' || $type === 'bool') { |
if ($type === 'specific') { |
2293 |
// |
// |
2294 |
return $this->get_value_for_rule($rule); |
return $this->get_value_for_rule($rule); |
2295 |
} |
} |
2364 |
// Retourne la chaîne de caractère |
// Retourne la chaîne de caractère |
2365 |
return $res_text; |
return $res_text; |
2366 |
} |
} |
2367 |
|
if ($type === 'simple' || $type === 'bool') { |
2368 |
|
// Retourne la valeur du champs rule |
2369 |
|
return $rule; |
2370 |
|
} |
2371 |
} |
} |
2372 |
|
|
2373 |
|
|
2410 |
$donnees_techniques = $this->getDonneesTechniques(); |
$donnees_techniques = $this->getDonneesTechniques(); |
2411 |
} |
} |
2412 |
// |
// |
2413 |
require_once "../obj/donnees_techniques.class.php"; |
$this->inst_donnees_techniques = $this->f->get_inst__om_dbform(array( |
2414 |
$this->inst_donnees_techniques = new donnees_techniques($donnees_techniques); |
"obj" => "donnees_techniques", |
2415 |
|
"idx" => $donnees_techniques, |
2416 |
|
)); |
2417 |
} |
} |
2418 |
// |
// |
2419 |
return $this->inst_donnees_techniques; |
return $this->inst_donnees_techniques; |
2431 |
$sql = "SELECT donnees_techniques |
$sql = "SELECT donnees_techniques |
2432 |
FROM ".DB_PREFIXE."donnees_techniques |
FROM ".DB_PREFIXE."donnees_techniques |
2433 |
WHERE dossier_instruction ='".$this->valF["dossier"]."'"; |
WHERE dossier_instruction ='".$this->valF["dossier"]."'"; |
2434 |
$donnees_techniques = $this->db->getOne($sql); |
$donnees_techniques = $this->f->db->getOne($sql); |
2435 |
$this->f->addToLog("getStatut() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog("getStatut() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
2436 |
if ( database::isError($donnees_techniques)){ |
if ( database::isError($donnees_techniques)){ |
2437 |
die(); |
die(); |
2440 |
return $donnees_techniques; |
return $donnees_techniques; |
2441 |
} |
} |
2442 |
|
|
|
|
|
2443 |
/** |
/** |
2444 |
* TRIGGER - triggerajouterapres. |
* TRIGGER - triggerajouterapres. |
2445 |
* |
* |
2450 |
* |
* |
2451 |
* @return boolean |
* @return boolean |
2452 |
*/ |
*/ |
2453 |
function triggerajouterapres($id, &$db = null, $val = array(), $DEBUG = null) { |
function triggerajouterapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
2454 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
2455 |
|
|
2456 |
// 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 |
2457 |
$inst_di = $this->get_inst_dossier($this->valF['dossier']); |
$inst_di = $this->get_inst_dossier($this->valF['dossier']); |
|
|
|
2458 |
// Instance de la classe evenement |
// Instance de la classe evenement |
2459 |
$inst_evenement = $this->get_inst_evenement($this->valF['evenement']); |
$inst_evenement = $this->get_inst_evenement($this->valF['evenement']); |
2460 |
|
// Instance de l'état courant du dossier d'instruction |
2461 |
|
$inst_current_etat = $this->f->get_inst__om_dbform(array( |
2462 |
|
"obj" => "etat", |
2463 |
|
"idx" => $inst_di->get_id_etat(), |
2464 |
|
)); |
2465 |
|
|
2466 |
/** |
/** |
2467 |
* Mise à jour des valeurs du dossier en fonction des valeurs calculées |
* Mise à jour des valeurs du dossier en fonction des valeurs calculées |
2469 |
*/ |
*/ |
2470 |
// état de complétude actuel du dossier |
// état de complétude actuel du dossier |
2471 |
$incompletude = ($inst_di->getVal('incompletude') == 't' ? true : false); |
$incompletude = ($inst_di->getVal('incompletude') == 't' ? true : false); |
2472 |
|
// L'événement suivant tacite paramétré est destiné à la gestion de l'incomplétude |
2473 |
|
$ev_suiv_tacite_incompletude = false; |
2474 |
// Initialisation |
// Initialisation |
2475 |
$valF = ""; |
$valF = array(); |
2476 |
$valF_dt = ""; |
$valF_dt = array(); |
2477 |
// |
// |
|
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; |
|
|
} |
|
|
} |
|
2478 |
// Récupération des paramètres de l'action |
// Récupération des paramètres de l'action |
2479 |
$sql = "SELECT * FROM ".DB_PREFIXE."action |
$sql = "SELECT * FROM ".DB_PREFIXE."action |
2480 |
WHERE action='".$this->valF['action']."'"; |
WHERE action='".$this->valF['action']."'"; |
2481 |
$res = $db->query($sql); |
$res = $this->f->db->query($sql); |
2482 |
$this->addToLog("triggerajouterapres(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
2483 |
if (database::isError($res)) { |
if (database::isError($res)) { |
2484 |
die($res->getMessage()); |
die($res->getMessage()); |
2485 |
} |
} |
2535 |
$valF['autorite_competente'] = $this->regle($row['regle_autorite_competente'], 'regle_autorite_competente'); |
$valF['autorite_competente'] = $this->regle($row['regle_autorite_competente'], 'regle_autorite_competente'); |
2536 |
} |
} |
2537 |
if ($row['regle_etat'] != '') { |
if ($row['regle_etat'] != '') { |
2538 |
// 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'); |
|
|
} |
|
2539 |
} |
} |
2540 |
if ($row['regle_date_cloture_instruction'] !== '') { |
if ($row['regle_date_cloture_instruction'] !== '') { |
2541 |
$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'); |
2573 |
if ($row['regle_date_transmission_parquet'] !== '') { |
if ($row['regle_date_transmission_parquet'] !== '') { |
2574 |
$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'); |
2575 |
} |
} |
2576 |
|
if ($row['regle_dossier_instruction_type'] !== '') { |
2577 |
|
$valF['dossier_instruction_type'] = $this->regle($row['regle_dossier_instruction_type'], 'regle_dossier_instruction_type'); |
2578 |
|
} |
2579 |
|
// La date d'affichage est modifiée seulement si le champ n'est pas |
2580 |
|
// renseigné |
2581 |
|
if ($row['regle_date_affichage'] !== '' |
2582 |
|
&& ($inst_di->getVal('date_affichage') === '' |
2583 |
|
|| $inst_di->getVal('date_affichage') === null)) { |
2584 |
|
// |
2585 |
|
$valF['date_affichage'] = $this->regle($row['regle_date_affichage'], 'regle_date_affichage'); |
2586 |
|
} |
2587 |
|
// |
2588 |
|
if ($row['regle_pec_metier'] != '') { |
2589 |
|
$valF['pec_metier'] = $this->regle($row['regle_pec_metier'], 'regle_pec_metier'); |
2590 |
|
} |
2591 |
|
if ($row['regle_a_qualifier'] != '') { |
2592 |
|
$valF['a_qualifier'] = $this->regle($row['regle_a_qualifier'], 'regle_a_qualifier'); |
2593 |
|
} |
2594 |
|
// |
2595 |
|
if ($row['regle_incompletude'] != '') { |
2596 |
|
$valF['incompletude'] = $this->regle($row['regle_incompletude'], 'regle_incompletude'); |
2597 |
|
} |
2598 |
|
if ($row['regle_incomplet_notifie'] != '') { |
2599 |
|
$valF['incomplet_notifie'] = $this->regle($row['regle_incomplet_notifie'], 'regle_incomplet_notifie'); |
2600 |
|
} |
2601 |
|
if ($row['regle_etat_pendant_incompletude'] != '') { |
2602 |
|
$valF['etat_pendant_incompletude'] = $this->regle($row['regle_etat_pendant_incompletude'], 'regle_etat_pendant_incompletude'); |
2603 |
|
} |
2604 |
|
if ($row['regle_evenement_suivant_tacite_incompletude'] != '') { |
2605 |
|
$resti = $this->regle($row['regle_evenement_suivant_tacite_incompletude'], 'regle_evenement_suivant_tacite_incompletude'); |
2606 |
|
if (strtolower($resti) === 't' || strtolower($resti) === 'true') { |
2607 |
|
$ev_suiv_tacite_incompletude = true; |
2608 |
|
} |
2609 |
|
} |
2610 |
} |
} |
2611 |
|
|
2612 |
// Si l'événement a un événement suivant tacite |
// Si l'événement a un événement suivant tacite |
2613 |
if($inst_evenement->getVal('evenement_suivant_tacite') != '') { |
if($inst_evenement->getVal('evenement_suivant_tacite') != '') { |
2614 |
// 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 |
2615 |
// dans le champ evenement_suivant_tacite du dossier |
// pas associé de le même façon au dossier d'instruction |
2616 |
if ($incompletude == false OR $inst_evenement->getVal('type') != "incompletude") { |
if ($ev_suiv_tacite_incompletude === false) { |
|
// |
|
2617 |
$valF['evenement_suivant_tacite'] = $inst_evenement->getVal('evenement_suivant_tacite'); |
$valF['evenement_suivant_tacite'] = $inst_evenement->getVal('evenement_suivant_tacite'); |
2618 |
} else { |
} |
2619 |
// Sinon l'événement tacite est stocké dans le champ |
if ($ev_suiv_tacite_incompletude === true) { |
|
// evenement_suivant_tacite_incompletude du dossier |
|
2620 |
$valF['evenement_suivant_tacite_incompletude'] = $inst_evenement->getVal('evenement_suivant_tacite'); |
$valF['evenement_suivant_tacite_incompletude'] = $inst_evenement->getVal('evenement_suivant_tacite'); |
2621 |
} |
} |
2622 |
} |
} |
2623 |
// 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 |
2624 |
if ($valF_dt != "") { |
if (count($valF_dt) > 0) { |
2625 |
$dt_id = $this->getDonneesTechniques(); |
$dt_id = $this->getDonneesTechniques(); |
2626 |
// On met à jour le dossier |
// On met à jour le dossier |
2627 |
$cle = " donnees_techniques='".$dt_id."'"; |
$cle = " donnees_techniques='".$dt_id."'"; |
2628 |
$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); |
2629 |
$this->addToLog("triggerajouterapres(): db->autoexecute(\"".DB_PREFIXE."donnees_techniques\", ".print_r($valF_dt, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->autoexecute(\"".DB_PREFIXE."donnees_techniques\", ".print_r($valF_dt, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
2630 |
if (database::isError($res1)) { |
if (database::isError($res1)) { |
2631 |
die($res->getMessage()); |
die($res->getMessage()); |
2632 |
} |
} |
2633 |
// Affichage d'informations à l'utilisateur |
// Affichage d'informations à l'utilisateur |
2634 |
$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')."]"); |
2635 |
} |
} |
2636 |
// 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 |
2637 |
if ($valF != "") { |
if (count($valF) > 0) { |
2638 |
// On met à jour le dossier |
// |
2639 |
$cle = " dossier='".$this->valF['dossier']."'"; |
$inst_dossier = $this->f->get_inst__om_dbform(array( |
2640 |
$res1 = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle); |
"obj" => "dossier", |
2641 |
$this->addToLog("triggerajouterapres(): db->autoexecute(\"".DB_PREFIXE."dossier\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
"idx" => $this->valF['dossier'], |
2642 |
if (database::isError($res1)) { |
)); |
2643 |
die($res->getMessage()); |
$valF['instruction'] = $id; |
2644 |
|
$valF['crud'] = 'create'; |
2645 |
|
$update_by_instruction = $inst_dossier->update_by_instruction($valF); |
2646 |
|
if ($update_by_instruction === false) { |
2647 |
|
$this->cleanMessage(); |
2648 |
|
$this->addToMessage(sprintf('%s %s', __("Une erreur s'est produite lors de la mise à jour du dossier d'instruction."), __("Veuillez contacter votre administrateur."))); |
2649 |
|
return false; |
2650 |
} |
} |
2651 |
// Affichage d'informations à l'utilisateur |
// Affichage d'informations à l'utilisateur |
2652 |
$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')."]"); |
2653 |
} |
} |
2654 |
|
|
2655 |
/** |
/** |
2685 |
$this->addToMessage(_("Notification (105) du référentiel ERP OK.")); |
$this->addToMessage(_("Notification (105) du référentiel ERP OK.")); |
2686 |
} |
} |
2687 |
|
|
2688 |
|
// Si le mode en rédaction intégrale est activé |
2689 |
|
if (isset($this->valF['flag_edition_integrale']) === true |
2690 |
|
&& $this->valF['flag_edition_integrale'] === true) { |
2691 |
|
$redactionIntegraleValF = array(); |
2692 |
|
|
2693 |
|
// Récupère la collectivite du dossier d'instruction |
2694 |
|
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
2695 |
|
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
2696 |
|
// Récupère le corps de la lettre type |
2697 |
|
$params = array( |
2698 |
|
"specific" => array( |
2699 |
|
"corps" => array( |
2700 |
|
"mode" => "get", |
2701 |
|
) |
2702 |
|
), |
2703 |
|
); |
2704 |
|
$result = $this->compute_pdf_output('lettretype', $this->valF['lettretype'], $collectivite, $id, $params); |
2705 |
|
$redactionIntegraleValF['corps_om_htmletatex'] = $result['pdf_output']; |
2706 |
|
// Récupère le titre de la lettre type |
2707 |
|
$params = array( |
2708 |
|
"specific" => array( |
2709 |
|
"titre" => array( |
2710 |
|
"mode" => "get", |
2711 |
|
) |
2712 |
|
), |
2713 |
|
); |
2714 |
|
$result = $this->compute_pdf_output('lettretype', $this->valF['lettretype'], $collectivite, $id, $params); |
2715 |
|
$redactionIntegraleValF['titre_om_htmletat'] = $result['pdf_output']; |
2716 |
|
|
2717 |
|
// mise à jour en base de données |
2718 |
|
$res = $this->f->db->autoExecute( |
2719 |
|
DB_PREFIXE.$this->table, |
2720 |
|
$redactionIntegraleValF, |
2721 |
|
DB_AUTOQUERY_UPDATE, |
2722 |
|
$this->clePrimaire."=".$id |
2723 |
|
); |
2724 |
|
$this->addToLog(__METHOD__."(): db->autoexecute(\"".DB_PREFIXE.'.'.$this->table."\", ".print_r($redactionIntegraleValF, true).", DB_AUTOQUERY_UPDATE, \"".$this->clePrimaire."=".$id."\");", VERBOSE_MODE); |
2725 |
|
if ($this->f->isDatabaseError($res, true) === true) { |
2726 |
|
return false; |
2727 |
|
} |
2728 |
|
} |
2729 |
|
|
2730 |
/** |
/** |
2731 |
* Mise à jour des données du DA. |
* Finalisation automatique de l'instruction si le paramétrage de l'événement l'autorise |
2732 |
*/ |
*/ |
2733 |
// |
// Si la finalisation automatique de l'événement est activée |
2734 |
$inst_da = $inst_di->get_inst_dossier_autorisation(); |
// ET si l'instruction n'a pas déjà été finalisée |
2735 |
// |
// ET s'il existe une lettre type associée |
2736 |
if ($inst_da->majDossierAutorisation() === false) { |
if ($inst_evenement->getVal('finaliser_automatiquement') === 't' |
2737 |
$this->addToMessage(_("Erreur lors de la mise a jour des donnees du dossier d'autorisation. Contactez votre administrateur.")); |
&& $inst_evenement->getVal('om_final_instruction') !== 't' |
2738 |
$this->correct = false; |
&& $inst_evenement->getVal('lettretype') !== '' |
2739 |
return false; |
&& $inst_evenement->getVal('lettretype') !== null) { |
2740 |
|
|
2741 |
|
// On instancie l'instruction |
2742 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
2743 |
|
"obj" => "instruction", |
2744 |
|
"idx" => $this->valF[$this->clePrimaire], |
2745 |
|
)); |
2746 |
|
|
2747 |
|
// On finalise l'instruction dans le contexte de finalisation : action 100 |
2748 |
|
$inst_instruction->setParameter('maj', 100); |
2749 |
|
$finalize = $inst_instruction->finalize($inst_instruction->valF); |
2750 |
|
|
2751 |
|
// Une erreur de finalisation renvoie 'false' : ajout dans les logs |
2752 |
|
// et dans le message d'erreur |
2753 |
|
if ($finalize === false) { |
2754 |
|
$this->f->addToLog(__METHOD__."() : ERROR - Impossible de finaliser l'instruction.", DEBUG_MODE); |
2755 |
|
$this->addToMessage(_("Erreur lors de la finalisation de l'instruction. Contactez votre administrateur.")); |
2756 |
|
return false; |
2757 |
|
} |
2758 |
} |
} |
2759 |
|
|
2760 |
/** |
/** |
2775 |
// retour |
// retour |
2776 |
// OU l'événement d'instruction est l'événement suivant tacite du |
// OU l'événement d'instruction est l'événement suivant tacite du |
2777 |
// dossier d'instruction (incomplétude prise en compte) |
// dossier d'instruction (incomplétude prise en compte) |
2778 |
if ($inst_evenement->getVal("retour") === 't' |
// ET l'événement d'instruction n'a pas déjà été finalisé |
2779 |
|
if (($inst_evenement->getVal("retour") === 't' |
2780 |
|| ($inst_di->getVal('evenement_suivant_tacite_incompletude') === $evenement_id |
|| ($inst_di->getVal('evenement_suivant_tacite_incompletude') === $evenement_id |
2781 |
|| $inst_di->getVal('evenement_suivant_tacite') === $evenement_id)) { |
|| $inst_di->getVal('evenement_suivant_tacite') === $evenement_id)) |
2782 |
|
&& ($inst_evenement->getVal('om_final_instruction') !== 't')) { |
2783 |
|
|
2784 |
// Finalise l'instruction |
// Finalise l'instruction |
2785 |
$inst_instruction = new instruction($this->valF[$this->clePrimaire], $this->f->db, 0); |
$inst_instruction = $this->f->get_inst__om_dbform(array( |
2786 |
|
"obj" => "instruction", |
2787 |
|
"idx" => $this->valF[$this->clePrimaire], |
2788 |
|
)); |
2789 |
$inst_instruction->setParameter('maj', 100); |
$inst_instruction->setParameter('maj', 100); |
2790 |
$finalize = $inst_instruction->finalize($inst_instruction->valF); |
$finalize = $inst_instruction->finalize($inst_instruction->valF); |
2791 |
if ($finalize === false) { |
if ($finalize === false) { |
2796 |
} |
} |
2797 |
|
|
2798 |
/** |
/** |
2799 |
|
* Mise à jour de la version de clôture *version_clos* du dossier si et |
2800 |
|
* seulement si l'instruction met à jour l'état du dossier. |
2801 |
|
*/ |
2802 |
|
if (isset($valF['etat']) === true |
2803 |
|
&& $valF['etat'] !== null |
2804 |
|
&& $valF['etat'] !== '') { |
2805 |
|
// Instanciation de l'état appliqué sur le dossier par l'instruction |
2806 |
|
$inst_etat = $this->f->get_inst__om_dbform(array( |
2807 |
|
"obj" => "etat", |
2808 |
|
"idx" => $valF['etat'], |
2809 |
|
)); |
2810 |
|
// |
2811 |
|
$update_version_clos = null; |
2812 |
|
// En cas d'instruction qui clôture le dossier |
2813 |
|
if ($inst_etat->getVal('statut') === 'cloture') { |
2814 |
|
$update_version_clos = $inst_di->update_version_clos('up'); |
2815 |
|
} |
2816 |
|
// En cas d'instruction qui rouvre le dossier |
2817 |
|
if ($inst_current_etat->getVal('statut') === 'cloture' |
2818 |
|
&& $inst_etat->getVal('statut') !== 'cloture') { |
2819 |
|
// |
2820 |
|
$update_version_clos = $inst_di->update_version_clos('down'); |
2821 |
|
// |
2822 |
|
$params = array( |
2823 |
|
'di_reopened' => true, |
2824 |
|
); |
2825 |
|
} |
2826 |
|
// |
2827 |
|
if ($update_version_clos === false) { |
2828 |
|
$this->f->addToLog(sprintf( |
2829 |
|
"%s() : ERREUR - %s %s", |
2830 |
|
__METHOD__, |
2831 |
|
sprintf( |
2832 |
|
__("Impossible de mettre à jour la version de clôture du dossier d'instruction %s."), |
2833 |
|
$inst_di->getVal($inst_di->clePrimaire) |
2834 |
|
), |
2835 |
|
sprintf( |
2836 |
|
__("L'instruction tente d'appliquer l'état %s."), |
2837 |
|
$inst_etat->getVal($inst_etat->clePrimaire) |
2838 |
|
) |
2839 |
|
)); |
2840 |
|
$this->addToMessage(sprintf( |
2841 |
|
"%s %s", |
2842 |
|
__("Erreur lors de la mise à jour de la version de clôture du dossier d'instruction."), |
2843 |
|
__("Veuillez contacter votre administrateur.") |
2844 |
|
)); |
2845 |
|
return false; |
2846 |
|
} |
2847 |
|
} |
2848 |
|
|
2849 |
|
/** |
2850 |
|
* Notification automatique |
2851 |
|
*/ |
2852 |
|
// Notification automatique à l'ajout de l'instruction si la notification |
2853 |
|
// automatique est choisie et qu'il n'y a pas de lettretype associée à l'événement |
2854 |
|
if ($inst_evenement->getVal('notification') === 'notification_automatique' && |
2855 |
|
($inst_evenement->getVal('lettretype') === null || |
2856 |
|
$inst_evenement->getVal('lettretype') === '')) { |
2857 |
|
// Récupération de la liste des demandeurs à notifier et de la catégorie |
2858 |
|
$categorie = $this->f->get_param_option_notification($collectivite_di); |
2859 |
|
$isPortal = $categorie == null || $categorie == '' || $categorie == 'portal' ? true : false; |
2860 |
|
$demandeursANotifie = $this->get_demandeurs_notifiable( |
2861 |
|
$this->valF['dossier'], |
2862 |
|
$isPortal |
2863 |
|
); |
2864 |
|
|
2865 |
|
// Création d'une notification et d'une tâche pour chaque demandeur à notifier |
2866 |
|
foreach ($demandeursANotifie as $demandeur) { |
2867 |
|
// Ajout de la notif et récupération de son id |
2868 |
|
$idNotif = $this->ajouter_notification( |
2869 |
|
$this->valF[$this->clePrimaire], |
2870 |
|
$this->f->get_connected_user_login_name(), |
2871 |
|
$demandeur, |
2872 |
|
$collectivite_di, |
2873 |
|
true |
2874 |
|
); |
2875 |
|
if ($idNotif === false) { |
2876 |
|
return false; |
2877 |
|
} |
2878 |
|
// Création de la tache en lui donnant l'id de la notification |
2879 |
|
$notification_by_task = $this->notification_by_task( |
2880 |
|
$idNotif, |
2881 |
|
$this->valF['dossier'], |
2882 |
|
$categorie |
2883 |
|
); |
2884 |
|
if ($notification_by_task === false) { |
2885 |
|
$this->addToMessage( |
2886 |
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
2887 |
|
); |
2888 |
|
return false; |
2889 |
|
} |
2890 |
|
} |
2891 |
|
$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."))); |
2892 |
|
} |
2893 |
|
|
2894 |
|
/** |
2895 |
|
* Mise à jour de la date de dernière modification du dossier |
2896 |
|
*/ |
2897 |
|
$inst_di->update_last_modification_date(); |
2898 |
|
|
2899 |
|
/** |
2900 |
|
* Mise à jour des données du DA. |
2901 |
|
*/ |
2902 |
|
$inst_da = $inst_di->get_inst_dossier_autorisation(); |
2903 |
|
$params['di_id'] = $this->valF['dossier']; |
2904 |
|
if ($inst_da->majDossierAutorisation($params) === false) { |
2905 |
|
$this->addToMessage(_("Erreur lors de la mise a jour des donnees du dossier d'autorisation. Contactez votre administrateur.")); |
2906 |
|
$this->correct = false; |
2907 |
|
return false; |
2908 |
|
} |
2909 |
|
|
2910 |
|
/** |
2911 |
* Historisation de la vie du DI. |
* Historisation de la vie du DI. |
2912 |
*/ |
*/ |
2913 |
// |
// |
2914 |
return $this->add_log_to_dossier($id, array_merge($val, $this->valF)); |
return $this->add_log_to_dossier($id, array_merge($val, $this->valF)); |
2915 |
} |
} |
2916 |
|
|
2917 |
function triggermodifierapres($id, &$db = null, $val = array(), $DEBUG = null) { |
public function is_notifiable_by_task_manual() { |
2918 |
|
$ev = $this->get_inst_evenement($this->getVal('evenement')); |
2919 |
|
|
2920 |
|
// Si l'instruction a une édition non finalisé quel que soit |
2921 |
|
// le type de notification, il n'est pas notifiable |
2922 |
|
if ($this->has_an_edition() === true) { |
2923 |
|
if ($this->is_unfinalizable_without_bypass() === false) { |
2924 |
|
return false; |
2925 |
|
} |
2926 |
|
} |
2927 |
|
|
2928 |
|
// Gestion des différents cas selon la valeur du champs notification |
2929 |
|
switch ($ev->getVal('notification')) { |
2930 |
|
case 'notification_manuelle': |
2931 |
|
return true; |
2932 |
|
case 'notification_manuelle_annexe': |
2933 |
|
return true; |
2934 |
|
case 'notification_automatique': |
2935 |
|
return false; |
2936 |
|
case 'notification_auto_signature_requise': |
2937 |
|
return false; |
2938 |
|
case 'notification_manuelle_signature_requise': |
2939 |
|
// Si il y a une date de retour de signature la notification est possible |
2940 |
|
if ($this->getVal('date_retour_signature') === null |
2941 |
|
|| $this->getVal('date_retour_signature') === '') { |
2942 |
|
return false; |
2943 |
|
} |
2944 |
|
return true; |
2945 |
|
case 'notification_manuelle_annexe_signature_requise': |
2946 |
|
// Si il y a une date de retour de signature la notification est possible |
2947 |
|
if ($this->getVal('date_retour_signature') === null |
2948 |
|
|| $this->getVal('date_retour_signature') === '') { |
2949 |
|
return false; |
2950 |
|
} |
2951 |
|
return true; |
2952 |
|
default: |
2953 |
|
return false; |
2954 |
|
} |
2955 |
|
} |
2956 |
|
|
2957 |
|
/** |
2958 |
|
* Crée une instance et une tache de notification pour le demandeur |
2959 |
|
* principal. |
2960 |
|
* |
2961 |
|
* @return boolean true si le traitement à réussi |
2962 |
|
*/ |
2963 |
|
protected function notifier_demandeur_principal() { |
2964 |
|
$this->begin_treatment(__METHOD__); |
2965 |
|
$message = ''; |
2966 |
|
// Récupération des informations concernant le demandeur |
2967 |
|
$dossier = $this->getVal('dossier'); |
2968 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite($dossier); |
2969 |
|
$demandeur = $this->get_demandeurs_notifiable( |
2970 |
|
$dossier, |
2971 |
|
true |
2972 |
|
); |
2973 |
|
if ($demandeur !== array()) { |
2974 |
|
$destinataire = array_values($demandeur); |
2975 |
|
// Ajout de la notif et récupération de son id |
2976 |
|
$idNotification = $this->ajouter_notification( |
2977 |
|
$this->getVal($this->clePrimaire), |
2978 |
|
$this->f->get_connected_user_login_name(), |
2979 |
|
$destinataire[0], |
2980 |
|
$collectivite_di, |
2981 |
|
true |
2982 |
|
); |
2983 |
|
if ($idNotification === false) { |
2984 |
|
return $this->end_treatment(__METHOD__, false); |
2985 |
|
} |
2986 |
|
// Création de la tâche en lui donnant l'id de la notification |
2987 |
|
$notification_by_task = $this->notification_by_task($idNotification, $dossier); |
2988 |
|
if ($notification_by_task === false) { |
2989 |
|
$this->addToMessage( |
2990 |
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
2991 |
|
); |
2992 |
|
return $this->end_treatment(__METHOD__, false); |
2993 |
|
} |
2994 |
|
$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."))); |
2995 |
|
return $this->end_treatment(__METHOD__, true); |
2996 |
|
} |
2997 |
|
$this->addToMessage( __("Le demandeur principal n'est pas notifiable.")); |
2998 |
|
return $this->end_treatment(__METHOD__, true); |
2999 |
|
} |
3000 |
|
|
3001 |
|
public function notification_by_task($object_id, $dossier, $category = null, $type = null) { |
3002 |
|
// Par défaut le type est portal |
3003 |
|
if ($category === null) { |
3004 |
|
$category = 'portal'; |
3005 |
|
} |
3006 |
|
// Si le type n'est pas correctement spécifié, alors il est calculé |
3007 |
|
if ($type === null |
3008 |
|
|| $type !== 'notification_recepisse' |
3009 |
|
|| $type !== 'notification_instruction' |
3010 |
|
|| $type !== 'notification_decision') { |
3011 |
|
// |
3012 |
|
$type = 'notification_instruction'; |
3013 |
|
// Vérifie si l'instruction est un récépissé |
3014 |
|
$trace = debug_backtrace(); |
3015 |
|
foreach ($trace as $key => $value) { |
3016 |
|
if (isset($trace[$key]['class']) === true |
3017 |
|
&& empty($trace[$key]['class']) === false) { |
3018 |
|
// |
3019 |
|
if (strtolower($trace[$key]['class']) === 'demande') { |
3020 |
|
$type = 'notification_recepisse'; |
3021 |
|
} |
3022 |
|
} |
3023 |
|
} |
3024 |
|
// Vérifie si l'instruction est une décision |
3025 |
|
if ($type !== 'notification_recepisse') { |
3026 |
|
$avis_decision = $this->getVal('avis_decision') !== null ? $this->getVal('avis_decision') : $this->valF['avis_decision']; |
3027 |
|
if ($avis_decision !== null && $avis_decision !== '') { |
3028 |
|
$type = 'notification_decision'; |
3029 |
|
} |
3030 |
|
} |
3031 |
|
} |
3032 |
|
// Préparation de la tache de notification |
3033 |
|
$inst_task = $this->f->get_inst__om_dbform(array( |
3034 |
|
"obj" => "task", |
3035 |
|
"idx" => 0, |
3036 |
|
)); |
3037 |
|
$task_val = array( |
3038 |
|
'type' => $type, |
3039 |
|
'object_id' => $object_id, |
3040 |
|
'dossier' => $dossier, |
3041 |
|
'category' => $category, |
3042 |
|
); |
3043 |
|
|
3044 |
|
$add_task = $inst_task->add_task(array('val' => $task_val)); |
3045 |
|
if ($add_task === false) { |
3046 |
|
return false; |
3047 |
|
} |
3048 |
|
|
3049 |
|
return true; |
3050 |
|
} |
3051 |
|
|
3052 |
|
/** |
3053 |
|
* A partir des informations passée en argument ajoute un nouvel élément |
3054 |
|
* dans la table instruction_notification. |
3055 |
|
* Avant l'ajout vérifie en utilisant l'id de la collectivité passée en |
3056 |
|
* paramètre si le paramétrage attendus est ok. |
3057 |
|
* Ajoute également un nouvel élement dans instruction_notification_document |
3058 |
|
* si l'instruction possède une lettretype. |
3059 |
|
* Si un identifiant d'une instruction annexe est donnée ajoute un deuxième |
3060 |
|
* élement dans la table instruction_notification_document qui correspondra |
3061 |
|
* à l'annexe de la notification. |
3062 |
|
* |
3063 |
|
* @param integer identifiant de l'instruction notifiée |
3064 |
|
* @param string information concernant l'emetteur |
3065 |
|
* @param array tableau contenant 2 entrées |
3066 |
|
* - destinatire : nom, prenom ou raison sociale, dénomination et courriel |
3067 |
|
* - courriel : adresse mail de la personne à notifier |
3068 |
|
* @param integer identifiant de la collectivité permettant de récupèrer les |
3069 |
|
* paramètres à valider |
3070 |
|
* @param boolean indique si la notification est automatique ou manuelle |
3071 |
|
* @param integer identifiant d'une instruction dont l'édition sera annexé |
3072 |
|
* à la notification |
3073 |
|
* |
3074 |
|
* @return integer|boolean identifiant de la notification créée si le traitement |
3075 |
|
* a réussie, false sinon. |
3076 |
|
*/ |
3077 |
|
protected function ajouter_notification( |
3078 |
|
$idInstruction, |
3079 |
|
$emetteur, |
3080 |
|
$destinataire, |
3081 |
|
$collectiviteId, |
3082 |
|
$demandeAuto = false, |
3083 |
|
$idInstrDocAnnexe = null |
3084 |
|
) { |
3085 |
|
// Vérification que les paramètres nécessaires à l'envoi de la notification existe avant |
3086 |
|
// de créer la notification |
3087 |
|
if (! $this->is_parametrage_notification_correct($collectiviteId)) { |
3088 |
|
$this->addToMessage(__("Erreur de paramétrage. L'url d'accès au(x) document(s) notifié(s) n'est pas paramétrée.")); |
3089 |
|
return false; |
3090 |
|
} |
3091 |
|
// Préparation de la notification |
3092 |
|
$inst_notif = $this->f->get_inst__om_dbform(array( |
3093 |
|
"obj" => "instruction_notification", |
3094 |
|
"idx" => "]", |
3095 |
|
)); |
3096 |
|
$notif_val = array( |
3097 |
|
'instruction_notification' => null, |
3098 |
|
'instruction' => $idInstruction, |
3099 |
|
'automatique' => $demandeAuto, |
3100 |
|
'emetteur' => $emetteur, |
3101 |
|
'date_envoi' => null, |
3102 |
|
'destinataire' => $destinataire['destinataire'], |
3103 |
|
'courriel' => $destinataire['courriel'], |
3104 |
|
'date_premier_acces' => null, |
3105 |
|
'statut' => 'en cours d\'envoi', |
3106 |
|
'commentaire' => 'Notification en cours de traitement' |
3107 |
|
); |
3108 |
|
|
3109 |
|
// Création de la notification |
3110 |
|
$add_notif = $inst_notif->ajouter($notif_val); |
3111 |
|
if ($add_notif === false) { |
3112 |
|
$this->addToMessage(__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).")); |
3113 |
|
return false; |
3114 |
|
} |
3115 |
|
|
3116 |
|
// Si il y a une lettretype finalisé stockage de la clé d'accès au documents |
3117 |
|
if ($this->evenement_has_an_edition($this->getVal('evenement')) === true) { |
3118 |
|
$add_notif_doc = $this->ajouter_notification_document( |
3119 |
|
$this->getVal($this->clePrimaire), |
3120 |
|
$inst_notif->getVal($inst_notif->clePrimaire) |
3121 |
|
); |
3122 |
|
if ($add_notif_doc === false) { |
3123 |
|
$this->addToMessage(__("Erreur lors de la génération de la notification du document.")); |
3124 |
|
return false; |
3125 |
|
} |
3126 |
|
} |
3127 |
|
// Si une annexe a été choisie stockage de la clé d'accès à l'annexe |
3128 |
|
if ($idInstrDocAnnexe != null || $idInstrDocAnnexe != '') { |
3129 |
|
$add_notif_annexe = $this->ajouter_notification_document( |
3130 |
|
$idInstrDocAnnexe, |
3131 |
|
$inst_notif->getVal($inst_notif->clePrimaire), |
3132 |
|
true |
3133 |
|
); |
3134 |
|
if ($add_notif_annexe === false) { |
3135 |
|
$this->addToMessage(__("Erreur lors de la génération de la notification de l'annexe.")); |
3136 |
|
return false; |
3137 |
|
} |
3138 |
|
} |
3139 |
|
|
3140 |
|
// Renvoie l'id de la nouvelle instance de instruction_notification |
3141 |
|
return $inst_notif->getVal($inst_notif->clePrimaire); |
3142 |
|
} |
3143 |
|
|
3144 |
|
/** |
3145 |
|
* Vérifie si le paramétrage de la notification des demandeurs est correct. |
3146 |
|
* |
3147 |
|
* @param integer identifiant de la collectivité |
3148 |
|
* @return boolean |
3149 |
|
*/ |
3150 |
|
protected function is_parametrage_notification_correct($collectiviteId) { |
3151 |
|
$categorie = $this->f->get_param_option_notification($collectiviteId); |
3152 |
|
$urlAccesNotif = $this->f->get_parametre_notification_url_acces($collectiviteId); |
3153 |
|
if ($categorie == 'mail' && $urlAccesNotif == null) { |
3154 |
|
return false; |
3155 |
|
} |
3156 |
|
return true; |
3157 |
|
} |
3158 |
|
|
3159 |
|
/** |
3160 |
|
* Ajoute un élément dans la table instruction_notification_document. |
3161 |
|
* |
3162 |
|
* @param integer $idInstruction : id de l'instruction à laquelle est rattaché le document |
3163 |
|
* @param integer $idNotification : id de la notification à laquelle on associe le document |
3164 |
|
* @param boolean $isAnnexe : indique si le document est une annexe ou pas |
3165 |
|
* |
3166 |
|
* @return boolean indique si le traitement a réussi |
3167 |
|
*/ |
3168 |
|
protected function ajouter_notification_document($idInstruction, $idNotification, $isAnnexe = false) { |
3169 |
|
$inst_notif_doc = $this->f->get_inst__om_dbform(array( |
3170 |
|
"obj" => "instruction_notification_document", |
3171 |
|
"idx" => "]", |
3172 |
|
)); |
3173 |
|
$notif_doc_val = array( |
3174 |
|
'instruction_notification_document' => null, |
3175 |
|
'instruction_notification' => $idNotification, |
3176 |
|
'instruction' => $idInstruction, |
3177 |
|
'cle' => $this->getCleAccesDocument(), |
3178 |
|
'annexe' => $isAnnexe |
3179 |
|
); |
3180 |
|
|
3181 |
|
$add_notif_doc = $inst_notif_doc->ajouter($notif_doc_val); |
3182 |
|
if ($add_notif_doc === false) { |
3183 |
|
return false; |
3184 |
|
} |
3185 |
|
return true; |
3186 |
|
} |
3187 |
|
|
3188 |
|
/** |
3189 |
|
* TRIGGER - triggermodifierapres. |
3190 |
|
* |
3191 |
|
* @return boolean |
3192 |
|
*/ |
3193 |
|
function triggermodifierapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
3194 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
3195 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite($val['dossier']); |
3196 |
|
$message = ''; |
3197 |
/** |
/** |
3198 |
* L'objectif ici est d'effectuer les recalculs de date dans le dossier |
* L'objectif ici est d'effectuer les recalculs de date dans le dossier |
3199 |
* si la date de l'evenement est modifiee |
* si la date de l'evenement est modifiee |
3200 |
*/ |
*/ |
3201 |
// Initialisation |
// Initialisation |
3202 |
$valF = ""; |
$valF = array(); |
3203 |
$valF_dt = ""; |
$valF_dt = array(); |
3204 |
// Initialisation du type d'événement |
// Initialisation du type d'événement |
3205 |
$type_evmt = ""; |
$type_evmt = ""; |
3206 |
// Récupération de l'action correspondante à l'événement |
// Récupération de l'action correspondante à l'événement |
3207 |
$sql = "SELECT action |
$sql = "SELECT action |
3208 |
FROM ".DB_PREFIXE."evenement |
FROM ".DB_PREFIXE."evenement |
3209 |
WHERE evenement=".$this->valF['evenement']; |
WHERE evenement=".$this->valF['evenement']; |
3210 |
$action = $db->getOne($sql); |
$action = $this->f->db->getOne($sql); |
3211 |
$this->addToLog("triggermodifierapres(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
3212 |
if (database::isError($action)) { |
if (database::isError($action)) { |
3213 |
die($action->getMessage()); |
die($action->getMessage()); |
3214 |
} |
} |
3216 |
// Récupération des paramètres de l'action |
// Récupération des paramètres de l'action |
3217 |
$sql = "SELECT * FROM ".DB_PREFIXE."action |
$sql = "SELECT * FROM ".DB_PREFIXE."action |
3218 |
WHERE action='".$action."'"; |
WHERE action='".$action."'"; |
3219 |
$res = $db->query($sql); |
$res = $this->f->db->query($sql); |
3220 |
$this->addToLog("triggermodifierapres(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
3221 |
if (database::isError($res)) { |
if (database::isError($res)) { |
3222 |
die($res->getMessage()); |
die($res->getMessage()); |
3223 |
} |
} |
3289 |
if ($row['regle_donnees_techniques5'] !== '') { |
if ($row['regle_donnees_techniques5'] !== '') { |
3290 |
$valF_dt[$row['cible_regle_donnees_techniques5']] = $this->regle($row['regle_donnees_techniques5'], 'regle_donnees_techniques5'); |
$valF_dt[$row['cible_regle_donnees_techniques5']] = $this->regle($row['regle_donnees_techniques5'], 'regle_donnees_techniques5'); |
3291 |
} |
} |
3292 |
|
if ($row['regle_dossier_instruction_type'] !== '') { |
3293 |
|
$valF['dossier_instruction_type'] = $this->regle($row['regle_dossier_instruction_type'], 'regle_dossier_instruction_type'); |
3294 |
|
} |
3295 |
} |
} |
3296 |
// 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 |
3297 |
if ($valF_dt != "") { |
if (count($valF_dt) > 0) { |
3298 |
$dt_id = $this->getDonneesTechniques(); |
$dt_id = $this->getDonneesTechniques(); |
3299 |
// On met à jour le dossier |
// On met à jour le dossier |
3300 |
$cle = " donnees_techniques='".$dt_id."'"; |
$cle = " donnees_techniques='".$dt_id."'"; |
3301 |
$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); |
3302 |
$this->addToLog("triggerajouterapres(): db->autoexecute(\"".DB_PREFIXE."donnees_techniques\", ".print_r($valF_dt, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->autoexecute(\"".DB_PREFIXE."donnees_techniques\", ".print_r($valF_dt, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
3303 |
if (database::isError($res1)) { |
if (database::isError($res1)) { |
3304 |
die($res->getMessage()); |
die($res->getMessage()); |
3305 |
} |
} |
3306 |
// Affichage d'informations à l'utilisateur |
// Affichage d'informations à l'utilisateur |
3307 |
$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')."]"); |
3308 |
} |
} |
3309 |
// 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 |
3310 |
if ($valF != "") { |
if (count($valF) > 0) { |
3311 |
// On met à jour le dossier |
// |
3312 |
$cle = " dossier='".$this->valF['dossier']."'"; |
$inst_dossier = $this->f->get_inst__om_dbform(array( |
3313 |
$res1 = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle); |
"obj" => "dossier", |
3314 |
$this->addToLog("triggermodifierapres(): db->autoexecute(\"".DB_PREFIXE."dossier\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
"idx" => $this->valF['dossier'], |
3315 |
if (database::isError($res1)) { |
)); |
3316 |
die($res->getMessage()); |
$valF['instruction'] = $id; |
3317 |
|
$valF['crud'] = 'update'; |
3318 |
|
$update_by_instruction = $inst_dossier->update_by_instruction($valF); |
3319 |
|
if ($update_by_instruction === false) { |
3320 |
|
$this->cleanMessage(); |
3321 |
|
$this->addToMessage(sprintf('%s %s', __("Une erreur s'est produite lors de la mise à jour du dossier d'instruction."), __("Veuillez contacter votre administrateur."))); |
3322 |
|
return false; |
3323 |
} |
} |
3324 |
// Affichage d'informations à l'utilisateur |
// Affichage d'informations à l'utilisateur |
3325 |
$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')."]"); |
3326 |
} |
} |
3327 |
|
|
3328 |
$restriction = $this->get_restriction($val['evenement']); |
$restriction = $this->get_restriction($val['evenement']); |
3332 |
// 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é |
3333 |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
3334 |
WHERE evenement=".$this->valF['evenement']; |
WHERE evenement=".$this->valF['evenement']; |
3335 |
$res = $db->query($sql); |
$res = $this->f->db->query($sql); |
3336 |
$this->addToLog("triggermodifierapres(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
3337 |
if (database::isError($res)) { |
if (database::isError($res)) { |
3338 |
die($res->getMessage()); |
die($res->getMessage()); |
3339 |
} |
} |
3343 |
if ($this->getVal('date_retour_signature') == "" AND |
if ($this->getVal('date_retour_signature') == "" AND |
3344 |
$this->valF['date_retour_signature'] != "" AND |
$this->valF['date_retour_signature'] != "" AND |
3345 |
$row['evenement_retour_signature'] != "") { |
$row['evenement_retour_signature'] != "") { |
3346 |
$new_instruction = new instruction("]", $db, $DEBUG); |
$new_instruction = $this->f->get_inst__om_dbform(array( |
3347 |
|
"obj" => "instruction", |
3348 |
|
"idx" => "]", |
3349 |
|
)); |
3350 |
// 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 |
3351 |
foreach($new_instruction->champs as $champ) { |
foreach($new_instruction->champs as $champ) { |
3352 |
$valNewInstr[$champ] = ""; |
$valNewInstr[$champ] = ""; |
3365 |
$new_instruction->setParameter("maj", 0); |
$new_instruction->setParameter("maj", 0); |
3366 |
$new_instruction->class_actions[0]["identifier"] = |
$new_instruction->class_actions[0]["identifier"] = |
3367 |
"retour signature de l'instruction $current_id"; |
"retour signature de l'instruction $current_id"; |
3368 |
$retour = $new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
$retour = $new_instruction->ajouter($valNewInstr); |
3369 |
|
|
3370 |
//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 |
3371 |
//de restriction |
//de restriction |
3372 |
if ($retour == false && !$new_instruction->restriction_valid){ |
if ($retour == false && !$new_instruction->restriction_valid){ |
3373 |
$error_message = $this->get_restriction_error_message($restriction); |
$error_message = $this->get_restriction_error_message($restriction); |
3374 |
$this->f->displayMessage("error", $error_message); |
$this->f->displayMessage("error", $error_message); |
3375 |
$this->addToLog("triggermodifierapres() : evenement retour ". |
$this->addToLog(__METHOD__."(): evenement retour ". |
3376 |
"instruction ".$this->valF[$this->clePrimaire]." : ". |
"instruction ".$this->valF[$this->clePrimaire]." : ". |
3377 |
$new_instruction->msg); |
$new_instruction->msg); |
3378 |
} |
} |
3388 |
$this->valF['date_retour_rar'] != "") { |
$this->valF['date_retour_rar'] != "") { |
3389 |
|
|
3390 |
if($row['evenement_retour_ar'] != "") { |
if($row['evenement_retour_ar'] != "") { |
3391 |
$new_instruction = new instruction("]", $db, $DEBUG); |
$new_instruction = $this->f->get_inst__om_dbform(array( |
3392 |
|
"obj" => "instruction", |
3393 |
|
"idx" => "]", |
3394 |
|
)); |
3395 |
// 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 |
3396 |
foreach($new_instruction->champs as $champ) { |
foreach($new_instruction->champs as $champ) { |
3397 |
$valNewInstr[$champ] = ""; |
$valNewInstr[$champ] = ""; |
3409 |
$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']); |
3410 |
$new_instruction->setParameter("maj", 0); |
$new_instruction->setParameter("maj", 0); |
3411 |
$new_instruction->class_actions[0]["identifier"] = |
$new_instruction->class_actions[0]["identifier"] = |
3412 |
"retour RAR de l'instruction $current_id"; |
"notification de l'instruction $current_id"; |
3413 |
$retour = $new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
$retour = $new_instruction->ajouter($valNewInstr); |
3414 |
|
|
3415 |
//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 |
3416 |
//de restriction |
//de restriction |
3418 |
$error_message = $this->get_restriction_error_message($restriction); |
$error_message = $this->get_restriction_error_message($restriction); |
3419 |
$this->f->displayMessage("error", $error_message); |
$this->f->displayMessage("error", $error_message); |
3420 |
$this->addToLog( |
$this->addToLog( |
3421 |
"triggermodifierapres() : evenement retour instruction ". |
__METHOD__."(): evenement retour instruction ". |
3422 |
$this->valF[$this->clePrimaire]." : ". |
$this->valF[$this->clePrimaire]." : ". |
3423 |
$new_instruction->msg |
$new_instruction->msg |
3424 |
); |
); |
3430 |
return false; |
return false; |
3431 |
} |
} |
3432 |
} |
} |
|
// Mise à jour du flag incomplet_notifie dans dossier si la |
|
|
// date limite d'instruction n'est pas dépassée |
|
|
if($row['type']=='incompletude' && |
|
|
($this->valF['archive_date_notification_delai'] >= $this->valF['date_retour_rar'] || |
|
|
$this->valF['archive_date_notification_delai'] == "")) { |
|
|
$valFIncomp['incomplet_notifie'] = true; |
|
|
$cle = " dossier='".$val['dossier']."'"; |
|
|
$resIncomp = $db->autoExecute( |
|
|
DB_PREFIXE.'dossier', |
|
|
$valFIncomp, |
|
|
DB_AUTOQUERY_UPDATE, |
|
|
$cle |
|
|
); |
|
|
$this->addToLog( |
|
|
"triggersupprimer(): db->autoexecute(\"". |
|
|
DB_PREFIXE."dossier\", ".print_r($valFIncomp, true). |
|
|
", DB_AUTOQUERY_UPDATE, \"".$cle."\");", |
|
|
VERBOSE_MODE |
|
|
); |
|
|
if (database::isError($resIncomp)) { |
|
|
die($resIncomp->getMessage()); |
|
|
} |
|
|
} |
|
3433 |
} |
} |
3434 |
} |
} |
3435 |
} |
} |
3436 |
|
|
3437 |
|
/** |
3438 |
|
* Mise à jour de la date de dernière modification du dossier |
3439 |
|
* d'instruction |
3440 |
|
*/ |
3441 |
|
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
3442 |
|
$inst_di->update_last_modification_date(); |
3443 |
|
|
3444 |
// Mise à jour des données du dossier d'autorisation |
// Mise à jour des données du dossier d'autorisation |
3445 |
require_once "../obj/dossier_autorisation.class.php"; |
$da = $this->f->get_inst__om_dbform(array( |
3446 |
$da = new dossier_autorisation($this->getNumDemandeAutorFromDossier($this->valF['dossier']), $this->db, DEBUG); |
"obj" => "dossier_autorisation", |
3447 |
if($da->majDossierAutorisation() === false) { |
"idx" => $this->getNumDemandeAutorFromDossier($this->valF['dossier']), |
3448 |
|
)); |
3449 |
|
$params = array( |
3450 |
|
'di_id' => $this->getVal('dossier'), |
3451 |
|
); |
3452 |
|
if($da->majDossierAutorisation($params) === false) { |
3453 |
$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.")); |
3454 |
$this->correct = false; |
$this->correct = false; |
3455 |
return false; |
return false; |
3456 |
} |
} |
3457 |
|
|
3458 |
|
// mise à jour des métadonnées issues des dates de suivi |
3459 |
|
$dateRetourSignatureModified = ($this->valF['date_retour_signature'] != $this->getVal('date_retour_signature')); |
3460 |
|
$dateRetourRARModified = ($this->valF['date_retour_rar'] != $this->getVal('date_retour_rar')); |
3461 |
|
if ($dateRetourSignatureModified || $dateRetourRARModified) { |
3462 |
|
|
3463 |
|
// Calculs des nouvelles métadonnées |
3464 |
|
$metadata = $this->getMetadata("om_fichier_instruction"); |
3465 |
|
|
3466 |
|
// On vérifie si l'instruction à finaliser a un événement de type arrete |
3467 |
|
$sql = "SELECT type FROM ".DB_PREFIXE."evenement WHERE evenement = ".$this->getVal("evenement"); |
3468 |
|
$typeEvenement = $this->f->db->getOne($sql); |
3469 |
|
$this->addToLog(__METHOD__."(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
3470 |
|
if ($this->f->isDatabaseError($typeEvenement, true) === true) { |
3471 |
|
$this->correct = false; |
3472 |
|
$this->addToMessage(__("Erreur de traitement de fichier.")); |
3473 |
|
$this->addToLog(__METHOD__."() erreur BDD: ".var_export($typeEvenement->getMessage(), true), DEBUG_MODE); |
3474 |
|
return false; |
3475 |
|
} |
3476 |
|
|
3477 |
|
// Si l'événement est de type arrete, on ajoute les métadonnées spécifiques |
3478 |
|
if ($typeEvenement == 'arrete'){ |
3479 |
|
$metadata = array_merge($metadata, $this->getMetadata("arrete")); |
3480 |
|
} |
3481 |
|
|
3482 |
|
// Filtre pour conserver uniquement les métadonnées liées aux dates |
3483 |
|
$metadataToKeep = array( |
3484 |
|
"statutAutorisation", |
3485 |
|
"dateEvenementDocument", |
3486 |
|
'date_cloture_metier', |
3487 |
|
"NotificationArrete", |
3488 |
|
"dateNotificationArrete", |
3489 |
|
"controleLegalite", |
3490 |
|
"dateSignature", |
3491 |
|
"nomSignataire", |
3492 |
|
"qualiteSignataire", |
3493 |
|
"dateControleLegalite", |
3494 |
|
); |
3495 |
|
$metadata = array_filter( |
3496 |
|
$metadata, |
3497 |
|
function($key) use ($metadataToKeep) { return in_array($key, $metadataToKeep); }, |
3498 |
|
ARRAY_FILTER_USE_KEY |
3499 |
|
); |
3500 |
|
|
3501 |
|
// Mise à jour des métadonnées du document en GED |
3502 |
|
$docUid = $this->getVal("om_fichier_instruction"); |
3503 |
|
$operationOrUID = $this->f->storage->update_metadata($docUid, $metadata); |
3504 |
|
if ($operationOrUID == 'OP_FAILURE') { |
3505 |
|
$this->correct = false; |
3506 |
|
$this->addToMessage(__("Erreur de traitement de fichier.")); |
3507 |
|
$this->addToLog(__METHOD__."() failed to update metadata: ".var_export($operationOrUID, true), DEBUG_MODE); |
3508 |
|
return false; |
3509 |
|
} |
3510 |
|
|
3511 |
|
// mise à jour de l'UID du document en BDD |
3512 |
|
else { |
3513 |
|
$valF = array('om_fichier_instruction' => $operationOrUID); |
3514 |
|
$res = $this->f->db->autoExecute(DB_PREFIXE.$this->table, $valF, DB_AUTOQUERY_UPDATE, $this->getCle($id)); |
3515 |
|
$this->addToLog(__METHOD__.'() : db->autoExecute("'.DB_PREFIXE.$this->table.'", '.print_r($valF, true).', DB_AUTOQUERY_UPDATE, "'.$this->getCle($id).'")', VERBOSE_MODE); |
3516 |
|
if ($this->f->isDatabaseError($res, true) === true) { |
3517 |
|
$this->correct = false; |
3518 |
|
$this->addToMessage(__("Erreur de traitement de fichier.")); |
3519 |
|
$this->addToLog(__METHOD__."() erreur BDD: ".var_export($res->getMessage(), true), DEBUG_MODE); |
3520 |
|
return false; |
3521 |
|
} |
3522 |
|
$this->addToMessage(__("La mise a jour du document s'est effectuee avec succes.")); |
3523 |
|
} |
3524 |
|
} |
3525 |
|
|
3526 |
|
// Notification auto des demandeurs |
3527 |
|
if ($dateRetourSignatureModified === true |
3528 |
|
&& $this->valF['date_retour_signature'] !== '' |
3529 |
|
&& $this->valF['date_retour_signature'] !== null) { |
3530 |
|
// |
3531 |
|
$ev = $this->get_inst_evenement($this->valF['evenement']); |
3532 |
|
if ($ev->getVal('notification') === 'notification_auto_signature_requise') { |
3533 |
|
// Récupération de la liste des demandeurs à notifier et de la catégorie |
3534 |
|
$categorie = $this->f->get_param_option_notification($collectivite_di); |
3535 |
|
$isPortal = $categorie == null || $categorie == '' || $categorie == 'portal' ? true : false; |
3536 |
|
$demandeursANotifie = $this->get_demandeurs_notifiable( |
3537 |
|
$this->valF['dossier'], |
3538 |
|
$isPortal |
3539 |
|
); |
3540 |
|
|
3541 |
|
// Création d'une notification et d'une tâche pour chaque demandeur à notifier |
3542 |
|
foreach ($demandeursANotifie as $demandeur) { |
3543 |
|
// Ajout de la notif et récupération de son id |
3544 |
|
$idNotif = $this->ajouter_notification( |
3545 |
|
$this->valF[$this->clePrimaire], |
3546 |
|
$this->f->get_connected_user_login_name(), |
3547 |
|
$demandeur, |
3548 |
|
$collectivite_di, |
3549 |
|
true |
3550 |
|
); |
3551 |
|
if ($idNotif === false) { |
3552 |
|
return false; |
3553 |
|
} |
3554 |
|
// Création de la tache en lui donnant l'id de la notification |
3555 |
|
$notification_by_task = $this->notification_by_task( |
3556 |
|
$idNotif, |
3557 |
|
$this->valF['dossier'], |
3558 |
|
$categorie |
3559 |
|
); |
3560 |
|
if ($notification_by_task === false) { |
3561 |
|
$this->addToMessage( |
3562 |
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
3563 |
|
); |
3564 |
|
return false; |
3565 |
|
} |
3566 |
|
} |
3567 |
|
$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."))); |
3568 |
|
} |
3569 |
|
} |
3570 |
|
|
3571 |
return $this->add_log_to_dossier($id, $val); |
return $this->add_log_to_dossier($id, $val); |
3572 |
} |
} |
3573 |
|
|
3574 |
function triggersupprimer($id, &$db = null, $val = array(), $DEBUG = null) { |
/** |
3575 |
|
* TRIGGER - triggersupprimer. |
3576 |
|
* |
3577 |
|
* @return boolean |
3578 |
|
*/ |
3579 |
|
function triggersupprimer($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
3580 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
3581 |
/** |
/** |
3582 |
* 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 |
3583 |
* archive dans le dossier d'instruction avant de supprimer l'événement |
* archive dans le dossier d'instruction avant de supprimer l'événement |
3584 |
* d'instruction |
* d'instruction si les valeurs du dossier sont différentes |
3585 |
*/ |
*/ |
3586 |
|
$valF = array(); |
3587 |
// Mise à jour des 4 valeurs modifiées par l'action |
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
3588 |
$valF['delai'] = $val['archive_delai']; |
foreach ($inst_di->champs as $key => $champ) { |
3589 |
$valF['accord_tacite'] = $val['archive_accord_tacite']; |
// Si le champ du DI à une archive dans l'instruction |
3590 |
$valF['etat'] = $val['archive_etat']; |
if (isset($val[sprintf('archive_%s', $champ)]) === true) { |
3591 |
if ($val['archive_avis'] != '') { |
// Si la valeur entre le champ du DI et son archive dans instruction |
3592 |
$valF['avis_decision'] = $val['archive_avis']; |
// est différente |
3593 |
} else { |
if ($inst_di->getVal($champ) !== $val[sprintf('archive_%s', $champ)]) { |
3594 |
$valF['avis_decision'] = null; |
$val[sprintf('archive_%s', $champ)] === '' ? $valF[$champ] = null : $valF[$champ] = $val[sprintf('archive_%s', $champ)]; |
3595 |
} |
} |
3596 |
// 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; |
|
3597 |
} |
} |
3598 |
$valF['date_cloture_instruction'] = null; |
// Spécificité du champ avis_decision dont le champ archive est nommé |
3599 |
if ($val['archive_date_cloture_instruction'] !== '') { |
// différemment |
3600 |
$valF['date_cloture_instruction'] = $val['archive_date_cloture_instruction']; |
if ($inst_di->getVal('avis_decision') !== $val['archive_avis']) { |
3601 |
|
$val['archive_avis'] === '' ? $valF['avis_decision'] = null : $valF['avis_decision'] = $val['archive_avis']; |
3602 |
|
} |
3603 |
|
// Spécificité de la date d'affichage dont la valeur n'ai jamais modifiée |
3604 |
|
// par l'archive |
3605 |
|
unset($valF['date_affichage']); |
3606 |
|
|
3607 |
|
/** |
3608 |
|
* Mise à jour de la version de clôture *version_clos* du dossier si et |
3609 |
|
* seulement si l'instruction met à jour l'état du dossier. |
3610 |
|
*/ |
3611 |
|
if (isset($valF['etat']) === true |
3612 |
|
&& $valF['etat'] !== null |
3613 |
|
&& $valF['etat'] !== '') { |
3614 |
|
// Récupère l'état actuel du dossier d'instruction |
3615 |
|
$inst_current_etat = $this->f->get_inst__om_dbform(array( |
3616 |
|
"obj" => "etat", |
3617 |
|
"idx" => $inst_di->get_id_etat(), |
3618 |
|
)); |
3619 |
|
// Instanciation de l'état archivé appliqué sur le dossier |
3620 |
|
$inst_etat = $this->f->get_inst__om_dbform(array( |
3621 |
|
"obj" => "etat", |
3622 |
|
"idx" => $valF['etat'], |
3623 |
|
)); |
3624 |
|
// |
3625 |
|
$update_version_clos = null; |
3626 |
|
// En cas de clôture du dossier par l'état archivé |
3627 |
|
if ($inst_etat->getVal('statut') === 'cloture') { |
3628 |
|
$update_version_clos = $inst_di->update_version_clos('up'); |
3629 |
|
} |
3630 |
|
// En cas de réouverture du dossier par l'état archivé |
3631 |
|
if ($inst_current_etat->getVal('statut') === 'cloture' |
3632 |
|
&& $inst_etat->getVal('statut') !== 'cloture') { |
3633 |
|
// |
3634 |
|
$update_version_clos = $inst_di->update_version_clos('down'); |
3635 |
|
// |
3636 |
|
$this->set_att_di_reopened(true); |
3637 |
|
} |
3638 |
|
// |
3639 |
|
if ($update_version_clos === false) { |
3640 |
|
$this->f->addToLog(sprintf( |
3641 |
|
"%s() : ERREUR - %s %s", |
3642 |
|
__METHOD__, |
3643 |
|
sprintf( |
3644 |
|
__("Impossible de mettre à jour la version de clôture du dossier d'instruction %s."), |
3645 |
|
$inst_di->getVal($inst_di->clePrimaire) |
3646 |
|
), |
3647 |
|
sprintf( |
3648 |
|
__("L'instruction tente d'appliquer l'état %s."), |
3649 |
|
$inst_etat->getVal($inst_etat->clePrimaire) |
3650 |
|
) |
3651 |
|
)); |
3652 |
|
$this->addToMessage(sprintf( |
3653 |
|
"%s %s", |
3654 |
|
__("Erreur lors de la mise à jour de la version de clôture du dossier d'instruction."), |
3655 |
|
__("Veuillez contacter votre administrateur.") |
3656 |
|
)); |
3657 |
|
return false; |
3658 |
|
} |
3659 |
} |
} |
3660 |
// Dates concernant les dossiers contentieux |
// On supprime toutes les notications liées à l'instruction |
3661 |
// Date de première visite |
$notifASupprimer = $this->get_instruction_notification($this->getVal($this->clePrimaire)); |
3662 |
$valF['date_premiere_visite'] = null; |
foreach ($notifASupprimer as $idNotif) { |
3663 |
if ($val['archive_date_premiere_visite'] !== '') { |
$inst_notif = $this->f->get_inst__om_dbform(array( |
3664 |
$valF['date_premiere_visite'] = $val['archive_date_premiere_visite']; |
"obj" => "instruction_notification", |
3665 |
} |
"idx" => $idNotif, |
3666 |
// Date de dernière visite |
)); |
3667 |
$valF['date_derniere_visite'] = null; |
$val_notif = array(); |
3668 |
if ($val['archive_date_derniere_visite'] !== '') { |
foreach ($inst_notif->champs as $champ) { |
3669 |
$valF['date_derniere_visite'] = $val['archive_date_derniere_visite']; |
$val_notif[$champ] = $inst_notif->getVal($champ); |
3670 |
} |
} |
3671 |
// Date contradictoire |
// La suppression des notifications entrainera la suppression des tâches qui y sont |
3672 |
$valF['date_contradictoire'] = null; |
// liées |
3673 |
if ($val['archive_date_contradictoire'] !== '') { |
$supprNotif = $inst_notif->supprimer($val_notif); |
3674 |
$valF['date_contradictoire'] = $val['archive_date_contradictoire']; |
if ($supprNotif == false) { |
3675 |
} |
$this->addToMessage(sprintf( |
3676 |
// Date de retour contradictoire |
"%s %s", |
3677 |
$valF['date_retour_contradictoire'] = null; |
__("Erreur lors de la suppression des notifications de l'instruction."), |
3678 |
if ($val['archive_date_retour_contradictoire'] !== '') { |
__("Veuillez contacter votre administrateur.") |
3679 |
$valF['date_retour_contradictoire'] = $val['archive_date_retour_contradictoire']; |
)); |
3680 |
} |
return false; |
3681 |
// Date de l'AIT |
} |
|
$valF['date_ait'] = null; |
|
|
if ($val['archive_date_ait'] !== '') { |
|
|
$valF['date_ait'] = $val['archive_date_ait']; |
|
|
} |
|
|
// Date de transmission au parquet |
|
|
$valF['date_transmission_parquet'] = null; |
|
|
if ($val['archive_date_transmission_parquet'] !== '') { |
|
|
$valF['date_transmission_parquet'] = $val['archive_date_transmission_parquet']; |
|
3682 |
} |
} |
3683 |
|
|
3684 |
// On met à jour le dossier |
// On met à jour le dossier |
3685 |
$cle = " dossier='".$val['dossier']."'"; |
$valF['instruction'] = $id; |
3686 |
$res = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle); |
$valF['crud'] = 'delete'; |
3687 |
$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); |
3688 |
if (database::isError($res)) { |
if ($update_by_instruction === false) { |
3689 |
die($res->getMessage()); |
$this->cleanMessage(); |
3690 |
|
$this->addToMessage(sprintf('%s %s', __("Une erreur s'est produite lors de la mise à jour du dossier d'instruction."), __("Veuillez contacter votre administrateur."))); |
3691 |
|
return false; |
3692 |
} |
} |
3693 |
|
|
3694 |
// Affichage d'informations à l'utilisateur |
// Affichage d'informations à l'utilisateur |
3695 |
$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')."]"); |
3696 |
|
|
3697 |
// 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 |
3698 |
} |
} |
3699 |
|
|
3700 |
function triggersupprimerapres($id, &$db = null, $val = array(), $DEBUG = null) { |
/** |
3701 |
|
* TRIGGER - triggersupprimerapres. |
3702 |
|
* |
3703 |
|
* @return boolean |
3704 |
|
*/ |
3705 |
|
function triggersupprimerapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
3706 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
3707 |
|
/** |
3708 |
|
* Mise à jour de la date de dernière modification du dossier |
3709 |
|
* d'instruction |
3710 |
|
*/ |
3711 |
|
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
3712 |
|
$inst_di->update_last_modification_date(); |
3713 |
|
|
3714 |
// Mise à jour des données du dossier d'autorisation |
/** |
3715 |
require_once "../obj/dossier_autorisation.class.php"; |
* Mise à jour des données du dossier d'autorisation |
3716 |
$da = new dossier_autorisation($this->getNumDemandeAutorFromDossier($val["dossier"]), $this->db, DEBUG); |
*/ |
3717 |
if($da->majDossierAutorisation() === false) { |
$da = $this->f->get_inst__om_dbform(array( |
3718 |
|
"obj" => "dossier_autorisation", |
3719 |
|
"idx" => $this->getNumDemandeAutorFromDossier($val["dossier"]), |
3720 |
|
)); |
3721 |
|
$params = array( |
3722 |
|
'di_id' => $this->getVal('dossier'), |
3723 |
|
'di_reopened' => $this->get_att_di_reopened(), |
3724 |
|
); |
3725 |
|
if($da->majDossierAutorisation($params) === false) { |
3726 |
$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.")); |
3727 |
$this->correct = false; |
$this->correct = false; |
3728 |
return false; |
return false; |
3729 |
} |
} |
3730 |
|
|
3731 |
|
/** |
3732 |
|
* Gestion des tâches pour la dématérialisation |
3733 |
|
*/ |
3734 |
|
$inst_task_empty = $this->f->get_inst__om_dbform(array( |
3735 |
|
"obj" => "task", |
3736 |
|
"idx" => 0, |
3737 |
|
)); |
3738 |
|
foreach ($inst_di->task_types as $task_type) { |
3739 |
|
$task_exists = $inst_task_empty->task_exists($task_type, $id); |
3740 |
|
if ($task_exists !== false) { |
3741 |
|
$inst_task = $this->f->get_inst__om_dbform(array( |
3742 |
|
"obj" => "task", |
3743 |
|
"idx" => $task_exists, |
3744 |
|
)); |
3745 |
|
if ($inst_task->getVal('state') === $inst_task::STATUS_NEW || $inst_task->getVal('state') === $inst_task::STATUS_DRAFT) { |
3746 |
|
$task_val = array( |
3747 |
|
'state' => $inst_task::STATUS_CANCELED, |
3748 |
|
); |
3749 |
|
$update_task = $inst_task->update_task(array('val' => $task_val)); |
3750 |
|
if ($update_task === false) { |
3751 |
|
$this->addToMessage(sprintf('%s %s', |
3752 |
|
sprintf(__("Une erreur s'est produite lors de la modification de la tâche %."), $inst_task->getVal($inst_task->clePrimaire)), |
3753 |
|
__("Veuillez contacter votre administrateur.") |
3754 |
|
)); |
3755 |
|
$this->correct = false; |
3756 |
|
return false; |
3757 |
|
} |
3758 |
|
} |
3759 |
|
} |
3760 |
|
} |
3761 |
|
|
3762 |
|
// |
3763 |
$val['evenement'] = $this->getVal('evenement'); |
$val['evenement'] = $this->getVal('evenement'); |
3764 |
return $this->add_log_to_dossier($id, $val); |
return $this->add_log_to_dossier($id, $val); |
3765 |
} |
} |
3766 |
|
|
3767 |
/** |
/** |
3768 |
|
* Permet de mettre la valeur passée en paramètre dans l'attribut de classe |
3769 |
|
* "di_reopened". |
3770 |
|
* |
3771 |
|
* @param boolean $val |
3772 |
|
*/ |
3773 |
|
function set_att_di_reopened($val) { |
3774 |
|
$this->di_reopened = $val; |
3775 |
|
} |
3776 |
|
|
3777 |
|
/** |
3778 |
|
* Permet de récupérer la valeur de l'attribut de classe "di_reopened". |
3779 |
|
* |
3780 |
|
* @return boolean |
3781 |
|
*/ |
3782 |
|
function get_att_di_reopened() { |
3783 |
|
return $this->di_reopened; |
3784 |
|
} |
3785 |
|
|
3786 |
|
/** |
3787 |
* Permet de composer un message d'erreur sur restriction non valide en |
* Permet de composer un message d'erreur sur restriction non valide en |
3788 |
* fonction du contexte. |
* fonction du contexte. |
3789 |
* |
* |
3822 |
} |
} |
3823 |
|
|
3824 |
/** |
/** |
3825 |
* Vérifie la restriction sur l'événement. |
* @return void |
|
* |
|
|
* @param array $val valeurs du formulaire |
|
|
* @param database $db handler database |
|
|
* @param boolean $DEBUG NA |
|
|
* |
|
|
* @return [type] [description] |
|
3826 |
*/ |
*/ |
3827 |
function verifier($val = array(), &$db = null, $DEBUG = null) { |
function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
3828 |
parent::verifier($val, $db, $DEBUG); |
parent::verifier($val); |
3829 |
|
// |
3830 |
if ( isset($val['evenement']) && is_numeric($val['evenement'])){ |
if ( isset($val['evenement']) && is_numeric($val['evenement'])){ |
3831 |
$restriction = $this->get_restriction($val['evenement']); |
$restriction = $this->get_restriction($val['evenement']); |
3832 |
|
|
3935 |
|
|
3936 |
// |
// |
3937 |
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
3938 |
|
|
3939 |
|
// |
3940 |
|
$params = array( |
3941 |
|
"specific" => array(), |
3942 |
|
); |
3943 |
|
// Si la rédaction libre est activée sur l'instruction |
3944 |
|
if ($this->getVal("flag_edition_integrale") == 't') { |
3945 |
|
$params["specific"]["corps"] = array( |
3946 |
|
"mode" => "set", |
3947 |
|
"value" => $this->getVal("corps_om_htmletatex"), |
3948 |
|
); |
3949 |
|
$params["specific"]["titre"] = array( |
3950 |
|
"mode" => "set", |
3951 |
|
"value" => $this->getVal("titre_om_htmletat"), |
3952 |
|
); |
3953 |
|
} |
3954 |
// Génération du PDF |
// Génération du PDF |
3955 |
$result = $this->compute_pdf_output('lettretype', $this->getVal('lettretype'), $collectivite); |
$result = $this->compute_pdf_output('lettretype', $this->getVal('lettretype'), $collectivite, null, $params); |
3956 |
$pdf_output = $result['pdf_output']; |
$pdf_output = $result['pdf_output']; |
3957 |
|
|
3958 |
//Métadonnées du document |
//Métadonnées du document |
3959 |
$metadata = array( |
$metadata = array( |
3960 |
'filename' => 'instruction_'.$id_inst.'.pdf', |
'filename' => 'instruction_'.$id_inst.'.pdf', |
3969 |
$sql = "SELECT type |
$sql = "SELECT type |
3970 |
FROM ".DB_PREFIXE."evenement |
FROM ".DB_PREFIXE."evenement |
3971 |
WHERE evenement = ".$this->getVal("evenement"); |
WHERE evenement = ".$this->getVal("evenement"); |
3972 |
$typeEvenement = $this->db->getOne($sql); |
$typeEvenement = $this->f->db->getOne($sql); |
3973 |
$this->addToLog(__METHOD__."(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
3974 |
if ($this->f->isDatabaseError($typeEvenement, true) === true) { |
if ($this->f->isDatabaseError($typeEvenement, true) === true) { |
3975 |
$this->correct = false; |
$this->correct = false; |
3986 |
|
|
3987 |
$metadata = array_merge($metadata, $spe_metadata, $arrete_metadata); |
$metadata = array_merge($metadata, $spe_metadata, $arrete_metadata); |
3988 |
|
|
3989 |
|
/* |
3990 |
|
// transforme le tableau de métadonnées en objet |
3991 |
|
$mdf = new MetadataFactory(); |
3992 |
|
$md = $mdf->build('Instruction', $metadata); |
3993 |
|
*/ |
3994 |
|
|
3995 |
// Si le document a déjà été finalisé on le met à jour |
// Si le document a déjà été finalisé on le met à jour |
3996 |
// en conservant son UID |
// en conservant son UID |
3997 |
if ($this->getVal("om_fichier_instruction") != ''){ |
if ($this->getVal("om_fichier_instruction") != ''){ |
4000 |
} |
} |
4001 |
// 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 |
4002 |
else { |
else { |
4003 |
$uid = $this->f->storage->create($pdf_output, $metadata); |
$uid = $this->f->storage->create($pdf_output, $metadata, "from_content", $this->table.".om_fichier_instruction"); |
4004 |
} |
} |
4005 |
} |
} |
4006 |
|
|
4017 |
if ($uid == '' || $uid == 'OP_FAILURE' ) { |
if ($uid == '' || $uid == 'OP_FAILURE' ) { |
4018 |
$this->correct = false; |
$this->correct = false; |
4019 |
$this->addToMessage($file_msg_error); |
$this->addToMessage($file_msg_error); |
4020 |
$this->addToLog(sprintf($log_msg_error, $id_inst, $uid)); |
$this->addToLog(sprintf($log_msg_error, $id_inst, $uid), DEBUG_MODE); |
4021 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
4022 |
} |
} |
4023 |
|
|
4054 |
$val['archive_date_retour_contradictoire'] = $this->dateDBToForm($val['archive_date_retour_contradictoire']); |
$val['archive_date_retour_contradictoire'] = $this->dateDBToForm($val['archive_date_retour_contradictoire']); |
4055 |
$val['archive_date_ait'] = $this->dateDBToForm($val['archive_date_ait']); |
$val['archive_date_ait'] = $this->dateDBToForm($val['archive_date_ait']); |
4056 |
$val['archive_date_transmission_parquet'] = $this->dateDBToForm($val['archive_date_transmission_parquet']); |
$val['archive_date_transmission_parquet'] = $this->dateDBToForm($val['archive_date_transmission_parquet']); |
4057 |
|
$val['archive_date_affichage'] = $this->dateDBToForm($val['archive_date_affichage']); |
4058 |
$this->setvalF($val); |
$this->setvalF($val); |
4059 |
|
|
4060 |
// Verification de la validite des donnees |
// Verification de la validite des donnees |
4061 |
$this->verifier($this->val, $this->db, DEBUG); |
$this->verifier($this->val); |
4062 |
// Si les verifications precedentes sont correctes, on procede a |
// Si les verifications precedentes sont correctes, on procede a |
4063 |
// la modification, sinon on ne fait rien et on retourne une erreur |
// la modification, sinon on ne fait rien et on retourne une erreur |
4064 |
if ($this->correct === true) { |
if ($this->correct === true) { |
4092 |
|
|
4093 |
// Execution de la requête de modification des donnees de l'attribut |
// Execution de la requête de modification des donnees de l'attribut |
4094 |
// valF de l'objet dans l'attribut table de l'objet |
// valF de l'objet dans l'attribut table de l'objet |
4095 |
$res = $this->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
$res = $this->f->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
4096 |
DB_AUTOQUERY_UPDATE, $this->getCle($id_inst)); |
DB_AUTOQUERY_UPDATE, $this->getCle($id_inst)); |
4097 |
$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); |
4098 |
// |
// |
4113 |
} |
} |
4114 |
// L'appel de verifier() a déjà positionné correct à false |
// L'appel de verifier() a déjà positionné correct à false |
4115 |
// et défini un message d'erreur. |
// et défini un message d'erreur. |
4116 |
$this->addToLog(sprintf($log_msg_error, $id_inst, $uid)); |
$this->addToLog(sprintf($log_msg_error, $id_inst, $uid), DEBUG_MODE); |
4117 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
4118 |
} |
} |
4119 |
|
|
4121 |
* 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 |
4122 |
* @return string numéro de dossier d'instruction |
* @return string numéro de dossier d'instruction |
4123 |
*/ |
*/ |
4124 |
protected function getDossier() { |
protected function getDossier($champ = null) { |
4125 |
if(empty($this->specificMetadata)) { |
if(empty($this->specificMetadata)) { |
4126 |
$this->getSpecificMetadata(); |
$this->getSpecificMetadata(); |
4127 |
} |
} |
4220 |
// Requête sql |
// Requête sql |
4221 |
$sql = "SELECT libelle FROM ".DB_PREFIXE."evenement |
$sql = "SELECT libelle FROM ".DB_PREFIXE."evenement |
4222 |
WHERE evenement=".$evenement; |
WHERE evenement=".$evenement; |
4223 |
$evenement_libelle = $this->db->getOne($sql); |
$evenement_libelle = $this->f->db->getOne($sql); |
4224 |
$this->addToLog("getTitle(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog("getTitle(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
4225 |
if (database::isError($evenement_libelle)) { |
if (database::isError($evenement_libelle)) { |
4226 |
die(); |
die(); |
4282 |
LEFT JOIN ".DB_PREFIXE."groupe |
LEFT JOIN ".DB_PREFIXE."groupe |
4283 |
ON dossier_autorisation_type.groupe = groupe.groupe |
ON dossier_autorisation_type.groupe = groupe.groupe |
4284 |
WHERE dossier.dossier = '".$dossier."'"; |
WHERE dossier.dossier = '".$dossier."'"; |
4285 |
$res = $this->db->query($sql); |
$res = $this->f->db->query($sql); |
4286 |
$this->f->addToLog("getSpecificMetadata() : db->query(".$sql.")", VERBOSE_MODE); |
$this->f->addToLog("getSpecificMetadata() : db->query(".$sql.")", VERBOSE_MODE); |
4287 |
if ( database::isError($res)){ |
if ( database::isError($res)){ |
4288 |
die(); |
die(); |
4327 |
ON |
ON |
4328 |
dossier.etat = etat.etat |
dossier.etat = etat.etat |
4329 |
WHERE dossier ='".$idx."'"; |
WHERE dossier ='".$idx."'"; |
4330 |
$statut = $this->db->getOne($sql); |
$statut = $this->f->db->getOne($sql); |
4331 |
$this->f->addToLog("getStatutAutorisationDossier() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog("getStatutAutorisationDossier() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
4332 |
if ( database::isError($statut)){ |
if ( database::isError($statut)){ |
4333 |
die(); |
die(); |
4348 |
// 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 |
4349 |
$sql = "SELECT * FROM ".DB_PREFIXE."dossier |
$sql = "SELECT * FROM ".DB_PREFIXE."dossier |
4350 |
WHERE dossier='".$this->valF['dossier']."'"; |
WHERE dossier='".$this->valF['dossier']."'"; |
4351 |
$res = $this->db->query($sql); |
$res = $this->f->db->query($sql); |
4352 |
$this->addToLog("get_dossier_actual(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog("get_dossier_actual(): db->query(\"".$sql."\");", VERBOSE_MODE); |
4353 |
$this->f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
4354 |
|
|
4381 |
$return['archive_date_limite_incompletude'] = $row['date_limite_incompletude']; |
$return['archive_date_limite_incompletude'] = $row['date_limite_incompletude']; |
4382 |
$return['archive_delai_incompletude'] = $row['delai_incompletude']; |
$return['archive_delai_incompletude'] = $row['delai_incompletude']; |
4383 |
$return['archive_autorite_competente'] = $row['autorite_competente']; |
$return['archive_autorite_competente'] = $row['autorite_competente']; |
4384 |
|
$return['archive_dossier_instruction_type'] = $row['dossier_instruction_type']; |
4385 |
$return['duree_validite'] = $row['duree_validite']; |
$return['duree_validite'] = $row['duree_validite']; |
4386 |
$return['date_depot'] = $row['date_depot']; |
$return['date_depot'] = $row['date_depot']; |
4387 |
|
$return['date_depot_mairie'] = $row['date_depot_mairie']; |
4388 |
$return['archive_date_cloture_instruction'] = $row['date_cloture_instruction']; |
$return['archive_date_cloture_instruction'] = $row['date_cloture_instruction']; |
4389 |
$return['archive_date_premiere_visite'] = $row['date_premiere_visite']; |
$return['archive_date_premiere_visite'] = $row['date_premiere_visite']; |
4390 |
$return['archive_date_derniere_visite'] = $row['date_derniere_visite']; |
$return['archive_date_derniere_visite'] = $row['date_derniere_visite']; |
4392 |
$return['archive_date_retour_contradictoire'] = $row['date_retour_contradictoire']; |
$return['archive_date_retour_contradictoire'] = $row['date_retour_contradictoire']; |
4393 |
$return['archive_date_ait'] = $row['date_ait']; |
$return['archive_date_ait'] = $row['date_ait']; |
4394 |
$return['archive_date_transmission_parquet'] = $row['date_transmission_parquet']; |
$return['archive_date_transmission_parquet'] = $row['date_transmission_parquet']; |
4395 |
|
$return['archive_date_affichage'] = $row['date_affichage']; |
4396 |
|
$return['archive_pec_metier'] = $row['pec_metier']; |
4397 |
|
$return['archive_a_qualifier'] = $row['a_qualifier']; |
4398 |
} |
} |
4399 |
|
|
4400 |
// Retour de la fonction |
// Retour de la fonction |
4422 |
ON instruction.evenement = evenement.evenement |
ON instruction.evenement = evenement.evenement |
4423 |
WHERE instruction.instruction = $idx"; |
WHERE instruction.instruction = $idx"; |
4424 |
$this->f->addToLog("checkEvenementNonVerrouillable() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog("checkEvenementNonVerrouillable() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
4425 |
$res = $this->db->getOne($sql); |
$res = $this->f->db->getOne($sql); |
4426 |
$this->f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
4427 |
|
|
4428 |
// Si le retour de la requête est true |
// Si le retour de la requête est true |
4510 |
if ($row['date_depot'] != '') { |
if ($row['date_depot'] != '') { |
4511 |
$this->valF['date_depot']= $row['date_depot']; |
$this->valF['date_depot']= $row['date_depot']; |
4512 |
} |
} |
4513 |
|
if ($row['date_depot_mairie'] != '') { |
4514 |
|
$this->valF['date_depot_mairie']= $row['date_depot_mairie']; |
4515 |
|
} |
4516 |
// Dates concernant les dossiers contentieux |
// Dates concernant les dossiers contentieux |
4517 |
if ($row['date_cloture_instruction'] != '') { |
if ($row['date_cloture_instruction'] != '') { |
4518 |
$this->valF['archive_date_cloture_instruction']= $row['date_cloture_instruction']; |
$this->valF['archive_date_cloture_instruction']= $row['date_cloture_instruction']; |
4535 |
if ($row['date_transmission_parquet'] != '') { |
if ($row['date_transmission_parquet'] != '') { |
4536 |
$this->valF['archive_date_transmission_parquet']= $row['date_transmission_parquet']; |
$this->valF['archive_date_transmission_parquet']= $row['date_transmission_parquet']; |
4537 |
} |
} |
4538 |
|
// |
4539 |
|
if ($row['dossier_instruction_type'] != '') { |
4540 |
|
$this->valF['archive_dossier_instruction_type']= $row['dossier_instruction_type']; |
4541 |
|
} |
4542 |
|
if ($row['date_affichage'] != '') { |
4543 |
|
$this->valF['archive_date_affichage']= $row['date_affichage']; |
4544 |
|
} |
4545 |
|
if (isset($row['pec_metier']) === true && $row['pec_metier'] != '') { |
4546 |
|
$this->valF['archive_pec_metier']= $row['pec_metier']; |
4547 |
|
} |
4548 |
|
if (isset($row['a_qualifier']) === true && $row['a_qualifier'] != '') { |
4549 |
|
$this->valF['archive_a_qualifier']= $row['a_qualifier']; |
4550 |
|
} |
4551 |
} |
} |
4552 |
|
|
4553 |
// {{{ |
// {{{ |
4679 |
"datecontrolelegalite"=>"", "ap_numrue"=>"", "ap_nomdelavoie"=>"", |
"datecontrolelegalite"=>"", "ap_numrue"=>"", "ap_nomdelavoie"=>"", |
4680 |
"ap_codepostal"=>"", "ap_ville"=>""); |
"ap_codepostal"=>"", "ap_ville"=>""); |
4681 |
|
|
4682 |
$sqlArrete = "SELECT signataire_arrete.nom as \"nomsignataire\", |
$sqlArrete = "SELECT |
4683 |
|
signataire_arrete.prenom || ' ' ||signataire_arrete.nom as \"nomsignataire\", |
4684 |
signataire_arrete.qualite as \"qualitesignataire\", |
signataire_arrete.qualite as \"qualitesignataire\", |
4685 |
instruction.etat as \"decisionarrete\", |
instruction.etat as \"decisionarrete\", |
4686 |
instruction.date_retour_rar as \"datenotification\", |
instruction.date_retour_rar as \"datenotification\", |
4698 |
LEFT JOIN ".DB_PREFIXE."donnees_techniques ON |
LEFT JOIN ".DB_PREFIXE."donnees_techniques ON |
4699 |
donnees_techniques.dossier_instruction = dossier.dossier |
donnees_techniques.dossier_instruction = dossier.dossier |
4700 |
WHERE instruction.instruction = ".$this->getVal("instruction"); |
WHERE instruction.instruction = ".$this->getVal("instruction"); |
4701 |
$resArrete = $this->db->query($sqlArrete); |
$resArrete = $this->f->db->query($sqlArrete); |
4702 |
$this->f->addToLog("getArreteMetadata(): db->query(\"".$sqlArrete."\");", VERBOSE_MODE); |
$this->f->addToLog("getArreteMetadata(): db->query(\"".$sqlArrete."\");", VERBOSE_MODE); |
4703 |
if ( database::isError($resArrete)){ |
if ( database::isError($resArrete)){ |
4704 |
die(); |
die(); |
4728 |
} |
} |
4729 |
|
|
4730 |
/** |
/** |
4731 |
|
* CONDITION - is_modifiable. |
4732 |
|
* |
4733 |
|
* Controle si l'évenement est modifiable. |
4734 |
|
* |
4735 |
|
* @return boolean |
4736 |
|
*/ |
4737 |
|
function is_evenement_modifiable() { |
4738 |
|
$evenement = $this->get_inst_evenement($this->getVal('evenement')); |
4739 |
|
return ! $this->get_boolean_from_pgsql_value($evenement->getVal('non_modifiable')); |
4740 |
|
} |
4741 |
|
|
4742 |
|
/** |
4743 |
* CONDITION - is_editable. |
* CONDITION - is_editable. |
4744 |
* |
* |
4745 |
* Condition pour la modification. |
* Condition pour la modification. |
4747 |
* @return boolean |
* @return boolean |
4748 |
*/ |
*/ |
4749 |
function is_editable() { |
function is_editable() { |
4750 |
|
|
4751 |
|
// XXX |
4752 |
|
// 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é) |
4753 |
|
// Si cette tâche identifiée est DONE alors la suppression/modification de cette intruction est impossible |
4754 |
|
|
4755 |
// Contrôle si l'utilisateur possède un bypass |
// Contrôle si l'utilisateur possède un bypass |
4756 |
$bypass = $this->f->isAccredited(get_class($this)."_modifier_bypass"); |
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_modifier_bypass"); |
4757 |
// |
// |
4758 |
if ($bypass == true) { |
if ($bypass == true) { |
4759 |
// |
// |
4776 |
return true; |
return true; |
4777 |
} |
} |
4778 |
|
|
|
// 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; |
|
|
} |
|
|
|
|
4779 |
// Si l'utilisateur est instructeur de la commune du dossier et que |
// Si l'utilisateur est instructeur de la commune du dossier et que |
4780 |
// l'instruction est créée par un instructeur de la commune |
// l'instruction est créée par un instructeur de la commune |
4781 |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
4788 |
} |
} |
4789 |
|
|
4790 |
/** |
/** |
4791 |
|
* Vérifie si l'événement est supprimable ou pas. |
4792 |
|
* |
4793 |
|
* @return boolean |
4794 |
|
*/ |
4795 |
|
function is_evenement_supprimable() { |
4796 |
|
// Controle si l'évenement est supprimable |
4797 |
|
$evenement = $this->get_inst_evenement($this->getVal('evenement')); |
4798 |
|
return ! $this->get_boolean_from_pgsql_value($evenement->getVal('non_supprimable')); |
4799 |
|
} |
4800 |
|
|
4801 |
|
/** |
4802 |
* CONDITION - is_deletable. |
* CONDITION - is_deletable. |
4803 |
* |
* |
4804 |
* Condition pour la suppression. |
* Condition pour la suppression. |
4806 |
* @return boolean |
* @return boolean |
4807 |
*/ |
*/ |
4808 |
function is_deletable() { |
function is_deletable() { |
4809 |
|
|
4810 |
|
// XXX |
4811 |
|
// 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é) |
4812 |
|
// Si cette tâche identifiée est DONE alors la suppression/modification de cette intruction est impossible |
4813 |
|
|
4814 |
// Contrôle si l'utilisateur possède un bypass intégral |
// Contrôle si l'utilisateur possède un bypass intégral |
4815 |
$bypass = $this->f->isAccredited(get_class($this)."_supprimer_bypass"); |
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_supprimer_bypass"); |
4816 |
// |
// |
4817 |
if ($bypass == true) { |
if ($bypass == true) { |
4818 |
|
|
4824 |
// division du dossier et si l'utilisateur n'a pas la permission bypass |
// division du dossier et si l'utilisateur n'a pas la permission bypass |
4825 |
// de la division |
// de la division |
4826 |
if ($this->is_instructeur_from_division_dossier() === false |
if ($this->is_instructeur_from_division_dossier() === false |
4827 |
&& $this->f->isAccredited(get_class()."_supprimer_bypass_division") === false) { |
&& $this->f->isAccredited($this->get_absolute_class_name()."_supprimer_bypass_division") === false) { |
4828 |
|
|
4829 |
// |
// |
4830 |
return false; |
return false; |
4833 |
// l'événement est-il le dernier ? |
// l'événement est-il le dernier ? |
4834 |
$dernier_evenement = false; |
$dernier_evenement = false; |
4835 |
// instanciation dossier |
// instanciation dossier |
4836 |
require_once "../obj/dossier.class.php"; |
$dossier = $this->f->get_inst__om_dbform(array( |
4837 |
$dossier = new dossier($this->getVal('dossier'), $this->db, DEBUG); |
"obj" => "dossier", |
4838 |
|
"idx" => $this->getVal('dossier'), |
4839 |
|
)); |
4840 |
// récupération dernier événement |
// récupération dernier événement |
4841 |
$id_dernier_evenement = $dossier->get_dernier_evenement(); |
$id_dernier_evenement = $dossier->get_dernier_evenement(); |
4842 |
if ($id_dernier_evenement == $this->getVal($this->clePrimaire)) { |
if ($id_dernier_evenement == $this->getVal($this->clePrimaire)) { |
4887 |
*/ |
*/ |
4888 |
function is_addable() { |
function is_addable() { |
4889 |
// Contrôle si l'utilisateur possède un bypass |
// Contrôle si l'utilisateur possède un bypass |
4890 |
$bypass = $this->f->isAccredited(get_class($this)."_ajouter_bypass"); |
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_ajouter_bypass"); |
4891 |
// |
// |
4892 |
if ($bypass == true) { |
if ($bypass == true) { |
4893 |
|
|
4915 |
*/ |
*/ |
4916 |
function is_finalizable() { |
function is_finalizable() { |
4917 |
// Contrôle si l'utilisateur possède un bypass |
// Contrôle si l'utilisateur possède un bypass |
4918 |
$bypass = $this->f->isAccredited(get_class($this)."_finaliser_bypass"); |
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_finaliser_bypass"); |
4919 |
// |
// |
4920 |
if ($bypass == true) { |
if ($bypass == true) { |
4921 |
// |
// |
4938 |
return true; |
return true; |
4939 |
} |
} |
4940 |
|
|
|
// 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; |
|
|
} |
|
|
|
|
4941 |
// Si l'utilisateur est instructeur de la commune du dossier et que |
// Si l'utilisateur est instructeur de la commune du dossier et que |
4942 |
// l'instruction est créée par un instructeur de la commune |
// l'instruction est créée par un instructeur de la commune |
4943 |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
4980 |
*/ |
*/ |
4981 |
function is_unfinalizable(){ |
function is_unfinalizable(){ |
4982 |
// Contrôle si l'utilisateur possède un bypass |
// Contrôle si l'utilisateur possède un bypass |
4983 |
$bypass = $this->f->isAccredited(get_class($this)."_definaliser_bypass"); |
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_definaliser_bypass"); |
4984 |
// |
// |
4985 |
if ($bypass == true) { |
if ($bypass == true) { |
4986 |
// |
// |
5003 |
return true; |
return true; |
5004 |
} |
} |
5005 |
|
|
|
// 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; |
|
|
} |
|
|
|
|
5006 |
// Si l'utilisateur est instructeur de la commune du dossier et que |
// Si l'utilisateur est instructeur de la commune du dossier et que |
5007 |
// l'instruction est créée par un instructeur de la commune |
// l'instruction est créée par un instructeur de la commune |
5008 |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
5096 |
if ($this->f->isCollectiviteMono($_SESSION['collectivite']) === true) { |
if ($this->f->isCollectiviteMono($_SESSION['collectivite']) === true) { |
5097 |
$sql .= " AND dossier.om_collectivite=".$_SESSION['collectivite']; |
$sql .= " AND dossier.om_collectivite=".$_SESSION['collectivite']; |
5098 |
} |
} |
5099 |
$res = $this->db->getone($sql); |
$res = $this->f->db->getone($sql); |
5100 |
if (database::isError($res)) { |
if (database::isError($res)) { |
5101 |
die(); |
die(); |
5102 |
} |
} |
5126 |
} |
} |
5127 |
|
|
5128 |
// Contrôle si l'utilisateur possède un bypass |
// Contrôle si l'utilisateur possède un bypass |
5129 |
$bypass = $this->f->isAccredited(get_class($this)."_modification_dates_bypass"); |
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_modification_dates_bypass"); |
5130 |
if ($bypass === true) { |
if ($bypass === true) { |
5131 |
return true; |
return true; |
5132 |
} |
} |
5133 |
|
|
5134 |
// 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 |
5135 |
|
// un utilisateur lié à un instructeur |
5136 |
|
$perm_moni_dates_d_closed = $this->f->isAccredited($this->get_absolute_class_name()."_modification_dates_cloture"); |
5137 |
|
|
5138 |
|
// On vérifie en premier lieu que le DI n'est pas clôturé et que |
5139 |
|
// l'utilisateur ne possède pas la permission de modifier le suivi des |
5140 |
|
// dates sur un dossier clôturé |
5141 |
$inst_dossier = $this->get_inst_dossier(); |
$inst_dossier = $this->get_inst_dossier(); |
5142 |
if ($inst_dossier->getStatut() === 'cloture') { |
if ($inst_dossier->getStatut() === 'cloture' |
5143 |
|
&& $perm_moni_dates_d_closed === false) { |
5144 |
// |
// |
5145 |
return false; |
return false; |
5146 |
} |
} |
5202 |
// 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 |
5203 |
// dites de TREATMENT. |
// dites de TREATMENT. |
5204 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
5205 |
|
$message = ''; |
5206 |
|
|
5207 |
// Traitement de la finalisation |
// Traitement de la finalisation |
5208 |
$ret = $this->manage_finalizing("finalize", $val); |
$ret = $this->manage_finalizing("finalize", $val); |
5214 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
5215 |
} |
} |
5216 |
|
|
5217 |
|
// Envoi des notifications aux demandeurs si la notification est automatique |
5218 |
|
// et que la signature n'est pas requise |
5219 |
|
$ev = $this->get_inst_evenement($this->getVal('evenement')); |
5220 |
|
if ($ev->getVal('notification') === 'notification_automatique') { |
5221 |
|
// Récupération de la catégorie et envoie des notifications au(x) demandeur(s) |
5222 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite($this->getVal('dossier')); |
5223 |
|
// Récupération de la liste des demandeurs à notifier et de la catégorie |
5224 |
|
$categorie = $this->f->get_param_option_notification($collectivite_di); |
5225 |
|
$isPortal = $categorie == null || $categorie == '' || $categorie == 'portal' ? true : false; |
5226 |
|
$demandeursANotifie = $this->get_demandeurs_notifiable( |
5227 |
|
$this->getVal('dossier'), |
5228 |
|
$isPortal |
5229 |
|
); |
5230 |
|
|
5231 |
|
// Création d'une notification et d'une tâche pour chaque demandeur à notifier |
5232 |
|
if (count($demandeursANotifie) > 0) { |
5233 |
|
foreach ($demandeursANotifie as $demandeur) { |
5234 |
|
// Ajout de la notif et récupération de son id |
5235 |
|
$idNotif = $this->ajouter_notification( |
5236 |
|
$this->getVal($this->clePrimaire), |
5237 |
|
$this->f->get_connected_user_login_name(), |
5238 |
|
$demandeur, |
5239 |
|
$collectivite_di, |
5240 |
|
true |
5241 |
|
); |
5242 |
|
if ($idNotif === false) { |
5243 |
|
// Termine le traitement |
5244 |
|
return $this->end_treatment(__METHOD__, false); |
5245 |
|
} |
5246 |
|
$notification_by_task = $this->notification_by_task( |
5247 |
|
$idNotif, |
5248 |
|
$this->getVal('dossier'), |
5249 |
|
$categorie |
5250 |
|
); |
5251 |
|
if ($notification_by_task === false) { |
5252 |
|
$this->addToMessage( |
5253 |
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
5254 |
|
); |
5255 |
|
// Termine le traitement |
5256 |
|
return $this->end_treatment(__METHOD__, false); |
5257 |
|
} |
5258 |
|
} |
5259 |
|
$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."))); |
5260 |
|
} |
5261 |
|
} |
5262 |
|
|
5263 |
// Termine le traitement |
// Termine le traitement |
5264 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
5265 |
} |
} |
5307 |
&& $this->getVal("om_final_instruction") != null) { |
&& $this->getVal("om_final_instruction") != null) { |
5308 |
|
|
5309 |
// Ouvre le document |
// Ouvre le document |
5310 |
$lien = '../spg/file.php?obj='.$this->table.'&'. |
$lien = '../app/index.php?module=form&snippet=file&obj='.$this->table.'&'. |
5311 |
'champ=om_fichier_instruction&id='.$this->getVal($this->clePrimaire); |
'champ=om_fichier_instruction&id='.$this->getVal($this->clePrimaire); |
5312 |
// |
// |
5313 |
header("Location: ".$lien); |
header("Location: ".$lien); |
5326 |
"mode" => "previsualisation", |
"mode" => "previsualisation", |
5327 |
), |
), |
5328 |
); |
); |
5329 |
|
// Si la rédaction libre est activée sur l'instruction |
5330 |
|
if ($this->getVal("flag_edition_integrale") == 't') { |
5331 |
|
$params["specific"]["corps"] = array( |
5332 |
|
"mode" => "set", |
5333 |
|
"value" => $this->getVal("corps_om_htmletatex"), |
5334 |
|
); |
5335 |
|
$params["specific"]["titre"] = array( |
5336 |
|
"mode" => "set", |
5337 |
|
"value" => $this->getVal("titre_om_htmletat"), |
5338 |
|
); |
5339 |
|
} |
5340 |
|
|
5341 |
// Génération du PDF |
// Génération du PDF |
5342 |
$result = $this->compute_pdf_output('lettretype', $this->getVal("lettretype"), $collectivite, null, $params); |
$result = $this->compute_pdf_output('lettretype', $this->getVal("lettretype"), $collectivite, null, $params); |
5359 |
|
|
5360 |
// Si l'identifiant n'est pas renseigné |
// Si l'identifiant n'est pas renseigné |
5361 |
if ($dossier_instruction_id === null) { |
if ($dossier_instruction_id === null) { |
5362 |
// Récupère la valeur en base de données |
// Récupère la valeur |
5363 |
$dossier_instruction_id = $this->getVal('dossier'); |
if ($this->getVal('dossier') !== null && $this->getVal('dossier') !== '') { |
5364 |
|
$dossier_instruction_id = $this->getVal('dossier'); |
5365 |
|
} elseif ($this->getParameter('idxformulaire') !== null |
5366 |
|
&& $this->getParameter('idxformulaire') !== '') { |
5367 |
|
// |
5368 |
|
$dossier_instruction_id = $this->getParameter('idxformulaire'); |
5369 |
|
} elseif ($this->f->get_submitted_get_value('idxformulaire') !== null |
5370 |
|
&& $this->f->get_submitted_get_value('idxformulaire') !== '') { |
5371 |
|
// |
5372 |
|
$dossier_instruction_id = $this->f->get_submitted_get_value('idxformulaire'); |
5373 |
|
} |
5374 |
} |
} |
5375 |
|
|
5376 |
// |
// |
5377 |
require_once "../obj/dossier_instruction.class.php"; |
$dossier_instruction = $this->f->get_inst__om_dbform(array( |
5378 |
$dossier_instruction = new dossier_instruction($dossier_instruction_id, $this->f->db, false); |
"obj" => "dossier_instruction", |
5379 |
|
"idx" => $dossier_instruction_id, |
5380 |
|
)); |
5381 |
|
|
5382 |
// |
// |
5383 |
return $dossier_instruction->getVal('om_collectivite'); |
return $dossier_instruction->getVal('om_collectivite'); |
5394 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
5395 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
5396 |
|
|
|
// XXX APP |
|
|
|
|
|
$f = $this->f; |
|
|
|
|
5397 |
/** |
/** |
5398 |
* Affichage de la structure HTML |
* Affichage de la structure HTML |
5399 |
*/ |
*/ |
5400 |
// |
// |
5401 |
if ($f->isAjaxRequest()) { |
if ($this->f->isAjaxRequest()) { |
5402 |
// |
// |
5403 |
header("Content-type: text/html; charset=".HTTPCHARSET.""); |
header("Content-type: text/html; charset=".HTTPCHARSET.""); |
5404 |
} else { |
} else { |
5405 |
// |
// |
5406 |
$f->setFlag("htmlonly"); |
$this->f->setFlag("htmlonly"); |
5407 |
$f->display(); |
$this->f->display(); |
5408 |
} |
} |
5409 |
// |
// |
5410 |
$f->displayStartContent(); |
$this->f->displayStartContent(); |
5411 |
// |
// |
5412 |
$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")); |
5413 |
$f->displayTitle(); |
$this->f->displayTitle(); |
5414 |
|
|
5415 |
/** |
/** |
5416 |
* |
* |
5417 |
*/ |
*/ |
5418 |
// |
// |
5419 |
($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 = ""); |
5420 |
$evenement = intval($evenement); |
$evenement = intval($evenement); |
5421 |
// |
// |
5422 |
($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 = ""); |
5423 |
// Récupération du code du type de DA |
// Récupération du code du type de DA |
5424 |
$code_da_type = ''; |
$code_da_type = ''; |
5425 |
if (preg_match('/[A-Za-z]{2,3}/', $idx, $matches) !== false) { |
if (preg_match('/[A-Za-z]{2,3}/', $idx, $matches) !== false) { |
5426 |
$code_da_type = $matches[0]; |
$code_da_type = $matches[0]; |
5427 |
} |
} |
5428 |
// |
// |
5429 |
($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"); |
5430 |
|
|
5431 |
// Récupération de la collectivité du dossier |
// Récupération de la collectivité du dossier |
5432 |
require_once "../obj/dossier.class.php"; |
$dossier = $this->f->get_inst__om_dbform(array( |
5433 |
$dossier = new dossier($idx, $f->db, DEBUG); |
"obj" => "dossier", |
5434 |
|
"idx" => $idx, |
5435 |
|
)); |
5436 |
|
|
5437 |
/** |
/** |
5438 |
* |
* |
5445 |
LEFT JOIN ".DB_PREFIXE."om_collectivite |
LEFT JOIN ".DB_PREFIXE."om_collectivite |
5446 |
ON bible.om_collectivite = om_collectivite.om_collectivite |
ON bible.om_collectivite = om_collectivite.om_collectivite |
5447 |
WHERE (evenement=".$evenement." OR evenement IS NULL) |
WHERE (evenement=".$evenement." OR evenement IS NULL) |
5448 |
AND complement=".$complement." |
AND (complement=".$complement." OR complement IS NULL) |
5449 |
AND (bible.dossier_autorisation_type IS NULL |
AND (bible.dossier_autorisation_type IS NULL |
5450 |
OR dossier_autorisation_type.code ='".$code_da_type."') |
OR dossier_autorisation_type.code ='".$code_da_type."') |
5451 |
AND (om_collectivite.niveau = '2' |
AND (om_collectivite.niveau = '2' |
5452 |
OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").") |
OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").") |
5453 |
ORDER BY bible_lib ASC"; |
ORDER BY bible_lib ASC"; |
5454 |
$res = $f->db->query($sql); |
$res = $this->f->db->query($sql); |
5455 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\");", VERBOSE_MODE); |
5456 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
5457 |
// |
// |
5458 |
echo "<form method=\"post\" name=\"f3\" action=\"#\">\n"; |
echo "<form method=\"post\" name=\"f3\" action=\"#\">\n"; |
5459 |
// |
// |
5485 |
echo "\t</table>\n"; |
echo "\t</table>\n"; |
5486 |
// |
// |
5487 |
echo "<div class=\"formControls\">\n"; |
echo "<div class=\"formControls\">\n"; |
5488 |
$f->layout->display_form_button(array( |
$this->f->layout->display_form_button(array( |
5489 |
"value" => _("Valider"), |
"value" => _("Valider"), |
5490 |
"onclick" => "bible_return('f2', 'complement".($complement == "1" ? "" : $complement)."_om_html'); return false;", |
"onclick" => "bible_return('f2', 'complement".($complement == "1" ? "" : $complement)."_om_html'); return false;", |
5491 |
)); |
)); |
5492 |
$f->displayLinkJsCloseWindow(); |
$this->f->displayLinkJsCloseWindow(); |
5493 |
echo "</div>\n"; |
echo "</div>\n"; |
5494 |
|
|
5495 |
} else { |
} else { |
5496 |
// |
// |
5497 |
$message_class = "error"; |
$message_class = "error"; |
5498 |
$message = _("Aucun element dans la bible pour l'evenement")." : ".$evenement; |
$message = _("Aucun element dans la bible pour l'evenement")." : ".$evenement; |
5499 |
$f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
5500 |
// |
// |
5501 |
echo "<div class=\"formControls\">\n"; |
echo "<div class=\"formControls\">\n"; |
5502 |
$f->displayLinkJsCloseWindow(); |
$this->f->displayLinkJsCloseWindow(); |
5503 |
echo "</div>\n"; |
echo "</div>\n"; |
5504 |
} |
} |
5505 |
// |
// |
5509 |
* Affichage de la structure HTML |
* Affichage de la structure HTML |
5510 |
*/ |
*/ |
5511 |
// |
// |
5512 |
$f->displayEndContent(); |
$this->f->displayEndContent(); |
5513 |
} |
} |
5514 |
|
|
5515 |
/** |
/** |
5522 |
function view_bible_auto() { |
function view_bible_auto() { |
5523 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
5524 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
|
|
|
|
// XXX APP |
|
|
|
|
|
$f = $this->f; |
|
|
|
|
5525 |
// |
// |
5526 |
$f->disableLog(); |
$this->f->disableLog(); |
5527 |
|
|
5528 |
$formatDate="AAAA-MM-JJ"; |
$formatDate="AAAA-MM-JJ"; |
5529 |
|
|
5530 |
// Récupération des paramètres |
// Récupération des paramètres |
5531 |
$idx = $f->get_submitted_get_value('idx'); |
$idx = $this->f->get_submitted_get_value('idx'); |
5532 |
$evenement = $f->get_submitted_get_value('ev'); |
$evenement = $this->f->get_submitted_get_value('ev'); |
5533 |
|
|
5534 |
// Initialisation de la variable de retour |
// Initialisation de la variable de retour |
5535 |
$retour['complement_om_html'] = ''; |
$retour['complement_om_html'] = ''; |
5537 |
$retour['complement3_om_html'] = ''; |
$retour['complement3_om_html'] = ''; |
5538 |
$retour['complement4_om_html'] = ''; |
$retour['complement4_om_html'] = ''; |
5539 |
// Vérification d'une consultation liée à l'événement |
// Vérification d'une consultation liée à l'événement |
5540 |
$consultation = $f->db->getOne( |
$consultation = $this->f->db->getOne( |
5541 |
"select consultation from ".DB_PREFIXE."evenement where evenement=".$evenement |
"select consultation from ".DB_PREFIXE."evenement where evenement=".$evenement |
5542 |
); |
); |
5543 |
$f->isDatabaseError($consultation); |
$this->f->isDatabaseError($consultation); |
5544 |
// Si consultation liée, récupération du retour d'avis |
// Si consultation liée, récupération du retour d'avis |
5545 |
if($consultation=='Oui'){ |
if($consultation=='Oui'){ |
5546 |
$sql="select date_retour,avis_consultation.libelle as avis_consultation, |
$sql="select date_retour,avis_consultation.libelle as avis_consultation, |
5549 |
on consultation.service =service.service |
on consultation.service =service.service |
5550 |
left join ".DB_PREFIXE."avis_consultation on |
left join ".DB_PREFIXE."avis_consultation on |
5551 |
consultation.avis_consultation = avis_consultation.avis_consultation |
consultation.avis_consultation = avis_consultation.avis_consultation |
5552 |
where dossier ='".$idx."'"; |
where dossier ='".$idx."' and consultation.visible"; |
5553 |
$res = $f->db->query($sql); |
$res = $this->f->db->query($sql); |
5554 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
5555 |
// Récupération des consultations |
// Récupération des consultations |
5556 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
5557 |
$correct=false; |
$correct=false; |
5581 |
|
|
5582 |
} // consultation |
} // consultation |
5583 |
// Récupération des bibles automatiques pour le champ complement_om_html |
// Récupération des bibles automatiques pour le champ complement_om_html |
5584 |
$retour['complement_om_html'] .= $this->getBible($f, $evenement, $idx, '1'); |
$retour['complement_om_html'] .= $this->getBible($evenement, $idx, '1'); |
5585 |
// Récupération des bibles automatiques pour le champ complement2_om_html |
// Récupération des bibles automatiques pour le champ complement2_om_html |
5586 |
$retour['complement2_om_html'] .= $this->getBible($f, $evenement, $idx, '2'); |
$retour['complement2_om_html'] .= $this->getBible($evenement, $idx, '2'); |
5587 |
// Récupération des bibles automatiques pour le champ complement3_om_html |
// Récupération des bibles automatiques pour le champ complement3_om_html |
5588 |
$retour['complement3_om_html'] .= $this->getBible($f, $evenement, $idx, '3'); |
$retour['complement3_om_html'] .= $this->getBible($evenement, $idx, '3'); |
5589 |
// Récupération des bibles automatiques pour le champ complement4_om_html |
// Récupération des bibles automatiques pour le champ complement4_om_html |
5590 |
$retour['complement4_om_html'] .= $this->getBible($f, $evenement, $idx, '4'); |
$retour['complement4_om_html'] .= $this->getBible($evenement, $idx, '4'); |
5591 |
|
|
5592 |
|
|
5593 |
|
|
5601 |
*/ |
*/ |
5602 |
function view_pdf_temp() { |
function view_pdf_temp() { |
5603 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
5604 |
|
// Utilisation de $_POST pour ne pas que les textes soient altérés. |
5605 |
$this->f->set_submitted_value(); |
$this->f->set_submitted_value(); |
5606 |
$merge_fields = array( |
$merge_fields = array(); |
5607 |
'[complement_instruction]' => urldecode($_POST['c1']), |
// |
5608 |
'[complement1_instruction]' => urldecode($_POST['c1']), |
if (array_key_exists('c1', $_POST) === true) { |
5609 |
'[complement2_instruction]' => urldecode($_POST['c2']), |
$merge_fields['[complement_instruction]'] = urldecode($_POST['c1']); |
5610 |
'[complement3_instruction]' => urldecode($_POST['c3']), |
$merge_fields['[complement1_instruction]'] = urldecode($_POST['c1']); |
5611 |
'[complement4_instruction]' => urldecode($_POST['c4']), |
} |
5612 |
); |
if (array_key_exists('c2', $_POST) === true) { |
5613 |
|
$merge_fields['[complement2_instruction]'] = urldecode($_POST['c2']); |
5614 |
|
} |
5615 |
|
if (array_key_exists('c3', $_POST) === true) { |
5616 |
|
$merge_fields['[complement3_instruction]'] = urldecode($_POST['c3']); |
5617 |
|
} |
5618 |
|
if (array_key_exists('c4', $_POST) === true) { |
5619 |
|
$merge_fields['[complement4_instruction]'] = urldecode($_POST['c4']); |
5620 |
|
} |
5621 |
$params = array( |
$params = array( |
5622 |
"watermark" => true, |
"watermark" => true, |
5623 |
"specific" => array( |
"specific" => array( |
5624 |
"merge_fields" => $merge_fields, |
"merge_fields" => $merge_fields, |
5625 |
), |
), |
5626 |
); |
); |
5627 |
|
// |
5628 |
|
if (array_key_exists('corps', $_POST) === true) { |
5629 |
|
$params["specific"]["corps"] = array( |
5630 |
|
"mode" => "set", |
5631 |
|
"value" => urldecode($_POST['corps']), |
5632 |
|
); |
5633 |
|
} |
5634 |
|
if (array_key_exists('titre', $_POST) === true) { |
5635 |
|
$params["specific"]["titre"] = array( |
5636 |
|
"mode" => "set", |
5637 |
|
"value" => urldecode($_POST['titre']), |
5638 |
|
); |
5639 |
|
} |
5640 |
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
5641 |
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
5642 |
$result = $this->compute_pdf_output('lettretype', $this->getVal('lettretype'), $collectivite, null, $params); |
$result = $this->compute_pdf_output('lettretype', $this->getVal('lettretype'), $collectivite, null, $params); |
5657 |
$params = array( |
$params = array( |
5658 |
"watermark" => true, |
"watermark" => true, |
5659 |
); |
); |
5660 |
|
// Si la rédaction libre est activée sur l'instruction |
5661 |
|
if ($this->getVal("flag_edition_integrale") == 't') { |
5662 |
|
$params["specific"]["corps"] = array( |
5663 |
|
"mode" => "set", |
5664 |
|
"value" => $this->getVal("corps_om_htmletatex"), |
5665 |
|
); |
5666 |
|
$params["specific"]["titre"] = array( |
5667 |
|
"mode" => "set", |
5668 |
|
"value" => $this->getVal("titre_om_htmletat"), |
5669 |
|
); |
5670 |
|
} |
5671 |
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
5672 |
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
5673 |
$result = $this->compute_pdf_output('lettretype', $this->getVal('lettretype'), $collectivite, null, $params); |
$result = $this->compute_pdf_output('lettretype', $this->getVal('lettretype'), $collectivite, null, $params); |
5678 |
/** |
/** |
5679 |
* Récupération des éléments de bible. |
* Récupération des éléments de bible. |
5680 |
* |
* |
|
* @param utils $f handler de om_application |
|
5681 |
* @param integer $event id de l'événement |
* @param integer $event id de l'événement |
5682 |
* @param string $idx id du dossier |
* @param string $idx id du dossier |
5683 |
* @param integer $compnb numéro du champ complement |
* @param integer $compnb numéro du champ complement |
5684 |
* |
* |
5685 |
* @return string Chaîne de texte à insérer dans le champ complement |
* @return string Chaîne de texte à insérer dans le champ complement |
5686 |
*/ |
*/ |
5687 |
function getBible($f, $event, $idx, $compnb) { |
function getBible($event, $idx, $compnb) { |
5688 |
// Récupération de la collectivité du dossier |
// Récupération de la collectivité du dossier |
5689 |
require_once "../obj/dossier.class.php"; |
$dossier = $this->f->get_inst__om_dbform(array( |
5690 |
$dossier = new dossier($idx, $f->db, DEBUG); |
"obj" => "dossier", |
5691 |
|
"idx" => $idx, |
5692 |
|
)); |
5693 |
// Récupération du code du type de DA |
// Récupération du code du type de DA |
5694 |
$code_da_type = ''; |
$code_da_type = ''; |
5695 |
if (preg_match('/[A-Za-z]{2,3}/', $idx, $matches) !== false) { |
if (preg_match('/[A-Za-z]{2,3}/', $idx, $matches) !== false) { |
5704 |
".DB_PREFIXE."om_collectivite |
".DB_PREFIXE."om_collectivite |
5705 |
ON bible.om_collectivite = om_collectivite.om_collectivite |
ON bible.om_collectivite = om_collectivite.om_collectivite |
5706 |
WHERE (evenement =".$event." or evenement IS NULL) and |
WHERE (evenement =".$event." or evenement IS NULL) and |
5707 |
complement=".$compnb." and |
(complement=".$compnb." OR complement IS NULL) and |
5708 |
automatique='Oui' and |
automatique='Oui' and |
5709 |
(dossier_autorisation_type.code ='".$code_da_type."' or |
(dossier_autorisation_type.code ='".$code_da_type."' or |
5710 |
bible.dossier_autorisation_type IS NULL) and |
bible.dossier_autorisation_type IS NULL) and |
5711 |
(om_collectivite.niveau = '2' OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").")"; |
(om_collectivite.niveau = '2' OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").")"; |
5712 |
|
|
5713 |
$res = $f->db->query($sql); |
$res = $this->f->db->query($sql); |
5714 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
5715 |
$temp = ""; |
$temp = ""; |
5716 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
5717 |
// Remplacement des retours à la ligne par des br |
// Remplacement des retours à la ligne par des br |
5737 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
5738 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
5739 |
|
|
|
// XXX APP |
|
|
|
|
|
$f = $this->f; |
|
|
|
|
5740 |
/** |
/** |
5741 |
* Validation du formulaire |
* Validation du formulaire |
5742 |
*/ |
*/ |
5743 |
// Si le formulaire a été validé |
// Si le formulaire a été validé |
5744 |
if ($f->get_submitted_post_value("validation") !== null) { |
if ($this->f->get_submitted_post_value("validation") !== null) { |
5745 |
// Si un bordereau à été sélectionné |
// Si un bordereau à été sélectionné |
5746 |
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") == "" ) { |
5747 |
// Si aucun bordereau n'a été sélectionné |
// Si aucun bordereau n'a été sélectionné |
5748 |
$message_class = "error"; |
$message_class = "error"; |
5749 |
$message = _("Veuillez selectionner un bordereau."); |
$message = _("Veuillez selectionner un bordereau."); |
5750 |
} |
} |
5751 |
// Sinon si les dates ne sont pas valide |
// Sinon si les dates ne sont pas valide |
5752 |
elseif (($f->get_submitted_post_value("date_bordereau_debut") !== null |
elseif (($this->f->get_submitted_post_value("date_bordereau_debut") !== null |
5753 |
&& $f->get_submitted_post_value("date_bordereau_debut") == "") |
&& $this->f->get_submitted_post_value("date_bordereau_debut") == "") |
5754 |
|| ($f->get_submitted_post_value("date_bordereau_fin") !== null |
|| ($this->f->get_submitted_post_value("date_bordereau_fin") !== null |
5755 |
&& $f->get_submitted_post_value("date_bordereau_fin") == "")) { |
&& $this->f->get_submitted_post_value("date_bordereau_fin") == "")) { |
5756 |
// Si aucune date n'a été saisie |
// Si aucune date n'a été saisie |
5757 |
$message_class = "error"; |
$message_class = "error"; |
5758 |
$message = _("Veuillez saisir une date valide."); |
$message = _("Veuillez saisir une date valide."); |
5759 |
} |
} |
5760 |
// Sinon si les dates ne sont pas valides |
// Sinon si les dates ne sont pas valides |
5761 |
elseif ($f->get_submitted_post_value("bordereau") === "bordereau_avis_maire_prefet" |
elseif ($this->f->get_submitted_post_value("bordereau") === "bordereau_avis_maire_prefet" |
5762 |
&& $f->getParameter("id_evenement_bordereau_avis_maire_prefet") == null) { |
&& $this->f->getParameter("id_evenement_bordereau_avis_maire_prefet") == null) { |
5763 |
// Si aucune date n'a été saisie |
// Si aucune date n'a été saisie |
5764 |
$message_class = "error"; |
$message_class = "error"; |
5765 |
$message = _("Erreur de parametrage. Contactez votre administrateur."); |
$message = _("Erreur de parametrage. Contactez votre administrateur."); |
5769 |
// 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 |
5770 |
$sql = "SELECT om_etat.libelle |
$sql = "SELECT om_etat.libelle |
5771 |
FROM ".DB_PREFIXE."om_etat |
FROM ".DB_PREFIXE."om_etat |
5772 |
WHERE om_etat.id = '".$f->get_submitted_post_value("bordereau")."'"; |
WHERE om_etat.id = '".$this->f->get_submitted_post_value("bordereau")."'"; |
5773 |
$res = $f->db->getone($sql); |
$res = $this->f->db->getone($sql); |
5774 |
$f->addToLog(__METHOD__.": db->getone(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->getone(\"".$sql."\")", VERBOSE_MODE); |
5775 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
5776 |
// |
// |
5777 |
$message_class = "valid"; |
$message_class = "valid"; |
5778 |
$message = _("Cliquez sur le lien ci-dessous pour telecharger votre bordereau"); |
$message = _("Cliquez sur le lien ci-dessous pour telecharger votre bordereau"); |
5779 |
$message .= " : <br/><br/>"; |
$message .= " : <br/><br/>"; |
5780 |
$message .= "<a class='om-prev-icon pdf-16'"; |
$message .= "<a class='om-prev-icon pdf-16'"; |
5781 |
$message .= " title=\""._("Bordereau")."\""; |
$message .= " title=\""._("Bordereau")."\""; |
5782 |
$message .= "href='../scr/form.php?obj=instruction"; |
$message .= "href='".OM_ROUTE_FORM."&obj=instruction"; |
5783 |
$message .= "&action=220"; |
$message .= "&action=220"; |
5784 |
$message .= "&idx=0"; |
$message .= "&idx=0"; |
5785 |
$message .= "&type_bordereau=".$f->get_submitted_post_value("bordereau"); |
$message .= "&type_bordereau=".$this->f->get_submitted_post_value("bordereau"); |
5786 |
$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"); |
5787 |
$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"); |
5788 |
// Si l'utilisateur est MULTI alors on ajoute le paramètre collectivite |
// Si l'utilisateur est MULTI alors on ajoute le paramètre collectivite |
5789 |
if ($f->get_submitted_post_value("om_collectivite") !== null) { |
if ($this->f->get_submitted_post_value("om_collectivite") !== null) { |
5790 |
$message .= "&collectivite=".$f->get_submitted_post_value("om_collectivite"); |
$message .= "&collectivite=".$this->f->get_submitted_post_value("om_collectivite"); |
5791 |
} |
} |
5792 |
$message .= "'"." target='_blank'>"; |
$message .= "'"." target='_blank'>"; |
5793 |
$message .= $res." "._("du")." ".$f->get_submitted_post_value("date_bordereau_debut") |
$message .= $res." "._("du")." ".$this->f->get_submitted_post_value("date_bordereau_debut") |
5794 |
." "._("au")." ".$f->get_submitted_post_value("date_bordereau_fin"); |
." "._("au")." ".$this->f->get_submitted_post_value("date_bordereau_fin"); |
5795 |
$message .= "</a>"; |
$message .= "</a>"; |
5796 |
} |
} |
5797 |
} |
} |
5801 |
*/ |
*/ |
5802 |
// Affichage du message de validation ou d'erreur |
// Affichage du message de validation ou d'erreur |
5803 |
if (isset($message) && isset($message_class) && $message != "") { |
if (isset($message) && isset($message_class) && $message != "") { |
5804 |
$f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
5805 |
} |
} |
|
// Inclusion de la classe de gestion des formulaires |
|
|
require_once "../obj/om_formulaire.class.php"; |
|
5806 |
// Ouverture du formulaire |
// Ouverture du formulaire |
5807 |
printf("\t<form"); |
printf("\t<form"); |
5808 |
printf(" method=\"post\""); |
printf(" method=\"post\""); |
5811 |
printf(">\n"); |
printf(">\n"); |
5812 |
// Paramétrage des champs du formulaire |
// Paramétrage des champs du formulaire |
5813 |
$champs = array("date_bordereau_debut", "date_bordereau_fin", "bordereau"); |
$champs = array("date_bordereau_debut", "date_bordereau_fin", "bordereau"); |
5814 |
// 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 |
5815 |
// collectivité dans le formulaire |
// collectivité dans le formulaire |
5816 |
if($_SESSION["niveau"] == 2) { |
if ($_SESSION["niveau"] == 2) { |
5817 |
array_push($champs, "om_collectivite"); |
array_push($champs, "om_collectivite"); |
5818 |
} |
} |
5819 |
// Création d'un nouvel objet de type formulaire |
// Création d'un nouvel objet de type formulaire |
5820 |
$form = new formulaire(NULL, 0, 0, $champs); |
$form = $this->f->get_inst__om_formulaire(array( |
5821 |
|
"validation" => 0, |
5822 |
|
"maj" => 0, |
5823 |
|
"champs" => $champs, |
5824 |
|
)); |
5825 |
// Paramétrage du champ date_bordereau_debut |
// Paramétrage du champ date_bordereau_debut |
5826 |
$form->setLib("date_bordereau_debut", _("date_bordereau_debut")); |
$form->setLib("date_bordereau_debut", _("date_bordereau_debut")); |
5827 |
$form->setType("date_bordereau_debut", "date"); |
$form->setType("date_bordereau_debut", "date"); |
5843 |
$form->setType("bordereau", "select"); |
$form->setType("bordereau", "select"); |
5844 |
$form->setRequired("bordereau"); |
$form->setRequired("bordereau"); |
5845 |
// Valeurs des champs |
// Valeurs des champs |
5846 |
if ($f->get_submitted_post_value("validation") !== null) { |
if ($this->f->get_submitted_post_value("validation") !== null) { |
5847 |
$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")); |
5848 |
$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")); |
5849 |
$form->setVal("bordereau", $f->get_submitted_post_value("bordereau")); |
$form->setVal("bordereau", $this->f->get_submitted_post_value("bordereau")); |
5850 |
$form->setVal("om_collectivite", $f->get_submitted_post_value("om_collectivite")); |
$form->setVal("om_collectivite", $this->f->get_submitted_post_value("om_collectivite")); |
5851 |
} |
} |
5852 |
// 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 |
5853 |
// 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 |
5856 |
FROM ".DB_PREFIXE."om_etat |
FROM ".DB_PREFIXE."om_etat |
5857 |
WHERE om_etat.id LIKE 'bordereau_%' |
WHERE om_etat.id LIKE 'bordereau_%' |
5858 |
ORDER BY om_etat.id"; |
ORDER BY om_etat.id"; |
5859 |
$res = $f->db->query($sql); |
$res = $this->f->db->query($sql); |
5860 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
5861 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
5862 |
// Données du select |
// Données du select |
5863 |
$contenu = array( |
$contenu = array( |
5864 |
0 => array("", ), |
0 => array("", ), |
5869 |
$contenu[1][] = $row['libelle']; |
$contenu[1][] = $row['libelle']; |
5870 |
} |
} |
5871 |
$form->setSelect("bordereau", $contenu); |
$form->setSelect("bordereau", $contenu); |
5872 |
// |
// |
5873 |
if($_SESSION["niveau"] == 2) { |
if ($_SESSION["niveau"] == 2) { |
5874 |
$form->setLib("om_collectivite", _("collectivite")); |
$form->setLib("om_collectivite", _("collectivite")); |
5875 |
$form->setType("om_collectivite", "select"); |
$form->setType("om_collectivite", "select"); |
5876 |
|
|
5877 |
// 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 |
5878 |
// de niveau 1 |
// de niveau 1 |
5879 |
$sql = "SELECT om_collectivite, libelle |
$sql = "SELECT om_collectivite, libelle |
5880 |
FROM ".DB_PREFIXE."om_collectivite |
FROM ".DB_PREFIXE."om_collectivite |
5881 |
WHERE niveau = '1' ORDER BY libelle"; |
WHERE niveau = '1' ORDER BY libelle"; |
5882 |
$res = $f->db->query($sql); |
$res = $this->f->db->query($sql); |
5883 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
5884 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
5885 |
// La valeur par défaut du select est Toutes |
// La valeur par défaut du select est Toutes |
5886 |
$list_collectivites = array( |
$list_collectivites = array( |
5887 |
0 => array("", ), |
0 => array("", ), |
5888 |
1 => array(_("toutes")) |
1 => array(_("toutes")) |
5889 |
); |
); |
|
|
|
|
$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); |
|
|
} |
|
5890 |
|
|
5891 |
|
$id_colls = ""; |
5892 |
|
// On stocke dans $id_colls l'id de toutes les collectivités de niveau 1 séparées |
5893 |
|
// par des virgules, pour un traitement plus facile dans la requête de sous-état |
5894 |
|
while ($row =& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
5895 |
|
if ($id_colls != "") { |
5896 |
|
$id_colls .= ","; |
5897 |
|
} |
5898 |
|
$id_colls .= $row['om_collectivite']; |
5899 |
|
$list_collectivites[0][] = $row['om_collectivite']; |
5900 |
|
$list_collectivites[1][] = $row['libelle']; |
5901 |
|
} |
5902 |
|
// On affecte la liste d'identifiants à l'option Toutes |
5903 |
|
$list_collectivites[0][0] = $id_colls ; |
5904 |
|
$form->setSelect("om_collectivite", $list_collectivites); |
5905 |
|
} |
5906 |
// Affichage du formulaire |
// Affichage du formulaire |
5907 |
$form->entete(); |
$form->entete(); |
5908 |
$form->afficher($champs, 0, false, false); |
$form->afficher($champs, 0, false, false); |
5909 |
$form->enpied(); |
$form->enpied(); |
5910 |
// Affichage du bouton |
// Affichage du bouton |
5911 |
printf("\t<div class=\"formControls\">\n"); |
printf("\t<div class=\"formControls\">\n"); |
5912 |
$f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
$this->f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
5913 |
printf("\t</div>\n"); |
printf("\t</div>\n"); |
5914 |
// Fermeture du formulaire |
// Fermeture du formulaire |
5915 |
printf("\t</form>\n"); |
printf("\t</form>\n"); |
|
|
|
5916 |
} |
} |
5917 |
|
|
5918 |
|
|
5941 |
/** |
/** |
5942 |
* VIEW - view_suivi_envoi_lettre_rar. |
* VIEW - view_suivi_envoi_lettre_rar. |
5943 |
* |
* |
5944 |
* Vu pour imprimer les RAR. |
* Vue pour imprimer les AR. |
5945 |
* |
* |
5946 |
* @return void |
* @return void |
5947 |
*/ |
*/ |
5949 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
5950 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
5951 |
|
|
|
// XXX APP |
|
|
|
|
|
$f = $this->f; |
|
|
|
|
5952 |
// |
// |
5953 |
if ($f->get_submitted_post_value("date") !== null) { |
if ($this->f->get_submitted_post_value("date") !== null) { |
5954 |
$date = $f->get_submitted_post_value("date"); |
$date = $this->f->get_submitted_post_value("date"); |
5955 |
} else { |
} else { |
5956 |
$date = ""; |
$date = ""; |
5957 |
} |
} |
5958 |
// |
// |
5959 |
if ($f->get_submitted_post_value("liste_code_barres_instruction") !== null) { |
if ($this->f->get_submitted_post_value("liste_code_barres_instruction") !== null) { |
5960 |
$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"); |
5961 |
} else { |
} else { |
5962 |
$liste_code_barres_instruction = ""; |
$liste_code_barres_instruction = ""; |
5963 |
} |
} |
5983 |
* Validation du formulaire |
* Validation du formulaire |
5984 |
*/ |
*/ |
5985 |
// Si le formulaire a été validé |
// Si le formulaire a été validé |
5986 |
if ($f->get_submitted_post_value('validation') !== null) { |
if ($this->f->get_submitted_post_value('validation') !== null) { |
5987 |
// |
// |
5988 |
if (empty($date) || empty($liste_code_barres_instruction)) { |
if (empty($date) || empty($liste_code_barres_instruction)) { |
5989 |
// |
// |
5991 |
$message = _("Tous les champs doivent etre remplis."); |
$message = _("Tous les champs doivent etre remplis."); |
5992 |
} else { |
} else { |
5993 |
// Création d'un tableau d'instruction |
// Création d'un tableau d'instruction |
5994 |
$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")); |
5995 |
// |
// |
5996 |
foreach ($liste as $code_barres) { |
foreach ($liste as $code_barres) { |
5997 |
// On enlève les éventuels espaces saisis |
// On enlève les éventuels espaces saisis |
6027 |
$conditions = implode(" OR ", $group_clause); |
$conditions = implode(" OR ", $group_clause); |
6028 |
$sql .= " AND (" . $conditions . ")"; |
$sql .= " AND (" . $conditions . ")"; |
6029 |
|
|
6030 |
$nbInstr = $f->db->getone($sql); |
$nbInstr = $this->f->db->getone($sql); |
6031 |
$f->addToLog(__METHOD__.": db->getone(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->getone(\"".$sql."\")", VERBOSE_MODE); |
6032 |
$f->isDatabaseError($nbInstr); |
$this->f->isDatabaseError($nbInstr); |
6033 |
// |
// |
6034 |
if ($nbInstr == "1") { |
if ($nbInstr == "1") { |
6035 |
// Récupération de la date d'envoi de l'instruction bippé |
// Récupération de la date d'envoi de l'instruction bippé |
6036 |
$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."'"; |
6037 |
$res = $f->db->query($sql); |
$res = $this->f->db->query($sql); |
6038 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
6039 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
6040 |
$row =& $res->fetchRow(DB_FETCHMODE_ASSOC); |
$row =& $res->fetchRow(DB_FETCHMODE_ASSOC); |
6041 |
// Si pas de date ou correspond à la date du formulaire on |
// Si pas de date ou correspond à la date du formulaire on |
6042 |
// effectue le traitement |
// effectue le traitement |
6043 |
if ($row["date_envoi_rar"] == "" || $row["date_envoi_rar"] == $date) { |
if ($row["date_envoi_rar"] == "" || $row["date_envoi_rar"] == $date) { |
6044 |
|
$instr = $this->f->get_inst__om_dbform(array( |
6045 |
require_once '../obj/instruction.class.php'; |
"obj" => "instruction", |
6046 |
require_once '../obj/dossier.class.php'; |
"idx" => $row['instruction'], |
6047 |
|
)); |
|
$instr = new instruction($row['instruction'], $f->db, DEBUG); |
|
6048 |
$valF = array(); |
$valF = array(); |
6049 |
foreach($instr->champs as $id => $champ) { |
foreach($instr->champs as $id => $champ) { |
6050 |
$valF[$champ] = $instr->val[$id]; |
$valF[$champ] = $instr->val[$id]; |
6053 |
# 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 |
6054 |
if ($isAccredited === true |
if ($isAccredited === true |
6055 |
&& array_key_exists($instr->getVal("dossier"), $dossierTab) === false) { |
&& array_key_exists($instr->getVal("dossier"), $dossierTab) === false) { |
6056 |
$dossier = new dossier($instr->getVal("dossier")); |
$dossier = $this->f->get_inst__om_dbform(array( |
6057 |
|
"obj" => "dossier", |
6058 |
|
"idx" => $instr->getVal("dossier"), |
6059 |
|
)); |
6060 |
if ($dossier->is_user_from_allowed_collectivite()){ |
if ($dossier->is_user_from_allowed_collectivite()){ |
6061 |
$dossierTab[$instr->getVal("dossier")] = $dossier; |
$dossierTab[$instr->getVal("dossier")] = $dossier; |
6062 |
} else { |
} else { |
6110 |
$instr->setParameter('maj', 1); |
$instr->setParameter('maj', 1); |
6111 |
$instr->class_actions[1]["identifier"] = |
$instr->class_actions[1]["identifier"] = |
6112 |
"envoi lettre RAR (depuis le menu suivi des pièces)"; |
"envoi lettre RAR (depuis le menu suivi des pièces)"; |
6113 |
if ($instr->modifier($valF, $f->db, DEBUG) == true) { |
if ($instr->modifier($valF) == true) { |
6114 |
$id4Gen[] = $code_barres; |
$id4Gen[] = $code_barres; |
6115 |
$nbLettres ++; |
$nbLettres ++; |
6116 |
} else { |
} else { |
6165 |
*/ |
*/ |
6166 |
// Affichage du message de validation ou d'erreur |
// Affichage du message de validation ou d'erreur |
6167 |
if (isset($message) && isset($message_class) && $message != "") { |
if (isset($message) && isset($message_class) && $message != "") { |
6168 |
$f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
6169 |
} |
} |
6170 |
// Affichage du message d'erreur |
// Affichage du message d'erreur |
6171 |
if(!empty($error)) { |
if(!empty($error)) { |
6172 |
$f->displayMessage("error", $error); |
$this->f->displayMessage("error", $error); |
6173 |
} |
} |
6174 |
// Affichage du message de validation de la saisie |
// Affichage du message de validation de la saisie |
6175 |
if ($nbLettres > 0) { |
if ($nbLettres > 0) { |
6181 |
echo _("Cliquez sur le lien ci-dessous pour telecharger votre document"); |
echo _("Cliquez sur le lien ci-dessous pour telecharger votre document"); |
6182 |
echo " : \n<br/><br/>"; |
echo " : \n<br/><br/>"; |
6183 |
echo "\n<a class='om-prev-icon pdf-16'"; |
echo "\n<a class='om-prev-icon pdf-16'"; |
6184 |
echo "\n title=\""._("imprimer les RAR")."\""; |
echo "\n title=\""._("imprimer les AR")."\""; |
6185 |
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)."\""; |
6186 |
echo "\n target='_blank'>"; |
echo "\n target='_blank'>"; |
6187 |
echo _("Telecharger le document pour")." ".$nbLettres." "._("RAR"); |
echo _("Telecharger le document pour")." ".$nbLettres." "._("AR"); |
6188 |
echo "\n</a>"; |
echo "\n</a>"; |
6189 |
echo "\n</span>"; |
echo "\n</span>"; |
6190 |
echo "\n</p>"; |
echo "\n</p>"; |
6225 |
echo "\n<p>"; |
echo "\n<p>"; |
6226 |
echo "\n<span class='text'>"; |
echo "\n<span class='text'>"; |
6227 |
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') . "\""; |
6228 |
echo "\n href=\"../scr/form.php?obj=dossier_instruction&action=3&idx="; |
echo "\n href=\"".OM_ROUTE_FORM."&obj=dossier_instruction&action=3&idx="; |
6229 |
echo $dossier->getVal("dossier"); |
echo $dossier->getVal("dossier"); |
6230 |
echo "\">"; |
echo "\">"; |
6231 |
echo "\n</a>"; |
echo "\n</a>"; |
6232 |
|
|
6233 |
echo "\n<a title=\""._("Consulter")."\" style=\"vertical-align:middle;\""; |
echo "\n<a title=\""._("Consulter")."\" style=\"vertical-align:middle;\""; |
6234 |
echo " href=\"../scr/form.php?obj="; |
echo " href=\"".OM_ROUTE_FORM."&obj="; |
6235 |
echo $obj; |
echo $obj; |
6236 |
echo "&action=3&idx="; |
echo "&action=3&idx="; |
6237 |
echo $dossier->getVal("dossier"); |
echo $dossier->getVal("dossier"); |
6250 |
echo "\n</div>"; |
echo "\n</div>"; |
6251 |
echo "\n</div>"; |
echo "\n</div>"; |
6252 |
} |
} |
|
// Inclusion de la classe de gestion des formulaires |
|
|
require_once "../obj/om_formulaire.class.php"; |
|
6253 |
// Ouverture du formulaire |
// Ouverture du formulaire |
6254 |
echo "\t<form"; |
echo "\t<form"; |
6255 |
echo " method=\"post\""; |
echo " method=\"post\""; |
6259 |
// Paramétrage des champs du formulaire |
// Paramétrage des champs du formulaire |
6260 |
$champs = array("date", "liste_code_barres_instruction"); |
$champs = array("date", "liste_code_barres_instruction"); |
6261 |
// Création d'un nouvel objet de type formulaire |
// Création d'un nouvel objet de type formulaire |
6262 |
$form = new formulaire(NULL, 0, 0, $champs); |
$form = $this->f->get_inst__om_formulaire(array( |
6263 |
|
"validation" => 0, |
6264 |
|
"maj" => 0, |
6265 |
|
"champs" => $champs, |
6266 |
|
)); |
6267 |
// Paramétrage du champ date du formulaire |
// Paramétrage du champ date du formulaire |
6268 |
$form->setLib("date", _("Date")."* :"); |
$form->setLib("date", _("Date")."* :"); |
6269 |
$form->setType("date", "date"); |
$form->setType("date", "date"); |
6283 |
$form->enpied(); |
$form->enpied(); |
6284 |
// Affichage du bouton |
// Affichage du bouton |
6285 |
echo "\t<div class=\"formControls\">\n"; |
echo "\t<div class=\"formControls\">\n"; |
6286 |
$f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
$this->f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
6287 |
echo "\t</div>\n"; |
echo "\t</div>\n"; |
6288 |
// Fermeture du formulaire |
// Fermeture du formulaire |
6289 |
echo "\t</form>\n"; |
echo "\t</form>\n"; |
6300 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
6301 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
6302 |
|
|
|
// XXX APP |
|
|
|
|
|
$f = $this->f; |
|
|
|
|
6303 |
// Récupération des valeur passées en POST ou GET |
// Récupération des valeur passées en POST ou GET |
6304 |
if($f->get_submitted_post_value("type_mise_a_jour") !== null) { |
if($this->f->get_submitted_post_value("type_mise_a_jour") !== null) { |
6305 |
$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"); |
6306 |
} elseif($f->get_submitted_get_value('type_mise_a_jour') !== null) { |
} elseif($this->f->get_submitted_get_value('type_mise_a_jour') !== null) { |
6307 |
$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'); |
6308 |
} else { |
} else { |
6309 |
$type_mise_a_jour = ""; |
$type_mise_a_jour = ""; |
6310 |
} |
} |
6311 |
if($f->get_submitted_post_value('date') !== null) { |
if($this->f->get_submitted_post_value('date') !== null) { |
6312 |
$date = $f->get_submitted_post_value('date'); |
$date = $this->f->get_submitted_post_value('date'); |
6313 |
} elseif($f->get_submitted_get_value('date') !== null) { |
} elseif($this->f->get_submitted_get_value('date') !== null) { |
6314 |
$date = $f->get_submitted_get_value('date'); |
$date = $this->f->get_submitted_get_value('date'); |
6315 |
} else { |
} else { |
6316 |
$date = ""; |
$date = ""; |
6317 |
} |
} |
6318 |
if($f->get_submitted_post_value('code_barres') !== null) { |
if($this->f->get_submitted_post_value('code_barres') !== null) { |
6319 |
$code_barres = $f->get_submitted_post_value('code_barres'); |
$code_barres = $this->f->get_submitted_post_value('code_barres'); |
6320 |
} elseif($f->get_submitted_get_value('code_barres') !== null) { |
} elseif($this->f->get_submitted_get_value('code_barres') !== null) { |
6321 |
$code_barres = $f->get_submitted_get_value('code_barres'); |
$code_barres = $this->f->get_submitted_get_value('code_barres'); |
6322 |
} else { |
} else { |
6323 |
$code_barres = ""; |
$code_barres = ""; |
6324 |
} |
} |
6330 |
$liste_champs=array(); |
$liste_champs=array(); |
6331 |
|
|
6332 |
// Si le formulaire a été validé |
// Si le formulaire a été validé |
6333 |
if ($f->get_submitted_post_value('validation') !== null) { |
if ($this->f->get_submitted_post_value('validation') !== null) { |
6334 |
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)) { |
6335 |
|
|
6336 |
// Vérification de l'existence de l'instruction |
// Vérification de l'existence de l'instruction |
6361 |
$sql .= " AND (" . $conditions . ")"; |
$sql .= " AND (" . $conditions . ")"; |
6362 |
|
|
6363 |
|
|
6364 |
$res = $f->db->query($sql); |
$res = $this->f->db->query($sql); |
6365 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
6366 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
6367 |
|
|
6368 |
if($res->numrows() == 1) { |
if($res->numrows() == 1) { |
6369 |
$liste_champs = explode(";", $type_mise_a_jour); |
$liste_champs = explode(";", $type_mise_a_jour); |
6370 |
// Mise à jour des dates après l'écran de verification |
// Mise à jour des dates après l'écran de verification |
6371 |
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'; |
|
6372 |
$row =& $res->fetchRow(DB_FETCHMODE_ASSOC); |
$row =& $res->fetchRow(DB_FETCHMODE_ASSOC); |
6373 |
$instr = new instruction($row['instruction'], $f->db, DEBUG); |
$instr = $this->f->get_inst__om_dbform(array( |
6374 |
|
"obj" => "instruction", |
6375 |
|
"idx" => $row['instruction'], |
6376 |
|
)); |
6377 |
$valF = array(); |
$valF = array(); |
6378 |
foreach($instr->champs as $id => $champ) { |
foreach($instr->champs as $id => $champ) { |
6379 |
$valF[$champ] = $instr->val[$id]; |
$valF[$champ] = $instr->val[$id]; |
6416 |
$code_barres = ""; |
$code_barres = ""; |
6417 |
|
|
6418 |
//Désactivation de l'autocommit |
//Désactivation de l'autocommit |
6419 |
$f->db->autoCommit(false); |
$this->f->db->autoCommit(false); |
6420 |
|
|
6421 |
//On modifie les valeurs de l'instruction |
//On modifie les valeurs de l'instruction |
6422 |
$instr->setParameter('maj', 170); |
$instr->setParameter('maj', 170); |
6423 |
$instr->class_actions[170]["identifier"] = |
$instr->class_actions[170]["identifier"] = |
6424 |
"mise à jour des dates (depuis le menu suivi des pièces)"; |
"mise à jour des dates (depuis le menu suivi des pièces)"; |
6425 |
$retour = $instr->modifier($valF, $f->db, DEBUG); |
$retour = $instr->modifier($valF); |
6426 |
|
|
6427 |
//Si une erreur s'est produite, on défait les modifications |
//Si une erreur s'est produite, on défait les modifications |
6428 |
//qui ont été faites |
//qui ont été faites |
6431 |
} |
} |
6432 |
//Sinon, on valide en base de données les modifications |
//Sinon, on valide en base de données les modifications |
6433 |
else { |
else { |
6434 |
$f->db->commit(); |
$this->f->db->commit(); |
6435 |
} |
} |
6436 |
|
|
6437 |
// Variable correct retourné depuis la classe instruction |
// Variable correct retourné depuis la classe instruction |
6472 |
INNER JOIN ".DB_PREFIXE."evenement ON |
INNER JOIN ".DB_PREFIXE."evenement ON |
6473 |
instruction.evenement=evenement.evenement |
instruction.evenement=evenement.evenement |
6474 |
WHERE code_barres='".$code_barres."'"; |
WHERE code_barres='".$code_barres."'"; |
6475 |
$resInfo = $f->db->query($sqlInfo); |
$resInfo = $this->f->db->query($sqlInfo); |
6476 |
$f->isDatabaseError($resInfo); |
$this->f->isDatabaseError($resInfo); |
6477 |
$infos = $resInfo->fetchRow(DB_FETCHMODE_ASSOC); |
$infos = $resInfo->fetchRow(DB_FETCHMODE_ASSOC); |
6478 |
|
|
6479 |
// Vérification de la non modification des dates de suivi |
// Vérification de la non modification des dates de suivi |
6498 |
*/ |
*/ |
6499 |
// Affichage du message de validation ou d'erreur |
// Affichage du message de validation ou d'erreur |
6500 |
if (isset($message) && isset($message_class) && $message != "") { |
if (isset($message) && isset($message_class) && $message != "") { |
6501 |
$f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
6502 |
} |
} |
6503 |
// Affichage du message d'erreur |
// Affichage du message d'erreur |
6504 |
if(!empty($error)) { |
if(!empty($error)) { |
6505 |
$f->displayMessage("error", $error); |
$this->f->displayMessage("error", $error); |
6506 |
} |
} |
6507 |
|
|
6508 |
// Affichage du message de validation de la saisie |
// Affichage du message de validation de la saisie |
6509 |
if($correct === true) { |
if($correct === true) { |
6510 |
$f->displayMessage("ok", _("Saisie enregistree")); |
$this->f->displayMessage("ok", _("Saisie enregistree")); |
6511 |
} |
} |
|
// Inclusion de la classe de gestion des formulaires |
|
|
require_once "../obj/om_formulaire.class.php"; |
|
6512 |
// Ouverture du formulaire |
// Ouverture du formulaire |
6513 |
echo "\t<form"; |
echo "\t<form"; |
6514 |
echo " method=\"post\""; |
echo " method=\"post\""; |
6526 |
$champs = array("type_mise_a_jour", "date", "code_barres"); |
$champs = array("type_mise_a_jour", "date", "code_barres"); |
6527 |
} |
} |
6528 |
// Création d'un nouvel objet de type formulaire |
// Création d'un nouvel objet de type formulaire |
6529 |
$form = new formulaire(NULL, 0, 0, $champs); |
$form = $this->f->get_inst__om_formulaire(array( |
6530 |
|
"validation" => 0, |
6531 |
|
"maj" => 0, |
6532 |
|
"champs" => $champs, |
6533 |
|
)); |
6534 |
// Paramétrage des champs du formulaire |
// Paramétrage des champs du formulaire |
6535 |
// Parametrage du champ type_mise_a_jour |
// Parametrage du champ type_mise_a_jour |
6536 |
$form->setLib("type_mise_a_jour", _("Date a mettre a jour")."* :"); |
$form->setLib("type_mise_a_jour", _("Date a mettre a jour")."* :"); |
6560 |
$contenu[1][4] = _("date de retour de controle de legalite"); |
$contenu[1][4] = _("date de retour de controle de legalite"); |
6561 |
|
|
6562 |
$contenu[0][5] = "date_retour_rar"; |
$contenu[0][5] = "date_retour_rar"; |
6563 |
$contenu[1][5] = _("date de retour de l'AR"); |
$contenu[1][5] = __("date de notification du correspondant"); |
6564 |
|
|
6565 |
$form->setSelect("type_mise_a_jour", $contenu); |
$form->setSelect("type_mise_a_jour", $contenu); |
6566 |
|
|
6620 |
$form->setType("autorite_competente", "static"); |
$form->setType("autorite_competente", "static"); |
6621 |
$form->setVal("autorite_competente", $infos['autorite_competente']); |
$form->setVal("autorite_competente", $infos['autorite_competente']); |
6622 |
|
|
6623 |
// Parametrage des libellés d'envoi avec RAR |
// Parametrage des libellés d'envoi avec AR |
6624 |
$form->setLib("date_envoi_rar", _("date_envoi_rar")." :"); |
$form->setLib("date_envoi_rar", __("date_envoi_ar")." :"); |
6625 |
$form->setLib("date_retour_rar", _("date_retour_rar")." :"); |
$form->setLib("date_retour_rar", __("date_notification")." :"); |
6626 |
|
|
6627 |
$form->setLib("date_envoi_signature", _("date_envoi_signature")." :"); |
$form->setLib("date_envoi_signature", _("date_envoi_signature")." :"); |
6628 |
$form->setLib("date_retour_signature", _("date_retour_signature")." :"); |
$form->setLib("date_retour_signature", _("date_retour_signature")." :"); |
6656 |
echo "\t<div class=\"formControls\">\n"; |
echo "\t<div class=\"formControls\">\n"; |
6657 |
// |
// |
6658 |
if(!$date_error) { |
if(!$date_error) { |
6659 |
$f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
$this->f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
6660 |
} |
} |
6661 |
// Si pas sur l'écran de validation |
// Si pas sur l'écran de validation |
6662 |
if(isset($infos)) { |
if(isset($infos)) { |
6663 |
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"; |
6664 |
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; |
6665 |
echo "\">Retour</a>"; |
echo "\">Retour</a>"; |
6666 |
} |
} |
6677 |
function view_pdf_lettre_rar() { |
function view_pdf_lettre_rar() { |
6678 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
6679 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
6680 |
|
// |
6681 |
|
$this->f->disableLog(); |
6682 |
|
|
6683 |
// XXX APP |
if($this->f->get_submitted_get_value('liste') != null) { |
6684 |
|
$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')); |
|
6685 |
|
|
6686 |
// Classe permettant la mise en page de l'édition pdf |
// Classe permettant la mise en page de l'édition pdf |
6687 |
require_once "../obj/pdf_lettre_rar.class.php"; |
require_once "../obj/pdf_lettre_rar.class.php"; |
6688 |
$pdf_lettre_rar = new pdf_lettre_rar('P', 'mm', 'A4'); |
$pdf_lettre_rar = new pdf_lettre_rar('P', 'mm', 'A4'); |
6689 |
// Initialisation de la mise en page |
// Initialisation de la mise en page |
6690 |
$pdf_lettre_rar->init($f); |
$pdf_lettre_rar->init($this->f); |
|
|
|
|
require_once "../obj/dossier.class.php"; |
|
6691 |
|
|
6692 |
foreach ($listeCodeBarres as $code_barres) { |
foreach ($listeCodeBarres as $code_barres) { |
6693 |
|
|
6695 |
$sql = "SELECT dossier |
$sql = "SELECT dossier |
6696 |
FROM " . DB_PREFIXE . "instruction |
FROM " . DB_PREFIXE . "instruction |
6697 |
WHERE code_barres = '" . $code_barres . "'"; |
WHERE code_barres = '" . $code_barres . "'"; |
6698 |
$dossier = $this->db->getOne($sql); |
$dossier = $this->f->db->getOne($sql); |
6699 |
$this->f->addToLog(__METHOD__."(): db->getOne(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__."(): db->getOne(\"".$sql."\")", VERBOSE_MODE); |
6700 |
$this->f->isDatabaseError($dossier); |
$this->f->isDatabaseError($dossier); |
6701 |
$inst_dossier = new dossier($dossier); |
$inst_dossier = $this->f->get_inst__om_dbform(array( |
6702 |
|
"obj" => "dossier", |
6703 |
|
"idx" => $dossier, |
6704 |
|
)); |
6705 |
|
|
6706 |
// En fonction du type de dossier, on récupère un demandeur différent dans les requêtes |
// En fonction du type de dossier, on récupère un demandeur différent dans les requêtes |
6707 |
$groupe = $inst_dossier->get_type_affichage_formulaire(); |
$groupe = $inst_dossier->get_type_affichage_formulaire(); |
6714 |
break; |
break; |
6715 |
case 'ADS': |
case 'ADS': |
6716 |
case 'DPC': |
case 'DPC': |
6717 |
|
case 'CONSULTATION ENTRANTE': |
6718 |
default: |
default: |
6719 |
$sql_demandeur = "((lien_dossier_demandeur.petitionnaire_principal IS TRUE AND demandeur.type_demandeur='petitionnaire') OR demandeur.type_demandeur='delegataire')"; |
$sql_demandeur = "((lien_dossier_demandeur.petitionnaire_principal IS TRUE AND demandeur.type_demandeur='petitionnaire') OR demandeur.type_demandeur='delegataire')"; |
6720 |
break; |
break; |
6748 |
AND " . $sql_demandeur . " |
AND " . $sql_demandeur . " |
6749 |
GROUP BY dossier.dossier_libelle, evenement.type, phase.code, division.libelle"; |
GROUP BY dossier.dossier_libelle, evenement.type, phase.code, division.libelle"; |
6750 |
|
|
6751 |
$res = $f->db->query($sql); |
$res = $this->f->db->query($sql); |
6752 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
6753 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
6754 |
$testDemandeur = $res->fetchrow(DB_FETCHMODE_ASSOC); |
$testDemandeur = $res->fetchrow(DB_FETCHMODE_ASSOC); |
6755 |
|
|
6756 |
|
|
6799 |
if($testDemandeur['type'] != 'arrete' AND $testDemandeur['nbdemandeur'] > 1) { |
if($testDemandeur['type'] != 'arrete' AND $testDemandeur['nbdemandeur'] > 1) { |
6800 |
$sqlAdresse .= " AND demandeur.type_demandeur='delegataire'"; |
$sqlAdresse .= " AND demandeur.type_demandeur='delegataire'"; |
6801 |
} else { |
} else { |
6802 |
$sqlAdresse .= " AND " . $sql_demandeur; |
$sqlAdresse .= " AND demandeur.type_demandeur='petitionnaire' AND lien_dossier_demandeur.petitionnaire_principal IS TRUE"; |
6803 |
} |
} |
6804 |
|
|
6805 |
$resAdresse = $f->db->query($sqlAdresse); |
$resAdresse = $this->f->db->query($sqlAdresse); |
6806 |
$adresse_dest = $resAdresse->fetchrow(DB_FETCHMODE_ASSOC); |
$adresse_dest = $resAdresse->fetchrow(DB_FETCHMODE_ASSOC); |
6807 |
$f->addToLog(__METHOD__.": db->query(\"".$sqlAdresse."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->query(\"".$sqlAdresse."\")", VERBOSE_MODE); |
6808 |
$f->isDatabaseError($resAdresse); |
$this->f->isDatabaseError($resAdresse); |
6809 |
|
|
6810 |
// Création adresse destinataire sans ligne vide |
// Création adresse destinataire sans ligne vide |
6811 |
$adresse_destinataire = array(); |
$adresse_destinataire = array(); |
6903 |
$message .= "<a class='om-prev-icon pdf-16'"; |
$message .= "<a class='om-prev-icon pdf-16'"; |
6904 |
$message .= " id=\"generer_bordereau_envoi_maire\""; |
$message .= " id=\"generer_bordereau_envoi_maire\""; |
6905 |
$message .= " title=\""._("Bordereau")."\""; |
$message .= " title=\""._("Bordereau")."\""; |
6906 |
$message .= " href='../scr/form.php?obj=instruction"; |
$message .= " href='".OM_ROUTE_FORM."&obj=instruction"; |
6907 |
$message .= "&action=200"; |
$message .= "&action=200"; |
6908 |
$message .= "&idx=".$id_instruction."'"; |
$message .= "&idx=".$id_instruction."'"; |
6909 |
$message .= " target='_blank'>"; |
$message .= " target='_blank'>"; |
6944 |
$this->f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
6945 |
} |
} |
6946 |
|
|
|
// Inclusion de la classe de gestion des formulaires |
|
|
require_once "../obj/om_formulaire.class.php"; |
|
6947 |
// Ouverture du formulaire |
// Ouverture du formulaire |
6948 |
$datasubmit = $this->getDataSubmit(); |
$datasubmit = $this->getDataSubmit(); |
6949 |
echo "\n<!-- ########## START DBFORM ########## -->\n"; |
echo "\n<!-- ########## START DBFORM ########## -->\n"; |
6960 |
$champs = array("code_barres","date"); |
$champs = array("code_barres","date"); |
6961 |
|
|
6962 |
// Création d'un nouvel objet de type formulaire |
// Création d'un nouvel objet de type formulaire |
6963 |
$form = new formulaire(NULL, 0, 0, $champs); |
$form = $this->f->get_inst__om_formulaire(array( |
6964 |
|
"validation" => 0, |
6965 |
|
"maj" => 0, |
6966 |
|
"champs" => $champs, |
6967 |
|
)); |
6968 |
|
|
6969 |
$template_required_label = '%s *'; |
$template_required_label = '%s *'; |
6970 |
// Parametrage du champ code_barres |
// Parametrage du champ code_barres |
7023 |
} |
} |
7024 |
|
|
7025 |
/** |
/** |
7026 |
|
* VIEW - view_rapport_instruction. |
7027 |
|
* |
7028 |
|
* Ouvre le sous-formulaire en ajaxIt dans un overlay. |
7029 |
|
* Cette action est bindée pour utiliser la fonction popUpIt. |
7030 |
|
* |
7031 |
|
* @return void |
7032 |
|
*/ |
7033 |
|
function view_overlay_notification_manuelle() { |
7034 |
|
|
7035 |
|
// Vérification de l'accessibilité sur l'élément |
7036 |
|
$this->checkAccessibility(); |
7037 |
|
|
7038 |
|
printf( |
7039 |
|
'<script type="text/javascript" > |
7040 |
|
overlayIt(\'%1$s\',\'%2$s&objsf=%1$s&idxformulaire=%4$s&retourformulaire=dossier_instruction&obj=%1$s&action=411&idx=%3$s\', 1); |
7041 |
|
</script>', |
7042 |
|
'instruction_notification_manuelle', |
7043 |
|
OM_ROUTE_SOUSFORM, |
7044 |
|
$this->getVal($this->clePrimaire), |
7045 |
|
$this->getVal('dossier') |
7046 |
|
); |
7047 |
|
} |
7048 |
|
|
7049 |
|
/** |
7050 |
* 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 |
7051 |
* pour exclure les dossiers du groupe contentieux. |
* pour exclure les dossiers du groupe contentieux. |
7052 |
* |
* |
7094 |
// Begin |
// Begin |
7095 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
7096 |
// Requête |
// Requête |
7097 |
$res = $this->db->autoExecute( |
$res = $this->f->db->autoExecute( |
7098 |
DB_PREFIXE.$this->table, |
DB_PREFIXE.$this->table, |
7099 |
$valF, |
$valF, |
7100 |
DB_AUTOQUERY_UPDATE, |
DB_AUTOQUERY_UPDATE, |
7119 |
if ($this->isInstrCanChangeDecision($this->valF["dossier"])) { |
if ($this->isInstrCanChangeDecision($this->valF["dossier"])) { |
7120 |
$this->valF['created_by_commune'] = true; |
$this->valF['created_by_commune'] = true; |
7121 |
} |
} |
7122 |
|
|
7123 |
|
// |
7124 |
|
if ($this->evenement_has_an_edition($this->valF['evenement']) === false) { |
7125 |
|
if (isset($this->valF['flag_edition_integrale']) === true) { |
7126 |
|
unset($this->valF['flag_edition_integrale']); |
7127 |
|
} |
7128 |
|
if (isset($this->valF['signataire_arrete']) === true) { |
7129 |
|
unset($this->valF['signataire_arrete']); |
7130 |
|
} |
7131 |
|
} |
7132 |
} |
} |
7133 |
|
|
7134 |
|
|
7393 |
*/ |
*/ |
7394 |
public function formater_modele($modele, $id_di, $id_inst) { |
public function formater_modele($modele, $id_di, $id_inst) { |
7395 |
// Création du lien d'accès direct à l'instruction |
// Création du lien d'accès direct à l'instruction |
7396 |
$url_inst = PATH_BASE_URL.'spg/direct_link.php?obj=dossier_instruction&action=3'. |
$url_inst = PATH_BASE_URL.'app/index.php?module=form&direct_link=true&obj=dossier_instruction&action=3'. |
7397 |
'&direct_field=dossier&direct_form=instruction&direct_action=3&direct_idx='.$id_inst; |
'&direct_field=dossier&direct_form=instruction&direct_action=3&direct_idx='.$id_inst; |
7398 |
$url_inst = '<a href="'.$url_inst.'">'.$url_inst.'</a>'; |
$url_inst = '<a href="'.$url_inst.'">'.$url_inst.'</a>'; |
7399 |
// Remplacement des champs de fusion |
// Remplacement des champs de fusion |
7495 |
$this->f->get_submitted_get_value('idxformulaire') : $id_dossier = ""); |
$this->f->get_submitted_get_value('idxformulaire') : $id_dossier = ""); |
7496 |
// |
// |
7497 |
if ($id_dossier !== "") { |
if ($id_dossier !== "") { |
7498 |
require_once "../obj/dossier_instruction.class.php"; |
$dossier = $this->f->get_inst__om_dbform(array( |
7499 |
$dossier = new dossier_instruction($id_dossier, $f->db, DEBUG); |
"obj" => "dossier_instruction", |
7500 |
|
"idx" => $id_dossier, |
7501 |
|
)); |
7502 |
// |
// |
7503 |
return $dossier->can_user_access_dossier(); |
return $dossier->can_user_access_dossier(); |
7504 |
} |
} |
7518 |
$id_dossier = $this->getVal('dossier'); |
$id_dossier = $this->getVal('dossier'); |
7519 |
// |
// |
7520 |
if ($id_dossier !== "" && $id_dossier !== null) { |
if ($id_dossier !== "" && $id_dossier !== null) { |
7521 |
require_once "../obj/dossier_instruction.class.php"; |
$dossier = $this->f->get_inst__om_dbform(array( |
7522 |
$dossier = new dossier_instruction($id_dossier, $f->db, DEBUG); |
"obj" => "dossier_instruction", |
7523 |
|
"idx" => $id_dossier, |
7524 |
|
)); |
7525 |
// |
// |
7526 |
return $dossier->can_user_access_dossier(); |
return $dossier->can_user_access_dossier(); |
7527 |
} |
} |
7528 |
return false; |
return false; |
7529 |
} |
} |
7530 |
|
|
7531 |
}// fin classe |
/** |
7532 |
|
* TREATMENT - envoyer_a_signature_sans_relecture |
7533 |
|
* |
7534 |
|
* Permet d'envoyer le document de l'instruction au parapheur pour signature sans relecture |
7535 |
|
* |
7536 |
|
* @return boolean true si l'envoi a été effectué avec succès false sinon |
7537 |
|
*/ |
7538 |
|
function envoyer_a_signature_sans_relecture() { |
7539 |
|
return $this->envoyer_a_signature(); |
7540 |
|
} |
7541 |
|
|
7542 |
|
/** |
7543 |
|
* TREATMENT - envoyer_a_signature_avec_relecture |
7544 |
|
* |
7545 |
|
* Permet d'envoyer le document de l'instruction au parapheur pour signature avec relecture |
7546 |
|
* |
7547 |
|
* @return boolean true si l'envoi a été effectué avec succès false sinon |
7548 |
|
*/ |
7549 |
|
function envoyer_a_signature_avec_relecture() { |
7550 |
|
$is_forced_view_files = true; |
7551 |
|
return $this->envoyer_a_signature($is_forced_view_files); |
7552 |
|
} |
7553 |
|
|
7554 |
|
/** |
7555 |
|
* TREATMENT - envoyer_a_signature |
7556 |
|
* |
7557 |
|
* Permet d'envoyer le document de l'instruction au parapheur pour signature |
7558 |
|
* |
7559 |
|
* @param boolean $is_forced_view_files Indique si il y a une relecture (true) ou non (false) |
7560 |
|
* |
7561 |
|
* @return boolean true si l'envoi a été effectué avec succès false sinon |
7562 |
|
*/ |
7563 |
|
function envoyer_a_signature($is_forced_view_files = false) { |
7564 |
|
$this->begin_treatment(__METHOD__); |
7565 |
|
$this->correct = true; |
7566 |
|
|
7567 |
|
// Instanciation de l'objet signataire_arrete |
7568 |
|
$inst_signataire_arrete = $this->f->get_inst__om_dbform(array( |
7569 |
|
'obj' => 'signataire_arrete', |
7570 |
|
'idx' => $this->getVal('signataire_arrete'), |
7571 |
|
)); |
7572 |
|
|
7573 |
|
// Instanciation de l'objet dossier |
7574 |
|
$inst_dossier = $this->f->get_inst__om_dbform(array( |
7575 |
|
'obj' => 'dossier', |
7576 |
|
'idx' => $this->getVal('dossier'), |
7577 |
|
)); |
7578 |
|
|
7579 |
|
// Récupération du document à signer |
7580 |
|
$file = $this->f->storage->get($this->getVal('om_fichier_instruction')); |
7581 |
|
if ($file === OP_FAILURE) { |
7582 |
|
$this->correct = false; |
7583 |
|
$this->addToMessage(__("Une erreur est survenue lors de la récupération du contenu du document de l'instruction.")); |
7584 |
|
// Termine le traitement |
7585 |
|
return $this->end_treatment(__METHOD__, false); |
7586 |
|
} |
7587 |
|
|
7588 |
|
// Initialisation des paramètre à passer pour l'envoi en signature |
7589 |
|
$data = array( |
7590 |
|
"om_utilisateur_email" => $this->f->om_utilisateur['email'], |
7591 |
|
"om_utilisateur_nom" => $this->f->om_utilisateur['nom'], |
7592 |
|
"signataire_arrete_email" => $inst_signataire_arrete->getVal('email'), |
7593 |
|
"signataire_arrete_nom" => $inst_signataire_arrete->getVal('nom'), |
7594 |
|
"signataire_arrete_prenom" => $inst_signataire_arrete->getVal('prenom'), |
7595 |
|
"date_limite_instruction" => $inst_dossier->getVal('incomplet_notifie') === 't' ? $inst_dossier->getVal('date_limite_incompletude') : $inst_dossier->getVal('date_limite'), |
7596 |
|
"dossier" => $this->getVal('dossier'), |
7597 |
|
"is_forced_view_files" => $is_forced_view_files, |
7598 |
|
'commentaire_signature' => $is_forced_view_files === true ? __('relecture demandee.') : null |
7599 |
|
); |
7600 |
|
|
7601 |
|
// Initialisation des métadonnées |
7602 |
|
$metadonnee_dossier = $file['metadata']; |
7603 |
|
// récupération de l'extension du fichier |
7604 |
|
$extension = substr($metadonnee_dossier['filename'], strrpos($metadonnee_dossier['filename'], '.')); |
7605 |
|
// Modification du libellé du document transmis au parapheur |
7606 |
|
// pour le mettre sous la forme : instruction_xxx_libelle_lettretype.extension |
7607 |
|
$metadonnee_dossier['filename'] = $this->getDocumentLibelle().$extension; |
7608 |
|
$metadonnee_dossier['titre_document'] = $this->getDocumentTitre(); |
7609 |
|
|
7610 |
|
$metadonnee_dossier['url_di'] = sprintf( |
7611 |
|
'%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', |
7612 |
|
PATH_BASE_URL, |
7613 |
|
$this->getVal($this->clePrimaire) |
7614 |
|
); |
7615 |
|
|
7616 |
|
$optional_data = null; |
7617 |
|
// Si il y a des paramètres supplémentaire spécifié dans le signataire alors on les récupère |
7618 |
|
if ($inst_signataire_arrete->getVal('parametre_parapheur') !== null && $inst_signataire_arrete->getVal('parametre_parapheur') !== '') { |
7619 |
|
$optional_data = json_decode($inst_signataire_arrete->getVal('parametre_parapheur'), true); |
7620 |
|
if (json_last_error() !== JSON_ERROR_NONE) { |
7621 |
|
$this->correct = false; |
7622 |
|
$this->addToMessage(__("Les paramètres supplémentaires envoyés au parapheur ne sont pas au bon format.")); |
7623 |
|
$this->addToLog(__METHOD__."(): ". |
7624 |
|
__("Erreur lors du décodage du format json des paramètres supplémentaires envoyé au parapheur. |
7625 |
|
Tableau : ").var_export($inst_signataire_arrete->getVal('parametre_parapheur'), true) |
7626 |
|
); |
7627 |
|
// Termine le traitement |
7628 |
|
return $this->end_treatment(__METHOD__, false); |
7629 |
|
} |
7630 |
|
} |
7631 |
|
|
7632 |
?> |
//Instanciation de la classe electronicsignature |
7633 |
|
$inst_es = $this->get_electronicsignature_instance(); |
7634 |
|
if ($inst_es === false) { |
7635 |
|
$this->correct = false; |
7636 |
|
return $this->end_treatment(__METHOD__, false); |
7637 |
|
} |
7638 |
|
|
7639 |
|
// Appel de la méthode de l'abstracteur send_for_signature() |
7640 |
|
// Cette méthode doit retourner un tableau de valeur |
7641 |
|
try { |
7642 |
|
$result = $inst_es->send_for_signature($data, $file['file_content'], $metadonnee_dossier, $optional_data); |
7643 |
|
} catch (electronicsignature_exception $e) { |
7644 |
|
$this->handle_electronicsignature_exception($e); |
7645 |
|
return $this->end_treatment(__METHOD__, false); |
7646 |
|
} |
7647 |
|
|
7648 |
|
// Après avoir reçu le résultat du parapheur, il faut mettre à jour les champs |
7649 |
|
$valF = array(); |
7650 |
|
|
7651 |
|
// Pour appeler la fonction modifier il faut traiter tous les champs de l'objet |
7652 |
|
foreach($this->champs as $identifiant => $champ) { |
7653 |
|
$valF[$champ] = $this->val[$identifiant]; |
7654 |
|
} |
7655 |
|
// On fait ensuite nos modifications spécifiques |
7656 |
|
$valF['id_parapheur_signature'] = $result['id_parapheur_signature']; |
7657 |
|
$valF['statut_signature'] = $result['statut']; |
7658 |
|
$valF['commentaire_signature'] = isset($result['commentaire_signature']) == true ? $result['commentaire_signature'] : null; |
7659 |
|
$valF['date_envoi_signature'] = date("Y-m-d", strtotime($result['date_envoi_signature'])); |
7660 |
|
$valF['historique_signature'] = $this->get_updated_historique_signature($result); |
7661 |
|
|
7662 |
|
$ret = $this->modifier($valF); |
7663 |
|
|
7664 |
|
if ($ret === false) { |
7665 |
|
$this->correct = false; |
7666 |
|
$this->addToMessage(__("Une erreur est survenue lors de la mise à jour des champs.")); |
7667 |
|
// Termine le traitement |
7668 |
|
return $this->end_treatment(__METHOD__, false); |
7669 |
|
} |
7670 |
|
|
7671 |
|
// Message |
7672 |
|
$this->addToMessage(__("Le document a été envoyé pour signature dans le parapheur.")); |
7673 |
|
if (array_key_exists('signature_page_url', $result) === true) { |
7674 |
|
$this->addToMessage(sprintf( |
7675 |
|
'<br> > <a href="%1$s" title="%2$s" target="_blank">%2$s</a>', |
7676 |
|
$result['signature_page_url'], |
7677 |
|
__("Signez directement le document") |
7678 |
|
)); |
7679 |
|
} |
7680 |
|
|
7681 |
|
// Tout s'est bien passé, on termine le traitement |
7682 |
|
return $this->end_treatment(__METHOD__, true); |
7683 |
|
} |
7684 |
|
|
7685 |
|
/** |
7686 |
|
* Permet de récupérer la traduction de la valeur de statut_signature |
7687 |
|
* |
7688 |
|
* @return string la valeur de statut_signature traduite | false |
7689 |
|
*/ |
7690 |
|
function get_trad_for_statut($value_to_trad){ |
7691 |
|
$statut_signature_tab = array( |
7692 |
|
'waiting' => __('en préparation'), |
7693 |
|
'in_progress' => __('en cours de signature'), |
7694 |
|
'canceled' => __('signature annulée'), |
7695 |
|
'expired' => __('délai de signature expiré'), |
7696 |
|
'finished' => __('signé') |
7697 |
|
); |
7698 |
|
if (array_key_exists($value_to_trad, $statut_signature_tab) === true) { |
7699 |
|
return $statut_signature_tab[$value_to_trad]; |
7700 |
|
} |
7701 |
|
|
7702 |
|
return false; |
7703 |
|
} |
7704 |
|
|
7705 |
|
/** |
7706 |
|
* Permet de mettre à jour le tableau json sotcké dans le champ historique_signature |
7707 |
|
* |
7708 |
|
* @return string (json) la valeur de historique_signature mis à jour | false |
7709 |
|
*/ |
7710 |
|
function get_updated_historique_signature($historique_signature_values) { |
7711 |
|
|
7712 |
|
$historique_signature_value_tab = $this->get_historique_signature_decoded(); |
7713 |
|
|
7714 |
|
if ($historique_signature_value_tab === false) { |
7715 |
|
$this->addToLog(__METHOD__."(): erreur historique signature", DEBUG_MODE); |
7716 |
|
return false; |
7717 |
|
} |
7718 |
|
|
7719 |
|
$last_val_historique_signature = array(); |
7720 |
|
|
7721 |
|
// Si la tableau récupéré n'est pas vide alors |
7722 |
|
// on récupère la dernière ligne du tableau |
7723 |
|
if (empty($historique_signature_value_tab) === false) { |
7724 |
|
$last_val_historique_signature = end($historique_signature_value_tab); |
7725 |
|
} |
7726 |
|
|
7727 |
|
$format_date = ''; |
7728 |
|
$format_date_hour = ''; |
7729 |
|
$date_converted=array(); |
7730 |
|
|
7731 |
|
$date_to_convert = array( |
7732 |
|
'date_envoi_signature' => $historique_signature_values['date_envoi_signature'], |
7733 |
|
'date_limite_instruction' => $historique_signature_values['date_limite_instruction'], |
7734 |
|
'date_retour_signature' => $historique_signature_values['date_retour_signature'] |
7735 |
|
); |
7736 |
|
|
7737 |
|
// Conversion des dates en fonction de leur format |
7738 |
|
foreach ($date_to_convert as $key => $value) { |
7739 |
|
$date_converted[$key] = null; |
7740 |
|
if ($value != null) { |
7741 |
|
$format_date = 'd/m/Y'; |
7742 |
|
$format_date_hour = 'd/m/Y H:i:s'; |
7743 |
|
$date_converted[$key] = empty(date_parse($value)['hour']) === false ? date($format_date_hour, strtotime($value)) : date($format_date, strtotime($value)); |
7744 |
|
} |
7745 |
|
} |
7746 |
|
|
7747 |
|
// Ce tableau permet de lister les colonnes de historique_signature et de les rendre traduisibles. |
7748 |
|
// Il faut en effet mettre les gettext avec l'intitulé explicite au moins |
7749 |
|
// une fois afin qu'il puisse être reconnu par le logiciel de traduction. |
7750 |
|
$tab_for_columns_trad = array( |
7751 |
|
__('entry_date'), |
7752 |
|
__('id_parapheur_signature'), |
7753 |
|
__('emetteur'), |
7754 |
|
__('signataire'), |
7755 |
|
__('date_envoi'), |
7756 |
|
__('date_limite'), |
7757 |
|
__('date_retour'), |
7758 |
|
__('statut_signature'), |
7759 |
|
__('commentaire_signature') |
7760 |
|
); |
7761 |
|
|
7762 |
|
array_push($historique_signature_value_tab, array( |
7763 |
|
'entry_date' => date('d/m/Y H:i:s'), |
7764 |
|
'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'], |
7765 |
|
'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'], |
7766 |
|
'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'], |
7767 |
|
'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'], |
7768 |
|
'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'], |
7769 |
|
'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'], |
7770 |
|
'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']), |
7771 |
|
'commentaire_signature' => isset($historique_signature_values['commentaire_signature']) === false || $historique_signature_values['commentaire_signature'] == null ? null : $historique_signature_values['commentaire_signature'], |
7772 |
|
)); |
7773 |
|
|
7774 |
|
return json_encode($historique_signature_value_tab, JSON_HEX_APOS); |
7775 |
|
} |
7776 |
|
|
7777 |
|
|
7778 |
|
/** |
7779 |
|
* Récupère le contenu du champ historique_signature et le converti en tableau |
7780 |
|
* |
7781 |
|
* @return array sinon false en cas d'erreur |
7782 |
|
*/ |
7783 |
|
protected function get_historique_signature_decoded() { |
7784 |
|
$val = $this->getVal('historique_signature'); |
7785 |
|
if ($val === '') { |
7786 |
|
$val = json_encode(array()); |
7787 |
|
} |
7788 |
|
if($this->isJson($val) === false) { |
7789 |
|
return false; |
7790 |
|
} |
7791 |
|
return json_decode($val, true); |
7792 |
|
} |
7793 |
|
|
7794 |
|
/** |
7795 |
|
* Récupère les informations à afficher dans le tableau de suivi à l'aide |
7796 |
|
* d'une requête sql. Stocke ces informations dans un tableau. |
7797 |
|
* Converti le tableau au format json et renvoi le json obtenu |
7798 |
|
* |
7799 |
|
* @return json |
7800 |
|
*/ |
7801 |
|
protected function get_json_suivi_notification() { |
7802 |
|
$valSuivi = array(); |
7803 |
|
// Liste des champs à afficher. Permet également la traduction des noms de colonnes. |
7804 |
|
$listeChampsTrad = array( |
7805 |
|
__('emetteur'), |
7806 |
|
__('date_envoi'), |
7807 |
|
__('destinataire'), |
7808 |
|
__('date_premier_acces'), |
7809 |
|
__('instruction'), |
7810 |
|
__('statut'), |
7811 |
|
__('commentaire') |
7812 |
|
); |
7813 |
|
$listeChamps = array( |
7814 |
|
'emetteur', |
7815 |
|
'date_envoi', |
7816 |
|
'destinataire', |
7817 |
|
'date_premier_acces', |
7818 |
|
'instruction', |
7819 |
|
'statut', |
7820 |
|
'commentaire' |
7821 |
|
); |
7822 |
|
|
7823 |
|
// Récupération des infos nécessaires à l'affichage du tableau |
7824 |
|
$sql = sprintf( |
7825 |
|
'SELECT |
7826 |
|
instruction_notification.instruction_notification, |
7827 |
|
CASE WHEN instruction_notification.automatique = TRUE |
7828 |
|
THEN TRIM(CONCAT(instruction_notification.emetteur, \' \', \'(automatique)\')) |
7829 |
|
ELSE instruction_notification.emetteur |
7830 |
|
END as emetteur, |
7831 |
|
date_envoi, |
7832 |
|
instruction_notification.destinataire, |
7833 |
|
instruction_notification.date_premier_acces, |
7834 |
|
evenement.libelle as instruction, |
7835 |
|
instruction_notification.statut, |
7836 |
|
instruction_notification.commentaire, |
7837 |
|
instruction_notification_document.instruction as instruction_annexe |
7838 |
|
FROM |
7839 |
|
%1$sinstruction_notification |
7840 |
|
LEFT JOIN %1$sinstruction |
7841 |
|
ON instruction.instruction = instruction_notification.instruction |
7842 |
|
LEFT JOIN %1$sevenement |
7843 |
|
ON instruction.evenement = evenement.evenement |
7844 |
|
LEFT JOIN %1$sinstruction_notification_document |
7845 |
|
ON instruction_notification.instruction_notification = instruction_notification_document.instruction_notification |
7846 |
|
AND instruction_notification_document.annexe = true |
7847 |
|
WHERE |
7848 |
|
instruction.instruction = %2$s |
7849 |
|
ORDER BY |
7850 |
|
date_envoi ASC, instruction_notification.destinataire ASC', |
7851 |
|
DB_PREFIXE, |
7852 |
|
$this->getVal('instruction') |
7853 |
|
); |
7854 |
|
$res = $this->f->db->query($sql); |
7855 |
|
$this->f->addToLog(__METHOD__."(): db->query(\"".$sql."\")", VERBOSE_MODE); |
7856 |
|
$this->f->isDatabaseError($res); |
7857 |
|
// Stockage des infos de chaque notification dans un tableau |
7858 |
|
while( $row =& $res->fetchrow(DB_FETCHMODE_ASSOC) ) { |
7859 |
|
$valNotif = array(); |
7860 |
|
foreach($listeChamps as $champ) { |
7861 |
|
$valNotif[$champ] = $row[$champ]; |
7862 |
|
if (($champ === 'date_envoi' |
7863 |
|
|| $champ === 'date_premier_acces') |
7864 |
|
&& $row[$champ] !== null |
7865 |
|
&& $row[$champ] !== '') { |
7866 |
|
// |
7867 |
|
$valNotif[$champ] = date('d/m/Y H:i:s', strtotime($row[$champ])); |
7868 |
|
} |
7869 |
|
} |
7870 |
|
if ($row['instruction_annexe'] !== null && $row['instruction_annexe'] !== '') { |
7871 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
7872 |
|
"obj" => "instruction", |
7873 |
|
"idx" => $row['instruction_annexe'], |
7874 |
|
)); |
7875 |
|
$inst_evenement = $inst_instruction->get_inst_evenement(); |
7876 |
|
$lienAnnexe = ' ('.$inst_evenement->getVal('libelle').')'; |
7877 |
|
$valNotif['instruction'] .= $lienAnnexe; |
7878 |
|
} |
7879 |
|
array_push($valSuivi, $valNotif); |
7880 |
|
} |
7881 |
|
|
7882 |
|
// Passage du tableau au format json |
7883 |
|
return json_encode($valSuivi, JSON_HEX_APOS); |
7884 |
|
} |
7885 |
|
|
7886 |
|
/** |
7887 |
|
* Traitement des erreurs retournées par l'abstracteur electronicsignature. |
7888 |
|
* |
7889 |
|
* @param electronicsignature_exception $exception Exception retournée par l'abstracteur. |
7890 |
|
* |
7891 |
|
* @return void |
7892 |
|
*/ |
7893 |
|
public function handle_electronicsignature_exception(electronicsignature_exception $exception) { |
7894 |
|
$this->f->displayMessage('error', $exception->getMessage()); |
7895 |
|
} |
7896 |
|
|
7897 |
|
|
7898 |
|
/** |
7899 |
|
* Retourne une instance du connecteur electronicsignature, et la créer si elle n'existe pas. |
7900 |
|
* |
7901 |
|
* @param boolean $with_handle_error Flag pour afficher ou non le message d'erreur à l'utilisateur. |
7902 |
|
* @return electronicsignature Instance de l'abstracteur. |
7903 |
|
*/ |
7904 |
|
public function get_electronicsignature_instance($with_handle_error = true) { |
7905 |
|
if(isset($this->electronicsignature_instance)) { |
7906 |
|
return $this->electronicsignature_instance; |
7907 |
|
} |
7908 |
|
// Instanciation du connecteur electronicsignature |
7909 |
|
try { |
7910 |
|
require_once "electronicsignature.class.php"; |
7911 |
|
$collectivites = array("collectivite_idx" => $this->get_dossier_instruction_om_collectivite(), "collectivite_multi_idx" => $this->f->get_idx_collectivite_multi()); |
7912 |
|
$this->electronicsignature_instance = new electronicsignature($collectivites); |
7913 |
|
} catch (electronicsignature_exception $e) { |
7914 |
|
if ($with_handle_error === true) { |
7915 |
|
$this->handle_electronicsignature_exception($e); |
7916 |
|
} |
7917 |
|
return false; |
7918 |
|
} |
7919 |
|
return $this->electronicsignature_instance; |
7920 |
|
} |
7921 |
|
|
7922 |
|
/** |
7923 |
|
* Retourne le lien de retour (VIEW formulaire et VIEW sousformulaire). |
7924 |
|
* |
7925 |
|
* @param string $view Appel dans le contexte de la vue 'formulaire' ou de |
7926 |
|
* la vue 'sousformulaire'. |
7927 |
|
* |
7928 |
|
* @return string |
7929 |
|
*/ |
7930 |
|
function get_back_link($view = "formulaire") { |
7931 |
|
// |
7932 |
|
$href = parent::get_back_link($view); |
7933 |
|
// |
7934 |
|
$crud = $this->get_action_crud(); |
7935 |
|
|
7936 |
|
// Redirection vers le formulaire de modification à la validation du |
7937 |
|
// formulaire d'ajout si l'événement associé possède une lettre type |
7938 |
|
if (($crud === 'create' |
7939 |
|
|| ($crud === null |
7940 |
|
&& $this->getParameter('maj') == 0)) |
7941 |
|
&& $this->correct == true |
7942 |
|
&& $this->evenement_has_an_edition($this->valF['evenement']) === true) { |
7943 |
|
|
7944 |
|
// On instancie l'instruction |
7945 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
7946 |
|
"obj" => "instruction", |
7947 |
|
"idx" => $this->valF[$this->clePrimaire], |
7948 |
|
)); |
7949 |
|
|
7950 |
|
// Si l'instruction n'est pas finalisée automatiquement |
7951 |
|
if ($inst_instruction->getVal('om_final_instruction') !== 't') { |
7952 |
|
$href = str_replace("&action=3", "&action=1", $href); |
7953 |
|
// |
7954 |
|
if (strpos($href, "&retour=tab") !== false) { |
7955 |
|
$href = str_replace("&retour=tab", "&retour= form", $href); |
7956 |
|
} else { |
7957 |
|
$href .= "&retour=form"; |
7958 |
|
} |
7959 |
|
} |
7960 |
|
} |
7961 |
|
|
7962 |
|
// |
7963 |
|
return $href; |
7964 |
|
} |
7965 |
|
|
7966 |
|
public function view_json_data() { |
7967 |
|
$this->checkAccessibility(); |
7968 |
|
$this->f->disableLog(); |
7969 |
|
$view = $this->get_json_data(); |
7970 |
|
printf(json_encode($view)); |
7971 |
|
} |
7972 |
|
|
7973 |
|
public function get_json_data() { |
7974 |
|
$val = array_combine($this->champs, $this->val); |
7975 |
|
foreach ($val as $key => $value) { |
7976 |
|
$val[$key] = strip_tags($value); |
7977 |
|
} |
7978 |
|
$val['tacite'] = 'f'; |
7979 |
|
$inst_ad = $this->f->get_inst__om_dbform(array( |
7980 |
|
"obj" => "avis_decision", |
7981 |
|
"idx" => $val['avis_decision'], |
7982 |
|
)); |
7983 |
|
if (preg_match('/[tT]acite/', $inst_ad->getVal('libelle')) === 1) { |
7984 |
|
$val['tacite'] = 't'; |
7985 |
|
} |
7986 |
|
return $val; |
7987 |
|
} |
7988 |
|
|
7989 |
|
public function get_related_instructions($instruction = null) { |
7990 |
|
$result = array(); |
7991 |
|
$evenements = array(); |
7992 |
|
if ($instruction === null) { |
7993 |
|
$instruction = $this->getVal($this->clePrimaire); |
7994 |
|
$evenement = $this->getVal('evenement'); |
7995 |
|
$dossier = $this->getVal('dossier'); |
7996 |
|
} else { |
7997 |
|
$inst = $this->f->get_inst__om_dbform(array( |
7998 |
|
"obj" => "instruction", |
7999 |
|
"idx" => $instruction, |
8000 |
|
)); |
8001 |
|
$evenement = $inst->getVal('evenement'); |
8002 |
|
$dossier = $inst->getVal('dossier'); |
8003 |
|
} |
8004 |
|
// |
8005 |
|
$query = sprintf(' |
8006 |
|
SELECT evenement |
8007 |
|
FROM %1$sevenement |
8008 |
|
WHERE evenement_retour_ar = %2$s |
8009 |
|
OR evenement_retour_signature = %2$s |
8010 |
|
', |
8011 |
|
DB_PREFIXE, |
8012 |
|
$evenement |
8013 |
|
); |
8014 |
|
$res = $this->f->get_one_result_from_db_query($query, true); |
8015 |
|
if ($res['code'] === 'KO') { |
8016 |
|
return false; |
8017 |
|
} |
8018 |
|
$ev_parent = $res['result']; |
8019 |
|
// |
8020 |
|
$query = sprintf(' |
8021 |
|
SELECT MAX(instruction.instruction) as instruction |
8022 |
|
FROM %1$sinstruction |
8023 |
|
WHERE dossier = \'%3$s\' |
8024 |
|
AND evenement = %2$s |
8025 |
|
', |
8026 |
|
DB_PREFIXE, |
8027 |
|
$ev_parent, |
8028 |
|
$dossier |
8029 |
|
); |
8030 |
|
$res = $this->f->get_one_result_from_db_query($query, true); |
8031 |
|
if ($res['code'] === 'KO') { |
8032 |
|
return false; |
8033 |
|
} |
8034 |
|
$result[] = $res['result']; |
8035 |
|
// |
8036 |
|
$query = sprintf(' |
8037 |
|
SELECT evenement_retour_ar |
8038 |
|
FROM %1$sevenement |
8039 |
|
WHERE evenement = %2$s |
8040 |
|
AND evenement_retour_ar != %3$s |
8041 |
|
', |
8042 |
|
DB_PREFIXE, |
8043 |
|
$ev_parent, |
8044 |
|
$evenement |
8045 |
|
); |
8046 |
|
$res = $this->f->get_one_result_from_db_query($query, true); |
8047 |
|
if ($res['code'] === 'KO') { |
8048 |
|
return false; |
8049 |
|
} |
8050 |
|
$evenements[] = $res['result']; |
8051 |
|
// |
8052 |
|
$query = sprintf(' |
8053 |
|
SELECT evenement_retour_signature |
8054 |
|
FROM %1$sevenement |
8055 |
|
WHERE evenement = %2$s |
8056 |
|
AND evenement_retour_signature != %3$s |
8057 |
|
', |
8058 |
|
DB_PREFIXE, |
8059 |
|
$ev_parent, |
8060 |
|
$evenement |
8061 |
|
); |
8062 |
|
$res = $this->f->get_one_result_from_db_query($query, true); |
8063 |
|
if ($res['code'] === 'KO') { |
8064 |
|
return false; |
8065 |
|
} |
8066 |
|
$evenements[] = $res['result']; |
8067 |
|
foreach ($evenements as $value) { |
8068 |
|
if ($value !== null) { |
8069 |
|
$query = sprintf(' |
8070 |
|
SELECT MAX(instruction.instruction) as instruction |
8071 |
|
FROM %1$sinstruction |
8072 |
|
WHERE dossier = \'%3$s\' |
8073 |
|
AND evenement = %2$s |
8074 |
|
', |
8075 |
|
DB_PREFIXE, |
8076 |
|
$value, |
8077 |
|
$dossier |
8078 |
|
); |
8079 |
|
$res = $this->f->get_one_result_from_db_query($query, true); |
8080 |
|
if ($res['code'] === 'KO') { |
8081 |
|
return false; |
8082 |
|
} |
8083 |
|
$result[] = $res['result']; |
8084 |
|
} |
8085 |
|
} |
8086 |
|
return $result; |
8087 |
|
} |
8088 |
|
|
8089 |
|
protected function getDocumentType($champ = null) { |
8090 |
|
$evenementId = $this->getVal('evenement'); |
8091 |
|
if (! empty($evenementId)) { |
8092 |
|
$evenement = $this->f->findObjectById('evenement', $evenementId); |
8093 |
|
if (! empty($evenement)) { |
8094 |
|
return __("Instruction").':'.$evenement->getVal('libelle'); |
8095 |
|
} |
8096 |
|
} |
8097 |
|
return parent::getDocumentType(); |
8098 |
|
} |
8099 |
|
|
8100 |
|
/** |
8101 |
|
* Récupère à l'aide d'une requête sql la liste des demandeurs |
8102 |
|
* pouvant être notifié. C'est à dire les demandeurs acceptant |
8103 |
|
* les notifications et pour lesquels une adresse mail existe. |
8104 |
|
* |
8105 |
|
* Dans le cas, d'une notification pour le portail citoyen, seul |
8106 |
|
* le pétitionnaire principal doit être notifier et uniquement si |
8107 |
|
* il a une adress mail et qu'il accepte les notifications. |
8108 |
|
* |
8109 |
|
* @param string identifiant du dossier |
8110 |
|
* @param boolean true si il faut récupérer la liste des demandeurs notifiable |
8111 |
|
* pour une notification de categorie portail |
8112 |
|
* @return array liste des demandeurs pouvant être notifié |
8113 |
|
*/ |
8114 |
|
protected function get_demandeurs_notifiable($idDossier = null, $portail = false) { |
8115 |
|
if ($idDossier === null) { |
8116 |
|
$idDossier = $this->getVal('dossier'); |
8117 |
|
} |
8118 |
|
// Ajoute une condition sur le where pour ne récupérer que le pétitionnaire principal |
8119 |
|
// pour une notification depuis le portail citoyen |
8120 |
|
$sqlPetitionnairePrincipal = ''; |
8121 |
|
if ($portail === true) { |
8122 |
|
$sqlPetitionnairePrincipal = 'AND lien_dossier_demandeur.petitionnaire_principal = true'; |
8123 |
|
} |
8124 |
|
|
8125 |
|
$listeDemandeursNotifiable = array(); |
8126 |
|
|
8127 |
|
// Requête de récupération des demandeurs |
8128 |
|
$sql = sprintf( |
8129 |
|
'SELECT |
8130 |
|
demandeur.demandeur, |
8131 |
|
CASE |
8132 |
|
WHEN demandeur.qualite=\'particulier\' |
8133 |
|
THEN TRIM(CONCAT(demandeur.particulier_nom, \' \', demandeur.particulier_prenom, \' \', demandeur.courriel)) |
8134 |
|
ELSE |
8135 |
|
TRIM(CONCAT(demandeur.personne_morale_raison_sociale, \' \', demandeur.personne_morale_denomination, \' \', demandeur.courriel)) |
8136 |
|
END AS destinataire, |
8137 |
|
demandeur.courriel |
8138 |
|
FROM |
8139 |
|
%1$sdossier |
8140 |
|
INNER JOIN %1$slien_dossier_demandeur |
8141 |
|
ON dossier.dossier = lien_dossier_demandeur.dossier |
8142 |
|
INNER JOIN %1$sdemandeur |
8143 |
|
ON lien_dossier_demandeur.demandeur = demandeur.demandeur |
8144 |
|
WHERE |
8145 |
|
dossier.dossier = \'%2$s\' AND |
8146 |
|
notification = \'t\' AND |
8147 |
|
courriel IS NOT NULL |
8148 |
|
%3$s', |
8149 |
|
DB_PREFIXE, |
8150 |
|
$idDossier, |
8151 |
|
$sqlPetitionnairePrincipal |
8152 |
|
); |
8153 |
|
$res = $this->f->db->query($sql); |
8154 |
|
$this->f->addToLog(__METHOD__."(): db->query(\"".$sql."\")", VERBOSE_MODE); |
8155 |
|
$this->f->isDatabaseError($res); |
8156 |
|
// Récupération des infos des demandeurs et stockage dans un tableau |
8157 |
|
// ayant pour clé les id des demandeurs |
8158 |
|
while($row = $res->fetchrow(DB_FETCHMODE_ASSOC)) { |
8159 |
|
$listeDemandeursNotifiable[$row['demandeur']] = $row; |
8160 |
|
} |
8161 |
|
|
8162 |
|
return $listeDemandeursNotifiable; |
8163 |
|
} |
8164 |
|
|
8165 |
|
/** |
8166 |
|
* Renvoie la liste des notifications liées à l'instruction |
8167 |
|
* |
8168 |
|
* @param integer id de l'instruction dont on cherche les notifications |
8169 |
|
* @return array liste des instruction_notification liés à l'instruction |
8170 |
|
*/ |
8171 |
|
public function get_instruction_notification($id_instruction) { |
8172 |
|
$listeInstrNotif = array(); |
8173 |
|
$sql = sprintf(' |
8174 |
|
SELECT |
8175 |
|
instruction_notification.instruction_notification |
8176 |
|
FROM |
8177 |
|
%1$sinstruction_notification |
8178 |
|
WHERE |
8179 |
|
instruction = %2$s', |
8180 |
|
DB_PREFIXE, |
8181 |
|
$id_instruction |
8182 |
|
); |
8183 |
|
$res = $this->f->db->query($sql); |
8184 |
|
$this->f->addToLog(__METHOD__."(): db->query(\"".$sql."\")", VERBOSE_MODE); |
8185 |
|
$this->f->isDatabaseError($res); |
8186 |
|
while ($row = $res->fetchrow(DB_FETCHMODE_ASSOC)) { |
8187 |
|
$listeInstrNotif[] = $row['instruction_notification']; |
8188 |
|
} |
8189 |
|
return $listeInstrNotif; |
8190 |
|
} |
8191 |
|
|
8192 |
|
/** |
8193 |
|
* Crée une clé d'accès unique permettant à un utilisateur |
8194 |
|
* anonyme de récupérer le document. |
8195 |
|
* |
8196 |
|
* @return string clé d'accès du document |
8197 |
|
*/ |
8198 |
|
protected function getCleAccesDocument() { |
8199 |
|
// Initialisation d'un tableau |
8200 |
|
$number_list = array(); |
8201 |
|
|
8202 |
|
// Génération aléatoire d'un nombre sur 4 caractères, 4 fois |
8203 |
|
for ($i = 0; $i < 4; $i++) { |
8204 |
|
$number_list[] = str_pad(mt_rand(0, 9999), 4, 0, STR_PAD_LEFT); |
8205 |
|
} |
8206 |
|
|
8207 |
|
// Transformation en chaîne tout en séparant les nombres par un "-" |
8208 |
|
$result = implode('-', $number_list); |
8209 |
|
|
8210 |
|
// Vérifie si la clé existe déjà et si c'est le cas génére une nouvelle clé |
8211 |
|
if ($this->getUidDocumentInstructionWithKey($result) != null) { |
8212 |
|
return $this->getCleAccesDocument(); |
8213 |
|
} |
8214 |
|
|
8215 |
|
// |
8216 |
|
return $result; |
8217 |
|
} |
8218 |
|
|
8219 |
|
/** |
8220 |
|
* Récupère une clé et renvoie l'uid du document liée à cette |
8221 |
|
* clé. Si la clé n'existe pas renvoie null. |
8222 |
|
* |
8223 |
|
* @param string $cleGen clé dont on cherche l'instruction |
8224 |
|
* @return integer|null |
8225 |
|
*/ |
8226 |
|
protected function getUidDocumentInstructionWithKey($cleGen) { |
8227 |
|
$query = sprintf( |
8228 |
|
'SELECT |
8229 |
|
instruction.om_fichier_instruction |
8230 |
|
FROM |
8231 |
|
%1$sinstruction_notification_document |
8232 |
|
LEFT JOIN %1$sinstruction ON instruction_notification_document.instruction = instruction.instruction |
8233 |
|
WHERE |
8234 |
|
instruction_notification_document.cle = \'%2$s\'', |
8235 |
|
DB_PREFIXE, |
8236 |
|
$this->f->db->escapeSimple($cleGen) |
8237 |
|
); |
8238 |
|
|
8239 |
|
$res = $this->f->db->getOne($query); |
8240 |
|
$this->addToLog(__METHOD__.": db->getOne(\"".$query."\");", VERBOSE_MODE); |
8241 |
|
$this->f->isDatabaseError($res); |
8242 |
|
return $res; |
8243 |
|
} |
8244 |
|
|
8245 |
|
/** |
8246 |
|
* Récupère une clé, fait une requête pour récupérer l'id de la notification liée a cette clé. |
8247 |
|
* Récupère l'instance de instruction_notification dont l'id a été récupéré et la renvoie. |
8248 |
|
* |
8249 |
|
* @param string $cleGen |
8250 |
|
* @return instruction_notification |
8251 |
|
*/ |
8252 |
|
protected function getInstanceNotificationWithKey($key) { |
8253 |
|
$sql = sprintf( |
8254 |
|
"SELECT |
8255 |
|
instruction_notification |
8256 |
|
FROM |
8257 |
|
%1\$sinstruction_notification_document |
8258 |
|
WHERE |
8259 |
|
cle = '%2\$s'", |
8260 |
|
DB_PREFIXE, |
8261 |
|
$this->f->db->escapeSimple($key) |
8262 |
|
); |
8263 |
|
$res = $this->f->db->getOne($sql); |
8264 |
|
$this->addToLog(__METHOD__.": db->getOne(\"".$sql."\");", VERBOSE_MODE); |
8265 |
|
$this->f->isDatabaseError($res); |
8266 |
|
|
8267 |
|
// Récupération de l'instance de notification |
8268 |
|
$instNotif = $this->f->get_inst__om_dbform(array( |
8269 |
|
"obj" => "instruction_notification", |
8270 |
|
"idx" => $res, |
8271 |
|
)); |
8272 |
|
return $instNotif; |
8273 |
|
} |
8274 |
|
|
8275 |
|
|
8276 |
|
/** |
8277 |
|
* Affiche la page de téléchargement du document de la notification. |
8278 |
|
* |
8279 |
|
* @param boolean $content_only Affiche le contenu seulement. |
8280 |
|
* |
8281 |
|
* @return void |
8282 |
|
*/ |
8283 |
|
public function view_telecharger_document_anonym() { |
8284 |
|
// Par défaut on considère qu'on va afficher le formulaire |
8285 |
|
$idx = 0; |
8286 |
|
// Flag d'erreur |
8287 |
|
$error = false; |
8288 |
|
// Message d'erreur |
8289 |
|
$message = ''; |
8290 |
|
|
8291 |
|
// Paramètres GET : récupération de la clé d'accès |
8292 |
|
$cle_acces_document = $this->f->get_submitted_get_value('key'); |
8293 |
|
$cle_acces_document = $this->f->db->escapeSimple($cle_acces_document); |
8294 |
|
// Vérification de l'existence de la clé et récupération de l'uid du fichier |
8295 |
|
$uidFichier = $this->getUidDocumentInstructionWithKey($cle_acces_document); |
8296 |
|
if ($uidFichier != null) { |
8297 |
|
// Récupération du document |
8298 |
|
$file = $this->f->storage->get($uidFichier); |
8299 |
|
|
8300 |
|
// Headers |
8301 |
|
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 |
8302 |
|
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date dans le passé |
8303 |
|
header("Content-Type: ".$file['metadata']['mimetype']); |
8304 |
|
header("Accept-Ranges: bytes"); |
8305 |
|
header("Content-Disposition: inline; filename=\"".$file['metadata']['filename']."\";" ); |
8306 |
|
// Affichage du document |
8307 |
|
echo $file['file_content']; |
8308 |
|
|
8309 |
|
// Récupération de la date de premier accès et maj du suivi uniquement |
8310 |
|
// si la date de 1er accès n'a pas encore été remplis |
8311 |
|
$inst_notif = $this->getInstanceNotificationWithKey($cle_acces_document); |
8312 |
|
if ($inst_notif->getVal('date_premier_acces') == null || |
8313 |
|
$inst_notif->getVal('date_premier_acces') == '') { |
8314 |
|
$notif_val = array(); |
8315 |
|
foreach ($inst_notif->champs as $champ) { |
8316 |
|
$notif_val[$champ] = $inst_notif->getVal($champ); |
8317 |
|
} |
8318 |
|
$notif_val['date_premier_acces'] = date("d/m/Y H:i:s"); |
8319 |
|
$notif_val['statut'] = 'vu'; |
8320 |
|
$notif_val['commentaire'] = 'Le document a été vu'; |
8321 |
|
$suivi_notif = $inst_notif->modifier($notif_val); |
8322 |
|
} |
8323 |
|
|
8324 |
|
} else { |
8325 |
|
// Page vide 404 |
8326 |
|
printf('Ressource inexistante'); |
8327 |
|
header('HTTP/1.0 404 Not Found'); |
8328 |
|
} |
8329 |
|
} |
8330 |
|
|
8331 |
|
/** |
8332 |
|
* Récupère le titre du document envoyé au parapheur |
8333 |
|
*/ |
8334 |
|
protected function getDocumentTitre($champ = null) { |
8335 |
|
$title = $this->getTitle(); |
8336 |
|
$dossier = $this->getDossier(); |
8337 |
|
return $dossier.' '.$title; |
8338 |
|
} |
8339 |
|
|
8340 |
|
/** |
8341 |
|
* Compose le nom du document à transmettre au parapheur. |
8342 |
|
* Le nom ets composé de cette manière : |
8343 |
|
* instruction_xxx_libelle_de_la_lettre_type_associee |
8344 |
|
* ou xxx correspond au numéro de l'instruction |
8345 |
|
*/ |
8346 |
|
protected function getDocumentLibelle() { |
8347 |
|
// Récupère le champ instruction |
8348 |
|
$instruction = $this->getVal("instruction"); |
8349 |
|
|
8350 |
|
// Requête sql servant à récupérer le titre du document |
8351 |
|
// TO_CHAR() introduit un espace avant l'affichage du nombre |
8352 |
|
// comme les espaces sont remplacé par des '_' dans le retour de la fonction |
8353 |
|
// il n'est pas nécessaire de mettre un '_' après le mot instruction. |
8354 |
|
$sql = sprintf( |
8355 |
|
'SELECT |
8356 |
|
CONCAT( |
8357 |
|
\'instruction\', |
8358 |
|
TO_CHAR(instruction.instruction, \'000\'), |
8359 |
|
\'_\', |
8360 |
|
LOWER(om_lettretype.libelle) |
8361 |
|
) as nom_fichier |
8362 |
|
FROM |
8363 |
|
%1$sinstruction |
8364 |
|
LEFT JOIN %1$som_lettretype ON om_lettretype.id = instruction.lettretype |
8365 |
|
WHERE |
8366 |
|
instruction = %2$s', |
8367 |
|
DB_PREFIXE, |
8368 |
|
$instruction |
8369 |
|
); |
8370 |
|
$documentLibelle = $this->f->db->getOne($sql); |
8371 |
|
$this->addToLog("getDocumentTitre(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
8372 |
|
if (database::isError($documentLibelle)) { |
8373 |
|
die(); |
8374 |
|
} |
8375 |
|
|
8376 |
|
// Transforamtion des ' ' en '_', des accents en lettres sans accents et des |
8377 |
|
// caractères spéciaux en '_' |
8378 |
|
// La méthode normalize_string est utilisé pour gérer les accents |
8379 |
|
$documentLibelle = $this->f->normalize_string($documentLibelle); |
8380 |
|
// TODO : comparer cette liste et celle de la méthode normalize_string |
8381 |
|
// pour éviter les doublons + vérifier qu'il n'y a pas de doublons dans cette |
8382 |
|
// liste |
8383 |
|
$invalid = array('Œ'=>'oe', 'œ'=>'oe', 'Ÿ'=>'y', 'ü'=>'u', |
8384 |
|
'¢' => '_', 'ß' => '_', '¥' => '_', '£' => '_', '™' => '_', '©' => '_', |
8385 |
|
'®' => '_', 'ª' => '_', '×' => '_', '÷' => '_', '±' => '_', '²' => '_', |
8386 |
|
'³' => '_', '¼' => '_', '½' => '_', '¾' => '_', 'µ' => '_', '¿' => '_', |
8387 |
|
'¶' => '_', '·' => '_', '¸' => '_', 'º' => '_', '°' => '_', '¯' => '_', |
8388 |
|
'§' => '_', '…' => '_', '¤' => '_', '¦' => '_', '≠' => '_', '¬' => '_', |
8389 |
|
'ˆ' => '_', '¨' => '_', '‰' => '_', '¤' => '_', '€' => '_', '$' => '_', |
8390 |
|
'«' => '_', '»' => '_', '‹' => '_', '›' => '_', 'ƒ' => '_', '¥' => '_', |
8391 |
|
'‘‘' => '_', '‚' => '_', '!' => '_', '¡' => '_', '¢' => '_', '£' => '_', |
8392 |
|
'?' => '_', '[' => '_', ']' => '_', '´' => '_', '`' => '_', '^' => '_', |
8393 |
|
'~' => '_', '˜' => '_', '#' => '_', '*' => '_', '.' => '_', ':' => '_', |
8394 |
|
';' => '_', '•' => '_', '¯' => '_', '‾' => '_', '–' => '_', '–' => '_', |
8395 |
|
'—' => '_', '_' => '_', '|' => '_', '¦' => '_', '‡' => '_', '§' => '_', |
8396 |
|
'¶' => '_', '©' => '_', '®' => '_', '™' => '_', '&' => '_', '@' => '_', |
8397 |
|
'/' => '_', '\\' => '_', '◊' => '_', '♠' => '_', '♣' => '_', '♥' => '_', |
8398 |
|
'♦' => '_', '←' => '_', '↑' => '_', '→' => '_', '↓' => '_', '↔' => '_', |
8399 |
|
'°' => '_', 'µ' => '_', '<' => '_', '>' => '_', '≤' => '_', '≥' => '_', |
8400 |
|
'=' => '_', '≈' => '_', '≠' => '_', '≡' => '_', '±' => '_', '−' => '_', |
8401 |
|
'+' => '_', '×' => '_', '÷' => '_', '⁄' => '_', '%' => '_', '‰' => '_', |
8402 |
|
'¼' => '_', '½' => '_', '¾' => '_', '¹' => '_', '²' => '_', '³' => '_', |
8403 |
|
'' => '_', 'º' => '_', 'ª' => '_', 'ƒ' => '_', '′' => '_', '″' => '_', |
8404 |
|
'∂' => '_', '∏' => '_', '∑' => '_', '√' => '_', '∞' => '_', '¬' => '_', |
8405 |
|
'∩' => '_', '∫' => '_', 'α' => '_', 'Α' => '_', 'β' => '_', 'Β' => '_', |
8406 |
|
'γ' => '_', 'Γ' => '_', 'δ' => '_', 'Δ' => '_', 'ε' => '_', 'Ε' => '_', |
8407 |
|
'ζ' => '_', 'Ζ' => '_', 'η' => '_', 'Η' => '_', 'θ' => '_', 'Θ' => '_', |
8408 |
|
'ι' => '_', 'Ι' => '_', 'κ' => '_', 'Κ' => '_', 'λ' => '_', 'Λ' => '_', |
8409 |
|
'μ' => '_', 'Μ' => '_', 'ν' => '_', 'Ν' => '_', 'ξ' => '_', 'Ξ' => '_', |
8410 |
|
'ο' => '_', 'Ο' => '_', 'π' => '_', 'Π' => '_', 'ρ' => '_', 'Ρ' => '_', |
8411 |
|
'σ' => '_', 'ς' => '_', 'Σ' => '_', 'τ' => '_', 'Τ' => '_', 'υ' => '_', |
8412 |
|
'Υ' => '_', 'φ' => '_', 'Φ' => '_', 'χ' => '_', 'Χ' => '_', 'ψ' => '_', |
8413 |
|
'Ψ' => '_', 'ω' => '_', 'Ω' => '_', ',' => '_', ' ' => '_' |
8414 |
|
); |
8415 |
|
|
8416 |
|
return str_replace(array_keys($invalid), array_values($invalid), $documentLibelle); |
8417 |
|
} |
8418 |
|
|
8419 |
|
/** |
8420 |
|
* Surcharge permettant de ne pas afficher le fil d'Ariane dans |
8421 |
|
* l'overlay de notification des demandeurs. |
8422 |
|
*/ |
8423 |
|
function getSubFormTitle($ent) { |
8424 |
|
if ($this->getParameter('maj') == '411') { |
8425 |
|
return ''; |
8426 |
|
} |
8427 |
|
return parent::getSubFormTitle($ent); |
8428 |
|
} |
8429 |
|
}// fin classe |