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 |
|
'titre_document' => 'getDocumentTitre' |
84 |
), |
), |
85 |
"arrete" => array( |
"arrete" => array( |
86 |
"numArrete" => "getNumArrete", |
"numArrete" => "getNumArrete", |
97 |
"ap_ville" => "getAp_ville", |
"ap_ville" => "getAp_ville", |
98 |
"activite" => "getActivite", |
"activite" => "getActivite", |
99 |
"dateControleLegalite" => "getDateControleLegalite", |
"dateControleLegalite" => "getDateControleLegalite", |
100 |
), |
'titre_document' => 'getDocumentTitre' |
101 |
|
) |
102 |
); |
); |
103 |
|
|
104 |
function __construct($id, &$db, $debug) { |
/** |
105 |
$this->constructeur($id, $db, $debug); |
* Flag pour identifier la reprise de l'instruction d'un dossier. |
106 |
} |
* Le statut de l'état passe de "cloture" à "encours". |
107 |
|
* |
108 |
|
* @var boolean |
109 |
|
*/ |
110 |
|
var $di_reopened = null; |
111 |
|
|
112 |
// {{{ Gestion de la confidentialité des données spécifiques |
// {{{ Gestion de la confidentialité des données spécifiques |
113 |
|
|
130 |
"is_editable", |
"is_editable", |
131 |
"is_finalizable_without_bypass", |
"is_finalizable_without_bypass", |
132 |
"can_user_access_dossier_contexte_modification", |
"can_user_access_dossier_contexte_modification", |
133 |
|
"is_evenement_modifiable", |
134 |
); |
); |
135 |
$this->class_actions[1]["portlet"]["libelle"] = _("Modifier"); |
$this->class_actions[1]["portlet"]["libelle"] = _("Modifier"); |
136 |
|
|
139 |
$this->class_actions[2]["condition"] = array( |
$this->class_actions[2]["condition"] = array( |
140 |
"is_deletable", |
"is_deletable", |
141 |
"is_finalizable_without_bypass", |
"is_finalizable_without_bypass", |
142 |
"can_user_access_dossier_contexte_modification" |
"can_user_access_dossier_contexte_modification", |
143 |
|
"is_evenement_supprimable", |
144 |
); |
); |
145 |
$this->class_actions[2]["portlet"]["libelle"] = _("Supprimer"); |
$this->class_actions[2]["portlet"]["libelle"] = _("Supprimer"); |
146 |
|
|
188 |
"is_unfinalizable", |
"is_unfinalizable", |
189 |
"is_unfinalizable_without_bypass", |
"is_unfinalizable_without_bypass", |
190 |
"can_user_access_dossier_contexte_modification", |
"can_user_access_dossier_contexte_modification", |
191 |
|
"is_not_sent_for_signature", |
192 |
), |
), |
193 |
); |
); |
194 |
|
|
263 |
); |
); |
264 |
|
|
265 |
// ACTION - 180 - pdf_lettre_rar |
// ACTION - 180 - pdf_lettre_rar |
266 |
// Génère PDF sur bordereaux de lettres RAR |
// Génère PDF sur bordereaux de lettres AR |
267 |
$this->class_actions[180] = array( |
$this->class_actions[180] = array( |
268 |
"identifier" => "pdf_lettre_rar", |
"identifier" => "pdf_lettre_rar", |
269 |
"view" => "view_pdf_lettre_rar", |
"view" => "view_pdf_lettre_rar", |
310 |
"view" => "view_generate_suivi_bordereaux", |
"view" => "view_generate_suivi_bordereaux", |
311 |
"permission_suffix" => "consulter", |
"permission_suffix" => "consulter", |
312 |
); |
); |
313 |
|
|
314 |
|
// ACTION - 777 - pdf_temp |
315 |
|
// Crée un PDF temporaire et affiche son contenu en base64 |
316 |
|
$this->class_actions[777] = array( |
317 |
|
"identifier" => "pdf_temp", |
318 |
|
"view" => "view_pdf_temp", |
319 |
|
"permission_suffix" => "modifier", |
320 |
|
"condition" => array("can_user_access_dossier_contexte_modification"), |
321 |
|
); |
322 |
|
|
323 |
|
// ACTION - 701 |
324 |
|
$this->class_actions[701] = array( |
325 |
|
"identifier" => "enable-edition-integrale", |
326 |
|
"portlet" => array( |
327 |
|
"type" => "action-direct-with-confirmation", |
328 |
|
"libelle" => _("Rédaction libre"), |
329 |
|
"order" => 50, |
330 |
|
"class" => "redac-libre-16", |
331 |
|
), |
332 |
|
"view" => "formulaire", |
333 |
|
"method" => "enable_edition_integrale", |
334 |
|
"permission_suffix" => "modifier", |
335 |
|
"condition" => array( |
336 |
|
"is_editable", |
337 |
|
"is_finalizable_without_bypass", |
338 |
|
"can_user_access_dossier_contexte_modification", |
339 |
|
"is_edition_integrale_not_enabled", |
340 |
|
"is_option_redaction_libre_enabled", |
341 |
|
"has_an_edition", |
342 |
|
), |
343 |
|
); |
344 |
|
// ACTION - 702 |
345 |
|
$this->class_actions[702] = array( |
346 |
|
"identifier" => "disable-edition-integrale", |
347 |
|
"portlet" => array( |
348 |
|
"type" => "action-direct-with-confirmation", |
349 |
|
"libelle" => _("Rédaction par compléments"), |
350 |
|
"order" => 50, |
351 |
|
"class" => "redac-complement-16", |
352 |
|
), |
353 |
|
"view" => "formulaire", |
354 |
|
"method" => "disable_edition_integrale", |
355 |
|
"permission_suffix" => "modifier", |
356 |
|
"condition" => array( |
357 |
|
"is_editable", |
358 |
|
"is_finalizable_without_bypass", |
359 |
|
"can_user_access_dossier_contexte_modification", |
360 |
|
"is_edition_integrale_enabled", |
361 |
|
"is_option_redaction_libre_enabled", |
362 |
|
"has_an_edition", |
363 |
|
), |
364 |
|
); |
365 |
|
// ACTION - 300 - evenement_has_an_edition_json |
366 |
|
// |
367 |
|
$this->class_actions[300] = array( |
368 |
|
"identifier" => "evenement_has_an_edition_json", |
369 |
|
"view" => "view_evenement_has_an_edition_json", |
370 |
|
"permission_suffix" => "consulter", |
371 |
|
); |
372 |
|
|
373 |
|
// ACTION - 301 - evenement_has_a_commentaire |
374 |
|
// |
375 |
|
$this->class_actions[301] = array( |
376 |
|
"identifier" => "evenement_has_a_commentaire_json", |
377 |
|
"view" => "view_evenement_has_a_commentaire_json", |
378 |
|
"permission_suffix" => "consulter", |
379 |
|
); |
380 |
|
|
381 |
|
// ACTION - 400 - Envoyer en signature |
382 |
|
// Cet évenement permet d'envoyer le document au parapheur pour signature |
383 |
|
$this->class_actions[400] = array( |
384 |
|
"identifier" => "envoyer_a_signature", |
385 |
|
"portlet" => array( |
386 |
|
"libelle" => _("Envoyer à signature"), |
387 |
|
"type" => "action-direct-with-confirmation", |
388 |
|
"class" => "envoyer_a_signature-16", |
389 |
|
), |
390 |
|
"view" => "formulaire", |
391 |
|
"method" => "envoyer_a_signature_sans_relecture", |
392 |
|
"condition" => array( |
393 |
|
"can_be_signed", |
394 |
|
), |
395 |
|
"permission_suffix" => "envoyer_a_signature", |
396 |
|
); |
397 |
|
|
398 |
|
// ACTION - 402 - Envoyer en signature avec relecture |
399 |
|
// Cet évenement permet d'envoyer le document au parapheur pour signature |
400 |
|
$this->class_actions[402] = array( |
401 |
|
"identifier" => "envoyer_a_signature_relecture", |
402 |
|
"portlet" => array( |
403 |
|
"libelle" => __("Envoyer à signature avec relecture"), |
404 |
|
"type" => "action-direct-with-confirmation", |
405 |
|
"class" => "envoyer_a_signature-16", |
406 |
|
), |
407 |
|
"view" => "formulaire", |
408 |
|
"method" => "envoyer_a_signature_avec_relecture", |
409 |
|
"condition" => array( |
410 |
|
"can_be_signed", |
411 |
|
"is_parapheur_relecture_parameter_enabled" |
412 |
|
), |
413 |
|
"permission_suffix" => "envoyer_a_signature", |
414 |
|
); |
415 |
|
|
416 |
|
// |
417 |
|
$this->class_actions[401] = array( |
418 |
|
"identifier" => "preview_edition", |
419 |
|
"view" => "formulaire", |
420 |
|
"permission_suffix" => "tab", |
421 |
|
); |
422 |
|
|
423 |
|
// ACTION - 410 - Notifier les pétitionnaires (mail ou autre) |
424 |
|
$this->class_actions[410] = array( |
425 |
|
"identifier" => "overlay_notification_manuelle", |
426 |
|
"portlet" => array( |
427 |
|
"libelle" => __("Notifier les pétitionnaires"), |
428 |
|
"type" => "action-self", |
429 |
|
"class" => "notifier_commune-16", |
430 |
|
), |
431 |
|
"condition" => array( |
432 |
|
"is_notifiable_by_task_manual", |
433 |
|
"is_not_portail_notification_sans_annexe" |
434 |
|
), |
435 |
|
"view" => "view_overlay_notification_manuelle", |
436 |
|
"permission_suffix" => "modifier", |
437 |
|
); |
438 |
|
|
439 |
|
// ACTION - 410 - Notifier les pétitionnaires (portail citoyen) |
440 |
|
$this->class_actions[411] = array( |
441 |
|
"identifier" => "notification_manuelle_portal", |
442 |
|
"portlet" => array( |
443 |
|
"libelle" => __("Notifier les pétitionnaires"), |
444 |
|
"type" => "action-direct-with-confirmation", |
445 |
|
"class" => "notifier_commune-16", |
446 |
|
), |
447 |
|
"condition" => array( |
448 |
|
"is_notifiable_by_task_manual", |
449 |
|
"is_portail_notification_sans_annexe" |
450 |
|
), |
451 |
|
"method" => "notifier_demandeur_principal", |
452 |
|
"permission_suffix" => "modifier", |
453 |
|
); |
454 |
|
|
455 |
|
// |
456 |
|
$this->class_actions[998] = array( |
457 |
|
"identifier" => "json_data", |
458 |
|
"view" => "view_json_data", |
459 |
|
"permission_suffix" => "consulter", |
460 |
|
); |
461 |
|
} |
462 |
|
|
463 |
|
/** |
464 |
|
* Clause select pour la requête de sélection des données de l'enregistrement. |
465 |
|
* |
466 |
|
* @return array |
467 |
|
*/ |
468 |
|
function get_var_sql_forminc__champs() { |
469 |
|
return array( |
470 |
|
"instruction", |
471 |
|
"destinataire", |
472 |
|
"instruction.evenement", |
473 |
|
"instruction.commentaire", |
474 |
|
"date_evenement", |
475 |
|
"instruction.lettretype", |
476 |
|
"signataire_arrete", |
477 |
|
"flag_edition_integrale", |
478 |
|
"om_final_instruction_utilisateur", |
479 |
|
"date_finalisation_courrier", |
480 |
|
"date_envoi_signature", |
481 |
|
"date_envoi_rar", |
482 |
|
"date_envoi_controle_legalite", |
483 |
|
|
484 |
|
"date_retour_signature", |
485 |
|
"date_retour_rar", |
486 |
|
"date_retour_controle_legalite", |
487 |
|
|
488 |
|
"numero_arrete", |
489 |
|
|
490 |
|
"complement_om_html", |
491 |
|
"'' as bible_auto", |
492 |
|
"'' as bible", |
493 |
|
"complement2_om_html", |
494 |
|
"'' as bible2", |
495 |
|
"complement3_om_html", |
496 |
|
"'' as bible3", |
497 |
|
"complement4_om_html", |
498 |
|
"'' as bible4", |
499 |
|
|
500 |
|
"titre_om_htmletat", |
501 |
|
"corps_om_htmletatex", |
502 |
|
|
503 |
|
"'' as btn_preview", |
504 |
|
"'' as btn_redaction", |
505 |
|
|
506 |
|
"'' as btn_refresh", |
507 |
|
"'' as live_preview", |
508 |
|
|
509 |
|
"dossier", |
510 |
|
"instruction.action", |
511 |
|
"instruction.delai", |
512 |
|
"instruction.etat", |
513 |
|
"instruction.autorite_competente", |
514 |
|
"instruction.accord_tacite", |
515 |
|
"instruction.delai_notification", |
516 |
|
"instruction.avis_decision", |
517 |
|
"archive_delai", |
518 |
|
"archive_accord_tacite", |
519 |
|
"archive_etat", |
520 |
|
"archive_avis", |
521 |
|
"archive_date_complet", |
522 |
|
"archive_date_rejet", |
523 |
|
"archive_date_limite", |
524 |
|
"archive_date_notification_delai", |
525 |
|
"archive_date_decision", |
526 |
|
"archive_date_validite", |
527 |
|
"archive_date_achevement", |
528 |
|
"archive_date_conformite", |
529 |
|
"archive_date_chantier", |
530 |
|
"archive_date_dernier_depot", |
531 |
|
"date_depot", |
532 |
|
"date_depot_mairie", |
533 |
|
"complement5_om_html", |
534 |
|
"'' as bible5", |
535 |
|
"complement6_om_html", |
536 |
|
"'' as bible6", |
537 |
|
"complement7_om_html", |
538 |
|
"'' as bible7", |
539 |
|
"complement8_om_html", |
540 |
|
"'' as bible8", |
541 |
|
"complement9_om_html", |
542 |
|
"'' as bible9", |
543 |
|
"complement10_om_html", |
544 |
|
"'' as bible10", |
545 |
|
"complement11_om_html", |
546 |
|
"'' as bible11", |
547 |
|
"complement12_om_html", |
548 |
|
"complement13_om_html", |
549 |
|
"complement14_om_html", |
550 |
|
"complement15_om_html", |
551 |
|
"archive_incompletude", |
552 |
|
"archive_incomplet_notifie", |
553 |
|
"archive_evenement_suivant_tacite", |
554 |
|
"archive_evenement_suivant_tacite_incompletude", |
555 |
|
"archive_etat_pendant_incompletude", |
556 |
|
"archive_date_limite_incompletude", |
557 |
|
"archive_delai_incompletude", |
558 |
|
"archive_autorite_competente", |
559 |
|
"code_barres", |
560 |
|
"om_fichier_instruction", |
561 |
|
"om_final_instruction", |
562 |
|
"om_fichier_instruction_dossier_final", |
563 |
|
"document_numerise", |
564 |
|
"duree_validite_parametrage", |
565 |
|
"duree_validite", |
566 |
|
"created_by_commune", |
567 |
|
"archive_date_cloture_instruction", |
568 |
|
"archive_date_premiere_visite", |
569 |
|
"archive_date_derniere_visite", |
570 |
|
"archive_date_contradictoire", |
571 |
|
"archive_date_retour_contradictoire", |
572 |
|
"archive_date_ait", |
573 |
|
"archive_date_transmission_parquet", |
574 |
|
"archive_dossier_instruction_type", |
575 |
|
"archive_date_affichage", |
576 |
|
"pec_metier", |
577 |
|
"archive_pec_metier", |
578 |
|
"archive_a_qualifier", |
579 |
|
"id_parapheur_signature", |
580 |
|
"statut_signature", |
581 |
|
"commentaire_signature", |
582 |
|
"historique_signature", |
583 |
|
"'' as suivi_notification", |
584 |
|
|
585 |
|
|
586 |
|
"'' as preview_edition", |
587 |
|
); |
588 |
|
} |
589 |
|
|
590 |
|
/** |
591 |
|
* CONDITION - is_edition_integrale_enabled |
592 |
|
* |
593 |
|
* Vérifie que la rédaction libre est activée sur l'instruction en cours. |
594 |
|
* |
595 |
|
* @return boolean |
596 |
|
*/ |
597 |
|
function is_edition_integrale_enabled() { |
598 |
|
if ($this->getVal("flag_edition_integrale") == 't') { |
599 |
|
return true; |
600 |
|
} |
601 |
|
return false; |
602 |
|
} |
603 |
|
|
604 |
|
/** |
605 |
|
* CONDITION - is_edition_integrale_not_enabled |
606 |
|
* |
607 |
|
* Vérifie que la rédaction libre est désactivée sur l'instruction en cours. |
608 |
|
* |
609 |
|
* @return boolean |
610 |
|
*/ |
611 |
|
function is_edition_integrale_not_enabled() { |
612 |
|
return !$this->is_edition_integrale_enabled(); |
613 |
|
} |
614 |
|
|
615 |
|
/** |
616 |
|
* CONDITION - is_option_redaction_libre_enabled |
617 |
|
* |
618 |
|
* Vérifie que l'option de rédaction libre est activée. |
619 |
|
* |
620 |
|
* @return boolean |
621 |
|
*/ |
622 |
|
function is_option_redaction_libre_enabled() { |
623 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite(); |
624 |
|
return $this->f->is_option_redaction_libre_enabled($collectivite_di); |
625 |
|
} |
626 |
|
|
627 |
|
/** |
628 |
|
* CONDITION - is_option_parapheur_relecture_enabled |
629 |
|
* |
630 |
|
* Vérifie que l'option de relecture lors de l'envoi en signature est activée. |
631 |
|
* |
632 |
|
* @return boolean |
633 |
|
*/ |
634 |
|
function is_parapheur_relecture_parameter_enabled() { |
635 |
|
//Instanciation de la classe electronicsignature |
636 |
|
$inst_es = $this->get_electronicsignature_instance(); |
637 |
|
if ($inst_es === false) { |
638 |
|
return false; |
639 |
|
} |
640 |
|
|
641 |
|
if ($inst_es->get_conf('is_forced_view_files') !== 'true' && $inst_es->get_conf('is_forced_view_files') !== true) { |
642 |
|
return false; |
643 |
|
} |
644 |
|
|
645 |
|
return true; |
646 |
|
} |
647 |
|
|
648 |
|
|
649 |
|
/** |
650 |
|
* CONDITION - is_sent_for_signature |
651 |
|
* |
652 |
|
* Vérifie que l'instruction a été envoyé à signature |
653 |
|
* |
654 |
|
* @return boolean |
655 |
|
*/ |
656 |
|
function is_sent_for_signature() { |
657 |
|
// Si un parapheur a été configuré |
658 |
|
// et que le champ id_parapheur_signature n'est pas vide |
659 |
|
// que le status est différent de "canceled" ou "expired" |
660 |
|
// alors l'évènement a été envoyé en signature |
661 |
|
if ($this->has_connector_electronicsignature() === true |
662 |
|
&& empty($this->getVal("id_parapheur_signature")) === false |
663 |
|
&& ($this->getVal("statut_signature") != "canceled" |
664 |
|
|| $this->getVal("statut_signature") != "expired" |
665 |
|
|| $this->getVal("statut_signature") != "finished")) { |
666 |
|
// |
667 |
|
return true; |
668 |
|
} |
669 |
|
|
670 |
|
return false; |
671 |
|
} |
672 |
|
|
673 |
|
/** |
674 |
|
* CONDITION - is_not_sent_for_signature |
675 |
|
* |
676 |
|
* Vérifie que l'instruction n'a pas été envoyé à signature |
677 |
|
* |
678 |
|
* @return boolean |
679 |
|
*/ |
680 |
|
function is_not_sent_for_signature() { |
681 |
|
return !$this->is_sent_for_signature(); |
682 |
|
} |
683 |
|
|
684 |
|
|
685 |
|
/** |
686 |
|
* CONDITION - is_signed |
687 |
|
* |
688 |
|
* Vérifie que l'instruction a été signé |
689 |
|
* |
690 |
|
* @return boolean |
691 |
|
*/ |
692 |
|
function is_signed() { |
693 |
|
// Si un parapheur a été configuré |
694 |
|
// et que le champ id_parapheur_signature n'est pas vide |
695 |
|
// et que le statut est égal à "finished" |
696 |
|
// alors le document de l'instruciton à été signé |
697 |
|
if ($this->has_connector_electronicsignature() === true |
698 |
|
&& empty($this->getVal("id_parapheur_signature")) === false |
699 |
|
&& $this->getVal("statut_signature") == "finished") { |
700 |
|
// |
701 |
|
return true; |
702 |
|
} |
703 |
|
|
704 |
|
return false; |
705 |
|
} |
706 |
|
|
707 |
|
/** |
708 |
|
* CONDITION - is_portail_notification |
709 |
|
* |
710 |
|
* Vérifie si la notification est une notification de catégorie portail |
711 |
|
* |
712 |
|
* @return boolean |
713 |
|
*/ |
714 |
|
function is_portail_notification_sans_annexe() { |
715 |
|
$collectiviteDi = $this->get_dossier_instruction_om_collectivite(); |
716 |
|
$ev = $this->get_inst_evenement($this->getVal('evenement')); |
717 |
|
if (($this->f->get_param_option_notification($collectiviteDi) === null || |
718 |
|
$this->f->get_param_option_notification($collectiviteDi) === 'portal') |
719 |
|
&& $ev->getVal('notification') != 'notification_manuelle_annexe' |
720 |
|
&& $ev->getVal('notification') != 'notification_manuelle_annexe_signature_requise' |
721 |
|
) { |
722 |
|
return true; |
723 |
|
} |
724 |
|
return false; |
725 |
|
} |
726 |
|
|
727 |
|
/** |
728 |
|
* CONDITION - is_not_portail_notification |
729 |
|
* |
730 |
|
* Vérifie si la notification n'est pas une notification de catégorie portail |
731 |
|
* |
732 |
|
* @return boolean |
733 |
|
*/ |
734 |
|
function is_not_portail_notification_sans_annexe() { |
735 |
|
return (! $this->is_portail_notification_sans_annexe()); |
736 |
|
} |
737 |
|
|
738 |
|
/** |
739 |
|
* CONDITION - can_be_signed |
740 |
|
* |
741 |
|
* Vérifie que le document de l'instruction peut être envoyé au parapheur pour signature |
742 |
|
* |
743 |
|
* @return boolean |
744 |
|
*/ |
745 |
|
function can_be_signed() { |
746 |
|
// Instanciation de l'objet signataire_arrete |
747 |
|
$inst_signataire_arrete = $this->f->get_inst__om_dbform(array( |
748 |
|
"obj" => "signataire_arrete", |
749 |
|
"idx" => $this->getVal("signataire_arrete"), |
750 |
|
)); |
751 |
|
// Si un parapheur a été configuré, que le document est finalisé, que le signataire |
752 |
|
// possède une adresse email, on vérifie le champ id_parapheur_signature |
753 |
|
// S'il est vide l'évènement peut être envoyé en signature |
754 |
|
// S'il ne l'est pas, alors on vérifie le champ statut_signature |
755 |
|
// Si la valeur de ce champ est égal à "canceled" ou "expired" |
756 |
|
// alors l'évènement peut être envoyé en signature |
757 |
|
if ($this->has_connector_electronicsignature() === true |
758 |
|
&& $this->getVal("om_final_instruction") == 't' |
759 |
|
&& empty($inst_signataire_arrete->getVal('email')) === false) { |
760 |
|
// |
761 |
|
if (empty($this->getVal("id_parapheur_signature")) === true |
762 |
|
|| $this->getVal("statut_signature") == "canceled" |
763 |
|
|| $this->getVal("statut_signature") == "expired") { |
764 |
|
// |
765 |
|
return true; |
766 |
|
} |
767 |
|
} |
768 |
|
|
769 |
|
$this->addToLog(__METHOD__."() has_connector_electronicsignature: ".var_export($this->has_connector_electronicsignature(), true), EXTRA_VERBOSE_MODE); |
770 |
|
$this->addToLog(__METHOD__."() om_final_instruction: ".var_export($this->getVal("om_final_instruction"), true), EXTRA_VERBOSE_MODE); |
771 |
|
$this->addToLog(__METHOD__."() email: ".var_export($inst_signataire_arrete->getVal('email'), true), EXTRA_VERBOSE_MODE); |
772 |
|
$this->addToLog(__METHOD__."() id_parapheur_signature: ".var_export($this->getVal("id_parapheur_signature"), true), EXTRA_VERBOSE_MODE); |
773 |
|
$this->addToLog(__METHOD__."() statut_signature: ".var_export($this->getVal("statut_signature"), true), EXTRA_VERBOSE_MODE); |
774 |
|
|
775 |
|
return false; |
776 |
|
} |
777 |
|
|
778 |
|
/** |
779 |
|
* CONDITION - has_connector_electronicsignature |
780 |
|
* |
781 |
|
* Vérifie qu'un parapheur est paramétré |
782 |
|
* |
783 |
|
* @return boolean |
784 |
|
*/ |
785 |
|
function has_connector_electronicsignature() { |
786 |
|
$inst_es = $this->get_electronicsignature_instance(false); |
787 |
|
if ($inst_es === false) { |
788 |
|
return false; |
789 |
|
} |
790 |
|
return true; |
791 |
|
} |
792 |
|
|
793 |
|
/** |
794 |
|
* CONDITION - can_display_parapheur |
795 |
|
* |
796 |
|
* Vérifie que le fieldset "Suivi Parapheur" soit affichable |
797 |
|
* |
798 |
|
* @return boolean |
799 |
|
*/ |
800 |
|
function can_display_parapheur() { |
801 |
|
$evenement_id = $this->getVal("evenement"); |
802 |
|
$inst_evenement = $this->get_inst_evenement($evenement_id); |
803 |
|
if ($this->has_connector_electronicsignature() === true |
804 |
|
&& $inst_evenement->getVal('lettretype') !== '' |
805 |
|
&& $inst_evenement->getVal('lettretype') !== null |
806 |
|
&& (empty($this->getVal("id_parapheur_signature")) === false |
807 |
|
|| empty($this->getVal("historique_signature")) === false)) { |
808 |
|
// |
809 |
|
return true; |
810 |
|
} |
811 |
|
|
812 |
|
return false; |
813 |
|
} |
814 |
|
|
815 |
|
/** |
816 |
|
* CONDITION - can_display_notification |
817 |
|
* |
818 |
|
* Vérifie que le fieldset "Suivi notification" soit affichable |
819 |
|
* |
820 |
|
* @return boolean |
821 |
|
*/ |
822 |
|
function can_display_notification() { |
823 |
|
// Le suivi des notification est affiché si l'événement est notifiable |
824 |
|
// et si des notifications ont été envoyées |
825 |
|
$evenement_id = $this->getVal("evenement"); |
826 |
|
$inst_evenement = $this->get_inst_evenement($evenement_id); |
827 |
|
if ($inst_evenement->getVal('notification') != null && |
828 |
|
$inst_evenement->getVal('notification') != '') { |
829 |
|
// Des notifications ont été envoyé si il existe au moins une notification |
830 |
|
// liées à l'instruction |
831 |
|
$idsNotifs = $this->get_instruction_notification($this->getVal($this->clePrimaire)); |
832 |
|
if (isset($idsNotifs) && $idsNotifs !== array()) { |
833 |
|
return true; |
834 |
|
} |
835 |
|
} |
836 |
|
return false; |
837 |
|
} |
838 |
|
|
839 |
|
/** |
840 |
|
* TREATMENT - disable_edition_integrale. |
841 |
|
* |
842 |
|
* Cette methode permet de passer la consultation en "lu" |
843 |
|
* |
844 |
|
* @return boolean true si maj effectué false sinon |
845 |
|
*/ |
846 |
|
function disable_edition_integrale() { |
847 |
|
// Cette méthode permet d'exécuter une routine en début des méthodes |
848 |
|
// dites de TREATMENT. |
849 |
|
$this->begin_treatment(__METHOD__); |
850 |
|
$this->correct = true; |
851 |
|
$valF = array( |
852 |
|
"flag_edition_integrale" => false, |
853 |
|
"titre_om_htmletat" => null, |
854 |
|
"corps_om_htmletatex" => null, |
855 |
|
); |
856 |
|
$res = $this->f->db->autoExecute( |
857 |
|
DB_PREFIXE.$this->table, |
858 |
|
$valF, |
859 |
|
DB_AUTOQUERY_UPDATE, |
860 |
|
$this->clePrimaire."=".$this->getVal($this->clePrimaire) |
861 |
|
); |
862 |
|
if ($this->f->isDatabaseError($res, true)) { |
863 |
|
// Appel de la methode de recuperation des erreurs |
864 |
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
865 |
|
$this->correct = false; |
866 |
|
// Termine le traitement |
867 |
|
return $this->end_treatment(__METHOD__, false); |
868 |
|
} else { |
869 |
|
$this->addToMessage(_("Rédaction par compléments activé.")); |
870 |
|
return $this->end_treatment(__METHOD__, true); |
871 |
|
} |
872 |
|
|
873 |
|
// Termine le traitement |
874 |
|
return $this->end_treatment(__METHOD__, false); |
875 |
} |
} |
876 |
|
|
877 |
|
/** |
878 |
|
* TREATMENT - enable_edition_integrale. |
879 |
|
* |
880 |
|
* Cette methode permet de passer la consultation en "lu" |
881 |
|
* |
882 |
|
* @return boolean true si maj effectué false sinon |
883 |
|
*/ |
884 |
|
function enable_edition_integrale() { |
885 |
|
// Cette méthode permet d'exécuter une routine en début des méthodes |
886 |
|
// dites de TREATMENT. |
887 |
|
$this->begin_treatment(__METHOD__); |
888 |
|
$this->correct = true; |
889 |
|
|
890 |
|
// Récupère la collectivite du dossier d'instruction |
891 |
|
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
892 |
|
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
893 |
|
// |
894 |
|
$params = array( |
895 |
|
"specific" => array( |
896 |
|
"corps" => array( |
897 |
|
"mode" => "get", |
898 |
|
) |
899 |
|
), |
900 |
|
); |
901 |
|
$result = $this->compute_pdf_output('lettretype', $this->getVal('lettretype'), $collectivite, null, $params); |
902 |
|
$corps = $result['pdf_output']; |
903 |
|
// |
904 |
|
$params = array( |
905 |
|
"specific" => array( |
906 |
|
"titre" => array( |
907 |
|
"mode" => "get", |
908 |
|
) |
909 |
|
), |
910 |
|
); |
911 |
|
$result = $this->compute_pdf_output('lettretype', $this->getVal('lettretype'), $collectivite, null, $params); |
912 |
|
$titre = $result['pdf_output']; |
913 |
|
// |
914 |
|
$valF = array( |
915 |
|
"flag_edition_integrale" => true, |
916 |
|
"titre_om_htmletat" => $titre, |
917 |
|
"corps_om_htmletatex" => $corps, |
918 |
|
); |
919 |
|
$res = $this->f->db->autoExecute( |
920 |
|
DB_PREFIXE.$this->table, |
921 |
|
$valF, |
922 |
|
DB_AUTOQUERY_UPDATE, |
923 |
|
$this->clePrimaire."=".$this->getVal($this->clePrimaire) |
924 |
|
); |
925 |
|
if ($this->f->isDatabaseError($res, true)) { |
926 |
|
// Appel de la methode de recuperation des erreurs |
927 |
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
928 |
|
$this->correct = false; |
929 |
|
// Termine le traitement |
930 |
|
return $this->end_treatment(__METHOD__, false); |
931 |
|
} else { |
932 |
|
$this->addToMessage(_("Rédaction libre activé.")); |
933 |
|
return $this->end_treatment(__METHOD__, true); |
934 |
|
} |
935 |
|
|
936 |
|
// Termine le traitement |
937 |
|
return $this->end_treatment(__METHOD__, false); |
938 |
|
} |
939 |
|
|
940 |
/** |
/** |
941 |
* 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 |
949 |
$sql = "select dossier_autorisation from ".DB_PREFIXE."dossier "; |
$sql = "select dossier_autorisation from ".DB_PREFIXE."dossier "; |
950 |
$sql .= " where dossier='".$id."'"; |
$sql .= " where dossier='".$id."'"; |
951 |
// |
// |
952 |
$dossier_autorisation = $this->db->getOne($sql); |
$dossier_autorisation = $this->f->db->getOne($sql); |
953 |
$this->addToLog("getNumDemandeAutorFromDossier(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
$this->addToLog("getNumDemandeAutorFromDossier(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
954 |
database::isError($dossier_autorisation); |
database::isError($dossier_autorisation); |
955 |
// |
// |
959 |
// }}} |
// }}} |
960 |
|
|
961 |
function setType(&$form, $maj) { |
function setType(&$form, $maj) { |
962 |
// |
// Récupération du mode de l'action |
963 |
parent::setType($form, $maj); |
$crud = $this->get_action_crud($maj); |
964 |
// On cache tous les champs |
// Récupère la collectivité du dossier d'instruction |
965 |
// 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'); |
|
966 |
|
|
967 |
// |
// Cache tous les champs |
968 |
$form->setType('archive_date_cloture_instruction','hidden'); |
foreach ($this->champs as $value) { |
969 |
$form->setType('archive_date_premiere_visite','hidden'); |
$form->setType($value, 'hidden'); |
970 |
$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'); |
|
971 |
|
|
972 |
// |
// Les champs historique_signature et statut_signature ne sont pas saisissable dans tous les cas |
973 |
$form->setType('duree_validite','hidden'); |
if ($this->can_display_parapheur() === true) { |
974 |
$form->setType('duree_validite_parametrage','hidden'); |
$form->setType('statut_signature', 'selectstatic'); |
975 |
|
$form->setType('historique_signature', 'jsontotab'); |
976 |
|
if ($this->getVal('commentaire_signature') == null) { |
977 |
|
$form->setType('commentaire_signature', 'hidden'); |
978 |
|
} else { |
979 |
|
$form->setType('commentaire_signature', 'hiddenstatic'); |
980 |
|
} |
981 |
|
} |
982 |
|
|
983 |
// |
// Le champ de suivi des notifications n'est pas affichable dans tous les cas |
984 |
$form->setType('created_by_commune','hidden'); |
if ($this->can_display_notification() === true && $maj == 3) { |
985 |
// |
$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'); |
|
986 |
} |
} |
987 |
// |
|
988 |
if ($maj < 2 || $maj == 125) { //ajouter, modifier et suivi des dates |
// MODE AJOUTER |
989 |
$form->setType('destinataire', 'hidden'); |
if ($this->getParameter('maj') == 0) { |
990 |
$form->setType('lettretype', 'hiddenstatic'); |
$form->setType('commentaire', 'textareahidden'); |
991 |
$form->setType('complement_om_html', 'html'); |
// Si l'option est active passage du champ date en lecture seule |
992 |
$form->setType('complement2_om_html', 'html'); |
if ($this->f->is_option_date_evenement_instruction_lecture_seule($collectivite_di) === true) { |
993 |
$form->setType('complement3_om_html', 'html'); |
$form->setType("date_evenement", "hiddenstaticdate"); |
994 |
$form->setType('complement4_om_html', 'html'); |
} else { |
995 |
$form->setType('bible_auto', 'httpclick'); |
$form->setType("date_evenement", "date"); |
996 |
$form->setType('bible', 'httpclick'); |
} |
997 |
$form->setType('bible2', 'httpclick'); |
if ($this->is_in_context_of_foreign_key("evenement", $this->getParameter("retourformulaire"))) { |
998 |
$form->setType('bible3', 'httpclick'); |
$form->setType("evenement", "selecthiddenstatic"); |
999 |
$form->setType('bible4', 'httpclick'); |
} else { |
1000 |
$form->setType('dossier', 'hidden'); |
$form->setType("evenement", "select"); |
1001 |
$form->setType('libelle', 'hiddenstatic'); |
} |
1002 |
$form->setType('signataire_arrete','select'); |
if ($this->is_in_context_of_foreign_key("signataire_arrete", $this->getParameter("retourformulaire"))) { |
1003 |
$form->setType('date_envoi_signature','datedisabled'); |
$form->setType("signataire_arrete", "selecthiddenstatic"); |
1004 |
$form->setType('date_retour_signature','datedisabled'); |
} else { |
1005 |
$form->setType('date_envoi_rar','datedisabled'); |
$form->setType("signataire_arrete", "select"); |
1006 |
$form->setType('date_retour_rar','datedisabled'); |
} |
1007 |
$form->setType('date_envoi_controle_legalite','datedisabled'); |
if ($this->is_option_redaction_libre_enabled() === true) { |
1008 |
$form->setType('date_retour_controle_legalite','datedisabled'); |
$form->setType("flag_edition_integrale", "select"); |
1009 |
$form->setType('date_finalisation_courrier','datedisabled'); |
} |
1010 |
|
} |
1011 |
if($maj==0){ // ajouter |
|
1012 |
$form->setType('instruction', 'hidden'); |
// MODE MODIFIER |
1013 |
$form->setType('lettretype', 'hidden'); |
if ($this->getParameter('maj') == 1) { |
1014 |
$form->setType('evenement', 'select'); |
// Si l'option est active passage du champ date en lecture seule |
1015 |
$form->setType('date_evenement', 'date2'); |
if ($this->f->is_option_date_evenement_instruction_lecture_seule($collectivite_di) === true) { |
1016 |
}else{ // modifier et suivi des dates |
$form->setType("date_evenement", "hiddenstaticdate"); |
1017 |
$form->setType('instruction', 'hiddenstatic'); |
} else { |
1018 |
$form->setType('evenement', 'selecthiddenstatic'); |
$form->setType("date_evenement", "date"); |
1019 |
//$form->setType('date_evenement', 'hiddenstaticdate'); |
} |
1020 |
$form->setType('date_evenement', 'date2'); |
$form->setType("evenement", "selecthiddenstatic"); |
1021 |
|
if ($this->has_an_edition() === true) { |
1022 |
|
$form->setType('lettretype', 'hiddenstatic'); |
1023 |
|
if ($this->is_in_context_of_foreign_key("signataire_arrete", $this->getParameter("retourformulaire"))) { |
1024 |
|
$form->setType("signataire_arrete", "selecthiddenstatic"); |
1025 |
|
} else { |
1026 |
|
$form->setType("signataire_arrete", "select"); |
1027 |
|
} |
1028 |
|
if ($this->getVal("flag_edition_integrale") == "t") { |
1029 |
|
$form->setType("titre_om_htmletat", "htmlEtat"); |
1030 |
|
$form->setType("corps_om_htmletatex", "htmlEtatEx"); |
1031 |
|
} else { |
1032 |
|
$form->setType("complement_om_html", "html"); |
1033 |
|
$form->setType("complement2_om_html", "html"); |
1034 |
|
$form->setType("complement3_om_html", "html"); |
1035 |
|
$form->setType("complement4_om_html", "html"); |
1036 |
|
$form->setType('bible_auto', 'httpclick'); |
1037 |
|
$form->setType('bible', 'httpclick'); |
1038 |
|
$form->setType('bible2', 'httpclick'); |
1039 |
|
$form->setType('bible3', 'httpclick'); |
1040 |
|
$form->setType('bible4', 'httpclick'); |
1041 |
|
} |
1042 |
|
if ($this->f->is_option_preview_pdf_enabled($collectivite_di) === true) { |
1043 |
|
// |
1044 |
|
$form->setType('btn_refresh', 'httpclickbutton'); |
1045 |
|
$form->setType('btn_preview', 'httpclickbutton'); |
1046 |
|
$form->setType('btn_redaction', 'httpclickbutton'); |
1047 |
|
$form->setType('live_preview', 'pdf'); |
1048 |
|
} |
1049 |
|
|
1050 |
// necessaire pour calcul de date en modification |
// necessaire pour calcul de date en modification |
1051 |
//$form->setType('delai', 'hiddenstatic'); |
//$form->setType('delai', 'hiddenstatic'); |
1052 |
// les administrateurs technique et fonctionnel peuvent |
// les administrateurs technique et fonctionnel peuvent |
1053 |
// modifier tous les champs de date |
// modifier tous les champs de date |
1054 |
// 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 |
1055 |
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") |
1056 |
|| $this->f->isAccredited(array('instruction', 'instruction_modification_dates'), "OR")) |
|| $this->f->isAccredited(array('instruction', 'instruction_modification_dates'), "OR")) |
1057 |
&& $this->getVal("date_finalisation_courrier") != '') { |
&& $this->getVal("date_finalisation_courrier") != '') { |
1058 |
|
// |
1059 |
$form->setType('date_envoi_signature', 'date'); |
$form->setType('date_envoi_signature', 'date'); |
1060 |
$form->setType('date_retour_signature', 'date'); |
$form->setType('date_retour_signature', 'date'); |
1061 |
|
if ($this->is_sent_for_signature() === true |
1062 |
|
&& $this->is_signed() === true) { |
1063 |
|
// |
1064 |
|
$form->setType("date_envoi_signature", "datereadonly"); |
1065 |
|
$form->setType("date_retour_signature", "datereadonly"); |
1066 |
|
} |
1067 |
$form->setType('date_envoi_rar', 'date'); |
$form->setType('date_envoi_rar', 'date'); |
1068 |
$form->setType('date_retour_rar', 'date'); |
$form->setType('date_retour_rar', 'date'); |
1069 |
$form->setType('date_envoi_controle_legalite', 'date'); |
$form->setType('date_envoi_controle_legalite', 'date'); |
1070 |
$form->setType('date_retour_controle_legalite', 'date'); |
$form->setType('date_retour_controle_legalite', 'date'); |
1071 |
$form->setType('date_finalisation_courrier', 'date'); |
$form->setType('date_finalisation_courrier', 'date'); |
|
// suivi des dates |
|
|
if ($maj == 125) { |
|
|
$form->setType('date_evenement', 'hiddenstaticdate'); |
|
|
$form->setType('complement_om_html', 'hiddenstatic'); |
|
|
$form->setType('complement2_om_html', 'hiddenstatic'); |
|
|
$form->setType('complement3_om_html', 'hiddenstatic'); |
|
|
$form->setType('complement4_om_html', 'hiddenstatic'); |
|
|
$form->setType('bible_auto', 'hidden'); |
|
|
$form->setType('bible', 'hidden'); |
|
|
$form->setType('bible2', 'hidden'); |
|
|
$form->setType('bible3', 'hidden'); |
|
|
$form->setType('bible4', 'hidden'); |
|
|
$form->setType('signataire_arrete','selecthiddenstatic'); |
|
|
$form->setType('om_final_instruction_utilisateur', 'hiddenstatic'); |
|
|
} |
|
1072 |
} |
} |
1073 |
} |
} |
|
} elseif($maj==2){ |
|
|
$form->setType('dossier', 'hidden'); |
|
|
$form->setType('bible_auto', 'hidden'); |
|
|
$form->setType('bible', 'hidden'); |
|
|
$form->setType('bible2', 'hidden'); |
|
|
$form->setType('bible3', 'hidden'); |
|
|
$form->setType('bible4', 'hidden'); |
|
|
}else { |
|
|
$form->setType('destinataire', 'hidden'); |
|
|
$form->setType('dossier', 'hidden'); |
|
|
$form->setType('bible_auto', 'hidden'); |
|
|
$form->setType('bible', 'hidden'); |
|
|
$form->setType('bible2', 'hidden'); |
|
|
$form->setType('bible3', 'hidden'); |
|
|
$form->setType('bible4', 'hidden'); |
|
|
} |
|
|
|
|
|
//Cache les champs pour la finalisation |
|
|
$form->setType('om_fichier_instruction', 'hidden'); |
|
|
$form->setType('om_final_instruction', 'hidden'); |
|
|
// Cache le document arrêté |
|
|
$form->setType('document_numerise', 'hidden'); |
|
|
|
|
|
//Masquer les champs date_envoi_controle_legalite et |
|
|
//date_retour_controle_legalite si ce n'est pas un arrêté et si ce n'est |
|
|
//pas un utilisateur ayant le droit spécifique |
|
|
if ( !is_numeric($this->getVal("avis_decision"))&& |
|
|
!$this->f->isAccredited(array("instruction", "instruction_modification_dates"), "OR")){ |
|
|
|
|
|
$form->setType("date_envoi_controle_legalite", "hiddendate"); |
|
|
$form->setType("date_retour_controle_legalite", "hiddendate"); |
|
1074 |
} |
} |
1075 |
|
|
1076 |
// Pour les actions finalize, unfinalize et notifier_commune |
// MODE CONSULTER + SUPPRIMER + SUIVI DES DATES 125 + NOTIFICATION MANUELLE |
1077 |
if($maj == 100 || $maj == 110 || $maj == 210) { |
if ($this->getParameter('maj') == 3 |
1078 |
// |
|| $this->getParameter('maj') == 2 |
1079 |
foreach ($this->champs as $value) { |
|| $this->getParameter('maj') == 125 |
1080 |
// Cache tous les champs |
|| $this->getParameter('maj') == 410) { |
1081 |
$form->setType($value, 'hidden'); |
// |
1082 |
|
$form->setType("date_evenement", "datestatic"); |
1083 |
|
$form->setType("evenement", "selecthiddenstatic"); |
1084 |
|
if ($this->has_an_edition() === true) { |
1085 |
|
$form->setType('lettretype', 'hiddenstatic'); |
1086 |
|
$form->setType("signataire_arrete", "selecthiddenstatic"); |
1087 |
|
if ($this->getVal("om_final_instruction") == 't') { |
1088 |
|
$form->setType('om_final_instruction_utilisateur', 'textareastatic'); |
1089 |
|
} else { |
1090 |
|
$form->setType('om_final_instruction_utilisateur', 'hidden'); |
1091 |
|
} |
1092 |
|
} |
1093 |
|
if ($this->evenement_has_a_commentaire($this->getVal('evenement')) === true ) { |
1094 |
|
$form->setType('commentaire', 'textareastatic'); |
1095 |
} |
} |
1096 |
} |
} |
1097 |
|
|
1098 |
|
// MODE CONSULTER + SUPPRIMER + NOTIFICATION MANUELLE |
1099 |
|
if ($this->getParameter('maj') == 3 |
1100 |
|
|| $this->getParameter('maj') == 2 |
1101 |
|
|| $this->getParameter('maj') == 410) { |
1102 |
|
// Si il n'y a pas de lettre type (edition) associé à l'événement |
1103 |
|
// les dates de suivi ne sont pas affichée |
1104 |
|
if ($this->has_an_edition() === true) { |
1105 |
|
$form->setType('date_envoi_signature', 'datestatic'); |
1106 |
|
$form->setType('date_retour_signature', 'datestatic'); |
1107 |
|
$form->setType('date_envoi_rar', 'datestatic'); |
1108 |
|
$form->setType('date_retour_rar', 'datestatic'); |
1109 |
|
$form->setType('date_envoi_controle_legalite', 'datestatic'); |
1110 |
|
$form->setType('date_retour_controle_legalite', 'datestatic'); |
1111 |
|
$form->setType('date_finalisation_courrier', 'datestatic'); |
1112 |
|
if ($this->getVal("flag_edition_integrale") == "t") { |
1113 |
|
$form->setType("titre_om_htmletat", "htmlstatic"); |
1114 |
|
$form->setType("corps_om_htmletatex", "htmlstatic"); |
1115 |
|
} else { |
1116 |
|
$form->setType("complement_om_html", "htmlstatic"); |
1117 |
|
$form->setType("complement2_om_html", "htmlstatic"); |
1118 |
|
$form->setType("complement3_om_html", "htmlstatic"); |
1119 |
|
$form->setType("complement4_om_html", "htmlstatic"); |
1120 |
|
} |
1121 |
|
} |
1122 |
|
} |
1123 |
|
|
1124 |
|
// MODE SUIVI DES DATES 125 |
1125 |
|
if ($this->getParameter('maj') == 125) { |
1126 |
|
$form->setType("date_evenement", "hiddenstaticdate"); |
1127 |
|
$form->setType('om_final_instruction_utilisateur', 'hiddenstatic'); |
1128 |
|
$form->setType('date_envoi_signature', 'date'); |
1129 |
|
$form->setType('date_retour_signature', 'date'); |
1130 |
|
if ($this->is_sent_for_signature() === true |
1131 |
|
|| $this->is_signed() === true) { |
1132 |
|
// |
1133 |
|
$form->setType("date_envoi_signature", "datereadonly"); |
1134 |
|
$form->setType("date_retour_signature", "datereadonly"); |
1135 |
|
} |
1136 |
|
$form->setType('date_envoi_rar', 'date'); |
1137 |
|
$form->setType('date_retour_rar', 'date'); |
1138 |
|
$form->setType('date_envoi_controle_legalite', 'date'); |
1139 |
|
$form->setType('date_retour_controle_legalite', 'date'); |
1140 |
|
$form->setType('date_finalisation_courrier', 'date'); |
1141 |
|
} |
1142 |
|
|
1143 |
|
if ($maj == 401) { |
1144 |
|
foreach ($this->champs as $champ) { |
1145 |
|
$form->setType($champ, 'hidden'); |
1146 |
|
} |
1147 |
|
$form->setType('preview_edition', 'pdf'); |
1148 |
|
} |
1149 |
|
} |
1150 |
|
|
1151 |
|
function setOnchange(&$form,$maj){ |
1152 |
|
parent::setOnchange($form,$maj); |
1153 |
|
|
1154 |
|
// MODE AJOUTER |
1155 |
|
if ($this->getParameter('maj') == 0) { |
1156 |
|
$form->setOnchange( |
1157 |
|
"evenement", |
1158 |
|
"manage_instruction_evenement_lettretype(this.value, '".addslashes($this->getParameter('idxformulaire'))."'); |
1159 |
|
manage_instruction_evenement_commentaire(this.value, '".addslashes($this->getParameter('idxformulaire'))."');" |
1160 |
|
); |
1161 |
|
} |
1162 |
|
} |
1163 |
|
|
1164 |
|
function evenement_has_an_edition($evenement_id) { |
1165 |
|
$evenement = $this->get_inst_evenement($evenement_id); |
1166 |
|
$lettretype = $evenement->getVal('lettretype'); |
1167 |
|
if ($lettretype !== '' && $lettretype !== null) { |
1168 |
|
return true; |
1169 |
|
} |
1170 |
|
return false; |
1171 |
} |
} |
1172 |
|
|
1173 |
function setSelect(&$form, $maj,&$db,$debug) { |
function view_evenement_has_an_edition_json() { |
1174 |
|
$json_return = array( |
1175 |
|
"lettretype" => $this->evenement_has_an_edition($this->f->get_submitted_get_value('evenement_id')), |
1176 |
|
"option_redaction_libre_enabled" => $this->is_option_redaction_libre_enabled(), |
1177 |
|
); |
1178 |
|
echo json_encode($json_return); |
1179 |
|
} |
1180 |
|
|
1181 |
|
function evenement_has_a_commentaire($evenement_id) { |
1182 |
|
$evenement = $this->get_inst_evenement($evenement_id); |
1183 |
|
return $this->get_boolean_from_pgsql_value($evenement->getVal('commentaire')); |
1184 |
|
} |
1185 |
|
|
1186 |
|
function view_evenement_has_a_commentaire_json() { |
1187 |
|
$json_return = array( |
1188 |
|
"commentaire" => $this->evenement_has_a_commentaire($this->f->get_submitted_get_value('evenement_id')) |
1189 |
|
); |
1190 |
|
echo json_encode($json_return); |
1191 |
|
} |
1192 |
|
|
1193 |
|
/** |
1194 |
|
* |
1195 |
|
* @return string |
1196 |
|
*/ |
1197 |
|
function get_var_sql_forminc__sql_signataire_arrete() { |
1198 |
|
return "SELECT |
1199 |
|
signataire_arrete.signataire_arrete, |
1200 |
|
CONCAT(signataire_arrete.prenom, ' ', signataire_arrete.nom) |
1201 |
|
FROM ".DB_PREFIXE."signataire_arrete |
1202 |
|
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))) |
1203 |
|
ORDER BY signataire_arrete.prenom, signataire_arrete.nom"; |
1204 |
|
} |
1205 |
|
|
1206 |
|
/** |
1207 |
|
* |
1208 |
|
* @return string |
1209 |
|
*/ |
1210 |
|
function get_var_sql_forminc__sql_signataire_arrete_by_id() { |
1211 |
|
return "SELECT |
1212 |
|
signataire_arrete.signataire_arrete, |
1213 |
|
CONCAT(signataire_arrete.prenom, ' ', signataire_arrete.nom) |
1214 |
|
FROM ".DB_PREFIXE."signataire_arrete |
1215 |
|
WHERE signataire_arrete.signataire_arrete = <idx>"; |
1216 |
|
} |
1217 |
|
|
1218 |
|
/** |
1219 |
|
* |
1220 |
|
* @return string |
1221 |
|
*/ |
1222 |
|
function get_var_sql_forminc__sql_signataire_arrete_by_di() { |
1223 |
|
return "SELECT |
1224 |
|
signataire_arrete.signataire_arrete, |
1225 |
|
CONCAT(signataire_arrete.prenom, ' ', signataire_arrete.nom) |
1226 |
|
FROM ".DB_PREFIXE."signataire_arrete |
1227 |
|
LEFT JOIN ".DB_PREFIXE."om_collectivite ON signataire_arrete.om_collectivite = om_collectivite.om_collectivite |
1228 |
|
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))) |
1229 |
|
AND (om_collectivite.niveau = '2' OR signataire_arrete.om_collectivite = <collectivite_di>) |
1230 |
|
ORDER BY signataire_arrete.prenom, signataire_arrete.nom"; |
1231 |
|
} |
1232 |
|
|
1233 |
|
/** |
1234 |
|
* |
1235 |
|
* @return string |
1236 |
|
*/ |
1237 |
|
function get_var_sql_forminc__sql_signataire_arrete_defaut() { |
1238 |
|
return "SELECT |
1239 |
|
signataire_arrete.signataire_arrete, |
1240 |
|
CONCAT(signataire_arrete.prenom, ' ', signataire_arrete.nom) |
1241 |
|
FROM ".DB_PREFIXE."signataire_arrete |
1242 |
|
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 |
1243 |
|
ORDER BY signataire_arrete.prenom, signataire_arrete.nom"; |
1244 |
|
} |
1245 |
|
|
1246 |
|
/** |
1247 |
|
* |
1248 |
|
* @return string |
1249 |
|
*/ |
1250 |
|
function get_var_sql_forminc__sql_signataire_arrete_defaut_by_di() { |
1251 |
|
return "SELECT |
1252 |
|
signataire_arrete.signataire_arrete, |
1253 |
|
CONCAT(signataire_arrete.prenom, ' ', signataire_arrete.nom) |
1254 |
|
FROM ".DB_PREFIXE."signataire_arrete |
1255 |
|
LEFT JOIN ".DB_PREFIXE."om_collectivite ON signataire_arrete.om_collectivite = om_collectivite.om_collectivite |
1256 |
|
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 |
1257 |
|
AND (om_collectivite.niveau = '2' OR signataire_arrete.om_collectivite = <collectivite_di>) |
1258 |
|
ORDER BY signataire_arrete.prenom, signataire_arrete.nom"; |
1259 |
|
} |
1260 |
|
|
1261 |
|
/** |
1262 |
|
* SETTER_FORM - setSelect. |
1263 |
|
* |
1264 |
|
* @return void |
1265 |
|
*/ |
1266 |
|
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
1267 |
|
//parent::setSelect($form, $maj); |
1268 |
/** |
/** |
1269 |
* 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 |
1270 |
* dossier est mauvaise pour les performances, car la requête qui |
* dossier est mauvaise pour les performances, car la requête qui |
1272 |
* 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 |
1273 |
* select |
* select |
1274 |
*/ |
*/ |
|
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"); |
|
|
|
|
1275 |
//// action |
//// action |
1276 |
//$this->init_select($form, $db, $maj, $debug, "action", |
//$this->init_select($form, $this->f->db, $maj, null, "action", |
1277 |
// $sql_action, $sql_action_by_id, false); |
// $sql_action, $sql_action_by_id, false); |
1278 |
|
|
1279 |
//// avis_decision |
//// avis_decision |
1280 |
//$this->init_select($form, $db, $maj, $debug, "avis_decision", |
//$this->init_select($form, $this->f->db, $maj, null, "avis_decision", |
1281 |
// $sql_avis_decision, $sql_avis_decision_by_id, false); |
// $sql_avis_decision, $sql_avis_decision_by_id, false); |
1282 |
|
|
1283 |
//// dossier |
//// dossier |
1284 |
//$this->init_select($form, $db, $maj, $debug, "dossier", |
//$this->init_select($form, $this->f->db, $maj, null, "dossier", |
1285 |
// $sql_dossier, $sql_dossier_by_id, false); |
// $sql_dossier, $sql_dossier_by_id, false); |
1286 |
|
|
1287 |
//// etat |
//// etat |
1288 |
//$this->init_select($form, $db, $maj, $debug, "etat", |
//$this->init_select($form, $this->f->db, $maj, null, "etat", |
1289 |
// $sql_etat, $sql_etat_by_id, false); |
// $sql_etat, $sql_etat_by_id, false); |
1290 |
|
|
1291 |
//// evenement |
//// evenement |
1292 |
//$this->init_select($form, $db, $maj, $debug, "evenement", |
//$this->init_select($form, $this->f->db, $maj, null, "evenement", |
1293 |
// $sql_evenement, $sql_evenement_by_id, false); |
// $sql_evenement, $sql_evenement_by_id, false); |
1294 |
|
|
1295 |
// signataire_arrete |
// signataire_arrete |
1305 |
|| $this->getParameter("retourformulaire") == "dossier_contentieux_mes_recours" |
|| $this->getParameter("retourformulaire") == "dossier_contentieux_mes_recours" |
1306 |
|| $this->getParameter("retourformulaire") == "dossier_contentieux_tous_recours") { |
|| $this->getParameter("retourformulaire") == "dossier_contentieux_tous_recours") { |
1307 |
// 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 |
1308 |
require_once "../obj/dossier_instruction.class.php"; |
$di = $this->f->get_inst__om_dbform(array( |
1309 |
$di = new dossier_instruction($this->getParameter('idxformulaire'), $db, $debug); |
"obj" => "dossier_instruction", |
1310 |
$sql_signataire_arrete_by_di = str_replace('<collectivite_di>', $di->getVal("om_collectivite"), $sql_signataire_arrete_by_di); |
"idx" => $this->getParameter('idxformulaire'), |
1311 |
$this->init_select($form, $db, $maj, $debug, "signataire_arrete", |
)); |
1312 |
$sql_signataire_arrete_by_di, $sql_signataire_arrete_by_id, true); |
$sql_signataire_arrete_by_di = str_replace( |
1313 |
|
'<collectivite_di>', |
1314 |
|
$di->getVal("om_collectivite"), |
1315 |
|
$this->get_var_sql_forminc__sql("signataire_arrete_by_di") |
1316 |
|
); |
1317 |
|
$this->init_select( |
1318 |
|
$form, |
1319 |
|
$this->f->db, |
1320 |
|
$maj, |
1321 |
|
null, |
1322 |
|
"signataire_arrete", |
1323 |
|
$sql_signataire_arrete_by_di, |
1324 |
|
$this->get_var_sql_forminc__sql("signataire_arrete_by_id"), |
1325 |
|
true |
1326 |
|
); |
1327 |
} else { |
} else { |
1328 |
$this->init_select($form, $db, $maj, $debug, "signataire_arrete", |
$this->init_select( |
1329 |
$sql_signataire_arrete, $sql_signataire_arrete_by_id, true); |
$form, |
1330 |
|
$this->f->db, |
1331 |
|
$maj, |
1332 |
|
null, |
1333 |
|
"signataire_arrete", |
1334 |
|
$this->get_var_sql_forminc__sql("signataire_arrete"), |
1335 |
|
$this->get_var_sql_forminc__sql("signataire_arrete_by_id"), |
1336 |
|
true |
1337 |
|
); |
1338 |
} |
} |
1339 |
|
|
1340 |
/** |
/** |
1359 |
INNER JOIN ".DB_PREFIXE."transition |
INNER JOIN ".DB_PREFIXE."transition |
1360 |
ON evenement.evenement = transition.evenement |
ON evenement.evenement = transition.evenement |
1361 |
AND dossier.etat=transition.etat |
AND dossier.etat=transition.etat |
1362 |
WHERE dossier.dossier='".$this->idxformulaire."' "; |
WHERE dossier.dossier='".$this->getParameter("idxformulaire")."' "; |
1363 |
|
|
1364 |
// Si changement de décision par instructeur commune |
// Si changement de décision par instructeur commune |
1365 |
if($this->f->isUserInstructeur() === true |
if($this->f->isUserInstructeur() === true |
1366 |
&& $this->getDivisionFromDossier($this->idxformulaire) != $_SESSION["division"] |
&& $this->getDivisionFromDossier($this->getParameter("idxformulaire")) != $_SESSION["division"] |
1367 |
&& $this->isInstrCanChangeDecision($this->idxformulaire) === true) { |
&& $this->isInstrCanChangeDecision($this->getParameter("idxformulaire")) === true) { |
1368 |
$sql .= "AND evenement.type IN ('arrete', 'changement_decision') "; |
$sql .= "AND evenement.type IN ('arrete', 'changement_decision') "; |
1369 |
} |
} |
1370 |
$sql .= "ORDER BY evenement.libelle, evenement.action"; |
$sql .= "ORDER BY evenement.libelle, evenement.action"; |
1371 |
$res = $db->query($sql); |
$res = $this->f->db->query($sql); |
1372 |
$this->addToLog("setSelect(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog("setSelect(): db->query(\"".$sql."\");", VERBOSE_MODE); |
1373 |
if (database::isError($res)) { |
if (database::isError($res)) { |
1374 |
die($res->getMessage()); |
die($res->getMessage()); |
1383 |
$contenu[1][] = $row[1]; |
$contenu[1][] = $row[1]; |
1384 |
} |
} |
1385 |
$form->setSelect("evenement", $contenu); |
$form->setSelect("evenement", $contenu); |
1386 |
|
|
1387 |
} else { |
} else { |
1388 |
$sql = "SELECT |
$sql = "SELECT |
1389 |
evenement.libelle as lib |
evenement.libelle as lib |
1390 |
FROM ".DB_PREFIXE."evenement |
FROM ".DB_PREFIXE."evenement |
1391 |
WHERE evenement.evenement=".$this->getVal("evenement").""; |
WHERE evenement.evenement=".$this->getVal("evenement").""; |
1392 |
$res = $db->getone($sql); |
$res = $this->f->db->getone($sql); |
1393 |
$this->addToLog("setSelect(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog("setSelect(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
1394 |
if (database::isError($res)) { |
if (database::isError($res)) { |
1395 |
die($res->getMessage()); |
die($res->getMessage()); |
1420 |
// lien bible4 |
// lien bible4 |
1421 |
$contenu = array(_("bible")); |
$contenu = array(_("bible")); |
1422 |
$form->setSelect("bible4",$contenu); |
$form->setSelect("bible4",$contenu); |
1423 |
|
|
1424 |
|
if ($maj == 1) { |
1425 |
|
$base64 = $this->init_pdf_temp(); |
1426 |
|
$form->setSelect('live_preview', array('base64'=>$base64)); |
1427 |
|
$form->setSelect("btn_refresh", array(_('Prévisualiser'))); |
1428 |
|
$form->setSelect("btn_preview", array(_('Prévisualiser >>'))); |
1429 |
|
$form->setSelect("btn_redaction", array(_('<< Rédiger'))); |
1430 |
|
} |
1431 |
|
|
1432 |
|
// Selection du type de rédaction à l'ajout |
1433 |
|
$content = array( |
1434 |
|
0 => array('f', 't', ), |
1435 |
|
1 => array(_('Rédaction par compléments'), _('Rédaction libre'), ), |
1436 |
|
); |
1437 |
|
$form->setSelect('flag_edition_integrale', $content); |
1438 |
|
|
1439 |
|
$contenu = array(); |
1440 |
|
foreach(array('waiting', 'in_progress', 'canceled', 'expired', 'finished') as $value) { |
1441 |
|
$contenu[0][] = $value; |
1442 |
|
$contenu[1][] = $this->get_trad_for_statut($value); |
1443 |
|
} |
1444 |
|
$form->setSelect('statut_signature', $contenu); |
1445 |
|
|
1446 |
|
|
1447 |
|
if ($maj == 401) { |
1448 |
|
$file = $this->f->storage->get($this->getVal('om_fichier_instruction')); |
1449 |
|
$base64 = base64_encode($file['file_content']); |
1450 |
|
$form->setSelect('preview_edition', array('base64' => $base64)); |
1451 |
|
} |
1452 |
} |
} |
1453 |
|
|
1454 |
function cleSecondaire($id, &$db, $val, $DEBUG) { |
function cleSecondaire($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
1455 |
// |
// |
1456 |
parent::cleSecondaire($id, $db, $val, $DEBUG); |
parent::cleSecondaire($id, $dnu1, $val); |
1457 |
|
|
1458 |
$id = $this->getVal($this->clePrimaire); |
$id = $this->getVal($this->clePrimaire); |
1459 |
|
|
1465 |
LEFT JOIN ".DB_PREFIXE."demande |
LEFT JOIN ".DB_PREFIXE."demande |
1466 |
ON demande.demande_type = demande_type.demande_type |
ON demande.demande_type = demande_type.demande_type |
1467 |
WHERE demande.instruction_recepisse = ".$id; |
WHERE demande.instruction_recepisse = ".$id; |
1468 |
$res = $this->db->getOne($sql); |
$res = $this->f->db->getOne($sql); |
1469 |
$this->addToLog("cleSecondaire(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog("cleSecondaire(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
1470 |
if (database::isError($res)) { |
if (database::isError($res)) { |
1471 |
die($res->getMessage()); |
die($res->getMessage()); |
1481 |
$sql = "SELECT demande |
$sql = "SELECT demande |
1482 |
FROM ".DB_PREFIXE."demande |
FROM ".DB_PREFIXE."demande |
1483 |
WHERE instruction_recepisse = ".$id; |
WHERE instruction_recepisse = ".$id; |
1484 |
$res = $this->db->getOne($sql); |
$res = $this->f->db->getOne($sql); |
1485 |
$this->addToLog("cleSecondaire(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog("cleSecondaire(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
1486 |
if (database::isError($res)) { |
if (database::isError($res)) { |
1487 |
die($res->getMessage()); |
die($res->getMessage()); |
1489 |
|
|
1490 |
//Si c'est un événement d'instruction lié à une demande |
//Si c'est un événement d'instruction lié à une demande |
1491 |
if ($res != null || $res != ""){ |
if ($res != null || $res != ""){ |
1492 |
|
$demande = $this->f->get_inst__om_dbform(array( |
1493 |
require_once "../obj/demande.class.php"; |
"obj" => "demande", |
1494 |
$demande = new demande($res, $this->db, DEBUG); |
"idx" => $res, |
1495 |
|
)); |
1496 |
|
|
1497 |
//On met à jour la demande en supprimant la liaison vers |
//On met à jour la demande en supprimant la liaison vers |
1498 |
//l'événement d'instruction |
//l'événement d'instruction |
1503 |
} |
} |
1504 |
$valF['date_demande']=$demande->dateDBToForm($valF['date_demande']); |
$valF['date_demande']=$demande->dateDBToForm($valF['date_demande']); |
1505 |
$valF['instruction_recepisse']=NULL; |
$valF['instruction_recepisse']=NULL; |
1506 |
$ret = $demande->modifier($valF, $this->db, DEBUG); |
$ret = $demande->modifier($valF); |
1507 |
} |
} |
1508 |
|
|
1509 |
/** |
/** |
1516 |
// concerne le dossier en cours |
// concerne le dossier en cours |
1517 |
$sql = "SELECT max(instruction) |
$sql = "SELECT max(instruction) |
1518 |
FROM ".DB_PREFIXE."instruction |
FROM ".DB_PREFIXE."instruction |
1519 |
WHERE dossier ='".$this->idxformulaire."'"; |
WHERE dossier ='".$this->getParameter("idxformulaire")."'"; |
1520 |
$dernierevenement = $db->getOne($sql); |
$dernierevenement = $this->f->db->getOne($sql); |
1521 |
$this->addToLog("setSelect(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog("setSelect(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
1522 |
if (database::isError($dernierevenement)) { |
if (database::isError($dernierevenement)) { |
1523 |
die($dernierevenement->getMessage()); |
die($dernierevenement->getMessage()); |
1567 |
return true; |
return true; |
1568 |
} |
} |
1569 |
|
|
1570 |
/*Met des valeurs par défaut dans certains des sous-formulaire*/ |
/** |
1571 |
function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire){ |
* SETTER_FORM - setValsousformulaire (setVal). |
1572 |
|
* |
1573 |
|
* @return void |
1574 |
|
*/ |
1575 |
|
function setValsousformulaire(&$form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire, &$dnu1 = null, $dnu2 = null) { |
1576 |
|
// parent::setValsousformulaire($form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire); |
1577 |
|
// |
1578 |
|
$this->retourformulaire = $retourformulaire; |
1579 |
// |
// |
|
$this->retourformulaire=$retourformulaire; |
|
|
$this->idxformulaire=$idxformulaire; |
|
|
// Ajout |
|
1580 |
if ($maj == 0) { |
if ($maj == 0) { |
1581 |
$form->setVal("destinataire", $idxformulaire); |
$form->setVal("destinataire", $this->getParameter("idxformulaire")); |
1582 |
$form->setVal("dossier", $idxformulaire); |
$form->setVal("dossier", $this->getParameter("idxformulaire")); |
1583 |
} |
} |
1584 |
// |
// |
1585 |
$this->set_form_default_values($form, $maj, $validation); |
$this->set_form_default_values($form, $maj, $validation); |
1586 |
} |
} |
1587 |
|
|
1588 |
/** |
/** |
1589 |
* Permet de pré-remplir les valeurs des formulaires. |
* SETTER_FORM - set_form_default_values (setVal). |
1590 |
* |
* |
1591 |
* @param [object] $form formulaire |
* @return void |
|
* @param [integer] $maj mode |
|
|
* @param [integer] $validation validation |
|
1592 |
*/ |
*/ |
1593 |
function set_form_default_values(&$form, $maj, $validation) { |
function set_form_default_values(&$form, $maj, $validation) { |
1594 |
|
// |
|
// Ajout |
|
1595 |
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"); |
|
1596 |
// si contexte DI |
// si contexte DI |
1597 |
if ($this->getParameter("retourformulaire") == "dossier" |
if ($this->getParameter("retourformulaire") == "dossier" |
1598 |
|| $this->getParameter("retourformulaire") == "dossier_instruction" |
|| $this->getParameter("retourformulaire") == "dossier_instruction" |
1605 |
|| $this->getParameter("retourformulaire") == "dossier_contentieux_mes_recours" |
|| $this->getParameter("retourformulaire") == "dossier_contentieux_mes_recours" |
1606 |
|| $this->getParameter("retourformulaire") == "dossier_contentieux_tous_recours") { |
|| $this->getParameter("retourformulaire") == "dossier_contentieux_tous_recours") { |
1607 |
// 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 |
1608 |
require_once "../obj/dossier_instruction.class.php"; |
$di = $this->f->get_inst__om_dbform(array( |
1609 |
$di = new dossier_instruction($this->getParameter('idxformulaire'), $db, DEBUG); |
"obj" => "dossier_instruction", |
1610 |
$sql = str_replace('<collectivite_di>', $di->getVal("om_collectivite"), $sql_signataire_arrete_defaut_by_di); |
"idx" => $this->getParameter("idxformulaire"), |
1611 |
|
)); |
1612 |
|
$sql = str_replace( |
1613 |
|
"<collectivite_di>", |
1614 |
|
$di->getVal("om_collectivite"), |
1615 |
|
$this->get_var_sql_forminc__sql("signataire_arrete_defaut_by_di") |
1616 |
|
); |
1617 |
} else { |
} else { |
1618 |
$sql = $sql_signataire_arrete_defaut; |
$sql = $this->get_var_sql_forminc__sql("signataire_arrete_defaut"); |
1619 |
} |
} |
|
// Date du jour |
|
|
$form->setVal("date_evenement", date('Y-m-d')); |
|
|
|
|
|
// Exécution de la requête |
|
1620 |
$res = $this->f->db->query($sql); |
$res = $this->f->db->query($sql); |
1621 |
$this->f->addToLog("setVal(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__."(): db->query(\"".$sql."\")", VERBOSE_MODE); |
1622 |
if ( database::isError($res)){ |
$this->f->isDatabaseError($res); |
|
die(); |
|
|
} |
|
|
|
|
1623 |
$row = $res->fetchrow(DB_FETCHMODE_ASSOC); |
$row = $res->fetchrow(DB_FETCHMODE_ASSOC); |
1624 |
|
if (isset($row["signataire_arrete"]) |
1625 |
if (isset($row['signataire_arrete']) && is_numeric($row['signataire_arrete'])){ |
&& is_numeric($row["signataire_arrete"])) { |
1626 |
$form->setVal("signataire_arrete",$row['signataire_arrete']); |
// |
1627 |
|
$form->setVal("signataire_arrete", $row["signataire_arrete"]); |
1628 |
} |
} |
1629 |
|
// Date du jour |
1630 |
|
$form->setVal("date_evenement", date("Y-m-d")); |
1631 |
} |
} |
1632 |
|
// |
|
// Ajout et modification |
|
1633 |
if ($maj == 0 || $maj == 1 || $maj == 125) { |
if ($maj == 0 || $maj == 1 || $maj == 125) { |
1634 |
$form->setVal("bible_auto","bible_auto()"); |
$form->setVal("bible_auto", "bible_auto()"); |
1635 |
$form->setVal("bible","bible(1)"); |
$form->setVal("bible", "bible(1)"); |
1636 |
$form->setVal("bible2","bible(2)"); |
$form->setVal("bible2", "bible(2)"); |
1637 |
$form->setVal("bible3","bible(3)"); |
$form->setVal("bible3", "bible(3)"); |
1638 |
$form->setVal("bible4","bible(4)"); |
$form->setVal("bible4", "bible(4)"); |
1639 |
|
} |
1640 |
|
// |
1641 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite(); |
1642 |
|
if ($maj == 1 |
1643 |
|
&& $this->f->is_option_preview_pdf_enabled($collectivite_di) === true |
1644 |
|
&& $this->has_an_edition() === true) { |
1645 |
|
// |
1646 |
|
$form->setVal("live_preview", $this->getVal($this->clePrimaire)); |
1647 |
|
$form->setVal("btn_refresh", "reload_pdf_viewer()"); |
1648 |
|
$form->setVal("btn_preview", "show_instr_preview()"); |
1649 |
|
$form->setVal("btn_redaction", "show_instr_redaction()"); |
1650 |
} |
} |
|
} |
|
1651 |
|
|
1652 |
|
if ($maj == 3 |
1653 |
|
&& $this->can_display_notification() |
1654 |
|
) { |
1655 |
|
$form->setVal("suivi_notification", $this->get_json_suivi_notification()); |
1656 |
|
} |
1657 |
|
} |
1658 |
|
|
1659 |
function setLayout(&$form, $maj){ |
function setLayout(&$form, $maj){ |
1660 |
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"); |
|
1661 |
|
|
1662 |
$form->setFieldset('evenement','D',_('Evenement')); |
$form->setFieldset('evenement','D',_('Evenement')); |
1663 |
$form->setFieldset('om_final_instruction_utilisateur','F',''); |
$form->setFieldset('om_final_instruction_utilisateur','F',''); |
1664 |
|
|
1665 |
$form->setBloc('om_final_instruction_utilisateur','F'); |
$form->setBloc('om_final_instruction_utilisateur','F'); |
1666 |
|
|
1667 |
$form->setBloc('date_finalisation_courrier','D',"","col_12"); |
$form->setBloc('date_finalisation_courrier','D',"",""); |
1668 |
|
|
1669 |
$form->setFieldset('date_finalisation_courrier','D',_('Dates')); |
$form->setFieldset('date_finalisation_courrier','D',_('Dates')); |
1670 |
$form->setBloc('date_finalisation_courrier','D',"","col_6"); |
$form->setBloc('date_finalisation_courrier','D',"","col_6"); |
1671 |
$form->setBloc('date_envoi_controle_legalite','F'); |
$form->setBloc('date_envoi_controle_legalite','F'); |
1672 |
|
|
1673 |
$form->setBloc('signataire_arrete','D',"","col_6"); |
$form->setBloc('date_retour_signature','D',"","col_6"); |
1674 |
$form->setBloc('date_retour_controle_legalite','F'); |
$form->setBloc('date_retour_controle_legalite','F'); |
1675 |
$form->setFieldset('date_retour_controle_legalite','F',''); |
$form->setFieldset('date_retour_controle_legalite','F',''); |
1676 |
|
|
1677 |
$form->setBloc('date_retour_controle_legalite','F'); |
$form->setBloc('date_retour_controle_legalite','F'); |
1678 |
|
|
1679 |
$form->setBloc('complement_om_html','D',"","col_12"); |
$form->setBloc('statut_signature','D'); |
1680 |
|
$form->setFieldset('statut_signature','D','Suivi Parapheur'); |
1681 |
|
$form->setBloc('commentaire_signature','F'); |
1682 |
|
$form->setBloc('historique_signature','D'); |
1683 |
|
$form->setFieldset('historique_signature', 'DF', __("Historique"), "collapsible, startClosed"); |
1684 |
|
$form->setBloc('historique_signature','F'); |
1685 |
|
$form->setFieldset('historique_signature','F'); |
1686 |
|
|
1687 |
|
$form->setFieldset('suivi_notification', 'D', __("Suivi notification"), "collapsible"); |
1688 |
|
$form->setFieldset('suivi_notification','F'); |
1689 |
|
|
1690 |
|
if ($maj == 1) { |
1691 |
|
// Récupère la collectivité du dossier d'instruction |
1692 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite(); |
1693 |
|
|
1694 |
|
// |
1695 |
|
if ($this->f->is_option_preview_pdf_enabled($collectivite_di) === true |
1696 |
|
&& $this->has_an_edition() === true) { |
1697 |
|
// |
1698 |
|
$form->setBloc('complement_om_html','D',"","container_instr_edition"); |
1699 |
|
$form->setBloc('complement_om_html','D',"","hidelabel box_instr_edition redaction_instr_edition"); |
1700 |
|
$form->setBloc('complement_om_html','D',"","box_instr_edition_main"); |
1701 |
|
$form->setFieldset('complement_om_html','D',_('Complement')); |
1702 |
|
$form->setFieldset('bible','F',''); |
1703 |
|
$form->setFieldset('complement2_om_html','D',_('Complement 2')); |
1704 |
|
$form->setFieldset('bible2','F',''); |
1705 |
|
$form->setFieldset('complement3_om_html','D',_('Complement 3')); |
1706 |
|
$form->setFieldset('bible3','F',''); |
1707 |
|
$form->setFieldset('complement4_om_html','D',_('Complement 4')); |
1708 |
|
$form->setFieldset('bible4','F',''); |
1709 |
|
$form->setFieldset('titre_om_htmletat','DF',_('Titre'), 'startClosed'); |
1710 |
|
$form->setFieldset('corps_om_htmletatex','DF',_('Corps')); |
1711 |
|
$form->setBloc('corps_om_htmletatex','F'); |
1712 |
|
$form->setBloc('btn_preview','DF',"","box_instr_edition_btn"); |
1713 |
|
$form->setBloc('btn_preview','F'); |
1714 |
|
$form->setBloc('btn_redaction','D', '',"hidelabel box_instr_edition preview_instr_edition"); |
1715 |
|
$form->setBloc('btn_redaction','DF',"","box_instr_edition_btn"); |
1716 |
|
$form->setFieldset('btn_refresh','D',_('Prévisualisation'), "box_instr_edition_main"); |
1717 |
|
$form->setFieldset('live_preview','F'); |
1718 |
|
$form->setBloc('live_preview','F'); |
1719 |
|
$form->setBloc('live_preview','F'); |
1720 |
|
} else { |
1721 |
|
$form->setBloc('complement_om_html','D',"","hidelabel"); |
1722 |
|
$form->setFieldset('complement_om_html','D',_('Complement')); |
1723 |
|
$form->setFieldset('bible','F',''); |
1724 |
|
$form->setFieldset('complement2_om_html','D',_('Complement 2')); |
1725 |
|
$form->setFieldset('bible2','F',''); |
1726 |
|
$form->setFieldset('complement3_om_html','D',_('Complement 3')); |
1727 |
|
$form->setFieldset('bible3','F',''); |
1728 |
|
$form->setFieldset('complement4_om_html','D',_('Complement 4')); |
1729 |
|
$form->setFieldset('bible4','F',''); |
1730 |
|
$form->setFieldset('titre_om_htmletat','DF',_('Titre'), 'startClosed'); |
1731 |
|
$form->setFieldset('corps_om_htmletatex','DF',_('Corps')); |
1732 |
|
$form->setBloc('corps_om_htmletatex','F'); |
1733 |
|
} |
1734 |
|
} else { |
1735 |
|
$form->setBloc('complement_om_html','D',"","hidelabel"); |
1736 |
$form->setFieldset('complement_om_html','D',_('Complement')); |
$form->setFieldset('complement_om_html','D',_('Complement')); |
1737 |
$form->setFieldset('bible','F',''); |
$form->setFieldset('bible','F',''); |
|
$form->setBloc('bible','F'); |
|
|
|
|
|
$form->setBloc('complement2_om_html','D',"","col_12"); |
|
1738 |
$form->setFieldset('complement2_om_html','D',_('Complement 2')); |
$form->setFieldset('complement2_om_html','D',_('Complement 2')); |
1739 |
$form->setFieldset('bible2','F',''); |
$form->setFieldset('bible2','F',''); |
|
$form->setBloc('bible2','F'); |
|
|
|
|
|
$form->setBloc('complement3_om_html','D',"","col_12"); |
|
1740 |
$form->setFieldset('complement3_om_html','D',_('Complement 3')); |
$form->setFieldset('complement3_om_html','D',_('Complement 3')); |
1741 |
$form->setFieldset('bible3','F',''); |
$form->setFieldset('bible3','F',''); |
|
$form->setBloc('bible3','F'); |
|
|
|
|
|
$form->setBloc('complement4_om_html','D',"","col_12"); |
|
1742 |
$form->setFieldset('complement4_om_html','D',_('Complement 4')); |
$form->setFieldset('complement4_om_html','D',_('Complement 4')); |
1743 |
$form->setFieldset('bible4','F',''); |
$form->setFieldset('bible4','F',''); |
1744 |
$form->setBloc('bible4','F'); |
$form->setFieldset('titre_om_htmletat','DF',_('Titre'), 'startClosed'); |
1745 |
|
$form->setFieldset('corps_om_htmletatex','DF',_('Corps')); |
1746 |
|
$form->setBloc('corps_om_htmletatex','F'); |
1747 |
} |
} |
1748 |
} |
} |
1749 |
|
|
1756 |
$form->setLib('bible2', ""); |
$form->setLib('bible2', ""); |
1757 |
$form->setLib('bible3', ""); |
$form->setLib('bible3', ""); |
1758 |
$form->setLib('bible4', ""); |
$form->setLib('bible4', ""); |
1759 |
|
$form->setLib('btn_refresh', ""); |
1760 |
|
$form->setLib('btn_preview', ""); |
1761 |
|
$form->setLib('btn_redaction', ""); |
1762 |
|
$form->setLib('live_preview', ""); |
1763 |
$form->setLib('om_final_instruction_utilisateur', _("finalise par")); |
$form->setLib('om_final_instruction_utilisateur', _("finalise par")); |
1764 |
|
$form->setLib('date_envoi_rar', __("date_envoi_ar")); |
1765 |
|
$form->setLib('date_retour_rar', __("date_notification")); |
1766 |
|
$form->setLib('statut_signature', __("statut")); |
1767 |
|
$form->setLib('commentaire_signature', __("commentaire")); |
1768 |
|
$form->setLib('historique_signature', ''); |
1769 |
|
$form->setLib('suivi_notification', ''); |
1770 |
|
$form->setLib('preview_edition', ""); |
1771 |
|
|
1772 |
|
// Ajout d'une infobulle d'aide lorsque le formulaire est en mode |
1773 |
|
// ajout et que l'option de rédaction libre est activée sur la |
1774 |
|
// collectivité du dossier |
1775 |
|
if ($maj === '0' && $this->is_option_redaction_libre_enabled() === true) { |
1776 |
|
// |
1777 |
|
$help_text_template = '%s <span class="info-16" title="%s"></span>'; |
1778 |
|
$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."); |
1779 |
|
$form->setLib('flag_edition_integrale', sprintf($help_text_template, _("Type de rédaction"), $help_text)); |
1780 |
|
} |
1781 |
|
else { |
1782 |
|
$form->setLib('flag_edition_integrale', _("Type de rédaction")); |
1783 |
|
} |
1784 |
|
|
1785 |
|
// Ajout d'une infobulle d'aide lorsque le formulaire est en mode |
1786 |
|
// modification et que l'option de prévisualisation de l'édition est |
1787 |
|
// activée sur la collectivité du dossier |
1788 |
|
if ($maj === '1' |
1789 |
|
&& $this->f->is_option_preview_pdf_enabled($this->get_dossier_instruction_om_collectivite()) === true) { |
1790 |
|
// |
1791 |
|
$help_text_template = '%s <span class="info-16" title="%s"></span>'; |
1792 |
|
$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."); |
1793 |
|
$form->setLib('date_evenement', sprintf($help_text_template, _('date_evenement'), $help_text)); |
1794 |
|
$form->setLib('signataire_arrete', sprintf($help_text_template, _('signataire_arrete'), $help_text)); |
1795 |
|
} |
1796 |
} |
} |
1797 |
|
|
1798 |
function triggerajouter($id, &$db, $val, $DEBUG) { |
/** |
1799 |
|
* TRIGGER - triggerajouter. |
1800 |
|
* |
1801 |
|
* @return boolean |
1802 |
|
*/ |
1803 |
|
function triggerajouter($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
1804 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
1805 |
/** |
/** |
1806 |
* 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 |
1807 |
* et dossier pour les stocker dans l'instruction : |
* et dossier pour les stocker dans l'instruction : |
1814 |
* - delai_notification |
* - delai_notification |
1815 |
* - lettretype |
* - lettretype |
1816 |
* - autorite_competente |
* - autorite_competente |
1817 |
|
* - pec_metier |
1818 |
* - complement_om_html |
* - complement_om_html |
1819 |
* - complement2_om_html |
* - complement2_om_html |
1820 |
* - complement3_om_html |
* - complement3_om_html |
1839 |
// 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é |
1840 |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
1841 |
WHERE evenement=".$this->valF['evenement']; |
WHERE evenement=".$this->valF['evenement']; |
1842 |
$res = $db->query($sql); |
$res = $this->f->db->query($sql); |
1843 |
$this->addToLog("triggerajouter(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
1844 |
if (database::isError($res)) { |
if (database::isError($res)) { |
1845 |
die($res->getMessage()); |
die($res->getMessage()); |
1846 |
} |
} |
1877 |
} |
} |
1878 |
// Récupération de la valeur de la lettre type |
// Récupération de la valeur de la lettre type |
1879 |
$this->valF['lettretype']=$row['lettretype']; |
$this->valF['lettretype']=$row['lettretype']; |
1880 |
|
// Récupération de la valeur de la prise en compte métier |
1881 |
|
// si la prise en compte métier est paramétrée dans l'événement |
1882 |
|
$this->valF['pec_metier'] = NULL; |
1883 |
|
if(isset($row['pec_metier']) === true and empty($row['pec_metier']) === false) { |
1884 |
|
$this->valF['pec_metier'] = $row['pec_metier']; |
1885 |
|
} |
1886 |
} |
} |
1887 |
// 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 |
1888 |
$sql = "SELECT * FROM ".DB_PREFIXE."dossier |
$sql = "SELECT * FROM ".DB_PREFIXE."dossier |
1889 |
WHERE dossier='".$this->valF['dossier']."'"; |
WHERE dossier='".$this->valF['dossier']."'"; |
1890 |
$res = $db->query($sql); |
$res = $this->f->db->query($sql); |
1891 |
$this->addToLog("triggerajouter(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
1892 |
if (database::isError($res)) { |
if (database::isError($res)) { |
1893 |
die($res->getMessage()); |
die($res->getMessage()); |
1894 |
} |
} |
1903 |
LEFT JOIN ".DB_PREFIXE."dossier |
LEFT JOIN ".DB_PREFIXE."dossier |
1904 |
ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
1905 |
WHERE dossier.dossier='".$this->valF['dossier']."'"; |
WHERE dossier.dossier='".$this->valF['dossier']."'"; |
1906 |
$duree_validite_parametrage = $db->getOne($sql); |
$duree_validite_parametrage = $this->f->db->getOne($sql); |
1907 |
$this->addToLog("triggerajouter(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
1908 |
database::isError($duree_validite_parametrage); |
database::isError($duree_validite_parametrage); |
1909 |
if ($duree_validite_parametrage != '') { |
if ($duree_validite_parametrage != '') { |
1910 |
$this->valF['duree_validite_parametrage']= $duree_validite_parametrage; |
$this->valF['duree_validite_parametrage']= $duree_validite_parametrage; |
2103 |
$sql = "SELECT retour |
$sql = "SELECT retour |
2104 |
FROM ".DB_PREFIXE."evenement |
FROM ".DB_PREFIXE."evenement |
2105 |
WHERE evenement = ".$evenement; |
WHERE evenement = ".$evenement; |
2106 |
$retour = $this->db->getOne($sql); |
$retour = $this->f->db->getOne($sql); |
2107 |
$this->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE); |
2108 |
if (database::isError($retour)) { |
if (database::isError($retour)) { |
2109 |
die($retour->getMessage()); |
die($retour->getMessage()); |
2134 |
WHERE |
WHERE |
2135 |
evenement =".$evenement; |
evenement =".$evenement; |
2136 |
|
|
2137 |
$restriction = $this->db->getOne($sql); |
$restriction = $this->f->db->getOne($sql); |
2138 |
$this->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE); |
2139 |
if (database::isError($restriction)) { |
if (database::isError($restriction)) { |
2140 |
die($restriction->getMessage()); |
die($restriction->getMessage()); |
2220 |
"regle_date_retour_contradictoire", |
"regle_date_retour_contradictoire", |
2221 |
"regle_date_ait", |
"regle_date_ait", |
2222 |
"regle_date_transmission_parquet", |
"regle_date_transmission_parquet", |
2223 |
|
"regle_date_affichage", |
2224 |
); |
); |
2225 |
// Tableau des champs de type numérique |
// Tableau des champs de type numérique |
2226 |
$rule_type_numeric = array( |
$rule_type_numeric = array( |
2232 |
); |
); |
2233 |
// Tableau des champs de type booléen |
// Tableau des champs de type booléen |
2234 |
$rule_type_bool = array( |
$rule_type_bool = array( |
2235 |
|
"regle_a_qualifier", |
2236 |
|
"regle_incompletude", |
2237 |
|
"regle_incomplet_notifie", |
2238 |
|
"regle_evenement_suivant_tacite_incompletude", |
2239 |
); |
); |
2240 |
// Tableau des champs spécifiques |
// Tableau des champs spécifiques |
2241 |
$rule_type_specific = array( |
$rule_type_specific = array( |
2243 |
"regle_etat", |
"regle_etat", |
2244 |
"regle_accord_tacite", |
"regle_accord_tacite", |
2245 |
"regle_avis", |
"regle_avis", |
2246 |
|
"regle_pec_metier", |
2247 |
|
"regle_etat_pendant_incompletude", |
2248 |
); |
); |
2249 |
// Tableau des champs de données techniques |
// Tableau des champs de données techniques |
2250 |
$rule_type_technical_data = array( |
$rule_type_technical_data = array( |
2254 |
'regle_donnees_techniques4', |
'regle_donnees_techniques4', |
2255 |
'regle_donnees_techniques5', |
'regle_donnees_techniques5', |
2256 |
); |
); |
2257 |
|
// Tableau des champs simple |
2258 |
|
$rule_type_simple = array( |
2259 |
|
"regle_dossier_instruction_type", |
2260 |
|
); |
2261 |
|
|
2262 |
// Définit le type du champ |
// Définit le type du champ |
2263 |
if (in_array($rule_name, $rule_type_date) == true) { |
if (in_array($rule_name, $rule_type_date) == true) { |
2278 |
if (in_array($rule_name, $rule_type_technical_data) === true) { |
if (in_array($rule_name, $rule_type_technical_data) === true) { |
2279 |
$type = 'text'; |
$type = 'text'; |
2280 |
} |
} |
2281 |
|
if (in_array($rule_name, $rule_type_simple) === true) { |
2282 |
|
$type = 'simple'; |
2283 |
|
} |
2284 |
|
|
2285 |
// 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 |
2286 |
// Récupère directement la valeur de l'opérande |
// Récupère directement la valeur de l'opérande |
2287 |
if ($type === 'specific' || $type === 'bool') { |
if ($type === 'specific') { |
2288 |
// |
// |
2289 |
return $this->get_value_for_rule($rule); |
return $this->get_value_for_rule($rule); |
2290 |
} |
} |
2359 |
// Retourne la chaîne de caractère |
// Retourne la chaîne de caractère |
2360 |
return $res_text; |
return $res_text; |
2361 |
} |
} |
2362 |
|
if ($type === 'simple' || $type === 'bool') { |
2363 |
|
// Retourne la valeur du champs rule |
2364 |
|
return $rule; |
2365 |
|
} |
2366 |
} |
} |
2367 |
|
|
2368 |
|
|
2405 |
$donnees_techniques = $this->getDonneesTechniques(); |
$donnees_techniques = $this->getDonneesTechniques(); |
2406 |
} |
} |
2407 |
// |
// |
2408 |
require_once "../obj/donnees_techniques.class.php"; |
$this->inst_donnees_techniques = $this->f->get_inst__om_dbform(array( |
2409 |
$this->inst_donnees_techniques = new donnees_techniques($donnees_techniques); |
"obj" => "donnees_techniques", |
2410 |
|
"idx" => $donnees_techniques, |
2411 |
|
)); |
2412 |
} |
} |
2413 |
// |
// |
2414 |
return $this->inst_donnees_techniques; |
return $this->inst_donnees_techniques; |
2426 |
$sql = "SELECT donnees_techniques |
$sql = "SELECT donnees_techniques |
2427 |
FROM ".DB_PREFIXE."donnees_techniques |
FROM ".DB_PREFIXE."donnees_techniques |
2428 |
WHERE dossier_instruction ='".$this->valF["dossier"]."'"; |
WHERE dossier_instruction ='".$this->valF["dossier"]."'"; |
2429 |
$donnees_techniques = $this->db->getOne($sql); |
$donnees_techniques = $this->f->db->getOne($sql); |
2430 |
$this->f->addToLog("getStatut() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog("getStatut() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
2431 |
if ( database::isError($donnees_techniques)){ |
if ( database::isError($donnees_techniques)){ |
2432 |
die(); |
die(); |
2435 |
return $donnees_techniques; |
return $donnees_techniques; |
2436 |
} |
} |
2437 |
|
|
|
|
|
2438 |
/** |
/** |
2439 |
* TRIGGER - triggerajouterapres. |
* TRIGGER - triggerajouterapres. |
2440 |
* |
* |
2445 |
* |
* |
2446 |
* @return boolean |
* @return boolean |
2447 |
*/ |
*/ |
2448 |
function triggerajouterapres($id, &$db, $val, $DEBUG) { |
function triggerajouterapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
2449 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
2450 |
|
|
2451 |
// 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 |
2452 |
$inst_di = $this->get_inst_dossier($this->valF['dossier']); |
$inst_di = $this->get_inst_dossier($this->valF['dossier']); |
|
|
|
2453 |
// Instance de la classe evenement |
// Instance de la classe evenement |
2454 |
$inst_evenement = $this->get_inst_evenement($this->valF['evenement']); |
$inst_evenement = $this->get_inst_evenement($this->valF['evenement']); |
2455 |
|
// Instance de l'état courant du dossier d'instruction |
2456 |
|
$inst_current_etat = $this->f->get_inst__om_dbform(array( |
2457 |
|
"obj" => "etat", |
2458 |
|
"idx" => $inst_di->get_id_etat(), |
2459 |
|
)); |
2460 |
|
|
2461 |
/** |
/** |
2462 |
* Mise à jour des valeurs du dossier en fonction des valeurs calculées |
* Mise à jour des valeurs du dossier en fonction des valeurs calculées |
2464 |
*/ |
*/ |
2465 |
// état de complétude actuel du dossier |
// état de complétude actuel du dossier |
2466 |
$incompletude = ($inst_di->getVal('incompletude') == 't' ? true : false); |
$incompletude = ($inst_di->getVal('incompletude') == 't' ? true : false); |
2467 |
|
// L'événement suivant tacite paramétré est destiné à la gestion de l'incomplétude |
2468 |
|
$ev_suiv_tacite_incompletude = false; |
2469 |
// Initialisation |
// Initialisation |
2470 |
$valF = ""; |
$valF = array(); |
2471 |
$valF_dt = ""; |
$valF_dt = array(); |
2472 |
// |
// |
|
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; |
|
|
} |
|
|
} |
|
2473 |
// Récupération des paramètres de l'action |
// Récupération des paramètres de l'action |
2474 |
$sql = "SELECT * FROM ".DB_PREFIXE."action |
$sql = "SELECT * FROM ".DB_PREFIXE."action |
2475 |
WHERE action='".$this->valF['action']."'"; |
WHERE action='".$this->valF['action']."'"; |
2476 |
$res = $db->query($sql); |
$res = $this->f->db->query($sql); |
2477 |
$this->addToLog("triggerajouterapres(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
2478 |
if (database::isError($res)) { |
if (database::isError($res)) { |
2479 |
die($res->getMessage()); |
die($res->getMessage()); |
2480 |
} |
} |
2530 |
$valF['autorite_competente'] = $this->regle($row['regle_autorite_competente'], 'regle_autorite_competente'); |
$valF['autorite_competente'] = $this->regle($row['regle_autorite_competente'], 'regle_autorite_competente'); |
2531 |
} |
} |
2532 |
if ($row['regle_etat'] != '') { |
if ($row['regle_etat'] != '') { |
2533 |
// 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'); |
|
|
} |
|
2534 |
} |
} |
2535 |
if ($row['regle_date_cloture_instruction'] !== '') { |
if ($row['regle_date_cloture_instruction'] !== '') { |
2536 |
$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'); |
2568 |
if ($row['regle_date_transmission_parquet'] !== '') { |
if ($row['regle_date_transmission_parquet'] !== '') { |
2569 |
$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'); |
2570 |
} |
} |
2571 |
|
if ($row['regle_dossier_instruction_type'] !== '') { |
2572 |
|
$valF['dossier_instruction_type'] = $this->regle($row['regle_dossier_instruction_type'], 'regle_dossier_instruction_type'); |
2573 |
|
} |
2574 |
|
// La date d'affichage est modifiée seulement si le champ n'est pas |
2575 |
|
// renseigné |
2576 |
|
if ($row['regle_date_affichage'] !== '' |
2577 |
|
&& ($inst_di->getVal('date_affichage') === '' |
2578 |
|
|| $inst_di->getVal('date_affichage') === null)) { |
2579 |
|
// |
2580 |
|
$valF['date_affichage'] = $this->regle($row['regle_date_affichage'], 'regle_date_affichage'); |
2581 |
|
} |
2582 |
|
// |
2583 |
|
if ($row['regle_pec_metier'] != '') { |
2584 |
|
$valF['pec_metier'] = $this->regle($row['regle_pec_metier'], 'regle_pec_metier'); |
2585 |
|
} |
2586 |
|
if ($row['regle_a_qualifier'] != '') { |
2587 |
|
$valF['a_qualifier'] = $this->regle($row['regle_a_qualifier'], 'regle_a_qualifier'); |
2588 |
|
} |
2589 |
|
// |
2590 |
|
if ($row['regle_incompletude'] != '') { |
2591 |
|
$valF['incompletude'] = $this->regle($row['regle_incompletude'], 'regle_incompletude'); |
2592 |
|
} |
2593 |
|
if ($row['regle_incomplet_notifie'] != '') { |
2594 |
|
$valF['incomplet_notifie'] = $this->regle($row['regle_incomplet_notifie'], 'regle_incomplet_notifie'); |
2595 |
|
} |
2596 |
|
if ($row['regle_etat_pendant_incompletude'] != '') { |
2597 |
|
$valF['etat_pendant_incompletude'] = $this->regle($row['regle_etat_pendant_incompletude'], 'regle_etat_pendant_incompletude'); |
2598 |
|
} |
2599 |
|
if ($row['regle_evenement_suivant_tacite_incompletude'] != '') { |
2600 |
|
$resti = $this->regle($row['regle_evenement_suivant_tacite_incompletude'], 'regle_evenement_suivant_tacite_incompletude'); |
2601 |
|
if (strtolower($resti) === 't' || strtolower($resti) === 'true') { |
2602 |
|
$ev_suiv_tacite_incompletude = true; |
2603 |
|
} |
2604 |
|
} |
2605 |
} |
} |
2606 |
|
|
2607 |
// Si l'événement a un événement suivant tacite |
// Si l'événement a un événement suivant tacite |
2608 |
if($inst_evenement->getVal('evenement_suivant_tacite') != '') { |
if($inst_evenement->getVal('evenement_suivant_tacite') != '') { |
2609 |
// 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 |
2610 |
// dans le champ evenement_suivant_tacite du dossier |
// pas associé de le même façon au dossier d'instruction |
2611 |
if ($incompletude == false OR $inst_evenement->getVal('type') != "incompletude") { |
if ($ev_suiv_tacite_incompletude === false) { |
|
// |
|
2612 |
$valF['evenement_suivant_tacite'] = $inst_evenement->getVal('evenement_suivant_tacite'); |
$valF['evenement_suivant_tacite'] = $inst_evenement->getVal('evenement_suivant_tacite'); |
2613 |
} else { |
} |
2614 |
// Sinon l'événement tacite est stocké dans le champ |
if ($ev_suiv_tacite_incompletude === true) { |
|
// evenement_suivant_tacite_incompletude du dossier |
|
2615 |
$valF['evenement_suivant_tacite_incompletude'] = $inst_evenement->getVal('evenement_suivant_tacite'); |
$valF['evenement_suivant_tacite_incompletude'] = $inst_evenement->getVal('evenement_suivant_tacite'); |
2616 |
} |
} |
2617 |
} |
} |
2618 |
// 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 |
2619 |
if ($valF_dt != "") { |
if (count($valF_dt) > 0) { |
2620 |
$dt_id = $this->getDonneesTechniques(); |
$dt_id = $this->getDonneesTechniques(); |
2621 |
// On met à jour le dossier |
// On met à jour le dossier |
2622 |
$cle = " donnees_techniques='".$dt_id."'"; |
$cle = " donnees_techniques='".$dt_id."'"; |
2623 |
$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); |
2624 |
$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); |
2625 |
if (database::isError($res1)) { |
if (database::isError($res1)) { |
2626 |
die($res->getMessage()); |
die($res->getMessage()); |
2627 |
} |
} |
2628 |
// Affichage d'informations à l'utilisateur |
// Affichage d'informations à l'utilisateur |
2629 |
$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')."]"); |
2630 |
} |
} |
2631 |
// 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 |
2632 |
if ($valF != "") { |
if (count($valF) > 0) { |
2633 |
// On met à jour le dossier |
// |
2634 |
$cle = " dossier='".$this->valF['dossier']."'"; |
$inst_dossier = $this->f->get_inst__om_dbform(array( |
2635 |
$res1 = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle); |
"obj" => "dossier", |
2636 |
$this->addToLog("triggerajouterapres(): db->autoexecute(\"".DB_PREFIXE."dossier\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
"idx" => $this->valF['dossier'], |
2637 |
if (database::isError($res1)) { |
)); |
2638 |
die($res->getMessage()); |
$valF['instruction'] = $id; |
2639 |
|
$update_by_instruction = $inst_dossier->update_by_instruction($valF); |
2640 |
|
if ($update_by_instruction === false) { |
2641 |
|
$this->cleanMessage(); |
2642 |
|
$this->addToMessage(sprintf('%s %s', __("Une erreur s'est produite lors de la mise à jour du dossier d'instruction."), __("Veuillez contacter votre administrateur."))); |
2643 |
|
return false; |
2644 |
} |
} |
2645 |
// Affichage d'informations à l'utilisateur |
// Affichage d'informations à l'utilisateur |
2646 |
$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')."]"); |
2647 |
} |
} |
2648 |
|
|
2649 |
/** |
/** |
2679 |
$this->addToMessage(_("Notification (105) du référentiel ERP OK.")); |
$this->addToMessage(_("Notification (105) du référentiel ERP OK.")); |
2680 |
} |
} |
2681 |
|
|
2682 |
|
// Si le mode en rédaction intégrale est activé |
2683 |
|
if (isset($this->valF['flag_edition_integrale']) === true |
2684 |
|
&& $this->valF['flag_edition_integrale'] === true) { |
2685 |
|
$redactionIntegraleValF = array(); |
2686 |
|
|
2687 |
|
// Récupère la collectivite du dossier d'instruction |
2688 |
|
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
2689 |
|
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
2690 |
|
// Récupère le corps de la lettre type |
2691 |
|
$params = array( |
2692 |
|
"specific" => array( |
2693 |
|
"corps" => array( |
2694 |
|
"mode" => "get", |
2695 |
|
) |
2696 |
|
), |
2697 |
|
); |
2698 |
|
$result = $this->compute_pdf_output('lettretype', $this->valF['lettretype'], $collectivite, $id, $params); |
2699 |
|
$redactionIntegraleValF['corps_om_htmletatex'] = $result['pdf_output']; |
2700 |
|
// Récupère le titre de la lettre type |
2701 |
|
$params = array( |
2702 |
|
"specific" => array( |
2703 |
|
"titre" => array( |
2704 |
|
"mode" => "get", |
2705 |
|
) |
2706 |
|
), |
2707 |
|
); |
2708 |
|
$result = $this->compute_pdf_output('lettretype', $this->valF['lettretype'], $collectivite, $id, $params); |
2709 |
|
$redactionIntegraleValF['titre_om_htmletat'] = $result['pdf_output']; |
2710 |
|
|
2711 |
|
// mise à jour en base de données |
2712 |
|
$res = $this->f->db->autoExecute( |
2713 |
|
DB_PREFIXE.$this->table, |
2714 |
|
$redactionIntegraleValF, |
2715 |
|
DB_AUTOQUERY_UPDATE, |
2716 |
|
$this->clePrimaire."=".$id |
2717 |
|
); |
2718 |
|
$this->addToLog(__METHOD__."(): db->autoexecute(\"".DB_PREFIXE.'.'.$this->table."\", ".print_r($redactionIntegraleValF, true).", DB_AUTOQUERY_UPDATE, \"".$this->clePrimaire."=".$id."\");", VERBOSE_MODE); |
2719 |
|
if ($this->f->isDatabaseError($res, true) === true) { |
2720 |
|
return false; |
2721 |
|
} |
2722 |
|
} |
2723 |
|
|
2724 |
|
/** |
2725 |
|
* Finalisation automatique de l'instruction si le paramétrage de l'événement l'autorise |
2726 |
|
*/ |
2727 |
|
// Si la finalisation automatique de l'événement est activée |
2728 |
|
// ET si l'instruction n'a pas déjà été finalisée |
2729 |
|
// ET s'il existe une lettre type associée |
2730 |
|
if ($inst_evenement->getVal('finaliser_automatiquement') === 't' |
2731 |
|
&& $inst_evenement->getVal('om_final_instruction') !== 't' |
2732 |
|
&& $inst_evenement->getVal('lettretype') !== '' |
2733 |
|
&& $inst_evenement->getVal('lettretype') !== null) { |
2734 |
|
|
2735 |
|
// On instancie l'instruction |
2736 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
2737 |
|
"obj" => "instruction", |
2738 |
|
"idx" => $this->valF[$this->clePrimaire], |
2739 |
|
)); |
2740 |
|
|
2741 |
|
// On finalise l'instruction dans le contexte de finalisation : action 100 |
2742 |
|
$inst_instruction->setParameter('maj', 100); |
2743 |
|
$finalize = $inst_instruction->finalize($inst_instruction->valF); |
2744 |
|
|
2745 |
|
// Une erreur de finalisation renvoie 'false' : ajout dans les logs |
2746 |
|
// et dans le message d'erreur |
2747 |
|
if ($finalize === false) { |
2748 |
|
$this->f->addToLog(__METHOD__."() : ERROR - Impossible de finaliser l'instruction.", DEBUG_MODE); |
2749 |
|
$this->addToMessage(_("Erreur lors de la finalisation de l'instruction. Contactez votre administrateur.")); |
2750 |
|
return false; |
2751 |
|
} |
2752 |
|
} |
2753 |
|
|
2754 |
|
/** |
2755 |
|
* Finalisation automatique des instructions tacites ou retours. |
2756 |
|
*/ |
2757 |
|
// Si l'option de finalisation automatique des instructions tacites ou |
2758 |
|
// retours est activée et l'événement d'instruction a une lettre type |
2759 |
|
// associée |
2760 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite($val['dossier']); |
2761 |
|
if ($this->f->is_option_finalisation_auto_enabled($collectivite_di) === true |
2762 |
|
&& $inst_evenement->getVal('lettretype') !== '' |
2763 |
|
&& $inst_evenement->getVal('lettretype') !== null) { |
2764 |
|
|
2765 |
|
// Rècupère l'identifiant de l'événement |
2766 |
|
$evenement_id = $inst_evenement->getVal($inst_evenement->clePrimaire); |
2767 |
|
|
2768 |
|
// Si l'événement d'instruction est identifié comme un événement |
2769 |
|
// retour |
2770 |
|
// OU l'événement d'instruction est l'événement suivant tacite du |
2771 |
|
// dossier d'instruction (incomplétude prise en compte) |
2772 |
|
// ET l'événement d'instruction n'a pas déjà été finalisé |
2773 |
|
if (($inst_evenement->getVal("retour") === 't' |
2774 |
|
|| ($inst_di->getVal('evenement_suivant_tacite_incompletude') === $evenement_id |
2775 |
|
|| $inst_di->getVal('evenement_suivant_tacite') === $evenement_id)) |
2776 |
|
&& ($inst_evenement->getVal('om_final_instruction') !== 't')) { |
2777 |
|
|
2778 |
|
// Finalise l'instruction |
2779 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
2780 |
|
"obj" => "instruction", |
2781 |
|
"idx" => $this->valF[$this->clePrimaire], |
2782 |
|
)); |
2783 |
|
$inst_instruction->setParameter('maj', 100); |
2784 |
|
$finalize = $inst_instruction->finalize($inst_instruction->valF); |
2785 |
|
if ($finalize === false) { |
2786 |
|
// |
2787 |
|
return false; |
2788 |
|
} |
2789 |
|
} |
2790 |
|
} |
2791 |
|
|
2792 |
|
/** |
2793 |
|
* Mise à jour de la version de clôture *version_clos* du dossier si et |
2794 |
|
* seulement si l'instruction met à jour l'état du dossier. |
2795 |
|
*/ |
2796 |
|
if (isset($valF['etat']) === true |
2797 |
|
&& $valF['etat'] !== null |
2798 |
|
&& $valF['etat'] !== '') { |
2799 |
|
// Instanciation de l'état appliqué sur le dossier par l'instruction |
2800 |
|
$inst_etat = $this->f->get_inst__om_dbform(array( |
2801 |
|
"obj" => "etat", |
2802 |
|
"idx" => $valF['etat'], |
2803 |
|
)); |
2804 |
|
// |
2805 |
|
$update_version_clos = null; |
2806 |
|
// En cas d'instruction qui clôture le dossier |
2807 |
|
if ($inst_etat->getVal('statut') === 'cloture') { |
2808 |
|
$update_version_clos = $inst_di->update_version_clos('up'); |
2809 |
|
} |
2810 |
|
// En cas d'instruction qui rouvre le dossier |
2811 |
|
if ($inst_current_etat->getVal('statut') === 'cloture' |
2812 |
|
&& $inst_etat->getVal('statut') !== 'cloture') { |
2813 |
|
// |
2814 |
|
$update_version_clos = $inst_di->update_version_clos('down'); |
2815 |
|
// |
2816 |
|
$params = array( |
2817 |
|
'di_reopened' => true, |
2818 |
|
); |
2819 |
|
} |
2820 |
|
// |
2821 |
|
if ($update_version_clos === false) { |
2822 |
|
$this->f->addToLog(sprintf( |
2823 |
|
"%s() : ERREUR - %s %s", |
2824 |
|
__METHOD__, |
2825 |
|
sprintf( |
2826 |
|
__("Impossible de mettre à jour la version de clôture du dossier d'instruction %s."), |
2827 |
|
$inst_di->getVal($inst_di->clePrimaire) |
2828 |
|
), |
2829 |
|
sprintf( |
2830 |
|
__("L'instruction tente d'appliquer l'état %s."), |
2831 |
|
$inst_etat->getVal($inst_etat->clePrimaire) |
2832 |
|
) |
2833 |
|
)); |
2834 |
|
$this->addToMessage(sprintf( |
2835 |
|
"%s %s", |
2836 |
|
__("Erreur lors de la mise à jour de la version de clôture du dossier d'instruction."), |
2837 |
|
__("Veuillez contacter votre administrateur.") |
2838 |
|
)); |
2839 |
|
return false; |
2840 |
|
} |
2841 |
|
} |
2842 |
|
|
2843 |
|
/** |
2844 |
|
* Notification automatique |
2845 |
|
*/ |
2846 |
|
// Notification automatique à l'ajout de l'instruction si la notification |
2847 |
|
// automatique est choisie et qu'il n'y a pas de lettretype associée à l'événement |
2848 |
|
if ($inst_evenement->getVal('notification') === 'notification_automatique' && |
2849 |
|
($inst_evenement->getVal('lettretype') === null || |
2850 |
|
$inst_evenement->getVal('lettretype') === '')) { |
2851 |
|
// Récupération de la liste des demandeurs à notifier et de la catégorie |
2852 |
|
$categorie = $this->f->get_param_option_notification($collectivite_di); |
2853 |
|
$isPortal = $categorie == null || $categorie == '' || $categorie == 'portal' ? true : false; |
2854 |
|
$demandeursANotifie = $this->get_demandeurs_notifiable( |
2855 |
|
$this->valF['dossier'], |
2856 |
|
$isPortal |
2857 |
|
); |
2858 |
|
|
2859 |
|
// Création d'une notification et d'une tâche pour chaque demandeur à notifier |
2860 |
|
foreach ($demandeursANotifie as $demandeur) { |
2861 |
|
// Ajout de la notif et récupération de son id |
2862 |
|
$idNotif = $this->ajouter_notification( |
2863 |
|
$this->valF[$this->clePrimaire], |
2864 |
|
true, |
2865 |
|
$this->f->get_connected_user_login_name(), |
2866 |
|
$demandeur |
2867 |
|
); |
2868 |
|
if ($idNotif === false) { |
2869 |
|
$this->addToMessage( |
2870 |
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
2871 |
|
); |
2872 |
|
return false; |
2873 |
|
} |
2874 |
|
// Création de la tache en lui donnant l'id de la notification |
2875 |
|
$notification_by_task = $this->notification_by_task( |
2876 |
|
$idNotif, |
2877 |
|
$this->valF['dossier'], |
2878 |
|
$categorie |
2879 |
|
); |
2880 |
|
if ($notification_by_task === false) { |
2881 |
|
$this->addToMessage( |
2882 |
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
2883 |
|
); |
2884 |
|
return false; |
2885 |
|
} |
2886 |
|
} |
2887 |
|
$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."))); |
2888 |
|
} |
2889 |
|
|
2890 |
|
/** |
2891 |
|
* Mise à jour de la date de dernière modification du dossier |
2892 |
|
*/ |
2893 |
|
$inst_di->update_last_modification_date(); |
2894 |
|
|
2895 |
/** |
/** |
2896 |
* Mise à jour des données du DA. |
* Mise à jour des données du DA. |
2897 |
*/ |
*/ |
|
// |
|
2898 |
$inst_da = $inst_di->get_inst_dossier_autorisation(); |
$inst_da = $inst_di->get_inst_dossier_autorisation(); |
2899 |
// |
$params['di_id'] = $this->valF['dossier']; |
2900 |
if ($inst_da->majDossierAutorisation() === false) { |
if ($inst_da->majDossierAutorisation($params) === false) { |
2901 |
$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.")); |
2902 |
$this->correct = false; |
$this->correct = false; |
2903 |
return false; |
return false; |
2910 |
return $this->add_log_to_dossier($id, array_merge($val, $this->valF)); |
return $this->add_log_to_dossier($id, array_merge($val, $this->valF)); |
2911 |
} |
} |
2912 |
|
|
2913 |
function triggermodifierapres($id,&$db,$val,$DEBUG) { |
public function is_notifiable_by_task_manual() { |
2914 |
|
$ev = $this->get_inst_evenement($this->getVal('evenement')); |
2915 |
|
|
2916 |
|
// Si l'instruction a une édition non finalisé quel que soit |
2917 |
|
// le type de notification, il n'est pas notifiable |
2918 |
|
if ($this->has_an_edition() === true) { |
2919 |
|
if ($this->is_unfinalizable_without_bypass() === false) { |
2920 |
|
return false; |
2921 |
|
} |
2922 |
|
} |
2923 |
|
|
2924 |
|
// Gestion des différents cas selon la valeur du champs notification |
2925 |
|
switch ($ev->getVal('notification')) { |
2926 |
|
case 'notification_manuelle': |
2927 |
|
return true; |
2928 |
|
case 'notification_manuelle_annexe': |
2929 |
|
return true; |
2930 |
|
case 'notification_automatique': |
2931 |
|
return false; |
2932 |
|
case 'notification_auto_signature_requise': |
2933 |
|
return false; |
2934 |
|
case 'notification_manuelle_signature_requise': |
2935 |
|
// Si il y a une date de retour de signature la notification est possible |
2936 |
|
if ($this->getVal('date_retour_signature') === null |
2937 |
|
|| $this->getVal('date_retour_signature') === '') { |
2938 |
|
return false; |
2939 |
|
} |
2940 |
|
return true; |
2941 |
|
case 'notification_manuelle_annexe_signature_requise': |
2942 |
|
// Si il y a une date de retour de signature la notification est possible |
2943 |
|
if ($this->getVal('date_retour_signature') === null |
2944 |
|
|| $this->getVal('date_retour_signature') === '') { |
2945 |
|
return false; |
2946 |
|
} |
2947 |
|
return true; |
2948 |
|
default: |
2949 |
|
return false; |
2950 |
|
} |
2951 |
|
} |
2952 |
|
|
2953 |
|
/** |
2954 |
|
* Crée une instance et une tache de notification pour le demandeur |
2955 |
|
* principal. |
2956 |
|
* |
2957 |
|
* @return boolean true si le traitement à réussi |
2958 |
|
*/ |
2959 |
|
protected function notifier_demandeur_principal() { |
2960 |
|
$this->begin_treatment(__METHOD__); |
2961 |
|
$message = ''; |
2962 |
|
// Récupération des informations concernant le demandeur |
2963 |
|
$dossier = $this->getVal('dossier'); |
2964 |
|
$demandeur = $this->get_demandeurs_notifiable( |
2965 |
|
$dossier, |
2966 |
|
true |
2967 |
|
); |
2968 |
|
if ($demandeur !== array()) { |
2969 |
|
$destinataire = array_values($demandeur); |
2970 |
|
// Ajout de la notif et récupération de son id |
2971 |
|
$idNotification = $this->ajouter_notification( |
2972 |
|
$this->getVal($this->clePrimaire), |
2973 |
|
true, |
2974 |
|
$this->f->get_connected_user_login_name(), |
2975 |
|
$destinataire[0] |
2976 |
|
); |
2977 |
|
if ($idNotification === false) { |
2978 |
|
$this->addToMessage( |
2979 |
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
2980 |
|
); |
2981 |
|
return $this->end_treatment(__METHOD__, false); |
2982 |
|
} |
2983 |
|
// Création de la tâche en lui donnant l'id de la notification |
2984 |
|
$notification_by_task = $this->notification_by_task($idNotification, $dossier); |
2985 |
|
if ($notification_by_task === false) { |
2986 |
|
$this->addToMessage( |
2987 |
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
2988 |
|
); |
2989 |
|
return $this->end_treatment(__METHOD__, false); |
2990 |
|
} |
2991 |
|
$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."))); |
2992 |
|
return $this->end_treatment(__METHOD__, true); |
2993 |
|
} |
2994 |
|
$this->addToMessage( __("Le demandeur principal n'est pas notifiable.")); |
2995 |
|
return $this->end_treatment(__METHOD__, true); |
2996 |
|
} |
2997 |
|
|
2998 |
|
public function notification_by_task($object_id, $dossier, $category = null, $type = null) { |
2999 |
|
// Par défaut le type est portal |
3000 |
|
if ($category === null) { |
3001 |
|
$category = 'portal'; |
3002 |
|
} |
3003 |
|
// Si le type n'est pas correctement spécifié, alors il est calculé |
3004 |
|
if ($type === null |
3005 |
|
|| $type !== 'notification_recepisse' |
3006 |
|
|| $type !== 'notification_instruction' |
3007 |
|
|| $type !== 'notification_decision') { |
3008 |
|
// |
3009 |
|
$type = 'notification_instruction'; |
3010 |
|
// Vérifie si l'instruction est un récépissé |
3011 |
|
$instruction_id = $this->getVal('instruction') !== null ? $this->getVal('instruction') : $this->valF['instruction']; |
3012 |
|
$dossier_id = $this->getVal('dossier') !== null && $this->getVal('dossier') !== '' ? |
3013 |
|
$this->getVal('dossier') : |
3014 |
|
$this->valF['dossier']; |
3015 |
|
$inst_dossier = $this->f->get_inst__om_dbform(array( |
3016 |
|
"obj" => "dossier_instruction", |
3017 |
|
"idx" => $dossier_id, |
3018 |
|
)); |
3019 |
|
$recepisse = $inst_dossier->get_demande_instruction_recepisse(); |
3020 |
|
if ($instruction_id === $recepisse |
3021 |
|
|| $recepisse === '' |
3022 |
|
|| $recepisse === null) { |
3023 |
|
// |
3024 |
|
$type = 'notification_recepisse'; |
3025 |
|
} |
3026 |
|
// Vérifie si l'instruction est une décision |
3027 |
|
if ($type !== 'notification_recepisse') { |
3028 |
|
$avis_decision = $this->getVal('avis_decision') !== null ? $this->getVal('avis_decision') : $this->valF['avis_decision']; |
3029 |
|
if ($avis_decision !== null && $avis_decision !== '') { |
3030 |
|
$type = 'notification_decision'; |
3031 |
|
} |
3032 |
|
} |
3033 |
|
} |
3034 |
|
// Préparation de la tache de notification |
3035 |
|
$inst_task = $this->f->get_inst__om_dbform(array( |
3036 |
|
"obj" => "task", |
3037 |
|
"idx" => 0, |
3038 |
|
)); |
3039 |
|
$task_val = array( |
3040 |
|
'type' => $type, |
3041 |
|
'object_id' => $object_id, |
3042 |
|
'dossier' => $dossier, |
3043 |
|
'category' => $category, |
3044 |
|
); |
3045 |
|
|
3046 |
|
$add_task = $inst_task->add_task(array('val' => $task_val)); |
3047 |
|
if ($add_task === false) { |
3048 |
|
return false; |
3049 |
|
} |
3050 |
|
|
3051 |
|
return true; |
3052 |
|
} |
3053 |
|
|
3054 |
|
protected function ajouter_notification( |
3055 |
|
$idInstruction, |
3056 |
|
$demandeAuto = false, |
3057 |
|
$emetteur, |
3058 |
|
$destinataire, |
3059 |
|
$idInstrDocAnnexe = null |
3060 |
|
) { |
3061 |
|
// Préparation de la notification |
3062 |
|
$inst_notif = $this->f->get_inst__om_dbform(array( |
3063 |
|
"obj" => "instruction_notification", |
3064 |
|
"idx" => "]", |
3065 |
|
)); |
3066 |
|
$notif_val = array( |
3067 |
|
'instruction_notification' => null, |
3068 |
|
'instruction' => $idInstruction, |
3069 |
|
'automatique' => $demandeAuto, |
3070 |
|
'emetteur' => $emetteur, |
3071 |
|
'date_envoi' => null, |
3072 |
|
'destinataire' => $destinataire['destinataire'], |
3073 |
|
'courriel' => $destinataire['courriel'], |
3074 |
|
'date_premier_acces' => null, |
3075 |
|
'statut' => 'en cours d\'envoi', |
3076 |
|
'commentaire' => 'Notification en cours de traitement' |
3077 |
|
); |
3078 |
|
|
3079 |
|
// Création de la notification |
3080 |
|
$add_notif = $inst_notif->ajouter($notif_val); |
3081 |
|
if ($add_notif === false) { |
3082 |
|
return false; |
3083 |
|
} |
3084 |
|
|
3085 |
|
// Si il y a une lettretype finalisé stockage de la clé d'accès au documents |
3086 |
|
if ($this->evenement_has_an_edition($this->getVal('evenement')) === true) { |
3087 |
|
$add_notif_doc = $this->ajouter_notification_document( |
3088 |
|
$this->getVal($this->clePrimaire), |
3089 |
|
$inst_notif->getVal($inst_notif->clePrimaire) |
3090 |
|
); |
3091 |
|
if ($add_notif_doc === false) { |
3092 |
|
return false; |
3093 |
|
} |
3094 |
|
} |
3095 |
|
// Si une annexe a été choisie stockage de la clé d'accès à l'annexe |
3096 |
|
if ($idInstrDocAnnexe != null || $idInstrDocAnnexe != '') { |
3097 |
|
$add_notif_annexe = $this->ajouter_notification_document( |
3098 |
|
$idInstrDocAnnexe, |
3099 |
|
$inst_notif->getVal($inst_notif->clePrimaire), |
3100 |
|
true |
3101 |
|
); |
3102 |
|
if ($add_notif_annexe === false) { |
3103 |
|
return false; |
3104 |
|
} |
3105 |
|
} |
3106 |
|
|
3107 |
|
// Renvoie l'id de la nouvelle instance de instruction_notification |
3108 |
|
return $inst_notif->getVal($inst_notif->clePrimaire); |
3109 |
|
} |
3110 |
|
|
3111 |
|
/** |
3112 |
|
* Ajoute un élément dans la table instruction_notification_document. |
3113 |
|
* |
3114 |
|
* @param integer $idInstruction : id de l'instruction à laquelle est rattaché le document |
3115 |
|
* @param integer $idNotification : id de la notification à laquelle on associe le document |
3116 |
|
* @param boolean $isAnnexe : indique si le document est une annexe ou pas |
3117 |
|
* |
3118 |
|
* @return boolean indique si le traitement a réussi |
3119 |
|
*/ |
3120 |
|
protected function ajouter_notification_document($idInstruction, $idNotification, $isAnnexe = false) { |
3121 |
|
$inst_notif_doc = $this->f->get_inst__om_dbform(array( |
3122 |
|
"obj" => "instruction_notification_document", |
3123 |
|
"idx" => "]", |
3124 |
|
)); |
3125 |
|
$notif_doc_val = array( |
3126 |
|
'instruction_notification_document' => null, |
3127 |
|
'instruction_notification' => $idNotification, |
3128 |
|
'instruction' => $idInstruction, |
3129 |
|
'cle' => $this->getCleAccesDocument(), |
3130 |
|
'annexe' => $isAnnexe |
3131 |
|
); |
3132 |
|
|
3133 |
|
$add_notif_doc = $inst_notif_doc->ajouter($notif_doc_val); |
3134 |
|
if ($add_notif_doc === false) { |
3135 |
|
return false; |
3136 |
|
} |
3137 |
|
return true; |
3138 |
|
} |
3139 |
|
|
3140 |
|
/** |
3141 |
|
* TRIGGER - triggermodifierapres. |
3142 |
|
* |
3143 |
|
* @return boolean |
3144 |
|
*/ |
3145 |
|
function triggermodifierapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
3146 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
3147 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite($val['dossier']); |
3148 |
|
$message = ''; |
3149 |
/** |
/** |
3150 |
* 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 |
3151 |
* si la date de l'evenement est modifiee |
* si la date de l'evenement est modifiee |
3152 |
*/ |
*/ |
3153 |
// Initialisation |
// Initialisation |
3154 |
$valF = ""; |
$valF = array(); |
3155 |
$valF_dt = ""; |
$valF_dt = array(); |
3156 |
// Initialisation du type d'événement |
// Initialisation du type d'événement |
3157 |
$type_evmt = ""; |
$type_evmt = ""; |
3158 |
// Récupération de l'action correspondante à l'événement |
// Récupération de l'action correspondante à l'événement |
3159 |
$sql = "SELECT action |
$sql = "SELECT action |
3160 |
FROM ".DB_PREFIXE."evenement |
FROM ".DB_PREFIXE."evenement |
3161 |
WHERE evenement=".$this->valF['evenement']; |
WHERE evenement=".$this->valF['evenement']; |
3162 |
$action = $db->getOne($sql); |
$action = $this->f->db->getOne($sql); |
3163 |
$this->addToLog("triggermodifierapres(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
3164 |
if (database::isError($action)) { |
if (database::isError($action)) { |
3165 |
die($action->getMessage()); |
die($action->getMessage()); |
3166 |
} |
} |
3168 |
// Récupération des paramètres de l'action |
// Récupération des paramètres de l'action |
3169 |
$sql = "SELECT * FROM ".DB_PREFIXE."action |
$sql = "SELECT * FROM ".DB_PREFIXE."action |
3170 |
WHERE action='".$action."'"; |
WHERE action='".$action."'"; |
3171 |
$res = $db->query($sql); |
$res = $this->f->db->query($sql); |
3172 |
$this->addToLog("triggermodifierapres(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
3173 |
if (database::isError($res)) { |
if (database::isError($res)) { |
3174 |
die($res->getMessage()); |
die($res->getMessage()); |
3175 |
} |
} |
3241 |
if ($row['regle_donnees_techniques5'] !== '') { |
if ($row['regle_donnees_techniques5'] !== '') { |
3242 |
$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'); |
3243 |
} |
} |
3244 |
|
if ($row['regle_dossier_instruction_type'] !== '') { |
3245 |
|
$valF['dossier_instruction_type'] = $this->regle($row['regle_dossier_instruction_type'], 'regle_dossier_instruction_type'); |
3246 |
|
} |
3247 |
} |
} |
3248 |
// 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 |
3249 |
if ($valF_dt != "") { |
if (count($valF_dt) > 0) { |
3250 |
$dt_id = $this->getDonneesTechniques(); |
$dt_id = $this->getDonneesTechniques(); |
3251 |
// On met à jour le dossier |
// On met à jour le dossier |
3252 |
$cle = " donnees_techniques='".$dt_id."'"; |
$cle = " donnees_techniques='".$dt_id."'"; |
3253 |
$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); |
3254 |
$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); |
3255 |
if (database::isError($res1)) { |
if (database::isError($res1)) { |
3256 |
die($res->getMessage()); |
die($res->getMessage()); |
3257 |
} |
} |
3258 |
// Affichage d'informations à l'utilisateur |
// Affichage d'informations à l'utilisateur |
3259 |
$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')."]"); |
3260 |
} |
} |
3261 |
// 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 |
3262 |
if ($valF != "") { |
if (count($valF) > 0) { |
3263 |
// On met à jour le dossier |
// |
3264 |
$cle = " dossier='".$this->valF['dossier']."'"; |
$inst_dossier = $this->f->get_inst__om_dbform(array( |
3265 |
$res1 = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle); |
"obj" => "dossier", |
3266 |
$this->addToLog("triggermodifierapres(): db->autoexecute(\"".DB_PREFIXE."dossier\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
"idx" => $this->valF['dossier'], |
3267 |
if (database::isError($res1)) { |
)); |
3268 |
die($res->getMessage()); |
$valF['instruction'] = $id; |
3269 |
|
$update_by_instruction = $inst_dossier->update_by_instruction($valF); |
3270 |
|
if ($update_by_instruction === false) { |
3271 |
|
$this->cleanMessage(); |
3272 |
|
$this->addToMessage(sprintf('%s %s', __("Une erreur s'est produite lors de la mise à jour du dossier d'instruction."), __("Veuillez contacter votre administrateur."))); |
3273 |
|
return false; |
3274 |
} |
} |
3275 |
// Affichage d'informations à l'utilisateur |
// Affichage d'informations à l'utilisateur |
3276 |
$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')."]"); |
3277 |
} |
} |
3278 |
|
|
3279 |
$restriction = $this->get_restriction($val['evenement']); |
$restriction = $this->get_restriction($val['evenement']); |
3283 |
// 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é |
3284 |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
3285 |
WHERE evenement=".$this->valF['evenement']; |
WHERE evenement=".$this->valF['evenement']; |
3286 |
$res = $db->query($sql); |
$res = $this->f->db->query($sql); |
3287 |
$this->addToLog("triggermodifierapres(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE); |
3288 |
if (database::isError($res)) { |
if (database::isError($res)) { |
3289 |
die($res->getMessage()); |
die($res->getMessage()); |
3290 |
} |
} |
3294 |
if ($this->getVal('date_retour_signature') == "" AND |
if ($this->getVal('date_retour_signature') == "" AND |
3295 |
$this->valF['date_retour_signature'] != "" AND |
$this->valF['date_retour_signature'] != "" AND |
3296 |
$row['evenement_retour_signature'] != "") { |
$row['evenement_retour_signature'] != "") { |
3297 |
$new_instruction = new instruction("]", $db, $DEBUG); |
$new_instruction = $this->f->get_inst__om_dbform(array( |
3298 |
|
"obj" => "instruction", |
3299 |
|
"idx" => "]", |
3300 |
|
)); |
3301 |
// 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 |
3302 |
foreach($new_instruction->champs as $champ) { |
foreach($new_instruction->champs as $champ) { |
3303 |
$valNewInstr[$champ] = ""; |
$valNewInstr[$champ] = ""; |
3316 |
$new_instruction->setParameter("maj", 0); |
$new_instruction->setParameter("maj", 0); |
3317 |
$new_instruction->class_actions[0]["identifier"] = |
$new_instruction->class_actions[0]["identifier"] = |
3318 |
"retour signature de l'instruction $current_id"; |
"retour signature de l'instruction $current_id"; |
3319 |
$retour = $new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
$retour = $new_instruction->ajouter($valNewInstr); |
3320 |
|
|
3321 |
//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 |
3322 |
//de restriction |
//de restriction |
3323 |
if ($retour == false && !$new_instruction->restriction_valid){ |
if ($retour == false && !$new_instruction->restriction_valid){ |
3324 |
$error_message = $this->get_restriction_error_message($restriction); |
$error_message = $this->get_restriction_error_message($restriction); |
3325 |
$this->f->displayMessage("error", $error_message); |
$this->f->displayMessage("error", $error_message); |
3326 |
$this->addToLog("triggermodifierapres() : evenement retour ". |
$this->addToLog(__METHOD__."(): evenement retour ". |
3327 |
"instruction ".$this->valF[$this->clePrimaire]." : ". |
"instruction ".$this->valF[$this->clePrimaire]." : ". |
3328 |
$new_instruction->msg); |
$new_instruction->msg); |
3329 |
} |
} |
3339 |
$this->valF['date_retour_rar'] != "") { |
$this->valF['date_retour_rar'] != "") { |
3340 |
|
|
3341 |
if($row['evenement_retour_ar'] != "") { |
if($row['evenement_retour_ar'] != "") { |
3342 |
$new_instruction = new instruction("]", $db, $DEBUG); |
$new_instruction = $this->f->get_inst__om_dbform(array( |
3343 |
|
"obj" => "instruction", |
3344 |
|
"idx" => "]", |
3345 |
|
)); |
3346 |
// 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 |
3347 |
foreach($new_instruction->champs as $champ) { |
foreach($new_instruction->champs as $champ) { |
3348 |
$valNewInstr[$champ] = ""; |
$valNewInstr[$champ] = ""; |
3360 |
$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']); |
3361 |
$new_instruction->setParameter("maj", 0); |
$new_instruction->setParameter("maj", 0); |
3362 |
$new_instruction->class_actions[0]["identifier"] = |
$new_instruction->class_actions[0]["identifier"] = |
3363 |
"retour RAR de l'instruction $current_id"; |
"notification de l'instruction $current_id"; |
3364 |
$retour = $new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
$retour = $new_instruction->ajouter($valNewInstr); |
3365 |
|
|
3366 |
//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 |
3367 |
//de restriction |
//de restriction |
3369 |
$error_message = $this->get_restriction_error_message($restriction); |
$error_message = $this->get_restriction_error_message($restriction); |
3370 |
$this->f->displayMessage("error", $error_message); |
$this->f->displayMessage("error", $error_message); |
3371 |
$this->addToLog( |
$this->addToLog( |
3372 |
"triggermodifierapres() : evenement retour instruction ". |
__METHOD__."(): evenement retour instruction ". |
3373 |
$this->valF[$this->clePrimaire]." : ". |
$this->valF[$this->clePrimaire]." : ". |
3374 |
$new_instruction->msg |
$new_instruction->msg |
3375 |
); |
); |
3381 |
return false; |
return false; |
3382 |
} |
} |
3383 |
} |
} |
|
// 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()); |
|
|
} |
|
|
} |
|
3384 |
} |
} |
3385 |
} |
} |
3386 |
} |
} |
3387 |
|
|
3388 |
|
/** |
3389 |
|
* Mise à jour de la date de dernière modification du dossier |
3390 |
|
* d'instruction |
3391 |
|
*/ |
3392 |
|
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
3393 |
|
$inst_di->update_last_modification_date(); |
3394 |
|
|
3395 |
// Mise à jour des données du dossier d'autorisation |
// Mise à jour des données du dossier d'autorisation |
3396 |
require_once "../obj/dossier_autorisation.class.php"; |
$da = $this->f->get_inst__om_dbform(array( |
3397 |
$da = new dossier_autorisation($this->getNumDemandeAutorFromDossier($this->valF['dossier']), $this->db, DEBUG); |
"obj" => "dossier_autorisation", |
3398 |
if($da->majDossierAutorisation() === false) { |
"idx" => $this->getNumDemandeAutorFromDossier($this->valF['dossier']), |
3399 |
|
)); |
3400 |
|
$params = array( |
3401 |
|
'di_id' => $this->getVal('dossier'), |
3402 |
|
); |
3403 |
|
if($da->majDossierAutorisation($params) === false) { |
3404 |
$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.")); |
3405 |
$this->correct = false; |
$this->correct = false; |
3406 |
return false; |
return false; |
3407 |
} |
} |
3408 |
|
|
3409 |
|
// mise à jour des métadonnées issues des dates de suivi |
3410 |
|
$dateRetourSignatureModified = ($this->valF['date_retour_signature'] != $this->getVal('date_retour_signature')); |
3411 |
|
$dateRetourRARModified = ($this->valF['date_retour_rar'] != $this->getVal('date_retour_rar')); |
3412 |
|
if ($dateRetourSignatureModified || $dateRetourRARModified) { |
3413 |
|
|
3414 |
|
// Calculs des nouvelles métadonnées |
3415 |
|
$metadata = $this->getMetadata("om_fichier_instruction"); |
3416 |
|
|
3417 |
|
// On vérifie si l'instruction à finaliser a un événement de type arrete |
3418 |
|
$sql = "SELECT type FROM ".DB_PREFIXE."evenement WHERE evenement = ".$this->getVal("evenement"); |
3419 |
|
$typeEvenement = $this->f->db->getOne($sql); |
3420 |
|
$this->addToLog(__METHOD__."(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
3421 |
|
if ($this->f->isDatabaseError($typeEvenement, true) === true) { |
3422 |
|
$this->correct = false; |
3423 |
|
$this->addToMessage(__("Erreur de traitement de fichier.")); |
3424 |
|
$this->addToLog(__METHOD__."() erreur BDD: ".var_export($typeEvenement->getMessage(), true), DEBUG_MODE); |
3425 |
|
return false; |
3426 |
|
} |
3427 |
|
|
3428 |
|
// Si l'événement est de type arrete, on ajoute les métadonnées spécifiques |
3429 |
|
if ($typeEvenement == 'arrete'){ |
3430 |
|
$metadata = array_merge($metadata, $this->getMetadata("arrete")); |
3431 |
|
} |
3432 |
|
|
3433 |
|
// Filtre pour conserver uniquement les métadonnées liées aux dates |
3434 |
|
$metadataToKeep = array( |
3435 |
|
"statutAutorisation", |
3436 |
|
"dateEvenementDocument", |
3437 |
|
'date_cloture_metier', |
3438 |
|
"NotificationArrete", |
3439 |
|
"dateNotificationArrete", |
3440 |
|
"controleLegalite", |
3441 |
|
"dateSignature", |
3442 |
|
"nomSignataire", |
3443 |
|
"qualiteSignataire", |
3444 |
|
"dateControleLegalite", |
3445 |
|
); |
3446 |
|
$metadata = array_filter( |
3447 |
|
$metadata, |
3448 |
|
function($key) use ($metadataToKeep) { return in_array($key, $metadataToKeep); }, |
3449 |
|
ARRAY_FILTER_USE_KEY |
3450 |
|
); |
3451 |
|
|
3452 |
|
// Mise à jour des métadonnées du document en GED |
3453 |
|
$docUid = $this->getVal("om_fichier_instruction"); |
3454 |
|
$operationOrUID = $this->f->storage->update_metadata($docUid, $metadata); |
3455 |
|
if ($operationOrUID == 'OP_FAILURE') { |
3456 |
|
$this->correct = false; |
3457 |
|
$this->addToMessage(__("Erreur de traitement de fichier.")); |
3458 |
|
$this->addToLog(__METHOD__."() failed to update metadata: ".var_export($operationOrUID, true), DEBUG_MODE); |
3459 |
|
return false; |
3460 |
|
} |
3461 |
|
|
3462 |
|
// mise à jour de l'UID du document en BDD |
3463 |
|
else { |
3464 |
|
$valF = array('om_fichier_instruction' => $operationOrUID); |
3465 |
|
$res = $this->f->db->autoExecute(DB_PREFIXE.$this->table, $valF, DB_AUTOQUERY_UPDATE, $this->getCle($id)); |
3466 |
|
$this->addToLog(__METHOD__.'() : db->autoExecute("'.DB_PREFIXE.$this->table.'", '.print_r($valF, true).', DB_AUTOQUERY_UPDATE, "'.$this->getCle($id).'")', VERBOSE_MODE); |
3467 |
|
if ($this->f->isDatabaseError($res, true) === true) { |
3468 |
|
$this->correct = false; |
3469 |
|
$this->addToMessage(__("Erreur de traitement de fichier.")); |
3470 |
|
$this->addToLog(__METHOD__."() erreur BDD: ".var_export($res->getMessage(), true), DEBUG_MODE); |
3471 |
|
return false; |
3472 |
|
} |
3473 |
|
$this->addToMessage(__("La mise a jour du document s'est effectuee avec succes.")); |
3474 |
|
} |
3475 |
|
} |
3476 |
|
|
3477 |
|
// Notification auto des demandeurs |
3478 |
|
if ($dateRetourSignatureModified === true |
3479 |
|
&& $this->valF['date_retour_signature'] !== '' |
3480 |
|
&& $this->valF['date_retour_signature'] !== null) { |
3481 |
|
// |
3482 |
|
$ev = $this->get_inst_evenement($this->valF['evenement']); |
3483 |
|
if ($ev->getVal('notification') === 'notification_auto_signature_requise') { |
3484 |
|
// Récupération de la liste des demandeurs à notifier et de la catégorie |
3485 |
|
$categorie = $this->f->get_param_option_notification($collectivite_di); |
3486 |
|
$isPortal = $categorie == null || $categorie == '' || $categorie == 'portal' ? true : false; |
3487 |
|
$demandeursANotifie = $this->get_demandeurs_notifiable( |
3488 |
|
$this->valF['dossier'], |
3489 |
|
$isPortal |
3490 |
|
); |
3491 |
|
|
3492 |
|
// Création d'une notification et d'une tâche pour chaque demandeur à notifier |
3493 |
|
foreach ($demandeursANotifie as $demandeur) { |
3494 |
|
// Ajout de la notif et récupération de son id |
3495 |
|
$idNotif = $this->ajouter_notification( |
3496 |
|
$this->valF[$this->clePrimaire], |
3497 |
|
true, |
3498 |
|
$this->f->get_connected_user_login_name(), |
3499 |
|
$demandeur |
3500 |
|
); |
3501 |
|
if ($idNotif === false) { |
3502 |
|
$this->addToMessage( |
3503 |
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
3504 |
|
); |
3505 |
|
return false; |
3506 |
|
} |
3507 |
|
// Création de la tache en lui donnant l'id de la notification |
3508 |
|
$notification_by_task = $this->notification_by_task( |
3509 |
|
$idNotif, |
3510 |
|
$this->valF['dossier'], |
3511 |
|
$categorie |
3512 |
|
); |
3513 |
|
if ($notification_by_task === false) { |
3514 |
|
$this->addToMessage( |
3515 |
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
3516 |
|
); |
3517 |
|
return false; |
3518 |
|
} |
3519 |
|
} |
3520 |
|
$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."))); |
3521 |
|
} |
3522 |
|
} |
3523 |
|
|
3524 |
return $this->add_log_to_dossier($id, $val); |
return $this->add_log_to_dossier($id, $val); |
3525 |
} |
} |
3526 |
|
|
3527 |
function triggersupprimer($id,&$db,$val,$DEBUG) { |
/** |
3528 |
|
* TRIGGER - triggersupprimer. |
3529 |
|
* |
3530 |
|
* @return boolean |
3531 |
|
*/ |
3532 |
|
function triggersupprimer($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
3533 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
3534 |
/** |
/** |
3535 |
* 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 |
3536 |
* archive dans le dossier d'instruction avant de supprimer l'événement |
* archive dans le dossier d'instruction avant de supprimer l'événement |
3537 |
* d'instruction |
* d'instruction si les valeurs du dossier sont différentes |
3538 |
*/ |
*/ |
3539 |
|
$valF = array(); |
3540 |
// Mise à jour des 4 valeurs modifiées par l'action |
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
3541 |
$valF['delai'] = $val['archive_delai']; |
foreach ($inst_di->champs as $key => $champ) { |
3542 |
$valF['accord_tacite'] = $val['archive_accord_tacite']; |
// Si le champ du DI à une archive dans l'instruction |
3543 |
$valF['etat'] = $val['archive_etat']; |
if (isset($val[sprintf('archive_%s', $champ)]) === true) { |
3544 |
if ($val['archive_avis'] != '') { |
// Si la valeur entre le champ du DI et son archive dans instruction |
3545 |
$valF['avis_decision'] = $val['archive_avis']; |
// est différente |
3546 |
} else { |
if ($inst_di->getVal($champ) !== $val[sprintf('archive_%s', $champ)]) { |
3547 |
$valF['avis_decision'] = null; |
$val[sprintf('archive_%s', $champ)] === '' ? $valF[$champ] = null : $valF[$champ] = $val[sprintf('archive_%s', $champ)]; |
3548 |
} |
} |
3549 |
// 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; |
|
3550 |
} |
} |
3551 |
$valF['date_cloture_instruction'] = null; |
// Spécificité du champ avis_decision dont le champ archive est nommé |
3552 |
if ($val['archive_date_cloture_instruction'] !== '') { |
// différemment |
3553 |
$valF['date_cloture_instruction'] = $val['archive_date_cloture_instruction']; |
if ($inst_di->getVal('avis_decision') !== $val['archive_avis']) { |
3554 |
|
$val['archive_avis'] === '' ? $valF['avis_decision'] = null : $valF['avis_decision'] = $val['archive_avis']; |
3555 |
|
} |
3556 |
|
// Spécificité de la date d'affichage dont la valeur n'ai jamais modifiée |
3557 |
|
// par l'archive |
3558 |
|
unset($valF['date_affichage']); |
3559 |
|
|
3560 |
|
/** |
3561 |
|
* Mise à jour de la version de clôture *version_clos* du dossier si et |
3562 |
|
* seulement si l'instruction met à jour l'état du dossier. |
3563 |
|
*/ |
3564 |
|
if (isset($valF['etat']) === true |
3565 |
|
&& $valF['etat'] !== null |
3566 |
|
&& $valF['etat'] !== '') { |
3567 |
|
// Récupère l'état actuel du dossier d'instruction |
3568 |
|
$inst_current_etat = $this->f->get_inst__om_dbform(array( |
3569 |
|
"obj" => "etat", |
3570 |
|
"idx" => $inst_di->get_id_etat(), |
3571 |
|
)); |
3572 |
|
// Instanciation de l'état archivé appliqué sur le dossier |
3573 |
|
$inst_etat = $this->f->get_inst__om_dbform(array( |
3574 |
|
"obj" => "etat", |
3575 |
|
"idx" => $valF['etat'], |
3576 |
|
)); |
3577 |
|
// |
3578 |
|
$update_version_clos = null; |
3579 |
|
// En cas de clôture du dossier par l'état archivé |
3580 |
|
if ($inst_etat->getVal('statut') === 'cloture') { |
3581 |
|
$update_version_clos = $inst_di->update_version_clos('up'); |
3582 |
|
} |
3583 |
|
// En cas de réouverture du dossier par l'état archivé |
3584 |
|
if ($inst_current_etat->getVal('statut') === 'cloture' |
3585 |
|
&& $inst_etat->getVal('statut') !== 'cloture') { |
3586 |
|
// |
3587 |
|
$update_version_clos = $inst_di->update_version_clos('down'); |
3588 |
|
// |
3589 |
|
$this->set_att_di_reopened(true); |
3590 |
|
} |
3591 |
|
// |
3592 |
|
if ($update_version_clos === false) { |
3593 |
|
$this->f->addToLog(sprintf( |
3594 |
|
"%s() : ERREUR - %s %s", |
3595 |
|
__METHOD__, |
3596 |
|
sprintf( |
3597 |
|
__("Impossible de mettre à jour la version de clôture du dossier d'instruction %s."), |
3598 |
|
$inst_di->getVal($inst_di->clePrimaire) |
3599 |
|
), |
3600 |
|
sprintf( |
3601 |
|
__("L'instruction tente d'appliquer l'état %s."), |
3602 |
|
$inst_etat->getVal($inst_etat->clePrimaire) |
3603 |
|
) |
3604 |
|
)); |
3605 |
|
$this->addToMessage(sprintf( |
3606 |
|
"%s %s", |
3607 |
|
__("Erreur lors de la mise à jour de la version de clôture du dossier d'instruction."), |
3608 |
|
__("Veuillez contacter votre administrateur.") |
3609 |
|
)); |
3610 |
|
return false; |
3611 |
|
} |
3612 |
} |
} |
3613 |
// Dates concernant les dossiers contentieux |
// On supprime toutes les notications liées à l'instruction |
3614 |
// Date de première visite |
$notifASupprimer = $this->get_instruction_notification($this->getVal($this->clePrimaire)); |
3615 |
$valF['date_premiere_visite'] = null; |
foreach ($notifASupprimer as $idNotif) { |
3616 |
if ($val['archive_date_premiere_visite'] !== '') { |
$inst_notif = $this->f->get_inst__om_dbform(array( |
3617 |
$valF['date_premiere_visite'] = $val['archive_date_premiere_visite']; |
"obj" => "instruction_notification", |
3618 |
} |
"idx" => $idNotif, |
3619 |
// Date de dernière visite |
)); |
3620 |
$valF['date_derniere_visite'] = null; |
$val_notif = array(); |
3621 |
if ($val['archive_date_derniere_visite'] !== '') { |
foreach ($inst_notif->champs as $champ) { |
3622 |
$valF['date_derniere_visite'] = $val['archive_date_derniere_visite']; |
$val_notif[$champ] = $inst_notif->getVal($champ); |
3623 |
} |
} |
3624 |
// Date contradictoire |
// La suppression des notifications entrainera la suppression des tâches qui y sont |
3625 |
$valF['date_contradictoire'] = null; |
// liées |
3626 |
if ($val['archive_date_contradictoire'] !== '') { |
$supprNotif = $inst_notif->supprimer($val_notif); |
3627 |
$valF['date_contradictoire'] = $val['archive_date_contradictoire']; |
if ($supprNotif == false) { |
3628 |
} |
$this->addToMessage(sprintf( |
3629 |
// Date de retour contradictoire |
"%s %s", |
3630 |
$valF['date_retour_contradictoire'] = null; |
__("Erreur lors de la suppression des notifications de l'instruction."), |
3631 |
if ($val['archive_date_retour_contradictoire'] !== '') { |
__("Veuillez contacter votre administrateur.") |
3632 |
$valF['date_retour_contradictoire'] = $val['archive_date_retour_contradictoire']; |
)); |
3633 |
} |
return false; |
3634 |
// 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']; |
|
3635 |
} |
} |
3636 |
|
|
3637 |
// On met à jour le dossier |
// On met à jour le dossier |
3638 |
$cle = " dossier='".$val['dossier']."'"; |
$valF['instruction'] = $id; |
3639 |
$res = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle); |
$update_by_instruction = $inst_di->update_by_instruction($valF); |
3640 |
$this->addToLog("triggersupprimer(): db->autoexecute(\"".DB_PREFIXE."dossier\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
if ($update_by_instruction === false) { |
3641 |
if (database::isError($res)) { |
$this->cleanMessage(); |
3642 |
die($res->getMessage()); |
$this->addToMessage(sprintf('%s %s', __("Une erreur s'est produite lors de la mise à jour du dossier d'instruction."), __("Veuillez contacter votre administrateur."))); |
3643 |
|
return false; |
3644 |
} |
} |
3645 |
|
|
3646 |
// Affichage d'informations à l'utilisateur |
// Affichage d'informations à l'utilisateur |
3647 |
$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')."]"); |
3648 |
|
|
3649 |
// 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 |
3650 |
} |
} |
3651 |
|
|
3652 |
function triggersupprimerapres($id,&$db,$val,$DEBUG) { |
/** |
3653 |
|
* TRIGGER - triggersupprimerapres. |
3654 |
|
* |
3655 |
|
* @return boolean |
3656 |
|
*/ |
3657 |
|
function triggersupprimerapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
3658 |
|
$this->addToLog(__METHOD__."(): start", EXTRA_VERBOSE_MODE); |
3659 |
|
/** |
3660 |
|
* Mise à jour de la date de dernière modification du dossier |
3661 |
|
* d'instruction |
3662 |
|
*/ |
3663 |
|
$inst_di = $this->get_inst_dossier($this->getVal('dossier')); |
3664 |
|
$inst_di->update_last_modification_date(); |
3665 |
|
|
3666 |
// Mise à jour des données du dossier d'autorisation |
/** |
3667 |
require_once "../obj/dossier_autorisation.class.php"; |
* Mise à jour des données du dossier d'autorisation |
3668 |
$da = new dossier_autorisation($this->getNumDemandeAutorFromDossier($val["dossier"]), $this->db, DEBUG); |
*/ |
3669 |
if($da->majDossierAutorisation() === false) { |
$da = $this->f->get_inst__om_dbform(array( |
3670 |
|
"obj" => "dossier_autorisation", |
3671 |
|
"idx" => $this->getNumDemandeAutorFromDossier($val["dossier"]), |
3672 |
|
)); |
3673 |
|
$params = array( |
3674 |
|
'di_id' => $this->getVal('dossier'), |
3675 |
|
'di_reopened' => $this->get_att_di_reopened(), |
3676 |
|
); |
3677 |
|
if($da->majDossierAutorisation($params) === false) { |
3678 |
$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.")); |
3679 |
$this->correct = false; |
$this->correct = false; |
3680 |
return false; |
return false; |
3681 |
} |
} |
3682 |
|
|
3683 |
|
/** |
3684 |
|
* Gestion des tâches pour la dématérialisation |
3685 |
|
*/ |
3686 |
|
$inst_task_empty = $this->f->get_inst__om_dbform(array( |
3687 |
|
"obj" => "task", |
3688 |
|
"idx" => 0, |
3689 |
|
)); |
3690 |
|
foreach ($inst_di->task_types as $task_type) { |
3691 |
|
$task_exists = $inst_task_empty->task_exists($task_type, $id); |
3692 |
|
if ($task_exists !== false) { |
3693 |
|
$inst_task = $this->f->get_inst__om_dbform(array( |
3694 |
|
"obj" => "task", |
3695 |
|
"idx" => $task_exists, |
3696 |
|
)); |
3697 |
|
if ($inst_task->getVal('state') === $inst_task::STATUS_NEW || $inst_task->getVal('state') === $inst_task::STATUS_DRAFT) { |
3698 |
|
$task_val = array( |
3699 |
|
'state' => $inst_task::STATUS_CANCELED, |
3700 |
|
); |
3701 |
|
$update_task = $inst_task->update_task(array('val' => $task_val)); |
3702 |
|
if ($update_task === false) { |
3703 |
|
$this->addToMessage(sprintf('%s %s', |
3704 |
|
sprintf(__("Une erreur s'est produite lors de la modification de la tâche %."), $inst_task->getVal($inst_task->clePrimaire)), |
3705 |
|
__("Veuillez contacter votre administrateur.") |
3706 |
|
)); |
3707 |
|
$this->correct = false; |
3708 |
|
return false; |
3709 |
|
} |
3710 |
|
} |
3711 |
|
} |
3712 |
|
} |
3713 |
|
|
3714 |
|
// |
3715 |
$val['evenement'] = $this->getVal('evenement'); |
$val['evenement'] = $this->getVal('evenement'); |
3716 |
return $this->add_log_to_dossier($id, $val); |
return $this->add_log_to_dossier($id, $val); |
3717 |
} |
} |
3718 |
|
|
3719 |
/** |
/** |
3720 |
|
* Permet de mettre la valeur passée en paramètre dans l'attribut de classe |
3721 |
|
* "di_reopened". |
3722 |
|
* |
3723 |
|
* @param boolean $val |
3724 |
|
*/ |
3725 |
|
function set_att_di_reopened($val) { |
3726 |
|
$this->di_reopened = $val; |
3727 |
|
} |
3728 |
|
|
3729 |
|
/** |
3730 |
|
* Permet de récupérer la valeur de l'attribut de classe "di_reopened". |
3731 |
|
* |
3732 |
|
* @return boolean |
3733 |
|
*/ |
3734 |
|
function get_att_di_reopened() { |
3735 |
|
return $this->di_reopened; |
3736 |
|
} |
3737 |
|
|
3738 |
|
/** |
3739 |
* Permet de composer un message d'erreur sur restriction non valide en |
* Permet de composer un message d'erreur sur restriction non valide en |
3740 |
* fonction du contexte. |
* fonction du contexte. |
3741 |
* |
* |
3774 |
} |
} |
3775 |
|
|
3776 |
/** |
/** |
3777 |
* 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] |
|
3778 |
*/ |
*/ |
3779 |
function verifier($val = array(), &$db, $DEBUG) { |
function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
3780 |
parent::verifier($val, $db, $DEBUG); |
parent::verifier($val); |
3781 |
|
// |
3782 |
if ( isset($val['evenement']) && is_numeric($val['evenement'])){ |
if ( isset($val['evenement']) && is_numeric($val['evenement'])){ |
3783 |
$restriction = $this->get_restriction($val['evenement']); |
$restriction = $this->get_restriction($val['evenement']); |
3784 |
|
|
3887 |
|
|
3888 |
// |
// |
3889 |
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
3890 |
|
|
3891 |
|
// |
3892 |
|
$params = array( |
3893 |
|
"specific" => array(), |
3894 |
|
); |
3895 |
|
// Si la rédaction libre est activée sur l'instruction |
3896 |
|
if ($this->getVal("flag_edition_integrale") == 't') { |
3897 |
|
$params["specific"]["corps"] = array( |
3898 |
|
"mode" => "set", |
3899 |
|
"value" => $this->getVal("corps_om_htmletatex"), |
3900 |
|
); |
3901 |
|
$params["specific"]["titre"] = array( |
3902 |
|
"mode" => "set", |
3903 |
|
"value" => $this->getVal("titre_om_htmletat"), |
3904 |
|
); |
3905 |
|
} |
3906 |
// Génération du PDF |
// Génération du PDF |
3907 |
$result = $this->compute_pdf_output('lettretype', $this->getVal('lettretype'), $collectivite); |
$result = $this->compute_pdf_output('lettretype', $this->getVal('lettretype'), $collectivite, null, $params); |
3908 |
$pdf_output = $result['pdf_output']; |
$pdf_output = $result['pdf_output']; |
3909 |
|
|
3910 |
//Métadonnées du document |
//Métadonnées du document |
3911 |
$metadata = array( |
$metadata = array( |
3912 |
'filename' => 'instruction_'.$id_inst.'.pdf', |
'filename' => 'instruction_'.$id_inst.'.pdf', |
3921 |
$sql = "SELECT type |
$sql = "SELECT type |
3922 |
FROM ".DB_PREFIXE."evenement |
FROM ".DB_PREFIXE."evenement |
3923 |
WHERE evenement = ".$this->getVal("evenement"); |
WHERE evenement = ".$this->getVal("evenement"); |
3924 |
$typeEvenement = $this->db->getOne($sql); |
$typeEvenement = $this->f->db->getOne($sql); |
3925 |
$this->addToLog(__METHOD__."(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
3926 |
if ($this->f->isDatabaseError($typeEvenement, true) === true) { |
if ($this->f->isDatabaseError($typeEvenement, true) === true) { |
3927 |
$this->correct = false; |
$this->correct = false; |
3938 |
|
|
3939 |
$metadata = array_merge($metadata, $spe_metadata, $arrete_metadata); |
$metadata = array_merge($metadata, $spe_metadata, $arrete_metadata); |
3940 |
|
|
3941 |
|
/* |
3942 |
|
// transforme le tableau de métadonnées en objet |
3943 |
|
$mdf = new MetadataFactory(); |
3944 |
|
$md = $mdf->build('Instruction', $metadata); |
3945 |
|
*/ |
3946 |
|
|
3947 |
// Si le document a déjà été finalisé on le met à jour |
// Si le document a déjà été finalisé on le met à jour |
3948 |
// en conservant son UID |
// en conservant son UID |
3949 |
if ($this->getVal("om_fichier_instruction") != ''){ |
if ($this->getVal("om_fichier_instruction") != ''){ |
3952 |
} |
} |
3953 |
// 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 |
3954 |
else { |
else { |
3955 |
$uid = $this->f->storage->create($pdf_output, $metadata); |
$uid = $this->f->storage->create($pdf_output, $metadata, "from_content", $this->table.".om_fichier_instruction"); |
3956 |
} |
} |
3957 |
} |
} |
3958 |
|
|
3969 |
if ($uid == '' || $uid == 'OP_FAILURE' ) { |
if ($uid == '' || $uid == 'OP_FAILURE' ) { |
3970 |
$this->correct = false; |
$this->correct = false; |
3971 |
$this->addToMessage($file_msg_error); |
$this->addToMessage($file_msg_error); |
3972 |
$this->addToLog(sprintf($log_msg_error, $id_inst, $uid)); |
$this->addToLog(sprintf($log_msg_error, $id_inst, $uid), DEBUG_MODE); |
3973 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
3974 |
} |
} |
3975 |
|
|
4006 |
$val['archive_date_retour_contradictoire'] = $this->dateDBToForm($val['archive_date_retour_contradictoire']); |
$val['archive_date_retour_contradictoire'] = $this->dateDBToForm($val['archive_date_retour_contradictoire']); |
4007 |
$val['archive_date_ait'] = $this->dateDBToForm($val['archive_date_ait']); |
$val['archive_date_ait'] = $this->dateDBToForm($val['archive_date_ait']); |
4008 |
$val['archive_date_transmission_parquet'] = $this->dateDBToForm($val['archive_date_transmission_parquet']); |
$val['archive_date_transmission_parquet'] = $this->dateDBToForm($val['archive_date_transmission_parquet']); |
4009 |
|
$val['archive_date_affichage'] = $this->dateDBToForm($val['archive_date_affichage']); |
4010 |
$this->setvalF($val); |
$this->setvalF($val); |
4011 |
|
|
4012 |
// Verification de la validite des donnees |
// Verification de la validite des donnees |
4013 |
$this->verifier($this->val, $this->db, DEBUG); |
$this->verifier($this->val); |
4014 |
// Si les verifications precedentes sont correctes, on procede a |
// Si les verifications precedentes sont correctes, on procede a |
4015 |
// la modification, sinon on ne fait rien et on retourne une erreur |
// la modification, sinon on ne fait rien et on retourne une erreur |
4016 |
if ($this->correct === true) { |
if ($this->correct === true) { |
4044 |
|
|
4045 |
// Execution de la requête de modification des donnees de l'attribut |
// Execution de la requête de modification des donnees de l'attribut |
4046 |
// valF de l'objet dans l'attribut table de l'objet |
// valF de l'objet dans l'attribut table de l'objet |
4047 |
$res = $this->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
$res = $this->f->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
4048 |
DB_AUTOQUERY_UPDATE, $this->getCle($id_inst)); |
DB_AUTOQUERY_UPDATE, $this->getCle($id_inst)); |
4049 |
$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); |
4050 |
// |
// |
4065 |
} |
} |
4066 |
// L'appel de verifier() a déjà positionné correct à false |
// L'appel de verifier() a déjà positionné correct à false |
4067 |
// et défini un message d'erreur. |
// et défini un message d'erreur. |
4068 |
$this->addToLog(sprintf($log_msg_error, $id_inst, $uid)); |
$this->addToLog(sprintf($log_msg_error, $id_inst, $uid), DEBUG_MODE); |
4069 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
4070 |
} |
} |
4071 |
|
|
4073 |
* 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 |
4074 |
* @return string numéro de dossier d'instruction |
* @return string numéro de dossier d'instruction |
4075 |
*/ |
*/ |
4076 |
protected function getDossier() { |
protected function getDossier($champ = null) { |
4077 |
if(empty($this->specificMetadata)) { |
if(empty($this->specificMetadata)) { |
4078 |
$this->getSpecificMetadata(); |
$this->getSpecificMetadata(); |
4079 |
} |
} |
4172 |
// Requête sql |
// Requête sql |
4173 |
$sql = "SELECT libelle FROM ".DB_PREFIXE."evenement |
$sql = "SELECT libelle FROM ".DB_PREFIXE."evenement |
4174 |
WHERE evenement=".$evenement; |
WHERE evenement=".$evenement; |
4175 |
$evenement_libelle = $this->db->getOne($sql); |
$evenement_libelle = $this->f->db->getOne($sql); |
4176 |
$this->addToLog("getTitle(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog("getTitle(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
4177 |
if (database::isError($evenement_libelle)) { |
if (database::isError($evenement_libelle)) { |
4178 |
die(); |
die(); |
4234 |
LEFT JOIN ".DB_PREFIXE."groupe |
LEFT JOIN ".DB_PREFIXE."groupe |
4235 |
ON dossier_autorisation_type.groupe = groupe.groupe |
ON dossier_autorisation_type.groupe = groupe.groupe |
4236 |
WHERE dossier.dossier = '".$dossier."'"; |
WHERE dossier.dossier = '".$dossier."'"; |
4237 |
$res = $this->db->query($sql); |
$res = $this->f->db->query($sql); |
4238 |
$this->f->addToLog("getSpecificMetadata() : db->query(".$sql.")", VERBOSE_MODE); |
$this->f->addToLog("getSpecificMetadata() : db->query(".$sql.")", VERBOSE_MODE); |
4239 |
if ( database::isError($res)){ |
if ( database::isError($res)){ |
4240 |
die(); |
die(); |
4279 |
ON |
ON |
4280 |
dossier.etat = etat.etat |
dossier.etat = etat.etat |
4281 |
WHERE dossier ='".$idx."'"; |
WHERE dossier ='".$idx."'"; |
4282 |
$statut = $this->db->getOne($sql); |
$statut = $this->f->db->getOne($sql); |
4283 |
$this->f->addToLog("getStatutAutorisationDossier() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog("getStatutAutorisationDossier() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
4284 |
if ( database::isError($statut)){ |
if ( database::isError($statut)){ |
4285 |
die(); |
die(); |
4300 |
// 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 |
4301 |
$sql = "SELECT * FROM ".DB_PREFIXE."dossier |
$sql = "SELECT * FROM ".DB_PREFIXE."dossier |
4302 |
WHERE dossier='".$this->valF['dossier']."'"; |
WHERE dossier='".$this->valF['dossier']."'"; |
4303 |
$res = $this->db->query($sql); |
$res = $this->f->db->query($sql); |
4304 |
$this->addToLog("get_dossier_actual(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog("get_dossier_actual(): db->query(\"".$sql."\");", VERBOSE_MODE); |
4305 |
$this->f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
4306 |
|
|
4333 |
$return['archive_date_limite_incompletude'] = $row['date_limite_incompletude']; |
$return['archive_date_limite_incompletude'] = $row['date_limite_incompletude']; |
4334 |
$return['archive_delai_incompletude'] = $row['delai_incompletude']; |
$return['archive_delai_incompletude'] = $row['delai_incompletude']; |
4335 |
$return['archive_autorite_competente'] = $row['autorite_competente']; |
$return['archive_autorite_competente'] = $row['autorite_competente']; |
4336 |
|
$return['archive_dossier_instruction_type'] = $row['dossier_instruction_type']; |
4337 |
$return['duree_validite'] = $row['duree_validite']; |
$return['duree_validite'] = $row['duree_validite']; |
4338 |
$return['date_depot'] = $row['date_depot']; |
$return['date_depot'] = $row['date_depot']; |
4339 |
|
$return['date_depot_mairie'] = $row['date_depot_mairie']; |
4340 |
$return['archive_date_cloture_instruction'] = $row['date_cloture_instruction']; |
$return['archive_date_cloture_instruction'] = $row['date_cloture_instruction']; |
4341 |
$return['archive_date_premiere_visite'] = $row['date_premiere_visite']; |
$return['archive_date_premiere_visite'] = $row['date_premiere_visite']; |
4342 |
$return['archive_date_derniere_visite'] = $row['date_derniere_visite']; |
$return['archive_date_derniere_visite'] = $row['date_derniere_visite']; |
4344 |
$return['archive_date_retour_contradictoire'] = $row['date_retour_contradictoire']; |
$return['archive_date_retour_contradictoire'] = $row['date_retour_contradictoire']; |
4345 |
$return['archive_date_ait'] = $row['date_ait']; |
$return['archive_date_ait'] = $row['date_ait']; |
4346 |
$return['archive_date_transmission_parquet'] = $row['date_transmission_parquet']; |
$return['archive_date_transmission_parquet'] = $row['date_transmission_parquet']; |
4347 |
|
$return['archive_date_affichage'] = $row['date_affichage']; |
4348 |
|
$return['archive_pec_metier'] = $row['pec_metier']; |
4349 |
|
$return['archive_a_qualifier'] = $row['a_qualifier']; |
4350 |
} |
} |
4351 |
|
|
4352 |
// Retour de la fonction |
// Retour de la fonction |
4374 |
ON instruction.evenement = evenement.evenement |
ON instruction.evenement = evenement.evenement |
4375 |
WHERE instruction.instruction = $idx"; |
WHERE instruction.instruction = $idx"; |
4376 |
$this->f->addToLog("checkEvenementNonVerrouillable() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog("checkEvenementNonVerrouillable() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
4377 |
$res = $this->db->getOne($sql); |
$res = $this->f->db->getOne($sql); |
4378 |
$this->f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
4379 |
|
|
4380 |
// Si le retour de la requête est true |
// Si le retour de la requête est true |
4462 |
if ($row['date_depot'] != '') { |
if ($row['date_depot'] != '') { |
4463 |
$this->valF['date_depot']= $row['date_depot']; |
$this->valF['date_depot']= $row['date_depot']; |
4464 |
} |
} |
4465 |
|
if ($row['date_depot_mairie'] != '') { |
4466 |
|
$this->valF['date_depot_mairie']= $row['date_depot_mairie']; |
4467 |
|
} |
4468 |
// Dates concernant les dossiers contentieux |
// Dates concernant les dossiers contentieux |
4469 |
if ($row['date_cloture_instruction'] != '') { |
if ($row['date_cloture_instruction'] != '') { |
4470 |
$this->valF['archive_date_cloture_instruction']= $row['date_cloture_instruction']; |
$this->valF['archive_date_cloture_instruction']= $row['date_cloture_instruction']; |
4487 |
if ($row['date_transmission_parquet'] != '') { |
if ($row['date_transmission_parquet'] != '') { |
4488 |
$this->valF['archive_date_transmission_parquet']= $row['date_transmission_parquet']; |
$this->valF['archive_date_transmission_parquet']= $row['date_transmission_parquet']; |
4489 |
} |
} |
4490 |
|
// |
4491 |
|
if ($row['dossier_instruction_type'] != '') { |
4492 |
|
$this->valF['archive_dossier_instruction_type']= $row['dossier_instruction_type']; |
4493 |
|
} |
4494 |
|
if ($row['date_affichage'] != '') { |
4495 |
|
$this->valF['archive_date_affichage']= $row['date_affichage']; |
4496 |
|
} |
4497 |
|
if (isset($row['pec_metier']) === true && $row['pec_metier'] != '') { |
4498 |
|
$this->valF['archive_pec_metier']= $row['pec_metier']; |
4499 |
|
} |
4500 |
|
if (isset($row['a_qualifier']) === true && $row['a_qualifier'] != '') { |
4501 |
|
$this->valF['archive_a_qualifier']= $row['a_qualifier']; |
4502 |
|
} |
4503 |
} |
} |
4504 |
|
|
4505 |
// {{{ |
// {{{ |
4631 |
"datecontrolelegalite"=>"", "ap_numrue"=>"", "ap_nomdelavoie"=>"", |
"datecontrolelegalite"=>"", "ap_numrue"=>"", "ap_nomdelavoie"=>"", |
4632 |
"ap_codepostal"=>"", "ap_ville"=>""); |
"ap_codepostal"=>"", "ap_ville"=>""); |
4633 |
|
|
4634 |
$sqlArrete = "SELECT signataire_arrete.nom as \"nomsignataire\", |
$sqlArrete = "SELECT |
4635 |
|
signataire_arrete.prenom || ' ' ||signataire_arrete.nom as \"nomsignataire\", |
4636 |
signataire_arrete.qualite as \"qualitesignataire\", |
signataire_arrete.qualite as \"qualitesignataire\", |
4637 |
instruction.etat as \"decisionarrete\", |
instruction.etat as \"decisionarrete\", |
4638 |
instruction.date_retour_rar as \"datenotification\", |
instruction.date_retour_rar as \"datenotification\", |
4650 |
LEFT JOIN ".DB_PREFIXE."donnees_techniques ON |
LEFT JOIN ".DB_PREFIXE."donnees_techniques ON |
4651 |
donnees_techniques.dossier_instruction = dossier.dossier |
donnees_techniques.dossier_instruction = dossier.dossier |
4652 |
WHERE instruction.instruction = ".$this->getVal("instruction"); |
WHERE instruction.instruction = ".$this->getVal("instruction"); |
4653 |
$resArrete = $this->db->query($sqlArrete); |
$resArrete = $this->f->db->query($sqlArrete); |
4654 |
$this->f->addToLog("getArreteMetadata(): db->query(\"".$sqlArrete."\");", VERBOSE_MODE); |
$this->f->addToLog("getArreteMetadata(): db->query(\"".$sqlArrete."\");", VERBOSE_MODE); |
4655 |
if ( database::isError($resArrete)){ |
if ( database::isError($resArrete)){ |
4656 |
die(); |
die(); |
4670 |
// Récupère la valeur du champ lettretype |
// Récupère la valeur du champ lettretype |
4671 |
$lettretype = $this->getVal("lettretype"); |
$lettretype = $this->getVal("lettretype"); |
4672 |
// Si le champ est vide |
// Si le champ est vide |
4673 |
if (empty($lettretype)) { |
if ($lettretype !== '' && $lettretype !== null) { |
4674 |
// |
// |
4675 |
return false; |
return true; |
4676 |
} |
} |
4677 |
|
|
4678 |
// |
// |
4679 |
return true; |
return false; |
4680 |
|
} |
4681 |
|
|
4682 |
|
/** |
4683 |
|
* CONDITION - is_modifiable. |
4684 |
|
* |
4685 |
|
* Controle si l'évenement est modifiable. |
4686 |
|
* |
4687 |
|
* @return boolean |
4688 |
|
*/ |
4689 |
|
function is_evenement_modifiable() { |
4690 |
|
$evenement = $this->get_inst_evenement($this->getVal('evenement')); |
4691 |
|
return ! $this->get_boolean_from_pgsql_value($evenement->getVal('non_modifiable')); |
4692 |
} |
} |
4693 |
|
|
4694 |
/** |
/** |
4699 |
* @return boolean |
* @return boolean |
4700 |
*/ |
*/ |
4701 |
function is_editable() { |
function is_editable() { |
4702 |
|
|
4703 |
|
// XXX |
4704 |
|
// 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é) |
4705 |
|
// Si cette tâche identifiée est DONE alors la suppression/modification de cette intruction est impossible |
4706 |
|
|
4707 |
// Contrôle si l'utilisateur possède un bypass |
// Contrôle si l'utilisateur possède un bypass |
4708 |
$bypass = $this->f->isAccredited(get_class($this)."_modifier_bypass"); |
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_modifier_bypass"); |
4709 |
// |
// |
4710 |
if ($bypass == true) { |
if ($bypass == true) { |
4711 |
// |
// |
4728 |
return true; |
return true; |
4729 |
} |
} |
4730 |
|
|
|
// 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; |
|
|
} |
|
|
|
|
4731 |
// Si l'utilisateur est instructeur de la commune du dossier et que |
// Si l'utilisateur est instructeur de la commune du dossier et que |
4732 |
// l'instruction est créée par un instructeur de la commune |
// l'instruction est créée par un instructeur de la commune |
4733 |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
4740 |
} |
} |
4741 |
|
|
4742 |
/** |
/** |
4743 |
|
* Vérifie si l'événement est supprimable ou pas. |
4744 |
|
* |
4745 |
|
* @return boolean |
4746 |
|
*/ |
4747 |
|
function is_evenement_supprimable() { |
4748 |
|
// Controle si l'évenement est supprimable |
4749 |
|
$evenement = $this->get_inst_evenement($this->getVal('evenement')); |
4750 |
|
return ! $this->get_boolean_from_pgsql_value($evenement->getVal('non_supprimable')); |
4751 |
|
} |
4752 |
|
|
4753 |
|
/** |
4754 |
* CONDITION - is_deletable. |
* CONDITION - is_deletable. |
4755 |
* |
* |
4756 |
* Condition pour lma modification. |
* Condition pour la suppression. |
4757 |
* |
* |
4758 |
* @return boolean |
* @return boolean |
4759 |
*/ |
*/ |
4760 |
function is_deletable() { |
function is_deletable() { |
4761 |
// Contrôle si l'utilisateur possède un bypass |
|
4762 |
$bypass = $this->f->isAccredited(get_class($this)."_supprimer_bypass"); |
// XXX |
4763 |
|
// 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é) |
4764 |
|
// Si cette tâche identifiée est DONE alors la suppression/modification de cette intruction est impossible |
4765 |
|
|
4766 |
|
// Contrôle si l'utilisateur possède un bypass intégral |
4767 |
|
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_supprimer_bypass"); |
4768 |
// |
// |
4769 |
if ($bypass == true) { |
if ($bypass == true) { |
4770 |
|
|
4773 |
} |
} |
4774 |
|
|
4775 |
// Si l'utilisateur est un intructeur qui ne correspond pas à la |
// Si l'utilisateur est un intructeur qui ne correspond pas à la |
4776 |
// division du dossier |
// division du dossier et si l'utilisateur n'a pas la permission bypass |
4777 |
if ($this->is_instructeur_from_division_dossier() !== true) { |
// de la division |
4778 |
|
if ($this->is_instructeur_from_division_dossier() === false |
4779 |
|
&& $this->f->isAccredited($this->get_absolute_class_name()."_supprimer_bypass_division") === false) { |
4780 |
|
|
4781 |
// |
// |
4782 |
return false; |
return false; |
4785 |
// l'événement est-il le dernier ? |
// l'événement est-il le dernier ? |
4786 |
$dernier_evenement = false; |
$dernier_evenement = false; |
4787 |
// instanciation dossier |
// instanciation dossier |
4788 |
require_once "../obj/dossier.class.php"; |
$dossier = $this->f->get_inst__om_dbform(array( |
4789 |
$dossier = new dossier($this->getVal('dossier'), $this->db, DEBUG); |
"obj" => "dossier", |
4790 |
|
"idx" => $this->getVal('dossier'), |
4791 |
|
)); |
4792 |
// récupération dernier événement |
// récupération dernier événement |
4793 |
$id_dernier_evenement = $dossier->get_dernier_evenement(); |
$id_dernier_evenement = $dossier->get_dernier_evenement(); |
4794 |
if ($id_dernier_evenement == $this->getVal($this->clePrimaire)) { |
if ($id_dernier_evenement == $this->getVal($this->clePrimaire)) { |
4839 |
*/ |
*/ |
4840 |
function is_addable() { |
function is_addable() { |
4841 |
// Contrôle si l'utilisateur possède un bypass |
// Contrôle si l'utilisateur possède un bypass |
4842 |
$bypass = $this->f->isAccredited(get_class($this)."_ajouter_bypass"); |
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_ajouter_bypass"); |
4843 |
// |
// |
4844 |
if ($bypass == true) { |
if ($bypass == true) { |
4845 |
|
|
4867 |
*/ |
*/ |
4868 |
function is_finalizable() { |
function is_finalizable() { |
4869 |
// Contrôle si l'utilisateur possède un bypass |
// Contrôle si l'utilisateur possède un bypass |
4870 |
$bypass = $this->f->isAccredited(get_class($this)."_finaliser_bypass"); |
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_finaliser_bypass"); |
4871 |
// |
// |
4872 |
if ($bypass == true) { |
if ($bypass == true) { |
4873 |
// |
// |
4890 |
return true; |
return true; |
4891 |
} |
} |
4892 |
|
|
|
// 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; |
|
|
} |
|
|
|
|
4893 |
// Si l'utilisateur est instructeur de la commune du dossier et que |
// Si l'utilisateur est instructeur de la commune du dossier et que |
4894 |
// l'instruction est créée par un instructeur de la commune |
// l'instruction est créée par un instructeur de la commune |
4895 |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
4932 |
*/ |
*/ |
4933 |
function is_unfinalizable(){ |
function is_unfinalizable(){ |
4934 |
// Contrôle si l'utilisateur possède un bypass |
// Contrôle si l'utilisateur possède un bypass |
4935 |
$bypass = $this->f->isAccredited(get_class($this)."_definaliser_bypass"); |
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_definaliser_bypass"); |
4936 |
// |
// |
4937 |
if ($bypass == true) { |
if ($bypass == true) { |
4938 |
// |
// |
4955 |
return true; |
return true; |
4956 |
} |
} |
4957 |
|
|
|
// 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; |
|
|
} |
|
|
|
|
4958 |
// Si l'utilisateur est instructeur de la commune du dossier et que |
// Si l'utilisateur est instructeur de la commune du dossier et que |
4959 |
// l'instruction est créée par un instructeur de la commune |
// l'instruction est créée par un instructeur de la commune |
4960 |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
5048 |
if ($this->f->isCollectiviteMono($_SESSION['collectivite']) === true) { |
if ($this->f->isCollectiviteMono($_SESSION['collectivite']) === true) { |
5049 |
$sql .= " AND dossier.om_collectivite=".$_SESSION['collectivite']; |
$sql .= " AND dossier.om_collectivite=".$_SESSION['collectivite']; |
5050 |
} |
} |
5051 |
$res = $this->db->getone($sql); |
$res = $this->f->db->getone($sql); |
5052 |
if (database::isError($res)) { |
if (database::isError($res)) { |
5053 |
die(); |
die(); |
5054 |
} |
} |
5078 |
} |
} |
5079 |
|
|
5080 |
// Contrôle si l'utilisateur possède un bypass |
// Contrôle si l'utilisateur possède un bypass |
5081 |
$bypass = $this->f->isAccredited(get_class($this)."_modification_dates_bypass"); |
$bypass = $this->f->isAccredited($this->get_absolute_class_name()."_modification_dates_bypass"); |
5082 |
if ($bypass === true) { |
if ($bypass === true) { |
5083 |
return true; |
return true; |
5084 |
} |
} |
5085 |
|
|
5086 |
// 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 |
5087 |
|
// un utilisateur lié à un instructeur |
5088 |
|
$perm_moni_dates_d_closed = $this->f->isAccredited($this->get_absolute_class_name()."_modification_dates_cloture"); |
5089 |
|
|
5090 |
|
// On vérifie en premier lieu que le DI n'est pas clôturé et que |
5091 |
|
// l'utilisateur ne possède pas la permission de modifier le suivi des |
5092 |
|
// dates sur un dossier clôturé |
5093 |
$inst_dossier = $this->get_inst_dossier(); |
$inst_dossier = $this->get_inst_dossier(); |
5094 |
if ($inst_dossier->getStatut() === 'cloture') { |
if ($inst_dossier->getStatut() === 'cloture' |
5095 |
|
&& $perm_moni_dates_d_closed === false) { |
5096 |
// |
// |
5097 |
return false; |
return false; |
5098 |
} |
} |
5154 |
// 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 |
5155 |
// dites de TREATMENT. |
// dites de TREATMENT. |
5156 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
5157 |
|
$message = ''; |
5158 |
|
|
5159 |
// Traitement de la finalisation |
// Traitement de la finalisation |
5160 |
$ret = $this->manage_finalizing("finalize", $val); |
$ret = $this->manage_finalizing("finalize", $val); |
5166 |
return $this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
5167 |
} |
} |
5168 |
|
|
5169 |
|
// Envoi des notifications aux demandeurs si la notification est automatique |
5170 |
|
// et que la signature n'est pas requise |
5171 |
|
$ev = $this->get_inst_evenement($this->getVal('evenement')); |
5172 |
|
if ($ev->getVal('notification') === 'notification_automatique') { |
5173 |
|
// Récupération de la catégorie et envoie des notifications au(x) demandeur(s) |
5174 |
|
$collectivite_di = $this->get_dossier_instruction_om_collectivite($this->getVal('dossier')); |
5175 |
|
// Récupération de la liste des demandeurs à notifier et de la catégorie |
5176 |
|
$categorie = $this->f->get_param_option_notification($collectivite_di); |
5177 |
|
$isPortal = $categorie == null || $categorie == '' || $categorie == 'portal' ? true : false; |
5178 |
|
$demandeursANotifie = $this->get_demandeurs_notifiable( |
5179 |
|
$this->getVal('dossier'), |
5180 |
|
$isPortal |
5181 |
|
); |
5182 |
|
|
5183 |
|
// Création d'une notification et d'une tâche pour chaque demandeur à notifier |
5184 |
|
if (count($demandeursANotifie) > 0) { |
5185 |
|
foreach ($demandeursANotifie as $demandeur) { |
5186 |
|
// Ajout de la notif et récupération de son id |
5187 |
|
$idNotif = $this->ajouter_notification( |
5188 |
|
$this->getVal($this->clePrimaire), |
5189 |
|
true, |
5190 |
|
$this->f->get_connected_user_login_name(), |
5191 |
|
$demandeur |
5192 |
|
); |
5193 |
|
if ($idNotif === false) { |
5194 |
|
$this->addToMessage( |
5195 |
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
5196 |
|
); |
5197 |
|
// Termine le traitement |
5198 |
|
return $this->end_treatment(__METHOD__, false); |
5199 |
|
} |
5200 |
|
$notification_by_task = $this->notification_by_task( |
5201 |
|
$idNotif, |
5202 |
|
$this->getVal('dossier'), |
5203 |
|
$categorie |
5204 |
|
); |
5205 |
|
if ($notification_by_task === false) { |
5206 |
|
$this->addToMessage( |
5207 |
|
__("Erreur lors de la génération de la notification au(x) pétitionnaire(s).") |
5208 |
|
); |
5209 |
|
// Termine le traitement |
5210 |
|
return $this->end_treatment(__METHOD__, false); |
5211 |
|
} |
5212 |
|
} |
5213 |
|
$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."))); |
5214 |
|
} |
5215 |
|
} |
5216 |
|
|
5217 |
// Termine le traitement |
// Termine le traitement |
5218 |
return $this->end_treatment(__METHOD__, true); |
return $this->end_treatment(__METHOD__, true); |
5219 |
} |
} |
5261 |
&& $this->getVal("om_final_instruction") != null) { |
&& $this->getVal("om_final_instruction") != null) { |
5262 |
|
|
5263 |
// Ouvre le document |
// Ouvre le document |
5264 |
$lien = '../spg/file.php?obj='.$this->table.'&'. |
$lien = '../app/index.php?module=form&snippet=file&obj='.$this->table.'&'. |
5265 |
'champ=om_fichier_instruction&id='.$this->getVal($this->clePrimaire); |
'champ=om_fichier_instruction&id='.$this->getVal($this->clePrimaire); |
5266 |
// |
// |
5267 |
header("Location: ".$lien); |
header("Location: ".$lien); |
5280 |
"mode" => "previsualisation", |
"mode" => "previsualisation", |
5281 |
), |
), |
5282 |
); |
); |
5283 |
|
// Si la rédaction libre est activée sur l'instruction |
5284 |
|
if ($this->getVal("flag_edition_integrale") == 't') { |
5285 |
|
$params["specific"]["corps"] = array( |
5286 |
|
"mode" => "set", |
5287 |
|
"value" => $this->getVal("corps_om_htmletatex"), |
5288 |
|
); |
5289 |
|
$params["specific"]["titre"] = array( |
5290 |
|
"mode" => "set", |
5291 |
|
"value" => $this->getVal("titre_om_htmletat"), |
5292 |
|
); |
5293 |
|
} |
5294 |
|
|
5295 |
// Génération du PDF |
// Génération du PDF |
5296 |
$result = $this->compute_pdf_output('lettretype', $this->getVal("lettretype"), $collectivite, null, $params); |
$result = $this->compute_pdf_output('lettretype', $this->getVal("lettretype"), $collectivite, null, $params); |
5305 |
/** |
/** |
5306 |
* Récupère la collectivité du dossier d'instruction. |
* Récupère la collectivité du dossier d'instruction. |
5307 |
* |
* |
5308 |
|
* @param string $dossier_instruction_id Identifiant du DI. |
5309 |
|
* |
5310 |
* @return integer |
* @return integer |
5311 |
*/ |
*/ |
5312 |
function get_dossier_instruction_om_collectivite() { |
function get_dossier_instruction_om_collectivite($dossier_instruction_id = null) { |
5313 |
|
|
5314 |
|
// Si l'identifiant n'est pas renseigné |
5315 |
|
if ($dossier_instruction_id === null) { |
5316 |
|
// Récupère la valeur |
5317 |
|
if ($this->getVal('dossier') !== null && $this->getVal('dossier') !== '') { |
5318 |
|
$dossier_instruction_id = $this->getVal('dossier'); |
5319 |
|
} elseif ($this->getParameter('idxformulaire') !== null |
5320 |
|
&& $this->getParameter('idxformulaire') !== '') { |
5321 |
|
// |
5322 |
|
$dossier_instruction_id = $this->getParameter('idxformulaire'); |
5323 |
|
} elseif ($this->f->get_submitted_get_value('idxformulaire') !== null |
5324 |
|
&& $this->f->get_submitted_get_value('idxformulaire') !== '') { |
5325 |
|
// |
5326 |
|
$dossier_instruction_id = $this->f->get_submitted_get_value('idxformulaire'); |
5327 |
|
} |
5328 |
|
} |
5329 |
|
|
5330 |
// |
// |
5331 |
require_once "../obj/dossier_instruction.class.php"; |
$dossier_instruction = $this->f->get_inst__om_dbform(array( |
5332 |
$dossier_instruction = new dossier_instruction($this->getVal('dossier'), $this->f->db, false); |
"obj" => "dossier_instruction", |
5333 |
|
"idx" => $dossier_instruction_id, |
5334 |
|
)); |
5335 |
|
|
5336 |
// |
// |
5337 |
return $dossier_instruction->getVal('om_collectivite'); |
return $dossier_instruction->getVal('om_collectivite'); |
5348 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
5349 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
5350 |
|
|
|
// XXX APP |
|
|
|
|
|
$f = $this->f; |
|
|
|
|
5351 |
/** |
/** |
5352 |
* Affichage de la structure HTML |
* Affichage de la structure HTML |
5353 |
*/ |
*/ |
5354 |
// |
// |
5355 |
if ($f->isAjaxRequest()) { |
if ($this->f->isAjaxRequest()) { |
5356 |
// |
// |
5357 |
header("Content-type: text/html; charset=".HTTPCHARSET.""); |
header("Content-type: text/html; charset=".HTTPCHARSET.""); |
5358 |
} else { |
} else { |
5359 |
// |
// |
5360 |
$f->setFlag("htmlonly"); |
$this->f->setFlag("htmlonly"); |
5361 |
$f->display(); |
$this->f->display(); |
5362 |
} |
} |
5363 |
// |
// |
5364 |
$f->displayStartContent(); |
$this->f->displayStartContent(); |
5365 |
// |
// |
5366 |
$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")); |
5367 |
$f->displayTitle(); |
$this->f->displayTitle(); |
5368 |
|
|
5369 |
/** |
/** |
5370 |
* |
* |
5371 |
*/ |
*/ |
5372 |
// |
// |
5373 |
($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 = ""); |
5374 |
$evenement = intval($evenement); |
$evenement = intval($evenement); |
5375 |
// |
// |
5376 |
($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 = ""); |
5377 |
// Récupération du code du type de DA |
// Récupération du code du type de DA |
5378 |
$code_da_type = ''; |
$code_da_type = ''; |
5379 |
if (preg_match('/[A-Za-z]{2,3}/', $idx, $matches) !== false) { |
if (preg_match('/[A-Za-z]{2,3}/', $idx, $matches) !== false) { |
5380 |
$code_da_type = $matches[0]; |
$code_da_type = $matches[0]; |
5381 |
} |
} |
5382 |
// |
// |
5383 |
($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"); |
5384 |
|
|
5385 |
// Récupération de la collectivité du dossier |
// Récupération de la collectivité du dossier |
5386 |
require_once "../obj/dossier.class.php"; |
$dossier = $this->f->get_inst__om_dbform(array( |
5387 |
$dossier = new dossier($idx, $f->db, DEBUG); |
"obj" => "dossier", |
5388 |
|
"idx" => $idx, |
5389 |
|
)); |
5390 |
|
|
5391 |
/** |
/** |
5392 |
* |
* |
5398 |
ON bible.dossier_autorisation_type=dossier_autorisation_type.dossier_autorisation_type |
ON bible.dossier_autorisation_type=dossier_autorisation_type.dossier_autorisation_type |
5399 |
LEFT JOIN ".DB_PREFIXE."om_collectivite |
LEFT JOIN ".DB_PREFIXE."om_collectivite |
5400 |
ON bible.om_collectivite = om_collectivite.om_collectivite |
ON bible.om_collectivite = om_collectivite.om_collectivite |
5401 |
WHERE evenement=".$evenement." |
WHERE (evenement=".$evenement." OR evenement IS NULL) |
5402 |
AND complement=".$complement." |
AND (complement=".$complement." OR complement IS NULL) |
5403 |
AND (bible.dossier_autorisation_type IS NULL |
AND (bible.dossier_autorisation_type IS NULL |
5404 |
OR dossier_autorisation_type.code ='".$code_da_type."') |
OR dossier_autorisation_type.code ='".$code_da_type."') |
5405 |
AND (om_collectivite.niveau = '2' |
AND (om_collectivite.niveau = '2' |
5406 |
OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").") |
OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").") |
5407 |
ORDER BY bible_lib ASC"; |
ORDER BY bible_lib ASC"; |
5408 |
$res = $f->db->query($sql); |
$res = $this->f->db->query($sql); |
5409 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\");", VERBOSE_MODE); |
5410 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
5411 |
// |
// |
5412 |
echo "<form method=\"post\" name=\"f3\" action=\"#\">\n"; |
echo "<form method=\"post\" name=\"f3\" action=\"#\">\n"; |
5413 |
// |
// |
5439 |
echo "\t</table>\n"; |
echo "\t</table>\n"; |
5440 |
// |
// |
5441 |
echo "<div class=\"formControls\">\n"; |
echo "<div class=\"formControls\">\n"; |
5442 |
$f->layout->display_form_button(array( |
$this->f->layout->display_form_button(array( |
5443 |
"value" => _("Valider"), |
"value" => _("Valider"), |
5444 |
"onclick" => "bible_return('f2', 'complement".($complement == "1" ? "" : $complement)."_om_html'); return false;", |
"onclick" => "bible_return('f2', 'complement".($complement == "1" ? "" : $complement)."_om_html'); return false;", |
5445 |
)); |
)); |
5446 |
$f->displayLinkJsCloseWindow(); |
$this->f->displayLinkJsCloseWindow(); |
5447 |
echo "</div>\n"; |
echo "</div>\n"; |
5448 |
|
|
5449 |
} else { |
} else { |
5450 |
// |
// |
5451 |
$message_class = "error"; |
$message_class = "error"; |
5452 |
$message = _("Aucun element dans la bible pour l'evenement")." : ".$evenement; |
$message = _("Aucun element dans la bible pour l'evenement")." : ".$evenement; |
5453 |
$f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
5454 |
// |
// |
5455 |
echo "<div class=\"formControls\">\n"; |
echo "<div class=\"formControls\">\n"; |
5456 |
$f->displayLinkJsCloseWindow(); |
$this->f->displayLinkJsCloseWindow(); |
5457 |
echo "</div>\n"; |
echo "</div>\n"; |
5458 |
} |
} |
5459 |
// |
// |
5463 |
* Affichage de la structure HTML |
* Affichage de la structure HTML |
5464 |
*/ |
*/ |
5465 |
// |
// |
5466 |
$f->displayEndContent(); |
$this->f->displayEndContent(); |
5467 |
} |
} |
5468 |
|
|
5469 |
/** |
/** |
5476 |
function view_bible_auto() { |
function view_bible_auto() { |
5477 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
5478 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
|
|
|
|
// XXX APP |
|
|
|
|
|
$f = $this->f; |
|
|
|
|
5479 |
// |
// |
5480 |
$f->disableLog(); |
$this->f->disableLog(); |
5481 |
|
|
5482 |
$formatDate="AAAA-MM-JJ"; |
$formatDate="AAAA-MM-JJ"; |
5483 |
|
|
5484 |
// Récupération des paramètres |
// Récupération des paramètres |
5485 |
$idx = $f->get_submitted_get_value('idx'); |
$idx = $this->f->get_submitted_get_value('idx'); |
5486 |
$evenement = $f->get_submitted_get_value('ev'); |
$evenement = $this->f->get_submitted_get_value('ev'); |
5487 |
|
|
5488 |
// Initialisation de la variable de retour |
// Initialisation de la variable de retour |
5489 |
$retour['complement_om_html'] = ''; |
$retour['complement_om_html'] = ''; |
5491 |
$retour['complement3_om_html'] = ''; |
$retour['complement3_om_html'] = ''; |
5492 |
$retour['complement4_om_html'] = ''; |
$retour['complement4_om_html'] = ''; |
5493 |
// Vérification d'une consultation liée à l'événement |
// Vérification d'une consultation liée à l'événement |
5494 |
$consultation = $f->db->getOne( |
$consultation = $this->f->db->getOne( |
5495 |
"select consultation from ".DB_PREFIXE."evenement where evenement=".$evenement |
"select consultation from ".DB_PREFIXE."evenement where evenement=".$evenement |
5496 |
); |
); |
5497 |
$f->isDatabaseError($consultation); |
$this->f->isDatabaseError($consultation); |
5498 |
// Si consultation liée, récupération du retour d'avis |
// Si consultation liée, récupération du retour d'avis |
5499 |
if($consultation=='Oui'){ |
if($consultation=='Oui'){ |
5500 |
$sql="select date_retour,avis_consultation.libelle as avis_consultation, |
$sql="select date_retour,avis_consultation.libelle as avis_consultation, |
5503 |
on consultation.service =service.service |
on consultation.service =service.service |
5504 |
left join ".DB_PREFIXE."avis_consultation on |
left join ".DB_PREFIXE."avis_consultation on |
5505 |
consultation.avis_consultation = avis_consultation.avis_consultation |
consultation.avis_consultation = avis_consultation.avis_consultation |
5506 |
where dossier ='".$idx."'"; |
where dossier ='".$idx."' and consultation.visible"; |
5507 |
$res = $f->db->query($sql); |
$res = $this->f->db->query($sql); |
5508 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
5509 |
// Récupération des consultations |
// Récupération des consultations |
5510 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
5511 |
$correct=false; |
$correct=false; |
5530 |
$temp=$temp." du ".$date_retour_f; |
$temp=$temp." du ".$date_retour_f; |
5531 |
} |
} |
5532 |
// Concaténation des retours d'avis de consultation |
// Concaténation des retours d'avis de consultation |
5533 |
$retour['complement_om_html'] .= $temp; |
$retour['complement_om_html'] .= $temp . "<br/><br/>"; |
5534 |
} // while |
} // while |
5535 |
|
|
5536 |
} // consultation |
} // consultation |
5537 |
// Récupération des bibles automatiques pour le champ complement_om_html |
// Récupération des bibles automatiques pour le champ complement_om_html |
5538 |
$retour['complement_om_html'] .= $this->getBible($f, $evenement, $idx, '1'); |
$retour['complement_om_html'] .= $this->getBible($evenement, $idx, '1'); |
5539 |
// Récupération des bibles automatiques pour le champ complement2_om_html |
// Récupération des bibles automatiques pour le champ complement2_om_html |
5540 |
$retour['complement2_om_html'] .= $this->getBible($f, $evenement, $idx, '2'); |
$retour['complement2_om_html'] .= $this->getBible($evenement, $idx, '2'); |
5541 |
// Récupération des bibles automatiques pour le champ complement3_om_html |
// Récupération des bibles automatiques pour le champ complement3_om_html |
5542 |
$retour['complement3_om_html'] .= $this->getBible($f, $evenement, $idx, '3'); |
$retour['complement3_om_html'] .= $this->getBible($evenement, $idx, '3'); |
5543 |
// Récupération des bibles automatiques pour le champ complement4_om_html |
// Récupération des bibles automatiques pour le champ complement4_om_html |
5544 |
$retour['complement4_om_html'] .= $this->getBible($f, $evenement, $idx, '4'); |
$retour['complement4_om_html'] .= $this->getBible($evenement, $idx, '4'); |
5545 |
|
|
5546 |
|
|
5547 |
|
|
5549 |
} |
} |
5550 |
|
|
5551 |
/** |
/** |
5552 |
|
* VIEW - view_pdf_temp |
5553 |
|
* |
5554 |
|
* @return void |
5555 |
|
*/ |
5556 |
|
function view_pdf_temp() { |
5557 |
|
$this->checkAccessibility(); |
5558 |
|
// Utilisation de $_POST pour ne pas que les textes soient altérés. |
5559 |
|
$this->f->set_submitted_value(); |
5560 |
|
$merge_fields = array(); |
5561 |
|
// |
5562 |
|
if (array_key_exists('c1', $_POST) === true) { |
5563 |
|
$merge_fields['[complement_instruction]'] = urldecode($_POST['c1']); |
5564 |
|
$merge_fields['[complement1_instruction]'] = urldecode($_POST['c1']); |
5565 |
|
} |
5566 |
|
if (array_key_exists('c2', $_POST) === true) { |
5567 |
|
$merge_fields['[complement2_instruction]'] = urldecode($_POST['c2']); |
5568 |
|
} |
5569 |
|
if (array_key_exists('c3', $_POST) === true) { |
5570 |
|
$merge_fields['[complement3_instruction]'] = urldecode($_POST['c3']); |
5571 |
|
} |
5572 |
|
if (array_key_exists('c4', $_POST) === true) { |
5573 |
|
$merge_fields['[complement4_instruction]'] = urldecode($_POST['c4']); |
5574 |
|
} |
5575 |
|
$params = array( |
5576 |
|
"watermark" => true, |
5577 |
|
"specific" => array( |
5578 |
|
"merge_fields" => $merge_fields, |
5579 |
|
), |
5580 |
|
); |
5581 |
|
// |
5582 |
|
if (array_key_exists('corps', $_POST) === true) { |
5583 |
|
$params["specific"]["corps"] = array( |
5584 |
|
"mode" => "set", |
5585 |
|
"value" => urldecode($_POST['corps']), |
5586 |
|
); |
5587 |
|
} |
5588 |
|
if (array_key_exists('titre', $_POST) === true) { |
5589 |
|
$params["specific"]["titre"] = array( |
5590 |
|
"mode" => "set", |
5591 |
|
"value" => urldecode($_POST['titre']), |
5592 |
|
); |
5593 |
|
} |
5594 |
|
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
5595 |
|
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
5596 |
|
$result = $this->compute_pdf_output('lettretype', $this->getVal('lettretype'), $collectivite, null, $params); |
5597 |
|
$retour = array( |
5598 |
|
'base' => base64_encode($result['pdf_output']), |
5599 |
|
); |
5600 |
|
echo json_encode($retour); |
5601 |
|
} |
5602 |
|
|
5603 |
|
/** |
5604 |
|
* Dans le contexte de prévisualisation des éditions, génère le rendu du |
5605 |
|
* PDF sans prise en compte de la valeur des compléments et le retourne en |
5606 |
|
* base 64. |
5607 |
|
* |
5608 |
|
* @return string Rendu PDF converti en base 64. |
5609 |
|
*/ |
5610 |
|
function init_pdf_temp() { |
5611 |
|
$params = array( |
5612 |
|
"watermark" => true, |
5613 |
|
); |
5614 |
|
// Si la rédaction libre est activée sur l'instruction |
5615 |
|
if ($this->getVal("flag_edition_integrale") == 't') { |
5616 |
|
$params["specific"]["corps"] = array( |
5617 |
|
"mode" => "set", |
5618 |
|
"value" => $this->getVal("corps_om_htmletatex"), |
5619 |
|
); |
5620 |
|
$params["specific"]["titre"] = array( |
5621 |
|
"mode" => "set", |
5622 |
|
"value" => $this->getVal("titre_om_htmletat"), |
5623 |
|
); |
5624 |
|
} |
5625 |
|
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
5626 |
|
$collectivite = $this->f->getCollectivite($dossier_instruction_om_collectivite); |
5627 |
|
$result = $this->compute_pdf_output('lettretype', $this->getVal('lettretype'), $collectivite, null, $params); |
5628 |
|
|
5629 |
|
return base64_encode($result['pdf_output']); |
5630 |
|
} |
5631 |
|
|
5632 |
|
/** |
5633 |
* Récupération des éléments de bible. |
* Récupération des éléments de bible. |
5634 |
* |
* |
|
* @param utils $f handler de om_application |
|
5635 |
* @param integer $event id de l'événement |
* @param integer $event id de l'événement |
5636 |
* @param string $idx id du dossier |
* @param string $idx id du dossier |
5637 |
* @param integer $compnb numéro du champ complement |
* @param integer $compnb numéro du champ complement |
5638 |
* |
* |
5639 |
* @return string Chaîne de texte à insérer dans le champ complement |
* @return string Chaîne de texte à insérer dans le champ complement |
5640 |
*/ |
*/ |
5641 |
function getBible($f, $event, $idx, $compnb) { |
function getBible($event, $idx, $compnb) { |
5642 |
// Récupération de la collectivité du dossier |
// Récupération de la collectivité du dossier |
5643 |
require_once "../obj/dossier.class.php"; |
$dossier = $this->f->get_inst__om_dbform(array( |
5644 |
$dossier = new dossier($idx, $f->db, DEBUG); |
"obj" => "dossier", |
5645 |
|
"idx" => $idx, |
5646 |
|
)); |
5647 |
// Récupération du code du type de DA |
// Récupération du code du type de DA |
5648 |
$code_da_type = ''; |
$code_da_type = ''; |
5649 |
if (preg_match('/[A-Za-z]{2,3}/', $idx, $matches) !== false) { |
if (preg_match('/[A-Za-z]{2,3}/', $idx, $matches) !== false) { |
5657 |
LEFT JOIN |
LEFT JOIN |
5658 |
".DB_PREFIXE."om_collectivite |
".DB_PREFIXE."om_collectivite |
5659 |
ON bible.om_collectivite = om_collectivite.om_collectivite |
ON bible.om_collectivite = om_collectivite.om_collectivite |
5660 |
WHERE evenement =".$event." and |
WHERE (evenement =".$event." or evenement IS NULL) and |
5661 |
complement=".$compnb." and |
(complement=".$compnb." OR complement IS NULL) and |
5662 |
automatique='Oui' and |
automatique='Oui' and |
5663 |
(dossier_autorisation_type.code ='".$code_da_type."' or |
(dossier_autorisation_type.code ='".$code_da_type."' or |
5664 |
bible.dossier_autorisation_type IS NULL) and |
bible.dossier_autorisation_type IS NULL) and |
5665 |
(om_collectivite.niveau = '2' OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").")"; |
(om_collectivite.niveau = '2' OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").")"; |
5666 |
|
|
5667 |
$res = $f->db->query($sql); |
$res = $this->f->db->query($sql); |
5668 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
5669 |
$temp = ""; |
$temp = ""; |
5670 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
5671 |
// Remplacement des retours à la ligne par des br |
// Remplacement des retours à la ligne par des br |
5672 |
$temp .= preg_replace( |
$temp .= preg_replace( |
5673 |
'#(\\\r|\\\r\\\n|\\\n)#', '<br/>', $row['contenu'] |
'#(\\\r|\\\r\\\n|\\\n)#', '<br/>', $row['contenu'] |
5674 |
); |
); |
5675 |
|
// Ajout d'un saut de ligne entre chaque bible. |
5676 |
|
$temp .= '<br/>'; |
5677 |
} // fin while |
} // fin while |
5678 |
return $temp; |
return $temp; |
5679 |
} |
} |
5691 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
5692 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
5693 |
|
|
|
// XXX APP |
|
|
|
|
|
$f = $this->f; |
|
|
|
|
5694 |
/** |
/** |
5695 |
* Validation du formulaire |
* Validation du formulaire |
5696 |
*/ |
*/ |
5697 |
// Si le formulaire a été validé |
// Si le formulaire a été validé |
5698 |
if ($f->get_submitted_post_value("validation") !== null) { |
if ($this->f->get_submitted_post_value("validation") !== null) { |
5699 |
// Si un bordereau à été sélectionné |
// Si un bordereau à été sélectionné |
5700 |
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") == "" ) { |
5701 |
// Si aucun bordereau n'a été sélectionné |
// Si aucun bordereau n'a été sélectionné |
5702 |
$message_class = "error"; |
$message_class = "error"; |
5703 |
$message = _("Veuillez selectionner un bordereau."); |
$message = _("Veuillez selectionner un bordereau."); |
5704 |
} |
} |
5705 |
// Sinon si les dates ne sont pas valide |
// Sinon si les dates ne sont pas valide |
5706 |
elseif (($f->get_submitted_post_value("date_bordereau_debut") !== null |
elseif (($this->f->get_submitted_post_value("date_bordereau_debut") !== null |
5707 |
&& $f->get_submitted_post_value("date_bordereau_debut") == "") |
&& $this->f->get_submitted_post_value("date_bordereau_debut") == "") |
5708 |
|| ($f->get_submitted_post_value("date_bordereau_fin") !== null |
|| ($this->f->get_submitted_post_value("date_bordereau_fin") !== null |
5709 |
&& $f->get_submitted_post_value("date_bordereau_fin") == "")) { |
&& $this->f->get_submitted_post_value("date_bordereau_fin") == "")) { |
5710 |
// Si aucune date n'a été saisie |
// Si aucune date n'a été saisie |
5711 |
$message_class = "error"; |
$message_class = "error"; |
5712 |
$message = _("Veuillez saisir une date valide."); |
$message = _("Veuillez saisir une date valide."); |
5713 |
} |
} |
5714 |
|
// Sinon si les dates ne sont pas valides |
5715 |
|
elseif ($this->f->get_submitted_post_value("bordereau") === "bordereau_avis_maire_prefet" |
5716 |
|
&& $this->f->getParameter("id_evenement_bordereau_avis_maire_prefet") == null) { |
5717 |
|
// Si aucune date n'a été saisie |
5718 |
|
$message_class = "error"; |
5719 |
|
$message = _("Erreur de parametrage. Contactez votre administrateur."); |
5720 |
|
} |
5721 |
// Affiche le message de validation |
// Affiche le message de validation |
5722 |
else { |
else { |
5723 |
// 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 |
5724 |
$sql = "SELECT om_etat.libelle |
$sql = "SELECT om_etat.libelle |
5725 |
FROM ".DB_PREFIXE."om_etat |
FROM ".DB_PREFIXE."om_etat |
5726 |
WHERE om_etat.id = '".$f->get_submitted_post_value("bordereau")."'"; |
WHERE om_etat.id = '".$this->f->get_submitted_post_value("bordereau")."'"; |
5727 |
$res = $f->db->getone($sql); |
$res = $this->f->db->getone($sql); |
5728 |
$f->addToLog(__METHOD__.": db->getone(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->getone(\"".$sql."\")", VERBOSE_MODE); |
5729 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
5730 |
// |
// |
5731 |
$message_class = "valid"; |
$message_class = "valid"; |
5732 |
$message = _("Cliquez sur le lien ci-dessous pour telecharger votre bordereau"); |
$message = _("Cliquez sur le lien ci-dessous pour telecharger votre bordereau"); |
5733 |
$message .= " : <br/><br/>"; |
$message .= " : <br/><br/>"; |
5734 |
$message .= "<a class='om-prev-icon pdf-16'"; |
$message .= "<a class='om-prev-icon pdf-16'"; |
5735 |
$message .= " title=\""._("Bordereau")."\""; |
$message .= " title=\""._("Bordereau")."\""; |
5736 |
$message .= "href='../scr/form.php?obj=instruction"; |
$message .= "href='".OM_ROUTE_FORM."&obj=instruction"; |
5737 |
$message .= "&action=220"; |
$message .= "&action=220"; |
5738 |
$message .= "&idx=0"; |
$message .= "&idx=0"; |
5739 |
$message .= "&type_bordereau=".$f->get_submitted_post_value("bordereau"); |
$message .= "&type_bordereau=".$this->f->get_submitted_post_value("bordereau"); |
5740 |
$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"); |
5741 |
$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"); |
5742 |
// Si l'utilisateur est MULTI alors on ajoute le paramètre collectivite |
// Si l'utilisateur est MULTI alors on ajoute le paramètre collectivite |
5743 |
if ($f->get_submitted_post_value("om_collectivite") !== null) { |
if ($this->f->get_submitted_post_value("om_collectivite") !== null) { |
5744 |
$message .= "&collectivite=".$f->get_submitted_post_value("om_collectivite"); |
$message .= "&collectivite=".$this->f->get_submitted_post_value("om_collectivite"); |
5745 |
} |
} |
5746 |
$message .= "'"." target='_blank'>"; |
$message .= "'"." target='_blank'>"; |
5747 |
$message .= $res." "._("du")." ".$f->get_submitted_post_value("date_bordereau_debut") |
$message .= $res." "._("du")." ".$this->f->get_submitted_post_value("date_bordereau_debut") |
5748 |
." "._("au")." ".$f->get_submitted_post_value("date_bordereau_fin"); |
." "._("au")." ".$this->f->get_submitted_post_value("date_bordereau_fin"); |
5749 |
$message .= "</a>"; |
$message .= "</a>"; |
5750 |
} |
} |
5751 |
} |
} |
5755 |
*/ |
*/ |
5756 |
// Affichage du message de validation ou d'erreur |
// Affichage du message de validation ou d'erreur |
5757 |
if (isset($message) && isset($message_class) && $message != "") { |
if (isset($message) && isset($message_class) && $message != "") { |
5758 |
$f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
5759 |
} |
} |
|
// Inclusion de la classe de gestion des formulaires |
|
|
require_once "../obj/om_formulaire.class.php"; |
|
5760 |
// Ouverture du formulaire |
// Ouverture du formulaire |
5761 |
printf("\t<form"); |
printf("\t<form"); |
5762 |
printf(" method=\"post\""); |
printf(" method=\"post\""); |
5765 |
printf(">\n"); |
printf(">\n"); |
5766 |
// Paramétrage des champs du formulaire |
// Paramétrage des champs du formulaire |
5767 |
$champs = array("date_bordereau_debut", "date_bordereau_fin", "bordereau"); |
$champs = array("date_bordereau_debut", "date_bordereau_fin", "bordereau"); |
5768 |
// 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 |
5769 |
// collectivité dans le formulaire |
// collectivité dans le formulaire |
5770 |
if($_SESSION["niveau"] == 2) { |
if ($_SESSION["niveau"] == 2) { |
5771 |
array_push($champs, "om_collectivite"); |
array_push($champs, "om_collectivite"); |
5772 |
} |
} |
5773 |
// Création d'un nouvel objet de type formulaire |
// Création d'un nouvel objet de type formulaire |
5774 |
$form = new formulaire(NULL, 0, 0, $champs); |
$form = $this->f->get_inst__om_formulaire(array( |
5775 |
|
"validation" => 0, |
5776 |
|
"maj" => 0, |
5777 |
|
"champs" => $champs, |
5778 |
|
)); |
5779 |
// Paramétrage du champ date_bordereau_debut |
// Paramétrage du champ date_bordereau_debut |
5780 |
$form->setLib("date_bordereau_debut", _("date_bordereau_debut")); |
$form->setLib("date_bordereau_debut", _("date_bordereau_debut")); |
5781 |
$form->setType("date_bordereau_debut", "date"); |
$form->setType("date_bordereau_debut", "date"); |
5797 |
$form->setType("bordereau", "select"); |
$form->setType("bordereau", "select"); |
5798 |
$form->setRequired("bordereau"); |
$form->setRequired("bordereau"); |
5799 |
// Valeurs des champs |
// Valeurs des champs |
5800 |
if ($f->get_submitted_post_value("validation") !== null) { |
if ($this->f->get_submitted_post_value("validation") !== null) { |
5801 |
$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")); |
5802 |
$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")); |
5803 |
$form->setVal("bordereau", $f->get_submitted_post_value("bordereau")); |
$form->setVal("bordereau", $this->f->get_submitted_post_value("bordereau")); |
5804 |
$form->setVal("om_collectivite", $f->get_submitted_post_value("om_collectivite")); |
$form->setVal("om_collectivite", $this->f->get_submitted_post_value("om_collectivite")); |
5805 |
} |
} |
5806 |
// 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 |
5807 |
// 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 |
5810 |
FROM ".DB_PREFIXE."om_etat |
FROM ".DB_PREFIXE."om_etat |
5811 |
WHERE om_etat.id LIKE 'bordereau_%' |
WHERE om_etat.id LIKE 'bordereau_%' |
5812 |
ORDER BY om_etat.id"; |
ORDER BY om_etat.id"; |
5813 |
$res = $f->db->query($sql); |
$res = $this->f->db->query($sql); |
5814 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
5815 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
5816 |
// Données du select |
// Données du select |
5817 |
$contenu = array( |
$contenu = array( |
5818 |
0 => array("", ), |
0 => array("", ), |
5823 |
$contenu[1][] = $row['libelle']; |
$contenu[1][] = $row['libelle']; |
5824 |
} |
} |
5825 |
$form->setSelect("bordereau", $contenu); |
$form->setSelect("bordereau", $contenu); |
5826 |
// |
// |
5827 |
if($_SESSION["niveau"] == 2) { |
if ($_SESSION["niveau"] == 2) { |
5828 |
$form->setLib("om_collectivite", _("collectivite")); |
$form->setLib("om_collectivite", _("collectivite")); |
5829 |
$form->setType("om_collectivite", "select"); |
$form->setType("om_collectivite", "select"); |
5830 |
|
|
5831 |
// 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 |
5832 |
// de niveau 1 |
// de niveau 1 |
5833 |
$sql = "SELECT om_collectivite, libelle |
$sql = "SELECT om_collectivite, libelle |
5834 |
FROM ".DB_PREFIXE."om_collectivite |
FROM ".DB_PREFIXE."om_collectivite |
5835 |
WHERE niveau = '1' ORDER BY libelle"; |
WHERE niveau = '1' ORDER BY libelle"; |
5836 |
$res = $f->db->query($sql); |
$res = $this->f->db->query($sql); |
5837 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
5838 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
5839 |
// La valeur par défaut du select est Toutes |
// La valeur par défaut du select est Toutes |
5840 |
$list_collectivites = array( |
$list_collectivites = array( |
5841 |
0 => array("", ), |
0 => array("", ), |
5842 |
1 => array(_("toutes")) |
1 => array(_("toutes")) |
5843 |
); |
); |
|
|
|
|
$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); |
|
|
} |
|
5844 |
|
|
5845 |
|
$id_colls = ""; |
5846 |
|
// On stocke dans $id_colls l'id de toutes les collectivités de niveau 1 séparées |
5847 |
|
// par des virgules, pour un traitement plus facile dans la requête de sous-état |
5848 |
|
while ($row =& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
5849 |
|
if ($id_colls != "") { |
5850 |
|
$id_colls .= ","; |
5851 |
|
} |
5852 |
|
$id_colls .= $row['om_collectivite']; |
5853 |
|
$list_collectivites[0][] = $row['om_collectivite']; |
5854 |
|
$list_collectivites[1][] = $row['libelle']; |
5855 |
|
} |
5856 |
|
// On affecte la liste d'identifiants à l'option Toutes |
5857 |
|
$list_collectivites[0][0] = $id_colls ; |
5858 |
|
$form->setSelect("om_collectivite", $list_collectivites); |
5859 |
|
} |
5860 |
// Affichage du formulaire |
// Affichage du formulaire |
5861 |
$form->entete(); |
$form->entete(); |
5862 |
$form->afficher($champs, 0, false, false); |
$form->afficher($champs, 0, false, false); |
5863 |
$form->enpied(); |
$form->enpied(); |
5864 |
// Affichage du bouton |
// Affichage du bouton |
5865 |
printf("\t<div class=\"formControls\">\n"); |
printf("\t<div class=\"formControls\">\n"); |
5866 |
$f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
$this->f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
5867 |
printf("\t</div>\n"); |
printf("\t</div>\n"); |
5868 |
// Fermeture du formulaire |
// Fermeture du formulaire |
5869 |
printf("\t</form>\n"); |
printf("\t</form>\n"); |
|
|
|
5870 |
} |
} |
5871 |
|
|
5872 |
|
|
5895 |
/** |
/** |
5896 |
* VIEW - view_suivi_envoi_lettre_rar. |
* VIEW - view_suivi_envoi_lettre_rar. |
5897 |
* |
* |
5898 |
* Vu pour imprimer les RAR. |
* Vue pour imprimer les AR. |
5899 |
* |
* |
5900 |
* @return void |
* @return void |
5901 |
*/ |
*/ |
5903 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
5904 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
5905 |
|
|
|
// XXX APP |
|
|
|
|
|
$f = $this->f; |
|
|
|
|
5906 |
// |
// |
5907 |
if ($f->get_submitted_post_value("date") !== null) { |
if ($this->f->get_submitted_post_value("date") !== null) { |
5908 |
$date = $f->get_submitted_post_value("date"); |
$date = $this->f->get_submitted_post_value("date"); |
5909 |
} else { |
} else { |
5910 |
$date = ""; |
$date = ""; |
5911 |
} |
} |
5912 |
// |
// |
5913 |
if ($f->get_submitted_post_value("liste_code_barres_instruction") !== null) { |
if ($this->f->get_submitted_post_value("liste_code_barres_instruction") !== null) { |
5914 |
$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"); |
5915 |
} else { |
} else { |
5916 |
$liste_code_barres_instruction = ""; |
$liste_code_barres_instruction = ""; |
5917 |
} |
} |
5937 |
* Validation du formulaire |
* Validation du formulaire |
5938 |
*/ |
*/ |
5939 |
// Si le formulaire a été validé |
// Si le formulaire a été validé |
5940 |
if ($f->get_submitted_post_value('validation') !== null) { |
if ($this->f->get_submitted_post_value('validation') !== null) { |
5941 |
// |
// |
5942 |
if (empty($date) || empty($liste_code_barres_instruction)) { |
if (empty($date) || empty($liste_code_barres_instruction)) { |
5943 |
// |
// |
5945 |
$message = _("Tous les champs doivent etre remplis."); |
$message = _("Tous les champs doivent etre remplis."); |
5946 |
} else { |
} else { |
5947 |
// Création d'un tableau d'instruction |
// Création d'un tableau d'instruction |
5948 |
$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")); |
5949 |
// |
// |
5950 |
foreach ($liste as $code_barres) { |
foreach ($liste as $code_barres) { |
5951 |
// On enlève les éventuels espaces saisis |
// On enlève les éventuels espaces saisis |
5967 |
ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
5968 |
INNER JOIN ".DB_PREFIXE."groupe |
INNER JOIN ".DB_PREFIXE."groupe |
5969 |
ON dossier_autorisation_type.groupe = groupe.groupe |
ON dossier_autorisation_type.groupe = groupe.groupe |
|
AND groupe.code != 'CTX' |
|
5970 |
WHERE code_barres='".$this->f->db->escapesimple($code_barres)."'"; |
WHERE code_barres='".$this->f->db->escapesimple($code_barres)."'"; |
5971 |
$nbInstr = $f->db->getone($sql); |
|
5972 |
$f->addToLog(__METHOD__.": db->getone(\"".$sql."\")", VERBOSE_MODE); |
// Ajout d'un filtre sur les groupes auxquels l'utilisateur a accès |
5973 |
$f->isDatabaseError($nbInstr); |
$group_clause = array(); |
5974 |
|
foreach ($_SESSION["groupe"] as $key => $value) { |
5975 |
|
$group_clause[$key] = "(groupe.code = '".$key."'"; |
5976 |
|
if($value["confidentiel"] !== true) { |
5977 |
|
$group_clause[$key] .= " AND dossier_autorisation_type.confidentiel IS NOT TRUE"; |
5978 |
|
} |
5979 |
|
$group_clause[$key] .= ")"; |
5980 |
|
} |
5981 |
|
$conditions = implode(" OR ", $group_clause); |
5982 |
|
$sql .= " AND (" . $conditions . ")"; |
5983 |
|
|
5984 |
|
$nbInstr = $this->f->db->getone($sql); |
5985 |
|
$this->f->addToLog(__METHOD__.": db->getone(\"".$sql."\")", VERBOSE_MODE); |
5986 |
|
$this->f->isDatabaseError($nbInstr); |
5987 |
// |
// |
5988 |
if ($nbInstr == "1") { |
if ($nbInstr == "1") { |
5989 |
// Récupération de la date d'envoi de l'instruction bippé |
// Récupération de la date d'envoi de l'instruction bippé |
5990 |
$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."'"; |
5991 |
$res = $f->db->query($sql); |
$res = $this->f->db->query($sql); |
5992 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
5993 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
5994 |
$row =& $res->fetchRow(DB_FETCHMODE_ASSOC); |
$row =& $res->fetchRow(DB_FETCHMODE_ASSOC); |
5995 |
// Si pas de date ou correspond à la date du formulaire on |
// Si pas de date ou correspond à la date du formulaire on |
5996 |
// effectue le traitement |
// effectue le traitement |
5997 |
if ($row["date_envoi_rar"] == "" || $row["date_envoi_rar"] == $date) { |
if ($row["date_envoi_rar"] == "" || $row["date_envoi_rar"] == $date) { |
5998 |
|
$instr = $this->f->get_inst__om_dbform(array( |
5999 |
require_once '../obj/instruction.class.php'; |
"obj" => "instruction", |
6000 |
require_once '../obj/dossier.class.php'; |
"idx" => $row['instruction'], |
6001 |
|
)); |
|
$instr = new instruction($row['instruction'], $f->db, DEBUG); |
|
6002 |
$valF = array(); |
$valF = array(); |
6003 |
foreach($instr->champs as $id => $champ) { |
foreach($instr->champs as $id => $champ) { |
6004 |
$valF[$champ] = $instr->val[$id]; |
$valF[$champ] = $instr->val[$id]; |
6007 |
# 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 |
6008 |
if ($isAccredited === true |
if ($isAccredited === true |
6009 |
&& array_key_exists($instr->getVal("dossier"), $dossierTab) === false) { |
&& array_key_exists($instr->getVal("dossier"), $dossierTab) === false) { |
6010 |
$dossier = new dossier($instr->getVal("dossier")); |
$dossier = $this->f->get_inst__om_dbform(array( |
6011 |
|
"obj" => "dossier", |
6012 |
|
"idx" => $instr->getVal("dossier"), |
6013 |
|
)); |
6014 |
if ($dossier->is_user_from_allowed_collectivite()){ |
if ($dossier->is_user_from_allowed_collectivite()){ |
6015 |
$dossierTab[$instr->getVal("dossier")] = $dossier; |
$dossierTab[$instr->getVal("dossier")] = $dossier; |
6016 |
} else { |
} else { |
6064 |
$instr->setParameter('maj', 1); |
$instr->setParameter('maj', 1); |
6065 |
$instr->class_actions[1]["identifier"] = |
$instr->class_actions[1]["identifier"] = |
6066 |
"envoi lettre RAR (depuis le menu suivi des pièces)"; |
"envoi lettre RAR (depuis le menu suivi des pièces)"; |
6067 |
if ($instr->modifier($valF, $f->db, DEBUG) == true) { |
if ($instr->modifier($valF) == true) { |
6068 |
$id4Gen[] = $code_barres; |
$id4Gen[] = $code_barres; |
6069 |
$nbLettres ++; |
$nbLettres ++; |
6070 |
} else { |
} else { |
6119 |
*/ |
*/ |
6120 |
// Affichage du message de validation ou d'erreur |
// Affichage du message de validation ou d'erreur |
6121 |
if (isset($message) && isset($message_class) && $message != "") { |
if (isset($message) && isset($message_class) && $message != "") { |
6122 |
$f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
6123 |
} |
} |
6124 |
// Affichage du message d'erreur |
// Affichage du message d'erreur |
6125 |
if(!empty($error)) { |
if(!empty($error)) { |
6126 |
$f->displayMessage("error", $error); |
$this->f->displayMessage("error", $error); |
6127 |
} |
} |
6128 |
// Affichage du message de validation de la saisie |
// Affichage du message de validation de la saisie |
6129 |
if ($nbLettres > 0) { |
if ($nbLettres > 0) { |
6135 |
echo _("Cliquez sur le lien ci-dessous pour telecharger votre document"); |
echo _("Cliquez sur le lien ci-dessous pour telecharger votre document"); |
6136 |
echo " : \n<br/><br/>"; |
echo " : \n<br/><br/>"; |
6137 |
echo "\n<a class='om-prev-icon pdf-16'"; |
echo "\n<a class='om-prev-icon pdf-16'"; |
6138 |
echo "\n title=\""._("imprimer les RAR")."\""; |
echo "\n title=\""._("imprimer les AR")."\""; |
6139 |
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)."\""; |
6140 |
echo "\n target='_blank'>"; |
echo "\n target='_blank'>"; |
6141 |
echo _("Telecharger le document pour")." ".$nbLettres." "._("RAR"); |
echo _("Telecharger le document pour")." ".$nbLettres." "._("AR"); |
6142 |
echo "\n</a>"; |
echo "\n</a>"; |
6143 |
echo "\n</span>"; |
echo "\n</span>"; |
6144 |
echo "\n</p>"; |
echo "\n</p>"; |
6160 |
echo "\n<br/>"; |
echo "\n<br/>"; |
6161 |
} |
} |
6162 |
foreach ($dossierTab as $dossier) { |
foreach ($dossierTab as $dossier) { |
6163 |
|
|
6164 |
|
$inst_da = $this->get_inst_common("dossier_autorisation", $dossier->getVal('dossier_autorisation')); |
6165 |
|
$inst_datd = $this->get_inst_common("dossier_autorisation_type_detaille", $inst_da->getVal('dossier_autorisation_type_detaille')); |
6166 |
|
$code_datd = $inst_datd->getVal('code'); |
6167 |
|
|
6168 |
|
$obj = "dossier_instruction"; |
6169 |
|
if ($code_datd === 'REC' OR $code_datd === 'REG') { |
6170 |
|
$obj = "dossier_contentieux_tous_recours"; |
6171 |
|
} |
6172 |
|
if ($code_datd === 'IN') { |
6173 |
|
$obj = "dossier_contentieux_toutes_infractions"; |
6174 |
|
} |
6175 |
|
|
6176 |
echo "\n<div class=\"bloc group\">"; |
echo "\n<div class=\"bloc group\">"; |
6177 |
echo "\n<div class=\"field field-type-text\">"; |
echo "\n<div class=\"field field-type-text\">"; |
6178 |
|
|
6179 |
echo "\n<p>"; |
echo "\n<p>"; |
6180 |
echo "\n<span class='text'>"; |
echo "\n<span class='text'>"; |
6181 |
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') . "\""; |
6182 |
echo "\n href=\"../scr/form.php?obj=dossier_instruction&action=3&idx="; |
echo "\n href=\"".OM_ROUTE_FORM."&obj=dossier_instruction&action=3&idx="; |
6183 |
echo $dossier->getVal("dossier"); |
echo $dossier->getVal("dossier"); |
6184 |
echo "\">"; |
echo "\">"; |
6185 |
echo "\n</a>"; |
echo "\n</a>"; |
6186 |
|
|
6187 |
echo "\n<a title=\""._("Consulter")."\" style=\"vertical-align:middle;\""; |
echo "\n<a title=\""._("Consulter")."\" style=\"vertical-align:middle;\""; |
6188 |
echo " href=\"../scr/form.php?obj=dossier_instruction&action=3&idx="; |
echo " href=\"".OM_ROUTE_FORM."&obj="; |
6189 |
|
echo $obj; |
6190 |
|
echo "&action=3&idx="; |
6191 |
echo $dossier->getVal("dossier"); |
echo $dossier->getVal("dossier"); |
6192 |
echo "\">"; |
echo "\">"; |
6193 |
echo $dossier->getVal("dossier_libelle"); |
echo $dossier->getVal("dossier_libelle"); |
6204 |
echo "\n</div>"; |
echo "\n</div>"; |
6205 |
echo "\n</div>"; |
echo "\n</div>"; |
6206 |
} |
} |
|
// Inclusion de la classe de gestion des formulaires |
|
|
require_once "../obj/om_formulaire.class.php"; |
|
6207 |
// Ouverture du formulaire |
// Ouverture du formulaire |
6208 |
echo "\t<form"; |
echo "\t<form"; |
6209 |
echo " method=\"post\""; |
echo " method=\"post\""; |
6213 |
// Paramétrage des champs du formulaire |
// Paramétrage des champs du formulaire |
6214 |
$champs = array("date", "liste_code_barres_instruction"); |
$champs = array("date", "liste_code_barres_instruction"); |
6215 |
// Création d'un nouvel objet de type formulaire |
// Création d'un nouvel objet de type formulaire |
6216 |
$form = new formulaire(NULL, 0, 0, $champs); |
$form = $this->f->get_inst__om_formulaire(array( |
6217 |
|
"validation" => 0, |
6218 |
|
"maj" => 0, |
6219 |
|
"champs" => $champs, |
6220 |
|
)); |
6221 |
// Paramétrage du champ date du formulaire |
// Paramétrage du champ date du formulaire |
6222 |
$form->setLib("date", _("Date")."* :"); |
$form->setLib("date", _("Date")."* :"); |
6223 |
$form->setType("date", "date"); |
$form->setType("date", "date"); |
6237 |
$form->enpied(); |
$form->enpied(); |
6238 |
// Affichage du bouton |
// Affichage du bouton |
6239 |
echo "\t<div class=\"formControls\">\n"; |
echo "\t<div class=\"formControls\">\n"; |
6240 |
$f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
$this->f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
6241 |
echo "\t</div>\n"; |
echo "\t</div>\n"; |
6242 |
// Fermeture du formulaire |
// Fermeture du formulaire |
6243 |
echo "\t</form>\n"; |
echo "\t</form>\n"; |
6254 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
6255 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
6256 |
|
|
|
// XXX APP |
|
|
|
|
|
$f = $this->f; |
|
|
|
|
6257 |
// Récupération des valeur passées en POST ou GET |
// Récupération des valeur passées en POST ou GET |
6258 |
if($f->get_submitted_post_value("type_mise_a_jour") !== null) { |
if($this->f->get_submitted_post_value("type_mise_a_jour") !== null) { |
6259 |
$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"); |
6260 |
} elseif($f->get_submitted_get_value('type_mise_a_jour') !== null) { |
} elseif($this->f->get_submitted_get_value('type_mise_a_jour') !== null) { |
6261 |
$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'); |
6262 |
} else { |
} else { |
6263 |
$type_mise_a_jour = ""; |
$type_mise_a_jour = ""; |
6264 |
} |
} |
6265 |
if($f->get_submitted_post_value('date') !== null) { |
if($this->f->get_submitted_post_value('date') !== null) { |
6266 |
$date = $f->get_submitted_post_value('date'); |
$date = $this->f->get_submitted_post_value('date'); |
6267 |
} elseif($f->get_submitted_get_value('date') !== null) { |
} elseif($this->f->get_submitted_get_value('date') !== null) { |
6268 |
$date = $f->get_submitted_get_value('date'); |
$date = $this->f->get_submitted_get_value('date'); |
6269 |
} else { |
} else { |
6270 |
$date = ""; |
$date = ""; |
6271 |
} |
} |
6272 |
if($f->get_submitted_post_value('code_barres') !== null) { |
if($this->f->get_submitted_post_value('code_barres') !== null) { |
6273 |
$code_barres = $f->get_submitted_post_value('code_barres'); |
$code_barres = $this->f->get_submitted_post_value('code_barres'); |
6274 |
} elseif($f->get_submitted_get_value('code_barres') !== null) { |
} elseif($this->f->get_submitted_get_value('code_barres') !== null) { |
6275 |
$code_barres = $f->get_submitted_get_value('code_barres'); |
$code_barres = $this->f->get_submitted_get_value('code_barres'); |
6276 |
} else { |
} else { |
6277 |
$code_barres = ""; |
$code_barres = ""; |
6278 |
} |
} |
6284 |
$liste_champs=array(); |
$liste_champs=array(); |
6285 |
|
|
6286 |
// Si le formulaire a été validé |
// Si le formulaire a été validé |
6287 |
if ($f->get_submitted_post_value('validation') !== null) { |
if ($this->f->get_submitted_post_value('validation') !== null) { |
6288 |
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)) { |
6289 |
|
|
6290 |
// Vérification de l'existence de l'instruction |
// Vérification de l'existence de l'instruction |
6300 |
ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
6301 |
INNER JOIN ".DB_PREFIXE."groupe |
INNER JOIN ".DB_PREFIXE."groupe |
6302 |
ON dossier_autorisation_type.groupe = groupe.groupe |
ON dossier_autorisation_type.groupe = groupe.groupe |
|
AND groupe.code != 'CTX' |
|
6303 |
WHERE code_barres='".$this->f->db->escapesimple($code_barres)."'"; |
WHERE code_barres='".$this->f->db->escapesimple($code_barres)."'"; |
6304 |
$res = $f->db->query($sql); |
|
6305 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
// Ajout d'un filtre sur les groupes auxquels l'utilisateur a accès |
6306 |
$f->isDatabaseError($res); |
$group_clause = array(); |
6307 |
|
foreach ($_SESSION["groupe"] as $key => $value) { |
6308 |
|
$group_clause[$key] = "(groupe.code = '".$key."'"; |
6309 |
|
if($value["confidentiel"] !== true) { |
6310 |
|
$group_clause[$key] .= " AND dossier_autorisation_type.confidentiel IS NOT TRUE"; |
6311 |
|
} |
6312 |
|
$group_clause[$key] .= ")"; |
6313 |
|
} |
6314 |
|
$conditions = implode(" OR ", $group_clause); |
6315 |
|
$sql .= " AND (" . $conditions . ")"; |
6316 |
|
|
6317 |
|
|
6318 |
|
$res = $this->f->db->query($sql); |
6319 |
|
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
6320 |
|
$this->f->isDatabaseError($res); |
6321 |
|
|
6322 |
if($res->numrows() == 1) { |
if($res->numrows() == 1) { |
6323 |
$liste_champs = explode(";", $type_mise_a_jour); |
$liste_champs = explode(";", $type_mise_a_jour); |
6324 |
// Mise à jour des dates après l'écran de verification |
// Mise à jour des dates après l'écran de verification |
6325 |
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'; |
|
6326 |
$row =& $res->fetchRow(DB_FETCHMODE_ASSOC); |
$row =& $res->fetchRow(DB_FETCHMODE_ASSOC); |
6327 |
$instr = new instruction($row['instruction'], $f->db, DEBUG); |
$instr = $this->f->get_inst__om_dbform(array( |
6328 |
|
"obj" => "instruction", |
6329 |
|
"idx" => $row['instruction'], |
6330 |
|
)); |
6331 |
$valF = array(); |
$valF = array(); |
6332 |
foreach($instr->champs as $id => $champ) { |
foreach($instr->champs as $id => $champ) { |
6333 |
$valF[$champ] = $instr->val[$id]; |
$valF[$champ] = $instr->val[$id]; |
6370 |
$code_barres = ""; |
$code_barres = ""; |
6371 |
|
|
6372 |
//Désactivation de l'autocommit |
//Désactivation de l'autocommit |
6373 |
$f->db->autoCommit(false); |
$this->f->db->autoCommit(false); |
6374 |
|
|
6375 |
//On modifie les valeurs de l'instruction |
//On modifie les valeurs de l'instruction |
6376 |
$instr->setParameter('maj', 170); |
$instr->setParameter('maj', 170); |
6377 |
$instr->class_actions[170]["identifier"] = |
$instr->class_actions[170]["identifier"] = |
6378 |
"mise à jour des dates (depuis le menu suivi des pièces)"; |
"mise à jour des dates (depuis le menu suivi des pièces)"; |
6379 |
$retour = $instr->modifier($valF, $f->db, DEBUG); |
$retour = $instr->modifier($valF); |
6380 |
|
|
6381 |
//Si une erreur s'est produite, on défait les modifications |
//Si une erreur s'est produite, on défait les modifications |
6382 |
//qui ont été faites |
//qui ont été faites |
6385 |
} |
} |
6386 |
//Sinon, on valide en base de données les modifications |
//Sinon, on valide en base de données les modifications |
6387 |
else { |
else { |
6388 |
$f->db->commit(); |
$this->f->db->commit(); |
6389 |
} |
} |
6390 |
|
|
6391 |
// Variable correct retourné depuis la classe instruction |
// Variable correct retourné depuis la classe instruction |
6426 |
INNER JOIN ".DB_PREFIXE."evenement ON |
INNER JOIN ".DB_PREFIXE."evenement ON |
6427 |
instruction.evenement=evenement.evenement |
instruction.evenement=evenement.evenement |
6428 |
WHERE code_barres='".$code_barres."'"; |
WHERE code_barres='".$code_barres."'"; |
6429 |
$resInfo = $f->db->query($sqlInfo); |
$resInfo = $this->f->db->query($sqlInfo); |
6430 |
$f->isDatabaseError($resInfo); |
$this->f->isDatabaseError($resInfo); |
6431 |
$infos = $resInfo->fetchRow(DB_FETCHMODE_ASSOC); |
$infos = $resInfo->fetchRow(DB_FETCHMODE_ASSOC); |
6432 |
|
|
6433 |
// Vérification de la non modification des dates de suivi |
// Vérification de la non modification des dates de suivi |
6452 |
*/ |
*/ |
6453 |
// Affichage du message de validation ou d'erreur |
// Affichage du message de validation ou d'erreur |
6454 |
if (isset($message) && isset($message_class) && $message != "") { |
if (isset($message) && isset($message_class) && $message != "") { |
6455 |
$f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
6456 |
} |
} |
6457 |
// Affichage du message d'erreur |
// Affichage du message d'erreur |
6458 |
if(!empty($error)) { |
if(!empty($error)) { |
6459 |
$f->displayMessage("error", $error); |
$this->f->displayMessage("error", $error); |
6460 |
} |
} |
6461 |
|
|
6462 |
// Affichage du message de validation de la saisie |
// Affichage du message de validation de la saisie |
6463 |
if($correct === true) { |
if($correct === true) { |
6464 |
$f->displayMessage("ok", _("Saisie enregistree")); |
$this->f->displayMessage("ok", _("Saisie enregistree")); |
6465 |
} |
} |
|
// Inclusion de la classe de gestion des formulaires |
|
|
require_once "../obj/om_formulaire.class.php"; |
|
6466 |
// Ouverture du formulaire |
// Ouverture du formulaire |
6467 |
echo "\t<form"; |
echo "\t<form"; |
6468 |
echo " method=\"post\""; |
echo " method=\"post\""; |
6480 |
$champs = array("type_mise_a_jour", "date", "code_barres"); |
$champs = array("type_mise_a_jour", "date", "code_barres"); |
6481 |
} |
} |
6482 |
// Création d'un nouvel objet de type formulaire |
// Création d'un nouvel objet de type formulaire |
6483 |
$form = new formulaire(NULL, 0, 0, $champs); |
$form = $this->f->get_inst__om_formulaire(array( |
6484 |
|
"validation" => 0, |
6485 |
|
"maj" => 0, |
6486 |
|
"champs" => $champs, |
6487 |
|
)); |
6488 |
// Paramétrage des champs du formulaire |
// Paramétrage des champs du formulaire |
6489 |
// Parametrage du champ type_mise_a_jour |
// Parametrage du champ type_mise_a_jour |
6490 |
$form->setLib("type_mise_a_jour", _("Date a mettre a jour")."* :"); |
$form->setLib("type_mise_a_jour", _("Date a mettre a jour")."* :"); |
6514 |
$contenu[1][4] = _("date de retour de controle de legalite"); |
$contenu[1][4] = _("date de retour de controle de legalite"); |
6515 |
|
|
6516 |
$contenu[0][5] = "date_retour_rar"; |
$contenu[0][5] = "date_retour_rar"; |
6517 |
$contenu[1][5] = _("date de retour de l'AR"); |
$contenu[1][5] = __("date de notification du correspondant"); |
6518 |
|
|
6519 |
$form->setSelect("type_mise_a_jour", $contenu); |
$form->setSelect("type_mise_a_jour", $contenu); |
6520 |
|
|
6574 |
$form->setType("autorite_competente", "static"); |
$form->setType("autorite_competente", "static"); |
6575 |
$form->setVal("autorite_competente", $infos['autorite_competente']); |
$form->setVal("autorite_competente", $infos['autorite_competente']); |
6576 |
|
|
6577 |
// Parametrage des libellés d'envoi avec RAR |
// Parametrage des libellés d'envoi avec AR |
6578 |
$form->setLib("date_envoi_rar", _("date_envoi_rar")." :"); |
$form->setLib("date_envoi_rar", __("date_envoi_ar")." :"); |
6579 |
$form->setLib("date_retour_rar", _("date_retour_rar")." :"); |
$form->setLib("date_retour_rar", __("date_notification")." :"); |
6580 |
|
|
6581 |
$form->setLib("date_envoi_signature", _("date_envoi_signature")." :"); |
$form->setLib("date_envoi_signature", _("date_envoi_signature")." :"); |
6582 |
$form->setLib("date_retour_signature", _("date_retour_signature")." :"); |
$form->setLib("date_retour_signature", _("date_retour_signature")." :"); |
6610 |
echo "\t<div class=\"formControls\">\n"; |
echo "\t<div class=\"formControls\">\n"; |
6611 |
// |
// |
6612 |
if(!$date_error) { |
if(!$date_error) { |
6613 |
$f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
$this->f->layout->display_form_button(array("value" => _("Valider"), "name" => "validation")); |
6614 |
} |
} |
6615 |
// Si pas sur l'écran de validation |
// Si pas sur l'écran de validation |
6616 |
if(isset($infos)) { |
if(isset($infos)) { |
6617 |
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"; |
6618 |
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; |
6619 |
echo "\">Retour</a>"; |
echo "\">Retour</a>"; |
6620 |
} |
} |
6631 |
function view_pdf_lettre_rar() { |
function view_pdf_lettre_rar() { |
6632 |
// Vérification de l'accessibilité sur l'élément |
// Vérification de l'accessibilité sur l'élément |
6633 |
$this->checkAccessibility(); |
$this->checkAccessibility(); |
6634 |
|
// |
6635 |
|
$this->f->disableLog(); |
6636 |
|
|
6637 |
// XXX APP |
if($this->f->get_submitted_get_value('liste') != null) { |
6638 |
|
$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')); |
|
6639 |
|
|
6640 |
// Classe permettant la mise en page de l'édition pdf |
// Classe permettant la mise en page de l'édition pdf |
6641 |
require_once "../obj/pdf_lettre_rar.class.php"; |
require_once "../obj/pdf_lettre_rar.class.php"; |
6642 |
$pdf_lettre_rar = new pdf_lettre_rar('P', 'mm', 'A4'); |
$pdf_lettre_rar = new pdf_lettre_rar('P', 'mm', 'A4'); |
6643 |
// Initialisation de la mise en page |
// Initialisation de la mise en page |
6644 |
$pdf_lettre_rar->init($f); |
$pdf_lettre_rar->init($this->f); |
6645 |
|
|
6646 |
foreach ($listeCodeBarres as $code_barres) { |
foreach ($listeCodeBarres as $code_barres) { |
6647 |
|
|
6648 |
|
// On récupère le dossier |
6649 |
|
$sql = "SELECT dossier |
6650 |
|
FROM " . DB_PREFIXE . "instruction |
6651 |
|
WHERE code_barres = '" . $code_barres . "'"; |
6652 |
|
$dossier = $this->f->db->getOne($sql); |
6653 |
|
$this->f->addToLog(__METHOD__."(): db->getOne(\"".$sql."\")", VERBOSE_MODE); |
6654 |
|
$this->f->isDatabaseError($dossier); |
6655 |
|
$inst_dossier = $this->f->get_inst__om_dbform(array( |
6656 |
|
"obj" => "dossier", |
6657 |
|
"idx" => $dossier, |
6658 |
|
)); |
6659 |
|
|
6660 |
|
// En fonction du type de dossier, on récupère un demandeur différent dans les requêtes |
6661 |
|
$groupe = $inst_dossier->get_type_affichage_formulaire(); |
6662 |
|
switch ($groupe) { |
6663 |
|
case 'CTX IN': |
6664 |
|
$sql_demandeur = "(lien_dossier_demandeur.petitionnaire_principal IS TRUE AND demandeur.type_demandeur='plaignant')"; |
6665 |
|
break; |
6666 |
|
case 'CTX RE': |
6667 |
|
$sql_demandeur = "(lien_dossier_demandeur.petitionnaire_principal IS TRUE AND demandeur.type_demandeur='requerant')"; |
6668 |
|
break; |
6669 |
|
case 'ADS': |
6670 |
|
case 'DPC': |
6671 |
|
case 'CONSULTATION ENTRANTE': |
6672 |
|
default: |
6673 |
|
$sql_demandeur = "((lien_dossier_demandeur.petitionnaire_principal IS TRUE AND demandeur.type_demandeur='petitionnaire') OR demandeur.type_demandeur='delegataire')"; |
6674 |
|
break; |
6675 |
|
} |
6676 |
|
|
6677 |
// Test si l'evenement est de type arrete et si un délégataire a été nommé |
// Test si l'evenement est de type arrete et si un délégataire a été nommé |
6678 |
$sql = "SELECT |
$sql = "SELECT |
6679 |
dossier.dossier_libelle, |
dossier.dossier_libelle, |
6699 |
inner join ".DB_PREFIXE."demandeur on |
inner join ".DB_PREFIXE."demandeur on |
6700 |
demandeur.demandeur=lien_dossier_demandeur.demandeur |
demandeur.demandeur=lien_dossier_demandeur.demandeur |
6701 |
WHERE code_barres='".$code_barres."' |
WHERE code_barres='".$code_barres."' |
6702 |
AND ((lien_dossier_demandeur.petitionnaire_principal IS TRUE AND demandeur.type_demandeur='petitionnaire') |
AND " . $sql_demandeur . " |
|
OR demandeur.type_demandeur='delegataire') |
|
6703 |
GROUP BY dossier.dossier_libelle, evenement.type, phase.code, division.libelle"; |
GROUP BY dossier.dossier_libelle, evenement.type, phase.code, division.libelle"; |
6704 |
|
|
6705 |
$res = $f->db->query($sql); |
$res = $this->f->db->query($sql); |
6706 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
6707 |
$f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
6708 |
$testDemandeur = $res->fetchrow(DB_FETCHMODE_ASSOC); |
$testDemandeur = $res->fetchrow(DB_FETCHMODE_ASSOC); |
6709 |
|
|
6710 |
|
|
6753 |
if($testDemandeur['type'] != 'arrete' AND $testDemandeur['nbdemandeur'] > 1) { |
if($testDemandeur['type'] != 'arrete' AND $testDemandeur['nbdemandeur'] > 1) { |
6754 |
$sqlAdresse .= " AND demandeur.type_demandeur='delegataire'"; |
$sqlAdresse .= " AND demandeur.type_demandeur='delegataire'"; |
6755 |
} else { |
} else { |
6756 |
$sqlAdresse .= " AND lien_dossier_demandeur.petitionnaire_principal IS TRUE AND demandeur.type_demandeur='petitionnaire'"; |
$sqlAdresse .= " AND demandeur.type_demandeur='petitionnaire' AND lien_dossier_demandeur.petitionnaire_principal IS TRUE"; |
6757 |
} |
} |
6758 |
|
|
6759 |
$resAdresse = $f->db->query($sqlAdresse); |
$resAdresse = $this->f->db->query($sqlAdresse); |
6760 |
$adresse_dest = $resAdresse->fetchrow(DB_FETCHMODE_ASSOC); |
$adresse_dest = $resAdresse->fetchrow(DB_FETCHMODE_ASSOC); |
6761 |
$f->addToLog(__METHOD__.": db->query(\"".$sqlAdresse."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__.": db->query(\"".$sqlAdresse."\")", VERBOSE_MODE); |
6762 |
$f->isDatabaseError($resAdresse); |
$this->f->isDatabaseError($resAdresse); |
6763 |
|
|
6764 |
// Création adresse destinataire sans ligne vide |
// Création adresse destinataire sans ligne vide |
6765 |
$adresse_destinataire = array(); |
$adresse_destinataire = array(); |
6789 |
$specifique_content[] = $testDemandeur['dossier_libelle']; |
$specifique_content[] = $testDemandeur['dossier_libelle']; |
6790 |
$specifique_content[] = "|||||".$adresse_dest['code_barres']."|||||"; |
$specifique_content[] = "|||||".$adresse_dest['code_barres']."|||||"; |
6791 |
unset($adresse_dest['code_barres']); |
unset($adresse_dest['code_barres']); |
|
|
|
6792 |
// Ajout d'une page aux pdf |
// Ajout d'une page aux pdf |
6793 |
$pdf_lettre_rar->addLetter($adresse_destinataire, $specifique_content, $testDemandeur['code_phase']); |
$pdf_lettre_rar->addLetter($adresse_destinataire, $specifique_content, $testDemandeur['code_phase']); |
6794 |
|
|
6795 |
} |
} |
6796 |
$pdf_output = $pdf_lettre_rar->output("lettre_rar".date("dmYHis").".pdf","S"); |
$pdf_output = $pdf_lettre_rar->output("lettre_rar".date("dmYHis").".pdf","S"); |
6797 |
require_once PATH_OPENMAIRIE."om_edition.class.php"; |
$om_edition = $this->f->get_inst__om_edition(); |
|
$om_edition = new edition(); |
|
6798 |
$om_edition->expose_pdf_output($pdf_output, "lettre_rar".date("dmYHis").".pdf"); |
$om_edition->expose_pdf_output($pdf_output, "lettre_rar".date("dmYHis").".pdf"); |
6799 |
} |
} |
6800 |
} |
} |
6857 |
$message .= "<a class='om-prev-icon pdf-16'"; |
$message .= "<a class='om-prev-icon pdf-16'"; |
6858 |
$message .= " id=\"generer_bordereau_envoi_maire\""; |
$message .= " id=\"generer_bordereau_envoi_maire\""; |
6859 |
$message .= " title=\""._("Bordereau")."\""; |
$message .= " title=\""._("Bordereau")."\""; |
6860 |
$message .= " href='../scr/form.php?obj=instruction"; |
$message .= " href='".OM_ROUTE_FORM."&obj=instruction"; |
6861 |
$message .= "&action=200"; |
$message .= "&action=200"; |
6862 |
$message .= "&idx=".$id_instruction."'"; |
$message .= "&idx=".$id_instruction."'"; |
6863 |
$message .= " target='_blank'>"; |
$message .= " target='_blank'>"; |
6898 |
$this->f->displayMessage($message_class, $message); |
$this->f->displayMessage($message_class, $message); |
6899 |
} |
} |
6900 |
|
|
|
// Inclusion de la classe de gestion des formulaires |
|
|
require_once "../obj/om_formulaire.class.php"; |
|
6901 |
// Ouverture du formulaire |
// Ouverture du formulaire |
6902 |
$datasubmit = $this->getDataSubmit(); |
$datasubmit = $this->getDataSubmit(); |
6903 |
echo "\n<!-- ########## START DBFORM ########## -->\n"; |
echo "\n<!-- ########## START DBFORM ########## -->\n"; |
6914 |
$champs = array("code_barres","date"); |
$champs = array("code_barres","date"); |
6915 |
|
|
6916 |
// Création d'un nouvel objet de type formulaire |
// Création d'un nouvel objet de type formulaire |
6917 |
$form = new formulaire(NULL, 0, 0, $champs); |
$form = $this->f->get_inst__om_formulaire(array( |
6918 |
|
"validation" => 0, |
6919 |
|
"maj" => 0, |
6920 |
|
"champs" => $champs, |
6921 |
|
)); |
6922 |
|
|
6923 |
$template_required_label = '%s *'; |
$template_required_label = '%s *'; |
6924 |
// Parametrage du champ code_barres |
// Parametrage du champ code_barres |
6977 |
} |
} |
6978 |
|
|
6979 |
/** |
/** |
6980 |
|
* VIEW - view_rapport_instruction. |
6981 |
|
* |
6982 |
|
* Ouvre le sous-formulaire en ajaxIt dans un overlay. |
6983 |
|
* Cette action est bindée pour utiliser la fonction popUpIt. |
6984 |
|
* |
6985 |
|
* @return void |
6986 |
|
*/ |
6987 |
|
function view_overlay_notification_manuelle() { |
6988 |
|
|
6989 |
|
// Vérification de l'accessibilité sur l'élément |
6990 |
|
$this->checkAccessibility(); |
6991 |
|
|
6992 |
|
printf( |
6993 |
|
'<script type="text/javascript" > |
6994 |
|
overlayIt(\'%1$s\',\'%2$s&objsf=%1$s&idxformulaire=%4$s&retourformulaire=dossier_instruction&obj=%1$s&action=411&idx=%3$s\', 1); |
6995 |
|
</script>', |
6996 |
|
'instruction_notification_manuelle', |
6997 |
|
OM_ROUTE_SOUSFORM, |
6998 |
|
$this->getVal($this->clePrimaire), |
6999 |
|
$this->getVal('dossier') |
7000 |
|
); |
7001 |
|
} |
7002 |
|
|
7003 |
|
/** |
7004 |
* 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 |
7005 |
* pour exclure les dossiers du groupe contentieux. |
* pour exclure les dossiers du groupe contentieux. |
7006 |
* |
* |
7048 |
// Begin |
// Begin |
7049 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
7050 |
// Requête |
// Requête |
7051 |
$res = $this->db->autoExecute( |
$res = $this->f->db->autoExecute( |
7052 |
DB_PREFIXE.$this->table, |
DB_PREFIXE.$this->table, |
7053 |
$valF, |
$valF, |
7054 |
DB_AUTOQUERY_UPDATE, |
DB_AUTOQUERY_UPDATE, |
7067 |
* validation du formulaire d'ajout. |
* validation du formulaire d'ajout. |
7068 |
* @param array $val tableau des valeurs retournées par le formulaire |
* @param array $val tableau des valeurs retournées par le formulaire |
7069 |
*/ |
*/ |
7070 |
function setValFAjout($val) { |
function setValFAjout($val = array()) { |
7071 |
// Mise à jour du flag created_by_commune lors d'un changement de décision |
// Mise à jour du flag created_by_commune lors d'un changement de décision |
7072 |
// par un utilisateur de commune sur un dossier instruit par la comcom |
// par un utilisateur de commune sur un dossier instruit par la comcom |
7073 |
if ($this->isInstrCanChangeDecision($this->valF["dossier"])) { |
if ($this->isInstrCanChangeDecision($this->valF["dossier"])) { |
7074 |
$this->valF['created_by_commune'] = true; |
$this->valF['created_by_commune'] = true; |
7075 |
} |
} |
7076 |
|
|
7077 |
|
// |
7078 |
|
if ($this->evenement_has_an_edition($this->valF['evenement']) === false) { |
7079 |
|
if (isset($this->valF['flag_edition_integrale']) === true) { |
7080 |
|
unset($this->valF['flag_edition_integrale']); |
7081 |
|
} |
7082 |
|
if (isset($this->valF['signataire_arrete']) === true) { |
7083 |
|
unset($this->valF['signataire_arrete']); |
7084 |
|
} |
7085 |
|
} |
7086 |
} |
} |
7087 |
|
|
7088 |
|
|
7347 |
*/ |
*/ |
7348 |
public function formater_modele($modele, $id_di, $id_inst) { |
public function formater_modele($modele, $id_di, $id_inst) { |
7349 |
// Création du lien d'accès direct à l'instruction |
// Création du lien d'accès direct à l'instruction |
7350 |
$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'. |
7351 |
'&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; |
7352 |
$url_inst = '<a href="'.$url_inst.'">'.$url_inst.'</a>'; |
$url_inst = '<a href="'.$url_inst.'">'.$url_inst.'</a>'; |
7353 |
// Remplacement des champs de fusion |
// Remplacement des champs de fusion |
7449 |
$this->f->get_submitted_get_value('idxformulaire') : $id_dossier = ""); |
$this->f->get_submitted_get_value('idxformulaire') : $id_dossier = ""); |
7450 |
// |
// |
7451 |
if ($id_dossier !== "") { |
if ($id_dossier !== "") { |
7452 |
require_once "../obj/dossier_instruction.class.php"; |
$dossier = $this->f->get_inst__om_dbform(array( |
7453 |
$dossier = new dossier_instruction($id_dossier, $f->db, DEBUG); |
"obj" => "dossier_instruction", |
7454 |
|
"idx" => $id_dossier, |
7455 |
|
)); |
7456 |
// |
// |
7457 |
return $dossier->can_user_access_dossier(); |
return $dossier->can_user_access_dossier(); |
7458 |
} |
} |
7472 |
$id_dossier = $this->getVal('dossier'); |
$id_dossier = $this->getVal('dossier'); |
7473 |
// |
// |
7474 |
if ($id_dossier !== "" && $id_dossier !== null) { |
if ($id_dossier !== "" && $id_dossier !== null) { |
7475 |
require_once "../obj/dossier_instruction.class.php"; |
$dossier = $this->f->get_inst__om_dbform(array( |
7476 |
$dossier = new dossier_instruction($id_dossier, $f->db, DEBUG); |
"obj" => "dossier_instruction", |
7477 |
|
"idx" => $id_dossier, |
7478 |
|
)); |
7479 |
// |
// |
7480 |
return $dossier->can_user_access_dossier(); |
return $dossier->can_user_access_dossier(); |
7481 |
} |
} |
7482 |
return false; |
return false; |
7483 |
} |
} |
7484 |
|
|
7485 |
}// fin classe |
/** |
7486 |
|
* TREATMENT - envoyer_a_signature_sans_relecture |
7487 |
|
* |
7488 |
|
* Permet d'envoyer le document de l'instruction au parapheur pour signature sans relecture |
7489 |
|
* |
7490 |
|
* @return boolean true si l'envoi a été effectué avec succès false sinon |
7491 |
|
*/ |
7492 |
|
function envoyer_a_signature_sans_relecture() { |
7493 |
|
return $this->envoyer_a_signature(); |
7494 |
|
} |
7495 |
|
|
7496 |
|
/** |
7497 |
|
* TREATMENT - envoyer_a_signature_avec_relecture |
7498 |
|
* |
7499 |
|
* Permet d'envoyer le document de l'instruction au parapheur pour signature avec relecture |
7500 |
|
* |
7501 |
|
* @return boolean true si l'envoi a été effectué avec succès false sinon |
7502 |
|
*/ |
7503 |
|
function envoyer_a_signature_avec_relecture() { |
7504 |
|
$is_forced_view_files = true; |
7505 |
|
return $this->envoyer_a_signature($is_forced_view_files); |
7506 |
|
} |
7507 |
|
|
7508 |
?> |
/** |
7509 |
|
* TREATMENT - envoyer_a_signature |
7510 |
|
* |
7511 |
|
* Permet d'envoyer le document de l'instruction au parapheur pour signature |
7512 |
|
* |
7513 |
|
* @param boolean $is_forced_view_files Indique si il y a une relecture (true) ou non (false) |
7514 |
|
* |
7515 |
|
* @return boolean true si l'envoi a été effectué avec succès false sinon |
7516 |
|
*/ |
7517 |
|
function envoyer_a_signature($is_forced_view_files = false) { |
7518 |
|
$this->begin_treatment(__METHOD__); |
7519 |
|
$this->correct = true; |
7520 |
|
|
7521 |
|
// Instanciation de l'objet signataire_arrete |
7522 |
|
$inst_signataire_arrete = $this->f->get_inst__om_dbform(array( |
7523 |
|
'obj' => 'signataire_arrete', |
7524 |
|
'idx' => $this->getVal('signataire_arrete'), |
7525 |
|
)); |
7526 |
|
|
7527 |
|
// Instanciation de l'objet dossier |
7528 |
|
$inst_dossier = $this->f->get_inst__om_dbform(array( |
7529 |
|
'obj' => 'dossier', |
7530 |
|
'idx' => $this->getVal('dossier'), |
7531 |
|
)); |
7532 |
|
|
7533 |
|
// Récupération du document à signer |
7534 |
|
$file = $this->f->storage->get($this->getVal('om_fichier_instruction')); |
7535 |
|
if ($file === OP_FAILURE) { |
7536 |
|
$this->correct = false; |
7537 |
|
$this->addToMessage(__("Une erreur est survenue lors de la récupération du contenu du document de l'instruction.")); |
7538 |
|
// Termine le traitement |
7539 |
|
return $this->end_treatment(__METHOD__, false); |
7540 |
|
} |
7541 |
|
|
7542 |
|
// Initialisation des paramètre à passer pour l'envoi en signature |
7543 |
|
$data = array( |
7544 |
|
"om_utilisateur_email" => $this->f->om_utilisateur['email'], |
7545 |
|
"om_utilisateur_nom" => $this->f->om_utilisateur['nom'], |
7546 |
|
"signataire_arrete_email" => $inst_signataire_arrete->getVal('email'), |
7547 |
|
"signataire_arrete_nom" => $inst_signataire_arrete->getVal('nom'), |
7548 |
|
"signataire_arrete_prenom" => $inst_signataire_arrete->getVal('prenom'), |
7549 |
|
"date_limite_instruction" => $inst_dossier->getVal('incomplet_notifie') === 't' ? $inst_dossier->getVal('date_limite_incompletude') : $inst_dossier->getVal('date_limite'), |
7550 |
|
"dossier" => $this->getVal('dossier'), |
7551 |
|
"is_forced_view_files" => $is_forced_view_files, |
7552 |
|
'commentaire_signature' => $is_forced_view_files === true ? __('relecture demandee.') : null |
7553 |
|
); |
7554 |
|
|
7555 |
|
// Initialisation des métadonnées |
7556 |
|
$metadonnee_dossier = $file['metadata']; |
7557 |
|
|
7558 |
|
$metadonnee_dossier['url_di'] = sprintf( |
7559 |
|
'%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', |
7560 |
|
PATH_BASE_URL, |
7561 |
|
$this->getVal($this->clePrimaire) |
7562 |
|
); |
7563 |
|
|
7564 |
|
$optional_data = null; |
7565 |
|
// Si il y a des paramètres supplémentaire spécifié dans le signataire alors on les récupère |
7566 |
|
if ($inst_signataire_arrete->getVal('parametre_parapheur') !== null && $inst_signataire_arrete->getVal('parametre_parapheur') !== '') { |
7567 |
|
$optional_data = json_decode($inst_signataire_arrete->getVal('parametre_parapheur'), true); |
7568 |
|
if (json_last_error() !== JSON_ERROR_NONE) { |
7569 |
|
$this->correct = false; |
7570 |
|
$this->addToMessage(__("Les paramètres supplémentaires envoyés au parapheur ne sont pas au bon format.")); |
7571 |
|
$this->addToLog(__METHOD__."(): ". |
7572 |
|
__("Erreur lors du décodage du format json des paramètres supplémentaires envoyé au parapheur. |
7573 |
|
Tableau : ").var_export($inst_signataire_arrete->getVal('parametre_parapheur'), true) |
7574 |
|
); |
7575 |
|
// Termine le traitement |
7576 |
|
return $this->end_treatment(__METHOD__, false); |
7577 |
|
} |
7578 |
|
} |
7579 |
|
|
7580 |
|
//Instanciation de la classe electronicsignature |
7581 |
|
$inst_es = $this->get_electronicsignature_instance(); |
7582 |
|
if ($inst_es === false) { |
7583 |
|
$this->correct = false; |
7584 |
|
return $this->end_treatment(__METHOD__, false); |
7585 |
|
} |
7586 |
|
|
7587 |
|
// Appel de la méthode de l'abstracteur send_for_signature() |
7588 |
|
// Cette méthode doit retourner un tableau de valeur |
7589 |
|
try { |
7590 |
|
$result = $inst_es->send_for_signature($data, $file['file_content'], $metadonnee_dossier, $optional_data); |
7591 |
|
} catch (electronicsignature_exception $e) { |
7592 |
|
$this->handle_electronicsignature_exception($e); |
7593 |
|
return $this->end_treatment(__METHOD__, false); |
7594 |
|
} |
7595 |
|
|
7596 |
|
// Après avoir reçu le résultat du parapheur, il faut mettre à jour les champs |
7597 |
|
$valF = array(); |
7598 |
|
|
7599 |
|
// Pour appeler la fonction modifier il faut traiter tous les champs de l'objet |
7600 |
|
foreach($this->champs as $identifiant => $champ) { |
7601 |
|
$valF[$champ] = $this->val[$identifiant]; |
7602 |
|
} |
7603 |
|
// On fait ensuite nos modifications spécifiques |
7604 |
|
$valF['id_parapheur_signature'] = $result['id_parapheur_signature']; |
7605 |
|
$valF['statut_signature'] = $result['statut']; |
7606 |
|
$valF['commentaire_signature'] = isset($result['commentaire_signature']) == true ? $result['commentaire_signature'] : null; |
7607 |
|
$valF['date_envoi_signature'] = date("Y-m-d", strtotime($result['date_envoi_signature'])); |
7608 |
|
$valF['historique_signature'] = $this->get_updated_historique_signature($result); |
7609 |
|
|
7610 |
|
$ret = $this->modifier($valF); |
7611 |
|
|
7612 |
|
if ($ret === false) { |
7613 |
|
$this->correct = false; |
7614 |
|
$this->addToMessage(__("Une erreur est survenue lors de la mise à jour des champs.")); |
7615 |
|
// Termine le traitement |
7616 |
|
return $this->end_treatment(__METHOD__, false); |
7617 |
|
} |
7618 |
|
|
7619 |
|
// Message |
7620 |
|
$this->addToMessage(__("Le document a été envoyé pour signature dans le parapheur.")); |
7621 |
|
if (array_key_exists('signature_page_url', $result) === true) { |
7622 |
|
$link_text = $result['signature_page_url']; |
7623 |
|
if (strlen($link_text) > 300) { |
7624 |
|
$link_text = substr($link_text, 0, 300).'…'; |
7625 |
|
} |
7626 |
|
$this->addToMessage(sprintf( |
7627 |
|
__("Lien vers la page de signature : %s"), |
7628 |
|
'<a href="'.$result['signature_page_url'].'" title="'.__("Signer le document").'" target="_blank">'.$link_text.'</a>' |
7629 |
|
)); |
7630 |
|
} |
7631 |
|
|
7632 |
|
// Tout s'est bien passé, on termine le traitement |
7633 |
|
return $this->end_treatment(__METHOD__, true); |
7634 |
|
} |
7635 |
|
|
7636 |
|
/** |
7637 |
|
* Permet de récupérer la traduction de la valeur de statut_signature |
7638 |
|
* |
7639 |
|
* @return string la valeur de statut_signature traduite | false |
7640 |
|
*/ |
7641 |
|
function get_trad_for_statut($value_to_trad){ |
7642 |
|
$statut_signature_tab = array( |
7643 |
|
'waiting' => __('en préparation'), |
7644 |
|
'in_progress' => __('en cours de signature'), |
7645 |
|
'canceled' => __('signature annulée'), |
7646 |
|
'expired' => __('délai de signature expiré'), |
7647 |
|
'finished' => __('signé') |
7648 |
|
); |
7649 |
|
if (array_key_exists($value_to_trad, $statut_signature_tab) === true) { |
7650 |
|
return $statut_signature_tab[$value_to_trad]; |
7651 |
|
} |
7652 |
|
|
7653 |
|
return false; |
7654 |
|
} |
7655 |
|
|
7656 |
|
/** |
7657 |
|
* Permet de mettre à jour le tableau json sotcké dans le champ historique_signature |
7658 |
|
* |
7659 |
|
* @return string (json) la valeur de historique_signature mis à jour | false |
7660 |
|
*/ |
7661 |
|
function get_updated_historique_signature($historique_signature_values) { |
7662 |
|
|
7663 |
|
$historique_signature_value_tab = $this->get_historique_signature_decoded(); |
7664 |
|
|
7665 |
|
if ($historique_signature_value_tab === false) { |
7666 |
|
$this->addToLog(__METHOD__."(): erreur historique signature", DEBUG_MODE); |
7667 |
|
return false; |
7668 |
|
} |
7669 |
|
|
7670 |
|
$last_val_historique_signature = array(); |
7671 |
|
|
7672 |
|
// Si la tableau récupéré n'est pas vide alors |
7673 |
|
// on récupère la dernière ligne du tableau |
7674 |
|
if (empty($historique_signature_value_tab) === false) { |
7675 |
|
$last_val_historique_signature = end($historique_signature_value_tab); |
7676 |
|
} |
7677 |
|
|
7678 |
|
$format_date = ''; |
7679 |
|
$format_date_hour = ''; |
7680 |
|
$date_converted=array(); |
7681 |
|
|
7682 |
|
$date_to_convert = array( |
7683 |
|
'date_envoi_signature' => $historique_signature_values['date_envoi_signature'], |
7684 |
|
'date_limite_instruction' => $historique_signature_values['date_limite_instruction'], |
7685 |
|
'date_retour_signature' => $historique_signature_values['date_retour_signature'] |
7686 |
|
); |
7687 |
|
|
7688 |
|
// Conversion des dates en fonction de leur format |
7689 |
|
foreach ($date_to_convert as $key => $value) { |
7690 |
|
$date_converted[$key] = null; |
7691 |
|
if ($value != null) { |
7692 |
|
$format_date = 'd/m/Y'; |
7693 |
|
$format_date_hour = 'd/m/Y H:i:s'; |
7694 |
|
$date_converted[$key] = empty(date_parse($value)['hour']) === false ? date($format_date_hour, strtotime($value)) : date($format_date, strtotime($value)); |
7695 |
|
} |
7696 |
|
} |
7697 |
|
|
7698 |
|
// Ce tableau permet de lister les colonnes de historique_signature et de les rendre traduisibles. |
7699 |
|
// Il faut en effet mettre les gettext avec l'intitulé explicite au moins |
7700 |
|
// une fois afin qu'il puisse être reconnu par le logiciel de traduction. |
7701 |
|
$tab_for_columns_trad = array( |
7702 |
|
__('entry_date'), |
7703 |
|
__('id_parapheur_signature'), |
7704 |
|
__('emetteur'), |
7705 |
|
__('signataire'), |
7706 |
|
__('date_envoi'), |
7707 |
|
__('date_limite'), |
7708 |
|
__('date_retour'), |
7709 |
|
__('statut_signature'), |
7710 |
|
__('commentaire_signature') |
7711 |
|
); |
7712 |
|
|
7713 |
|
array_push($historique_signature_value_tab, array( |
7714 |
|
'entry_date' => date('d/m/Y H:i:s'), |
7715 |
|
'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'], |
7716 |
|
'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'], |
7717 |
|
'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'], |
7718 |
|
'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'], |
7719 |
|
'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'], |
7720 |
|
'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'], |
7721 |
|
'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']), |
7722 |
|
'commentaire_signature' => isset($historique_signature_values['commentaire_signature']) === false || $historique_signature_values['commentaire_signature'] == null ? null : $historique_signature_values['commentaire_signature'], |
7723 |
|
)); |
7724 |
|
|
7725 |
|
return json_encode($historique_signature_value_tab, JSON_HEX_APOS); |
7726 |
|
} |
7727 |
|
|
7728 |
|
|
7729 |
|
/** |
7730 |
|
* Récupère le contenu du champ historique_signature et le converti en tableau |
7731 |
|
* |
7732 |
|
* @return array sinon false en cas d'erreur |
7733 |
|
*/ |
7734 |
|
protected function get_historique_signature_decoded() { |
7735 |
|
$val = $this->getVal('historique_signature'); |
7736 |
|
if ($val === '') { |
7737 |
|
$val = json_encode(array()); |
7738 |
|
} |
7739 |
|
if($this->isJson($val) === false) { |
7740 |
|
return false; |
7741 |
|
} |
7742 |
|
return json_decode($val, true); |
7743 |
|
} |
7744 |
|
|
7745 |
|
/** |
7746 |
|
* Récupère les informations à afficher dans le tableau de suivi à l'aide |
7747 |
|
* d'une requête sql. Stocke ces informations dans un tableau. |
7748 |
|
* Converti le tableau au format json et renvoi le json obtenu |
7749 |
|
* |
7750 |
|
* @return json |
7751 |
|
*/ |
7752 |
|
protected function get_json_suivi_notification() { |
7753 |
|
$valSuivi = array(); |
7754 |
|
// Liste des champs à afficher. Permet également la traduction des noms de colonnes. |
7755 |
|
$listeChampsTrad = array( |
7756 |
|
__('emetteur'), |
7757 |
|
__('date_envoi'), |
7758 |
|
__('destinataire'), |
7759 |
|
__('date_premier_acces'), |
7760 |
|
__('instruction'), |
7761 |
|
__('statut'), |
7762 |
|
__('commentaire') |
7763 |
|
); |
7764 |
|
$listeChamps = array( |
7765 |
|
'emetteur', |
7766 |
|
'date_envoi', |
7767 |
|
'destinataire', |
7768 |
|
'date_premier_acces', |
7769 |
|
'instruction', |
7770 |
|
'statut', |
7771 |
|
'commentaire' |
7772 |
|
); |
7773 |
|
|
7774 |
|
// Récupération des infos nécessaires à l'affichage du tableau |
7775 |
|
$sql = sprintf( |
7776 |
|
'SELECT |
7777 |
|
instruction_notification.instruction_notification, |
7778 |
|
CASE WHEN instruction_notification.automatique = TRUE |
7779 |
|
THEN TRIM(CONCAT(instruction_notification.emetteur, \' \', \'(automatique)\')) |
7780 |
|
ELSE instruction_notification.emetteur |
7781 |
|
END as emetteur, |
7782 |
|
date_envoi, |
7783 |
|
instruction_notification.destinataire, |
7784 |
|
instruction_notification.date_premier_acces, |
7785 |
|
evenement.libelle as instruction, |
7786 |
|
instruction_notification.statut, |
7787 |
|
instruction_notification.commentaire, |
7788 |
|
instruction_notification_document.instruction as instruction_annexe |
7789 |
|
FROM |
7790 |
|
%1$sinstruction_notification |
7791 |
|
LEFT JOIN %1$sinstruction |
7792 |
|
ON instruction.instruction = instruction_notification.instruction |
7793 |
|
LEFT JOIN %1$sevenement |
7794 |
|
ON instruction.evenement = evenement.evenement |
7795 |
|
LEFT JOIN %1$sinstruction_notification_document |
7796 |
|
ON instruction_notification.instruction_notification = instruction_notification_document.instruction_notification |
7797 |
|
AND instruction_notification_document.annexe = true |
7798 |
|
WHERE |
7799 |
|
instruction.instruction = %2$s |
7800 |
|
ORDER BY |
7801 |
|
date_envoi ASC, instruction_notification.destinataire ASC', |
7802 |
|
DB_PREFIXE, |
7803 |
|
$this->getVal('instruction') |
7804 |
|
); |
7805 |
|
$res = $this->f->db->query($sql); |
7806 |
|
$this->f->addToLog(__METHOD__."(): db->query(\"".$sql."\")", VERBOSE_MODE); |
7807 |
|
$this->f->isDatabaseError($res); |
7808 |
|
// Stockage des infos de chaque notification dans un tableau |
7809 |
|
while( $row =& $res->fetchrow(DB_FETCHMODE_ASSOC) ) { |
7810 |
|
$valNotif = array(); |
7811 |
|
foreach($listeChamps as $champ) { |
7812 |
|
$valNotif[$champ] = $row[$champ]; |
7813 |
|
if (($champ === 'date_envoi' |
7814 |
|
|| $champ === 'date_premier_acces') |
7815 |
|
&& $row[$champ] !== null |
7816 |
|
&& $row[$champ] !== '') { |
7817 |
|
// |
7818 |
|
$valNotif[$champ] = date('d/m/Y H:i:s', strtotime($row[$champ])); |
7819 |
|
} |
7820 |
|
} |
7821 |
|
if ($row['instruction_annexe'] !== null && $row['instruction_annexe'] !== '') { |
7822 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
7823 |
|
"obj" => "instruction", |
7824 |
|
"idx" => $row['instruction_annexe'], |
7825 |
|
)); |
7826 |
|
$inst_evenement = $inst_instruction->get_inst_evenement(); |
7827 |
|
$lienAnnexe = ' ('.$inst_evenement->getVal('libelle').')'; |
7828 |
|
$valNotif['instruction'] .= $lienAnnexe; |
7829 |
|
} |
7830 |
|
array_push($valSuivi, $valNotif); |
7831 |
|
} |
7832 |
|
|
7833 |
|
// Passage du tableau au format json |
7834 |
|
return json_encode($valSuivi, JSON_HEX_APOS); |
7835 |
|
} |
7836 |
|
|
7837 |
|
/** |
7838 |
|
* Traitement des erreurs retournées par l'abstracteur electronicsignature. |
7839 |
|
* |
7840 |
|
* @param electronicsignature_exception $exception Exception retournée par l'abstracteur. |
7841 |
|
* |
7842 |
|
* @return void |
7843 |
|
*/ |
7844 |
|
public function handle_electronicsignature_exception(electronicsignature_exception $exception) { |
7845 |
|
$this->f->displayMessage('error', $exception->getMessage()); |
7846 |
|
} |
7847 |
|
|
7848 |
|
|
7849 |
|
/** |
7850 |
|
* Retourne une instance du connecteur electronicsignature, et la créer si elle n'existe pas. |
7851 |
|
* |
7852 |
|
* @param boolean $with_handle_error Flag pour afficher ou non le message d'erreur à l'utilisateur. |
7853 |
|
* @return electronicsignature Instance de l'abstracteur. |
7854 |
|
*/ |
7855 |
|
public function get_electronicsignature_instance($with_handle_error = true) { |
7856 |
|
if(isset($this->electronicsignature_instance)) { |
7857 |
|
return $this->electronicsignature_instance; |
7858 |
|
} |
7859 |
|
// Instanciation du connecteur electronicsignature |
7860 |
|
try { |
7861 |
|
require_once "electronicsignature.class.php"; |
7862 |
|
$collectivites = array("collectivite_idx" => $this->get_dossier_instruction_om_collectivite(), "collectivite_multi_idx" => $this->f->get_idx_collectivite_multi()); |
7863 |
|
$this->electronicsignature_instance = new electronicsignature($collectivites); |
7864 |
|
} catch (electronicsignature_exception $e) { |
7865 |
|
if ($with_handle_error === true) { |
7866 |
|
$this->handle_electronicsignature_exception($e); |
7867 |
|
} |
7868 |
|
return false; |
7869 |
|
} |
7870 |
|
return $this->electronicsignature_instance; |
7871 |
|
} |
7872 |
|
|
7873 |
|
/** |
7874 |
|
* Retourne le lien de retour (VIEW formulaire et VIEW sousformulaire). |
7875 |
|
* |
7876 |
|
* @param string $view Appel dans le contexte de la vue 'formulaire' ou de |
7877 |
|
* la vue 'sousformulaire'. |
7878 |
|
* |
7879 |
|
* @return string |
7880 |
|
*/ |
7881 |
|
function get_back_link($view = "formulaire") { |
7882 |
|
// |
7883 |
|
$href = parent::get_back_link($view); |
7884 |
|
// |
7885 |
|
$crud = $this->get_action_crud(); |
7886 |
|
|
7887 |
|
// Redirection vers le formulaire de modification à la validation du |
7888 |
|
// formulaire d'ajout si l'événement associé possède une lettre type |
7889 |
|
if (($crud === 'create' |
7890 |
|
|| ($crud === null |
7891 |
|
&& $this->getParameter('maj') == 0)) |
7892 |
|
&& $this->correct == true |
7893 |
|
&& $this->evenement_has_an_edition($this->valF['evenement']) === true) { |
7894 |
|
|
7895 |
|
// On instancie l'instruction |
7896 |
|
$inst_instruction = $this->f->get_inst__om_dbform(array( |
7897 |
|
"obj" => "instruction", |
7898 |
|
"idx" => $this->valF[$this->clePrimaire], |
7899 |
|
)); |
7900 |
|
|
7901 |
|
// Si l'instruction n'est pas finalisée automatiquement |
7902 |
|
if ($inst_instruction->getVal('om_final_instruction') !== 't') { |
7903 |
|
$href = str_replace("&action=3", "&action=1", $href); |
7904 |
|
// |
7905 |
|
if (strpos($href, "&retour=tab") !== false) { |
7906 |
|
$href = str_replace("&retour=tab", "&retour= form", $href); |
7907 |
|
} else { |
7908 |
|
$href .= "&retour=form"; |
7909 |
|
} |
7910 |
|
} |
7911 |
|
} |
7912 |
|
|
7913 |
|
// |
7914 |
|
return $href; |
7915 |
|
} |
7916 |
|
|
7917 |
|
public function view_json_data() { |
7918 |
|
$this->checkAccessibility(); |
7919 |
|
$this->f->disableLog(); |
7920 |
|
$view = $this->get_json_data(); |
7921 |
|
printf(json_encode($view)); |
7922 |
|
} |
7923 |
|
|
7924 |
|
public function get_json_data() { |
7925 |
|
$val = array_combine($this->champs, $this->val); |
7926 |
|
foreach ($val as $key => $value) { |
7927 |
|
$val[$key] = strip_tags($value); |
7928 |
|
} |
7929 |
|
$val['tacite'] = 'f'; |
7930 |
|
$inst_ad = $this->f->get_inst__om_dbform(array( |
7931 |
|
"obj" => "avis_decision", |
7932 |
|
"idx" => $val['avis_decision'], |
7933 |
|
)); |
7934 |
|
if (preg_match('/[tT]acite/', $inst_ad->getVal('libelle')) === 1) { |
7935 |
|
$val['tacite'] = 't'; |
7936 |
|
} |
7937 |
|
return $val; |
7938 |
|
} |
7939 |
|
|
7940 |
|
public function get_related_instructions($instruction = null) { |
7941 |
|
$result = array(); |
7942 |
|
$evenements = array(); |
7943 |
|
if ($instruction === null) { |
7944 |
|
$instruction = $this->getVal($this->clePrimaire); |
7945 |
|
$evenement = $this->getVal('evenement'); |
7946 |
|
$dossier = $this->getVal('dossier'); |
7947 |
|
} else { |
7948 |
|
$inst = $this->f->get_inst__om_dbform(array( |
7949 |
|
"obj" => "instruction", |
7950 |
|
"idx" => $instruction, |
7951 |
|
)); |
7952 |
|
$evenement = $inst->getVal('evenement'); |
7953 |
|
$dossier = $inst->getVal('dossier'); |
7954 |
|
} |
7955 |
|
// |
7956 |
|
$query = sprintf(' |
7957 |
|
SELECT evenement |
7958 |
|
FROM %1$sevenement |
7959 |
|
WHERE evenement_retour_ar = %2$s |
7960 |
|
OR evenement_retour_signature = %2$s |
7961 |
|
', |
7962 |
|
DB_PREFIXE, |
7963 |
|
$evenement |
7964 |
|
); |
7965 |
|
$res = $this->f->get_one_result_from_db_query($query, true); |
7966 |
|
if ($res['code'] === 'KO') { |
7967 |
|
return false; |
7968 |
|
} |
7969 |
|
$ev_parent = $res['result']; |
7970 |
|
// |
7971 |
|
$query = sprintf(' |
7972 |
|
SELECT MAX(instruction.instruction) as instruction |
7973 |
|
FROM %1$sinstruction |
7974 |
|
WHERE dossier = \'%3$s\' |
7975 |
|
AND evenement = %2$s |
7976 |
|
', |
7977 |
|
DB_PREFIXE, |
7978 |
|
$ev_parent, |
7979 |
|
$dossier |
7980 |
|
); |
7981 |
|
$res = $this->f->get_one_result_from_db_query($query, true); |
7982 |
|
if ($res['code'] === 'KO') { |
7983 |
|
return false; |
7984 |
|
} |
7985 |
|
$result[] = $res['result']; |
7986 |
|
// |
7987 |
|
$query = sprintf(' |
7988 |
|
SELECT evenement_retour_ar |
7989 |
|
FROM %1$sevenement |
7990 |
|
WHERE evenement = %2$s |
7991 |
|
AND evenement_retour_ar != %3$s |
7992 |
|
', |
7993 |
|
DB_PREFIXE, |
7994 |
|
$ev_parent, |
7995 |
|
$evenement |
7996 |
|
); |
7997 |
|
$res = $this->f->get_one_result_from_db_query($query, true); |
7998 |
|
if ($res['code'] === 'KO') { |
7999 |
|
return false; |
8000 |
|
} |
8001 |
|
$evenements[] = $res['result']; |
8002 |
|
// |
8003 |
|
$query = sprintf(' |
8004 |
|
SELECT evenement_retour_signature |
8005 |
|
FROM %1$sevenement |
8006 |
|
WHERE evenement = %2$s |
8007 |
|
AND evenement_retour_signature != %3$s |
8008 |
|
', |
8009 |
|
DB_PREFIXE, |
8010 |
|
$ev_parent, |
8011 |
|
$evenement |
8012 |
|
); |
8013 |
|
$res = $this->f->get_one_result_from_db_query($query, true); |
8014 |
|
if ($res['code'] === 'KO') { |
8015 |
|
return false; |
8016 |
|
} |
8017 |
|
$evenements[] = $res['result']; |
8018 |
|
foreach ($evenements as $value) { |
8019 |
|
if ($value !== null) { |
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 |
|
$value, |
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 |
|
} |
8037 |
|
return $result; |
8038 |
|
} |
8039 |
|
|
8040 |
|
protected function getDocumentType($champ = null) { |
8041 |
|
$evenementId = $this->getVal('evenement'); |
8042 |
|
if (! empty($evenementId)) { |
8043 |
|
$evenement = $this->f->findObjectById('evenement', $evenementId); |
8044 |
|
if (! empty($evenement)) { |
8045 |
|
return __("Instruction").':'.$evenement->getVal('libelle'); |
8046 |
|
} |
8047 |
|
} |
8048 |
|
return parent::getDocumentType(); |
8049 |
|
} |
8050 |
|
|
8051 |
|
/** |
8052 |
|
* Récupère à l'aide d'une requête sql la liste des demandeurs |
8053 |
|
* pouvant être notifié. C'est à dire les demandeurs acceptant |
8054 |
|
* les notifications et pour lesquels une adresse mail existe. |
8055 |
|
* |
8056 |
|
* Dans le cas, d'une notification pour le portail citoyen, seul |
8057 |
|
* le pétitionnaire principal doit être notifier et uniquement si |
8058 |
|
* il a une adress mail et qu'il accepte les notifications. |
8059 |
|
* |
8060 |
|
* @param string identifiant du dossier |
8061 |
|
* @param boolean true si il faut récupérer la liste des demandeurs notifiable |
8062 |
|
* pour une notification de categorie portail |
8063 |
|
* @return array liste des demandeurs pouvant être notifié |
8064 |
|
*/ |
8065 |
|
protected function get_demandeurs_notifiable($idDossier = null, $portail = false) { |
8066 |
|
if ($idDossier === null) { |
8067 |
|
$idDossier = $this->getVal('dossier'); |
8068 |
|
} |
8069 |
|
// Ajoute une condition sur le where pour ne récupérer que le pétitionnaire principal |
8070 |
|
// pour une notification depuis le portail citoyen |
8071 |
|
$sqlPetitionnairePrincipal = ''; |
8072 |
|
if ($portail === true) { |
8073 |
|
$sqlPetitionnairePrincipal = 'AND lien_dossier_demandeur.petitionnaire_principal = true'; |
8074 |
|
} |
8075 |
|
|
8076 |
|
$listeDemandeursNotifiable = array(); |
8077 |
|
|
8078 |
|
// Requête de récupération des demandeurs |
8079 |
|
$sql = sprintf( |
8080 |
|
'SELECT |
8081 |
|
demandeur.demandeur, |
8082 |
|
CASE |
8083 |
|
WHEN demandeur.qualite=\'particulier\' |
8084 |
|
THEN TRIM(CONCAT(demandeur.particulier_nom, \' \', demandeur.particulier_prenom, \' \', demandeur.courriel)) |
8085 |
|
ELSE |
8086 |
|
TRIM(CONCAT(demandeur.personne_morale_raison_sociale, \' \', demandeur.personne_morale_denomination, \' \', demandeur.courriel)) |
8087 |
|
END AS destinataire, |
8088 |
|
demandeur.courriel |
8089 |
|
FROM |
8090 |
|
%1$sdossier |
8091 |
|
INNER JOIN %1$slien_dossier_demandeur |
8092 |
|
ON dossier.dossier = lien_dossier_demandeur.dossier |
8093 |
|
INNER JOIN %1$sdemandeur |
8094 |
|
ON lien_dossier_demandeur.demandeur = demandeur.demandeur |
8095 |
|
WHERE |
8096 |
|
dossier.dossier = \'%2$s\' AND |
8097 |
|
notification = \'t\' AND |
8098 |
|
courriel IS NOT NULL |
8099 |
|
%3$s', |
8100 |
|
DB_PREFIXE, |
8101 |
|
$idDossier, |
8102 |
|
$sqlPetitionnairePrincipal |
8103 |
|
); |
8104 |
|
$res = $this->f->db->query($sql); |
8105 |
|
$this->f->addToLog(__METHOD__."(): db->query(\"".$sql."\")", VERBOSE_MODE); |
8106 |
|
$this->f->isDatabaseError($res); |
8107 |
|
// Récupération des infos des demandeurs et stockage dans un tableau |
8108 |
|
// ayant pour clé les id des demandeurs |
8109 |
|
while($row = $res->fetchrow(DB_FETCHMODE_ASSOC)) { |
8110 |
|
$listeDemandeursNotifiable[$row['demandeur']] = $row; |
8111 |
|
} |
8112 |
|
|
8113 |
|
return $listeDemandeursNotifiable; |
8114 |
|
} |
8115 |
|
|
8116 |
|
/** |
8117 |
|
* Renvoie la liste des notifications liées à l'instruction |
8118 |
|
* |
8119 |
|
* @param integer id de l'instruction dont on cherche les notifications |
8120 |
|
* @return array liste des instruction_notification liés à l'instruction |
8121 |
|
*/ |
8122 |
|
public function get_instruction_notification($id_instruction) { |
8123 |
|
$listeInstrNotif = array(); |
8124 |
|
$sql = sprintf(' |
8125 |
|
SELECT |
8126 |
|
instruction_notification.instruction_notification |
8127 |
|
FROM |
8128 |
|
%1$sinstruction_notification |
8129 |
|
WHERE |
8130 |
|
instruction = %2$s', |
8131 |
|
DB_PREFIXE, |
8132 |
|
$id_instruction |
8133 |
|
); |
8134 |
|
$res = $this->f->db->query($sql); |
8135 |
|
$this->f->addToLog(__METHOD__."(): db->query(\"".$sql."\")", VERBOSE_MODE); |
8136 |
|
$this->f->isDatabaseError($res); |
8137 |
|
while ($row = $res->fetchrow(DB_FETCHMODE_ASSOC)) { |
8138 |
|
$listeInstrNotif[] = $row['instruction_notification']; |
8139 |
|
} |
8140 |
|
return $listeInstrNotif; |
8141 |
|
} |
8142 |
|
|
8143 |
|
/** |
8144 |
|
* Crée une clé d'accès unique permettant à un utilisateur |
8145 |
|
* anonyme de récupérer le document. |
8146 |
|
* |
8147 |
|
* @return string clé d'accès du document |
8148 |
|
*/ |
8149 |
|
protected function getCleAccesDocument() { |
8150 |
|
// Initialisation d'un tableau |
8151 |
|
$number_list = array(); |
8152 |
|
|
8153 |
|
// Génération aléatoire d'un nombre sur 4 caractères, 4 fois |
8154 |
|
for ($i = 0; $i < 4; $i++) { |
8155 |
|
$number_list[] = str_pad(mt_rand(0, 9999), 4, 0, STR_PAD_LEFT); |
8156 |
|
} |
8157 |
|
|
8158 |
|
// Transformation en chaîne tout en séparant les nombres par un "-" |
8159 |
|
$result = implode('-', $number_list); |
8160 |
|
|
8161 |
|
// Vérifie si la clé existe déjà et si c'est le cas génére une nouvelle clé |
8162 |
|
if ($this->getUidDocumentInstructionWithKey($result) != null) { |
8163 |
|
return $this->getCleAccesDocument(); |
8164 |
|
} |
8165 |
|
|
8166 |
|
// |
8167 |
|
return $result; |
8168 |
|
} |
8169 |
|
|
8170 |
|
/** |
8171 |
|
* Récupère une clé et renvoie l'uid du document liée à cette |
8172 |
|
* clé. Si la clé n'existe pas renvoie null. |
8173 |
|
* |
8174 |
|
* @param string $cleGen clé dont on cherche l'instruction |
8175 |
|
* @return integer|null |
8176 |
|
*/ |
8177 |
|
protected function getUidDocumentInstructionWithKey($cleGen) { |
8178 |
|
$query = sprintf( |
8179 |
|
'SELECT |
8180 |
|
instruction.om_fichier_instruction |
8181 |
|
FROM |
8182 |
|
%1$sinstruction_notification_document |
8183 |
|
LEFT JOIN %1$sinstruction ON instruction_notification_document.instruction = instruction.instruction |
8184 |
|
WHERE |
8185 |
|
instruction_notification_document.cle = \'%2$s\'', |
8186 |
|
DB_PREFIXE, |
8187 |
|
$this->f->db->escapeSimple($cleGen) |
8188 |
|
); |
8189 |
|
|
8190 |
|
$res = $this->f->db->getOne($query); |
8191 |
|
$this->addToLog(__METHOD__.": db->getOne(\"".$query."\");", VERBOSE_MODE); |
8192 |
|
$this->f->isDatabaseError($res); |
8193 |
|
|
8194 |
|
return $res; |
8195 |
|
} |
8196 |
|
|
8197 |
|
/** |
8198 |
|
* Récupère une clé, fait une requête pour récupérer l'id de la notification liée a cette clé. |
8199 |
|
* Récupère l'instance de instruction_notification dont l'id a été récupéré et la renvoie. |
8200 |
|
* |
8201 |
|
* @param string $cleGen |
8202 |
|
* @return instruction_notification |
8203 |
|
*/ |
8204 |
|
protected function getInstanceNotificationWithKey($key) { |
8205 |
|
$sql = sprintf( |
8206 |
|
"SELECT |
8207 |
|
instruction_notification |
8208 |
|
FROM |
8209 |
|
%1\$sinstruction_notification_document |
8210 |
|
WHERE |
8211 |
|
cle = '%2\$s'", |
8212 |
|
DB_PREFIXE, |
8213 |
|
$this->f->db->escapeSimple($key) |
8214 |
|
); |
8215 |
|
$res = $this->f->db->getOne($sql); |
8216 |
|
$this->addToLog(__METHOD__.": db->getOne(\"".$sql."\");", VERBOSE_MODE); |
8217 |
|
$this->f->isDatabaseError($res); |
8218 |
|
|
8219 |
|
// Récupération de l'instance de notification |
8220 |
|
$instNotif = $this->f->get_inst__om_dbform(array( |
8221 |
|
"obj" => "instruction_notification", |
8222 |
|
"idx" => $res, |
8223 |
|
)); |
8224 |
|
return $instNotif; |
8225 |
|
} |
8226 |
|
|
8227 |
|
|
8228 |
|
/** |
8229 |
|
* Affiche la page de téléchargement du document de la notification. |
8230 |
|
* |
8231 |
|
* @param boolean $content_only Affiche le contenu seulement. |
8232 |
|
* |
8233 |
|
* @return void |
8234 |
|
*/ |
8235 |
|
public function view_telecharger_document_anonym() { |
8236 |
|
// Par défaut on considère qu'on va afficher le formulaire |
8237 |
|
$idx = 0; |
8238 |
|
// Flag d'erreur |
8239 |
|
$error = false; |
8240 |
|
// Message d'erreur |
8241 |
|
$message = ''; |
8242 |
|
|
8243 |
|
// Paramètres GET : récupération de la clé d'accès |
8244 |
|
$cle_acces_document = $this->f->get_submitted_get_value('key'); |
8245 |
|
$cle_acces_document = $this->f->db->escapeSimple($cle_acces_document); |
8246 |
|
// Vérification de l'existence de la clé et récupération de l'uid du fichier |
8247 |
|
$uidFichier = $this->getUidDocumentInstructionWithKey($cle_acces_document); |
8248 |
|
if ($uidFichier != null) { |
8249 |
|
// Récupération du document |
8250 |
|
$file = $this->f->storage->get($uidFichier); |
8251 |
|
|
8252 |
|
// Headers |
8253 |
|
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 |
8254 |
|
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date dans le passé |
8255 |
|
header("Content-Type: ".$file['metadata']['mimetype']); |
8256 |
|
header("Accept-Ranges: bytes"); |
8257 |
|
header("Content-Disposition: inline; filename=\"".$file['metadata']['filename']."\";" ); |
8258 |
|
// Affichage du document |
8259 |
|
echo $file['file_content']; |
8260 |
|
|
8261 |
|
// Récupération de la date de premier accès et maj du suivi uniquement |
8262 |
|
// si la date de 1er accès n'a pas encore été remplis |
8263 |
|
$inst_notif = $this->getInstanceNotificationWithKey($cle_acces_document); |
8264 |
|
if ($inst_notif->getVal('date_premier_acces') == null || |
8265 |
|
$inst_notif->getVal('date_premier_acces') == '') { |
8266 |
|
$notif_val = array(); |
8267 |
|
foreach ($inst_notif->champs as $champ) { |
8268 |
|
$notif_val[$champ] = $inst_notif->getVal($champ); |
8269 |
|
} |
8270 |
|
$notif_val['date_premier_acces'] = date("d/m/Y H:i:s"); |
8271 |
|
$notif_val['statut'] = 'vu'; |
8272 |
|
$notif_val['commentaire'] = 'Le document a été vu'; |
8273 |
|
$suivi_notif = $inst_notif->modifier($notif_val); |
8274 |
|
} |
8275 |
|
|
8276 |
|
} else { |
8277 |
|
// Page vide 404 |
8278 |
|
printf('Ressource inexistante'); |
8279 |
|
header('HTTP/1.0 404 Not Found'); |
8280 |
|
} |
8281 |
|
} |
8282 |
|
|
8283 |
|
protected function getDocumentTitre($champ = null) { |
8284 |
|
$title = $this->getTitle(); |
8285 |
|
$dossier = $this->getDossier(); |
8286 |
|
return $dossier.' '.$title; |
8287 |
|
} |
8288 |
|
|
8289 |
|
/** |
8290 |
|
* Surcharge permettant de ne pas afficher le fil d'Ariane dans |
8291 |
|
* l'overlay de notification des demandeurs. |
8292 |
|
*/ |
8293 |
|
function getSubFormTitle($ent) { |
8294 |
|
if ($this->getParameter('maj') == '411') { |
8295 |
|
return ''; |
8296 |
|
} |
8297 |
|
return parent::getSubFormTitle($ent); |
8298 |
|
} |
8299 |
|
}// fin classe |