1 |
<?php |
<?php |
2 |
//$Id$ |
/** |
3 |
//gen openMairie le 10/02/2011 20:34 |
* |
4 |
/* |
* |
5 |
$Id: instruction.class.php,v 1.29 2010-10-27 10:52:20 fraynaud Exp $ |
* specific : |
6 |
specific : |
* - cle secondaire |
7 |
- cle secondaire |
* destruction autorisée que pour le dernier evenement |
8 |
destruction autorisée que pour le dernier evenement |
* [delete the last event ] |
9 |
[delete the last event ] |
* - variable globale [global variables] |
10 |
- variable globale [global variables] |
* var $archive_date_depot; |
11 |
var $archive_date_depot; |
* var $retourformulaire; |
12 |
var $retourformulaire; |
* var $idxformulaire; |
13 |
var $idxformulaire; |
* - modification des données dans dossier trigger avant |
14 |
- modification des données dans dossier trigger avant |
* [modify dossier data with trigger function] |
15 |
[modify dossier data with trigger function] |
* - function moisdate : pour ajouter des mois a une date |
16 |
- function moisdate : pour ajouter des mois a une date |
* [add months (delay) and calculation final date] |
17 |
[add months (delay) and calculation final date] |
* - voir script_lang.js : bible ... |
18 |
- voir script_lang.js : bible ... |
* |
19 |
*/ |
* @package openfoncier |
20 |
require_once ("../gen/obj/instruction.class.php"); |
* @version SVN : $Id$ |
21 |
require_once("../services/outgoing/messageenqueuer.php"); |
*/ |
22 |
|
|
23 |
|
// |
24 |
|
require_once "../gen/obj/instruction.class.php"; |
25 |
|
|
26 |
|
// |
27 |
|
require_once "../services/outgoing/messageenqueuer.php"; |
28 |
|
|
29 |
|
// |
30 |
class instruction extends instruction_gen { |
class instruction extends instruction_gen { |
31 |
|
|
32 |
var $archive_date_depot; // specific |
var $archive_date_depot; // specific |
33 |
var $retourformulaire; // specific |
var $retourformulaire; // specific |
34 |
var $idxformulaire; // specific |
var $idxformulaire; // specific |
35 |
|
var $valEvenement; |
36 |
|
// Tableau contenant une partie des métadonnées arrêtés |
37 |
|
var $metadonneesArrete; |
38 |
|
|
39 |
|
var $metadata = array( |
40 |
|
"om_fichier_instruction" => array( |
41 |
|
"dossier" => "getDossier", |
42 |
|
"dossier_autorisation" => "getDossierAutorisation", |
43 |
|
"date_demande_initiale" => "getDateDemandeInitiale", |
44 |
|
"dossier_instruction_type" => "getDossierInstructionType", |
45 |
|
"statut" => "getStatut", |
46 |
|
"dossier_autorisation_type" => "getDossierAutorisationType", |
47 |
|
"date_creation" => "getDateEvenement", |
48 |
|
"groupe_instruction" => 'getGroupeInstruction', |
49 |
|
), |
50 |
|
"document_arrete" => array( |
51 |
|
"numArrete" => "getNumArrete", |
52 |
|
"specialiteArrete" => "getSpecialiteArrete", |
53 |
|
"decisionArrete" => "getDecisionArrete", |
54 |
|
"chketatReglementaire" => "getChketatReglementaire", |
55 |
|
"chkNotification" => "getChkNotification", |
56 |
|
"dateNotification" => "getDateNotification", |
57 |
|
"chkCreationdroit" => "getChkCreationdroit", |
58 |
|
"chkPublication" => "getChkPublication", |
59 |
|
"datePublication" => "getDatePublication", |
60 |
|
"chkControleLegalite" => "getChkControleLegalite", |
61 |
|
"dateSignatureArrete" => "getDateSignatureArrete", |
62 |
|
"nomSignataire" => "getNomSignataire", |
63 |
|
"qualiteSignataire" => "getQualiteSignataire", |
64 |
|
"chkDelegation" => "getChkDelegation", |
65 |
|
"ap_numRue" => "getAp_numRue", |
66 |
|
"ap_nomDeLaVoie" => "getAp_nomDeLaVoie", |
67 |
|
"ap_codePostal" => "getAp_codePostal", |
68 |
|
"ap_ville" => "getAp_ville", |
69 |
|
), |
70 |
|
); |
71 |
|
|
72 |
function instruction($id,&$db,$debug) { |
|
73 |
$this->constructeur($id,$db,$debug); |
function instruction($id, &$db, $debug) { |
74 |
}// fin constructeur |
$this->constructeur($id, $db, $debug); |
75 |
|
} |
76 |
|
|
77 |
// {{{ Gestion de la confidentialité des données spécifiques |
// {{{ Gestion de la confidentialité des données spécifiques |
78 |
|
|
82 |
function checkAccessibility() { |
function checkAccessibility() { |
83 |
// |
// |
84 |
parent::checkAccessibility(); |
parent::checkAccessibility(); |
85 |
// Si l'utilisateur est un intructeur qui en correspond pas à la |
// Si l'utilisateur est un intructeur qui ne correspond pas à la |
86 |
// division du dossier |
// division du dossier |
87 |
if ($this->f->isUserInstructeur() |
if ($this->f->isUserInstructeur() |
88 |
&& isset($this->f->om_utilisateur["division"]) |
&& isset($this->f->om_utilisateur["division"]) |
98 |
&& $this->val[array_search("lu", $this->champs)]== "t") { |
&& $this->val[array_search("lu", $this->champs)]== "t") { |
99 |
unset($this->actions_sup["lu"]); |
unset($this->actions_sup["lu"]); |
100 |
} |
} |
101 |
|
|
102 |
|
//Si le document est déjà finalisé, on affiche uniquement le lien de |
103 |
|
//dé-finalisation |
104 |
|
$om_final_instruction = $this->getVal("om_final_instruction"); |
105 |
|
if ( isset($this->actions_sup["finalisation"]) && |
106 |
|
$om_final_instruction== "t" ){ |
107 |
|
|
108 |
|
//On cache le lien de finalisation et on affiche le bon lien pour l'édition |
109 |
|
unset($this->actions_sup["finalisation"]); |
110 |
|
$this->actions_sup["pdfetat"]["lien"] = "../spg/file.php?id="; |
111 |
|
$this->actions_sup["pdfetat"]["id"] = |
112 |
|
"&obj=instruction&champ=om_fichier_instruction"; |
113 |
|
} |
114 |
|
//Si le document n'est pas finalisé, on affiche uniquement le lien de |
115 |
|
//finalisation |
116 |
|
if ( isset($this->actions_sup["definalisation"]) && |
117 |
|
$om_final_instruction!= "t" ){ |
118 |
|
|
119 |
|
//On cache le lien de finalisation et on affiche le bon lien pour l'édition |
120 |
|
unset($this->actions_sup["definalisation"]); |
121 |
|
$this->actions_sup["pdfetat"]["lien"] = "../app/pdf_instruction.php?idx="; |
122 |
|
$this->actions_sup["pdfetat"]["id"] = ""; |
123 |
|
} |
124 |
} |
} |
125 |
|
|
126 |
/** |
/** |
134 |
&& $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier() |
&& $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier() |
135 |
&& $this->getParameter("maj") != 3) { |
&& $this->getParameter("maj") != 3) { |
136 |
// |
// |
137 |
|
$this->addToLog("canAccess(): utilisateur instructeur sur un dossier d'une autre division", EXTRA_VERBOSE_MODE); |
138 |
return false; |
return false; |
139 |
} |
} |
140 |
// |
// |
142 |
} |
} |
143 |
|
|
144 |
/** |
/** |
145 |
* Cette méthode permet de récupérer la division d'un dossier |
* Cette variable permet de stocker le résultat de la méthode |
146 |
|
* getDivisionFromDossier() afin de ne pas effectuer le recalcul à chacun de |
147 |
|
* ces appels. |
148 |
|
* @var string Code de la division du dossier en cours |
149 |
|
*/ |
150 |
|
var $_division_from_dossier = NULL; |
151 |
|
|
152 |
|
/** |
153 |
|
* Cette méthode permet de récupérer le code de division correspondant |
154 |
|
* au dossier sur lequel on se trouve. |
155 |
|
* |
156 |
|
* @return string Code de la division du dossier en cours |
157 |
*/ |
*/ |
158 |
function getDivisionFromDossier() { |
function getDivisionFromDossier() { |
159 |
|
|
160 |
|
// Cette méthode peut être appelée plusieurs fois lors d'une requête. |
161 |
|
// Pour éviter de refaire le traitement de recherche de la division |
162 |
|
// alors on vérifie si nous ne l'avons pas déjà calculé. |
163 |
|
if ($this->_division_from_dossier != NULL) { |
164 |
|
// Logger |
165 |
|
$this->addToLog("getDivisionFromDossier(): retour de la valeur déjà calculée - '".$this->_division_from_dossier."'", EXTRA_VERBOSE_MODE); |
166 |
|
// On retourne la valeur déjà calculée |
167 |
|
return $this->_division_from_dossier; |
168 |
|
} |
169 |
|
|
170 |
|
// Par défaut, on définit la valeur du dossier à NULL |
171 |
|
$dossier = NULL; |
172 |
|
// Test sur le mode et le contexte du formulaire |
173 |
|
if ($this->getParameter("maj") == 0 |
174 |
|
&& ($this->getParameter("retourformulaire") == "dossier" |
175 |
|
|| $this->getParameter("retourformulaire") == "dossier_instruction" |
176 |
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_encours" |
177 |
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_encours" |
178 |
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_clotures" |
179 |
|
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_clotures")) { |
180 |
|
// Si on se trouve en mode AJOUT (seul mode où l'enregistrement |
181 |
|
// n'existe pas en base de données) ET que nous nous trouvons |
182 |
|
// dans le contexte d'un dossier d'instruction alors on récupère |
183 |
|
// le numéro de dossier depuis le paramètre 'idxformulaire' |
184 |
|
$dossier = $this->getParameter("idxformulaire"); |
185 |
|
} else { |
186 |
|
// Sinon on récupère le numéro de dossier dans le champs dossier de |
187 |
|
// l'enregistrement (en base de données) |
188 |
|
$dossier = $this->getVal("dossier"); |
189 |
|
} |
190 |
|
|
191 |
|
// On appelle la méthode de la classe utils qui renvoi le code de la |
192 |
|
// division d'un dossier, on la stocke pour ne pas refaire le calcul au |
193 |
|
// prochain appel de cette méthode |
194 |
|
$this->_division_from_dossier = $this->f->getDivisionFromDossier($dossier); |
195 |
|
// Logger |
196 |
|
$this->addToLog("getDivisionFromDossier(): retour de la valeur nouvellement calculée - '".$this->_division_from_dossier."'", EXTRA_VERBOSE_MODE); |
197 |
|
// On retourne la valeur retournée |
198 |
|
return $this->_division_from_dossier; |
199 |
|
|
200 |
|
} |
201 |
|
|
202 |
|
/** |
203 |
|
* Cette méthode permet de récupérer le dossier d'autorisation d'un dossier |
204 |
|
*/ |
205 |
|
function getDossierAutorisationFromDossier($id) { |
206 |
// |
// |
207 |
if (!isset($this->val[array_search("dossier", $this->champs)])) { |
if (!isset($id)) { |
208 |
return NULL; |
return NULL; |
209 |
} |
} |
210 |
// |
// |
211 |
$sql = "select division from ".DB_PREFIXE."dossier "; |
$sql = "select dossier_autorisation from ".DB_PREFIXE."dossier "; |
212 |
$sql .= " where dossier='".$this->val[array_search("dossier", $this->champs)]."'"; |
$sql .= " where dossier='".$id."'"; |
213 |
// |
// |
214 |
$division = $this->db->getOne($sql); |
$dossier_autorisation = $this->db->getOne($sql); |
215 |
$this->addToLog("getDivisionFromDossier(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
$this->addToLog("getDossierAutorisationFromDossier(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
216 |
database::isError($division); |
database::isError($dossier_autorisation); |
217 |
// |
// |
218 |
return $division; |
return $dossier_autorisation; |
219 |
} |
} |
220 |
|
|
221 |
// }}} |
// }}} |
222 |
|
|
223 |
function cleSecondaire($id,&$db,$val,$DEBUG) { |
function setType(&$form, $maj) { |
224 |
parent::cleSecondaire($id,$db,$val,$DEBUG); |
// |
225 |
// controle suppression cle secondaire [secondary key delete control] |
parent::setType($form, $maj); |
226 |
// ------------------------------------------------------------------------------------ |
// On cache tous les champs |
227 |
// specifique detruire que le dernier [specific instruction : delete the last event ] |
// XXX |
|
// ------------------------------------------------------------------------------------ |
|
|
$dernierevenement=''; |
|
|
$sql="select max(instruction) from ".DB_PREFIXE."instruction where dossier ='". |
|
|
$this->idxformulaire."'"; |
|
|
$dernierevenement = $db->getOne($sql); |
|
|
if($dernierevenement==$id){ |
|
|
$this->correct=true; |
|
|
$this->addToMessage(_('Destruction_chronologique')); |
|
|
}else{ |
|
|
$this->addToMessage(_('Destruction_evenement')." : ".$dernierevenement); |
|
|
$this->addToMessage(_('Destruction_chronologique')); |
|
|
$this->correct=false; |
|
|
} |
|
|
} |
|
|
|
|
|
// Sélectionne le signataire_arrete par défaut |
|
|
function setVal(&$form,$maj,$validation){ |
|
|
|
|
|
// Ajout |
|
|
if($maj == 0) { |
|
|
|
|
|
// Création de la requête |
|
|
$sql = "SELECT signataire_arrete |
|
|
FROM ".DB_PREFIXE."signataire_arrete |
|
|
WHERE defaut IS TRUE"; |
|
|
|
|
|
// Exécution de la requête |
|
|
$this->f->addToLog("deleteAllLienDossierInstructionTypeEvenementEvenement(): db->query(\"".$sql."\");", VERBOSE_MODE); |
|
|
$res = $this->f->db->query($sql); |
|
|
$this->f->isDatabaseError(); |
|
|
|
|
|
$row = $res->fetchrow(DB_FETCHMODE_ASSOC); |
|
|
|
|
|
if ( isset($row['signataire_arrete']) && is_numeric($row['signataire_arrete'])){ |
|
|
|
|
|
$form->setVal("signataire_arrete",$row['signataire_arrete']); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
/*Met des valeurs par défaut dans certains des sous-formulaire*/ |
|
|
function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire){ |
|
|
if ($validation==0 and $maj<2) { |
|
|
if ($maj == 0){ |
|
|
$form->setVal("destinataire", $idxformulaire); |
|
|
$form->setVal("dossier", $idxformulaire); |
|
|
$form->setVal("date_evenement", date('Y-m-d')); |
|
|
} |
|
|
$form->setVal("bible_auto","bible_auto()"); |
|
|
$form->setVal("bible","bible()"); |
|
|
$form->setVal("bible2","bible2()"); |
|
|
} |
|
|
$this->retourformulaire=$retourformulaire; |
|
|
$this->idxformulaire=$idxformulaire; |
|
|
} |
|
|
|
|
|
/*Affecte un type à certains champs*/ |
|
|
function setType(&$form,$maj) { |
|
|
parent::setType($form,$maj); |
|
|
if ($maj < 2) { //ajouter et modifier |
|
|
$form->setType('destinataire', 'hidden'); |
|
|
$form->setType('lettretype', 'hiddenstatic'); |
|
|
$form->setType('complement', 'textarea'); |
|
|
$form->setType('complement2', 'textarea'); |
|
|
$form->setType('bible_auto', 'httpclick'); |
|
|
$form->setType('bible', 'httpclick'); |
|
|
$form->setType('bible2', 'httpclick'); |
|
|
$form->setType('dossier', 'hidden'); |
|
|
$form->setType('libelle', 'hiddenstatic'); |
|
|
$form->setType('signataire_arrete','select'); |
|
|
if($maj==0){ // add |
|
|
$form->setType('instruction', 'hiddenstatic'); |
|
|
$form->setType('evenement', 'select'); |
|
|
$form->setType('date_evenement', 'date2'); |
|
|
}else{ // modify |
|
|
$form->setType('instruction', 'hiddenstatic'); |
|
|
$form->setType('evenement', 'hiddenstatic'); |
|
|
//$form->setType('date_evenement', 'hiddenstaticdate'); |
|
|
$form->setType('date_evenement', 'date2'); |
|
|
// necessaire pour calcul de date en modification |
|
|
$form->setType('delai', 'hiddenstatic'); |
|
|
} |
|
|
} elseif($maj==2){ |
|
|
$form->setType('dossier', 'hidden'); |
|
|
$form->setType('bible_auto', 'hidden'); |
|
|
$form->setType('bible', 'hidden'); |
|
|
$form->setType('bible2', 'hidden'); |
|
|
}else { |
|
|
$form->setType('destinataire', 'hidden'); |
|
|
$form->setType('dossier', 'hidden'); |
|
|
$form->setType('bible_auto', 'hidden'); |
|
|
$form->setType('bible', 'hidden'); |
|
|
$form->setType('bible2', 'hidden'); |
|
|
} |
|
228 |
$form->setType('complement3', 'hidden'); |
$form->setType('complement3', 'hidden'); |
229 |
$form->setType('bible3', 'hidden'); |
$form->setType('bible3', 'hidden'); |
230 |
$form->setType('complement4', 'hidden'); |
$form->setType('complement4', 'hidden'); |
251 |
$form->setType('bible14', 'hidden'); |
$form->setType('bible14', 'hidden'); |
252 |
$form->setType('complement15', 'hidden'); |
$form->setType('complement15', 'hidden'); |
253 |
$form->setType('bible15', 'hidden'); |
$form->setType('bible15', 'hidden'); |
254 |
|
// |
255 |
$form->setType('delai', 'hidden'); |
$form->setType('delai', 'hidden'); |
256 |
$form->setType('etat', 'hidden'); |
$form->setType('etat', 'hidden'); |
257 |
$form->setType('accord_tacite', 'hidden'); |
$form->setType('accord_tacite', 'hidden'); |
258 |
$form->setType('action', 'hidden'); |
$form->setType('action', 'hidden'); |
259 |
$form->setType('delai_notification', 'hidden'); |
$form->setType('delai_notification', 'hidden'); |
260 |
$form->setType('avis_decision', 'hidden'); |
$form->setType('avis_decision', 'hidden'); |
261 |
|
// |
262 |
$form->setType('archive_delai', 'hidden'); |
$form->setType('archive_delai', 'hidden'); |
263 |
$form->setType('archive_etat', 'hidden'); |
$form->setType('archive_etat', 'hidden'); |
264 |
$form->setType('archive_accord_tacite', 'hidden'); |
$form->setType('archive_accord_tacite', 'hidden'); |
265 |
$form->setType('archive_avis', 'hidden'); |
$form->setType('archive_avis', 'hidden'); |
266 |
$form->setType('archive_date_complet', 'hidden'); |
$form->setType('archive_date_complet', 'hidden'); |
267 |
|
$form->setType('archive_date_dernier_depot', 'hidden'); |
268 |
$form->setType('archive_date_rejet', 'hidden'); |
$form->setType('archive_date_rejet', 'hidden'); |
269 |
$form->setType('archive_date_limite', 'hidden'); |
$form->setType('archive_date_limite', 'hidden'); |
270 |
$form->setType('archive_date_notification_delai', 'hidden'); |
$form->setType('archive_date_notification_delai', 'hidden'); |
273 |
$form->setType('archive_date_achevement', 'hidden'); |
$form->setType('archive_date_achevement', 'hidden'); |
274 |
$form->setType('archive_date_conformite', 'hidden'); |
$form->setType('archive_date_conformite', 'hidden'); |
275 |
$form->setType('archive_date_chantier', 'hidden'); |
$form->setType('archive_date_chantier', 'hidden'); |
276 |
|
// |
277 |
$form->setType('numero_arrete', 'hidden'); |
$form->setType('numero_arrete', 'hidden'); |
278 |
|
// |
279 |
|
$form->setType('code_barres', 'hidden'); |
280 |
|
|
281 |
|
// |
282 |
|
$form->setType('archive_incompletude','hidden'); |
283 |
|
$form->setType('archive_evenement_suivant_tacite','hidden'); |
284 |
|
$form->setType('archive_evenement_suivant_tacite_incompletude','hidden'); |
285 |
|
$form->setType('archive_etat_pendant_incompletude','hidden'); |
286 |
|
$form->setType('archive_date_limite_incompletude','hidden'); |
287 |
|
$form->setType('archive_delai_incompletude','hidden'); |
288 |
|
if ($maj < 2) { //ajouter et modifier |
289 |
|
$form->setType('destinataire', 'hidden'); |
290 |
|
$form->setType('lettretype', 'hiddenstatic'); |
291 |
|
$form->setType('complement', 'textarea'); |
292 |
|
$form->setType('complement2', 'textarea'); |
293 |
|
$form->setType('bible_auto', 'httpclick'); |
294 |
|
$form->setType('bible', 'httpclick'); |
295 |
|
$form->setType('bible2', 'httpclick'); |
296 |
|
$form->setType('dossier', 'hidden'); |
297 |
|
$form->setType('libelle', 'hiddenstatic'); |
298 |
|
$form->setType('signataire_arrete','select'); |
299 |
|
$form->setType('date_envoi_signature','datedisabled'); |
300 |
|
$form->setType('date_retour_signature','datedisabled'); |
301 |
|
$form->setType('date_envoi_rar','datedisabled'); |
302 |
|
$form->setType('date_retour_rar','datedisabled'); |
303 |
|
$form->setType('date_envoi_controle_legalite','datedisabled'); |
304 |
|
$form->setType('date_retour_controle_legalite','datedisabled'); |
305 |
|
if($maj==0){ // add |
306 |
|
$form->setType('instruction', 'hiddenstatic'); |
307 |
|
$form->setType('evenement', 'select'); |
308 |
|
$form->setType('date_evenement', 'date2'); |
309 |
|
}else{ // modify |
310 |
|
$form->setType('instruction', 'hiddenstatic'); |
311 |
|
$form->setType('evenement', 'selecthiddenstatic'); |
312 |
|
//$form->setType('date_evenement', 'hiddenstaticdate'); |
313 |
|
$form->setType('date_evenement', 'date2'); |
314 |
|
// necessaire pour calcul de date en modification |
315 |
|
//$form->setType('delai', 'hiddenstatic'); |
316 |
|
} |
317 |
|
} elseif($maj==2){ |
318 |
|
$form->setType('dossier', 'hidden'); |
319 |
|
$form->setType('bible_auto', 'hidden'); |
320 |
|
$form->setType('bible', 'hidden'); |
321 |
|
$form->setType('bible2', 'hidden'); |
322 |
|
}else { |
323 |
|
$form->setType('destinataire', 'hidden'); |
324 |
|
$form->setType('dossier', 'hidden'); |
325 |
|
$form->setType('bible_auto', 'hidden'); |
326 |
|
$form->setType('bible', 'hidden'); |
327 |
|
$form->setType('bible2', 'hidden'); |
328 |
|
} |
329 |
|
|
330 |
|
//Cache les champs pour la finalisation |
331 |
|
$form->setType('om_fichier_instruction', 'hidden'); |
332 |
|
$form->setType('om_final_instruction', 'hidden'); |
333 |
|
// Cache le document arrêté |
334 |
|
$form->setType('document_arrete', 'hidden'); |
335 |
} |
} |
336 |
|
|
337 |
/*Met des valeurs choisies dans certains select du formulaire*/ |
function setSelect(&$form, $maj,&$db,$debug) { |
338 |
function setSelect(&$form, $maj,&$db,$DEBUG) { |
/** |
339 |
|
* On ne surcharge pas la méthode parent car une requête sur la table |
340 |
|
* dossier est mauvaise pour les performances, car la requête qui |
341 |
|
* concerne evenement est plus complexe que celle générée et car les |
342 |
|
* champs action, avis_decision et etat ne sont pas utilisés comme des |
343 |
|
* select |
344 |
|
*/ |
345 |
if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php")) |
if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php")) |
346 |
include ("../sql/".$db->phptype."/".$this->table.".form.inc.php"); |
include ("../sql/".$db->phptype."/".$this->table.".form.inc.php"); |
347 |
|
elseif(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc")) |
348 |
|
include ("../sql/".$db->phptype."/".$this->table.".form.inc"); |
349 |
|
|
350 |
parent::setSelect($form, $maj, $db, $DEBUG); |
//// action |
351 |
|
//$this->init_select($form, $db, $maj, $debug, "action", |
352 |
// *** evenement *** |
// $sql_action, $sql_action_by_id, false); |
353 |
$contenu=array(); |
|
354 |
// etat du dossier |
//// avis_decision |
355 |
$sql="select etat from ".DB_PREFIXE."dossier where dossier ='". |
//$this->init_select($form, $db, $maj, $debug, "avis_decision", |
356 |
$this->idxformulaire."'"; |
// $sql_avis_decision, $sql_avis_decision_by_id, false); |
357 |
$etat_dossier = $db->getOne($sql); |
|
358 |
// nature du dossier d'autorisation |
//// dossier |
359 |
$sql="select code from ".DB_PREFIXE."dossier |
//$this->init_select($form, $db, $maj, $debug, "dossier", |
360 |
INNER JOIN ".DB_PREFIXE."dossier_autorisation ON |
// $sql_dossier, $sql_dossier_by_id, false); |
361 |
dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
|
362 |
INNER JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille ON |
//// etat |
363 |
dossier_autorisation.dossier_autorisation_type_detaille = |
//$this->init_select($form, $db, $maj, $debug, "etat", |
364 |
dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
// $sql_etat, $sql_etat_by_id, false); |
365 |
WHERE dossier ='". |
|
366 |
$this->idxformulaire."'"; |
//// evenement |
367 |
$nature_dossier = $db->getOne($sql); |
//$this->init_select($form, $db, $maj, $debug, "evenement", |
368 |
|
// $sql_evenement, $sql_evenement_by_id, false); |
369 |
// recherche des evenement de transition |
|
370 |
// XXX modifier la requète après la modification de structure du workflow |
// signataire_arrete |
371 |
$sql= $sql_transition." where transition.etat ='".$etat_dossier."' and dossier='". |
$this->init_select($form, $db, $maj, $debug, "signataire_arrete", |
372 |
$this->idxformulaire."' order by evenement.action"; |
$sql_signataire_arrete, $sql_signataire_arrete_by_id, true); |
373 |
|
|
374 |
// *** attention en dur le CU |
/** |
375 |
$this->addToLog("setSelect(): db->query(\"".$sql."\");", VERBOSE_MODE); |
* Gestion du filtre sur les événements de workflow disponibles |
376 |
|
* On récupère ici en fonction de l'état du dossier d'instruction en |
377 |
|
* cours et du type du dossier d'instruction en cours la liste |
378 |
|
* événements disponibles. |
379 |
|
*/ |
380 |
|
if ($maj == 0) { |
381 |
|
// Récupération des événements par une jointure entre la table dossier |
382 |
|
// et la table transition et la table evenement et la table |
383 |
|
// lien_dossier_instruction_type_evenement en fonction de l'identifiant |
384 |
|
// du dossier d'instruction en cours |
385 |
|
$sql = "SELECT |
386 |
|
evenement.evenement, |
387 |
|
(evenement.libelle||' ['||evenement.action||']') as lib |
388 |
|
FROM ".DB_PREFIXE."dossier |
389 |
|
INNER JOIN ".DB_PREFIXE."lien_dossier_instruction_type_evenement |
390 |
|
ON dossier.dossier_instruction_type=lien_dossier_instruction_type_evenement.dossier_instruction_type |
391 |
|
INNER JOIN ".DB_PREFIXE."evenement |
392 |
|
ON evenement.evenement=lien_dossier_instruction_type_evenement.evenement |
393 |
|
INNER JOIN ".DB_PREFIXE."transition |
394 |
|
ON evenement.evenement = transition.evenement |
395 |
|
AND dossier.etat=transition.etat |
396 |
|
WHERE dossier.dossier='".$this->idxformulaire."' |
397 |
|
ORDER BY evenement.action"; |
398 |
|
$res = $db->query($sql); |
399 |
|
$this->addToLog("setSelect(): db->query(\"".$sql."\");", VERBOSE_MODE); |
400 |
|
if (database::isError($res)) { |
401 |
|
die($res->getMessage()); |
402 |
|
} |
403 |
|
// Remplissage du tableau du select |
404 |
|
$contenu = array( |
405 |
|
0 => array("",), |
406 |
|
1 => array(_('choisir')." "._('evenement'),) |
407 |
|
); |
408 |
|
while ($row=& $res->fetchRow()) { |
409 |
|
$contenu[0][] = $row[0]; |
410 |
|
$contenu[1][] = $row[1]; |
411 |
|
} |
412 |
|
$form->setSelect("evenement", $contenu); |
413 |
|
} else { |
414 |
|
$sql = "SELECT |
415 |
|
(evenement.libelle||' ['||evenement.action||']') as lib |
416 |
|
FROM ".DB_PREFIXE."evenement |
417 |
|
WHERE evenement.evenement=".$this->getVal("evenement").""; |
418 |
|
$res = $db->getone($sql); |
419 |
|
$this->addToLog("setSelect(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
420 |
|
if (database::isError($res)) { |
421 |
|
die($res->getMessage()); |
422 |
|
} |
423 |
|
// |
424 |
|
$contenu = array( |
425 |
|
0 => array($this->getVal("evenement"),), |
426 |
|
1 => array($res,) |
427 |
|
); |
428 |
|
$form->setSelect("evenement", $contenu); |
429 |
|
} |
430 |
|
|
431 |
$res = $db->query($sql); |
/** |
432 |
if (database::isError($res)) |
* Gesion des liens vers la bible |
433 |
die($res->getMessage()); |
*/ |
434 |
$contenu[0][0]=""; |
// lien bible_auto |
435 |
$contenu[1][0]=_('choisir')." "._('evenement'); |
$contenu = array(_("automatique")); |
|
$k=1; |
|
|
while ($row=& $res->fetchRow()){ |
|
|
if($maj==0){ // ajouter |
|
|
$contenu[0][$k]=$row[0]; |
|
|
$contenu[1][$k]=$row[1]; |
|
|
$k++; |
|
|
}else{ |
|
|
// select hiddenstatic |
|
|
$contenu[0][$k]=$row[0]; |
|
|
$contenu[1][$k]=$row[1]; |
|
|
$k++; |
|
|
} |
|
|
} |
|
|
$form->setSelect("evenement",$contenu); |
|
|
// lien bible_auto [link] |
|
|
$contenu=array(); |
|
|
$contenu[0]=" automatique "; |
|
436 |
$form->setSelect("bible_auto",$contenu); |
$form->setSelect("bible_auto",$contenu); |
437 |
// lien bible1 |
// lien bible1 |
438 |
$contenu=array(); |
$contenu = array(_("bible")); |
|
$contenu[0]=" Bible "; |
|
439 |
$form->setSelect("bible",$contenu); |
$form->setSelect("bible",$contenu); |
440 |
// lien bible2 |
// lien bible2 |
441 |
$contenu=array(); |
$contenu = array(_("bible")); |
|
$contenu[0]=" Bible "; |
|
442 |
$form->setSelect("bible2",$contenu); |
$form->setSelect("bible2",$contenu); |
443 |
} // function select |
} |
444 |
|
|
445 |
|
function cleSecondaire($id, &$db, $val, $DEBUG) { |
446 |
|
// |
447 |
|
parent::cleSecondaire($id, $db, $val, $DEBUG); |
448 |
|
|
449 |
|
/** |
450 |
|
* Vérification que l'élément supprimé est le dernier pour pouvoir |
451 |
|
* remodifier les données de manière itérative. |
452 |
|
*/ |
453 |
|
// Initialisation |
454 |
|
$dernierevenement = ""; |
455 |
|
// Récupération du dernier élément de la table d'instruction qui |
456 |
|
// concerne le dossier en cours |
457 |
|
$sql = "SELECT max(instruction) |
458 |
|
FROM ".DB_PREFIXE."instruction |
459 |
|
WHERE dossier ='".$this->idxformulaire."'"; |
460 |
|
$dernierevenement = $db->getOne($sql); |
461 |
|
$this->addToLog("setSelect(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
462 |
|
if (database::isError($dernierevenement)) { |
463 |
|
die($dernierevenement->getMessage()); |
464 |
|
} |
465 |
|
// Si on se trouve effectivement sur le dernier evenement d'instruction |
466 |
|
if ($dernierevenement == $id) { |
467 |
|
// Alors on valide la suppression |
468 |
|
$this->correct = true; |
469 |
|
$this->addToMessage(_('Destruction_chronologique')); |
470 |
|
} else { |
471 |
|
// Alors on annule la suppression |
472 |
|
$this->correct = false; |
473 |
|
$this->addToMessage(_("Seul le dernier evenement d'instruction peut etre supprime.")); |
474 |
|
} |
475 |
|
} |
476 |
|
|
477 |
|
// Vérification de la non modification des dates de suivi |
478 |
|
function updateDate($champ) { |
479 |
|
if($this->valF[$champ] != "") { |
480 |
|
if($this->getVal($champ) != "" AND $this->getVal($champ) != $this->valF[$champ]) { |
481 |
|
$this->correct = false; |
482 |
|
$this->addToMessage(_("Les dates de suivis ne peuvent etre modifiees")); |
483 |
|
} |
484 |
|
} |
485 |
|
} |
486 |
|
|
487 |
|
// Sélectionne le signataire_arrete par défaut |
488 |
|
function setVal(&$form,$maj,$validation){ |
489 |
|
|
490 |
|
// Ajout |
491 |
|
if($maj == 0) { |
492 |
|
|
493 |
|
// Création de la requête |
494 |
|
$sql = "SELECT signataire_arrete |
495 |
|
FROM ".DB_PREFIXE."signataire_arrete |
496 |
|
WHERE defaut IS TRUE"; |
497 |
|
|
498 |
|
// Exécution de la requête |
499 |
|
$res = $this->f->db->query($sql); |
500 |
|
$this->f->addToLog("deleteAllLienDossierInstructionTypeEvenementEvenement(): db->query(\"".$sql."\");", VERBOSE_MODE); |
501 |
|
if ( database::isError($res)){ |
502 |
|
die(); |
503 |
|
} |
504 |
|
|
505 |
|
$row = $res->fetchrow(DB_FETCHMODE_ASSOC); |
506 |
|
|
507 |
|
if ( isset($row['signataire_arrete']) && is_numeric($row['signataire_arrete'])){ |
508 |
|
|
509 |
|
$form->setVal("signataire_arrete",$row['signataire_arrete']); |
510 |
|
} |
511 |
|
} |
512 |
|
} |
513 |
|
|
514 |
|
/*Met des valeurs par défaut dans certains des sous-formulaire*/ |
515 |
|
function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire){ |
516 |
|
if ($validation==0 and $maj<2) { |
517 |
|
if ($maj == 0){ |
518 |
|
$form->setVal("destinataire", $idxformulaire); |
519 |
|
$form->setVal("dossier", $idxformulaire); |
520 |
|
$form->setVal("date_evenement", date('Y-m-d')); |
521 |
|
} |
522 |
|
$form->setVal("bible_auto","bible_auto()"); |
523 |
|
$form->setVal("bible","bible()"); |
524 |
|
$form->setVal("bible2","bible2()"); |
525 |
|
} |
526 |
|
$this->retourformulaire=$retourformulaire; |
527 |
|
$this->idxformulaire=$idxformulaire; |
528 |
|
} |
529 |
|
|
530 |
|
|
531 |
function setLayout(&$form, $maj){ |
function setLayout(&$form, $maj){ |
532 |
if ( $maj < 2 OR $maj == 3 ) { |
if ( $maj < 2 OR $maj == 3 ) { |
534 |
$form->setBloc('evenement','D',"","col_12"); |
$form->setBloc('evenement','D',"","col_12"); |
535 |
|
|
536 |
$form->setFieldset('evenement','D',_('Evenement')); |
$form->setFieldset('evenement','D',_('Evenement')); |
|
$form->setBloc('evenement','D',"","group col_12"); |
|
|
$form->setBloc('date_evenement','F'); |
|
537 |
$form->setFieldset('lettretype','F',''); |
$form->setFieldset('lettretype','F',''); |
538 |
|
|
539 |
$form->setBloc('lettretype','F'); |
$form->setBloc('lettretype','F'); |
562 |
} |
} |
563 |
} |
} |
564 |
|
|
565 |
/*Change le libellé de certains champs*/ |
function setLib(&$form, $maj) { |
566 |
function setLib(&$form,$maj) { |
// |
567 |
parent :: setLib($form,$maj); |
parent::setLib($form, $maj); |
568 |
$form->setLib('libelle',' '); |
// |
569 |
$form->setLib('bible_auto',""); |
$form->setLib('bible_auto', ""); |
570 |
$form->setLib('bible',""); |
$form->setLib('bible', ""); |
571 |
$form->setLib('bible2',""); |
$form->setLib('bible2', ""); |
572 |
} |
} |
573 |
|
|
574 |
// ================================================================== |
function triggerajouter($id, &$db, $val, $DEBUG) { |
575 |
// trigger avant modification des données [trigger before modify data] |
/** |
576 |
// ================================================================== |
* Le code suivant permet de récupérer des valeurs des tables evenement |
577 |
function triggerajouter($id,&$db,$val,$DEBUG) { |
* et dossier pour les stocker dans l'instruction : |
578 |
// mise a jour instruction avec evenement |
* DEPUIS L'EVENEMENT |
579 |
// [modify instruction with evenement] |
* - action |
580 |
$sql= "select * from ".DB_PREFIXE."evenement where evenement =".$this->valF['evenement']; |
* - delai |
581 |
|
* - accord_tacite |
582 |
|
* - etat |
583 |
|
* - avis_decision |
584 |
|
* - delai_notification |
585 |
|
* - lettretype |
586 |
|
* DEPUIS LE DOSSIER D'INSTRUCTION |
587 |
|
* - archive_delai |
588 |
|
* - archive_accord_tacite |
589 |
|
* - archive_etat |
590 |
|
* - archive_avis |
591 |
|
* - date_complet |
592 |
|
* - date_rejet |
593 |
|
* - date_limite |
594 |
|
* - date_notification_delai |
595 |
|
* - date_decision |
596 |
|
* - date_validite |
597 |
|
* - date_achevement |
598 |
|
* - date_chantier |
599 |
|
* - date_conformite |
600 |
|
* Il permet également de stocker la date_depot du dossier d'instruction |
601 |
|
* dans l'attribut $this->archive_date_depot de la classe. |
602 |
|
*/ |
603 |
|
// Récupération de tous les paramètres de l'événement sélectionné |
604 |
|
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
605 |
|
WHERE evenement=".$this->valF['evenement']; |
606 |
$res = $db->query($sql); |
$res = $db->query($sql); |
607 |
if (database::isError($res)) die($res->getMessage()); |
$this->addToLog("triggerajouter(): db->query(\"".$sql."\");", VERBOSE_MODE); |
608 |
|
if (database::isError($res)) { |
609 |
if ($DEBUG == 1) |
die($res->getMessage()); |
610 |
echo " la requete ".$sql." est exécutée<br>"; |
} |
611 |
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
612 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
// Récupération de l'identifiant de l'action |
613 |
|
// si une action est paramétrée dans l'événement |
614 |
if(isset($row['action']) and !empty($row['action'])) { |
$this->valF['action'] = NULL; |
615 |
|
if (isset($row['action']) and !empty($row['action'])) { |
616 |
$this->valF['action']=$row['action']; |
$this->valF['action']=$row['action']; |
|
} else { |
|
|
$this->valF['action']=NULL; |
|
617 |
} |
} |
618 |
$this->valF['delai']=$row['delai']; |
// Récupération de la valeur du délai |
619 |
if(isset($row['etat']) and !empty($row['etat'])) { |
$this->valF['delai'] = $row['delai']; |
620 |
|
// Récupération de l'identifiant de l'état |
621 |
|
// si un état est paramétré dans l'événement |
622 |
|
$this->valF['etat']=NULL; |
623 |
|
if (isset($row['etat']) and !empty($row['etat'])) { |
624 |
$this->valF['etat']=$row['etat']; |
$this->valF['etat']=$row['etat']; |
|
} else { |
|
|
$this->valF['etat']=NULL; |
|
625 |
} |
} |
626 |
|
// Récupération de la valeur d'accord tacite |
627 |
$this->valF['accord_tacite']=$row['accord_tacite']; |
$this->valF['accord_tacite']=$row['accord_tacite']; |
628 |
|
// Récupération de la valeur du délai de notification |
629 |
$this->valF['delai_notification']=$row['delai_notification']; |
$this->valF['delai_notification']=$row['delai_notification']; |
630 |
|
// Récupération de l'identifiant de l'avis |
631 |
|
// si un avis est paramétré dans l'événement |
632 |
|
$this->valF['avis_decision'] = NULL; |
633 |
if(isset($row['avis_decision']) and !empty($row['avis_decision'])) { |
if(isset($row['avis_decision']) and !empty($row['avis_decision'])) { |
634 |
$this->valF['avis_decision']=$row['avis_decision']; |
$this->valF['avis_decision']=$row['avis_decision']; |
|
} else { |
|
|
$this->valF['avis_decision']=NULL; |
|
635 |
} |
} |
636 |
if($row['lettretype']!="") |
// Récupération de la valeur de la lettre type |
637 |
|
// Sinon on lui affecte lavaleur par défaut standard |
638 |
|
if ($row['lettretype'] != "") { |
639 |
$this->valF['lettretype']=$row['lettretype']; |
$this->valF['lettretype']=$row['lettretype']; |
640 |
else |
} else { |
641 |
$this->valF['lettretype']="standard"; |
$this->valF['lettretype'] = "standard"; // XXX |
642 |
|
} |
643 |
} |
} |
644 |
$sql= "select * from ".DB_PREFIXE."dossier where dossier = '".$this->valF['dossier']."'"; |
// Récupération de toutes les valeurs du dossier d'instruction en cours |
645 |
|
$sql = "SELECT * FROM ".DB_PREFIXE."dossier |
646 |
|
WHERE dossier='".$this->valF['dossier']."'"; |
647 |
$res = $db->query($sql); |
$res = $db->query($sql); |
648 |
if (database::isError($res)) |
$this->addToLog("triggerajouter(): db->query(\"".$sql."\");", VERBOSE_MODE); |
649 |
|
if (database::isError($res)) { |
650 |
die($res->getMessage()); |
die($res->getMessage()); |
651 |
if ($DEBUG == 1) |
} |
652 |
echo " la requete ".$sql." est exécutée<br>"; |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
653 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
// XXX On stocke la date de dépôt actuelle du dossier d'instruction |
654 |
// |
// dans un attribut de la classe |
655 |
$this->archive_date_depot = $row['date_depot']; |
$this->archive_date_depot = $row['date_depot']; |
656 |
// archive en instruction (si suppression) |
// Récupération de la valeur actuelle du délai, de l'accord tacite, |
657 |
|
// de l'état et de l'avis du dossier d'instruction |
658 |
$this->valF['archive_delai']=$row['delai']; |
$this->valF['archive_delai']=$row['delai']; |
659 |
$this->valF['archive_accord_tacite']=$row['accord_tacite']; |
$this->valF['archive_accord_tacite']=$row['accord_tacite']; |
660 |
$this->valF['archive_etat']=$row['etat']; |
$this->valF['archive_etat']=$row['etat']; |
661 |
$this->valF['archive_avis']=$row['avis_decision']; |
$this->valF['archive_avis']=$row['avis_decision']; |
662 |
// compatibilite pgsql |
// Récupération de la valeur actuelle des 9 dates du dossier |
663 |
if($row['date_complet']!='') |
// d'instruction |
664 |
$this->valF['archive_date_complet']=$row['date_complet']; |
if ($row['date_complet'] != '') { |
665 |
if($row['date_rejet']!='') |
$this->valF['archive_date_complet']=$row['date_complet']; |
666 |
$this->valF['archive_date_rejet']= $row['date_rejet']; |
} |
667 |
if($row['date_limite']!='') |
if ($row['date_dernier_depot'] != '') { |
668 |
$this->valF['archive_date_limite']= $row['date_limite']; |
$this->valF['archive_date_dernier_depot']=$row['date_dernier_depot']; |
669 |
if($row['date_notification_delai']!='') |
} |
670 |
$this->valF['archive_date_notification_delai']= $row['date_notification_delai']; |
if ($row['date_rejet']!='') { |
671 |
if($row['date_decision']!='') |
$this->valF['archive_date_rejet']= $row['date_rejet']; |
672 |
$this->valF['archive_date_decision']= $row['date_decision']; |
} |
673 |
if($row['date_validite']!='') |
if ($row['date_limite']!='') { |
674 |
$this->valF['archive_date_validite']= $row['date_validite']; |
$this->valF['archive_date_limite']= $row['date_limite']; |
675 |
if($row['date_achevement']!='') |
} |
676 |
$this->valF['archive_date_achevement']= $row['date_achevement']; |
if ($row['date_notification_delai']!='') { |
677 |
if($row['date_chantier']!='') |
$this->valF['archive_date_notification_delai']= $row['date_notification_delai']; |
678 |
$this->valF['archive_date_chantier']= $row['date_chantier']; |
} |
679 |
if($row['date_conformite']!='') |
if ($row['date_decision']!='') { |
680 |
$this->valF['archive_date_conformite']= $row['date_conformite']; |
$this->valF['archive_date_decision']= $row['date_decision']; |
681 |
|
} |
682 |
|
if ($row['date_validite']!='') { |
683 |
|
$this->valF['archive_date_validite']= $row['date_validite']; |
684 |
|
} |
685 |
|
if ($row['date_achevement']!='') { |
686 |
|
$this->valF['archive_date_achevement']= $row['date_achevement']; |
687 |
|
} |
688 |
|
if ($row['date_chantier']!='') { |
689 |
|
$this->valF['archive_date_chantier']= $row['date_chantier']; |
690 |
|
} |
691 |
|
if ($row['date_conformite']!='') { |
692 |
|
$this->valF['archive_date_conformite']= $row['date_conformite']; |
693 |
|
} |
694 |
|
if ($row['incompletude']!='') { |
695 |
|
$this->valF['archive_incompletude']= $row['incompletude']; |
696 |
|
} |
697 |
|
if ($row['evenement_suivant_tacite']!='') { |
698 |
|
$this->valF['archive_evenement_suivant_tacite']= $row['evenement_suivant_tacite']; |
699 |
|
} |
700 |
|
if ($row['evenement_suivant_tacite_incompletude']!='') { |
701 |
|
$this->valF['archive_evenement_suivant_tacite_incompletude']= $row['evenement_suivant_tacite_incompletude']; |
702 |
|
} |
703 |
|
if ($row['etat_pendant_incompletude']!='') { |
704 |
|
$this->valF['archive_etat_pendant_incompletude']= $row['etat_pendant_incompletude']; |
705 |
|
} |
706 |
|
if ($row['date_limite_incompletude']!='') { |
707 |
|
$this->valF['archive_date_limite_incompletude']= $row['date_limite_incompletude']; |
708 |
|
} |
709 |
|
if ($row['delai_incompletude']!='') { |
710 |
|
$this->valF['archive_delai_incompletude']= $row['delai_incompletude']; |
711 |
|
} |
712 |
} |
} |
713 |
|
|
714 |
|
// Identifiant du type de courrier |
715 |
|
$idTypeCourrier = '11'; |
716 |
|
$idCourrier = str_pad($this->valF["instruction"], 10, "0", STR_PAD_LEFT); |
717 |
|
// Code barres |
718 |
|
$this->valF["code_barres"] = $idTypeCourrier . $idCourrier; |
719 |
} |
} |
720 |
|
|
721 |
// Test si une restriction est valide |
// Test si une restriction est valide |
833 |
} |
} |
834 |
|
|
835 |
|
|
836 |
|
|
|
// ================================================================== |
|
|
// valeur dossier apres modification [values dossier after action] |
|
|
// ================================================================== |
|
837 |
function triggerajouterapres($id,&$db,$val,$DEBUG) { |
function triggerajouterapres($id,&$db,$val,$DEBUG) { |
838 |
// mise a null au lieu de "" / voir compatibilite mysql |
/** |
839 |
// voir parametrage CU en dur |
* Mise à jour des valeurs du dossier en fonction des valeurs calculées |
840 |
// voir parametrage des actions en dur |
* par l'action |
841 |
$param=1; |
*/ |
842 |
if($param==1){ |
$this->getValEvenement(); |
843 |
$sql="select * from ".DB_PREFIXE."action where action = '".$this->valF['action']."'"; |
// Initialisation |
844 |
$res = $db->query($sql); |
$valF = ""; |
845 |
if (database::isError($res)) |
// état de complétude actuel du dossier |
846 |
die($res->getMessage()); |
$incompletude = $this->dossierIncomplet(); |
847 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
|
848 |
if($row['regle_etat']!=''){ |
if($incompletude === FALSE) { |
849 |
$valF['etat']= $this->regle($row['regle_etat']); |
// Si l'événement d'instruction est de type incompletude |
850 |
} |
if($this->valEvenement['type'] == "incompletude") { |
851 |
if($row['regle_delai']!=''){ |
// On marque le dossier en incomplétude pour application des actions |
852 |
$valF['delai']= $this->regle($row['regle_delai']); |
$incompletude = TRUE; |
853 |
} |
// Set du flag incomplétude de la table dossier |
854 |
if($row['regle_accord_tacite']!=''){ |
$valF['incompletude'] = TRUE; |
855 |
$valF['accord_tacite']= $this->regle($row['regle_accord_tacite']); |
// Enregistrement de l'état dans la variable provisoire |
856 |
} |
$valF['etat_pendant_incompletude'] = $this->valF['archive_etat']; |
857 |
if($row['regle_avis']!=''){ |
} |
858 |
$valF['avis_decision']= $this->regle($row['regle_avis']); |
} else { |
859 |
} |
// Si l'evenement d'instruction est de type retour ou contient une |
860 |
if($row['regle_date_limite']!=''){ |
// decision, on sort d'incomplétude |
861 |
$valF['date_limite']= $this->regle($row['regle_date_limite']); |
if($this->valEvenement['type'] == "retour" OR |
862 |
} |
$this->valEvenement['avis_decision'] != NULL) { |
863 |
if($row['regle_date_complet']!=''){ |
// On enlève la marque d'incomplétude pour application des actions |
864 |
$valF['date_complet']= $this->regle($row['regle_date_complet']); |
$incompletude = FALSE; |
865 |
} |
// On enlève le flag d'incomplétude sur l'enregistrement de la table dossier |
866 |
if($row['regle_date_notification_delai']!=''){ |
$valF['incompletude'] = FALSE; |
867 |
$valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']); |
// Restauration de l'état depuis l'état provisoire |
868 |
} |
$valF['etat'] = $this->valF['archive_etat_pendant_incompletude']; |
869 |
if($row['regle_date_decision']!=''){ |
// On vide la variable provisoire ainsi que le délai de complétude |
870 |
$valF['date_decision']= $this->regle($row['regle_date_decision']); |
// et la date limite de complétude |
871 |
} |
$valF['etat_pendant_incompletude'] = NULL; |
872 |
if($row['regle_date_rejet']!=''){ |
$valF['delai_incompletude'] = NULL; |
873 |
$valF['date_rejet']= $this->regle($row['regle_date_rejet']); |
$valF['date_limite_incompletude'] = NULL; |
874 |
} |
} |
875 |
if($row['regle_date_validite']!=''){ |
} |
876 |
$valF['date_validite']= $this->regle($row['regle_date_validite']); |
// Récupération des paramètres de l'action |
877 |
} |
$sql = "SELECT * FROM ".DB_PREFIXE."action |
878 |
if($row['regle_date_chantier']!=''){ |
WHERE action='".$this->valF['action']."'"; |
879 |
$valF['date_chantier']= $this->regle($row['regle_date_chantier']); |
$res = $db->query($sql); |
880 |
} |
$this->addToLog("triggerajouterapres(): db->query(\"".$sql."\");", VERBOSE_MODE); |
881 |
if($row['regle_date_achevement']!=''){ |
if (database::isError($res)) { |
882 |
$valF['date_achevement']= $this->regle($row['regle_date_achevement']); |
die($res->getMessage()); |
883 |
|
} |
884 |
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
885 |
|
|
886 |
|
// pour chacune des regles, on applique la regle |
887 |
|
if($row['regle_delai']!=''){ |
888 |
|
$valF['delai'] = $this->regle($row['regle_delai']); |
889 |
|
} |
890 |
|
if($row['regle_accord_tacite']!=''){ |
891 |
|
$valF['accord_tacite'] = $this->regle($row['regle_accord_tacite']); |
892 |
|
} |
893 |
|
if($row['regle_avis']!=''){ |
894 |
|
$valF['avis_decision'] = $this->regle($row['regle_avis']); |
895 |
|
} |
896 |
|
if($row['regle_date_limite']!=''){ |
897 |
|
$valF['date_limite']= $this->regle($row['regle_date_limite']); |
898 |
|
} |
899 |
|
if($row['regle_date_complet']!=''){ |
900 |
|
$valF['date_complet']= $this->regle($row['regle_date_complet']); |
901 |
|
} |
902 |
|
if($row['regle_date_dernier_depot']!=''){ |
903 |
|
$valF['date_dernier_depot']= $this->regle($row['regle_date_dernier_depot']); |
904 |
|
} |
905 |
|
if($row['regle_date_notification_delai']!=''){ |
906 |
|
$valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']); |
907 |
|
} |
908 |
|
if($row['regle_date_decision']!=''){ |
909 |
|
$valF['date_decision']= $this->regle($row['regle_date_decision']); |
910 |
|
} |
911 |
|
if($row['regle_date_rejet']!=''){ |
912 |
|
$valF['date_rejet']= $this->regle($row['regle_date_rejet']); |
913 |
|
} |
914 |
|
if($row['regle_date_validite']!=''){ |
915 |
|
$valF['date_validite']= $this->regle($row['regle_date_validite']); |
916 |
|
} |
917 |
|
if($row['regle_date_chantier']!=''){ |
918 |
|
$valF['date_chantier']= $this->regle($row['regle_date_chantier']); |
919 |
|
} |
920 |
|
if($row['regle_date_achevement']!=''){ |
921 |
|
$valF['date_achevement']= $this->regle($row['regle_date_achevement']); |
922 |
|
} |
923 |
|
if($row['regle_date_conformite']!=''){ |
924 |
|
$valF['date_conformite']= $this->regle($row['regle_date_conformite']); |
925 |
|
} |
926 |
|
if($row['regle_date_limite_incompletude']!=''){ |
927 |
|
$valF['date_limite_incompletude']= $this->regle($row['regle_date_limite_incompletude']); |
928 |
|
} |
929 |
|
if($row['regle_delai_incompletude']!=''){ |
930 |
|
$valF['delai_incompletude']= $this->regle($row['regle_delai_incompletude']); |
931 |
|
} |
932 |
|
if($row['regle_etat']!=''){ |
933 |
|
// Si on est dans le cas général ou qu'on est en incomplétude et |
934 |
|
// qu'on a un événement de type incomplétude alors : on stocke |
935 |
|
// l'état dans la variable courante |
936 |
|
if ($incompletude == FALSE OR $this->valEvenement['type'] == "incompletude") { |
937 |
|
$valF['etat'] = $this->regle($row['regle_etat']); |
938 |
|
} else { |
939 |
|
$valF['etat_pendant_incompletude'] = $this->regle($row['regle_etat']); |
940 |
} |
} |
941 |
if($row['regle_date_conformite']!=''){ |
} |
942 |
$valF['date_conformite']= $this->regle($row['regle_date_conformite']); |
|
943 |
|
if($this->valEvenement['evenement_suivant_tacite'] != '') { |
944 |
|
// Si on est pas en incomplétude on stocke l'événement tacite |
945 |
|
//de l'événement dans la variable courante |
946 |
|
if ($incompletude == FALSE) { |
947 |
|
$valF['evenement_suivant_tacite'] = $this->valEvenement['evenement_suivant_tacite']; |
948 |
|
} else { |
949 |
|
$valF['evenement_suivant_tacite_incompletude'] = $this->valEvenement['evenement_suivant_tacite']; |
950 |
} |
} |
951 |
|
} |
952 |
// Appel des méthode stockées dans le champ methode_trigger |
} |
953 |
if($row['methode_trigger'] != "") { |
// Si des valeurs ont été calculées alors on met à jour l'enregistrement |
954 |
foreach (explode(";", $row['methode_trigger']) as $methode) { |
if ($valF != "") { |
955 |
if(method_exists($this, $methode)) { |
// On met à jour le dossier |
956 |
$this->$methode(); |
$cle = " dossier='".$this->valF['dossier']."'"; |
957 |
} |
$res1 = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle); |
958 |
|
$this->addToLog("triggerajouterapres(): db->autoexecute(\"".DB_PREFIXE."dossier\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
959 |
} |
if (database::isError($res1)) { |
|
} |
|
|
} |
|
|
}else{ |
|
|
switch ($this->valF['action']) { |
|
|
case "initialisation" : |
|
|
$valF['delai']= $this->valF['delai']; |
|
|
$valF['etat']= $this->valF['etat']; |
|
|
$valF['accord_tacite']= $this->valF['accord_tacite']; |
|
|
// la date_complet est la date de depot |
|
|
$valF['date_complet']= $this->archive_date_depot; // **** |
|
|
$valF['date_limite'] = $this->moisdate($valF['date_complet'],$valF['delai']); |
|
|
$valF['date_notification_delai'] = $this->moisdate($valF['date_complet'],1); |
|
|
break; |
|
|
case "notification" : |
|
|
$valF['delai']= $this->valF['delai']; |
|
|
$valF['etat']= $this->valF['etat']; |
|
|
$valF['accord_tacite']= $this->valF['accord_tacite']; |
|
|
// la date_complet est celle precedemment saisie |
|
|
$valF['date_complet']=$this->valF['archive_date_complet']; |
|
|
$valF['date_limite'] = $this->moisdate($valF['date_complet'],$valF['delai']); |
|
|
$valF['date_notification_delai'] = $this->moisdate($valF['date_complet'],1); |
|
|
// la date du courrier ne doit pas etre depasse par rapport au delai de |
|
|
// notification [verify notification date] |
|
|
if($this->valF['archive_date_notification_delai']<$this->valF['date_evenement']) |
|
|
$this->msg=$this->msg."<br><img src='../img/erreur.gif'> "._("date_notification_delai")." ". |
|
|
$this->valF['archive_date_notification_delai']." < "._('date_evenement'); |
|
|
// |
|
|
break; |
|
|
case "retour" : |
|
|
$valF['delai']= $this->valF['delai']; |
|
|
$valF['etat']= $this->valF['etat']; |
|
|
$valF['accord_tacite']= $this->valF['accord_tacite']; |
|
|
// la date_complet est celle de l evenement |
|
|
$valF['date_complet']= $this->valF['date_evenement']; |
|
|
$valF['date_limite'] = $this->moisdate($valF['date_complet'],$valF['delai']); |
|
|
$valF['date_notification_delai'] = $this->moisdate($valF['date_complet'],1); |
|
|
break; |
|
|
case "rejet" : |
|
|
//$valF['delai']=0; // *** delai a garder pour etat dpc |
|
|
$valF['etat']= $this->valF['etat']; |
|
|
$valF['accord_tacite']= $this->valF['accord_tacite']; |
|
|
// la date rejet est initialisee |
|
|
$valF['date_rejet']= $this->valF['date_evenement']; |
|
|
// les dates de depart et fin d instruction sont annulées |
|
|
$valF['date_limite'] =null; |
|
|
$valF['date_notification_delai'] =null; |
|
|
$valF['date_complet']=null; |
|
|
break; |
|
|
case "majoration" : |
|
|
$valF['delai']= $this->valF['archive_delai']+$this->valF['delai']; |
|
|
$valF['etat']= $this->valF['etat']; |
|
|
$valF['accord_tacite']= $this->valF['accord_tacite']; |
|
|
$valF['date_complet']=$this->valF['archive_date_complet']; |
|
|
// majoration de la date limite |
|
|
$valF['date_limite'] = $this->moisdate($valF['date_complet'],$valF['delai']); |
|
|
$valF['date_notification_delai'] = $this->moisdate($valF['date_complet'],1); |
|
|
// la date du courrier ne doit pas etre depasse par rapport au delai de |
|
|
// notification |
|
|
if($this->valF['archive_date_notification_delai']<$this->valF['date_evenement']) |
|
|
$this->msg=$this->msg."<br><img src='../img/erreur.gif'>"._("date_notification_delai"). |
|
|
$this->valF['archive_date_notification_delai']." < "._('date_evenement'); |
|
|
break; |
|
|
case "acceptation" : |
|
|
$valF['etat']= $this->valF['etat']; |
|
|
$valF['date_decision']= $this->valF['date_evenement']; |
|
|
$valF['avis_decision']= $this->valF['avis_decision']; |
|
|
// date de validite = date de l evenement + delai |
|
|
$valF['date_validite'] = $this->moisdate($this->valF['date_evenement'],$this->valF['delai']); |
|
|
break; |
|
|
case "refus" : |
|
|
$valF['etat']= $this->valF['etat']; |
|
|
$valF['date_decision']= $this->valF['date_evenement']; |
|
|
$valF['avis_decision']= $this->valF['avis_decision']; |
|
|
break; |
|
|
case "prolongation" : |
|
|
$valF['date_validite'] = $this->moisdate($this->valF['archive_date_validite'],$this->valF['delai']); |
|
|
break; |
|
|
case "sursis" : |
|
|
$valF['date_limite'] = $this->moisdate($this->valF['date_evenement'],$this->valF['delai']); |
|
|
$valF['etat']= $this->valF['etat']; |
|
|
$valF['accord_tacite']= $this->valF['accord_tacite']; |
|
|
$valF['avis_decision']= $this->valF['avis_decision']; |
|
|
$valF['date_decision']= $this->valF['date_evenement']; |
|
|
$temp = $valF['date_limite']; |
|
|
$valF['date_validite']= $this->moisdate($temp,2); |
|
|
break; |
|
|
case "execution" : |
|
|
$valF['etat']= $this->valF['etat']; |
|
|
$valF['date_chantier'] = $this->valF['date_evenement']; |
|
|
//echo $this->msg=$this->msg.$valF['date_chantier'].""; |
|
|
break; |
|
|
case "achevement" : |
|
|
$valF['etat']= $this->valF['etat']; |
|
|
$valF['date_achevement'] = $this->valF['date_evenement']; |
|
|
break; |
|
|
case "archivage" : |
|
|
$valF['etat']= $this->valF['etat']; |
|
|
$valF['date_conformite'] = $this->valF['date_evenement']; |
|
|
break; |
|
|
|
|
|
default: |
|
|
if ($this->valF['etat']!="") |
|
|
$valF['etat']= $this->valF['etat']; |
|
|
}// end switch |
|
|
} // end param |
|
|
if($valF!=""){ |
|
|
$cle= " dossier = '".$this->valF['dossier']."'"; |
|
|
$res1= $db->autoExecute(DB_PREFIXE.'dossier',$valF,DB_AUTOQUERY_UPDATE,$cle); |
|
|
if (database::isError($res1)) |
|
960 |
die($res->getMessage()); |
die($res->getMessage()); |
961 |
if ($DEBUG == 1) |
} |
962 |
echo "La requête de mise à jour est effectuée.<br>"; |
// Affichage d'informations à l'utilisateur |
963 |
$this->msg=$this->msg."<br>"._('enregistrement')." ". |
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
|
$this->valF['dossier']." "._('table')." dossier [". |
|
|
$db->affectedRows()." "._('enregistrement'). |
|
|
" "._('mis_a_jour')."]" ; |
|
964 |
} |
} |
965 |
|
|
966 |
|
/** |
967 |
|
* REFERENTIEL ERP |
968 |
|
*/ |
969 |
// verification si envoi vers ERP est active |
// verification si envoi vers ERP est active |
970 |
if ($this->f->getParameter('option_erp') != "") { |
if ($this->f->getParameter('option_erp') != "") { |
971 |
// la nature du dossier |
// la nature du dossier |
972 |
$nature_dossier = substr($this->idxformulaire,0,2); |
$nature_dossier = substr($this->idxformulaire,0,2); |
973 |
$dossier_erp = $this->getFromDB("SELECT erp FROM ".DB_PREFIXE."dossier WHERE dossier = '" . |
// |
974 |
$this->valF['dossier'] . "'"); |
$sql = "SELECT erp |
975 |
$evenement_libelle = $this->getFromDB( |
FROM ".DB_PREFIXE."dossier |
976 |
"SELECT libelle FROM ".DB_PREFIXE."evenement WHERE evenement = '" . |
WHERE dossier='".$this->valF['dossier']."'"; |
977 |
$this->valF['evenement'] . "'"); |
$dossier_erp = $this->db->getone($sql); |
978 |
|
$this->addToLog("triggerajouterapres(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
979 |
|
if (database::isError($res)) { |
980 |
|
die($res->getMessage()); |
981 |
|
} |
982 |
|
// |
983 |
|
$sql = "SELECT libelle |
984 |
|
FROM ".DB_PREFIXE."evenement |
985 |
|
WHERE evenement='".$this->valF['evenement']."'"; |
986 |
|
$evenement_libelle = $this->db->getone($sql); |
987 |
|
$this->addToLog("triggerajouterapres(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
988 |
|
if (database::isError($res)) { |
989 |
|
die($res->getMessage()); |
990 |
|
} |
991 |
|
// |
992 |
if ($dossier_erp == 't') { |
if ($dossier_erp == 't') { |
993 |
// envoi du message en cas d'un PC qui est ERP et sur lequel un evenement |
// envoi du message en cas d'un PC qui est ERP et sur lequel un evenement |
994 |
// d'acceptation etait fait |
// d'acceptation etait fait |
1009 |
} |
} |
1010 |
} |
} |
1011 |
} // fin de if ($this->f->getParameter('option_erp') != "") |
} // fin de if ($this->f->getParameter('option_erp') != "") |
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
* Fait une requette sql pour extraire la valeur d'un champ, et retourne |
|
|
* cette valeur |
|
|
* @param string $sql La requete sql a executer |
|
|
* @return La valeur du champs cherche, sinon NULL. En cas d'erreur de la BD |
|
|
* l'execution s'arrete. |
|
|
*/ |
|
|
function getFromDB($sql) { |
|
|
//$sql = "SELECT libelle FROM ".DB_PREFIXE."dossier WHERE dossier = '" . $dossier . "'"; |
|
|
$res = $this->db->limitquery($sql, 0, 1); |
|
|
$this->addToLog("getDossierERPSpecification(): db->limitquery(\"". |
|
|
str_replace(",",", ",$sql)."\", 0, 1);", VERBOSE_MODE); |
|
|
// Si une erreur survient on die |
|
|
if (database::isError($res, true)) { |
|
|
// Appel de la methode de recuperation des erreurs |
|
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), 'instruction'); |
|
|
} |
|
|
// retourne la nature du dossier |
|
|
while ($row =& $res->fetchRow()) { |
|
|
return $row[0]; |
|
|
} |
|
|
// la nature n'etait pas trouve, ce qui ne devrait pas se passer |
|
|
return NULL; |
|
1012 |
|
|
1013 |
|
// Mise à jour des données du dossier d'autorisation |
1014 |
|
require_once "../obj/dossier_autorisation.class.php"; |
1015 |
|
$da = new dossier_autorisation($this->getDossierAutorisationFromDossier($this->valF['dossier']), $this->db, DEBUG); |
1016 |
|
$da->majDossierAutorisation(); |
1017 |
|
|
1018 |
|
// Finalisation du document |
1019 |
|
$this->finaliserAjouter(); |
1020 |
|
} |
1021 |
|
function triggermodifier($id,&$db,$val,$DEBUG) { |
1022 |
|
// Ajout de l'arrêté dans la GED |
1023 |
|
if ($this->valF['numero_arrete'] != $this->getVal('numero_arrete') |
1024 |
|
AND $this->valF["om_fichier_instruction"] != "") { |
1025 |
|
$file = $this->f->storage->get($this->valF["om_fichier_instruction"]); |
1026 |
|
if(isset($file) and $file != null) { |
1027 |
|
// Récupération des métadonnées calculées après validation |
1028 |
|
$spe_metadata = $this->getMetadata("document_arrete"); |
1029 |
|
$pdf_output = $file["file_content"]; |
1030 |
|
//Métadonnées du document |
1031 |
|
$metadata = array( |
1032 |
|
'filename' => 'instruction_'.$this->valF[$this->clePrimaire].'.pdf', |
1033 |
|
'mimetype' => 'application/pdf', |
1034 |
|
'size' => strlen($pdf_output) |
1035 |
|
); |
1036 |
|
$metadata = array_merge($metadata, $spe_metadata); |
1037 |
|
|
1038 |
|
//Si le document a déjà été finalisé |
1039 |
|
//on met à jour le document mais pas son uid |
1040 |
|
if ( $this->getVal("document_arrete") != '' ){ |
1041 |
|
$uid = $this->f->storage->update( |
1042 |
|
$this->getVal("document_arrete"), $pdf_output, $metadata); |
1043 |
|
} |
1044 |
|
//Sinon, on joute le document et on récupère son uid |
1045 |
|
else { |
1046 |
|
//Stockage du PDF |
1047 |
|
$uid = $this->f->storage->create($pdf_output, $metadata); |
1048 |
|
} |
1049 |
|
if($uid != OP_FAILURE) { |
1050 |
|
$this->valF["document_arrete"] = $uid; |
1051 |
|
} |
1052 |
|
} |
1053 |
|
|
1054 |
|
} |
1055 |
} |
} |
|
|
|
|
|
|
1056 |
function triggermodifierapres($id,&$db,$val,$DEBUG) { |
function triggermodifierapres($id,&$db,$val,$DEBUG) { |
1057 |
/* |
/** |
1058 |
* cette fonction a pour objet de permettre de modifier la date courrier |
* L'objectif ici est d'effectuer les recalculs de date dans le dossier |
1059 |
*/ |
* si la date de l'evenement est modifiee |
1060 |
$valF=array(); |
*/ |
1061 |
$sql= "select action from ".DB_PREFIXE."evenement where evenement =".$this->valF['evenement']; |
// Initialisation |
1062 |
|
$valF = ""; |
1063 |
|
// Récupération de l'action correspondante à l'événement |
1064 |
|
$sql = "SELECT action |
1065 |
|
FROM ".DB_PREFIXE."evenement |
1066 |
|
WHERE evenement=".$this->valF['evenement']; |
1067 |
$action = $db->getOne($sql); |
$action = $db->getOne($sql); |
1068 |
if (database::isError($action)) die($action->getMessage().$sql); |
$this->addToLog("triggermodifierapres(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
1069 |
$sql="select * from ".DB_PREFIXE."action where action = '".$action."'"; |
if (database::isError($action)) { |
1070 |
|
die($action->getMessage()); |
1071 |
|
} |
1072 |
|
|
1073 |
|
// Récupération de tous les paramètres de l'événement sélectionné |
1074 |
|
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
1075 |
|
WHERE evenement=".$this->valF['evenement']; |
1076 |
|
$res = $db->query($sql); |
1077 |
|
$this->addToLog("triggerajouter(): db->query(\"".$sql."\");", VERBOSE_MODE); |
1078 |
|
if (database::isError($res)) { |
1079 |
|
die($res->getMessage()); |
1080 |
|
} |
1081 |
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
1082 |
|
// Si la date de retour signature est éditée on vérifie si il existe un événement automatique |
1083 |
|
if ($this->getVal('date_retour_signature') == "" AND |
1084 |
|
$this->valF['date_retour_signature'] != "" AND |
1085 |
|
$row['evenement_retour_signature'] != "") { |
1086 |
|
$new_instruction = new instruction("]", $db, $DEBUG); |
1087 |
|
// Création d'un tableau avec la liste des champs de l'instruction |
1088 |
|
foreach($new_instruction->champs as $champ) { |
1089 |
|
$valNewInstr[$champ] = ""; |
1090 |
|
} |
1091 |
|
// Définition des valeurs de la nouvelle instruction |
1092 |
|
$valNewInstr["evenement"] = $row['evenement_retour_signature']; |
1093 |
|
$valNewInstr["destinataire"] = $this->valF['destinataire']; |
1094 |
|
$valNewInstr["dossier"] = $this->valF['dossier']; |
1095 |
|
$valNewInstr["date_evenement"] = date("d/m/Y"); |
1096 |
|
$new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
1097 |
|
} |
1098 |
|
// Si la date de retour AR est éditée on vérifie si il existe un événement automatique |
1099 |
|
if ($this->getVal('date_retour_rar') == "" AND |
1100 |
|
$this->valF['date_retour_rar'] != "" AND |
1101 |
|
$row['evenement_retour_ar'] != "" ) { |
1102 |
|
$new_instruction = new instruction("]", $db, $DEBUG); |
1103 |
|
// Création d'un tableau avec la liste des champs de l'instruction |
1104 |
|
foreach($new_instruction->champs as $champ) { |
1105 |
|
$valNewInstr[$champ] = ""; |
1106 |
|
} |
1107 |
|
// Définition des valeurs de la nouvelle instruction |
1108 |
|
$valNewInstr["evenement"] = $row['evenement_retour_ar']; |
1109 |
|
$valNewInstr["destinataire"] = $this->valF['destinataire']; |
1110 |
|
$valNewInstr["dossier"] = $this->valF['dossier']; |
1111 |
|
$valNewInstr["date_evenement"] = date("d/m/Y"); |
1112 |
|
$new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
1113 |
|
} |
1114 |
|
} |
1115 |
|
|
1116 |
|
// Récupération des paramètres de l'action |
1117 |
|
$sql = "SELECT * FROM ".DB_PREFIXE."action |
1118 |
|
WHERE action='".$action."'"; |
1119 |
$res = $db->query($sql); |
$res = $db->query($sql); |
1120 |
if (database::isError($res)) die($res->getMessage().$sql); |
$this->addToLog("triggermodifierapres(): db->query(\"".$sql."\");", VERBOSE_MODE); |
1121 |
|
if (database::isError($res)) { |
1122 |
|
die($res->getMessage()); |
1123 |
|
} |
1124 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
1125 |
// application des regles sur le courrier + delai |
// application des regles sur le courrier + delai |
1126 |
if(preg_match("/date_evenement/",$row['regle_date_limite'])){ |
if(preg_match("/date_evenement/",$row['regle_date_limite'])){ |
1129 |
if(preg_match("/date_evenement/",$row['regle_date_complet'])){ |
if(preg_match("/date_evenement/",$row['regle_date_complet'])){ |
1130 |
$valF['date_complet']= $this->regle($row['regle_date_complet']); |
$valF['date_complet']= $this->regle($row['regle_date_complet']); |
1131 |
} |
} |
1132 |
|
if(preg_match("/date_evenement/",$row['regle_date_dernier_depot'])){ |
1133 |
|
$valF['date_dernier_depot']= $this->regle($row['regle_date_dernier_depot']); |
1134 |
|
} |
1135 |
if(preg_match("/date_evenement/",$row['regle_date_notification_delai'])){ |
if(preg_match("/date_evenement/",$row['regle_date_notification_delai'])){ |
1136 |
$valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']); |
$valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']); |
1137 |
} |
} |
1153 |
if(preg_match("/date_evenement/",$row['regle_date_conformite'])){ |
if(preg_match("/date_evenement/",$row['regle_date_conformite'])){ |
1154 |
$valF['date_conformite']= $this->regle($row['regle_date_conformite']); |
$valF['date_conformite']= $this->regle($row['regle_date_conformite']); |
1155 |
} |
} |
1156 |
} // while |
} |
1157 |
if($valF!=array()){ |
// Si des valeurs ont été calculées alors on met à jour l'enregistrement |
1158 |
$cle= " dossier = '".$this->valF['dossier']."'"; |
if ($valF != "") { |
1159 |
$res1= $db->autoExecute(DB_PREFIXE.'dossier',$valF,DB_AUTOQUERY_UPDATE,$cle); |
// On met à jour le dossier |
1160 |
if (database::isError($res1)) |
$cle = " dossier='".$this->valF['dossier']."'"; |
1161 |
|
$res1 = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle); |
1162 |
|
$this->addToLog("triggerajouterapres(): db->autoexecute(\"".DB_PREFIXE."dossier\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
1163 |
|
if (database::isError($res1)) { |
1164 |
die($res->getMessage()); |
die($res->getMessage()); |
1165 |
if ($DEBUG == 1) |
} |
1166 |
echo "La requête de mise à jour est effectuée.<br>"; |
// Affichage d'informations à l'utilisateur |
1167 |
$this->msg=$this->msg."<br>"._('enregistrement')." ". |
$this->addToMessage(_('enregistrement')." ".$this->valF['dossier']." "._('table')." dossier [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
|
$this->valF['dossier']." "._('table')." dossier [". |
|
|
$db->affectedRows()." "._('enregistrement'). |
|
|
" "._('mis_a_jour')."]" ; |
|
|
} |
|
|
|
|
|
// Envoi des infos au |
|
|
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_numero as \"ws_DA_In_N_Voie\", |
|
|
'' as \"ws_DA_In_Type_Voie\", |
|
|
dossier.complement 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); |
|
|
$this->f->isDatabaseError(); |
|
|
|
|
|
$rowArrete = $resArrete->fetchRow(DB_FETCHMODE_ASSOC); |
|
|
$msgenque->setArreteInfo($rowArrete); |
|
|
$msgenque->enqueueMessage($msgenque::$ARRETE_ENVOI); |
|
1168 |
} |
} |
1169 |
|
|
1170 |
|
/** |
1171 |
|
* REFERENTIEL ARRETE |
1172 |
|
*/ |
1173 |
|
if ($this->f->getParameter('option_referentiel_arrete') != "") { |
1174 |
|
if ($this->valF['date_retour_signature'] != $this->getVal('date_retour_signature')) { |
1175 |
|
$msgenque = new MessageEnqueuer(); |
1176 |
|
$sqlArrete = "SELECT instruction.signataire_arrete as \"ws_DA_In_Signataire\", |
1177 |
|
signataire_arrete.nom as \"ws_DA_In_Sign_Nom\", |
1178 |
|
signataire_arrete.prenom as \"ws_DA_In_Sign_Prenom\", |
1179 |
|
signataire_arrete.qualite as \"ws_DA_In_Sign_Qualite\", |
1180 |
|
instruction.date_evenement as \"ws_DA_In_Dte_Redac\", |
1181 |
|
'' as \"ws_DA_In_lieu_Redac\", |
1182 |
|
instruction.dossier as \"ws_DA_In_N_Doss_DAS\", |
1183 |
|
'' as \"ws_DA_In_Sigle\", |
1184 |
|
instruction.etat as \"ws_DA_In_Decision\", |
1185 |
|
dossier.date_depot as \"ws_DA_In_Dte_Depot_Dem\", |
1186 |
|
dossier.terrain_numero as \"ws_DA_In_N_Voie\", |
1187 |
|
'' as \"ws_DA_In_Type_Voie\", |
1188 |
|
dossier.complement as \"ws_DA_In_Adresse1\", |
1189 |
|
dossier.terrain_adresse_lieu_dit as \"ws_DA_In_Adresse2\", |
1190 |
|
dossier.terrain_adresse_code_postal as \"ws_DA_In_CP\", |
1191 |
|
dossier.terrain_adresse_localite as \"ws_DA_In_Ville\", |
1192 |
|
dossier.terrain_references_cadastrales as \"ws_DA_In_Nb_Parcelle\", |
1193 |
|
'' as \"ws_DA_In_Detail_Parcelle\", |
1194 |
|
CONCAT(donnees_techniques.am_projet_desc,' ',donnees_techniques.co_projet_desc) as \"ws_DA_In_Nature_Trvx\", |
1195 |
|
'' as \"ws_DA_In_Destination_Trvx\", |
1196 |
|
dossier_autorisation_type_detaille.code as \"ws_DA_In_Type_Dos_Autoris\", |
1197 |
|
COALESCE(particulier_nom,personne_morale_raison_sociale) as \"ws_DA_In_Nom_Petition\", |
1198 |
|
COALESCE(particulier_prenom, personne_morale_denomination) as \"ws_DA_In_Prenom_Petition\", |
1199 |
|
'' as \"ws_DA_In_Piece_GED\", |
1200 |
|
instruction.date_retour_signature as \"ws_DA_In_Dte_Signature\" |
1201 |
|
FROM ".DB_PREFIXE."instruction |
1202 |
|
LEFT JOIN ".DB_PREFIXE."signataire_arrete ON |
1203 |
|
instruction.signataire_arrete = signataire_arrete.signataire_arrete |
1204 |
|
LEFT JOIN ".DB_PREFIXE."dossier ON |
1205 |
|
instruction.dossier = dossier.dossier |
1206 |
|
LEFT JOIN ".DB_PREFIXE."lien_dossier_demandeur ON |
1207 |
|
lien_dossier_demandeur.dossier = dossier.dossier |
1208 |
|
LEFT JOIN ".DB_PREFIXE."demandeur ON |
1209 |
|
lien_dossier_demandeur.demandeur = demandeur.demandeur |
1210 |
|
LEFT JOIN ".DB_PREFIXE."dossier_instruction_type ON |
1211 |
|
dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
1212 |
|
LEFT JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille ON |
1213 |
|
dossier_instruction_type.dossier_autorisation_type_detaille = |
1214 |
|
dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
1215 |
|
LEFT JOIN ".DB_PREFIXE."donnees_techniques ON |
1216 |
|
donnees_techniques.dossier_instruction = dossier.dossier |
1217 |
|
WHERE instruction.instruction = ".$this->valF['instruction']; |
1218 |
|
$resArrete = $this->db->query($sqlArrete); |
1219 |
|
$this->f->addToLog("triggerModifierApres(): db->query(\"".$sqlArrete."\");", VERBOSE_MODE); |
1220 |
|
if ( database::isError($resArrete)){ |
1221 |
|
die(); |
1222 |
|
} |
1223 |
|
|
1224 |
|
$rowArrete = $resArrete->fetchRow(DB_FETCHMODE_ASSOC); |
1225 |
|
$msgenque->setArreteInfo($rowArrete); |
1226 |
|
$msgenque->enqueueMessage($msgenque::$ARRETE_ENVOI); |
1227 |
|
} |
1228 |
|
} |
1229 |
|
|
1230 |
|
// Mise à jour des données du dossier d'autorisation |
1231 |
|
require_once "../obj/dossier_autorisation.class.php"; |
1232 |
|
$da = new dossier_autorisation($this->getDossierAutorisationFromDossier($this->valF['dossier']), $this->db, DEBUG); |
1233 |
|
$da->majDossierAutorisation(); |
1234 |
} |
} |
1235 |
|
|
1236 |
|
/** |
1237 |
|
* Méthode de récupération des métadonnées arrêtés dans la base de données, |
1238 |
|
* les données sont stockés dans l'attribut $this->metadonneesArrete |
1239 |
|
*/ |
1240 |
|
function getArreteMetadata() { |
1241 |
|
$sqlArrete = "SELECT signataire_arrete.nom as \"nomsignataire\", |
1242 |
|
signataire_arrete.qualite as \"qualitesignataire\", |
1243 |
|
instruction.date_evenement as \"datesignaturearrete\", |
1244 |
|
instruction.etat as \"decisionarrete\", |
1245 |
|
dossier.terrain_adresse_voie_numero as \"ap_numrue\", |
1246 |
|
dossier.complement as \"ap_nomdelavoie\", |
1247 |
|
dossier.terrain_adresse_code_postal as \"ap_codepostal\", |
1248 |
|
dossier.terrain_adresse_localite as \"ap_ville\" |
1249 |
|
FROM ".DB_PREFIXE."instruction |
1250 |
|
LEFT JOIN ".DB_PREFIXE."signataire_arrete ON |
1251 |
|
instruction.signataire_arrete = signataire_arrete.signataire_arrete |
1252 |
|
LEFT JOIN ".DB_PREFIXE."dossier ON |
1253 |
|
instruction.dossier = dossier.dossier |
1254 |
|
LEFT JOIN ".DB_PREFIXE."donnees_techniques ON |
1255 |
|
donnees_techniques.dossier_instruction = dossier.dossier |
1256 |
|
WHERE instruction.instruction = ".$this->valF['instruction']; |
1257 |
|
$resArrete = $this->db->query($sqlArrete); |
1258 |
|
$this->f->addToLog("triggerModifierApres(): db->query(\"".$sqlArrete."\");", VERBOSE_MODE); |
1259 |
|
if ( database::isError($resArrete)){ |
1260 |
|
die(); |
1261 |
|
} |
1262 |
|
|
1263 |
|
$this->metadonneesArrete = $resArrete->fetchRow(DB_FETCHMODE_ASSOC); |
1264 |
|
} |
1265 |
|
|
1266 |
|
// Méthodes de récupération des métadonnées arrêté |
1267 |
|
function getNumArrete() { |
1268 |
|
return $this->valF['numero_arrete']; |
1269 |
|
} |
1270 |
|
function getSpecialiteArrete() { |
1271 |
|
return "ADS"; |
1272 |
|
} |
1273 |
|
function getDecisionArrete() { |
1274 |
|
if (empty($this->metadonneesArrete)) { |
1275 |
|
$this->getArreteMetadata(); |
1276 |
|
} |
1277 |
|
return $this->metadonneesArrete["decisionarrete"]; |
1278 |
|
} |
1279 |
|
function getChketatReglementaire() { |
1280 |
|
return ""; |
1281 |
|
} |
1282 |
|
function getChkNotification() { |
1283 |
|
if( isset($this->valF["date_retour_rar"]) ) { |
1284 |
|
return true; |
1285 |
|
} else { |
1286 |
|
return false; |
1287 |
|
} |
1288 |
|
} |
1289 |
|
function getDateNotification() { |
1290 |
|
return date("d/m/Y", strtotime($this->valF["date_retour_rar"])); |
1291 |
|
} |
1292 |
|
function getChkCreationdroit() { |
1293 |
|
return ""; |
1294 |
|
} |
1295 |
|
function getChkPublication() { |
1296 |
|
return ""; |
1297 |
|
} |
1298 |
|
function getDatePublication() { |
1299 |
|
return ""; |
1300 |
|
} |
1301 |
|
function getChkControleLegalite() { |
1302 |
|
if( isset($this->valF["date_retour_controle_legalite"]) ) { |
1303 |
|
return true; |
1304 |
|
} else { |
1305 |
|
return false; |
1306 |
|
} |
1307 |
|
} |
1308 |
|
function getDateSignatureArrete() { |
1309 |
|
return date("d/m/Y", strtotime($this->valF['date_retour_signature'])); |
1310 |
|
} |
1311 |
|
function getNomSignataire() { |
1312 |
|
if (empty($this->metadonneesArrete)) { |
1313 |
|
$this->getArreteMetadata(); |
1314 |
|
} |
1315 |
|
return $this->metadonneesArrete["nomsignataire"]; |
1316 |
|
} |
1317 |
|
function getQualiteSignataire() { |
1318 |
|
if (empty($this->metadonneesArrete)) { |
1319 |
|
$this->getArreteMetadata(); |
1320 |
|
} |
1321 |
|
return $this->metadonneesArrete["qualitesignataire"]; |
1322 |
|
} |
1323 |
|
function getChkDelegation() { |
1324 |
|
return ""; |
1325 |
|
} |
1326 |
|
function getAp_numRue() { |
1327 |
|
if (empty($this->metadonneesArrete)) { |
1328 |
|
$this->getArreteMetadata(); |
1329 |
|
} |
1330 |
|
return $this->metadonneesArrete["ap_numrue"]; |
1331 |
|
} |
1332 |
|
function getAp_nomDeLaVoie() { |
1333 |
|
if (empty($this->metadonneesArrete)) { |
1334 |
|
$this->getArreteMetadata(); |
1335 |
|
} |
1336 |
|
return $this->metadonneesArrete["ap_nomdelavoie"]; |
1337 |
|
} |
1338 |
|
function getAp_codePostal() { |
1339 |
|
if (empty($this->metadonneesArrete)) { |
1340 |
|
$this->getArreteMetadata(); |
1341 |
|
} |
1342 |
|
return $this->metadonneesArrete["ap_codepostal"]; |
1343 |
|
} |
1344 |
|
function getAp_ville() { |
1345 |
|
if (empty($this->metadonneesArrete)) { |
1346 |
|
$this->getArreteMetadata(); |
1347 |
|
} |
1348 |
|
return $this->metadonneesArrete["ap_ville"]; |
1349 |
|
} |
1350 |
|
|
1351 |
|
// Fin des méthodes de récupération des métadonnées |
1352 |
|
|
|
|
|
|
// trigger before delete |
|
1353 |
function triggersupprimer($id,&$db,$val,$DEBUG) { |
function triggersupprimer($id,&$db,$val,$DEBUG) { |
1354 |
// archive en instruction (si suppression) [archive if delete instruction] |
/** |
1355 |
$valF['delai']=$val['archive_delai']; |
* L'objectif ici est de repositionner les valeurs récupérées en |
1356 |
$valF['accord_tacite']=$val['archive_accord_tacite']; |
* archive dans le dossier d'instruction avant de supprimer l'événement |
1357 |
$valF['etat']=$val['archive_etat']; |
* d'instruction |
1358 |
if($val['archive_avis']=='') |
*/ |
1359 |
$valF['avis_decision']= null; |
// Mise à jour des 4 valeurs modifiées par l'action |
1360 |
else |
$valF['delai'] = $val['archive_delai']; |
1361 |
$valF['avis_decision']=$val['archive_avis']; |
$valF['accord_tacite'] = $val['archive_accord_tacite']; |
1362 |
// if= compatibilite pgsql |
$valF['etat'] = $val['archive_etat']; |
1363 |
if($val['archive_date_complet']!='') |
if ($val['archive_avis'] != '') { |
1364 |
$valF['date_complet']=$val['archive_date_complet']; |
$valF['avis_decision'] = $val['archive_avis']; |
1365 |
if($val['archive_date_rejet']!='') |
} else { |
1366 |
$valF['date_rejet']= $val['archive_date_rejet']; |
$valF['avis_decision'] = NULL; |
1367 |
if($val['archive_date_limite']!='') |
} |
1368 |
$valF['date_limite']= $val['archive_date_limite']; |
// Mise à jour des 10 dates avec la valeur présente dans le formulaire |
1369 |
if($val['archive_date_notification_delai']!='') |
// de suppression. Si la valeur de la date est vide alors on fixe |
1370 |
$valF['date_notification_delai']= $val['archive_date_notification_delai']; |
// à la valeur NULL |
1371 |
if($val['archive_date_decision']!='') |
// |
1372 |
$valF['date_decision']= $val['archive_date_decision']; |
if ($val['archive_date_complet'] != '') { |
1373 |
if($val['archive_date_validite']!='') |
$valF['date_complet'] = $val['archive_date_complet']; |
1374 |
$valF['date_validite']= $val['archive_date_validite']; |
} else { |
1375 |
if($val['archive_date_achevement']!='') |
$valF['date_complet'] = NULL; |
1376 |
$valF['date_achevement']= $val['archive_date_achevement']; |
} |
1377 |
if($val['archive_date_chantier']!='') |
if ($val['archive_date_dernier_depot'] != '') { |
1378 |
$valF['date_chantier']= $val['archive_date_chantier']; |
$valF['date_dernier_depot'] = $val['archive_date_dernier_depot']; |
1379 |
if($val['archive_date_conformite']!='') |
} else { |
1380 |
$valF['date_conformite']= $val['archive_date_conformite']; |
$valF['date_dernier_depot'] = NULL; |
1381 |
|
} |
1382 |
$cle= " dossier = '".$val['dossier']."'"; |
if ($val['archive_date_rejet'] != '') { |
1383 |
$res= $db->autoExecute(DB_PREFIXE.'dossier',$valF,DB_AUTOQUERY_UPDATE,$cle); |
$valF['date_rejet'] = $val['archive_date_rejet']; |
1384 |
if (database::isError($res)) |
} else { |
1385 |
|
$valF['date_rejet'] = NULL; |
1386 |
|
} |
1387 |
|
if ($val['archive_date_limite'] != '') { |
1388 |
|
$valF['date_limite'] = $val['archive_date_limite']; |
1389 |
|
} else { |
1390 |
|
$valF['date_limite'] = NULL; |
1391 |
|
} |
1392 |
|
if ($val['archive_date_notification_delai'] != '') { |
1393 |
|
$valF['date_notification_delai'] = $val['archive_date_notification_delai']; |
1394 |
|
} else { |
1395 |
|
$valF['date_notification_delai'] = NULL; |
1396 |
|
} |
1397 |
|
if ($val['archive_date_decision'] != '') { |
1398 |
|
$valF['date_decision'] = $val['archive_date_decision']; |
1399 |
|
} else { |
1400 |
|
$valF['date_decision'] = NULL; |
1401 |
|
} |
1402 |
|
if ($val['archive_date_validite'] != '') { |
1403 |
|
$valF['date_validite'] = $val['archive_date_validite']; |
1404 |
|
} else { |
1405 |
|
$valF['date_validite'] = NULL; |
1406 |
|
} |
1407 |
|
if ($val['archive_date_achevement'] != '') { |
1408 |
|
$valF['date_achevement'] = $val['archive_date_achevement']; |
1409 |
|
} else { |
1410 |
|
$valF['date_achevement'] = NULL; |
1411 |
|
} |
1412 |
|
if ($val['archive_date_chantier'] != '') { |
1413 |
|
$valF['date_chantier'] = $val['archive_date_chantier']; |
1414 |
|
} else { |
1415 |
|
$valF['date_chantier'] = NULL; |
1416 |
|
} |
1417 |
|
if ($val['archive_date_conformite'] != '') { |
1418 |
|
$valF['date_conformite'] = $val['archive_date_conformite']; |
1419 |
|
} else { |
1420 |
|
$valF['date_conformite'] = NULL; |
1421 |
|
} |
1422 |
|
if ($val['archive_incompletude'] != '') { |
1423 |
|
$valF['incompletude'] = $val['archive_incompletude']; |
1424 |
|
} else { |
1425 |
|
$valF['incompletude'] = NULL; |
1426 |
|
} |
1427 |
|
if ($val['archive_evenement_suivant_tacite'] != '') { |
1428 |
|
$valF['evenement_suivant_tacite'] = $val['archive_evenement_suivant_tacite']; |
1429 |
|
} else { |
1430 |
|
$valF['evenement_suivant_tacite'] = NULL; |
1431 |
|
} |
1432 |
|
if ($val['archive_evenement_suivant_tacite_incompletude'] != '') { |
1433 |
|
$valF['evenement_suivant_tacite_incompletude'] = $val['archive_evenement_suivant_tacite_incompletude']; |
1434 |
|
} else { |
1435 |
|
$valF['evenement_suivant_tacite_incompletude'] = NULL; |
1436 |
|
} |
1437 |
|
if ($val['archive_etat_pendant_incompletude'] != '') { |
1438 |
|
$valF['etat_pendant_incompletude'] = $val['archive_etat_pendant_incompletude']; |
1439 |
|
} else { |
1440 |
|
$valF['etat_pendant_incompletude'] = NULL; |
1441 |
|
} |
1442 |
|
if ($val['archive_date_limite_incompletude'] != '') { |
1443 |
|
$valF['date_limite_incompletude'] = $val['archive_date_limite_incompletude']; |
1444 |
|
} else { |
1445 |
|
$valF['date_limite_incompletude'] = NULL; |
1446 |
|
} |
1447 |
|
if ($val['archive_delai_incompletude'] != '') { |
1448 |
|
$valF['delai_incompletude'] = $val['archive_delai_incompletude']; |
1449 |
|
} else { |
1450 |
|
$valF['delai_incompletude'] = NULL; |
1451 |
|
} |
1452 |
|
// On met à jour le dossier |
1453 |
|
$cle = " dossier='".$val['dossier']."'"; |
1454 |
|
$res = $db->autoExecute(DB_PREFIXE.'dossier', $valF, DB_AUTOQUERY_UPDATE, $cle); |
1455 |
|
$this->addToLog("triggersupprimer(): db->autoexecute(\"".DB_PREFIXE."dossier\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$cle."\");", VERBOSE_MODE); |
1456 |
|
if (database::isError($res)) { |
1457 |
die($res->getMessage()); |
die($res->getMessage()); |
|
else{ |
|
|
if ($DEBUG == 1) |
|
|
echo "La requête de mise à jour est effectuée.<br>"; |
|
1458 |
} |
} |
1459 |
|
// Affichage d'informations à l'utilisateur |
1460 |
|
$this->addToMessage(_("Suppression de l'instruction")." [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
1461 |
|
|
1462 |
} |
} |
1463 |
|
|
1464 |
|
function triggersupprimerapres($id,&$db,$val,$DEBUG) { |
1465 |
|
|
1466 |
|
// Mise à jour des données du dossier d'autorisation |
1467 |
|
require_once "../obj/dossier_autorisation.class.php"; |
1468 |
|
$da = new dossier_autorisation($this->getDossierAutorisationFromDossier($val["dossier"]), $this->db, DEBUG); |
1469 |
|
$da->majDossierAutorisation(); |
1470 |
|
} |
1471 |
|
|
1472 |
// ============================================= |
// ============================================= |
1473 |
// calcul de date avec ajout de mois (delais) |
// calcul de date avec ajout de mois (delais) |
1474 |
// [add months (delay) and calculation final date] |
// [add months (delay) and calculation final date] |
1523 |
// Vérifie la restriction sur l'événement |
// Vérifie la restriction sur l'événement |
1524 |
function verifier($val = array(), &$db, $DEBUG){ |
function verifier($val = array(), &$db, $DEBUG){ |
1525 |
parent::verifier($val, $db, $DEBUG); |
parent::verifier($val, $db, $DEBUG); |
|
//Récupère la restriction |
|
|
$sql= "SELECT |
|
|
restriction |
|
|
FROM |
|
|
".DB_PREFIXE."evenement |
|
|
WHERE |
|
|
evenement =".$this->valF['evenement']; |
|
1526 |
|
|
1527 |
$res = $db->query($sql); |
if ( isset($val['evenement']) && is_numeric($val['evenement'])){ |
1528 |
$this->f->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE); |
//Récupère la restriction |
1529 |
$this->f->isDatabaseError(); |
$sql= "SELECT |
1530 |
|
restriction |
1531 |
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
FROM |
1532 |
|
".DB_PREFIXE."evenement |
1533 |
//Test qu'une restriction est présente |
WHERE |
1534 |
if ( isset($row['restriction']) && $row['restriction'] != "" ){ |
evenement =".$val['evenement']; |
1535 |
|
|
1536 |
//Test si la restriction est valide |
$res = $db->query($sql); |
1537 |
if ( !$this->restrictionIsValid($row['restriction']) ){ |
$this->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE); |
1538 |
|
if (database::isError($res)) { |
1539 |
$this->correct=false; |
die($res->getMessage()); |
1540 |
$this->addToMessage(_("Restriction non valide")); |
} |
1541 |
} |
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
1542 |
else { |
|
1543 |
|
//Test qu'une restriction est présente |
1544 |
|
if ( isset($row['restriction']) && $row['restriction'] != "" ){ |
1545 |
|
|
1546 |
$this->correct = true; |
//Test si la restriction est valide |
1547 |
|
if ( !$this->restrictionIsValid($row['restriction']) ){ |
1548 |
|
|
1549 |
|
$this->correct=false; |
1550 |
|
$this->addToMessage(_("Restriction non valide")); |
1551 |
|
} |
1552 |
|
else { |
1553 |
|
|
1554 |
|
$this->correct = true; |
1555 |
|
} |
1556 |
} |
} |
1557 |
} |
} |
1558 |
|
|
1559 |
|
$this->updateDate("date_envoi_signature"); |
1560 |
|
$this->updateDate("date_retour_signature"); |
1561 |
|
$this->updateDate("date_envoi_rar"); |
1562 |
|
$this->updateDate("date_retour_rar"); |
1563 |
|
$this->updateDate("date_envoi_controle_legalite"); |
1564 |
|
$this->updateDate("date_retour_controle_legalite"); |
1565 |
} |
} |
1566 |
|
|
1567 |
/** |
/** |
1568 |
* Méthode permettant de mettre à jour l'état d'un DA |
* Méthode permettant de récupérer toutes les valeurs de l'événement |
1569 |
|
* sélectionné après validation du formulaire d'instruction |
1570 |
|
* |
1571 |
|
* @return array() veleurs de l'événement lié |
1572 |
*/ |
*/ |
1573 |
function majEtatDA() { |
|
1574 |
if($this->valF['action'] == 'accepter' AND $this->valF['avis_decision'] == 8) { |
private function getValEvenement() { |
1575 |
$val['etat_dossier_autorisation']=5; |
if(!empty($this->valEvenement)) { |
1576 |
} elseif($this->valF['action'] == 'accepter' AND $this->valF['avis_decision'] == 15) { |
return $this->valEvenement; |
|
$val['etat_dossier_autorisation']=3; |
|
|
} elseif($this->valF['action'] == 'accepter') { |
|
|
$val['etat_dossier_autorisation']=2; |
|
|
} elseif($this->valF['action'] == 'rejeter') { |
|
|
$val['etat_dossier_autorisation']=4; |
|
|
} elseif($this->valF['action'] == 'terminer') { |
|
|
$val['etat_dossier_autorisation']=8; |
|
|
} elseif($this->valF['action'] == 'majorer') { |
|
|
$val['etat_dossier_autorisation']=6; |
|
1577 |
} else { |
} else { |
1578 |
$val['etat_dossier_autorisation']=7; |
$sql = "SELECT * FROM ".DB_PREFIXE."evenement |
1579 |
} |
WHERE evenement=".$this->valF['evenement']; |
1580 |
|
$res = $this->db->query($sql); |
1581 |
//Récupération du numéro de dossier d'autorisation lié au dossier d'instruction |
$this->addToLog("getValEvenement(): db->query(\"".$sql."\");", VERBOSE_MODE); |
1582 |
$IDdossier_autorisation = $this->getDossierAutorisation($this->valF['dossier']); |
if (database::isError($res)) { |
1583 |
|
die($res->getMessage()); |
1584 |
// Mis à jour de l'état du dossier d'autorisation |
} |
1585 |
require_once '../obj/dossier_autorisation.class.php'; |
$this->valEvenement = $res->fetchRow(DB_FETCHMODE_ASSOC); |
1586 |
$dossier_autorisation = new dossier_autorisation($IDdossier_autorisation,$this->db,DEBUG); |
return $this->valEvenement; |
|
|
|
|
$dossier_autorisation->val[array_search("etat_dossier_autorisation", $dossier_autorisation->champs)] = $val['etat_dossier_autorisation']; |
|
|
|
|
|
//Récupération des données |
|
|
$valDossierAutorisation = array(); |
|
|
for ( $i=0 ; $i<count($dossier_autorisation->champs); $i++){ |
|
|
|
|
|
$valDossierAutorisation[$dossier_autorisation->champs[$i]]= |
|
|
$dossier_autorisation->val[$i]; |
|
1587 |
} |
} |
1588 |
|
} |
1589 |
|
|
1590 |
$dossier_autorisation->modifier($valDossierAutorisation, $this->db, DEBUG); |
/** |
1591 |
|
* Méthode permettant de savoir si le dossier lié à l'instruction à le flag |
1592 |
|
* incompletude à true après validation du formulaire d'instruction |
1593 |
|
* |
1594 |
|
* @return boolean |
1595 |
|
*/ |
1596 |
|
private function dossierIncomplet() { |
1597 |
|
$sql = "SELECT incompletude FROM ".DB_PREFIXE."dossier |
1598 |
|
WHERE dossier='".$this->valF['dossier']."'"; |
1599 |
|
$incompletude = $this->db->getOne($sql); |
1600 |
|
$this->addToLog("dossierIncomplet(): db->query(\"".$sql."\");", VERBOSE_MODE); |
1601 |
|
if (database::isError($incompletude)) { |
1602 |
|
die($incompletude->getMessage()); |
1603 |
|
} |
1604 |
|
if ($incompletude == 't') { |
1605 |
|
return true; |
1606 |
|
} else { |
1607 |
|
return false; |
1608 |
|
} |
1609 |
} |
} |
1610 |
|
|
1611 |
/** |
/** |
1612 |
* Méthode permettant de mettre à jour les données d'un DA |
* Finalisation des documents. |
1613 |
*/ |
*/ |
1614 |
function majDataDA() { |
function finaliser( $champ = '', $status, $sousform){ |
1615 |
|
|
1616 |
//Récupération du numéro de dossier d'autorisation lié au dossier d'instruction |
//Si on finalise le document |
1617 |
$IDdossier_autorisation = $this->getDossierAutorisation($this->valF['dossier']); |
if ( $status == 1 ){ |
|
require_once '../obj/dossier_autorisation.class.php'; |
|
|
$dossier_autorisation = new dossier_autorisation($IDdossier_autorisation,$this->db,DEBUG); |
|
|
|
|
|
require_once '../obj/dossier.class.php'; |
|
|
$dossier = new dossier($this->valF['dossier'],$this->db,DEBUG); |
|
|
|
|
|
//Récupération des données |
|
|
$valDossierAutorisation = array(); |
|
|
for ( $i=0 ; $i<count($dossier_autorisation->champs); $i++){ |
|
1618 |
|
|
1619 |
if ( array_search($dossier_autorisation->champs[$i], $dossier->champs) ){ |
//Génération du PDF |
1620 |
|
$_GET['output'] = "string"; |
1621 |
$valDossierAutorisation[$dossier_autorisation->champs[$i]]=$dossier->getVal($dossier_autorisation->champs[$i]); |
$f = $this->f; |
1622 |
|
include '../app/pdf_instruction.php'; |
1623 |
|
|
1624 |
|
//Métadonnées du document |
1625 |
|
$metadata = array( |
1626 |
|
'filename' => 'instruction_'.$idx.'.pdf', |
1627 |
|
'mimetype' => 'application/pdf', |
1628 |
|
'size' => strlen($pdf_output) |
1629 |
|
); |
1630 |
|
|
1631 |
|
// Récupération des métadonnées calculées après validation |
1632 |
|
$spe_metadata = $this->getMetadata("om_fichier_instruction"); |
1633 |
|
|
1634 |
|
$metadata = array_merge($metadata, $spe_metadata); |
1635 |
|
//Si le document a déjà été finalisé |
1636 |
|
//on met à jour le document mais pas son uid |
1637 |
|
if ( $this->getVal("om_fichier_instruction") != '' ){ |
1638 |
|
$uid = $this->f->storage->update( |
1639 |
|
$this->getVal("om_fichier_instruction"), $pdf_output, $metadata); |
1640 |
} |
} |
1641 |
|
//Sinon, on joute le document et on récupère son uid |
1642 |
else { |
else { |
1643 |
$valDossierAutorisation[$dossier_autorisation->champs[$i]]= |
//Stockage du PDF |
1644 |
$dossier_autorisation->val[$i]; |
$uid = $this->f->storage->create($pdf_output, $metadata); |
1645 |
|
} |
1646 |
|
} |
1647 |
|
else { |
1648 |
|
//Récupération de l'uid du document finalisé |
1649 |
|
$uid = $this->getVal("om_fichier_instruction"); |
1650 |
|
|
1651 |
|
//On dé-finalise avant de finaliser |
1652 |
|
if ( $uid == '' ){ |
1653 |
|
return -1; |
1654 |
} |
} |
1655 |
} |
} |
1656 |
|
|
1657 |
$dossier_autorisation->modifier($valDossierAutorisation, $this->db, DEBUG); |
//Mise à jour des données |
1658 |
|
if ( $uid != '' ){ |
1659 |
// Suppression du liens entre les lots et le DA |
// Logger |
1660 |
$valLot['dossier_autorisation'] = NULL; |
$this->addToLog("finaliser() - begin", EXTRA_VERBOSE_MODE); |
1661 |
$this->db->autoExecute(DB_PREFIXE."lot", $valLot, DB_AUTOQUERY_UPDATE, "dossier_autorisation='".$IDdossier_autorisation."'"); |
// Recuperation de la valeur de la cle primaire de l'objet |
1662 |
|
if($this->getVal($this->clePrimaire) != '') |
1663 |
// Liaison des lots du DI avec le DA |
$id = $this->getVal($this->clePrimaire); |
1664 |
$sqlLot = "SELECT lot FROM ".DB_PREFIXE."lien_dossier_lot WHERE dossier='".$this->valF['dossier']."'"; |
else |
1665 |
$res = $this->db->query($sqlLot); |
$id=$this->id; |
1666 |
$this->addToLog($sqlLot); |
|
1667 |
$this->f->isDatabaseError(); |
//Tableau contenant le lien vers le PDF et lien du portlet pour la mise |
1668 |
while($rowLot = $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
//à jour de l'interface |
1669 |
$valLot['dossier_autorisation'] = $IDdossier_autorisation; |
if ( $status == 0 ){ |
1670 |
$this->db->autoExecute(DB_PREFIXE."lot", $valLot, DB_AUTOQUERY_UPDATE, "lot=".$rowLot['lot']); |
$lien = '../app/pdf_instruction.php?idx='.$id; |
1671 |
|
} |
1672 |
|
else { |
1673 |
|
$lien = '../spg/file.php?obj=instruction&'. |
1674 |
|
'champ=om_fichier_instruction&id='.$id; |
1675 |
|
} |
1676 |
|
|
1677 |
|
$retour = array( |
1678 |
|
"portlet"=> "<a href=\"#\" onclick=\"finalizeDocument(". |
1679 |
|
$id.", 'instruction', '".$sousform."', ".(($status==0)?1:0).")\"> |
1680 |
|
<span class=\"om-prev-icon om-icon-16 om-icon-fix delete-16 " |
1681 |
|
.(($status==1)?"de":"")."finalise\" title=\"". |
1682 |
|
(($status==1)?_("Reprendre la redaction du document"):_("Finaliser le document"))."\">". |
1683 |
|
(($status==1)?_("Reprendre la redaction du document"):_("Finaliser le document"))."</span> |
1684 |
|
</a>", |
1685 |
|
"pdf" => $lien |
1686 |
|
); |
1687 |
|
|
1688 |
|
foreach ( $this->champs as $key=>$value ) |
1689 |
|
$val[$value] = $this->val[$key]; |
1690 |
|
$val['date_evenement']=$this->dateDBToForm($val['date_evenement']); |
1691 |
|
$val['archive_date_complet']=$this->dateDBToForm($val['archive_date_complet']); |
1692 |
|
$val['archive_date_rejet']=$this->dateDBToForm($val['archive_date_rejet']); |
1693 |
|
$val['archive_date_limite']=$this->dateDBToForm($val['archive_date_limite']); |
1694 |
|
$val['archive_date_notification_delai']=$this->dateDBToForm($val['archive_date_notification_delai']); |
1695 |
|
$val['archive_date_decision']=$this->dateDBToForm($val['archive_date_decision']); |
1696 |
|
$val['archive_date_validite']=$this->dateDBToForm($val['archive_date_validite']); |
1697 |
|
$val['archive_date_achevement']=$this->dateDBToForm($val['archive_date_achevement']); |
1698 |
|
$val['archive_date_chantier']=$this->dateDBToForm($val['archive_date_chantier']); |
1699 |
|
$val['archive_date_conformite']=$this->dateDBToForm($val['archive_date_conformite']); |
1700 |
|
$val['archive_date_dernier_depot']=$this->dateDBToForm($val['archive_date_dernier_depot']); |
1701 |
|
$val['archive_date_limite_incompletude']=$this->dateDBToForm($val['archive_date_limite_incompletude']); |
1702 |
|
$val['date_finalisation_courrier']=$this->dateDBToForm($val['date_finalisation_courrier']); |
1703 |
|
$val['date_envoi_signature']=$this->dateDBToForm($val['date_envoi_signature']); |
1704 |
|
$val['date_retour_signature']=$this->dateDBToForm($val['date_retour_signature']); |
1705 |
|
$val['date_envoi_rar']=$this->dateDBToForm($val['date_envoi_rar']); |
1706 |
|
$val['date_retour_rar']=$this->dateDBToForm($val['date_retour_rar']); |
1707 |
|
$val['date_envoi_controle_legalite']=$this->dateDBToForm($val['date_envoi_controle_legalite']); |
1708 |
|
$val['date_retour_controle_legalite']=$this->dateDBToForm($val['date_retour_controle_legalite']); |
1709 |
|
|
1710 |
|
$this->setvalF($val); |
1711 |
|
|
1712 |
|
// Verification de la validite des donnees |
1713 |
|
$this->verifier($this->val, $this->db, DEBUG); |
1714 |
|
// Verification du verrou |
1715 |
|
$this->testverrou(); |
1716 |
|
// Si les verifications precedentes sont correctes, on procede a |
1717 |
|
// la modification, sinon on ne fait rien et on retourne une erreur |
1718 |
|
if ($this->correct) { |
1719 |
|
// Execution du trigger 'before' specifique au MODE 'update' |
1720 |
|
$this->triggermodifier( $id, $this->db, $this->val, DEBUG); |
1721 |
|
$valF = array( |
1722 |
|
"om_final_instruction"=> ($status==1)?TRUE:FALSE, |
1723 |
|
"om_fichier_instruction"=>$uid); |
1724 |
|
// Execution de la requête de modification des donnees de l'attribut |
1725 |
|
// valF de l'objet dans l'attribut table de l'objet |
1726 |
|
$res = $this->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
1727 |
|
DB_AUTOQUERY_UPDATE, $this->getCle($id)); |
1728 |
|
$this->addToLog("finaliser() : db->autoExecute(\"".DB_PREFIXE.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($id)."\")", VERBOSE_MODE); |
1729 |
|
// Si une erreur survient |
1730 |
|
if (database::isError($res)) { |
1731 |
|
// Appel de la methode de recuperation des erreurs |
1732 |
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
1733 |
|
} else { |
1734 |
|
// Log |
1735 |
|
$this->addToLog(_("Requete executee"), VERBOSE_MODE); |
1736 |
|
// Log |
1737 |
|
$message = _("Enregistrement")." ".$id." "; |
1738 |
|
$message .= _("de la table")." \"".$this->table."\" "; |
1739 |
|
$message .= "[ ".$this->db->affectedRows()." "; |
1740 |
|
$message .= _("enregistrement(s) mis a jour")." ]"; |
1741 |
|
$this->addToLog($message, VERBOSE_MODE); |
1742 |
|
// Mise en place du verrou pour ne pas finaliser plusieurs fois |
1743 |
|
// le meme document |
1744 |
|
$this->verrouille(); |
1745 |
|
// Execution du trigger 'after' specifique au MODE 'update' |
1746 |
|
//$this->triggermodifierapres($id, $this->db, $val, DEBUG); |
1747 |
|
|
1748 |
|
return $retour; |
1749 |
|
} |
1750 |
|
} else { |
1751 |
|
// Message d'echec (saut d'une ligne supplementaire avant le |
1752 |
|
// message pour qu'il soit mis en evidence) |
1753 |
|
$this->addToLog("Finalisation non enregistree"); |
1754 |
|
return -1; |
1755 |
|
} |
1756 |
|
} |
1757 |
|
// Si le document n'a pas été stocké |
1758 |
|
else{ |
1759 |
|
return -1; |
1760 |
} |
} |
1761 |
} |
} |
1762 |
|
|
1763 |
// Récupération de l'identifiant du dossier d'autorisation lié au dossier d'instruction |
/** |
1764 |
function getDossierAutorisation($dossier_instruction){ |
* Finalisation du document lors de l'ajout d'une instruction |
1765 |
|
* |
1766 |
$sql = "SELECT |
*/ |
1767 |
dossier_autorisation.dossier_autorisation |
function finaliserAjouter(){ |
1768 |
FROM |
|
1769 |
".DB_PREFIXE."dossier_autorisation |
//Génération du PDF |
1770 |
LEFT JOIN |
$_GET['output'] = "string"; |
1771 |
".DB_PREFIXE."dossier |
$_GET['obj'] = "instruction"; |
1772 |
ON |
$_GET['idx'] = $this->valF[$this->clePrimaire]; |
1773 |
dossier_autorisation.dossier_autorisation = dossier.dossier_autorisation |
$f = $this->f; |
1774 |
WHERE |
include '../app/pdf_instruction.php'; |
1775 |
dossier.dossier = '".$dossier_instruction."'"; |
|
1776 |
|
//Métadonnées du document |
1777 |
$IDdossier_autorisation = $this->db->getOne($sql); |
$metadata = array( |
1778 |
$this->addToLog("getDossierAutorisation(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
'filename' => 'instruction_'.$idx.'.pdf', |
1779 |
database::isError($IDdossier_autorisation); |
'mimetype' => 'application/pdf', |
1780 |
|
'size' => strlen($pdf_output) |
1781 |
|
); |
1782 |
|
|
1783 |
|
// Récupération des métadonnées calculées après validation |
1784 |
|
$spe_metadata = $this->getMetadata("om_fichier_instruction"); |
1785 |
|
|
1786 |
|
$metadata = array_merge($metadata, $spe_metadata); |
1787 |
|
|
1788 |
|
//On ajoute le document et on récupère son uid |
1789 |
|
$uid = $this->f->storage->create($pdf_output, $metadata); |
1790 |
|
|
1791 |
|
//Mise à jour des données |
1792 |
|
if ( $uid != '' ){ |
1793 |
|
// Logger |
1794 |
|
$this->addToLog("finaliserAjouter() - begin", EXTRA_VERBOSE_MODE); |
1795 |
|
|
1796 |
|
$valF = array( |
1797 |
|
"om_final_instruction"=> TRUE, |
1798 |
|
"om_fichier_instruction"=>$uid); |
1799 |
|
|
1800 |
|
// Execution de la requête de modification des donnees de l'attribut |
1801 |
|
// valF de l'objet dans l'attribut table de l'objet |
1802 |
|
$res = $this->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
1803 |
|
DB_AUTOQUERY_UPDATE, $this->getCle($idx)); |
1804 |
|
$this->addToLog("finaliserAjouter() : db->autoExecute(\"".DB_PREFIXE.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($idx)."\")", VERBOSE_MODE); |
1805 |
|
// Si une erreur survient |
1806 |
|
if (database::isError($res)) { |
1807 |
|
// Appel de la methode de recuperation des erreurs |
1808 |
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
1809 |
|
} else { |
1810 |
|
// Log |
1811 |
|
$this->addToLog(_("Requete executee"), VERBOSE_MODE); |
1812 |
|
// Log |
1813 |
|
$message = _("Enregistrement")." ".$idx." "; |
1814 |
|
$message .= _("de la table")." \"".$this->table."\" "; |
1815 |
|
$message .= "[ ".$this->db->affectedRows()." "; |
1816 |
|
$message .= _("enregistrement(s) mis a jour")." ]"; |
1817 |
|
$this->addToLog($message, VERBOSE_MODE); |
1818 |
|
} |
1819 |
|
} |
1820 |
|
} |
1821 |
|
|
1822 |
|
/** |
1823 |
|
* Récupération du numéro de dossier d'instruction à ajouter aux métadonnées |
1824 |
|
* @return [type] [description] |
1825 |
|
*/ |
1826 |
|
protected function getDossier() { |
1827 |
|
if(empty($this->specificMetadata)) { |
1828 |
|
$this->getSpecificMetadata(); |
1829 |
|
} |
1830 |
|
return $this->specificMetadata->dossier; |
1831 |
|
} |
1832 |
|
/** |
1833 |
|
* Récupération du numéro de dossier d'autorisation à ajouter aux métadonnées |
1834 |
|
* @return [type] [description] |
1835 |
|
*/ |
1836 |
|
protected function getDossierAutorisation() { |
1837 |
|
if(empty($this->specificMetadata)) { |
1838 |
|
$this->getSpecificMetadata(); |
1839 |
|
} |
1840 |
|
return $this->specificMetadata->dossier_autorisation; |
1841 |
|
} |
1842 |
|
/** |
1843 |
|
* Récupération de la date de demande initiale du dossier à ajouter aux métadonnées |
1844 |
|
* @return [type] [description] |
1845 |
|
*/ |
1846 |
|
protected function getDateDemandeInitiale() { |
1847 |
|
if(empty($this->specificMetadata)) { |
1848 |
|
$this->getSpecificMetadata(); |
1849 |
|
} |
1850 |
|
return $this->specificMetadata->date_demande_initiale; |
1851 |
|
} |
1852 |
|
/** |
1853 |
|
* Récupération du type de dossier d'instruction à ajouter aux métadonnées |
1854 |
|
* @return [type] [description] |
1855 |
|
*/ |
1856 |
|
protected function getDossierInstructionType() { |
1857 |
|
if(empty($this->specificMetadata)) { |
1858 |
|
$this->getSpecificMetadata(); |
1859 |
|
} |
1860 |
|
return $this->specificMetadata->dossier_instruction_type; |
1861 |
|
} |
1862 |
|
/** |
1863 |
|
* Récupération du statut du dossier d'autorisation à ajouter aux métadonnées |
1864 |
|
* @return [type] [description] |
1865 |
|
*/ |
1866 |
|
protected function getStatut() { |
1867 |
|
if(empty($this->specificMetadata)) { |
1868 |
|
$this->getSpecificMetadata(); |
1869 |
|
} |
1870 |
|
return $this->specificMetadata->statut; |
1871 |
|
} |
1872 |
|
/** |
1873 |
|
* Récupération du type de dossier d'autorisation à ajouter aux métadonnées |
1874 |
|
* @return [type] [description] |
1875 |
|
*/ |
1876 |
|
protected function getDossierAutorisationType() { |
1877 |
|
if(empty($this->specificMetadata)) { |
1878 |
|
$this->getSpecificMetadata(); |
1879 |
|
} |
1880 |
|
return $this->specificMetadata->dossier_autorisation_type; |
1881 |
|
} |
1882 |
|
/** |
1883 |
|
* Récupération de la date d'ajout de document à ajouter aux métadonnées |
1884 |
|
* @return [type] [description] |
1885 |
|
*/ |
1886 |
|
protected function getDateEvenement() { |
1887 |
|
return date("d/m/Y"); |
1888 |
|
} |
1889 |
|
/** |
1890 |
|
* Récupération du groupe d'instruction à ajouter aux métadonnées |
1891 |
|
* @return string Groupe d'instruction |
1892 |
|
*/ |
1893 |
|
protected function getGroupeInstruction() { |
1894 |
|
if(empty($this->specificMetadata)) { |
1895 |
|
$this->getSpecificMetadata(); |
1896 |
|
} |
1897 |
|
return $this->specificMetadata->groupe_instruction; |
1898 |
|
} |
1899 |
|
|
1900 |
|
/** |
1901 |
|
* Cette méthode permet de stocker en attribut toutes les métadonnées |
1902 |
|
* nécessaire à l'ajout d'un document. |
1903 |
|
*/ |
1904 |
|
public function getSpecificMetadata() { |
1905 |
|
if (isset($this->valF["dossier"]) AND $this->valF["dossier"] != "") { |
1906 |
|
$dossier = $this->valF["dossier"]; |
1907 |
|
} else { |
1908 |
|
$dossier = $this->getVal("dossier"); |
1909 |
|
} |
1910 |
|
//Requête pour récupérer les informations essentiels sur le dossier d'instruction |
1911 |
|
$sql = "SELECT dossier.dossier as dossier, |
1912 |
|
dossier_autorisation.dossier_autorisation as dossier_autorisation, |
1913 |
|
to_char(dossier.date_demande, 'YYYY/MM') as date_demande_initiale, |
1914 |
|
dossier_instruction_type.code as dossier_instruction_type, |
1915 |
|
etat_dossier_autorisation.libelle as statut, |
1916 |
|
dossier_autorisation_type.code as dossier_autorisation_type, |
1917 |
|
groupe.code as groupe_instruction |
1918 |
|
FROM ".DB_PREFIXE."dossier |
1919 |
|
LEFT JOIN ".DB_PREFIXE."dossier_instruction_type |
1920 |
|
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
1921 |
|
LEFT JOIN ".DB_PREFIXE."dossier_autorisation |
1922 |
|
ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
1923 |
|
LEFT JOIN ".DB_PREFIXE."etat_dossier_autorisation |
1924 |
|
ON dossier_autorisation.etat_dossier_autorisation = etat_dossier_autorisation.etat_dossier_autorisation |
1925 |
|
LEFT JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille |
1926 |
|
ON dossier_autorisation.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
1927 |
|
LEFT JOIN ".DB_PREFIXE."dossier_autorisation_type |
1928 |
|
ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
1929 |
|
LEFT JOIN ".DB_PREFIXE."groupe |
1930 |
|
ON dossier_autorisation_type.groupe = groupe.groupe |
1931 |
|
WHERE dossier.dossier = '".$dossier."'"; |
1932 |
|
$res = $this->db->query($sql); |
1933 |
|
$this->f->addToLog("obj/document_numerise.class.php : db->query(".$sql.")", VERBOSE_MODE); |
1934 |
|
if ( database::isError($res)){ |
1935 |
|
die(); |
1936 |
|
} |
1937 |
|
|
1938 |
return $IDdossier_autorisation; |
//Le résultat est récupéré dans un objet |
1939 |
|
$row =& $res->fetchRow(DB_FETCHMODE_OBJECT); |
1940 |
|
|
1941 |
|
//Si il y a un résultat |
1942 |
|
if ($row !== null) { |
1943 |
|
|
1944 |
|
//Alors on créé l'objet dossier_instruction |
1945 |
|
$this->specificMetadata = $row; |
1946 |
|
|
1947 |
|
} |
1948 |
} |
} |
1949 |
}// fin classe |
}// fin classe |
1950 |
?> |
?> |