1 |
<?php |
<?php |
2 |
/** |
/** |
|
* |
|
|
* |
|
3 |
* specific : |
* specific : |
4 |
* - cle secondaire |
* - cle secondaire |
5 |
* destruction autorisée que pour le dernier evenement |
* destruction autorisée que pour le dernier evenement |
6 |
* [delete the last event ] |
* [delete the last event ] |
7 |
* - variable globale [global variables] |
* - variable globale [global variables] |
|
* var $archive_date_depot; |
|
8 |
* var $retourformulaire; |
* var $retourformulaire; |
9 |
* var $idxformulaire; |
* var $idxformulaire; |
10 |
* - modification des données dans dossier trigger avant |
* - modification des données dans dossier trigger avant |
14 |
* - voir script_lang.js : bible ... |
* - voir script_lang.js : bible ... |
15 |
* |
* |
16 |
* @package openfoncier |
* @package openfoncier |
17 |
* @version SVN : $Id: instruction.class.php 6178 2016-03-15 10:56:43Z nmeucci $ |
* @version SVN : $Id$ |
18 |
*/ |
*/ |
19 |
|
|
20 |
// |
// |
21 |
require_once "../gen/obj/instruction.class.php"; |
require_once "../gen/obj/instruction.class.php"; |
22 |
|
|
23 |
// |
// |
|
require_once "../services/outgoing/messageenqueuer.php"; |
|
|
|
|
|
// |
|
24 |
class instruction extends instruction_gen { |
class instruction extends instruction_gen { |
25 |
|
|
26 |
// Champs contenant les UID des fichiers |
// Champs contenant les UID des fichiers |
28 |
"om_fichier_instruction" => "file", |
"om_fichier_instruction" => "file", |
29 |
); |
); |
30 |
|
|
|
var $archive_date_depot; // specific |
|
31 |
var $retourformulaire; // specific |
var $retourformulaire; // specific |
32 |
var $idxformulaire; // specific |
var $idxformulaire; // specific |
33 |
var $valEvenement; |
var $valEvenement; |
35 |
// Tableau contenant une partie des métadonnées arrêtés |
// Tableau contenant une partie des métadonnées arrêtés |
36 |
var $metadonneesArrete; |
var $metadonneesArrete; |
37 |
|
|
38 |
|
/** |
39 |
|
* Instance de la classe dossier |
40 |
|
* |
41 |
|
* @var mixed |
42 |
|
*/ |
43 |
|
var $inst_dossier = null; |
44 |
|
|
45 |
|
/** |
46 |
|
* Instance de la classe instructeur |
47 |
|
* |
48 |
|
* @var mixed |
49 |
|
*/ |
50 |
|
var $inst_instructeur = null; |
51 |
|
|
52 |
|
/** |
53 |
|
* Instance de la classe om_utilisateur |
54 |
|
* |
55 |
|
* @var mixed |
56 |
|
*/ |
57 |
|
var $inst_om_utilisateur = null; |
58 |
|
|
59 |
var $metadata = array( |
var $metadata = array( |
60 |
"om_fichier_instruction" => array( |
"om_fichier_instruction" => array( |
61 |
"dossier" => "getDossier", |
"dossier" => "getDossier", |
68 |
"dateEvenementDocument" => "getDateEvenementDocument", |
"dateEvenementDocument" => "getDateEvenementDocument", |
69 |
"groupeInstruction" => 'getGroupeInstruction', |
"groupeInstruction" => 'getGroupeInstruction', |
70 |
"title" => 'getTitle', |
"title" => 'getTitle', |
71 |
|
'concerneERP' => 'get_concerne_erp', |
72 |
), |
), |
73 |
"arrete" => array( |
"arrete" => array( |
74 |
"numArrete" => "getNumArrete", |
"numArrete" => "getNumArrete", |
87 |
"dateControleLegalite" => "getDateControleLegalite", |
"dateControleLegalite" => "getDateControleLegalite", |
88 |
), |
), |
89 |
); |
); |
|
/** @var boolean Les nouvelles actions sont activées sur cet objet */ |
|
|
var $activate_class_action; |
|
90 |
|
|
91 |
function __construct($id, &$db, $debug) { |
function __construct($id, &$db, $debug) { |
|
//On active les nouvelles actions |
|
|
$this->activate_class_action = true; |
|
92 |
$this->constructeur($id, $db, $debug); |
$this->constructeur($id, $db, $debug); |
93 |
} |
} |
94 |
|
|
105 |
|
|
106 |
// ACTION - 000 - ajouter |
// ACTION - 000 - ajouter |
107 |
// Modifie la condition d'affichage du bouton ajouter |
// Modifie la condition d'affichage du bouton ajouter |
108 |
$this->class_actions[0]["condition"] = "is_addable_editable_and_deletable"; |
$this->class_actions[0]["condition"] = array("is_addable", "can_user_access_dossier_contexte_ajout"); |
109 |
|
|
110 |
// ACTION - 001 - modifier |
// ACTION - 001 - modifier |
111 |
// Modifie la condition et le libellé du bouton modifier |
// Modifie la condition et le libellé du bouton modifier |
112 |
$this->class_actions[1]["condition"] = array("is_editable", "is_finalizable_without_bypass"); |
$this->class_actions[1]["condition"] = array( |
113 |
|
"is_editable", |
114 |
|
"is_finalizable_without_bypass", |
115 |
|
"can_user_access_dossier_contexte_modification", |
116 |
|
); |
117 |
$this->class_actions[1]["portlet"]["libelle"] = _("Modifier"); |
$this->class_actions[1]["portlet"]["libelle"] = _("Modifier"); |
118 |
|
|
119 |
// ACTION - 002 - supprimer |
// ACTION - 002 - supprimer |
120 |
// Modifie la condition et le libellé du bouton supprimer |
// Modifie la condition et le libellé du bouton supprimer |
121 |
$this->class_actions[2]["condition"] = array("is_deletable", "is_finalizable_without_bypass"); |
$this->class_actions[2]["condition"] = array( |
122 |
|
"is_deletable", |
123 |
|
"is_finalizable_without_bypass", |
124 |
|
"can_user_access_dossier_contexte_modification" |
125 |
|
); |
126 |
$this->class_actions[2]["portlet"]["libelle"] = _("Supprimer"); |
$this->class_actions[2]["portlet"]["libelle"] = _("Supprimer"); |
127 |
|
|
128 |
|
// ACTION - 003 - consulter |
129 |
|
// |
130 |
|
$this->class_actions[3]["condition"] = "can_user_access_dossier_contexte_modification"; |
131 |
|
|
132 |
// ACTION - 100 - finaliser |
// ACTION - 100 - finaliser |
133 |
// Finalise l'enregistrement |
// Finalise l'enregistrement |
134 |
$this->class_actions[100] = array( |
$this->class_actions[100] = array( |
143 |
"method" => "finalize", |
"method" => "finalize", |
144 |
"button" => "finaliser", |
"button" => "finaliser", |
145 |
"permission_suffix" => "finaliser", |
"permission_suffix" => "finaliser", |
146 |
"condition" => array("is_finalizable", "is_finalizable_without_bypass", "has_an_edition"), |
"condition" => array( |
147 |
|
"is_finalizable", |
148 |
|
"is_finalizable_without_bypass", |
149 |
|
"has_an_edition", |
150 |
|
"can_user_access_dossier_contexte_modification", |
151 |
|
), |
152 |
); |
); |
153 |
|
|
154 |
// ACTION - 110 - definaliser |
// ACTION - 110 - definaliser |
165 |
"method" => "unfinalize", |
"method" => "unfinalize", |
166 |
"button" => "definaliser", |
"button" => "definaliser", |
167 |
"permission_suffix" => "definaliser", |
"permission_suffix" => "definaliser", |
168 |
"condition" => array("is_unfinalizable", "is_unfinalizable_without_bypass"), |
"condition" => array( |
169 |
|
"is_unfinalizable", |
170 |
|
"is_unfinalizable_without_bypass", |
171 |
|
"can_user_access_dossier_contexte_modification", |
172 |
|
), |
173 |
); |
); |
174 |
|
|
175 |
// ACTION - 120 - edition |
// ACTION - 120 - edition |
183 |
"class" => "pdf-16", |
"class" => "pdf-16", |
184 |
), |
), |
185 |
"view" => "view_edition", |
"view" => "view_edition", |
186 |
"condition" => "has_an_edition", |
"condition" => array("has_an_edition", "can_user_access_dossier_contexte_modification"), |
187 |
"permission_suffix" => "om_fichier_instruction_telecharger", |
"permission_suffix" => "om_fichier_instruction_telecharger", |
188 |
); |
); |
189 |
|
|
198 |
"class" => "suivi-dates-16", |
"class" => "suivi-dates-16", |
199 |
), |
), |
200 |
"crud" => "update", |
"crud" => "update", |
201 |
"condition" => array("is_unfinalizable", "is_unfinalizable_without_bypass"), |
"condition" => array("can_monitoring_dates", "can_user_access_dossier_contexte_modification"), |
202 |
"permission_suffix" => "modification_dates", |
"permission_suffix" => "modification_dates", |
203 |
); |
); |
204 |
|
|
266 |
"view" => "view_generate_bordereau_envoi_maire", |
"view" => "view_generate_bordereau_envoi_maire", |
267 |
"permission_suffix" => "bordereau_envoi_maire", |
"permission_suffix" => "bordereau_envoi_maire", |
268 |
); |
); |
|
} |
|
|
|
|
|
/** |
|
|
* Cette variable permet de stocker le résultat de la méthode |
|
|
* getDivisionFromDossier() afin de ne pas effectuer le recalcul à chacun de |
|
|
* ces appels. |
|
|
* @var string Code de la division du dossier en cours |
|
|
*/ |
|
|
var $_division_from_dossier = NULL; |
|
269 |
|
|
270 |
/** |
// ACTION - 210 - notifier_commune |
271 |
* Cette méthode permet de récupérer le code de division correspondant |
// Notifie la commune par mail d'un évément d'instruction finalisé |
272 |
* au dossier sur lequel on se trouve. |
$this->class_actions[210] = array( |
273 |
* |
"identifier" => "notifier_commune", |
274 |
* @return string Code de la division du dossier en cours |
"portlet" => array( |
275 |
*/ |
"type" => "action-direct-with-confirmation", |
276 |
function getDivisionFromDossier() { |
"libelle" => _("Notifier la commune par courriel"), |
277 |
|
"order" => 210, |
278 |
// Cette méthode peut être appelée plusieurs fois lors d'une requête. |
"class" => "notifier_commune-16", |
279 |
// Pour éviter de refaire le traitement de recherche de la division |
), |
280 |
// alors on vérifie si nous ne l'avons pas déjà calculé. |
"view" => "formulaire", |
281 |
if ($this->_division_from_dossier != NULL) { |
"method" => "notifier_commune", |
282 |
// Logger |
"permission_suffix" => "notifier_commune", |
283 |
$this->addToLog("getDivisionFromDossier(): retour de la valeur déjà calculée - '".$this->_division_from_dossier."'", EXTRA_VERBOSE_MODE); |
"condition" => array("is_notifiable", "can_user_access_dossier_contexte_modification"), |
284 |
// On retourne la valeur déjà calculée |
); |
|
return $this->_division_from_dossier; |
|
|
} |
|
|
|
|
|
// Par défaut, on définit la valeur du dossier à NULL |
|
|
$dossier = NULL; |
|
|
// Test sur le mode et le contexte du formulaire |
|
|
if ($this->getParameter("maj") == 0 |
|
|
&& ($this->getParameter("retourformulaire") == "dossier" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_encours" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_encours" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_clotures" |
|
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_clotures")) { |
|
|
// Si on se trouve en mode AJOUT (seul mode où l'enregistrement |
|
|
// n'existe pas en base de données) ET que nous nous trouvons |
|
|
// dans le contexte d'un dossier d'instruction alors on récupère |
|
|
// le numéro de dossier depuis le paramètre 'idxformulaire' |
|
|
$dossier = $this->getParameter("idxformulaire"); |
|
|
} else { |
|
|
// Sinon on récupère le numéro de dossier dans le champs dossier de |
|
|
// l'enregistrement (en base de données) |
|
|
$dossier = $this->getVal("dossier"); |
|
|
} |
|
|
|
|
|
// On appelle la méthode de la classe utils qui renvoi le code de la |
|
|
// division d'un dossier, on la stocke pour ne pas refaire le calcul au |
|
|
// prochain appel de cette méthode |
|
|
$this->_division_from_dossier = $this->f->getDivisionFromDossier($dossier); |
|
|
// Logger |
|
|
$this->addToLog("getDivisionFromDossier(): retour de la valeur nouvellement calculée - '".$this->_division_from_dossier."'", EXTRA_VERBOSE_MODE); |
|
|
// On retourne la valeur retournée |
|
|
return $this->_division_from_dossier; |
|
285 |
|
|
286 |
|
// ACTION - 220 - generate_suivi_bordereaux |
287 |
|
// GénÚre PDF bordereaux |
288 |
|
$this->class_actions[220] = array( |
289 |
|
"identifier" => "generate_suivi_bordereaux", |
290 |
|
"view" => "view_generate_suivi_bordereaux", |
291 |
|
"permission_suffix" => "consulter", |
292 |
|
); |
293 |
} |
} |
294 |
|
|
295 |
|
|
296 |
/** |
/** |
297 |
* 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 |
298 |
*/ |
*/ |
365 |
$form->setType('archive_date_conformite', 'hiddendate'); |
$form->setType('archive_date_conformite', 'hiddendate'); |
366 |
$form->setType('archive_date_chantier', 'hiddendate'); |
$form->setType('archive_date_chantier', 'hiddendate'); |
367 |
$form->setType('archive_autorite_competente','hidden'); |
$form->setType('archive_autorite_competente','hidden'); |
368 |
|
$form->setType('date_depot','hidden'); |
369 |
// |
// |
370 |
$form->setType('numero_arrete', 'hidden'); |
$form->setType('numero_arrete', 'hidden'); |
371 |
// |
// |
381 |
$form->setType('archive_delai_incompletude','hidden'); |
$form->setType('archive_delai_incompletude','hidden'); |
382 |
|
|
383 |
// |
// |
384 |
|
$form->setType('archive_date_cloture_instruction','hidden'); |
385 |
|
$form->setType('archive_date_premiere_visite','hidden'); |
386 |
|
$form->setType('archive_date_derniere_visite','hidden'); |
387 |
|
$form->setType('archive_date_contradictoire','hidden'); |
388 |
|
$form->setType('archive_date_retour_contradictoire','hidden'); |
389 |
|
$form->setType('archive_date_ait','hiddendate'); |
390 |
|
$form->setType('archive_date_transmission_parquet','hidden'); |
391 |
|
|
392 |
|
// |
393 |
$form->setType('duree_validite','hidden'); |
$form->setType('duree_validite','hidden'); |
394 |
$form->setType('duree_validite_parametrage','hidden'); |
$form->setType('duree_validite_parametrage','hidden'); |
395 |
|
|
441 |
// les administrateurs technique et fonctionnel peuvent |
// les administrateurs technique et fonctionnel peuvent |
442 |
// modifier tous les champs de date |
// modifier tous les champs de date |
443 |
// 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 |
444 |
if ($this->f->isAccredited("instruction_modification_dates") |
if (($this->f->isAccredited(array(get_class($this), get_class($this)."modification_dates"), "OR") |
445 |
|
|| $this->f->isAccredited(array('instruction', 'instruction_modification_dates'), "OR")) |
446 |
&& $this->getVal("date_finalisation_courrier") != '') { |
&& $this->getVal("date_finalisation_courrier") != '') { |
447 |
$form->setType('date_envoi_signature', 'date'); |
$form->setType('date_envoi_signature', 'date'); |
448 |
$form->setType('date_retour_signature', 'date'); |
$form->setType('date_retour_signature', 'date'); |
453 |
$form->setType('date_finalisation_courrier', 'date'); |
$form->setType('date_finalisation_courrier', 'date'); |
454 |
// suivi des dates |
// suivi des dates |
455 |
if ($maj == 125) { |
if ($maj == 125) { |
456 |
|
$form->setType('date_evenement', 'hiddenstaticdate'); |
457 |
$form->setType('complement_om_html', 'hiddenstatic'); |
$form->setType('complement_om_html', 'hiddenstatic'); |
458 |
$form->setType('complement2_om_html', 'hiddenstatic'); |
$form->setType('complement2_om_html', 'hiddenstatic'); |
459 |
$form->setType('complement3_om_html', 'hiddenstatic'); |
$form->setType('complement3_om_html', 'hiddenstatic'); |
495 |
//date_retour_controle_legalite si ce n'est pas un arrêté et si ce n'est |
//date_retour_controle_legalite si ce n'est pas un arrêté et si ce n'est |
496 |
//pas un utilisateur ayant le droit spécifique |
//pas un utilisateur ayant le droit spécifique |
497 |
if ( !is_numeric($this->getVal("avis_decision"))&& |
if ( !is_numeric($this->getVal("avis_decision"))&& |
498 |
!$this->f->isAccredited("instruction_modification_dates")){ |
!$this->f->isAccredited(array("instruction", "instruction_modification_dates"), "OR")){ |
499 |
|
|
500 |
$form->setType("date_envoi_controle_legalite", "hiddendate"); |
$form->setType("date_envoi_controle_legalite", "hiddendate"); |
501 |
$form->setType("date_retour_controle_legalite", "hiddendate"); |
$form->setType("date_retour_controle_legalite", "hiddendate"); |
502 |
} |
} |
503 |
|
|
504 |
// Pour les actions finalize et unfinalize |
// Pour les actions finalize, unfinalize et notifier_commune |
505 |
if($maj == 100 || $maj == 110) { |
if($maj == 100 || $maj == 110 || $maj == 210) { |
506 |
// |
// |
507 |
foreach ($this->champs as $value) { |
foreach ($this->champs as $value) { |
508 |
// Cache tous les champs |
// Cache tous les champs |
551 |
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_encours" |
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_encours" |
552 |
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_encours" |
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_encours" |
553 |
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_clotures" |
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_clotures" |
554 |
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_clotures") { |
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_clotures" |
555 |
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_mes_infractions" |
556 |
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_toutes_infractions" |
557 |
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_mes_recours" |
558 |
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_tous_recours") { |
559 |
// 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 |
560 |
require_once "../obj/dossier_instruction.class.php"; |
require_once "../obj/dossier_instruction.class.php"; |
561 |
$di = new dossier_instruction($this->getParameter('idxformulaire'), $db, $debug); |
$di = new dossier_instruction($this->getParameter('idxformulaire'), $db, $debug); |
593 |
|
|
594 |
// Si changement de décision par instructeur commune |
// Si changement de décision par instructeur commune |
595 |
if($this->f->isUserInstructeur() === true |
if($this->f->isUserInstructeur() === true |
596 |
&& $this->f->getDivisionFromDossier($this->idxformulaire) != $_SESSION["division"] |
&& $this->getDivisionFromDossier($this->idxformulaire) != $_SESSION["division"] |
597 |
&& $this->f->isInstrCanChangeDecision($this->idxformulaire) === true) { |
&& $this->isInstrCanChangeDecision($this->idxformulaire) === true) { |
598 |
$sql .= "AND evenement.type IN ('arrete', 'changement_decision') "; |
$sql .= "AND evenement.type IN ('arrete', 'changement_decision') "; |
599 |
} |
} |
600 |
$sql .= "ORDER BY evenement.libelle, evenement.action"; |
$sql .= "ORDER BY evenement.libelle, evenement.action"; |
746 |
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_encours" |
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_encours" |
747 |
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_encours" |
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_encours" |
748 |
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_clotures" |
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_clotures" |
749 |
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_clotures") { |
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_clotures" |
750 |
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_mes_infractions" |
751 |
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_toutes_infractions" |
752 |
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_mes_recours" |
753 |
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_tous_recours") { |
754 |
|
|
755 |
// Vérification de la possibilité de modifier les dates si déjà éditées |
// Vérification de la possibilité de modifier les dates si déjà éditées |
756 |
if($this->valF[$champ] != "" AND !$this->f->user_is_admin) { |
if($this->valF[$champ] != "" AND !$this->f->user_is_admin) { |
802 |
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_encours" |
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_encours" |
803 |
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_encours" |
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_encours" |
804 |
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_clotures" |
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_clotures" |
805 |
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_clotures") { |
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_clotures" |
806 |
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_mes_infractions" |
807 |
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_toutes_infractions" |
808 |
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_mes_recours" |
809 |
|
|| $this->getParameter("retourformulaire") == "dossier_contentieux_tous_recours") { |
810 |
// 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 |
811 |
require_once "../obj/dossier_instruction.class.php"; |
require_once "../obj/dossier_instruction.class.php"; |
812 |
$di = new dossier_instruction($this->getParameter('idxformulaire'), $db, DEBUG); |
$di = new dossier_instruction($this->getParameter('idxformulaire'), $db, DEBUG); |
911 |
* - delai_notification |
* - delai_notification |
912 |
* - lettretype |
* - lettretype |
913 |
* - autorite_competente |
* - autorite_competente |
914 |
|
* - complement_om_html |
915 |
|
* - complement2_om_html |
916 |
|
* - complement3_om_html |
917 |
|
* - complement4_om_html |
918 |
|
* - complement5_om_html |
919 |
* DEPUIS LE DOSSIER D'INSTRUCTION |
* DEPUIS LE DOSSIER D'INSTRUCTION |
920 |
* - archive_delai |
* - archive_delai |
921 |
* - archive_accord_tacite |
* - archive_accord_tacite |
931 |
* - date_chantier |
* - date_chantier |
932 |
* - date_conformite |
* - date_conformite |
933 |
* - avis_decision |
* - avis_decision |
|
* Il permet également de stocker la date_depot du dossier d'instruction |
|
|
* dans l'attribut $this->archive_date_depot de la classe. |
|
934 |
*/ |
*/ |
935 |
// 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é |
936 |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
984 |
} |
} |
985 |
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
986 |
$this->updateArchiveData($row); |
$this->updateArchiveData($row); |
|
$this->archive_date_depot = $row['date_depot']; |
|
987 |
|
|
988 |
// Récupération de la duree de validite du dossier d'autorisation |
// Récupération de la duree de validite du dossier d'autorisation |
989 |
$sql = "SELECT duree_validite_parametrage |
$sql = "SELECT duree_validite_parametrage |
1017 |
$this->restriction_valid = true; |
$this->restriction_valid = true; |
1018 |
return $this->restriction_valid; |
return $this->restriction_valid; |
1019 |
} |
} |
1020 |
// Liste des opérateurs possible |
// Liste des opérateurs possibles sans espace |
1021 |
$operateurs = array(">=", "<=", "+", "-"); |
$operateurs = array(">=", "<=", "+", "-", "&&", "||", "==", "!="); |
1022 |
// Liste des opérateurs avec espace |
// Liste identique mais avec le marqueur § |
1023 |
$operateurs_blank = array(" >= ", " <= ", " + ", " - "); |
$mark = "§"; |
1024 |
|
$operateurs_marked = array(); |
1025 |
|
foreach ($operateurs as $operateur) { |
1026 |
|
$operateurs_marked[] = $mark.$operateur.$mark; |
1027 |
|
} |
1028 |
|
|
1029 |
// Supprime tous les espaces de la chaîne de caractère |
// Supprime tous les espaces de la chaîne de caractère |
1030 |
$restriction = str_replace(' ', '', $restriction); |
$restriction = preg_replace('/\s+/', '', $restriction); |
1031 |
|
|
1032 |
// Met des espace avant et après les opérateurs puis transforme la |
// Met un marqueur avant et après les opérateurs |
1033 |
// chaine en un tableau |
// puis transforme la chaine en un tableau |
1034 |
$tabRestriction = str_replace($operateurs, $operateurs_blank, |
$restriction = str_replace($operateurs, $operateurs_marked, |
1035 |
$restriction); |
$restriction); |
|
$tabRestriction = explode(" ", $tabRestriction); |
|
1036 |
|
|
1037 |
|
// Pour chaque opérateur logique |
1038 |
|
foreach (array('&&', '||') as $operator) { |
1039 |
|
|
1040 |
|
// S'il est absent on ne fait aucun traitement |
1041 |
|
if (strpos($restriction, $mark.$operator.$mark) === false) { |
1042 |
|
continue; |
1043 |
|
} |
1044 |
|
// Sinon on vérifie les deux conditions avec le OU/ET logique |
1045 |
|
$restrictions = explode($mark.$operator.$mark, $restriction); |
1046 |
|
$restrictions[0] = explode($mark, $restrictions[0]); |
1047 |
|
$restrictions[1] = explode($mark, $restrictions[1]); |
1048 |
|
$res_bool = false; |
1049 |
|
if ($operator == '&&') { |
1050 |
|
if ($this->is_restriction_satisfied($restrictions[0], $operateurs) |
1051 |
|
&& $this->is_restriction_satisfied($restrictions[1], $operateurs)) { |
1052 |
|
$res_bool = true; |
1053 |
|
} |
1054 |
|
} |
1055 |
|
if ($operator == '||') { |
1056 |
|
if ($this->is_restriction_satisfied($restrictions[0], $operateurs) |
1057 |
|
|| $this->is_restriction_satisfied($restrictions[1], $operateurs)) { |
1058 |
|
$res_bool = true; |
1059 |
|
} |
1060 |
|
} |
1061 |
|
return $res_bool; |
1062 |
|
} |
1063 |
|
$tabRestriction = explode($mark, $restriction); |
1064 |
|
return $this->is_restriction_satisfied($tabRestriction, $operateurs); |
1065 |
|
|
1066 |
|
} |
1067 |
|
|
1068 |
|
function is_restriction_satisfied($restriction, $operateurs) { |
1069 |
// Tableau comprenant les résultat |
// Tableau comprenant les résultat |
1070 |
$res = array(); |
$res = array(); |
1071 |
// Compteur pour les résultat |
// Compteur pour les résultat |
1077 |
$res_bool = true; |
$res_bool = true; |
1078 |
|
|
1079 |
// S'il y a un comparateur |
// S'il y a un comparateur |
1080 |
if (in_array(">=", $tabRestriction) |
if (in_array(">=", $restriction) |
1081 |
|| in_array("<=", $tabRestriction)) { |
|| in_array("<=", $restriction) |
1082 |
|
|| in_array("==", $restriction) |
1083 |
|
|| in_array("!=", $restriction)) { |
1084 |
|
|
1085 |
// Si le tableau n'est pas vide |
// Si le tableau n'est pas vide |
1086 |
if (count($tabRestriction) > 0) { |
if (count($restriction) > 0) { |
1087 |
|
|
1088 |
// Boucle dans le tableau pour récupérer seulement les valeurs |
// Boucle dans le tableau pour récupérer seulement les valeurs |
1089 |
foreach ($tabRestriction as $key => $value) { |
foreach ($restriction as $key => $value) { |
|
|
|
1090 |
// |
// |
1091 |
if (!in_array($value, $operateurs)) { |
if (!in_array($value, $operateurs)) { |
1092 |
if ($this->getRestrictionValue($value) != false) { |
if ($this->getRestrictionValue($value) != false) { |
1104 |
// Boucle dans le tableau |
// Boucle dans le tableau |
1105 |
// commence à 1 car le 0 doit rester inchangé tout au long du |
// commence à 1 car le 0 doit rester inchangé tout au long du |
1106 |
// traitement |
// traitement |
1107 |
for ($i = 1; $i<count($tabRestriction); $i++) { |
for ($i = 1; $i<count($restriction); $i++) { |
1108 |
|
|
1109 |
// Récupère le comparateur |
// Récupère le comparateur |
1110 |
if ($tabRestriction[$i] === ">=" |
if ($restriction[$i] === ">=" |
1111 |
|| $tabRestriction[$i] === "<=") { |
|| $restriction[$i] === "<=" |
1112 |
$comparateur = $tabRestriction[$i]; |
|| $restriction[$i] === "==" |
1113 |
|
|| $restriction[$i] === "!=") { |
1114 |
|
$comparateur = $restriction[$i]; |
1115 |
} |
} |
1116 |
|
|
1117 |
// Si l'opérateur qui suit est un "+" |
// Si l'opérateur qui suit est un "+" |
1118 |
if ($tabRestriction[$i] === "+") { |
if ($restriction[$i] === "+") { |
1119 |
$dateDep = $res[$j]; |
$dateDep = $res[$j]; |
1120 |
unset($res[$j]);$j++; |
unset($res[$j]);$j++; |
1121 |
$duree = $res[$j]; |
$duree = $res[$j]; |
1124 |
} |
} |
1125 |
|
|
1126 |
// Si l'opérateur qui suit est un "-" |
// Si l'opérateur qui suit est un "-" |
1127 |
if ($tabRestriction[$i] === "-") { |
if ($restriction[$i] === "-") { |
1128 |
$dateDep = $res[$j]; |
$dateDep = $res[$j]; |
1129 |
unset($res[$j]);$j++; |
unset($res[$j]);$j++; |
1130 |
$duree = $res[$j]; |
$duree = $res[$j]; |
1147 |
} |
} |
1148 |
} |
} |
1149 |
if ($comparateur === "<=") { |
if ($comparateur === "<=") { |
1150 |
|
// |
1151 |
if (strtotime($res[0]) <= strtotime($res[$j])) { |
if (strtotime($res[0]) <= strtotime($res[$j])) { |
1152 |
$res_bool = true; |
$res_bool = true; |
1153 |
} |
} |
1154 |
} |
} |
1155 |
|
if ($comparateur === "==") { |
1156 |
|
// |
1157 |
|
if (strtotime($res[0]) == strtotime($res[$j])) { |
1158 |
|
$res_bool = true; |
1159 |
|
} |
1160 |
|
} |
1161 |
|
if ($comparateur === "!=") { |
1162 |
|
// |
1163 |
|
if (strtotime($res[0]) != strtotime($res[$j])) { |
1164 |
|
$res_bool = true; |
1165 |
|
} |
1166 |
|
} |
1167 |
} |
} |
1168 |
// Sinon une erreur s'affiche |
// Sinon une erreur s'affiche |
1169 |
} else { |
} else { |
1258 |
return $return; |
return $return; |
1259 |
} |
} |
1260 |
|
|
1261 |
|
|
1262 |
/** |
/** |
1263 |
* Calcul des règle d'action. |
* Calcul des règle d'action selon leur type. |
1264 |
* @param string $rule Règle d'action |
* |
1265 |
* @param string $rule_name Nom de la règle |
* Types de règle : |
1266 |
* @param string $type Type de la règle |
* - date |
1267 |
|
* - numeric |
1268 |
|
* - text |
1269 |
|
* - bool |
1270 |
|
* - specific |
1271 |
|
* - technical_data |
1272 |
|
* |
1273 |
|
* @param string $rule Règle d'action. |
1274 |
|
* @param string $rule_name Nom de la règle. |
1275 |
|
* @param string $type Type de la règle. |
1276 |
* |
* |
1277 |
* @return mixed Résultat de la règle |
* @return mixed Résultat de la règle |
1278 |
*/ |
*/ |
1279 |
function regle($rule, $rule_name, $type = null) { |
public function regle($rule, $rule_name, $type = null) { |
1280 |
|
|
1281 |
// Supprime tous les espaces de la chaîne de caractère |
// Supprime tous les espaces de la chaîne de caractère |
1282 |
$rule = str_replace(' ', '', $rule); |
$rule = str_replace(' ', '', $rule); |
1290 |
return null; |
return null; |
1291 |
} |
} |
1292 |
|
|
|
// Si c'est une règle spécifique |
|
|
if ($rule_name == "regle_autorite_competente" |
|
|
|| $rule_name == "regle_etat" |
|
|
|| $rule_name == "regle_accord_tacite" |
|
|
|| $rule_name == "regle_avis") { |
|
|
// |
|
|
return $this->valF[$rule]; |
|
|
} |
|
|
|
|
1293 |
// Tableau des champs de type date |
// Tableau des champs de type date |
1294 |
$rule_type_date = array( |
$rule_type_date = array( |
1295 |
"regle_date_limite", |
"regle_date_limite", |
1303 |
"regle_date_rejet", |
"regle_date_rejet", |
1304 |
"regle_date_dernier_depot", |
"regle_date_dernier_depot", |
1305 |
"regle_date_limite_incompletude", |
"regle_date_limite_incompletude", |
1306 |
|
"regle_date_cloture_instruction", |
1307 |
|
"regle_date_premiere_visite", |
1308 |
|
"regle_date_derniere_visite", |
1309 |
|
"regle_date_contradictoire", |
1310 |
|
"regle_date_retour_contradictoire", |
1311 |
|
"regle_date_ait", |
1312 |
|
"regle_date_transmission_parquet", |
1313 |
); |
); |
1314 |
// Tableau des champs de type numérique |
// Tableau des champs de type numérique |
1315 |
$rule_type_numeric = array( |
$rule_type_numeric = array( |
1316 |
"regle_delai", |
"regle_delai", |
1317 |
"regle_delai_incompletude", |
"regle_delai_incompletude", |
1318 |
); |
); |
1319 |
|
// Tableau des champs de type text |
1320 |
|
$rule_type_text = array( |
1321 |
|
); |
1322 |
|
// Tableau des champs de type booléen |
1323 |
|
$rule_type_bool = array( |
1324 |
|
); |
1325 |
|
// Tableau des champs spécifiques |
1326 |
|
$rule_type_specific = array( |
1327 |
|
"regle_autorite_competente", |
1328 |
|
"regle_etat", |
1329 |
|
"regle_accord_tacite", |
1330 |
|
"regle_avis", |
1331 |
|
); |
1332 |
|
// Tableau des champs de données techniques |
1333 |
|
$rule_type_technical_data = array( |
1334 |
|
'regle_donnees_techniques1', |
1335 |
|
'regle_donnees_techniques2', |
1336 |
|
'regle_donnees_techniques3', |
1337 |
|
'regle_donnees_techniques4', |
1338 |
|
'regle_donnees_techniques5', |
1339 |
|
); |
1340 |
|
|
1341 |
// Définit le type du champ |
// Définit le type du champ |
1342 |
if (in_array($rule_name, $rule_type_date) == true) { |
if (in_array($rule_name, $rule_type_date) == true) { |
1345 |
if (in_array($rule_name, $rule_type_numeric) == true) { |
if (in_array($rule_name, $rule_type_numeric) == true) { |
1346 |
$type = "numeric"; |
$type = "numeric"; |
1347 |
} |
} |
1348 |
|
if (in_array($rule_name, $rule_type_text) === true) { |
1349 |
|
$type = "text"; |
1350 |
|
} |
1351 |
|
if (in_array($rule_name, $rule_type_bool) === true) { |
1352 |
|
$type = "bool"; |
1353 |
|
} |
1354 |
|
if (in_array($rule_name, $rule_type_specific) === true) { |
1355 |
|
$type = "specific"; |
1356 |
|
} |
1357 |
|
if (in_array($rule_name, $rule_type_technical_data) === true) { |
1358 |
|
$type = 'text'; |
1359 |
|
} |
1360 |
|
|
1361 |
|
// Si c'est un type spécifique ou booléen alors il n'a qu'un opérande |
1362 |
|
// Récupère directement la valeur de l'opérande |
1363 |
|
if ($type === 'specific' || $type === 'bool') { |
1364 |
|
// |
1365 |
|
return $this->get_value_for_rule($rule); |
1366 |
|
} |
1367 |
|
|
1368 |
// Initialisation des variables |
// Initialisation des variables |
1369 |
$key_date = 0; |
$key_date = 0; |
1370 |
$total_numeric = 0; |
$total_numeric = 0; |
1371 |
|
$res_text = ''; |
1372 |
|
|
1373 |
// Pour chaque opérande |
// Pour chaque opérande |
1374 |
foreach ($operands as $key => $operand) { |
foreach ($operands as $key => $operand) { |
1376 |
// Si c'est une règle de type date |
// Si c'est une règle de type date |
1377 |
if ($type == 'date') { |
if ($type == 'date') { |
1378 |
// Vérifie si au moins une des opérandes est une date |
// Vérifie si au moins une des opérandes est une date |
1379 |
if (!is_numeric($operand) |
if (is_numeric($operand) === false |
1380 |
&& isset($this->valF[$operand]) |
&& $this->get_value_for_rule($operand) !== null |
1381 |
&& $this->f->check_date($this->valF[$operand]) == true) { |
&& $this->f->check_date($this->get_value_for_rule($operand)) == true) { |
1382 |
// Récupère la position de la date |
// Récupère la position de la date |
1383 |
$key_date = $key; |
$key_date = $key; |
1384 |
} |
} |
1387 |
// Ajoute l'opérande au total |
// Ajoute l'opérande au total |
1388 |
$total_numeric += $operand; |
$total_numeric += $operand; |
1389 |
} |
} |
1390 |
if (!is_numeric($operand) |
if (is_numeric($operand) === false |
1391 |
&& isset($this->valF[$operand]) |
&& $this->get_value_for_rule($operand) !== null |
1392 |
&& is_numeric($this->valF[$operand]) == true) { |
&& is_numeric($this->get_value_for_rule($operand)) == true) { |
1393 |
// Ajoute l'opérande au total |
// Ajoute l'opérande au total |
1394 |
$total_numeric += $this->valF[$operand]; |
$total_numeric += $this->get_value_for_rule($operand); |
1395 |
} |
} |
1396 |
} |
} |
1397 |
|
|
1402 |
// Ajoute l'opérande au total |
// Ajoute l'opérande au total |
1403 |
$total_numeric += $operand; |
$total_numeric += $operand; |
1404 |
} |
} |
1405 |
if (!is_numeric($operand) |
if (is_numeric($operand) === false |
1406 |
&& isset($this->valF[$operand]) |
&& $this->get_value_for_rule($operand) !== null |
1407 |
&& is_numeric($this->valF[$operand]) == true) { |
&& is_numeric($this->get_value_for_rule($operand)) == true) { |
1408 |
// Ajoute l'opérande au total |
// Ajoute l'opérande au total |
1409 |
$total_numeric += $this->valF[$operand]; |
$total_numeric += $this->get_value_for_rule($operand); |
1410 |
} |
} |
1411 |
} |
} |
1412 |
|
|
1413 |
|
// Si c'est une règle de type text |
1414 |
|
if ($type === 'text') { |
1415 |
|
// Concatène toutes les chaînes de caractère |
1416 |
|
$res_text .= $this->get_value_for_rule($operand); |
1417 |
|
} |
1418 |
} |
} |
1419 |
|
|
1420 |
// Résultat pour une règle de type date |
// Résultat pour une règle de type date |
1429 |
// Retourne le calcul |
// Retourne le calcul |
1430 |
return $total_numeric; |
return $total_numeric; |
1431 |
} |
} |
1432 |
|
|
1433 |
|
// Résultat pour une règle de type text |
1434 |
|
if ($type === 'text') { |
1435 |
|
// Retourne la chaîne de caractère |
1436 |
|
return $res_text; |
1437 |
|
} |
1438 |
|
} |
1439 |
|
|
1440 |
|
|
1441 |
|
/** |
1442 |
|
* Récupère la valeur du champs dans l'instruction ou dans les données |
1443 |
|
* techniques. |
1444 |
|
* Spécifique au calcul des règles. |
1445 |
|
* |
1446 |
|
* @param string $field Champ |
1447 |
|
* |
1448 |
|
* @return mixed Valeur du champ |
1449 |
|
*/ |
1450 |
|
private function get_value_for_rule($field) { |
1451 |
|
// Si le champ n'existe pas dans la table instruction |
1452 |
|
if (array_key_exists($field, $this->valF) === false) { |
1453 |
|
// Récupère l'instance de la classe donnees_techniques |
1454 |
|
$inst_donnees_techniques = $this->get_inst_donnees_techniques(); |
1455 |
|
// Retourne la valeur de la donnée technique |
1456 |
|
return $inst_donnees_techniques->getVal($field); |
1457 |
|
} |
1458 |
|
|
1459 |
|
// |
1460 |
|
return $this->valF[$field]; |
1461 |
|
} |
1462 |
|
|
1463 |
|
|
1464 |
|
/** |
1465 |
|
* [get_inst_donnees_techniques description] |
1466 |
|
* |
1467 |
|
* @param [type] $donnees_techniques [description] |
1468 |
|
* |
1469 |
|
* @return [type] [description] |
1470 |
|
*/ |
1471 |
|
function get_inst_donnees_techniques($donnees_techniques = null) { |
1472 |
|
// |
1473 |
|
if (isset($this->inst_donnees_techniques) === false or |
1474 |
|
$this->inst_donnees_techniques === null) { |
1475 |
|
// |
1476 |
|
if (is_null($donnees_techniques)) { |
1477 |
|
$donnees_techniques = $this->getDonneesTechniques(); |
1478 |
|
} |
1479 |
|
// |
1480 |
|
require_once "../obj/donnees_techniques.class.php"; |
1481 |
|
$this->inst_donnees_techniques = new donnees_techniques($donnees_techniques); |
1482 |
|
} |
1483 |
|
// |
1484 |
|
return $this->inst_donnees_techniques; |
1485 |
|
} |
1486 |
|
|
1487 |
|
|
1488 |
|
/** |
1489 |
|
* Retourne l'identifiant des données techniques liées du dossier |
1490 |
|
* @return string L'identifiant des données techniques liées du dossier |
1491 |
|
*/ |
1492 |
|
function getDonneesTechniques() { |
1493 |
|
|
1494 |
|
$donnees_techniques = ''; |
1495 |
|
|
1496 |
|
$sql = "SELECT donnees_techniques |
1497 |
|
FROM ".DB_PREFIXE."donnees_techniques |
1498 |
|
WHERE dossier_instruction ='".$this->valF["dossier"]."'"; |
1499 |
|
$donnees_techniques = $this->db->getOne($sql); |
1500 |
|
$this->f->addToLog("getStatut() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
1501 |
|
if ( database::isError($donnees_techniques)){ |
1502 |
|
die(); |
1503 |
|
} |
1504 |
|
|
1505 |
|
return $donnees_techniques; |
1506 |
} |
} |
1507 |
|
|
1508 |
function triggerajouterapres($id,&$db,$val,$DEBUG) { |
|
1509 |
|
/** |
1510 |
|
* TRIGGER - triggerajouterapres. |
1511 |
|
* |
1512 |
|
* - Mise à jour des informations liées au workflow sur le dossier |
1513 |
|
* - Interface avec le référentiel ERP [105][111] |
1514 |
|
* - Mise à jour du DA |
1515 |
|
* - Historisation de la vie du DI |
1516 |
|
* |
1517 |
|
* @return boolean |
1518 |
|
*/ |
1519 |
|
function triggerajouterapres($id, &$db, $val, $DEBUG) { |
1520 |
|
|
1521 |
|
// On a besoin de l'instance du dossier lié à l'événement d'instruction |
1522 |
|
$inst_di = $this->get_inst_dossier($this->valF['dossier']); |
1523 |
|
|
1524 |
|
// Instance de la classe evenement |
1525 |
|
$inst_evenement = $this->get_inst_evenement($this->valF['evenement']); |
1526 |
|
|
1527 |
/** |
/** |
1528 |
* Mise à jour des valeurs du dossier en fonction des valeurs calculées |
* Mise à jour des valeurs du dossier en fonction des valeurs calculées |
1529 |
* par l'action |
* par l'action |
1530 |
*/ |
*/ |
1531 |
$this->getValEvenement(); |
// état de complétude actuel du dossier |
1532 |
|
$incompletude = ($inst_di->getVal('incompletude') == 't' ? true : false); |
1533 |
// Initialisation |
// Initialisation |
1534 |
$valF = ""; |
$valF = ""; |
1535 |
// état de complétude actuel du dossier |
$valF_dt = ""; |
1536 |
$incompletude = $this->dossierIncomplet(); |
// |
|
|
|
1537 |
if($incompletude === FALSE) { |
if($incompletude === FALSE) { |
1538 |
// Si l'événement d'instruction est de type incompletude |
// Si l'événement d'instruction est de type incompletude |
1539 |
if($this->valEvenement['type'] == "incompletude") { |
if($inst_evenement->getVal('type') == "incompletude") { |
1540 |
// On marque le dossier en incomplétude pour application des actions |
// On marque le dossier en incomplétude pour application des actions |
1541 |
$incompletude = TRUE; |
$incompletude = TRUE; |
1542 |
// Set du flag incomplétude de la table dossier |
// Set du flag incomplétude de la table dossier |
1547 |
} else { |
} else { |
1548 |
// Si l'evenement d'instruction est de type retour ou contient une |
// Si l'evenement d'instruction est de type retour ou contient une |
1549 |
// decision, on sort d'incomplétude |
// decision, on sort d'incomplétude |
1550 |
if($this->valEvenement['type'] == "retour" OR |
if($inst_evenement->getVal('type') == "retour" OR |
1551 |
$this->valEvenement['avis_decision'] != NULL) { |
$inst_evenement->getVal('avis_decision') != NULL) { |
1552 |
// On enlève la marque d'incomplétude pour application des actions |
// On enlève la marque d'incomplétude pour application des actions |
1553 |
$incompletude = FALSE; |
$incompletude = FALSE; |
1554 |
// On enlève le flag d'incomplétude sur l'enregistrement de la table dossier |
// On enlève le flag d'incomplétude sur l'enregistrement de la table dossier |
1575 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
1576 |
|
|
1577 |
// pour chacune des regles, on applique la regle |
// pour chacune des regles, on applique la regle |
1578 |
if($row['regle_delai']!=''){ |
if ($row['regle_delai'] != '') { |
1579 |
$valF['delai'] = $this->regle($row['regle_delai'], 'regle_delai'); |
$valF['delai'] = $this->regle($row['regle_delai'], 'regle_delai'); |
1580 |
} |
} |
1581 |
if($row['regle_accord_tacite']!=''){ |
if ($row['regle_accord_tacite'] != '') { |
1582 |
$valF['accord_tacite'] = $this->regle($row['regle_accord_tacite'], 'regle_accord_tacite'); |
$valF['accord_tacite'] = $this->regle($row['regle_accord_tacite'], 'regle_accord_tacite'); |
1583 |
} |
} |
1584 |
if($row['regle_avis']!=''){ |
if ($row['regle_avis'] != '') { |
1585 |
$valF['avis_decision'] = $this->regle($row['regle_avis'], 'regle_avis'); |
$valF['avis_decision'] = $this->regle($row['regle_avis'], 'regle_avis'); |
1586 |
} |
} |
1587 |
if($row['regle_date_limite']!=''){ |
if ($row['regle_date_limite'] != '') { |
1588 |
$valF['date_limite']= $this->regle($row['regle_date_limite'], 'regle_date_limite'); |
$valF['date_limite'] = $this->regle($row['regle_date_limite'], 'regle_date_limite'); |
1589 |
} |
} |
1590 |
if($row['regle_date_complet']!=''){ |
if ($row['regle_date_complet'] != '') { |
1591 |
$valF['date_complet']= $this->regle($row['regle_date_complet'], 'regle_date_complet'); |
$valF['date_complet'] = $this->regle($row['regle_date_complet'], 'regle_date_complet'); |
1592 |
} |
} |
1593 |
if($row['regle_date_dernier_depot']!=''){ |
if ($row['regle_date_dernier_depot'] != '') { |
1594 |
$valF['date_dernier_depot']= $this->regle($row['regle_date_dernier_depot'], 'regle_date_dernier_depot'); |
$valF['date_dernier_depot'] = $this->regle($row['regle_date_dernier_depot'], 'regle_date_dernier_depot'); |
1595 |
} |
} |
1596 |
if($row['regle_date_notification_delai']!=''){ |
if ($row['regle_date_notification_delai'] != '') { |
1597 |
$valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai'], 'regle_date_notification_delai'); |
$valF['date_notification_delai'] = $this->regle($row['regle_date_notification_delai'], 'regle_date_notification_delai'); |
1598 |
} |
} |
1599 |
if($row['regle_date_decision']!=''){ |
if ($row['regle_date_decision'] != '') { |
1600 |
$valF['date_decision']= $this->regle($row['regle_date_decision'], 'regle_date_decision'); |
$valF['date_decision'] = $this->regle($row['regle_date_decision'], 'regle_date_decision'); |
1601 |
} |
} |
1602 |
if($row['regle_date_rejet']!=''){ |
if ($row['regle_date_rejet'] != '') { |
1603 |
$valF['date_rejet']= $this->regle($row['regle_date_rejet'], 'regle_date_rejet'); |
$valF['date_rejet'] = $this->regle($row['regle_date_rejet'], 'regle_date_rejet'); |
1604 |
} |
} |
1605 |
if($row['regle_date_validite']!=''){ |
if ($row['regle_date_validite'] != '') { |
1606 |
$valF['date_validite']= $this->regle($row['regle_date_validite'], 'regle_date_validite'); |
$valF['date_validite'] = $this->regle($row['regle_date_validite'], 'regle_date_validite'); |
1607 |
} |
} |
1608 |
if($row['regle_date_chantier']!=''){ |
if ($row['regle_date_chantier'] != '') { |
1609 |
$valF['date_chantier']= $this->regle($row['regle_date_chantier'], 'regle_date_chantier'); |
$valF['date_chantier'] = $this->regle($row['regle_date_chantier'], 'regle_date_chantier'); |
1610 |
} |
} |
1611 |
if($row['regle_date_achevement']!=''){ |
if ($row['regle_date_achevement'] != '') { |
1612 |
$valF['date_achevement']= $this->regle($row['regle_date_achevement'], 'regle_date_achevement'); |
$valF['date_achevement'] = $this->regle($row['regle_date_achevement'], 'regle_date_achevement'); |
1613 |
} |
} |
1614 |
if($row['regle_date_conformite']!=''){ |
if ($row['regle_date_conformite'] != '') { |
1615 |
$valF['date_conformite']= $this->regle($row['regle_date_conformite'], 'regle_date_conformite'); |
$valF['date_conformite'] = $this->regle($row['regle_date_conformite'], 'regle_date_conformite'); |
1616 |
} |
} |
1617 |
if($row['regle_date_limite_incompletude']!=''){ |
if ($row['regle_date_limite_incompletude'] != '') { |
1618 |
$valF['date_limite_incompletude']= $this->regle($row['regle_date_limite_incompletude'], 'regle_date_limite_incompletude'); |
$valF['date_limite_incompletude'] = $this->regle($row['regle_date_limite_incompletude'], 'regle_date_limite_incompletude'); |
1619 |
} |
} |
1620 |
if($row['regle_delai_incompletude']!=''){ |
if ($row['regle_delai_incompletude'] != '') { |
1621 |
$valF['delai_incompletude']= $this->regle($row['regle_delai_incompletude'], 'regle_delai_incompletude'); |
$valF['delai_incompletude'] = $this->regle($row['regle_delai_incompletude'], 'regle_delai_incompletude'); |
1622 |
} |
} |
1623 |
if($row['regle_autorite_competente']!=''){ |
if ($row['regle_autorite_competente'] != '') { |
1624 |
$valF['autorite_competente']= $this->regle($row['regle_autorite_competente'], 'regle_autorite_competente'); |
$valF['autorite_competente'] = $this->regle($row['regle_autorite_competente'], 'regle_autorite_competente'); |
1625 |
} |
} |
1626 |
if($row['regle_etat']!=''){ |
if ($row['regle_etat'] != '') { |
1627 |
// Si on est dans le cas général ou qu'on est en incomplétude et |
// Si on est dans le cas général ou qu'on est en incomplétude et |
1628 |
// qu'on a un événement de type incomplétude alors : on stocke |
// qu'on a un événement de type incomplétude alors : on stocke |
1629 |
// l'état dans la variable courante |
// l'état dans la variable courante |
1630 |
if ($incompletude == FALSE OR $this->valEvenement['type'] == "incompletude") { |
if ($incompletude == FALSE OR $inst_evenement->getVal('type') == "incompletude") { |
1631 |
$valF['etat'] = $this->regle($row['regle_etat'], 'regle_etat'); |
$valF['etat'] = $this->regle($row['regle_etat'], 'regle_etat'); |
1632 |
} else { |
} else { |
1633 |
$valF['etat_pendant_incompletude'] = $this->regle($row['regle_etat'], 'regle_etat'); |
$valF['etat_pendant_incompletude'] = $this->regle($row['regle_etat'], 'regle_etat'); |
1634 |
} |
} |
1635 |
} |
} |
1636 |
|
if ($row['regle_date_cloture_instruction'] !== '') { |
1637 |
|
$valF['date_cloture_instruction'] = $this->regle($row['regle_date_cloture_instruction'], 'regle_date_cloture_instruction'); |
1638 |
|
} |
1639 |
|
if ($row['regle_date_premiere_visite'] !== '') { |
1640 |
|
$valF['date_premiere_visite'] = $this->regle($row['regle_date_premiere_visite'], 'regle_date_premiere_visite'); |
1641 |
|
} |
1642 |
|
if ($row['regle_date_derniere_visite'] !== '') { |
1643 |
|
$valF['date_derniere_visite'] = $this->regle($row['regle_date_derniere_visite'], 'regle_date_derniere_visite'); |
1644 |
|
} |
1645 |
|
if ($row['regle_date_contradictoire'] !== '') { |
1646 |
|
$valF['date_contradictoire'] = $this->regle($row['regle_date_contradictoire'], 'regle_date_contradictoire'); |
1647 |
|
} |
1648 |
|
if ($row['regle_date_retour_contradictoire'] !== '') { |
1649 |
|
$valF['date_retour_contradictoire'] = $this->regle($row['regle_date_retour_contradictoire'], 'regle_date_retour_contradictoire'); |
1650 |
|
} |
1651 |
|
if ($row['regle_date_ait'] !== '') { |
1652 |
|
$valF['date_ait'] = $this->regle($row['regle_date_ait'], 'regle_date_ait'); |
1653 |
|
} |
1654 |
|
if ($row['regle_donnees_techniques1'] !== '') { |
1655 |
|
$valF_dt[$row['cible_regle_donnees_techniques1']] = $this->regle($row['regle_donnees_techniques1'], 'regle_donnees_techniques1'); |
1656 |
|
} |
1657 |
|
if ($row['regle_donnees_techniques2'] !== '') { |
1658 |
|
$valF_dt[$row['cible_regle_donnees_techniques2']] = $this->regle($row['regle_donnees_techniques2'], 'regle_donnees_techniques2'); |
1659 |
|
} |
1660 |
|
if ($row['regle_donnees_techniques3'] !== '') { |
1661 |
|
$valF_dt[$row['cible_regle_donnees_techniques3']] = $this->regle($row['regle_donnees_techniques3'], 'regle_donnees_techniques3'); |
1662 |
|
} |
1663 |
|
if ($row['regle_donnees_techniques4'] !== '') { |
1664 |
|
$valF_dt[$row['cible_regle_donnees_techniques4']] = $this->regle($row['regle_donnees_techniques4'], 'regle_donnees_techniques4'); |
1665 |
|
} |
1666 |
|
if ($row['regle_donnees_techniques5'] !== '') { |
1667 |
|
$valF_dt[$row['cible_regle_donnees_techniques5']] = $this->regle($row['regle_donnees_techniques5'], 'regle_donnees_techniques5'); |
1668 |
|
} |
1669 |
|
if ($row['regle_date_transmission_parquet'] !== '') { |
1670 |
|
$valF['date_transmission_parquet'] = $this->regle($row['regle_date_transmission_parquet'], 'regle_date_transmission_parquet'); |
1671 |
|
} |
1672 |
} |
} |
1673 |
if($this->valEvenement['evenement_suivant_tacite'] != '') { |
|
1674 |
// Si on est pas en incomplétude on stocke l'événement tacite |
// Si l'événement a un événement suivant tacite |
1675 |
//de l'événement dans la variable courante |
if($inst_evenement->getVal('evenement_suivant_tacite') != '') { |
1676 |
|
// Si le DI n'est pas en incomplétude, l'événement tacite est stocké |
1677 |
if ($incompletude == FALSE OR $this->valEvenement['type'] != "incompletude") { |
// dans le champ evenement_suivant_tacite du dossier |
1678 |
$valF['evenement_suivant_tacite'] = $this->valEvenement['evenement_suivant_tacite']; |
if ($incompletude == false OR $inst_evenement->getVal('type') != "incompletude") { |
1679 |
} else { |
// |
1680 |
$valF['evenement_suivant_tacite_incompletude'] = $this->valEvenement['evenement_suivant_tacite']; |
$valF['evenement_suivant_tacite'] = $inst_evenement->getVal('evenement_suivant_tacite'); |
1681 |
} |
} else { |
1682 |
|
// Sinon l'événement tacite est stocké dans le champ |
1683 |
|
// evenement_suivant_tacite_incompletude du dossier |
1684 |
|
$valF['evenement_suivant_tacite_incompletude'] = $inst_evenement->getVal('evenement_suivant_tacite'); |
1685 |
|
} |
1686 |
|
} |
1687 |
|
// Si des valeurs de données techniques ont été calculées alors on met à jour l'enregistrement |
1688 |
|
if ($valF_dt != "") { |
1689 |
|
$dt_id = $this->getDonneesTechniques(); |
1690 |
|
// On met à jour le dossier |
1691 |
|
$cle = " donnees_techniques='".$dt_id."'"; |
1692 |
|
$res1 = $db->autoExecute(DB_PREFIXE.'donnees_techniques', $valF_dt, DB_AUTOQUERY_UPDATE, $cle); |
1693 |
|
$this->addToLog("triggerajouterapres(): db->autoexecute(\"".DB_PREFIXE."donnees_techniques\", ".print_r($valF_dt, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
1694 |
|
if (database::isError($res1)) { |
1695 |
|
die($res->getMessage()); |
1696 |
|
} |
1697 |
|
// Affichage d'informations à l'utilisateur |
1698 |
|
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
1699 |
} |
} |
1700 |
// 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 |
1701 |
if ($valF != "") { |
if ($valF != "") { |
1711 |
} |
} |
1712 |
|
|
1713 |
/** |
/** |
1714 |
* REFERENTIEL ERP |
* Interface avec le référentiel ERP. |
1715 |
|
* |
1716 |
|
* (WS->ERP)[105] Arrêté d'un dossier PC effectué -> PC qui concerne un ERP |
1717 |
|
* (WS->ERP)[111] Décision de conformité effectuée -> PC qui concerne un ERP |
1718 |
|
* Déclencheur : |
1719 |
|
* - L'option ERP est activée |
1720 |
|
* - Le dossier est marqué comme "connecté au référentiel ERP" |
1721 |
|
* - Le dossier est de type PC |
1722 |
|
* - Le formulaire d'ajout d'un événement d'instruction est validé |
1723 |
|
* avec un événement pour lequel les services ERP doivent être |
1724 |
|
* informé |
1725 |
*/ |
*/ |
1726 |
// verification si envoi vers ERP est active |
// |
1727 |
if ($this->f->getParameter('option_erp') === 'true') { |
if ($this->f->is_option_referentiel_erp_enabled() === true |
1728 |
// la nature du dossier |
&& $inst_di->is_connected_to_referentiel_erp() === true |
1729 |
$nature_dossier = substr($this->idxformulaire,0,2); |
&& $this->f->getDATCode($this->valF['dossier']) == $this->f->getParameter('erp__dossier__nature__pc') |
1730 |
// |
&& in_array($inst_evenement->getVal($inst_evenement->clePrimaire), explode(";", $this->f->getParameter('erp__evenements__decision__pc')))) { |
|
$sql = "SELECT erp |
|
|
FROM ".DB_PREFIXE."dossier |
|
|
WHERE dossier='".$this->valF['dossier']."'"; |
|
|
$dossier_erp = $this->db->getone($sql); |
|
|
$this->addToLog("triggerajouterapres(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
|
|
if (database::isError($res)) { |
|
|
die($res->getMessage()); |
|
|
} |
|
1731 |
// |
// |
1732 |
$sql = "SELECT libelle |
$infos = array( |
1733 |
FROM ".DB_PREFIXE."evenement |
"dossier_instruction" => $this->valF['dossier'], |
1734 |
WHERE evenement='".$this->valF['evenement']."'"; |
"decision" => $inst_evenement->getVal("libelle"), |
1735 |
$evenement_libelle = $this->db->getone($sql); |
); |
|
$this->addToLog("triggerajouterapres(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
|
|
if (database::isError($res)) { |
|
|
die($res->getMessage()); |
|
|
} |
|
1736 |
// |
// |
1737 |
if ($dossier_erp == 't') { |
$ret = $this->f->send_message_to_referentiel_erp(105, $infos); |
1738 |
// envoi du message en cas d'un PC qui est ERP et sur lequel un evenement |
if ($ret !== true) { |
1739 |
// d'acceptation etait fait |
$this->cleanMessage(); |
1740 |
if ($nature_dossier == |
$this->addToMessage(_("Une erreur s'est produite lors de la notification (105) du référentiel ERP. Contactez votre administrateur.")); |
1741 |
$this->f->getParameter('erp_evenement_accepter_dossier_PC') |
return false; |
|
&& $this->valF['evenement'] == |
|
|
$this->f->getParameter('erp_evenement_accepter_sans_reserve')) { |
|
|
$msgenque = new MessageEnqueuer(); |
|
|
$msgenque->setDossierInstructionIdentifier($this->valF['dossier']); |
|
|
$msgenque->setDecision($evenement_libelle); |
|
|
$return = $msgenque->enqueueMessage($msgenque::$ERP_ARRETE_PC_EFFECTUE); |
|
|
//Si une erreur s'est produite on arrête le traitement et on |
|
|
//retourne une erreur |
|
|
if ($return !== 0){ |
|
|
|
|
|
$this->addToMessage(_("Une erreur s'est produite lors de ". |
|
|
"l'envoi du message au referentiel ERP. Merci de ". |
|
|
"contacter votre administrateur")); |
|
|
//On ne valide pas le formulaire |
|
|
$this->addToMessage("<br/>"._("SAISIE NON ENREGISTREE")."<br/>"); |
|
|
$this->correct = false; |
|
|
return false; |
|
|
} |
|
|
else { |
|
|
$this->addToMessage(_("Le message a ete transmis au ". |
|
|
"referentiel ERP.")); |
|
|
} |
|
|
} |
|
|
if ($this->valF['evenement'] == |
|
|
$this->f->getParameter('erp_evenement_refuser_dossier')) { |
|
|
$msgenque = new MessageEnqueuer(); |
|
|
$msgenque->setDossierInstructionIdentifier($this->valF['dossier']); |
|
|
$return = $msgenque->enqueueMessage($msgenque::$ERP_DECISION_CONFORMITE_EFFECTUE); |
|
|
//Si une erreur s'est produite on arrête le traitement et on |
|
|
//retourne une erreur |
|
|
if ($return !== 0){ |
|
|
|
|
|
$this->addToMessage(_("Une erreur s'est produite lors de ". |
|
|
"l'envoi du message au referentiel ERP. Merci de ". |
|
|
"contacter votre administrateur")); |
|
|
//On ne valide pas le formulaire |
|
|
$this->addToMessage("<br/>"._("SAISIE NON ENREGISTREE")."<br/>"); |
|
|
$this->correct = false; |
|
|
return false; |
|
|
} |
|
|
else { |
|
|
$this->addToMessage(_("Le message a ete transmis au ". |
|
|
"referentiel ERP.")); |
|
|
} |
|
|
} |
|
1742 |
} |
} |
1743 |
} // fin de if ($this->f->getParameter('option_erp') === 'true') |
$this->addToMessage(_("Notification (105) du référentiel ERP OK.")); |
1744 |
|
} |
1745 |
|
|
1746 |
// Mise à jour des données du dossier d'autorisation |
/** |
1747 |
require_once "../obj/dossier_autorisation.class.php"; |
* Mise à jour des données du DA. |
1748 |
$da = new dossier_autorisation($this->getNumDemandeAutorFromDossier($this->valF['dossier']), $this->db, DEBUG); |
*/ |
1749 |
if($da->majDossierAutorisation() === false) { |
// |
1750 |
|
$inst_da = $inst_di->get_inst_dossier_autorisation(); |
1751 |
|
// |
1752 |
|
if ($inst_da->majDossierAutorisation() === false) { |
1753 |
$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.")); |
1754 |
$this->correct = false; |
$this->correct = false; |
1755 |
return false; |
return false; |
1756 |
} |
} |
1757 |
} |
|
1758 |
|
/** |
1759 |
|
* Historisation de la vie du DI. |
1760 |
|
*/ |
1761 |
|
// |
1762 |
|
return $this->add_log_to_dossier($id, array_merge($val, $this->valF)); |
1763 |
|
} |
1764 |
|
|
1765 |
function triggermodifierapres($id,&$db,$val,$DEBUG) { |
function triggermodifierapres($id,&$db,$val,$DEBUG) { |
1766 |
/** |
/** |
1769 |
*/ |
*/ |
1770 |
// Initialisation |
// Initialisation |
1771 |
$valF = ""; |
$valF = ""; |
1772 |
|
$valF_dt = ""; |
1773 |
// Initialisation du type d'événement |
// Initialisation du type d'événement |
1774 |
$type_evmt = ""; |
$type_evmt = ""; |
1775 |
// Récupération de l'action correspondante à l'événement |
// Récupération de l'action correspondante à l'événement |
1822 |
if(preg_match("/date_evenement/",$row['regle_date_conformite'])){ |
if(preg_match("/date_evenement/",$row['regle_date_conformite'])){ |
1823 |
$valF['date_conformite']= $this->regle($row['regle_date_conformite'], 'regle_date_conformite'); |
$valF['date_conformite']= $this->regle($row['regle_date_conformite'], 'regle_date_conformite'); |
1824 |
} |
} |
1825 |
|
if(preg_match("/date_evenement/",$row['regle_date_cloture_instruction'])){ |
1826 |
|
$valF['date_cloture_instruction']= $this->regle($row['regle_date_cloture_instruction'], 'regle_date_cloture_instruction'); |
1827 |
|
} |
1828 |
|
if(preg_match("/date_evenement/",$row['regle_date_premiere_visite'])){ |
1829 |
|
$valF['date_premiere_visite']= $this->regle($row['regle_date_premiere_visite'], 'regle_date_premiere_visite'); |
1830 |
|
} |
1831 |
|
if(preg_match("/date_evenement/",$row['regle_date_derniere_visite'])){ |
1832 |
|
$valF['date_derniere_visite']= $this->regle($row['regle_date_derniere_visite'], 'regle_date_derniere_visite'); |
1833 |
|
} |
1834 |
|
if(preg_match("/date_evenement/",$row['regle_date_contradictoire'])){ |
1835 |
|
$valF['date_contradictoire']= $this->regle($row['regle_date_contradictoire'], 'regle_date_contradictoire'); |
1836 |
|
} |
1837 |
|
if(preg_match("/date_evenement/",$row['regle_date_retour_contradictoire'])){ |
1838 |
|
$valF['date_retour_contradictoire']= $this->regle($row['regle_date_retour_contradictoire'], 'regle_date_retour_contradictoire'); |
1839 |
|
} |
1840 |
|
if(preg_match("/date_evenement/",$row['regle_date_ait'])){ |
1841 |
|
$valF['date_ait']= $this->regle($row['regle_date_ait'], 'regle_date_ait'); |
1842 |
|
} |
1843 |
|
if(preg_match("/date_evenement/",$row['regle_date_transmission_parquet'])){ |
1844 |
|
$valF['date_transmission_parquet']= $this->regle($row['regle_date_transmission_parquet'], 'regle_date_transmission_parquet'); |
1845 |
|
} |
1846 |
|
if ($row['regle_donnees_techniques1'] !== '') { |
1847 |
|
$valF_dt[$row['cible_regle_donnees_techniques1']] = $this->regle($row['regle_donnees_techniques1'], 'regle_donnees_techniques1'); |
1848 |
|
} |
1849 |
|
if ($row['regle_donnees_techniques2'] !== '') { |
1850 |
|
$valF_dt[$row['cible_regle_donnees_techniques2']] = $this->regle($row['regle_donnees_techniques2'], 'regle_donnees_techniques2'); |
1851 |
|
} |
1852 |
|
if ($row['regle_donnees_techniques3'] !== '') { |
1853 |
|
$valF_dt[$row['cible_regle_donnees_techniques3']] = $this->regle($row['regle_donnees_techniques3'], 'regle_donnees_techniques3'); |
1854 |
|
} |
1855 |
|
if ($row['regle_donnees_techniques4'] !== '') { |
1856 |
|
$valF_dt[$row['cible_regle_donnees_techniques4']] = $this->regle($row['regle_donnees_techniques4'], 'regle_donnees_techniques4'); |
1857 |
|
} |
1858 |
|
if ($row['regle_donnees_techniques5'] !== '') { |
1859 |
|
$valF_dt[$row['cible_regle_donnees_techniques5']] = $this->regle($row['regle_donnees_techniques5'], 'regle_donnees_techniques5'); |
1860 |
|
} |
1861 |
|
} |
1862 |
|
// Si des valeurs de données techniques ont été calculées alors on met à jour l'enregistrement |
1863 |
|
if ($valF_dt != "") { |
1864 |
|
$dt_id = $this->getDonneesTechniques(); |
1865 |
|
// On met à jour le dossier |
1866 |
|
$cle = " donnees_techniques='".$dt_id."'"; |
1867 |
|
$res1 = $db->autoExecute(DB_PREFIXE.'donnees_techniques', $valF_dt, DB_AUTOQUERY_UPDATE, $cle); |
1868 |
|
$this->addToLog("triggerajouterapres(): db->autoexecute(\"".DB_PREFIXE."donnees_techniques\", ".print_r($valF_dt, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
1869 |
|
if (database::isError($res1)) { |
1870 |
|
die($res->getMessage()); |
1871 |
|
} |
1872 |
|
// Affichage d'informations à l'utilisateur |
1873 |
|
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
1874 |
} |
} |
1875 |
// 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 |
1876 |
if ($valF != "") { |
if ($valF != "") { |
1897 |
if (database::isError($res)) { |
if (database::isError($res)) { |
1898 |
die($res->getMessage()); |
die($res->getMessage()); |
1899 |
} |
} |
1900 |
|
$current_id = $this->getVal($this->clePrimaire); |
1901 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
1902 |
// Si la date de retour signature est éditée on vérifie si il existe un événement automatique |
// Si la date de retour signature est éditée on vérifie si il existe un événement automatique |
1903 |
if ($this->getVal('date_retour_signature') == "" AND |
if ($this->getVal('date_retour_signature') == "" AND |
1919 |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
1920 |
$valNewInstr["date_envoi_controle_legalite"] = $this->f->formatDate($this->valF['date_envoi_controle_legalite']); |
$valNewInstr["date_envoi_controle_legalite"] = $this->f->formatDate($this->valF['date_envoi_controle_legalite']); |
1921 |
$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']); |
1922 |
|
$new_instruction->setParameter("maj", 0); |
1923 |
|
$new_instruction->class_actions[0]["identifier"] = |
1924 |
|
"retour signature de l'instruction $current_id"; |
1925 |
$retour = $new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
$retour = $new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
1926 |
|
|
1927 |
//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 |
1961 |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
1962 |
$valNewInstr["date_envoi_controle_legalite"] = $this->f->formatDate($this->valF['date_envoi_controle_legalite']); |
$valNewInstr["date_envoi_controle_legalite"] = $this->f->formatDate($this->valF['date_envoi_controle_legalite']); |
1963 |
$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']); |
1964 |
$new_instruction->setParameter("maj", $this->getParameter("maj")); |
$new_instruction->setParameter("maj", 0); |
1965 |
|
$new_instruction->class_actions[0]["identifier"] = |
1966 |
|
"retour RAR de l'instruction $current_id"; |
1967 |
$retour = $new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
$retour = $new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
1968 |
|
|
1969 |
//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 |
2011 |
} |
} |
2012 |
} |
} |
2013 |
|
|
|
//Récupération du type de l'événement |
|
|
$sql = "SELECT type |
|
|
FROM ".DB_PREFIXE."evenement |
|
|
WHERE evenement=".$this->valF['evenement']; |
|
|
$type_evmt = $db->getOne($sql); |
|
|
$this->addToLog("triggermodifierapres(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
|
|
if (database::isError($type_evmt)) { |
|
|
die($type_evmt->getMessage()); |
|
|
} |
|
|
|
|
|
/** |
|
|
* REFERENTIEL ARRETE |
|
|
*/ |
|
|
// Si l'option référentiel arrêté est activé et l'événement est de type |
|
|
// arrêté |
|
|
|
|
|
if ($this->f->getParameter('option_referentiel_arrete') === 'true' AND |
|
|
$type_evmt == "arrete") { |
|
|
if ($this->valF['date_retour_signature'] != $this->getVal('date_retour_signature')) { |
|
|
$msgenque = new MessageEnqueuer(); |
|
|
$sqlArrete = "SELECT instruction.signataire_arrete as \"ws_DA_In_Signataire\", |
|
|
signataire_arrete.nom as \"ws_DA_In_Sign_Nom\", |
|
|
signataire_arrete.prenom as \"ws_DA_In_Sign_Prenom\", |
|
|
signataire_arrete.qualite as \"ws_DA_In_Sign_Qualite\", |
|
|
instruction.date_evenement as \"ws_DA_In_Dte_Redac\", |
|
|
'' as \"ws_DA_In_lieu_Redac\", |
|
|
instruction.dossier as \"ws_DA_In_N_Doss_DAS\", |
|
|
'' as \"ws_DA_In_Sigle\", |
|
|
instruction.etat as \"ws_DA_In_Decision\", |
|
|
dossier.date_depot as \"ws_DA_In_Dte_Depot_Dem\", |
|
|
dossier.terrain_adresse_voie_numero as \"ws_DA_In_N_Voie\", |
|
|
'' as \"ws_DA_In_Type_Voie\", |
|
|
dossier.terrain_adresse_voie as \"ws_DA_In_Adresse1\", |
|
|
dossier.terrain_adresse_lieu_dit as \"ws_DA_In_Adresse2\", |
|
|
dossier.terrain_adresse_code_postal as \"ws_DA_In_CP\", |
|
|
dossier.terrain_adresse_localite as \"ws_DA_In_Ville\", |
|
|
dossier.terrain_references_cadastrales as \"ws_DA_In_Nb_Parcelle\", |
|
|
'' as \"ws_DA_In_Detail_Parcelle\", |
|
|
CONCAT(donnees_techniques.am_projet_desc,' ',donnees_techniques.co_projet_desc) as \"ws_DA_In_Nature_Trvx\", |
|
|
'' as \"ws_DA_In_Destination_Trvx\", |
|
|
dossier_autorisation_type_detaille.code as \"ws_DA_In_Type_Dos_Autoris\", |
|
|
COALESCE(particulier_nom,personne_morale_raison_sociale) as \"ws_DA_In_Nom_Petition\", |
|
|
COALESCE(particulier_prenom, personne_morale_denomination) as \"ws_DA_In_Prenom_Petition\", |
|
|
'' as \"ws_DA_In_Piece_GED\", |
|
|
instruction.date_retour_signature as \"ws_DA_In_Dte_Signature\" |
|
|
FROM ".DB_PREFIXE."instruction |
|
|
LEFT JOIN ".DB_PREFIXE."signataire_arrete ON |
|
|
instruction.signataire_arrete = signataire_arrete.signataire_arrete |
|
|
LEFT JOIN ".DB_PREFIXE."dossier ON |
|
|
instruction.dossier = dossier.dossier |
|
|
LEFT JOIN ".DB_PREFIXE."lien_dossier_demandeur ON |
|
|
lien_dossier_demandeur.dossier = dossier.dossier |
|
|
LEFT JOIN ".DB_PREFIXE."demandeur ON |
|
|
lien_dossier_demandeur.demandeur = demandeur.demandeur |
|
|
LEFT JOIN ".DB_PREFIXE."dossier_instruction_type ON |
|
|
dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
|
|
LEFT JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille ON |
|
|
dossier_instruction_type.dossier_autorisation_type_detaille = |
|
|
dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
|
|
LEFT JOIN ".DB_PREFIXE."donnees_techniques ON |
|
|
donnees_techniques.dossier_instruction = dossier.dossier |
|
|
WHERE instruction.instruction = ".$this->valF['instruction']; |
|
|
$resArrete = $this->db->query($sqlArrete); |
|
|
$this->f->addToLog("triggermodifierapres(): db->query(\"".$sqlArrete."\");", VERBOSE_MODE); |
|
|
if ( database::isError($resArrete)){ |
|
|
die(); |
|
|
} |
|
|
|
|
|
$rowArrete = $resArrete->fetchRow(DB_FETCHMODE_ASSOC); |
|
|
$msgenque->setArreteInfo($rowArrete); |
|
|
$return = $msgenque->enqueueMessage($msgenque::$ARRETE_ENVOI); |
|
|
//Si une erreur s'est produite on arrête le traitement et on |
|
|
//retourne une erreur |
|
|
if ($return !== 0){ |
|
|
|
|
|
//On supprime les messages précédents |
|
|
$this->msg = ''; |
|
|
$this->addToMessage(_("Une erreur s'est produite lors de ". |
|
|
"l'envoi du message au referentiel arrêté. Merci de ". |
|
|
"contacter votre administrateur.")); |
|
|
//On ne valide pas le formulaire |
|
|
$this->addToMessage("<br/>"._("SAISIE NON ENREGISTREE")."<br/>"); |
|
|
$this->correct = false; |
|
|
return false; |
|
|
} |
|
|
else { |
|
|
$this->addToMessage(_("Le message a ete transmis au ". |
|
|
"referentiel arrêté.")); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
2014 |
// Mise à jour des données du dossier d'autorisation |
// Mise à jour des données du dossier d'autorisation |
2015 |
require_once "../obj/dossier_autorisation.class.php"; |
require_once "../obj/dossier_autorisation.class.php"; |
2016 |
$da = new dossier_autorisation($this->getNumDemandeAutorFromDossier($this->valF['dossier']), $this->db, DEBUG); |
$da = new dossier_autorisation($this->getNumDemandeAutorFromDossier($this->valF['dossier']), $this->db, DEBUG); |
2019 |
$this->correct = false; |
$this->correct = false; |
2020 |
return false; |
return false; |
2021 |
} |
} |
2022 |
} |
return $this->add_log_to_dossier($id, $val); |
2023 |
|
} |
2024 |
|
|
2025 |
function triggersupprimer($id,&$db,$val,$DEBUG) { |
function triggersupprimer($id,&$db,$val,$DEBUG) { |
2026 |
/** |
/** |
2029 |
* d'instruction |
* d'instruction |
2030 |
*/ |
*/ |
2031 |
|
|
2032 |
// Mise à jour des 4 valeurs modifiées par l'action |
// Mise à jour des 4 valeurs modifiées par l'action |
2033 |
$valF['delai'] = $val['archive_delai']; |
$valF['delai'] = $val['archive_delai']; |
2034 |
$valF['accord_tacite'] = $val['archive_accord_tacite']; |
$valF['accord_tacite'] = $val['archive_accord_tacite']; |
2035 |
$valF['etat'] = $val['archive_etat']; |
$valF['etat'] = $val['archive_etat']; |
2036 |
if ($val['archive_avis'] != '') { |
if ($val['archive_avis'] != '') { |
2037 |
$valF['avis_decision'] = $val['archive_avis']; |
$valF['avis_decision'] = $val['archive_avis']; |
2038 |
} else { |
} else { |
2039 |
$valF['avis_decision'] = NULL; |
$valF['avis_decision'] = null; |
2040 |
} |
} |
2041 |
// Mise à jour des 10 dates avec la valeur présente dans le formulaire |
// Mise à jour des dates avec la valeur présente dans le formulaire |
2042 |
// de suppression. Si la valeur de la date est vide alors on fixe |
// de suppression. Si la valeur de la date est vide alors on fixe |
2043 |
// à la valeur NULL |
// à la valeur null |
2044 |
// |
if ($val['archive_date_complet'] != '') { |
2045 |
if ($val['archive_date_complet'] != '') { |
$valF['date_complet'] = $val['archive_date_complet']; |
2046 |
$valF['date_complet'] = $val['archive_date_complet']; |
} else { |
2047 |
} else { |
$valF['date_complet'] = null; |
2048 |
$valF['date_complet'] = NULL; |
} |
2049 |
} |
if ($val['archive_date_dernier_depot'] != '') { |
2050 |
if ($val['archive_date_dernier_depot'] != '') { |
$valF['date_dernier_depot'] = $val['archive_date_dernier_depot']; |
2051 |
$valF['date_dernier_depot'] = $val['archive_date_dernier_depot']; |
} else { |
2052 |
} else { |
$valF['date_dernier_depot'] = null; |
2053 |
$valF['date_dernier_depot'] = NULL; |
} |
2054 |
} |
if ($val['archive_date_rejet'] != '') { |
2055 |
if ($val['archive_date_rejet'] != '') { |
$valF['date_rejet'] = $val['archive_date_rejet']; |
2056 |
$valF['date_rejet'] = $val['archive_date_rejet']; |
} else { |
2057 |
} else { |
$valF['date_rejet'] = null; |
2058 |
$valF['date_rejet'] = NULL; |
} |
2059 |
} |
if ($val['archive_date_limite'] != '') { |
2060 |
if ($val['archive_date_limite'] != '') { |
$valF['date_limite'] = $val['archive_date_limite']; |
2061 |
$valF['date_limite'] = $val['archive_date_limite']; |
} else { |
2062 |
} else { |
$valF['date_limite'] = null; |
2063 |
$valF['date_limite'] = NULL; |
} |
2064 |
} |
if ($val['archive_date_notification_delai'] != '') { |
2065 |
if ($val['archive_date_notification_delai'] != '') { |
$valF['date_notification_delai'] = $val['archive_date_notification_delai']; |
2066 |
$valF['date_notification_delai'] = $val['archive_date_notification_delai']; |
} else { |
2067 |
} else { |
$valF['date_notification_delai'] = null; |
2068 |
$valF['date_notification_delai'] = NULL; |
} |
2069 |
} |
if ($val['archive_date_decision'] != '') { |
2070 |
if ($val['archive_date_decision'] != '') { |
$valF['date_decision'] = $val['archive_date_decision']; |
2071 |
$valF['date_decision'] = $val['archive_date_decision']; |
} else { |
2072 |
} else { |
$valF['date_decision'] = null; |
2073 |
$valF['date_decision'] = NULL; |
} |
2074 |
} |
if ($val['archive_date_validite'] != '') { |
2075 |
if ($val['archive_date_validite'] != '') { |
$valF['date_validite'] = $val['archive_date_validite']; |
2076 |
$valF['date_validite'] = $val['archive_date_validite']; |
} else { |
2077 |
} else { |
$valF['date_validite'] = null; |
2078 |
$valF['date_validite'] = NULL; |
} |
2079 |
} |
if ($val['archive_date_achevement'] != '') { |
2080 |
if ($val['archive_date_achevement'] != '') { |
$valF['date_achevement'] = $val['archive_date_achevement']; |
2081 |
$valF['date_achevement'] = $val['archive_date_achevement']; |
} else { |
2082 |
} else { |
$valF['date_achevement'] = null; |
2083 |
$valF['date_achevement'] = NULL; |
} |
2084 |
} |
if ($val['archive_date_chantier'] != '') { |
2085 |
if ($val['archive_date_chantier'] != '') { |
$valF['date_chantier'] = $val['archive_date_chantier']; |
2086 |
$valF['date_chantier'] = $val['archive_date_chantier']; |
} else { |
2087 |
} else { |
$valF['date_chantier'] = null; |
2088 |
$valF['date_chantier'] = NULL; |
} |
2089 |
} |
if ($val['archive_date_conformite'] != '') { |
2090 |
if ($val['archive_date_conformite'] != '') { |
$valF['date_conformite'] = $val['archive_date_conformite']; |
2091 |
$valF['date_conformite'] = $val['archive_date_conformite']; |
} else { |
2092 |
} else { |
$valF['date_conformite'] = null; |
2093 |
$valF['date_conformite'] = NULL; |
} |
2094 |
} |
if ($val['archive_incompletude'] != '') { |
2095 |
if ($val['archive_incompletude'] != '') { |
$valF['incompletude'] = $val['archive_incompletude']; |
2096 |
$valF['incompletude'] = $val['archive_incompletude']; |
} else { |
2097 |
} else { |
$valF['incompletude'] = null; |
2098 |
$valF['incompletude'] = NULL; |
} |
2099 |
} |
if ($val['archive_incomplet_notifie'] != '') { |
2100 |
if ($val['archive_incomplet_notifie'] != '') { |
$valF['incomplet_notifie'] = $val['archive_incomplet_notifie']; |
2101 |
$valF['incomplet_notifie'] = $val['archive_incomplet_notifie']; |
} else { |
2102 |
} else { |
$valF['incomplet_notifie'] = null; |
2103 |
$valF['incomplet_notifie'] = NULL; |
} |
2104 |
} |
if ($val['archive_evenement_suivant_tacite'] != '') { |
2105 |
if ($val['archive_evenement_suivant_tacite'] != '') { |
$valF['evenement_suivant_tacite'] = $val['archive_evenement_suivant_tacite']; |
2106 |
$valF['evenement_suivant_tacite'] = $val['archive_evenement_suivant_tacite']; |
} else { |
2107 |
} else { |
$valF['evenement_suivant_tacite'] = null; |
2108 |
$valF['evenement_suivant_tacite'] = NULL; |
} |
2109 |
} |
if ($val['archive_evenement_suivant_tacite_incompletude'] != '') { |
2110 |
if ($val['archive_evenement_suivant_tacite_incompletude'] != '') { |
$valF['evenement_suivant_tacite_incompletude'] = $val['archive_evenement_suivant_tacite_incompletude']; |
2111 |
$valF['evenement_suivant_tacite_incompletude'] = $val['archive_evenement_suivant_tacite_incompletude']; |
} else { |
2112 |
} else { |
$valF['evenement_suivant_tacite_incompletude'] = null; |
2113 |
$valF['evenement_suivant_tacite_incompletude'] = NULL; |
} |
2114 |
} |
if ($val['archive_etat_pendant_incompletude'] != '') { |
2115 |
if ($val['archive_etat_pendant_incompletude'] != '') { |
$valF['etat_pendant_incompletude'] = $val['archive_etat_pendant_incompletude']; |
2116 |
$valF['etat_pendant_incompletude'] = $val['archive_etat_pendant_incompletude']; |
} else { |
2117 |
} else { |
$valF['etat_pendant_incompletude'] = null; |
2118 |
$valF['etat_pendant_incompletude'] = NULL; |
} |
2119 |
} |
if ($val['archive_date_limite_incompletude'] != '') { |
2120 |
if ($val['archive_date_limite_incompletude'] != '') { |
$valF['date_limite_incompletude'] = $val['archive_date_limite_incompletude']; |
2121 |
$valF['date_limite_incompletude'] = $val['archive_date_limite_incompletude']; |
} else { |
2122 |
} else { |
$valF['date_limite_incompletude'] = null; |
2123 |
$valF['date_limite_incompletude'] = NULL; |
} |
2124 |
} |
if ($val['archive_delai_incompletude'] != '') { |
2125 |
if ($val['archive_delai_incompletude'] != '') { |
$valF['delai_incompletude'] = $val['archive_delai_incompletude']; |
2126 |
$valF['delai_incompletude'] = $val['archive_delai_incompletude']; |
} else { |
2127 |
} else { |
$valF['delai_incompletude'] = null; |
2128 |
$valF['delai_incompletude'] = NULL; |
} |
2129 |
} |
if ($val['archive_autorite_competente'] != '') { |
2130 |
if ($val['archive_autorite_competente'] != '') { |
$valF['autorite_competente'] = $val['archive_autorite_competente']; |
2131 |
$valF['autorite_competente'] = $val['archive_autorite_competente']; |
} else { |
2132 |
} else { |
$valF['autorite_competente'] = null; |
2133 |
$valF['autorite_competente'] = NULL; |
} |
2134 |
} |
$valF['date_cloture_instruction'] = null; |
2135 |
// On met à jour le dossier |
if ($val['archive_date_cloture_instruction'] !== '') { |
2136 |
$cle = " dossier='".$val['dossier']."'"; |
$valF['date_cloture_instruction'] = $val['archive_date_cloture_instruction']; |
2137 |
$res = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle); |
} |
2138 |
$this->addToLog("triggersupprimer(): db->autoexecute(\"".DB_PREFIXE."dossier\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
// Dates concernant les dossiers contentieux |
2139 |
if (database::isError($res)) { |
// Date de première visite |
2140 |
die($res->getMessage()); |
$valF['date_premiere_visite'] = null; |
2141 |
} |
if ($val['archive_date_premiere_visite'] !== '') { |
2142 |
// Affichage d'informations à l'utilisateur |
$valF['date_premiere_visite'] = $val['archive_date_premiere_visite']; |
2143 |
$this->addToMessage(_("Suppression de l'instruction")." [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
} |
2144 |
|
// Date de dernière visite |
2145 |
// Mise à jour de la demande si un récépissé d'instruction correspond à l'instruction à supprimer |
$valF['date_derniere_visite'] = null; |
2146 |
|
if ($val['archive_date_derniere_visite'] !== '') { |
2147 |
|
$valF['date_derniere_visite'] = $val['archive_date_derniere_visite']; |
2148 |
|
} |
2149 |
|
// Date contradictoire |
2150 |
|
$valF['date_contradictoire'] = null; |
2151 |
|
if ($val['archive_date_contradictoire'] !== '') { |
2152 |
|
$valF['date_contradictoire'] = $val['archive_date_contradictoire']; |
2153 |
|
} |
2154 |
|
// Date de retour contradictoire |
2155 |
|
$valF['date_retour_contradictoire'] = null; |
2156 |
|
if ($val['archive_date_retour_contradictoire'] !== '') { |
2157 |
|
$valF['date_retour_contradictoire'] = $val['archive_date_retour_contradictoire']; |
2158 |
|
} |
2159 |
|
// Date de l'AIT |
2160 |
|
$valF['date_ait'] = null; |
2161 |
|
if ($val['archive_date_ait'] !== '') { |
2162 |
|
$valF['date_ait'] = $val['archive_date_ait']; |
2163 |
|
} |
2164 |
|
// Date de transmission au parquet |
2165 |
|
$valF['date_transmission_parquet'] = null; |
2166 |
|
if ($val['archive_date_transmission_parquet'] !== '') { |
2167 |
|
$valF['date_transmission_parquet'] = $val['archive_date_transmission_parquet']; |
2168 |
|
} |
2169 |
|
|
2170 |
|
// On met à jour le dossier |
2171 |
|
$cle = " dossier='".$val['dossier']."'"; |
2172 |
|
$res = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle); |
2173 |
|
$this->addToLog("triggersupprimer(): db->autoexecute(\"".DB_PREFIXE."dossier\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
2174 |
|
if (database::isError($res)) { |
2175 |
|
die($res->getMessage()); |
2176 |
|
} |
2177 |
|
// Affichage d'informations à l'utilisateur |
2178 |
|
$this->addToMessage(_("Suppression de l'instruction")." [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
2179 |
|
|
2180 |
|
// Mise à jour de la demande si un récépissé d'instruction correspond à l'instruction à supprimer |
2181 |
} |
} |
2182 |
|
|
2183 |
function triggersupprimerapres($id,&$db,$val,$DEBUG) { |
function triggersupprimerapres($id,&$db,$val,$DEBUG) { |
2190 |
$this->correct = false; |
$this->correct = false; |
2191 |
return false; |
return false; |
2192 |
} |
} |
2193 |
|
$val['evenement'] = $this->getVal('evenement'); |
2194 |
|
return $this->add_log_to_dossier($id, $val); |
2195 |
} |
} |
2196 |
|
|
2197 |
/** |
/** |
2263 |
} |
} |
2264 |
|
|
2265 |
// Liste des opérateurs possible |
// Liste des opérateurs possible |
2266 |
$operateurs = array(">=", "<=", "+", "-"); |
$operateurs = array(">=", "<=", "+", "-", "&&", "||", "==", "!="); |
|
|
|
2267 |
// Supprime tous les espaces de la chaîne de caractère |
// Supprime tous les espaces de la chaîne de caractère |
2268 |
$restriction = str_replace(' ', '', $restriction); |
$restriction = str_replace(' ', '', $restriction); |
2269 |
|
|
2320 |
} |
} |
2321 |
|
|
2322 |
} |
} |
|
|
|
|
/** |
|
|
* Méthode permettant de récupérer toutes les valeurs de l'événement |
|
|
* sélectionné après validation du formulaire d'instruction |
|
|
* |
|
|
* @return array() veleurs de l'événement lié |
|
|
*/ |
|
|
|
|
|
private function getValEvenement() { |
|
|
if(!empty($this->valEvenement)) { |
|
|
return $this->valEvenement; |
|
|
} else { |
|
|
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
|
|
WHERE evenement=".$this->valF['evenement']; |
|
|
$res = $this->db->query($sql); |
|
|
$this->addToLog("getValEvenement(): db->query(\"".$sql."\");", VERBOSE_MODE); |
|
|
if (database::isError($res)) { |
|
|
die($res->getMessage()); |
|
|
} |
|
|
$this->valEvenement = $res->fetchRow(DB_FETCHMODE_ASSOC); |
|
|
return $this->valEvenement; |
|
|
} |
|
|
} |
|
|
|
|
|
/** |
|
|
* Méthode permettant de savoir si le dossier lié à l'instruction à le flag |
|
|
* incompletude à true après validation du formulaire d'instruction |
|
|
* |
|
|
* @return boolean |
|
|
*/ |
|
|
private function dossierIncomplet() { |
|
|
$sql = "SELECT incompletude FROM ".DB_PREFIXE."dossier |
|
|
WHERE dossier='".$this->valF['dossier']."'"; |
|
|
$incompletude = $this->db->getOne($sql); |
|
|
$this->addToLog("dossierIncomplet(): db->query(\"".$sql."\");", VERBOSE_MODE); |
|
|
if (database::isError($incompletude)) { |
|
|
die($incompletude->getMessage()); |
|
|
} |
|
|
if ($incompletude == 't') { |
|
|
return true; |
|
|
} else { |
|
|
return false; |
|
|
} |
|
|
} |
|
2323 |
|
|
2324 |
/** |
/** |
2325 |
* Finalisation des documents. |
* Finalisation des documents. |
2328 |
* @param string $sousform permet de savoir si se trouve dans un sousformulaire (passé au javascript) |
* @param string $sousform permet de savoir si se trouve dans un sousformulaire (passé au javascript) |
2329 |
*/ |
*/ |
2330 |
function manage_finalizing($mode = null, $val = array()) { |
function manage_finalizing($mode = null, $val = array()) { |
2331 |
|
// |
2332 |
|
$this->begin_treatment(__METHOD__); |
2333 |
|
|
2334 |
// Si le mode n'existe pas on retourne false |
// |
2335 |
if ($mode != "finalize" && $mode != "unfinalize") { |
$id_inst = $this->getVal($this->clePrimaire); |
|
return false; |
|
|
} |
|
2336 |
|
|
2337 |
// Recuperation de la valeur de la cle primaire de l'objet |
// |
2338 |
$id = $this->getVal($this->clePrimaire); |
$admin_msg_error = _("Veuillez contacter votre administrateur."); |
2339 |
|
$file_msg_error = _("Erreur de traitement de fichier.") |
2340 |
|
." ".$admin_msg_error; |
2341 |
|
$bdd_msg_error = _("Erreur de base de données.") |
2342 |
|
." ".$admin_msg_error; |
2343 |
|
$log_msg_error = "Finalisation non enregistrée - id instruction = %s - uid fichier = %s"; |
2344 |
|
|
2345 |
// Si on finalise le document |
// Si on finalise le document |
2346 |
if ($mode == "finalize"){ |
if ($mode == "finalize"){ |
2347 |
|
// |
2348 |
|
$etat = _('finalisation'); |
2349 |
|
|
2350 |
// Récupère la collectivite du dossier d'instruction |
// Récupère la collectivite du dossier d'instruction |
2351 |
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
$dossier_instruction_om_collectivite = $this->get_dossier_instruction_om_collectivite(); |
2359 |
|
|
2360 |
//Métadonnées du document |
//Métadonnées du document |
2361 |
$metadata = array( |
$metadata = array( |
2362 |
'filename' => 'instruction_'.$id.'.pdf', |
'filename' => 'instruction_'.$id_inst.'.pdf', |
2363 |
'mimetype' => 'application/pdf', |
'mimetype' => 'application/pdf', |
2364 |
'size' => strlen($pdf_output) |
'size' => strlen($pdf_output) |
2365 |
); |
); |
2373 |
WHERE evenement = ".$this->getVal("evenement"); |
WHERE evenement = ".$this->getVal("evenement"); |
2374 |
$typeEvenement = $this->db->getOne($sql); |
$typeEvenement = $this->db->getOne($sql); |
2375 |
$this->addToLog(__METHOD__."(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog(__METHOD__."(): db->getOne(\"".$sql."\");", VERBOSE_MODE); |
2376 |
if (database::isError($typeEvenement, true)) { |
if ($this->f->isDatabaseError($typeEvenement, true) === true) { |
2377 |
die(); |
$this->correct = false; |
2378 |
|
$this->addToMessage($bdd_msg_error); |
2379 |
|
return $this->end_treatment(__METHOD__, false); |
2380 |
} |
} |
2381 |
|
|
2382 |
//Initialisation de la variable |
//Initialisation de la variable |
2388 |
|
|
2389 |
$metadata = array_merge($metadata, $spe_metadata, $arrete_metadata); |
$metadata = array_merge($metadata, $spe_metadata, $arrete_metadata); |
2390 |
|
|
2391 |
// Si le document a déjà été finalisé |
// Si le document a déjà été finalisé on le met à jour |
2392 |
// met à jour le document mais pas son uid |
// en conservant son UID |
2393 |
if ($this->getVal("om_fichier_instruction") != ''){ |
if ($this->getVal("om_fichier_instruction") != ''){ |
|
|
|
|
// Met à jour le document |
|
2394 |
$uid = $this->f->storage->update( |
$uid = $this->f->storage->update( |
2395 |
$this->getVal("om_fichier_instruction"), $pdf_output, $metadata); |
$this->getVal("om_fichier_instruction"), $pdf_output, $metadata); |
2396 |
} |
} |
2397 |
//Sinon, ajoute le document et récupère son uid |
// Sinon on crée un nouveau document et dont on récupère l'UID |
2398 |
else { |
else { |
|
|
|
|
//Stockage du PDF |
|
2399 |
$uid = $this->f->storage->create($pdf_output, $metadata); |
$uid = $this->f->storage->create($pdf_output, $metadata); |
2400 |
} |
} |
2401 |
} |
} |
2402 |
|
|
2403 |
// Si on finalise le document |
// Si on définalise le document |
2404 |
if ($mode == "unfinalize") { |
if ($mode == "unfinalize") { |
2405 |
|
// |
2406 |
|
$etat = _('définalisation'); |
2407 |
// Récupération de l'uid du document finalisé |
// Récupération de l'uid du document finalisé |
2408 |
$uid = $this->getVal("om_fichier_instruction"); |
$uid = $this->getVal("om_fichier_instruction"); |
2409 |
} |
} |
2410 |
|
|
2411 |
// |
// Si on définalise l'UID doit être défini |
2412 |
|
// Si on finalise la création/modification du fichier doit avoir réussi |
2413 |
if ($uid == '' || $uid == 'OP_FAILURE' ) { |
if ($uid == '' || $uid == 'OP_FAILURE' ) { |
2414 |
// Stop le traitement |
$this->correct = false; |
2415 |
return false; |
$this->addToMessage($file_msg_error); |
2416 |
|
$this->addToLog(sprintf($log_msg_error, $id_inst, $uid)); |
2417 |
// Message d'echec (saut d'une ligne supplementaire avant le |
return $this->end_treatment(__METHOD__, false); |
|
// message pour qu'il soit mis en evidence) |
|
|
$this->addToLog( |
|
|
_("Finalisation non enregistree")." - ". |
|
|
_("id instruction")." = ".$id." - ". |
|
|
_("uid fichier")." = ".$uid |
|
|
); |
|
2418 |
} |
} |
2419 |
|
|
|
// Logger |
|
|
$this->addToLog(__METHOD__."() - begin", EXTRA_VERBOSE_MODE); |
|
|
|
|
2420 |
// |
// |
2421 |
foreach ($this->champs as $key => $champ) { |
foreach ($this->champs as $key => $champ) { |
2422 |
// |
// |
2424 |
} |
} |
2425 |
|
|
2426 |
// |
// |
2427 |
$val['date_evenement']=$this->dateDBToForm($val['date_evenement']); |
$val['date_evenement'] = $this->dateDBToForm($val['date_evenement']); |
2428 |
$val['archive_date_complet']=$this->dateDBToForm($val['archive_date_complet']); |
$val['archive_date_complet'] = $this->dateDBToForm($val['archive_date_complet']); |
2429 |
$val['archive_date_rejet']=$this->dateDBToForm($val['archive_date_rejet']); |
$val['archive_date_rejet'] = $this->dateDBToForm($val['archive_date_rejet']); |
2430 |
$val['archive_date_limite']=$this->dateDBToForm($val['archive_date_limite']); |
$val['archive_date_limite'] = $this->dateDBToForm($val['archive_date_limite']); |
2431 |
$val['archive_date_notification_delai']=$this->dateDBToForm($val['archive_date_notification_delai']); |
$val['archive_date_notification_delai'] = $this->dateDBToForm($val['archive_date_notification_delai']); |
2432 |
$val['archive_date_decision']=$this->dateDBToForm($val['archive_date_decision']); |
$val['archive_date_decision'] = $this->dateDBToForm($val['archive_date_decision']); |
2433 |
$val['archive_date_validite']=$this->dateDBToForm($val['archive_date_validite']); |
$val['archive_date_validite'] = $this->dateDBToForm($val['archive_date_validite']); |
2434 |
$val['archive_date_achevement']=$this->dateDBToForm($val['archive_date_achevement']); |
$val['archive_date_achevement'] = $this->dateDBToForm($val['archive_date_achevement']); |
2435 |
$val['archive_date_chantier']=$this->dateDBToForm($val['archive_date_chantier']); |
$val['archive_date_chantier'] = $this->dateDBToForm($val['archive_date_chantier']); |
2436 |
$val['archive_date_conformite']=$this->dateDBToForm($val['archive_date_conformite']); |
$val['archive_date_conformite'] = $this->dateDBToForm($val['archive_date_conformite']); |
2437 |
$val['archive_date_dernier_depot']=$this->dateDBToForm($val['archive_date_dernier_depot']); |
$val['archive_date_dernier_depot'] = $this->dateDBToForm($val['archive_date_dernier_depot']); |
2438 |
$val['archive_date_limite_incompletude']=$this->dateDBToForm($val['archive_date_limite_incompletude']); |
$val['archive_date_limite_incompletude'] = $this->dateDBToForm($val['archive_date_limite_incompletude']); |
2439 |
$val['date_finalisation_courrier']=$this->dateDBToForm($val['date_finalisation_courrier']); |
$val['date_finalisation_courrier'] = $this->dateDBToForm($val['date_finalisation_courrier']); |
2440 |
$val['date_envoi_signature']=$this->dateDBToForm($val['date_envoi_signature']); |
$val['date_envoi_signature'] = $this->dateDBToForm($val['date_envoi_signature']); |
2441 |
$val['date_retour_signature']=$this->dateDBToForm($val['date_retour_signature']); |
$val['date_retour_signature'] = $this->dateDBToForm($val['date_retour_signature']); |
2442 |
$val['date_envoi_rar']=$this->dateDBToForm($val['date_envoi_rar']); |
$val['date_envoi_rar'] = $this->dateDBToForm($val['date_envoi_rar']); |
2443 |
$val['date_retour_rar']=$this->dateDBToForm($val['date_retour_rar']); |
$val['date_retour_rar'] = $this->dateDBToForm($val['date_retour_rar']); |
2444 |
$val['date_envoi_controle_legalite']=$this->dateDBToForm($val['date_envoi_controle_legalite']); |
$val['date_envoi_controle_legalite'] = $this->dateDBToForm($val['date_envoi_controle_legalite']); |
2445 |
$val['date_retour_controle_legalite']=$this->dateDBToForm($val['date_retour_controle_legalite']); |
$val['date_retour_controle_legalite'] = $this->dateDBToForm($val['date_retour_controle_legalite']); |
2446 |
|
$val['archive_date_cloture_instruction'] = $this->dateDBToForm($val['archive_date_cloture_instruction']); |
2447 |
|
$val['archive_date_premiere_visite'] = $this->dateDBToForm($val['archive_date_premiere_visite']); |
2448 |
|
$val['archive_date_derniere_visite'] = $this->dateDBToForm($val['archive_date_derniere_visite']); |
2449 |
|
$val['archive_date_contradictoire'] = $this->dateDBToForm($val['archive_date_contradictoire']); |
2450 |
|
$val['archive_date_retour_contradictoire'] = $this->dateDBToForm($val['archive_date_retour_contradictoire']); |
2451 |
|
$val['archive_date_ait'] = $this->dateDBToForm($val['archive_date_ait']); |
2452 |
|
$val['archive_date_transmission_parquet'] = $this->dateDBToForm($val['archive_date_transmission_parquet']); |
2453 |
$this->setvalF($val); |
$this->setvalF($val); |
2454 |
|
|
2455 |
// Verification de la validite des donnees |
// Verification de la validite des donnees |
2456 |
$this->verifier($this->val, $this->db, DEBUG); |
$this->verifier($this->val, $this->db, DEBUG); |
|
// Verification du verrou |
|
|
$this->testverrou(); |
|
2457 |
// Si les verifications precedentes sont correctes, on procede a |
// Si les verifications precedentes sont correctes, on procede a |
2458 |
// la modification, sinon on ne fait rien et on retourne une erreur |
// la modification, sinon on ne fait rien et on retourne une erreur |
2459 |
if ($this->correct) { |
if ($this->correct === true) { |
|
// Execution du trigger 'before' specifique au MODE 'update' |
|
|
$this->triggermodifier($id, $this->db, $this->val, DEBUG); |
|
|
|
|
2460 |
// |
// |
2461 |
$valF = array( |
$valF = array( |
2462 |
"om_fichier_instruction" => $uid, |
"om_fichier_instruction" => $uid, |
2465 |
// |
// |
2466 |
if($mode=="finalize") { |
if($mode=="finalize") { |
2467 |
// état finalisé vrai |
// état finalisé vrai |
2468 |
$valF["om_final_instruction"] = 't'; |
$valF["om_final_instruction"] = true; |
2469 |
// ajout log utilisateur |
// ajout log utilisateur |
2470 |
$login = $_SESSION['login']; |
$login = $_SESSION['login']; |
2471 |
$nom = ""; |
$nom = ""; |
2480 |
} |
} |
2481 |
} else { |
} else { |
2482 |
// état finalisé faux |
// état finalisé faux |
2483 |
$valF["om_final_instruction"] = 'f'; |
$valF["om_final_instruction"] = false; |
2484 |
// suppression log utilisateur |
// suppression log utilisateur |
2485 |
$valF["om_final_instruction_utilisateur"] = ''; |
$valF["om_final_instruction_utilisateur"] = ''; |
2486 |
} |
} |
2488 |
// Execution de la requête de modification des donnees de l'attribut |
// Execution de la requête de modification des donnees de l'attribut |
2489 |
// valF de l'objet dans l'attribut table de l'objet |
// valF de l'objet dans l'attribut table de l'objet |
2490 |
$res = $this->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
$res = $this->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
2491 |
DB_AUTOQUERY_UPDATE, $this->getCle($id)); |
DB_AUTOQUERY_UPDATE, $this->getCle($id_inst)); |
2492 |
$this->addToLog(__METHOD__."() : db->autoExecute(\"".DB_PREFIXE.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($id)."\")", VERBOSE_MODE); |
$this->addToLog(__METHOD__."() : db->autoExecute(\"".DB_PREFIXE.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($id_inst)."\")", VERBOSE_MODE); |
2493 |
// Si une erreur survient |
// |
2494 |
if (database::isError($res, true)) { |
if ($this->f->isDatabaseError($res, true) === true) { |
2495 |
// Appel de la methode de recuperation des erreurs |
$this->correct = false; |
2496 |
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
$this->addToMessage($bdd_msg_error); |
2497 |
} else { |
return $this->end_treatment(__METHOD__, false); |
2498 |
// Log |
} |
|
$this->addToLog(_("Requete executee"), VERBOSE_MODE); |
|
|
// Log |
|
|
$message = _("Enregistrement")." ".$id." "; |
|
|
$message .= _("de la table")." \"".$this->table."\" "; |
|
|
$message .= "[ ".$this->db->affectedRows()." "; |
|
|
$message .= _("enregistrement(s) mis a jour")." ]"; |
|
|
$this->addToLog($message, VERBOSE_MODE); |
|
|
// Mise en place du verrou pour ne pas finaliser plusieurs fois |
|
|
// le meme document |
|
|
$this->verrouille(); |
|
|
// Execution du trigger 'after' specifique au MODE 'update' |
|
|
//$this->triggermodifierapres($id, $this->db, $val, DEBUG); |
|
|
|
|
|
if($mode == "finalize") { |
|
|
$etat = _('finalisation'); |
|
|
} else { |
|
|
$etat = _('definalisation'); |
|
|
} |
|
|
$this->msg = ""; |
|
|
$this->addToMessage(sprintf(_("La %s du document s'est effectuee avec succes."), $etat)); |
|
2499 |
|
|
2500 |
return true; |
// |
2501 |
} |
$this->addToMessage(sprintf(_("La %s du document s'est effectuee avec succes."), $etat)); |
2502 |
} else { |
// |
2503 |
// Message d'echec (saut d'une ligne supplementaire avant le |
if ($this->add_log_to_dossier($id_inst, $val) === false) { |
2504 |
// message pour qu'il soit mis en evidence) |
return $this->end_treatment(__METHOD__, false); |
2505 |
$this->addToLog( |
} |
2506 |
_("Finalisation non enregistree")." - ". |
// |
2507 |
_("id instruction")." = ".$id." - ". |
return $this->end_treatment(__METHOD__, true); |
|
_("uid fichier")." = ".$uid |
|
|
); |
|
|
return false; |
|
2508 |
} |
} |
2509 |
|
// L'appel de verifier() a déjà positionné correct à false |
2510 |
|
// et défini un message d'erreur. |
2511 |
|
$this->addToLog(sprintf($log_msg_error, $id_inst, $uid)); |
2512 |
|
return $this->end_treatment(__METHOD__, false); |
2513 |
} |
} |
2514 |
|
|
2515 |
/** |
/** |
2625 |
return $evenement_libelle; |
return $evenement_libelle; |
2626 |
} |
} |
2627 |
|
|
2628 |
|
|
2629 |
|
/** |
2630 |
|
* Récupération du champ ERP du dossier d'instruction. |
2631 |
|
* |
2632 |
|
* @return boolean |
2633 |
|
*/ |
2634 |
|
public function get_concerne_erp() { |
2635 |
|
// |
2636 |
|
if(empty($this->specificMetadata)) { |
2637 |
|
$this->getSpecificMetadata(); |
2638 |
|
} |
2639 |
|
// |
2640 |
|
return $this->specificMetadata->erp; |
2641 |
|
} |
2642 |
|
|
2643 |
|
|
2644 |
/** |
/** |
2645 |
* Cette méthode permet de stocker en attribut toutes les métadonnées |
* Cette méthode permet de stocker en attribut toutes les métadonnées |
2646 |
* nécessaire à l'ajout d'un document. |
* nécessaire à l'ajout d'un document. |
2658 |
dossier_instruction_type.code as dossier_instruction_type, |
dossier_instruction_type.code as dossier_instruction_type, |
2659 |
etat_dossier_autorisation.libelle as statut, |
etat_dossier_autorisation.libelle as statut, |
2660 |
dossier_autorisation_type.code as dossier_autorisation_type, |
dossier_autorisation_type.code as dossier_autorisation_type, |
2661 |
groupe.code as groupe_instruction |
groupe.code as groupe_instruction, |
2662 |
|
CASE WHEN dossier.erp IS TRUE |
2663 |
|
THEN 'true' |
2664 |
|
ELSE 'false' |
2665 |
|
END as erp |
2666 |
FROM ".DB_PREFIXE."dossier |
FROM ".DB_PREFIXE."dossier |
2667 |
LEFT JOIN ".DB_PREFIXE."dossier_instruction_type |
LEFT JOIN ".DB_PREFIXE."dossier_instruction_type |
2668 |
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
2688 |
|
|
2689 |
//Si il y a un résultat |
//Si il y a un résultat |
2690 |
if ($row !== null) { |
if ($row !== null) { |
2691 |
|
|
2692 |
//Génération du numéro de version |
// Instrance de la classe dossier |
2693 |
$sql = "SELECT |
$inst_dossier = $this->get_inst_dossier($dossier); |
2694 |
count(*) |
|
2695 |
FROM |
// Insère l'attribut version à l'objet |
2696 |
".DB_PREFIXE."dossier |
$row->version = $inst_dossier->get_dossier_instruction_version(); |
|
LEFT JOIN |
|
|
".DB_PREFIXE."dossier_autorisation |
|
|
ON |
|
|
dossier_autorisation.dossier_autorisation = dossier.dossier_autorisation |
|
|
LEFT JOIN |
|
|
".DB_PREFIXE."dossier_instruction_type |
|
|
ON |
|
|
dossier_instruction_type.dossier_instruction_type = dossier.dossier_instruction_type |
|
|
WHERE |
|
|
dossier_autorisation.dossier_autorisation = '".$row->dossier_autorisation."' |
|
|
AND |
|
|
dossier_instruction_type.code = '".$row->dossier_instruction_type."'"; |
|
|
$row->version = $this->db->getOne($sql); |
|
|
$this->f->addToLog("getSpecificMetadata(): db->getOne(\"".$sql."\")", VERBOSE_MODE); |
|
|
if ( database::isError($row->version)){ |
|
|
$this->f->addToError("", $row->version, $row->version); |
|
|
return false; |
|
|
} |
|
|
|
|
|
//Formatage du numéro de version |
|
|
$row->version = str_pad($row->version, 2, "0", STR_PAD_LEFT); |
|
2697 |
|
|
2698 |
//Alors on créé l'objet dossier_instruction |
//Alors on créé l'objet dossier_instruction |
2699 |
$this->specificMetadata = $row; |
$this->specificMetadata = $row; |
2752 |
|
|
2753 |
// Récupération de la valeur actuelle du délai, de l'accord tacite, |
// Récupération de la valeur actuelle du délai, de l'accord tacite, |
2754 |
// de l'état et de l'avis du dossier d'instruction |
// de l'état et de l'avis du dossier d'instruction |
2755 |
$return['archive_delai']=$row['delai']; |
$return['archive_delai'] = $row['delai']; |
2756 |
$return['archive_accord_tacite']=$row['accord_tacite']; |
$return['archive_accord_tacite'] = $row['accord_tacite']; |
2757 |
$return['archive_etat']=$row['etat']; |
$return['archive_etat'] = $row['etat']; |
2758 |
$return['archive_avis']=$row['avis_decision']; |
$return['archive_avis'] = $row['avis_decision']; |
2759 |
// Récupération de la valeur actuelle des 9 dates du dossier |
// Récupération de la valeur actuelle des dates du dossier |
2760 |
// d'instruction |
// d'instruction |
2761 |
$return['archive_date_complet']=$row['date_complet']; |
$return['archive_date_complet'] = $row['date_complet']; |
2762 |
$return['archive_date_dernier_depot']=$row['date_dernier_depot']; |
$return['archive_date_dernier_depot'] = $row['date_dernier_depot']; |
2763 |
$return['archive_date_rejet']= $row['date_rejet']; |
$return['archive_date_rejet'] = $row['date_rejet']; |
2764 |
$return['archive_date_limite']= $row['date_limite']; |
$return['archive_date_limite'] = $row['date_limite']; |
2765 |
$return['archive_date_notification_delai']= $row['date_notification_delai']; |
$return['archive_date_notification_delai'] = $row['date_notification_delai']; |
2766 |
$return['archive_date_decision']= $row['date_decision']; |
$return['archive_date_decision'] = $row['date_decision']; |
2767 |
$return['archive_date_validite']= $row['date_validite']; |
$return['archive_date_validite'] = $row['date_validite']; |
2768 |
$return['archive_date_achevement']= $row['date_achevement']; |
$return['archive_date_achevement'] = $row['date_achevement']; |
2769 |
$return['archive_date_chantier']= $row['date_chantier']; |
$return['archive_date_chantier'] = $row['date_chantier']; |
2770 |
$return['archive_date_conformite']= $row['date_conformite']; |
$return['archive_date_conformite'] = $row['date_conformite']; |
2771 |
$return['archive_incompletude']= $row['incompletude']; |
$return['archive_incompletude'] = $row['incompletude']; |
2772 |
$return['archive_incomplet_notifie']= $row['incomplet_notifie']; |
$return['archive_incomplet_notifie'] = $row['incomplet_notifie']; |
2773 |
$return['archive_evenement_suivant_tacite']= $row['evenement_suivant_tacite']; |
$return['archive_evenement_suivant_tacite'] = $row['evenement_suivant_tacite']; |
2774 |
$return['archive_evenement_suivant_tacite_incompletude']= $row['evenement_suivant_tacite_incompletude']; |
$return['archive_evenement_suivant_tacite_incompletude'] = $row['evenement_suivant_tacite_incompletude']; |
2775 |
$return['archive_etat_pendant_incompletude']= $row['etat_pendant_incompletude']; |
$return['archive_etat_pendant_incompletude'] = $row['etat_pendant_incompletude']; |
2776 |
$return['archive_date_limite_incompletude']= $row['date_limite_incompletude']; |
$return['archive_date_limite_incompletude'] = $row['date_limite_incompletude']; |
2777 |
$return['archive_delai_incompletude']= $row['delai_incompletude']; |
$return['archive_delai_incompletude'] = $row['delai_incompletude']; |
2778 |
$return['archive_autorite_competente']= $row['autorite_competente']; |
$return['archive_autorite_competente'] = $row['autorite_competente']; |
2779 |
$return['duree_validite']= $row['duree_validite']; |
$return['duree_validite'] = $row['duree_validite']; |
2780 |
|
$return['date_depot'] = $row['date_depot']; |
2781 |
|
$return['archive_date_cloture_instruction'] = $row['date_cloture_instruction']; |
2782 |
|
$return['archive_date_premiere_visite'] = $row['date_premiere_visite']; |
2783 |
|
$return['archive_date_derniere_visite'] = $row['date_derniere_visite']; |
2784 |
|
$return['archive_date_contradictoire'] = $row['date_contradictoire']; |
2785 |
|
$return['archive_date_retour_contradictoire'] = $row['date_retour_contradictoire']; |
2786 |
|
$return['archive_date_ait'] = $row['date_ait']; |
2787 |
|
$return['archive_date_transmission_parquet'] = $row['date_transmission_parquet']; |
2788 |
} |
} |
2789 |
|
|
2790 |
// Retour de la fonction |
// Retour de la fonction |
2846 |
if ($row['date_dernier_depot'] != '') { |
if ($row['date_dernier_depot'] != '') { |
2847 |
$this->valF['archive_date_dernier_depot']=$row['date_dernier_depot']; |
$this->valF['archive_date_dernier_depot']=$row['date_dernier_depot']; |
2848 |
} |
} |
2849 |
if ($row['date_rejet']!='') { |
if ($row['date_rejet'] != '') { |
2850 |
$this->valF['archive_date_rejet']= $row['date_rejet']; |
$this->valF['archive_date_rejet']= $row['date_rejet']; |
2851 |
} |
} |
2852 |
if ($row['date_limite']!='') { |
if ($row['date_limite'] != '') { |
2853 |
$this->valF['archive_date_limite']= $row['date_limite']; |
$this->valF['archive_date_limite']= $row['date_limite']; |
2854 |
} |
} |
2855 |
if ($row['date_notification_delai']!='') { |
if ($row['date_notification_delai'] != '') { |
2856 |
$this->valF['archive_date_notification_delai']= $row['date_notification_delai']; |
$this->valF['archive_date_notification_delai']= $row['date_notification_delai']; |
2857 |
} |
} |
2858 |
if ($row['date_decision']!='') { |
if ($row['date_decision'] != '') { |
2859 |
$this->valF['archive_date_decision']= $row['date_decision']; |
$this->valF['archive_date_decision']= $row['date_decision']; |
2860 |
} |
} |
2861 |
if ($row['date_validite']!='') { |
if ($row['date_validite'] != '') { |
2862 |
$this->valF['archive_date_validite']= $row['date_validite']; |
$this->valF['archive_date_validite']= $row['date_validite']; |
2863 |
} |
} |
2864 |
if ($row['date_achevement']!='') { |
if ($row['date_achevement'] != '') { |
2865 |
$this->valF['archive_date_achevement']= $row['date_achevement']; |
$this->valF['archive_date_achevement']= $row['date_achevement']; |
2866 |
} |
} |
2867 |
if ($row['date_chantier']!='') { |
if ($row['date_chantier'] != '') { |
2868 |
$this->valF['archive_date_chantier']= $row['date_chantier']; |
$this->valF['archive_date_chantier']= $row['date_chantier']; |
2869 |
} |
} |
2870 |
if ($row['date_conformite']!='') { |
if ($row['date_conformite'] != '') { |
2871 |
$this->valF['archive_date_conformite']= $row['date_conformite']; |
$this->valF['archive_date_conformite']= $row['date_conformite']; |
2872 |
} |
} |
2873 |
if ($row['incompletude']!='') { |
if ($row['incompletude'] != '') { |
2874 |
$this->valF['archive_incompletude']= $row['incompletude']; |
$this->valF['archive_incompletude']= $row['incompletude']; |
2875 |
} |
} |
2876 |
if ($row['incomplet_notifie']!='') { |
if ($row['incomplet_notifie'] != '') { |
2877 |
$this->valF['archive_incomplet_notifie']= $row['incomplet_notifie']; |
$this->valF['archive_incomplet_notifie']= $row['incomplet_notifie']; |
2878 |
} |
} |
2879 |
if ($row['evenement_suivant_tacite']!='') { |
if ($row['evenement_suivant_tacite'] != '') { |
2880 |
$this->valF['archive_evenement_suivant_tacite']= $row['evenement_suivant_tacite']; |
$this->valF['archive_evenement_suivant_tacite']= $row['evenement_suivant_tacite']; |
2881 |
} |
} |
2882 |
if ($row['evenement_suivant_tacite_incompletude']!='') { |
if ($row['evenement_suivant_tacite_incompletude'] != '') { |
2883 |
$this->valF['archive_evenement_suivant_tacite_incompletude']= $row['evenement_suivant_tacite_incompletude']; |
$this->valF['archive_evenement_suivant_tacite_incompletude']= $row['evenement_suivant_tacite_incompletude']; |
2884 |
} |
} |
2885 |
if ($row['etat_pendant_incompletude']!='') { |
if ($row['etat_pendant_incompletude'] != '') { |
2886 |
$this->valF['archive_etat_pendant_incompletude']= $row['etat_pendant_incompletude']; |
$this->valF['archive_etat_pendant_incompletude']= $row['etat_pendant_incompletude']; |
2887 |
} |
} |
2888 |
if ($row['date_limite_incompletude']!='') { |
if ($row['date_limite_incompletude'] != '') { |
2889 |
$this->valF['archive_date_limite_incompletude']= $row['date_limite_incompletude']; |
$this->valF['archive_date_limite_incompletude']= $row['date_limite_incompletude']; |
2890 |
} |
} |
2891 |
if ($row['delai_incompletude']!='') { |
if ($row['delai_incompletude'] != '') { |
2892 |
$this->valF['archive_delai_incompletude']= $row['delai_incompletude']; |
$this->valF['archive_delai_incompletude']= $row['delai_incompletude']; |
2893 |
} |
} |
2894 |
if ($row['autorite_competente']!='') { |
if ($row['autorite_competente'] != '') { |
2895 |
$this->valF['archive_autorite_competente']= $row['autorite_competente']; |
$this->valF['archive_autorite_competente']= $row['autorite_competente']; |
2896 |
} |
} |
2897 |
if ($row['duree_validite']!='') { |
if ($row['duree_validite'] != '') { |
2898 |
$this->valF['duree_validite']= $row['duree_validite']; |
$this->valF['duree_validite']= $row['duree_validite']; |
2899 |
} |
} |
2900 |
|
if ($row['date_depot'] != '') { |
2901 |
|
$this->valF['date_depot']= $row['date_depot']; |
2902 |
|
} |
2903 |
|
// Dates concernant les dossiers contentieux |
2904 |
|
if ($row['date_cloture_instruction'] != '') { |
2905 |
|
$this->valF['archive_date_cloture_instruction']= $row['date_cloture_instruction']; |
2906 |
|
} |
2907 |
|
if ($row['date_premiere_visite'] != '') { |
2908 |
|
$this->valF['archive_date_premiere_visite']= $row['date_premiere_visite']; |
2909 |
|
} |
2910 |
|
if ($row['date_derniere_visite'] != '') { |
2911 |
|
$this->valF['archive_date_derniere_visite']= $row['date_derniere_visite']; |
2912 |
|
} |
2913 |
|
if ($row['date_contradictoire'] != '') { |
2914 |
|
$this->valF['archive_date_contradictoire']= $row['date_contradictoire']; |
2915 |
|
} |
2916 |
|
if ($row['date_retour_contradictoire'] != '') { |
2917 |
|
$this->valF['archive_date_retour_contradictoire']= $row['date_retour_contradictoire']; |
2918 |
|
} |
2919 |
|
if ($row['date_ait'] != '') { |
2920 |
|
$this->valF['archive_date_ait']= $row['date_ait']; |
2921 |
|
} |
2922 |
|
if ($row['date_transmission_parquet'] != '') { |
2923 |
|
$this->valF['archive_date_transmission_parquet']= $row['date_transmission_parquet']; |
2924 |
|
} |
2925 |
} |
} |
2926 |
|
|
2927 |
// {{{ |
// {{{ |
3109 |
*/ |
*/ |
3110 |
function is_editable() { |
function is_editable() { |
3111 |
// Contrôle si l'utilisateur possède un bypass |
// Contrôle si l'utilisateur possède un bypass |
3112 |
$bypass = $this->f->isAccredited(get_class()."_modifier_bypass"); |
$bypass = $this->f->isAccredited(get_class($this)."_modifier_bypass"); |
3113 |
// |
// |
3114 |
if ($bypass == true) { |
if ($bypass == true) { |
|
|
|
3115 |
// |
// |
3116 |
return true; |
return true; |
3117 |
} |
} |
3118 |
|
|
|
// Si l'utilisateur est un intructeur qui ne correspond pas à la |
|
|
// division du dossier |
|
|
if ($this->f->isUserInstructeur() |
|
|
&& $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier() |
|
|
&& $this->f->isAccredited("instruction_changer_decision") === false) { |
|
|
|
|
|
// |
|
|
return false; |
|
|
} |
|
|
|
|
|
// si instructeur commune |
|
|
if($this->f->isAccredited("instruction_changer_decision") === true |
|
|
&& $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier() |
|
|
&& ($this->f->isInstrCanChangeDecision($this->getVal('dossier')) !== true |
|
|
|| $this->getVal('created_by_commune') !== 't')) { |
|
|
return false; |
|
|
} |
|
3119 |
// Si l'utilisateur est un instructeur, que le dossier est cloturé et |
// Si l'utilisateur est un instructeur, que le dossier est cloturé et |
3120 |
// que l'événement n'est pas identifié comme non verrouillable |
// que l'événement n'est pas identifié comme non verrouillable |
3121 |
if ($this->f->isUserInstructeur() |
if ($this->f->isUserInstructeur() |
3122 |
&& $this->getStatutAutorisationDossier($this->getParameter("idxformulaire")) == "cloture" |
&& $this->getStatutAutorisationDossier($this->getParameter("idxformulaire")) == "cloture" |
3123 |
&& $this->checkEvenementNonVerrouillable($this->getVal("instruction")) === false) { |
&& $this->checkEvenementNonVerrouillable($this->getVal("instruction")) === false) { |
|
|
|
3124 |
// |
// |
3125 |
return false; |
return false; |
3126 |
} |
} |
3127 |
|
|
3128 |
|
// Si l'utilisateur est un intructeur qui correspond à la division du |
3129 |
|
// dossier |
3130 |
|
if ($this->is_instructeur_from_division_dossier() === true) { |
3131 |
|
// |
3132 |
|
return true; |
3133 |
|
} |
3134 |
|
|
3135 |
|
// Si l'utilisateur est instructeur de la commune du dossier et que la |
3136 |
|
// décision peut être changée par la commune. |
3137 |
|
if ($this->is_instructeur_from_collectivite_dossier() === true and |
3138 |
|
$this->isInstrCanChangeDecision($this->getVal('dossier')) === true) { |
3139 |
|
return true; |
3140 |
|
} |
3141 |
|
|
3142 |
|
// Si l'utilisateur est instructeur de la commune du dossier et que |
3143 |
|
// l'instruction est créée par un instructeur de la commune |
3144 |
|
if ($this->is_instructeur_from_collectivite_dossier() === true and |
3145 |
|
$this->getVal('created_by_commune') === 't') { |
3146 |
|
return true; |
3147 |
|
} |
3148 |
|
|
3149 |
// |
// |
3150 |
return true; |
return false; |
3151 |
} |
} |
3152 |
|
|
3153 |
/** |
/** |
3159 |
*/ |
*/ |
3160 |
function is_deletable() { |
function is_deletable() { |
3161 |
// Contrôle si l'utilisateur possède un bypass |
// Contrôle si l'utilisateur possède un bypass |
3162 |
$bypass = $this->f->isAccredited(get_class()."_supprimer_bypass"); |
$bypass = $this->f->isAccredited(get_class($this)."_supprimer_bypass"); |
3163 |
// |
// |
3164 |
if ($bypass == true) { |
if ($bypass == true) { |
3165 |
|
|
3169 |
|
|
3170 |
// Si l'utilisateur est un intructeur qui ne correspond pas à la |
// Si l'utilisateur est un intructeur qui ne correspond pas à la |
3171 |
// division du dossier |
// division du dossier |
3172 |
if ($this->f->isUserInstructeur() |
if ($this->is_instructeur_from_division_dossier() !== true) { |
|
&& $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier()) { |
|
3173 |
|
|
3174 |
// |
// |
3175 |
return false; |
return false; |
3176 |
} |
} |
3177 |
|
|
3178 |
|
// l'événement est-il le dernier ? |
3179 |
|
$dernier_evenement = false; |
3180 |
|
// instanciation dossier |
3181 |
|
require_once "../obj/dossier.class.php"; |
3182 |
|
$dossier = new dossier($this->getVal('dossier'), $this->db, DEBUG); |
3183 |
|
// récupération dernier événement |
3184 |
|
$id_dernier_evenement = $dossier->get_dernier_evenement(); |
3185 |
|
if ($id_dernier_evenement == $this->getVal($this->clePrimaire)) { |
3186 |
|
$dernier_evenement = true; |
3187 |
|
} |
3188 |
|
|
3189 |
|
// Si dossier cloturé ou si pas dernier événement |
3190 |
|
// ou de type retour ou si une date est renseignée |
3191 |
|
// ET utilisateur non administrateur |
3192 |
|
if ($this->getStatutAutorisationDossier($this->getVal('dossier')) == 'cloture' |
3193 |
|
|| $dernier_evenement == false |
3194 |
|
|| $this->is_evenement_retour($this->getVal("evenement")) == true |
3195 |
|
|| $this->getVal('date_envoi_signature') != '' |
3196 |
|
|| $this->getVal('date_retour_signature') != '' |
3197 |
|
|| $this->getVal('date_envoi_rar') != '' |
3198 |
|
|| $this->getVal('date_retour_rar') != '' |
3199 |
|
|| $this->getVal('date_envoi_controle_legalite') != '' |
3200 |
|
|| $this->getVal('date_retour_controle_legalite') != '') { |
3201 |
|
// pas le droit de supprimer |
3202 |
|
return false;; |
3203 |
|
} |
3204 |
|
|
3205 |
// |
// |
3206 |
return true; |
return true; |
3207 |
} |
} |
3208 |
|
|
3209 |
|
|
3210 |
|
/** |
3211 |
|
* Vérifie que l'utilisateur est instructeur et qu'il est de la division du |
3212 |
|
* dossier. |
3213 |
|
* |
3214 |
|
* @return, boolean true/false |
3215 |
|
*/ |
3216 |
|
function is_instructeur_from_collectivite_dossier() { |
3217 |
|
if ($this->f->isUserInstructeur() === true and |
3218 |
|
$this->f->om_utilisateur["om_collectivite"] == $this->get_dossier_instruction_om_collectivite()) { |
3219 |
|
return true; |
3220 |
|
} |
3221 |
|
return false; |
3222 |
|
} |
3223 |
|
|
3224 |
/** |
/** |
3225 |
* CONDITION - is_addable. |
* CONDITION - is_addable. |
3226 |
* |
* |
3230 |
*/ |
*/ |
3231 |
function is_addable() { |
function is_addable() { |
3232 |
// Contrôle si l'utilisateur possède un bypass |
// Contrôle si l'utilisateur possède un bypass |
3233 |
$bypass = $this->f->isAccredited(get_class()."_ajouter_bypass"); |
$bypass = $this->f->isAccredited(get_class($this)."_ajouter_bypass"); |
3234 |
// |
// |
3235 |
if ($bypass == true) { |
if ($bypass == true) { |
3236 |
|
|
3237 |
// |
// |
3238 |
return true; |
return true; |
3239 |
} |
} |
3240 |
|
// Si l'utilisateur est un intructeur qui correspond à la |
3241 |
// Si l'utilisateur est un intructeur qui ne correspond pas à la |
// division du dossier ou qu'il peut changer la décision |
3242 |
// division du dossier |
if ($this->is_instructeur_from_division_dossier() === true or |
3243 |
if ($this->f->isUserInstructeur() |
$this->isInstrCanChangeDecision($this->getParameter('idxformulaire')) === true) { |
|
&& $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier() |
|
|
&& $this->f->isAccredited("instruction_changer_decision") === false) { |
|
|
|
|
3244 |
// |
// |
3245 |
return false; |
return true; |
|
} |
|
|
|
|
|
// si instructeur commune |
|
|
if($this->f->isAccredited("instruction_changer_decision") === false |
|
|
&& $this->f->isInstrCanChangeDecision($this->getVal('dossier')) === true) { |
|
|
return false; |
|
3246 |
} |
} |
3247 |
|
|
|
|
|
3248 |
// |
// |
3249 |
return true; |
return false; |
3250 |
} |
} |
3251 |
|
|
3252 |
/** |
/** |
3258 |
*/ |
*/ |
3259 |
function is_finalizable() { |
function is_finalizable() { |
3260 |
// Contrôle si l'utilisateur possède un bypass |
// Contrôle si l'utilisateur possède un bypass |
3261 |
$bypass = $this->f->isAccredited(get_class()."_finaliser_bypass"); |
$bypass = $this->f->isAccredited(get_class($this)."_finaliser_bypass"); |
3262 |
// |
// |
3263 |
if ($bypass == true) { |
if ($bypass == true) { |
|
|
|
3264 |
// |
// |
3265 |
return true; |
return true; |
3266 |
} |
} |
3267 |
|
|
|
// Si l'utilisateur est un intructeur qui ne correspond pas à la |
|
|
// division du dossier |
|
|
if ($this->f->isUserInstructeur() |
|
|
&& $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier() |
|
|
&& $this->f->isAccredited("instruction_changer_decision") === false) { |
|
|
|
|
|
// |
|
|
return false; |
|
|
} |
|
|
|
|
|
// si instructeur commune |
|
|
if($this->f->isAccredited("instruction_changer_decision") === true |
|
|
&& $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier() |
|
|
&& ($this->f->isInstrCanChangeDecision($this->getVal('dossier')) !== true |
|
|
|| $this->getVal('created_by_commune') !== 't')) { |
|
|
return false; |
|
|
} |
|
|
|
|
3268 |
// Si l'utilisateur est un instructeur, que le dossier est cloturé et |
// Si l'utilisateur est un instructeur, que le dossier est cloturé et |
3269 |
// que l'événement n'est pas identifié comme non verrouillable |
// que l'événement n'est pas identifié comme non verrouillable |
3270 |
if ($this->f->isUserInstructeur() |
if ($this->f->isUserInstructeur() |
3271 |
&& $this->getStatutAutorisationDossier($this->getParameter("idxformulaire")) == "cloture" |
&& $this->getStatutAutorisationDossier($this->getParameter("idxformulaire")) == "cloture" |
3272 |
&& $this->checkEvenementNonVerrouillable($this->getVal("instruction")) === false) { |
&& $this->checkEvenementNonVerrouillable($this->getVal("instruction")) === false) { |
|
|
|
3273 |
// |
// |
3274 |
return false; |
return false; |
3275 |
} |
} |
3276 |
|
|
3277 |
|
// Si l'utilisateur est un intructeur qui correspond à la division du |
3278 |
|
// dossier |
3279 |
|
if ($this->is_instructeur_from_division_dossier() === true) { |
3280 |
|
// |
3281 |
|
return true; |
3282 |
|
} |
3283 |
|
|
3284 |
|
// Si l'utilisateur est instructeur de la commune du dossier et que la |
3285 |
|
// décision peut être changée par la commune. |
3286 |
|
if ($this->is_instructeur_from_collectivite_dossier() === true and |
3287 |
|
$this->isInstrCanChangeDecision($this->getVal('dossier')) === true) { |
3288 |
|
return true; |
3289 |
|
} |
3290 |
|
|
3291 |
|
// Si l'utilisateur est instructeur de la commune du dossier et que |
3292 |
|
// l'instruction est créée par un instructeur de la commune |
3293 |
|
if ($this->is_instructeur_from_collectivite_dossier() === true and |
3294 |
|
$this->getVal('created_by_commune') === 't') { |
3295 |
|
return true; |
3296 |
|
} |
3297 |
|
|
3298 |
// |
// |
3299 |
return true; |
return false; |
3300 |
} |
} |
3301 |
|
|
3302 |
/** |
/** |
3330 |
*/ |
*/ |
3331 |
function is_unfinalizable(){ |
function is_unfinalizable(){ |
3332 |
// Contrôle si l'utilisateur possède un bypass |
// Contrôle si l'utilisateur possède un bypass |
3333 |
$bypass = $this->f->isAccredited(get_class()."_definaliser_bypass"); |
$bypass = $this->f->isAccredited(get_class($this)."_definaliser_bypass"); |
3334 |
// |
// |
3335 |
if ($bypass == true) { |
if ($bypass == true) { |
|
|
|
3336 |
// |
// |
3337 |
return true; |
return true; |
3338 |
} |
} |
3339 |
|
|
3340 |
// Si l'utilisateur est un intructeur qui ne correspond pas à la |
// Si l'utilisateur est un instructeur, que le dossier est cloturé et |
3341 |
// division du dossier |
// que l'événement n'est pas identifié comme non verrouillable |
3342 |
if ($this->f->isUserInstructeur() |
if ($this->f->isUserInstructeur() |
3343 |
&& $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier() |
&& $this->getStatutAutorisationDossier($this->getParameter("idxformulaire")) == "cloture" |
3344 |
&& $this->f->isAccredited("instruction_changer_decision") === false) { |
&& $this->checkEvenementNonVerrouillable($this->getVal("instruction")) === false) { |
|
|
|
3345 |
// |
// |
3346 |
return false; |
return false; |
3347 |
} |
} |
3348 |
|
|
3349 |
// si instructeur commune |
// Si l'utilisateur est un intructeur qui correspond à la division du |
3350 |
if($this->f->isAccredited("instruction_changer_decision") === true |
// dossier |
3351 |
&& $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier() |
if ($this->is_instructeur_from_division_dossier() === true) { |
3352 |
&& ($this->f->isInstrCanChangeDecision($this->getVal('dossier')) !== true |
// |
3353 |
|| $this->getVal('created_by_commune') !== 't')) { |
return true; |
|
return false; |
|
3354 |
} |
} |
3355 |
|
|
3356 |
// Si l'utilisateur est un instructeur, que le dossier est cloturé et |
// Si l'utilisateur est instructeur de la commune du dossier et que la |
3357 |
// que l'événement n'est pas identifié comme non verrouillable |
// décision peut être changée par la commune. |
3358 |
if ($this->f->isUserInstructeur() |
if ($this->is_instructeur_from_collectivite_dossier() === true and |
3359 |
&& $this->getStatutAutorisationDossier($this->getParameter("idxformulaire")) == "cloture" |
$this->isInstrCanChangeDecision($this->getVal('dossier')) === true) { |
3360 |
&& $this->checkEvenementNonVerrouillable($this->getVal("instruction")) === false) { |
return true; |
3361 |
|
} |
3362 |
|
|
3363 |
// |
// Si l'utilisateur est instructeur de la commune du dossier et que |
3364 |
return false; |
// l'instruction est créée par un instructeur de la commune |
3365 |
|
if ($this->is_instructeur_from_collectivite_dossier() === true and |
3366 |
|
$this->getVal('created_by_commune') === 't') { |
3367 |
|
return true; |
3368 |
} |
} |
3369 |
|
|
3370 |
// |
// |
3371 |
return true; |
return false; |
3372 |
} |
} |
3373 |
|
|
3374 |
/** |
/** |
3392 |
return false; |
return false; |
3393 |
} |
} |
3394 |
|
|
3395 |
|
|
3396 |
|
/** |
3397 |
|
* Permet de définir si un instructeur commune peut editer une instruction |
3398 |
|
* |
3399 |
|
* @return boolean true si il peut |
3400 |
|
*/ |
3401 |
|
function isInstrCanChangeDecision($idx) { |
3402 |
|
|
3403 |
|
if ($this->f->isAccredited(array("instruction", "instruction_changer_decision"), "OR") !== true or |
3404 |
|
$this->f->isUserInstructeur() !== true) { |
3405 |
|
return false; |
3406 |
|
} |
3407 |
|
|
3408 |
|
|
3409 |
|
|
3410 |
|
// Sinon on vérifie l'éligibilité du dossier au changement de décision |
3411 |
|
$sql = |
3412 |
|
"SELECT |
3413 |
|
dossier.dossier |
3414 |
|
FROM |
3415 |
|
".DB_PREFIXE."dossier |
3416 |
|
JOIN ".DB_PREFIXE."instruction ON instruction.instruction = ( |
3417 |
|
SELECT instruction |
3418 |
|
FROM ".DB_PREFIXE."instruction |
3419 |
|
JOIN ".DB_PREFIXE."evenement on instruction.evenement=evenement.evenement |
3420 |
|
WHERE instruction.dossier = dossier.dossier |
3421 |
|
AND evenement.retour IS FALSE |
3422 |
|
ORDER BY date_evenement DESC, instruction DESC |
3423 |
|
LIMIT 1 |
3424 |
|
) |
3425 |
|
JOIN ".DB_PREFIXE."evenement ON instruction.evenement=evenement.evenement |
3426 |
|
JOIN ".DB_PREFIXE."instructeur ON dossier.instructeur=instructeur.instructeur |
3427 |
|
JOIN ".DB_PREFIXE."om_utilisateur ON instructeur.om_utilisateur=om_utilisateur.om_utilisateur |
3428 |
|
JOIN ".DB_PREFIXE."om_collectivite ON om_collectivite.om_collectivite=om_utilisateur.om_collectivite |
3429 |
|
JOIN ".DB_PREFIXE."etat ON dossier.etat = etat.etat |
3430 |
|
WHERE |
3431 |
|
|
3432 |
|
( |
3433 |
|
evenement.type = 'arrete' AND |
3434 |
|
( |
3435 |
|
instruction.om_final_instruction IS TRUE |
3436 |
|
OR instruction.created_by_commune IS TRUE |
3437 |
|
) OR |
3438 |
|
evenement.type = 'changement_decision' |
3439 |
|
) |
3440 |
|
AND evenement.retour IS FALSE |
3441 |
|
AND instruction.date_retour_signature IS NULL |
3442 |
|
AND instruction.date_envoi_rar IS NULL |
3443 |
|
AND instruction.date_retour_rar IS NULL |
3444 |
|
AND instruction.date_envoi_controle_legalite IS NULL |
3445 |
|
AND instruction.date_retour_controle_legalite IS NULL |
3446 |
|
AND etat.statut = 'encours' |
3447 |
|
AND dossier.dossier = '".$idx."' |
3448 |
|
AND om_collectivite.niveau = '2' |
3449 |
|
"; |
3450 |
|
|
3451 |
|
|
3452 |
|
// Si collectivité de l'utilisateur niveau mono alors filtre sur celle-ci |
3453 |
|
if ($this->f->isCollectiviteMono($_SESSION['collectivite']) === true) { |
3454 |
|
$sql .= " AND dossier.om_collectivite=".$_SESSION['collectivite']; |
3455 |
|
} |
3456 |
|
$res = $this->db->getone($sql); |
3457 |
|
if (database::isError($res)) { |
3458 |
|
die(); |
3459 |
|
} |
3460 |
|
// Si le dossier n'est pas sujet au changement de decision |
3461 |
|
if($res == null) { |
3462 |
|
return false; |
3463 |
|
} |
3464 |
|
return true; |
3465 |
|
} |
3466 |
|
|
3467 |
|
|
3468 |
|
/** |
3469 |
|
* CONDITION - can_monitoring_dates. |
3470 |
|
* |
3471 |
|
* Condition pour afficher le bouton de suivi des dates. |
3472 |
|
* |
3473 |
|
* @return boolean |
3474 |
|
*/ |
3475 |
|
public function can_monitoring_dates() { |
3476 |
|
// Récupère la valeur du champ finalisé |
3477 |
|
$om_final_instruction = $this->getVal('om_final_instruction'); |
3478 |
|
|
3479 |
|
// Si l'instruction n'est pas finalisée |
3480 |
|
if ($om_final_instruction !== 't') { |
3481 |
|
// |
3482 |
|
return false; |
3483 |
|
} |
3484 |
|
|
3485 |
|
// Contrôle si l'utilisateur possède un bypass |
3486 |
|
$bypass = $this->f->isAccredited(get_class($this)."_modification_dates_bypass"); |
3487 |
|
if ($bypass === true) { |
3488 |
|
return true; |
3489 |
|
} |
3490 |
|
|
3491 |
|
// On vérifie en premier lieu que le DI n'est pas clôturé |
3492 |
|
$inst_dossier = $this->get_inst_dossier(); |
3493 |
|
if ($inst_dossier->getStatut() === 'cloture') { |
3494 |
|
// |
3495 |
|
return false; |
3496 |
|
} |
3497 |
|
// On récupère ses infos |
3498 |
|
$coll_di = $inst_dossier->getVal('om_collectivite'); |
3499 |
|
$div_di = $this->getDivisionFromDossier(); |
3500 |
|
// et celles de son éventuel instructeur |
3501 |
|
$instr_di = $inst_dossier->getVal('instructeur'); |
3502 |
|
|
3503 |
|
// Il faut disposer d'une entrée instructeur |
3504 |
|
if ($this->f->isUserInstructeur() === false) { |
3505 |
|
return false; |
3506 |
|
} |
3507 |
|
|
3508 |
|
// Par défaut on prétend que l'instructeur n'est pas multi |
3509 |
|
$instr_di_coll_multi = false; |
3510 |
|
// Si un instructeur est affecté au dossier |
3511 |
|
if ($instr_di !== '' && $instr_di !== null) { |
3512 |
|
// Vérifie si l'instructeur est de la collectivité de niveau 2 |
3513 |
|
$instr_di_coll = $this->get_instructeur_om_collectivite($instr_di); |
3514 |
|
if ($this->f->isCollectiviteMono($instr_di_coll) === false) { |
3515 |
|
// |
3516 |
|
$instr_di_coll_multi = true; |
3517 |
|
} |
3518 |
|
} |
3519 |
|
|
3520 |
|
// Il faut qu'il instruise le dossier ou soit de la même division |
3521 |
|
if ($this->f->om_utilisateur['instructeur'] === $instr_di |
3522 |
|
|| $this->f->om_utilisateur['division'] === $div_di) { |
3523 |
|
// |
3524 |
|
return true; |
3525 |
|
} |
3526 |
|
|
3527 |
|
// On donne également le droit s'il est de la même collectivité que |
3528 |
|
// le dossier ET si l'instruction est déléguée à la communauté |
3529 |
|
if ($this->f->isCollectiviteMono($this->f->om_utilisateur['om_collectivite']) === true |
3530 |
|
&& $this->f->om_utilisateur['om_collectivite'] === $coll_di |
3531 |
|
&& $instr_di_coll_multi === true) { |
3532 |
|
// |
3533 |
|
return true; |
3534 |
|
} |
3535 |
|
|
3536 |
|
// Si l'instructeur ne rentre pas dans les deux cas précédents |
3537 |
|
return false; |
3538 |
|
} |
3539 |
|
|
3540 |
|
|
3541 |
/** |
/** |
3542 |
* TREATMENT - finalize. |
* TREATMENT - finalize. |
3543 |
* |
* |
3560 |
if ($ret !== true) { |
if ($ret !== true) { |
3561 |
|
|
3562 |
// Termine le traitement |
// Termine le traitement |
3563 |
$this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
3564 |
} |
} |
3565 |
|
|
3566 |
// Termine le traitement |
// Termine le traitement |
3589 |
if ($ret !== true) { |
if ($ret !== true) { |
3590 |
|
|
3591 |
// Termine le traitement |
// Termine le traitement |
3592 |
$this->end_treatment(__METHOD__, false); |
return $this->end_treatment(__METHOD__, false); |
3593 |
} |
} |
3594 |
|
|
3595 |
// Termine le traitement |
// Termine le traitement |
3696 |
$evenement = intval($evenement); |
$evenement = intval($evenement); |
3697 |
// |
// |
3698 |
($f->get_submitted_get_value("idx") ? $idx = $f->get_submitted_get_value("idx") : $idx = ""); |
($f->get_submitted_get_value("idx") ? $idx = $f->get_submitted_get_value("idx") : $idx = ""); |
3699 |
$nature = substr($idx, 0, 2); |
// Récupération du code du type de DA |
3700 |
|
$code_da_type = ''; |
3701 |
|
if (preg_match('/[A-Za-z]{2,3}/', $idx, $matches) !== false) { |
3702 |
|
$code_da_type = $matches[0]; |
3703 |
|
} |
3704 |
// |
// |
3705 |
($f->get_submitted_get_value("complement") ? $complement = $f->get_submitted_get_value("complement") : $complement = "1"); |
($f->get_submitted_get_value("complement") ? $complement = $f->get_submitted_get_value("complement") : $complement = "1"); |
3706 |
|
|
3721 |
WHERE evenement=".$evenement." |
WHERE evenement=".$evenement." |
3722 |
AND complement=".$complement." |
AND complement=".$complement." |
3723 |
AND (bible.dossier_autorisation_type IS NULL |
AND (bible.dossier_autorisation_type IS NULL |
3724 |
OR dossier_autorisation_type.code ='".$nature."') |
OR dossier_autorisation_type.code ='".$code_da_type."') |
3725 |
AND (om_collectivite.niveau = '2' |
AND (om_collectivite.niveau = '2' |
3726 |
OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").") |
OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").") |
3727 |
ORDER BY bible_lib ASC"; |
ORDER BY bible_lib ASC"; |
3787 |
} |
} |
3788 |
|
|
3789 |
/** |
/** |
3790 |
* VIEW - view_bible |
* VIEW - view_bible_auto |
3791 |
* |
* |
3792 |
* Affiche la bible manuelle. |
* Renvoie les valeurs de la bible à placer dans les compléments de l'instruction. |
3793 |
* |
* |
3794 |
* @return void |
* @return void |
3795 |
*/ |
*/ |
3887 |
// Récupération de la collectivité du dossier |
// Récupération de la collectivité du dossier |
3888 |
require_once "../obj/dossier.class.php"; |
require_once "../obj/dossier.class.php"; |
3889 |
$dossier = new dossier($idx, $f->db, DEBUG); |
$dossier = new dossier($idx, $f->db, DEBUG); |
3890 |
|
// Récupération du code du type de DA |
3891 |
|
$code_da_type = ''; |
3892 |
|
if (preg_match('/[A-Za-z]{2,3}/', $idx, $matches) !== false) { |
3893 |
|
$code_da_type = $matches[0]; |
3894 |
|
} |
3895 |
// |
// |
3896 |
$sql = "SELECT * FROM ".DB_PREFIXE."bible |
$sql = "SELECT * FROM ".DB_PREFIXE."bible |
3897 |
LEFT OUTER JOIN ".DB_PREFIXE."dossier_autorisation_type |
LEFT OUTER JOIN ".DB_PREFIXE."dossier_autorisation_type |
3903 |
WHERE evenement =".$event." and |
WHERE evenement =".$event." and |
3904 |
complement=".$compnb." and |
complement=".$compnb." and |
3905 |
automatique='Oui' and |
automatique='Oui' and |
3906 |
(dossier_autorisation_type.code ='".substr($idx, 0, 2)."' or |
(dossier_autorisation_type.code ='".$code_da_type."' or |
3907 |
bible.dossier_autorisation_type IS NULL) and |
bible.dossier_autorisation_type IS NULL) and |
3908 |
(om_collectivite.niveau = '2' OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").")"; |
(om_collectivite.niveau = '2' OR bible.om_collectivite = ".$dossier->getVal("om_collectivite").")"; |
3909 |
|
|
3922 |
/** |
/** |
3923 |
* VIEW - view_suivi_bordereaux. |
* VIEW - view_suivi_bordereaux. |
3924 |
* |
* |
3925 |
* Vu pour imprimer un bordereau d'envoi. |
* Formulaire de choix du bordereau de suivi, permettant de générer les 4 bordereaux. |
3926 |
|
* Si l'utilisateur est d'une collectivité de niveau 2 il a le choix de la |
3927 |
|
* collectivité des dossiers affichés. |
3928 |
* |
* |
3929 |
* @return void |
* @return void |
3930 |
*/ |
*/ |
3971 |
$message .= " : <br/><br/>"; |
$message .= " : <br/><br/>"; |
3972 |
$message .= "<a class='om-prev-icon pdf-16'"; |
$message .= "<a class='om-prev-icon pdf-16'"; |
3973 |
$message .= " title=\""._("Bordereau")."\""; |
$message .= " title=\""._("Bordereau")."\""; |
3974 |
$message .= " href='../pdf/pdfetat.php?obj=".$f->get_submitted_post_value("bordereau")."&date_bordereau_debut=".$f->get_submitted_post_value("date_bordereau_debut"); |
$message .= "href='../scr/form.php?obj=instruction"; |
3975 |
|
$message .= "&action=220"; |
3976 |
|
$message .= "&idx=0"; |
3977 |
|
$message .= "&type_bordereau=".$f->get_submitted_post_value("bordereau"); |
3978 |
|
$message .= "&date_bordereau_debut=".$f->get_submitted_post_value("date_bordereau_debut"); |
3979 |
$message .= "&date_bordereau_fin=".$f->get_submitted_post_value("date_bordereau_fin"); |
$message .= "&date_bordereau_fin=".$f->get_submitted_post_value("date_bordereau_fin"); |
3980 |
// Si l'utilisateur est MULTI alors on ajoute le paramètre collectivite |
// Si l'utilisateur est MULTI alors on ajoute le paramètre collectivite |
3981 |
if ($f->get_submitted_post_value("om_collectivite") !== null) { |
if ($f->get_submitted_post_value("om_collectivite") !== null) { |
4107 |
|
|
4108 |
} |
} |
4109 |
|
|
4110 |
|
|
4111 |
|
/** |
4112 |
|
* VIEW - view_generate_suivi_bordereaux. |
4113 |
|
* |
4114 |
|
* Génère et affiche les bordereaux de suivi. |
4115 |
|
* |
4116 |
|
* @return [void] |
4117 |
|
*/ |
4118 |
|
function view_generate_suivi_bordereaux() { |
4119 |
|
// Vérification de l'accessibilité sur l'élément |
4120 |
|
$this->checkAccessibility(); |
4121 |
|
// Récupération du type de bordereau |
4122 |
|
$bordereau = $this->f->get_submitted_get_value('type_bordereau'); |
4123 |
|
// Génération du PDF |
4124 |
|
$result = $this->compute_pdf_output('etat', $bordereau, null, $this->getVal($this->clePrimaire)); |
4125 |
|
// Affichage du PDF |
4126 |
|
$this->expose_pdf_output( |
4127 |
|
$result['pdf_output'], |
4128 |
|
$result['filename'] |
4129 |
|
); |
4130 |
|
} |
4131 |
|
|
4132 |
|
|
4133 |
/** |
/** |
4134 |
* VIEW - view_suivi_envoi_lettre_rar. |
* VIEW - view_suivi_envoi_lettre_rar. |
4135 |
* |
* |
4165 |
// |
// |
4166 |
$error = ""; |
$error = ""; |
4167 |
|
|
4168 |
|
// Initialisation du tableau qui va contenir les DI pour lister les liens |
4169 |
|
$dossierTab = array(); |
4170 |
|
// On vérifie que l'utilisateur ait les droits pour afficher des consultations |
4171 |
|
$isAccredited = $this->f->isAccredited(array("dossier_instruction","dossier_instruction_consulter"), "OR"); |
4172 |
|
$hasHidden = true; |
4173 |
|
// S'il ne peut pas les consulter il aura des dossiers caché |
4174 |
|
if ($isAccredited === true) { |
4175 |
|
$hasHidden = false; |
4176 |
|
} |
4177 |
|
|
4178 |
/** |
/** |
4179 |
* Validation du formulaire |
* Validation du formulaire |
4180 |
*/ |
*/ |
4197 |
// Si la valeur transmise est numérique |
// Si la valeur transmise est numérique |
4198 |
if (is_numeric($code_barres)) { |
if (is_numeric($code_barres)) { |
4199 |
// |
// |
4200 |
$sql = "SELECT count(*) FROM ".DB_PREFIXE."instruction WHERE code_barres='".$code_barres."'"; |
$sql = "SELECT count(*) |
4201 |
|
FROM ".DB_PREFIXE."instruction |
4202 |
|
INNER JOIN ".DB_PREFIXE."dossier |
4203 |
|
ON dossier.dossier=instruction.dossier |
4204 |
|
INNER JOIN ".DB_PREFIXE."dossier_instruction_type |
4205 |
|
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
4206 |
|
INNER JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille |
4207 |
|
ON dossier_instruction_type.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
4208 |
|
INNER JOIN ".DB_PREFIXE."dossier_autorisation_type |
4209 |
|
ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
4210 |
|
INNER JOIN ".DB_PREFIXE."groupe |
4211 |
|
ON dossier_autorisation_type.groupe = groupe.groupe |
4212 |
|
AND groupe.code != 'CTX' |
4213 |
|
WHERE code_barres='".$this->f->db->escapesimple($code_barres)."'"; |
4214 |
$nbInstr = $f->db->getone($sql); |
$nbInstr = $f->db->getone($sql); |
4215 |
$f->addToLog(__METHOD__.": db->getone(\"".$sql."\")", VERBOSE_MODE); |
$f->addToLog(__METHOD__.": db->getone(\"".$sql."\")", VERBOSE_MODE); |
4216 |
$f->isDatabaseError($nbInstr); |
$f->isDatabaseError($nbInstr); |
4227 |
if ($row["date_envoi_rar"] == "" || $row["date_envoi_rar"] == $date) { |
if ($row["date_envoi_rar"] == "" || $row["date_envoi_rar"] == $date) { |
4228 |
|
|
4229 |
require_once '../obj/instruction.class.php'; |
require_once '../obj/instruction.class.php'; |
4230 |
|
require_once '../obj/dossier.class.php'; |
4231 |
|
|
4232 |
$instr = new instruction($row['instruction'], $f->db, DEBUG); |
$instr = new instruction($row['instruction'], $f->db, DEBUG); |
4233 |
$valF = array(); |
$valF = array(); |
4234 |
foreach($instr->champs as $id => $champ) { |
foreach($instr->champs as $id => $champ) { |
4235 |
$valF[$champ] = $instr->val[$id]; |
$valF[$champ] = $instr->val[$id]; |
4236 |
} |
} |
4237 |
|
|
4238 |
|
# Si on peut consulter les dossiers et que le dossier n'existe pas déjà dans la liste |
4239 |
|
if ($isAccredited === true |
4240 |
|
&& array_key_exists($instr->getVal("dossier"), $dossierTab) === false) { |
4241 |
|
$dossier = new dossier($instr->getVal("dossier")); |
4242 |
|
if ($dossier->is_user_from_allowed_collectivite()){ |
4243 |
|
$dossierTab[$instr->getVal("dossier")] = $dossier; |
4244 |
|
} else { |
4245 |
|
$hasHidden = true; |
4246 |
|
} |
4247 |
|
} |
4248 |
|
|
4249 |
$valF['date_evenement']= |
$valF['date_evenement']= |
4250 |
$instr->dateDBToForm($valF['date_evenement']); |
$instr->dateDBToForm($valF['date_evenement']); |
4251 |
$valF['archive_date_complet']= |
$valF['archive_date_complet']= |
4284 |
$instr->dateDBToForm($valF['date_envoi_controle_legalite']); |
$instr->dateDBToForm($valF['date_envoi_controle_legalite']); |
4285 |
$valF['date_retour_controle_legalite']= |
$valF['date_retour_controle_legalite']= |
4286 |
$instr->dateDBToForm($valF['date_retour_controle_legalite']); |
$instr->dateDBToForm($valF['date_retour_controle_legalite']); |
|
|
|
4287 |
$valF['date_envoi_rar'] = $date; |
$valF['date_envoi_rar'] = $date; |
4288 |
|
|
4289 |
// Vérification de la finalisation du document |
// Vérification de la finalisation du document |
4290 |
// correspondant au code barres |
// correspondant au code barres |
4291 |
if($instr->getVal("om_final_instruction") === 't') { |
if($instr->getVal("om_final_instruction") === 't') { |
4292 |
$instr->setParameter('maj', 1); |
$instr->setParameter('maj', 1); |
4293 |
|
$instr->class_actions[1]["identifier"] = |
4294 |
|
"envoi lettre RAR (depuis le menu suivi des pièces)"; |
4295 |
if ($instr->modifier($valF, $f->db, DEBUG) == true) { |
if ($instr->modifier($valF, $f->db, DEBUG) == true) { |
4296 |
$id4Gen[] = $code_barres; |
$id4Gen[] = $code_barres; |
4297 |
$nbLettres ++; |
$nbLettres ++; |
4356 |
// Affichage du message de validation de la saisie |
// Affichage du message de validation de la saisie |
4357 |
if ($nbLettres > 0) { |
if ($nbLettres > 0) { |
4358 |
// |
// |
4359 |
$message_class = "valid"; |
echo "\n<div class=\"message ui-widget ui-corner-all ui-state-highlight ui-state-valid\" >"; |
4360 |
$message = _("Cliquez sur le lien ci-dessous pour telecharger votre document"); |
echo "\n<p>"; |
4361 |
$message .= " : <br/><br/>"; |
echo "\n<span class=\"ui-icon ui-icon-info\"></span>"; |
4362 |
$message .= "<a class='om-prev-icon pdf-16'"; |
echo "\n<span class=\"text\">"; |
4363 |
$message .= " title=\""._("imprimer les RAR")."\""; |
echo _("Cliquez sur le lien ci-dessous pour telecharger votre document"); |
4364 |
$message .= " href=\"../scr/form.php?obj=instruction&action=180&idx=0&liste=".implode(",",$id4Gen)."\""; |
echo " : \n<br/><br/>"; |
4365 |
$message .= " target='_blank'>"; |
echo "\n<a class='om-prev-icon pdf-16'"; |
4366 |
$message .= _("Telecharger le document pour")." ".$nbLettres." "._("RAR"); |
echo "\n title=\""._("imprimer les RAR")."\""; |
4367 |
$message .= "</a>"; |
echo "\n href=\"../scr/form.php?obj=instruction&action=180&idx=0&liste=".implode(",",$id4Gen)."\""; |
4368 |
$f->displayMessage($message_class, $message); |
echo "\n target='_blank'>"; |
4369 |
|
echo _("Telecharger le document pour")." ".$nbLettres." "._("RAR"); |
4370 |
|
echo "\n</a>"; |
4371 |
|
echo "\n</span>"; |
4372 |
|
echo "\n</p>"; |
4373 |
|
echo "\n<br/>\n"; |
4374 |
|
if ($isAccredited === true) { |
4375 |
|
echo '<fieldset id="fieldset-form-rar-lien_di" class="cadre ui-corner-all startClosed" style="background-color: inherite;">'; |
4376 |
|
echo "\n<legend class=\"ui-corner-all ui-widget-content ui-state-active\" style=\"background-color: transparent; color: inherit;\">\n"; |
4377 |
|
echo _('Dossiers concernés par ce traitement'); |
4378 |
|
echo "\n</legend>"; |
4379 |
|
echo "\n<div class=\"fieldsetContent\" style=\"display: none;background-color: inherite\">"; |
4380 |
|
|
4381 |
|
if ($hasHidden === true) { |
4382 |
|
echo "\n<br/>"; |
4383 |
|
echo "\n<p>"; |
4384 |
|
echo "\n<span class='text'>"; |
4385 |
|
echo _("Certains dossiers ont été omis de la liste ci-dessous car vous ne possédez pas les permissions nécessaires pour y accéder."); |
4386 |
|
echo "</span>"; |
4387 |
|
echo "\n</p>"; |
4388 |
|
echo "\n<br/>"; |
4389 |
|
} |
4390 |
|
foreach ($dossierTab as $dossier) { |
4391 |
|
echo "\n<div class=\"bloc group\">"; |
4392 |
|
echo "\n<div class=\"field field-type-text\">"; |
4393 |
|
|
4394 |
|
echo "\n<p>"; |
4395 |
|
echo "\n<span class='text'>"; |
4396 |
|
echo "\n<a class=\"om-icon om-icon-16 consult-16\" title=\"" . _('Consulter') . "\""; |
4397 |
|
echo "\n href=\"../scr/form.php?obj=dossier_instruction&action=3&idx="; |
4398 |
|
echo $dossier->getVal("dossier"); |
4399 |
|
echo "\">"; |
4400 |
|
echo "\n</a>"; |
4401 |
|
|
4402 |
|
echo "\n<a title=\""._("Consulter")."\" style=\"vertical-align:middle;\""; |
4403 |
|
echo " href=\"../scr/form.php?obj=dossier_instruction&action=3&idx="; |
4404 |
|
echo $dossier->getVal("dossier"); |
4405 |
|
echo "\">"; |
4406 |
|
echo $dossier->getVal("dossier_libelle"); |
4407 |
|
echo "\n</a>"; |
4408 |
|
echo "\n</span>"; |
4409 |
|
echo "\n</p>"; |
4410 |
|
|
4411 |
|
echo "\n</div>"; |
4412 |
|
echo "\n</div>"; |
4413 |
|
} |
4414 |
|
echo "\n</div>"; |
4415 |
|
echo "\n</fieldset>"; |
4416 |
|
} |
4417 |
|
echo "\n</div>"; |
4418 |
|
echo "\n</div>"; |
4419 |
} |
} |
4420 |
// Inclusion de la classe de gestion des formulaires |
// Inclusion de la classe de gestion des formulaires |
4421 |
require_once "../obj/om_formulaire.class.php"; |
require_once "../obj/om_formulaire.class.php"; |
4502 |
if ($f->get_submitted_post_value('validation') !== null) { |
if ($f->get_submitted_post_value('validation') !== null) { |
4503 |
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)) { |
4504 |
|
|
4505 |
//Vérification de l'existance de l'instruction |
// Vérification de l'existence de l'instruction |
4506 |
$sql = "SELECT instruction FROM ".DB_PREFIXE."instruction WHERE code_barres='".$this->f->db->escapesimple($code_barres)."'"; |
$sql = "SELECT instruction |
4507 |
|
FROM ".DB_PREFIXE."instruction |
4508 |
|
INNER JOIN ".DB_PREFIXE."dossier |
4509 |
|
ON dossier.dossier=instruction.dossier |
4510 |
|
INNER JOIN ".DB_PREFIXE."dossier_instruction_type |
4511 |
|
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
4512 |
|
INNER JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille |
4513 |
|
ON dossier_instruction_type.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
4514 |
|
INNER JOIN ".DB_PREFIXE."dossier_autorisation_type |
4515 |
|
ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
4516 |
|
INNER JOIN ".DB_PREFIXE."groupe |
4517 |
|
ON dossier_autorisation_type.groupe = groupe.groupe |
4518 |
|
AND groupe.code != 'CTX' |
4519 |
|
WHERE code_barres='".$this->f->db->escapesimple($code_barres)."'"; |
4520 |
$res = $f->db->query($sql); |
$res = $f->db->query($sql); |
4521 |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
$f->addToLog(__METHOD__.": db->query(\"".$sql."\")", VERBOSE_MODE); |
4522 |
$f->isDatabaseError($res); |
$f->isDatabaseError($res); |
4532 |
foreach($instr->champs as $id => $champ) { |
foreach($instr->champs as $id => $champ) { |
4533 |
$valF[$champ] = $instr->val[$id]; |
$valF[$champ] = $instr->val[$id]; |
4534 |
} |
} |
4535 |
$valF['date_evenement']=$instr->dateDBToForm($valF['date_evenement']); |
$valF['date_evenement'] = $instr->dateDBToForm($valF['date_evenement']); |
4536 |
$valF['archive_date_complet']=$instr->dateDBToForm($valF['archive_date_complet']); |
$valF['archive_date_complet'] = $instr->dateDBToForm($valF['archive_date_complet']); |
4537 |
$valF['archive_date_rejet']=$instr->dateDBToForm($valF['archive_date_rejet']); |
$valF['archive_date_rejet'] = $instr->dateDBToForm($valF['archive_date_rejet']); |
4538 |
$valF['archive_date_limite']=$instr->dateDBToForm($valF['archive_date_limite']); |
$valF['archive_date_limite'] = $instr->dateDBToForm($valF['archive_date_limite']); |
4539 |
$valF['archive_date_notification_delai']=$instr->dateDBToForm($valF['archive_date_notification_delai']); |
$valF['archive_date_notification_delai'] = $instr->dateDBToForm($valF['archive_date_notification_delai']); |
4540 |
$valF['archive_date_decision']=$instr->dateDBToForm($valF['archive_date_decision']); |
$valF['archive_date_decision'] = $instr->dateDBToForm($valF['archive_date_decision']); |
4541 |
$valF['archive_date_validite']=$instr->dateDBToForm($valF['archive_date_validite']); |
$valF['archive_date_validite'] = $instr->dateDBToForm($valF['archive_date_validite']); |
4542 |
$valF['archive_date_achevement']=$instr->dateDBToForm($valF['archive_date_achevement']); |
$valF['archive_date_achevement'] = $instr->dateDBToForm($valF['archive_date_achevement']); |
4543 |
$valF['archive_date_chantier']=$instr->dateDBToForm($valF['archive_date_chantier']); |
$valF['archive_date_chantier'] = $instr->dateDBToForm($valF['archive_date_chantier']); |
4544 |
$valF['archive_date_conformite']=$instr->dateDBToForm($valF['archive_date_conformite']); |
$valF['archive_date_conformite'] = $instr->dateDBToForm($valF['archive_date_conformite']); |
4545 |
$valF['archive_date_dernier_depot']=$instr->dateDBToForm($valF['archive_date_dernier_depot']); |
$valF['archive_date_dernier_depot'] = $instr->dateDBToForm($valF['archive_date_dernier_depot']); |
4546 |
$valF['archive_date_limite_incompletude']=$instr->dateDBToForm($valF['archive_date_limite_incompletude']); |
$valF['archive_date_limite_incompletude'] = $instr->dateDBToForm($valF['archive_date_limite_incompletude']); |
4547 |
$valF['date_finalisation_courrier']=$instr->dateDBToForm($valF['date_finalisation_courrier']); |
$valF['date_finalisation_courrier'] = $instr->dateDBToForm($valF['date_finalisation_courrier']); |
4548 |
$valF['date_envoi_signature']=$instr->dateDBToForm($valF['date_envoi_signature']); |
$valF['date_envoi_signature'] = $instr->dateDBToForm($valF['date_envoi_signature']); |
4549 |
$valF['date_retour_signature']=$instr->dateDBToForm($valF['date_retour_signature']); |
$valF['date_retour_signature'] = $instr->dateDBToForm($valF['date_retour_signature']); |
4550 |
$valF['date_envoi_rar']=$instr->dateDBToForm($valF['date_envoi_rar']); |
$valF['date_envoi_rar'] = $instr->dateDBToForm($valF['date_envoi_rar']); |
4551 |
$valF['date_retour_rar']=$instr->dateDBToForm($valF['date_retour_rar']); |
$valF['date_retour_rar'] = $instr->dateDBToForm($valF['date_retour_rar']); |
4552 |
$valF['date_envoi_controle_legalite']=$instr->dateDBToForm($valF['date_envoi_controle_legalite']); |
$valF['date_envoi_controle_legalite'] = $instr->dateDBToForm($valF['date_envoi_controle_legalite']); |
4553 |
$valF['date_retour_controle_legalite']=$instr->dateDBToForm($valF['date_retour_controle_legalite']); |
$valF['date_retour_controle_legalite'] = $instr->dateDBToForm($valF['date_retour_controle_legalite']); |
4554 |
|
$valF['archive_date_cloture_instruction'] = $instr->dateDBToForm($valF['archive_date_cloture_instruction']); |
4555 |
|
$valF['archive_date_premiere_visite'] = $instr->dateDBToForm($valF['archive_date_premiere_visite']); |
4556 |
|
$valF['archive_date_derniere_visite'] = $instr->dateDBToForm($valF['archive_date_derniere_visite']); |
4557 |
|
$valF['archive_date_contradictoire'] = $instr->dateDBToForm($valF['archive_date_contradictoire']); |
4558 |
|
$valF['archive_date_retour_contradictoire'] = $instr->dateDBToForm($valF['archive_date_retour_contradictoire']); |
4559 |
|
$valF['archive_date_ait'] = $instr->dateDBToForm($valF['archive_date_ait']); |
4560 |
|
$valF['archive_date_transmission_parquet'] = $instr->dateDBToForm($valF['archive_date_transmission_parquet']); |
4561 |
|
|
4562 |
foreach(explode(";", $type_mise_a_jour) as $maj_date) { |
foreach(explode(";", $type_mise_a_jour) as $maj_date) { |
4563 |
$valF[$maj_date]=$date; |
$valF[$maj_date]=$date; |
4574 |
|
|
4575 |
//On modifie les valeurs de l'instruction |
//On modifie les valeurs de l'instruction |
4576 |
$instr->setParameter('maj', 170); |
$instr->setParameter('maj', 170); |
4577 |
|
$instr->class_actions[170]["identifier"] = |
4578 |
|
"mise à jour des dates (depuis le menu suivi des pièces)"; |
4579 |
$retour = $instr->modifier($valF, $f->db, DEBUG); |
$retour = $instr->modifier($valF, $f->db, DEBUG); |
4580 |
|
|
4581 |
//Si une erreur s'est produite, on défait les modifications |
//Si une erreur s'est produite, on défait les modifications |
5151 |
} |
} |
5152 |
|
|
5153 |
/** |
/** |
5154 |
* Retourne l'événement d'instruction dont on donne le code-barres |
* Retourne l'événement d'instruction dont on donne le code-barres, avec un filtre |
5155 |
|
* pour exclure les dossiers du groupe contentieux. |
5156 |
* |
* |
5157 |
* @param [string] $barcode numéro du code-barres |
* @param [string] $barcode numéro du code-barres |
5158 |
* @return [mixed] ID de son instruction ou null si aucun code |
* @return [mixed] ID de son instruction ou null si aucun code |
5161 |
// Begin |
// Begin |
5162 |
$this->begin_treatment(__METHOD__); |
$this->begin_treatment(__METHOD__); |
5163 |
// Vérification de l'existence de l'événement d'instruction |
// Vérification de l'existence de l'événement d'instruction |
5164 |
// pour le code-barres donné |
// pour le code-barres donné, en excluant les dossiers liés au groupe CTX |
5165 |
$sql = "SELECT instruction |
$sql = "SELECT instruction |
5166 |
FROM ".DB_PREFIXE."instruction |
FROM ".DB_PREFIXE."instruction |
5167 |
WHERE code_barres = '".$this->f->db->escapesimple($barcode)."'"; |
INNER JOIN ".DB_PREFIXE."dossier |
5168 |
|
ON dossier.dossier=instruction.dossier |
5169 |
|
INNER JOIN ".DB_PREFIXE."dossier_instruction_type |
5170 |
|
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
5171 |
|
INNER JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille |
5172 |
|
ON dossier_instruction_type.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
5173 |
|
INNER JOIN ".DB_PREFIXE."dossier_autorisation_type |
5174 |
|
ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
5175 |
|
INNER JOIN ".DB_PREFIXE."groupe |
5176 |
|
ON dossier_autorisation_type.groupe = groupe.groupe |
5177 |
|
AND groupe.code != 'CTX' |
5178 |
|
WHERE code_barres = '".$this->f->db->escapesimple($barcode)."'"; |
5179 |
$res = $this->f->db->getOne($sql); |
$res = $this->f->db->getOne($sql); |
5180 |
$this->f->addToLog(__METHOD__." : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
$this->f->addToLog(__METHOD__." : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
5181 |
$this->f->isDatabaseError($res); |
$this->f->isDatabaseError($res); |
5220 |
function setValFAjout($val) { |
function setValFAjout($val) { |
5221 |
// 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 |
5222 |
// par un utilisateur de commune sur un dossier instruit par la comcom |
// par un utilisateur de commune sur un dossier instruit par la comcom |
5223 |
if($this->f->isInstrCanChangeDecision($this->valF["dossier"])) { |
if ($this->isInstrCanChangeDecision($this->valF["dossier"])) { |
5224 |
$this->valF['created_by_commune'] = true; |
$this->valF['created_by_commune'] = true; |
5225 |
} |
} |
5226 |
} |
} |
5227 |
|
|
5228 |
|
|
5229 |
|
/** |
5230 |
|
* Récupère l'instance d'un événement de workflow. |
5231 |
|
* |
5232 |
|
* @param mixed $evenement Identifiant de l'événement. |
5233 |
|
* |
5234 |
|
* @return object |
5235 |
|
*/ |
5236 |
|
function get_inst_evenement($evenement = null) { |
5237 |
|
// |
5238 |
|
return $this->get_inst_common("evenement", $evenement); |
5239 |
|
} |
5240 |
|
|
5241 |
|
/** |
5242 |
|
* Logue l'action de l'instruction dans son DI. |
5243 |
|
* |
5244 |
|
* @param string $id Clé primaire de l'instruction. |
5245 |
|
* @param array $val Valeurs de l'instruction. |
5246 |
|
* |
5247 |
|
* @return bool Vrai si traitement effectué avec succès |
5248 |
|
*/ |
5249 |
|
private function add_log_to_dossier($id, array $val) { |
5250 |
|
$maj = $this->getParameter("maj"); |
5251 |
|
// Action = Trace par défaut |
5252 |
|
$action = $this->get_backtrace(); |
5253 |
|
// Action = Identifant de l'action si contexte connu |
5254 |
|
if (empty($maj) === false |
5255 |
|
|| (empty($maj) === true && $maj === 0)) { |
5256 |
|
$action = $this->get_action_param($maj, 'identifier'); |
5257 |
|
if ($action === 'modifier_suivi') { |
5258 |
|
$action = "modifier (via l'action suivi des dates)"; |
5259 |
|
} |
5260 |
|
if ($action === 'notifier_commune' |
5261 |
|
&& isset($val['mails_destinataires']) === true) { |
5262 |
|
$action = "notification de la commune (courriels : "; |
5263 |
|
$action .= $val['mails_destinataires'].")"; |
5264 |
|
} |
5265 |
|
} |
5266 |
|
// Création du log |
5267 |
|
$log = array( |
5268 |
|
'date' => date('Y-m-d H:i:s'), |
5269 |
|
'user' => $_SESSION['login'], |
5270 |
|
'action' => $action, |
5271 |
|
'values' => array( |
5272 |
|
'date_evenement' => $this->dateDB($val['date_evenement']), |
5273 |
|
'date_retour_rar' => $this->dateDB($val['date_retour_rar']), |
5274 |
|
'date_retour_signature' => $this->dateDB($val['date_retour_signature']), |
5275 |
|
'evenement' => $val['evenement'], |
5276 |
|
'action' => $val['action'], |
5277 |
|
'instruction' => $id, |
5278 |
|
'etat' => $val['etat'], |
5279 |
|
), |
5280 |
|
); |
5281 |
|
// Ajout du log |
5282 |
|
$di = $this->get_inst_dossier($val['dossier']); |
5283 |
|
$ret = $di->add_log_instructions($log); |
5284 |
|
if ($ret === false) { |
5285 |
|
$this->correct = false; |
5286 |
|
$this->msg = ''; |
5287 |
|
$this->addToMessage($di->msg); |
5288 |
|
} |
5289 |
|
return $ret; |
5290 |
|
} |
5291 |
|
|
5292 |
|
|
5293 |
|
/** |
5294 |
|
* Retourne le contexte de déboguage formaté en HTML. |
5295 |
|
* |
5296 |
|
* @return string Une ligne par trace |
5297 |
|
*/ |
5298 |
|
private function get_backtrace() { |
5299 |
|
$trace = debug_backtrace(); |
5300 |
|
$backtrace = ''; |
5301 |
|
$i = 1; |
5302 |
|
foreach ($trace as $key => $value) { |
5303 |
|
$func = $trace[$key]['function']; |
5304 |
|
// On ne s'autolog pas |
5305 |
|
if ($func === 'get_backtrace' |
5306 |
|
|| $func === 'add_log_to_dossier') { |
5307 |
|
continue; |
5308 |
|
} |
5309 |
|
$backtrace .= $i.') '; |
5310 |
|
// Si dans une classe |
5311 |
|
if (isset($trace[$key]['class']) === true |
5312 |
|
&& empty($trace[$key]['class']) === false) { |
5313 |
|
$backtrace .= $trace[$key]['class'].'->'.$func; |
5314 |
|
} |
5315 |
|
// Si procédural |
5316 |
|
else { |
5317 |
|
$file = $trace[$key]['file']; |
5318 |
|
$line = $trace[$key]['line']; |
5319 |
|
$truncated_file = $this->f->get_relative_path($file); |
5320 |
|
if ($truncated_file !== false) { |
5321 |
|
$file = $truncated_file; |
5322 |
|
} |
5323 |
|
$backtrace .= $func.' IN<br/> '.$file.':'.$line; |
5324 |
|
} |
5325 |
|
$backtrace .= '<br/>'; |
5326 |
|
$i++; |
5327 |
|
} |
5328 |
|
return $backtrace; |
5329 |
|
} |
5330 |
|
|
5331 |
|
/** |
5332 |
|
* CONDITION - is_notifiable. |
5333 |
|
* |
5334 |
|
* Condition pour afficher l'action notifier_commune. |
5335 |
|
* |
5336 |
|
* @return boolean |
5337 |
|
*/ |
5338 |
|
public function is_notifiable() { |
5339 |
|
// L'instruction doit être finalisée, ce qui revient à dire |
5340 |
|
// définalisable sans bypass |
5341 |
|
if ($this->is_unfinalizable_without_bypass() === false) { |
5342 |
|
return false; |
5343 |
|
} |
5344 |
|
// La collectivité de l'utilisateur doit être de niveau multi |
5345 |
|
if ($this->f->has_collectivite_multi() === false) { |
5346 |
|
return false; |
5347 |
|
} |
5348 |
|
// Le paramètre multi de l'objet du courriel doit exister |
5349 |
|
if ($this->f->getParameter('param_courriel_de_notification_commune_objet_depuis_instruction') === NULL) { |
5350 |
|
return false; |
5351 |
|
} |
5352 |
|
// Le paramètre multi du modèle du courriel doit exister |
5353 |
|
if ($this->f->getParameter('param_courriel_de_notification_commune_modele_depuis_instruction') === NULL) { |
5354 |
|
return false; |
5355 |
|
} |
5356 |
|
// A ce stade toutes les conditions sont satisfaites |
5357 |
|
return true; |
5358 |
|
} |
5359 |
|
|
5360 |
|
/** |
5361 |
|
* TREATMENT - notifier_commune. |
5362 |
|
* |
5363 |
|
* Notifie aux communes et par courriel la finalisation d'une instruction. |
5364 |
|
* |
5365 |
|
* @return boolean |
5366 |
|
*/ |
5367 |
|
public function notifier_commune() { |
5368 |
|
// Cette méthode permet d'exécuter une routine en début des méthodes |
5369 |
|
// dites de TREATMENT. |
5370 |
|
$this->begin_treatment(__METHOD__); |
5371 |
|
// Définition des paramètres |
5372 |
|
$p_objet = 'param_courriel_de_notification_commune_objet_depuis_instruction'; |
5373 |
|
$p_modele = 'param_courriel_de_notification_commune_modele_depuis_instruction'; |
5374 |
|
$p_courriel = 'param_courriel_de_notification_commune'; |
5375 |
|
// Définition des variables de substitution |
5376 |
|
$id_di = $this->getVal('dossier'); |
5377 |
|
$id_inst = $this->getVal($this->clePrimaire); |
5378 |
|
// Instanciation du DI |
5379 |
|
$di = $this->get_inst_dossier($id_di); |
5380 |
|
// Récupération du paramétrage de la collectivité du dossier |
5381 |
|
$collectivite_di = $di->getVal('om_collectivite'); |
5382 |
|
$params_mono = $this->f->getCollectivite($collectivite_di); |
5383 |
|
// Récupération du paramétrage de la collectivité multi |
5384 |
|
$collectivite_multi = $this->f->get_idx_collectivite_multi(); |
5385 |
|
$params_multi = $this->f->getCollectivite($collectivite_multi); |
5386 |
|
// Vérification de l'objet (obligatoirement multi) |
5387 |
|
$objet = null; |
5388 |
|
if (isset($params_multi[$p_objet]) === true |
5389 |
|
&& $params_multi[$p_objet] !== '') { |
5390 |
|
$objet = $params_multi[$p_objet]; |
5391 |
|
} |
5392 |
|
// Vérification du modèle mono en priorité |
5393 |
|
$modele = null; |
5394 |
|
if (isset($params_mono[$p_modele]) === true |
5395 |
|
&& $params_mono[$p_modele] !== '') { |
5396 |
|
$modele = $params_mono[$p_modele]; |
5397 |
|
|
5398 |
|
} |
5399 |
|
// Sinon vérification du modèle multi |
5400 |
|
if ($modele === null |
5401 |
|
&& isset($params_multi[$p_modele]) === true |
5402 |
|
&& $params_multi[$p_modele] !== '') { |
5403 |
|
$modele = $params_multi[$p_modele]; |
5404 |
|
} |
5405 |
|
// Vérification des adresses de courriel mono |
5406 |
|
$courriels_valides = array(); |
5407 |
|
$courriels_invalides = array(); |
5408 |
|
if (isset($params_mono[$p_courriel]) === true |
5409 |
|
&& $params_mono[$p_courriel] !== '') { |
5410 |
|
// Un mail par ligne |
5411 |
|
$adresses = explode("\n", $params_mono[$p_courriel]); |
5412 |
|
// Vérification de la validité de chaque mail avec preg_match |
5413 |
|
foreach ($adresses as $adresse) { |
5414 |
|
$adresse = trim($adresse); |
5415 |
|
if ($this->f->checkValidEmailAddress($adresse) === 1) { |
5416 |
|
$courriels_valides[] = $adresse; |
5417 |
|
} else { |
5418 |
|
$courriels_invalides[] = $adresse; |
5419 |
|
} |
5420 |
|
} |
5421 |
|
} |
5422 |
|
// Vérification du paramétrage global : |
5423 |
|
// on stoppe le traitement si au moins un paramètre est incorrect |
5424 |
|
if ($objet === null |
5425 |
|
|| $modele === null |
5426 |
|
|| count($courriels_valides) === 0 |
5427 |
|
|| count($courriels_invalides) > 0) { |
5428 |
|
// On construit le message d'erreur adéquat |
5429 |
|
$this->addToMessage(_('Erreur de paramétrage :')); |
5430 |
|
if ($objet === null) { |
5431 |
|
$this->addToMessage(_("* l'objet du courriel envoyé aux communes est vide")); |
5432 |
|
} |
5433 |
|
if ($modele === null) { |
5434 |
|
$this->addToMessage(_("* le modèle du courriel envoyé aux communes est vide")); |
5435 |
|
} |
5436 |
|
if (count($courriels_valides) === 0) { |
5437 |
|
$this->addToMessage(_("* aucun courriel valide de destinataire de la commune")); |
5438 |
|
} |
5439 |
|
if (count($courriels_invalides) > 0) { |
5440 |
|
$courriels_invalides = implode(', ', $courriels_invalides); |
5441 |
|
$this->addToMessage(_("* un ou plusieurs courriels des destinataires de la commune sont invalides : ").$courriels_invalides); |
5442 |
|
} |
5443 |
|
$this->addToMessage(_("Veuillez contacter votre administrateur.")); |
5444 |
|
return $this->end_treatment(__METHOD__, false); |
5445 |
|
} |
5446 |
|
// Remplacement des variables de substitution |
5447 |
|
$objet = str_replace('<DOSSIER_INSTRUCTION>', $id_di, $objet); |
5448 |
|
$modele = $this->formater_modele($modele, $id_di, $id_inst); |
5449 |
|
// Exécution du traitement d'envoi du/des mail(s) |
5450 |
|
$fails = array(); |
5451 |
|
foreach ($courriels_valides as $email) { |
5452 |
|
if ($this->f->sendMail( |
5453 |
|
iconv("UTF-8", "CP1252", $objet), |
5454 |
|
iconv("UTF-8", "CP1252", $modele), |
5455 |
|
iconv("UTF-8", "CP1252", $email)) === false) { |
5456 |
|
$fails[] = $email; |
5457 |
|
} |
5458 |
|
} |
5459 |
|
// Si échec message d'erreur et arrêt du traitement |
5460 |
|
if (count($fails) > 0) { |
5461 |
|
$fails = implode(', ', $fails); |
5462 |
|
$this->addToMessage(_("Erreur lors de l'envoi du courriel aux destinataires : ").$fails); |
5463 |
|
$this->addToMessage(_("Veuillez contacter votre administrateur.")); |
5464 |
|
return $this->end_treatment(__METHOD__, false); |
5465 |
|
} |
5466 |
|
// Ajout du log |
5467 |
|
$this->setValFFromVal(); |
5468 |
|
$val_inst = $this->valF; |
5469 |
|
$val_inst['mails_destinataires'] = implode(', ', $courriels_valides); |
5470 |
|
if ($this->add_log_to_dossier($id_inst, $val_inst) === false) { |
5471 |
|
$this->addToMessage(_("Erreur lors de la notification.")); |
5472 |
|
$this->addToMessage(_("Veuillez contacter votre administrateur.")); |
5473 |
|
return $this->end_treatment(__METHOD__, false); |
5474 |
|
} |
5475 |
|
// Message de validation |
5476 |
|
$this->addToMessage(_('La commune a été notifiée.')); |
5477 |
|
return $this->end_treatment(__METHOD__, true); |
5478 |
|
} |
5479 |
|
|
5480 |
|
/** |
5481 |
|
* Formatte le corps du courriel notifié aux communes |
5482 |
|
* |
5483 |
|
* @param string $modele template du modèle du courriel |
5484 |
|
* @param string $id_di clé primaire du DI |
5485 |
|
* @param string $id_inst clé primaire de l'instruction |
5486 |
|
* @return string corps du mail au format HTML |
5487 |
|
*/ |
5488 |
|
public function formater_modele($modele, $id_di, $id_inst) { |
5489 |
|
// Création du lien d'accès direct à l'instruction |
5490 |
|
$url_inst = PATH_BASE_URL.'spg/direct_link.php?obj=dossier_instruction&action=3'. |
5491 |
|
'&direct_field=dossier&direct_form=instruction&direct_action=3&direct_idx='.$id_inst; |
5492 |
|
$url_inst = '<a href="'.$url_inst.'">'.$url_inst.'</a>'; |
5493 |
|
// Remplacement des champs de fusion |
5494 |
|
$modele = str_replace('<DOSSIER_INSTRUCTION>', $id_di, $modele); |
5495 |
|
$modele = str_replace('<URL_INSTRUCTION>', $url_inst, $modele); |
5496 |
|
$modele = str_replace('<ID_INSTRUCTION>', $id_inst, $modele); |
5497 |
|
// Encodage HTML des sauts de ligne |
5498 |
|
$modele = preg_replace("/\r\n|\r|\n/",'<br/>',$modele); |
5499 |
|
// |
5500 |
|
return $modele; |
5501 |
|
} |
5502 |
|
|
5503 |
|
|
5504 |
|
/** |
5505 |
|
* Récupère l'instance de l'instructeur |
5506 |
|
* |
5507 |
|
* @param integer $instructeur Identifiant de l'instructeur. |
5508 |
|
* |
5509 |
|
* @return object |
5510 |
|
*/ |
5511 |
|
protected function get_inst_instructeur($instructeur) { |
5512 |
|
// |
5513 |
|
return $this->get_inst_common("instructeur", $instructeur); |
5514 |
|
} |
5515 |
|
|
5516 |
|
|
5517 |
|
/** |
5518 |
|
* Récupère l'instance de l'utilisateur |
5519 |
|
* |
5520 |
|
* @param integer $om_utilisateur Identifiant de l'utilisateur. |
5521 |
|
* |
5522 |
|
* @return object |
5523 |
|
*/ |
5524 |
|
protected function get_inst_om_utilisateur($om_utilisateur) { |
5525 |
|
// |
5526 |
|
return $this->get_inst_common("om_utilisateur", $om_utilisateur); |
5527 |
|
} |
5528 |
|
|
5529 |
|
|
5530 |
|
/** |
5531 |
|
* Récupère l'instance de la division. |
5532 |
|
* |
5533 |
|
* @param integer $division Identifiant de la division. |
5534 |
|
* |
5535 |
|
* @return object |
5536 |
|
*/ |
5537 |
|
protected function get_inst_division($division) { |
5538 |
|
// |
5539 |
|
return $this->get_inst_common("division", $division); |
5540 |
|
} |
5541 |
|
|
5542 |
|
|
5543 |
|
/** |
5544 |
|
* Récupère l'instance de la direction. |
5545 |
|
* |
5546 |
|
* @param integer $direction Identifiant de la direction. |
5547 |
|
* |
5548 |
|
* @return object |
5549 |
|
*/ |
5550 |
|
protected function get_inst_direction($direction) { |
5551 |
|
// |
5552 |
|
return $this->get_inst_common("direction", $direction); |
5553 |
|
} |
5554 |
|
|
5555 |
|
|
5556 |
|
/** |
5557 |
|
* Récupère la collectivité d'un instructeur en passant par sa division puis |
5558 |
|
* par sa direction. |
5559 |
|
* |
5560 |
|
* @param integer $instructeur Identifiant de l'instructeur. |
5561 |
|
* |
5562 |
|
* @return integer |
5563 |
|
*/ |
5564 |
|
protected function get_instructeur_om_collectivite($instructeur) { |
5565 |
|
// Chemin vers la collectivité d'un instructeur |
5566 |
|
$inst_instr = $this->get_inst_instructeur($instructeur); |
5567 |
|
$inst_division = $this->get_inst_division($inst_instr->getVal('division')); |
5568 |
|
$inst_direction = $this->get_inst_direction($inst_division->getVal('direction')); |
5569 |
|
|
5570 |
|
// Collectivité |
5571 |
|
$om_collectivite = $inst_direction->getVal('om_collectivite'); |
5572 |
|
|
5573 |
|
// |
5574 |
|
return $om_collectivite; |
5575 |
|
} |
5576 |
|
|
5577 |
|
/* |
5578 |
|
* CONDITION - can_user_access_dossier_contexte_ajout |
5579 |
|
* |
5580 |
|
* Vérifie que l'utilisateur a bien accès au dossier d'instruction passé dans le |
5581 |
|
* formulaire d'ajout. |
5582 |
|
* Cette méthode vérifie que l'utilisateur est lié au groupe du dossier, et si le |
5583 |
|
* dossier est confidentiel qu'il a accès aux confidentiels de ce groupe. |
5584 |
|
* |
5585 |
|
*/ |
5586 |
|
function can_user_access_dossier_contexte_ajout() { |
5587 |
|
|
5588 |
|
($this->f->get_submitted_get_value('idxformulaire') !== null ? $id_dossier = |
5589 |
|
$this->f->get_submitted_get_value('idxformulaire') : $id_dossier = ""); |
5590 |
|
// |
5591 |
|
if ($id_dossier !== "") { |
5592 |
|
require_once "../obj/dossier_instruction.class.php"; |
5593 |
|
$dossier = new dossier_instruction($id_dossier, $f->db, DEBUG); |
5594 |
|
// |
5595 |
|
return $dossier->can_user_access_dossier(); |
5596 |
|
} |
5597 |
|
return false; |
5598 |
|
} |
5599 |
|
|
5600 |
|
/* |
5601 |
|
* CONDITION - can_user_access_dossier |
5602 |
|
* |
5603 |
|
* Vérifie que l'utilisateur a bien accès au dossier lié à l'instruction instanciée. |
5604 |
|
* Cette méthode vérifie que l'utilisateur est lié au groupe du dossier, et si le |
5605 |
|
* dossier est confidentiel qu'il a accès aux confidentiels de ce groupe. |
5606 |
|
* |
5607 |
|
*/ |
5608 |
|
function can_user_access_dossier_contexte_modification() { |
5609 |
|
|
5610 |
|
$id_dossier = $this->getVal('dossier'); |
5611 |
|
// |
5612 |
|
if ($id_dossier !== "" && $id_dossier !== null) { |
5613 |
|
require_once "../obj/dossier_instruction.class.php"; |
5614 |
|
$dossier = new dossier_instruction($id_dossier, $f->db, DEBUG); |
5615 |
|
// |
5616 |
|
return $dossier->can_user_access_dossier(); |
5617 |
|
} |
5618 |
|
return false; |
5619 |
|
} |
5620 |
|
|
5621 |
}// fin classe |
}// fin classe |
5622 |
|
|
5623 |
?> |
?> |