1 |
fraynaud |
3 |
<?php |
2 |
|
|
//$Id$ |
3 |
fraynaud |
20 |
//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 $ |
6 |
|
|
specific : |
7 |
|
|
- cle secondaire |
8 |
|
|
destruction autorisée que pour le dernier evenement |
9 |
|
|
[delete the last event ] |
10 |
|
|
- variable globale [global variables] |
11 |
|
|
var $archive_date_depot; |
12 |
|
|
var $retourformulaire; |
13 |
|
|
var $idxformulaire; |
14 |
|
|
- modification des données dans dossier trigger avant |
15 |
|
|
[modify dossier data with trigger function] |
16 |
|
|
- function moisdate : pour ajouter des mois a une date |
17 |
|
|
[add months (delay) and calculation final date] |
18 |
|
|
- voir script_lang.js : bible ... |
19 |
|
|
*/ |
20 |
fraynaud |
3 |
require_once ("../gen/obj/instruction.class.php"); |
21 |
mlimic |
910 |
require_once("../services/outgoing/messageenqueuer.php"); |
22 |
fraynaud |
3 |
|
23 |
|
|
class instruction extends instruction_gen { |
24 |
|
|
|
25 |
fraynaud |
20 |
var $archive_date_depot; // specific |
26 |
|
|
var $retourformulaire; // specific |
27 |
|
|
var $idxformulaire; // specific |
28 |
fraynaud |
3 |
|
29 |
fraynaud |
20 |
function instruction($id,&$db,$debug) { |
30 |
|
|
$this->constructeur($id,$db,$debug); |
31 |
|
|
}// fin constructeur |
32 |
|
|
|
33 |
fmichon |
944 |
// {{{ Gestion de la confidentialité des données spécifiques |
34 |
|
|
|
35 |
|
|
/** |
36 |
|
|
* Surcharge pour gérer les actions disponibles dans le portlet |
37 |
|
|
*/ |
38 |
|
|
function checkAccessibility() { |
39 |
|
|
// |
40 |
|
|
parent::checkAccessibility(); |
41 |
|
|
// Si l'utilisateur est un intructeur qui en correspond pas à la |
42 |
|
|
// division du dossier |
43 |
|
|
if ($this->f->isUserInstructeur() |
44 |
|
|
&& isset($this->f->om_utilisateur["division"]) |
45 |
|
|
&& $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier()) { |
46 |
|
|
// |
47 |
|
|
$this->actions_sup = array(); |
48 |
|
|
$this->setParameter("actions", array()); |
49 |
|
|
} |
50 |
|
|
// Si une action 'lu' est présente et que le champ lu est à true |
51 |
|
|
// on supprime l'action |
52 |
|
|
if (isset($this->actions_sup["lu"]) |
53 |
|
|
&& isset($this->val[array_search("lu", $this->champs)]) |
54 |
|
|
&& $this->val[array_search("lu", $this->champs)]== "t") { |
55 |
|
|
unset($this->actions_sup["lu"]); |
56 |
|
|
} |
57 |
|
|
} |
58 |
|
|
|
59 |
|
|
/** |
60 |
|
|
* Cette methode est à surcharger elle permet de tester dans chaque classe |
61 |
|
|
* des droits des droits spécifiques en fonction des données |
62 |
|
|
*/ |
63 |
|
|
function canAccess() { |
64 |
|
|
// Si l'utilisateur est un intructeur qui ne correspond pas à la |
65 |
|
|
// division du dossier |
66 |
|
|
if ($this->f->isUserInstructeur() |
67 |
|
|
&& $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier() |
68 |
|
|
&& $this->getParameter("maj") != 3) { |
69 |
|
|
// |
70 |
|
|
return false; |
71 |
|
|
} |
72 |
|
|
// |
73 |
|
|
return true; |
74 |
|
|
} |
75 |
|
|
|
76 |
|
|
/** |
77 |
|
|
* Cette méthode permet de récupérer la division d'un dossier |
78 |
|
|
*/ |
79 |
|
|
function getDivisionFromDossier() { |
80 |
|
|
// |
81 |
|
|
if (!isset($this->val[array_search("dossier", $this->champs)])) { |
82 |
|
|
return NULL; |
83 |
|
|
} |
84 |
|
|
// |
85 |
|
|
$sql = "select division from ".DB_PREFIXE."dossier "; |
86 |
|
|
$sql .= " where dossier='".$this->val[array_search("dossier", $this->champs)]."'"; |
87 |
|
|
// |
88 |
|
|
$division = $this->db->getOne($sql); |
89 |
|
|
$this->addToLog("getDivisionFromDossier(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
90 |
|
|
database::isError($division); |
91 |
|
|
// |
92 |
|
|
return $division; |
93 |
|
|
} |
94 |
|
|
|
95 |
|
|
// }}} |
96 |
|
|
|
97 |
fraynaud |
20 |
function cleSecondaire($id,&$db,$val,$DEBUG) { |
98 |
fraynaud |
129 |
parent::cleSecondaire($id,$db,$val,$DEBUG); |
99 |
|
|
// controle suppression cle secondaire [secondary key delete control] |
100 |
|
|
// ------------------------------------------------------------------------------------ |
101 |
|
|
// specifique detruire que le dernier [specific instruction : delete the last event ] |
102 |
|
|
// ------------------------------------------------------------------------------------ |
103 |
fraynaud |
20 |
$dernierevenement=''; |
104 |
fraynaud |
242 |
$sql="select max(instruction) from ".DB_PREFIXE."instruction where dossier ='". |
105 |
fraynaud |
20 |
$this->idxformulaire."'"; |
106 |
|
|
$dernierevenement = $db->getOne($sql); |
107 |
|
|
if($dernierevenement==$id){ |
108 |
|
|
$this->correct=true; |
109 |
nhaye |
460 |
$this->addToMessage(_('Destruction_chronologique')); |
110 |
fraynaud |
20 |
}else{ |
111 |
nhaye |
460 |
$this->addToMessage(_('Destruction_evenement')." : ".$dernierevenement); |
112 |
|
|
$this->addToMessage(_('Destruction_chronologique')); |
113 |
fraynaud |
20 |
$this->correct=false; |
114 |
|
|
} |
115 |
|
|
} |
116 |
|
|
|
117 |
vpihour |
1058 |
/*Met des valeurs par défaut dans certains des sous-formulaire*/ |
118 |
fraynaud |
20 |
function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire){ |
119 |
nhaye |
428 |
if ($validation==0 and $maj<2) { |
120 |
fraynaud |
20 |
if ($maj == 0){ |
121 |
|
|
$form->setVal("destinataire", $idxformulaire); |
122 |
|
|
$form->setVal("dossier", $idxformulaire); |
123 |
vpihour |
1127 |
$form->setVal("date_evenement", date('Y-m-d')); |
124 |
fraynaud |
20 |
} |
125 |
|
|
$form->setVal("bible_auto","bible_auto()"); |
126 |
|
|
$form->setVal("bible","bible()"); |
127 |
|
|
$form->setVal("bible2","bible2()"); |
128 |
|
|
} |
129 |
|
|
$this->retourformulaire=$retourformulaire; |
130 |
|
|
$this->idxformulaire=$idxformulaire; |
131 |
|
|
} |
132 |
|
|
|
133 |
vpihour |
1058 |
/*Affecte un type à certains champs*/ |
134 |
fraynaud |
20 |
function setType(&$form,$maj) { |
135 |
nhaye |
428 |
parent::setType($form,$maj); |
136 |
|
|
if ($maj < 2) { //ajouter et modifier |
137 |
|
|
$form->setType('destinataire', 'hidden'); |
138 |
|
|
$form->setType('lettretype', 'hiddenstatic'); |
139 |
|
|
$form->setType('complement', 'textarea'); |
140 |
|
|
$form->setType('complement2', 'textarea'); |
141 |
|
|
$form->setType('bible_auto', 'httpclick'); |
142 |
|
|
$form->setType('bible', 'httpclick'); |
143 |
|
|
$form->setType('bible2', 'httpclick'); |
144 |
|
|
$form->setType('dossier', 'hiddenstatic'); |
145 |
|
|
$form->setType('libelle', 'hiddenstatic'); |
146 |
|
|
if($maj==0){ // add |
147 |
|
|
$form->setType('instruction', 'hiddenstatic'); |
148 |
|
|
$form->setType('evenement', 'select'); |
149 |
vpihour |
1127 |
$form->setType('date_evenement', 'date2'); |
150 |
nhaye |
428 |
}else{ // modify |
151 |
|
|
$form->setType('instruction', 'hiddenstatic'); |
152 |
|
|
$form->setType('evenement', 'hiddenstatic'); |
153 |
vpihour |
1127 |
//$form->setType('date_evenement', 'hiddenstaticdate'); |
154 |
|
|
$form->setType('date_evenement', 'date2'); |
155 |
nhaye |
428 |
// necessaire pour calcul de date en modification |
156 |
|
|
$form->setType('delai', 'hiddenstatic'); |
157 |
|
|
} |
158 |
nhaye |
460 |
} elseif($maj==2){ |
159 |
|
|
$form->setType('dossier', 'hiddenstatic'); |
160 |
|
|
}else { |
161 |
|
|
$form->setType('destinataire', 'hidden'); |
162 |
|
|
$form->setType('dossier', 'static'); |
163 |
nhaye |
428 |
} |
164 |
fraynaud |
20 |
$form->setType('complement3', 'hidden'); |
165 |
nhaye |
428 |
$form->setType('bible_auto', 'hidden'); |
166 |
|
|
$form->setType('bible', 'hidden'); |
167 |
|
|
$form->setType('bible2', 'hidden'); |
168 |
fraynaud |
20 |
$form->setType('bible3', 'hidden'); |
169 |
|
|
$form->setType('complement4', 'hidden'); |
170 |
|
|
$form->setType('bible4', 'hidden'); |
171 |
|
|
$form->setType('complement5', 'hidden'); |
172 |
|
|
$form->setType('bible5', 'hidden'); |
173 |
|
|
$form->setType('complement6', 'hidden'); |
174 |
|
|
$form->setType('bible6', 'hidden'); |
175 |
|
|
$form->setType('complement7', 'hidden'); |
176 |
|
|
$form->setType('bible7', 'hidden'); |
177 |
|
|
$form->setType('complement8', 'hidden'); |
178 |
|
|
$form->setType('bible8', 'hidden'); |
179 |
|
|
$form->setType('complement9', 'hidden'); |
180 |
|
|
$form->setType('bible9', 'hidden'); |
181 |
|
|
$form->setType('complement10', 'hidden'); |
182 |
|
|
$form->setType('bible10', 'hidden'); |
183 |
|
|
$form->setType('complement11', 'hidden'); |
184 |
|
|
$form->setType('bible11', 'hidden'); |
185 |
|
|
$form->setType('complement12', 'hidden'); |
186 |
|
|
$form->setType('bible12', 'hidden'); |
187 |
|
|
$form->setType('complement13', 'hidden'); |
188 |
|
|
$form->setType('bible13', 'hidden'); |
189 |
|
|
$form->setType('complement14', 'hidden'); |
190 |
|
|
$form->setType('bible14', 'hidden'); |
191 |
|
|
$form->setType('complement15', 'hidden'); |
192 |
|
|
$form->setType('bible15', 'hidden'); |
193 |
|
|
$form->setType('delai', 'hidden'); |
194 |
|
|
$form->setType('etat', 'hidden'); |
195 |
|
|
$form->setType('accord_tacite', 'hidden'); |
196 |
|
|
$form->setType('action', 'hidden'); |
197 |
|
|
$form->setType('delai_notification', 'hidden'); |
198 |
vpihour |
489 |
$form->setType('avis_decision', 'hidden'); |
199 |
fraynaud |
20 |
$form->setType('archive_delai', 'hidden'); |
200 |
|
|
$form->setType('archive_etat', 'hidden'); |
201 |
|
|
$form->setType('archive_accord_tacite', 'hidden'); |
202 |
|
|
$form->setType('archive_avis', 'hidden'); |
203 |
|
|
$form->setType('archive_date_complet', 'hidden'); |
204 |
|
|
$form->setType('archive_date_rejet', 'hidden'); |
205 |
|
|
$form->setType('archive_date_limite', 'hidden'); |
206 |
|
|
$form->setType('archive_date_notification_delai', 'hidden'); |
207 |
|
|
$form->setType('archive_date_decision', 'hidden'); |
208 |
|
|
$form->setType('archive_date_validite', 'hidden'); |
209 |
|
|
$form->setType('archive_date_achevement', 'hidden'); |
210 |
|
|
$form->setType('archive_date_conformite', 'hidden'); |
211 |
nhaye |
428 |
$form->setType('archive_date_chantier', 'hidden'); |
212 |
fraynaud |
20 |
} |
213 |
fraynaud |
265 |
|
214 |
vpihour |
1058 |
/*Met des valeurs choisies dans certains select du formulaire*/ |
215 |
fraynaud |
20 |
function setSelect(&$form, $maj,&$db,$DEBUG) { |
216 |
atreal |
312 |
if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php")) |
217 |
|
|
include ("../sql/".$db->phptype."/".$this->table.".form.inc.php"); |
218 |
nhaye |
428 |
|
219 |
|
|
// *** evenement *** |
220 |
|
|
$contenu=array(); |
221 |
|
|
// etat du dossier |
222 |
|
|
$sql="select etat from ".DB_PREFIXE."dossier where dossier ='". |
223 |
|
|
$this->idxformulaire."'"; |
224 |
|
|
$etat_dossier = $db->getOne($sql); |
225 |
|
|
$nature_dossier= substr($this->idxformulaire,0,2); |
226 |
|
|
// recherche des evenement de transition |
227 |
|
|
$sql= $sql_transition." where transition.etat ='".$etat_dossier."' and (evenement.nature ='". |
228 |
|
|
$nature_dossier."' or (nature ='T' and nature !='CU')) order by evenement.action"; |
229 |
|
|
|
230 |
|
|
// *** attention en dur le CU |
231 |
vpihour |
1124 |
$this->addToLog("setSelect(): db->query(\"".$sql."\");", VERBOSE_MODE); |
232 |
nhaye |
428 |
|
233 |
|
|
$res = $db->query($sql); |
234 |
|
|
if (database::isError($res)) |
235 |
|
|
die($res->getMessage()); |
236 |
|
|
$contenu[0][0]=""; |
237 |
|
|
$contenu[1][0]=_('choisir')." "._('evenement'); |
238 |
|
|
$k=1; |
239 |
|
|
while ($row=& $res->fetchRow()){ |
240 |
|
|
if($maj==0){ // ajouter |
241 |
|
|
$contenu[0][$k]=$row[0]; |
242 |
|
|
$contenu[1][$k]=$row[1]; |
243 |
|
|
$k++; |
244 |
|
|
}else{ |
245 |
|
|
// select hiddenstatic |
246 |
|
|
$contenu[0][$k]=$row[0]; |
247 |
|
|
$contenu[1][$k]=$row[1]; |
248 |
|
|
$k++; |
249 |
fraynaud |
20 |
} |
250 |
|
|
} |
251 |
nhaye |
428 |
$form->setSelect("evenement",$contenu); |
252 |
|
|
// lien bible_auto [link] |
253 |
|
|
$contenu=array(); |
254 |
|
|
$contenu[0]=" automatique "; |
255 |
|
|
$form->setSelect("bible_auto",$contenu); |
256 |
|
|
// lien bible1 |
257 |
|
|
$contenu=array(); |
258 |
|
|
$contenu[0]=" Bible "; |
259 |
|
|
$form->setSelect("bible",$contenu); |
260 |
|
|
// lien bible2 |
261 |
|
|
$contenu=array(); |
262 |
|
|
$contenu[0]=" Bible "; |
263 |
|
|
$form->setSelect("bible2",$contenu); |
264 |
fraynaud |
20 |
} // function select |
265 |
|
|
|
266 |
|
|
function setGroupe(&$form,$maj){ |
267 |
|
|
$form->setGroupe('evenement','D'); |
268 |
|
|
$form->setGroupe('libelle','G'); |
269 |
vpihour |
1127 |
$form->setGroupe('date_evenement','G'); |
270 |
fraynaud |
20 |
$form->setGroupe('lettretype','F'); |
271 |
|
|
} |
272 |
|
|
|
273 |
|
|
function setRegroupe(&$form,$maj){ |
274 |
|
|
$form->setRegroupe('evenement','D',_('evenement'), "collapsible"); |
275 |
|
|
$form->setRegroupe('libelle','G',''); |
276 |
vpihour |
1127 |
$form->setRegroupe('date_evenement','G',''); |
277 |
fraynaud |
20 |
$form->setRegroupe('lettretype','F',''); |
278 |
fraynaud |
196 |
$form->setRegroupe('complement','D',_('complement'), "collapsible"); |
279 |
fraynaud |
20 |
$form->setRegroupe('bible_auto','G',''); |
280 |
|
|
$form->setRegroupe('bible','F',''); |
281 |
|
|
$form->setRegroupe('complement2','D',_('complement2'), "startClosed"); |
282 |
|
|
$form->setRegroupe('bible2','F',''); |
283 |
|
|
} |
284 |
|
|
|
285 |
vpihour |
1058 |
/*Change le libellé de certains champs*/ |
286 |
fraynaud |
20 |
function setLib(&$form,$maj) { |
287 |
|
|
parent :: setLib($form,$maj); |
288 |
|
|
$form->setLib('libelle',' '); |
289 |
|
|
$form->setLib('bible_auto',""); |
290 |
|
|
$form->setLib('bible',""); |
291 |
|
|
$form->setLib('bible2',""); |
292 |
|
|
$form->setLib('lettretype',"->"._(" courrier ")); |
293 |
vpihour |
1127 |
$form->setLib('date_evenement',_(" du ")); |
294 |
fraynaud |
20 |
} |
295 |
|
|
|
296 |
|
|
// ================================================================== |
297 |
vpihour |
1058 |
// trigger avant modification des données [trigger before modify data] |
298 |
fraynaud |
20 |
// ================================================================== |
299 |
|
|
function triggerajouter($id,&$db,$val,$DEBUG) { |
300 |
|
|
// mise a jour instruction avec evenement |
301 |
|
|
// [modify instruction with evenement] |
302 |
fraynaud |
242 |
$sql= "select * from ".DB_PREFIXE."evenement where evenement =".$this->valF['evenement']; |
303 |
vpihour |
1137 |
|
304 |
fraynaud |
20 |
$res = $db->query($sql); |
305 |
fraynaud |
129 |
if (database::isError($res)) die($res->getMessage()); |
306 |
vpihour |
1137 |
|
307 |
fraynaud |
20 |
if ($DEBUG == 1) |
308 |
|
|
echo " la requete ".$sql." est exécutée<br>"; |
309 |
vpihour |
1137 |
|
310 |
fraynaud |
20 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
311 |
vpihour |
1137 |
|
312 |
nhaye |
460 |
if(isset($row['action']) and !empty($row['action'])) { |
313 |
|
|
$this->valF['action']=$row['action']; |
314 |
|
|
} else { |
315 |
|
|
$this->valF['action']=NULL; |
316 |
|
|
} |
317 |
fraynaud |
20 |
$this->valF['delai']=$row['delai']; |
318 |
nhaye |
460 |
if(isset($row['etat']) and !empty($row['etat'])) { |
319 |
|
|
$this->valF['etat']=$row['etat']; |
320 |
|
|
} else { |
321 |
|
|
$this->valF['etat']=NULL; |
322 |
|
|
} |
323 |
fraynaud |
20 |
$this->valF['accord_tacite']=$row['accord_tacite']; |
324 |
|
|
$this->valF['delai_notification']=$row['delai_notification']; |
325 |
vpihour |
489 |
if(isset($row['avis_decision']) and !empty($row['avis_decision'])) { |
326 |
|
|
$this->valF['avis_decision']=$row['avis_decision']; |
327 |
nhaye |
460 |
} else { |
328 |
vpihour |
489 |
$this->valF['avis_decision']=NULL; |
329 |
nhaye |
460 |
} |
330 |
fraynaud |
20 |
if($row['lettretype']!="") |
331 |
|
|
$this->valF['lettretype']=$row['lettretype']; |
332 |
|
|
else |
333 |
|
|
$this->valF['lettretype']="standard"; |
334 |
vpihour |
1137 |
|
335 |
fraynaud |
20 |
} |
336 |
fraynaud |
242 |
$sql= "select * from ".DB_PREFIXE."dossier where dossier = '".$this->valF['dossier']."'"; |
337 |
fraynaud |
20 |
$res = $db->query($sql); |
338 |
|
|
if (database::isError($res)) |
339 |
|
|
die($res->getMessage()); |
340 |
|
|
if ($DEBUG == 1) |
341 |
|
|
echo " la requete ".$sql." est exécutée<br>"; |
342 |
|
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
343 |
|
|
// |
344 |
|
|
$this->archive_date_depot = $row['date_depot']; |
345 |
|
|
// archive en instruction (si suppression) |
346 |
|
|
$this->valF['archive_delai']=$row['delai']; |
347 |
|
|
$this->valF['archive_accord_tacite']=$row['accord_tacite']; |
348 |
|
|
$this->valF['archive_etat']=$row['etat']; |
349 |
vpihour |
489 |
$this->valF['archive_avis']=$row['avis_decision']; |
350 |
fraynaud |
20 |
// compatibilite pgsql |
351 |
|
|
if($row['date_complet']!='') |
352 |
|
|
$this->valF['archive_date_complet']=$row['date_complet']; |
353 |
|
|
if($row['date_rejet']!='') |
354 |
|
|
$this->valF['archive_date_rejet']= $row['date_rejet']; |
355 |
|
|
if($row['date_limite']!='') |
356 |
|
|
$this->valF['archive_date_limite']= $row['date_limite']; |
357 |
|
|
if($row['date_notification_delai']!='') |
358 |
|
|
$this->valF['archive_date_notification_delai']= $row['date_notification_delai']; |
359 |
|
|
if($row['date_decision']!='') |
360 |
|
|
$this->valF['archive_date_decision']= $row['date_decision']; |
361 |
|
|
if($row['date_validite']!='') |
362 |
|
|
$this->valF['archive_date_validite']= $row['date_validite']; |
363 |
|
|
if($row['date_achevement']!='') |
364 |
|
|
$this->valF['archive_date_achevement']= $row['date_achevement']; |
365 |
|
|
if($row['date_chantier']!='') |
366 |
|
|
$this->valF['archive_date_chantier']= $row['date_chantier']; |
367 |
|
|
if($row['date_conformite']!='') |
368 |
|
|
$this->valF['archive_date_conformite']= $row['date_conformite']; |
369 |
|
|
} |
370 |
|
|
} |
371 |
|
|
|
372 |
vpihour |
1137 |
// Test si une restriction est valide |
373 |
|
|
// return boolean |
374 |
|
|
function restrictionIsValid($restriction){ |
375 |
|
|
|
376 |
|
|
/* Met des espace avant et après les opérateurs puis transforme la chaine en |
377 |
|
|
* un tableau */ |
378 |
|
|
$tabRestriction = str_replace(">="," >= ", |
379 |
|
|
str_replace("<="," <= ", |
380 |
|
|
str_replace("-"," - ", |
381 |
|
|
str_replace("+"," + ",$restriction)))); |
382 |
|
|
$tabRestriction = explode( " ", $tabRestriction); |
383 |
|
|
|
384 |
|
|
//Variables de résultat |
385 |
|
|
$res = array(); |
386 |
|
|
$i = 0; |
387 |
|
|
$comp = ""; |
388 |
|
|
|
389 |
|
|
|
390 |
|
|
//Test que le tableau n'est pas vide |
391 |
|
|
if ( count($tabRestriction) > 0 ){ |
392 |
|
|
|
393 |
|
|
$res[0] = $this->getRestrictionValue($tabRestriction[0]); |
394 |
|
|
|
395 |
|
|
//Calcul des variables |
396 |
|
|
for ( $j = 1 ; $j < count($tabRestriction) ; $j += 2 ) { |
397 |
|
|
|
398 |
|
|
//Variable de comparaison |
399 |
|
|
if ( strcmp( ">=", $tabRestriction[$j] ) == 0 || |
400 |
|
|
strcmp( "<=", $tabRestriction[$j]) ==0 ){ |
401 |
|
|
|
402 |
|
|
$comp = $tabRestriction[$j]; |
403 |
|
|
$res[++$i] = $this->getRestrictionValue($tabRestriction[$j+1]); |
404 |
|
|
} |
405 |
|
|
// Fait l'addition |
406 |
|
|
elseif ( strcmp( "+", $tabRestriction[$j]) == 0 ){ |
407 |
|
|
|
408 |
|
|
$res[$i] = $this->moisdate( $res[$i], $this->getRestrictionValue($tabRestriction[$j+1]) ); |
409 |
|
|
} |
410 |
|
|
} |
411 |
|
|
} |
412 |
|
|
|
413 |
|
|
// Effectue le test |
414 |
|
|
if ( strcmp($comp, ">=") == 0 ){ |
415 |
|
|
|
416 |
|
|
if ( $res[0] >= $res[1] || $res[0] == "" ){ |
417 |
|
|
|
418 |
|
|
return true; |
419 |
|
|
} |
420 |
|
|
else { |
421 |
|
|
|
422 |
|
|
return false; |
423 |
|
|
} |
424 |
|
|
} |
425 |
|
|
elseif ( strcmp($comp, "<=") == 0 ){ |
426 |
|
|
|
427 |
|
|
if ( $res[0] <= $res[1] || $res[1] == "" ){ |
428 |
|
|
|
429 |
|
|
return true; |
430 |
|
|
} |
431 |
|
|
else { |
432 |
|
|
|
433 |
|
|
return false; |
434 |
|
|
} |
435 |
|
|
} |
436 |
|
|
|
437 |
|
|
return true; |
438 |
|
|
} |
439 |
|
|
|
440 |
|
|
//Retourne la valeur de valF si $restrictionValue n'est pas un chiffre, le chiffre sinon |
441 |
|
|
function getRestrictionValue($restrictionValue){ |
442 |
|
|
|
443 |
|
|
return ( is_numeric($restrictionValue) ) ? |
444 |
|
|
$restrictionValue : |
445 |
|
|
$this->valF[$restrictionValue]; |
446 |
|
|
} |
447 |
|
|
|
448 |
fraynaud |
123 |
function regle($regle){ |
449 |
|
|
$temp = explode ("+",$regle); |
450 |
atreal |
208 |
//echo '|'.$regle; |
451 |
fraynaud |
124 |
// cas rejet |
452 |
fraynaud |
129 |
if($regle=="null") // 1 dimension -> null |
453 |
fraynaud |
124 |
return null; |
454 |
|
|
if(sizeof($temp)==1) // 1 dimension |
455 |
|
|
if($temp[0]=="archive_date_depot") // initialisation avec le depot |
456 |
fraynaud |
123 |
return $this->$regle; |
457 |
fraynaud |
124 |
else // cas general |
458 |
fraynaud |
123 |
return $this->valF[$regle]; |
459 |
fraynaud |
124 |
if(sizeof($temp)==2){ // 2 dimensions |
460 |
|
|
if($temp[0]=="archive_date_depot") //initialisation avec le depot |
461 |
fraynaud |
123 |
if(is_numeric($temp[1])) |
462 |
|
|
return $this->moisdate($this->$temp[0], $temp[1]); |
463 |
|
|
else |
464 |
|
|
return $this->moisdate($this->$temp[0], $this->valF[$temp[1]]); |
465 |
fraynaud |
124 |
if($temp[0]=="archive_delai") // majoration de delai |
466 |
|
|
return $this->valF[$temp[0]]+$this->valF[$temp[1]]; |
467 |
|
|
// cas general 2 dimensions |
468 |
fraynaud |
123 |
if(is_numeric($temp[1])) |
469 |
|
|
return $this->moisdate($this->valF[$temp[0]], $temp[1]); |
470 |
|
|
else |
471 |
|
|
return $this->moisdate($this->valF[$temp[0]], $this->valF[$temp[1]]); |
472 |
|
|
} |
473 |
fraynaud |
124 |
if(sizeof($temp)==3){ // 3 dimensions |
474 |
|
|
// cas date de validite de sursis |
475 |
|
|
if(is_numeric($temp[1])) |
476 |
|
|
$temp1 = $this->moisdate($this->valF[$temp[0]], $temp[1]); |
477 |
|
|
else |
478 |
|
|
$temp1 = $this->moisdate($this->valF[$temp[0]], $this->valF[$temp[1]]); |
479 |
|
|
if(is_numeric($temp[2])) |
480 |
|
|
return $this->moisdate($temp1, $temp[2]); |
481 |
|
|
else |
482 |
|
|
return $this->moisdate($temp1, $this->valF[$temp[2]]); |
483 |
|
|
} |
484 |
fraynaud |
123 |
} |
485 |
|
|
|
486 |
|
|
|
487 |
|
|
|
488 |
fraynaud |
20 |
// ================================================================== |
489 |
|
|
// valeur dossier apres modification [values dossier after action] |
490 |
|
|
// ================================================================== |
491 |
|
|
function triggerajouterapres($id,&$db,$val,$DEBUG) { |
492 |
fraynaud |
47 |
// mise a null au lieu de "" / voir compatibilite mysql |
493 |
|
|
// voir parametrage CU en dur |
494 |
|
|
// voir parametrage des actions en dur |
495 |
fraynaud |
123 |
$param=1; |
496 |
fraynaud |
121 |
if($param==1){ |
497 |
fraynaud |
242 |
$sql="select * from ".DB_PREFIXE."action where action = '".$this->valF['action']."'"; |
498 |
fraynaud |
121 |
$res = $db->query($sql); |
499 |
|
|
if (database::isError($res)) |
500 |
|
|
die($res->getMessage()); |
501 |
|
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
502 |
|
|
if($row['regle_etat']!=''){ |
503 |
fraynaud |
123 |
$valF['etat']= $this->regle($row['regle_etat']); |
504 |
fraynaud |
121 |
} |
505 |
|
|
if($row['regle_delai']!=''){ |
506 |
fraynaud |
123 |
$valF['delai']= $this->regle($row['regle_delai']); |
507 |
fraynaud |
121 |
} |
508 |
|
|
if($row['regle_accord_tacite']!=''){ |
509 |
fraynaud |
123 |
$valF['accord_tacite']= $this->regle($row['regle_accord_tacite']); |
510 |
fraynaud |
121 |
} |
511 |
fraynaud |
124 |
if($row['regle_avis']!=''){ |
512 |
vpihour |
489 |
$valF['avis_decision']= $this->regle($row['regle_avis']); |
513 |
fraynaud |
124 |
} |
514 |
fraynaud |
121 |
if($row['regle_date_limite']!=''){ |
515 |
fraynaud |
123 |
$valF['date_limite']= $this->regle($row['regle_date_limite']); |
516 |
|
|
} |
517 |
|
|
if($row['regle_date_complet']!=''){ |
518 |
|
|
$valF['date_complet']= $this->regle($row['regle_date_complet']); |
519 |
|
|
} |
520 |
|
|
if($row['regle_date_notification_delai']!=''){ |
521 |
|
|
$valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']); |
522 |
|
|
} |
523 |
fraynaud |
124 |
if($row['regle_date_decision']!=''){ |
524 |
|
|
$valF['date_decision']= $this->regle($row['regle_date_decision']); |
525 |
|
|
} |
526 |
|
|
if($row['regle_date_rejet']!=''){ |
527 |
|
|
$valF['date_rejet']= $this->regle($row['regle_date_rejet']); |
528 |
|
|
} |
529 |
|
|
if($row['regle_date_validite']!=''){ |
530 |
|
|
$valF['date_validite']= $this->regle($row['regle_date_validite']); |
531 |
|
|
} |
532 |
|
|
if($row['regle_date_chantier']!=''){ |
533 |
|
|
$valF['date_chantier']= $this->regle($row['regle_date_chantier']); |
534 |
|
|
} |
535 |
|
|
if($row['regle_date_achevement']!=''){ |
536 |
|
|
$valF['date_achevement']= $this->regle($row['regle_date_achevement']); |
537 |
|
|
} |
538 |
|
|
if($row['regle_date_conformite']!=''){ |
539 |
|
|
$valF['date_conformite']= $this->regle($row['regle_date_conformite']); |
540 |
|
|
} |
541 |
fraynaud |
121 |
} |
542 |
|
|
}else{ |
543 |
fraynaud |
242 |
switch ($this->valF['action']) { |
544 |
|
|
case "initialisation" : |
545 |
|
|
$valF['delai']= $this->valF['delai']; |
546 |
|
|
$valF['etat']= $this->valF['etat']; |
547 |
|
|
$valF['accord_tacite']= $this->valF['accord_tacite']; |
548 |
|
|
// la date_complet est la date de depot |
549 |
|
|
$valF['date_complet']= $this->archive_date_depot; // **** |
550 |
|
|
$valF['date_limite'] = $this->moisdate($valF['date_complet'],$valF['delai']); |
551 |
|
|
$valF['date_notification_delai'] = $this->moisdate($valF['date_complet'],1); |
552 |
|
|
break; |
553 |
|
|
case "notification" : |
554 |
|
|
$valF['delai']= $this->valF['delai']; |
555 |
|
|
$valF['etat']= $this->valF['etat']; |
556 |
|
|
$valF['accord_tacite']= $this->valF['accord_tacite']; |
557 |
|
|
// la date_complet est celle precedemment saisie |
558 |
|
|
$valF['date_complet']=$this->valF['archive_date_complet']; |
559 |
|
|
$valF['date_limite'] = $this->moisdate($valF['date_complet'],$valF['delai']); |
560 |
|
|
$valF['date_notification_delai'] = $this->moisdate($valF['date_complet'],1); |
561 |
|
|
// la date du courrier ne doit pas etre depasse par rapport au delai de |
562 |
|
|
// notification [verify notification date] |
563 |
vpihour |
1127 |
if($this->valF['archive_date_notification_delai']<$this->valF['date_evenement']) |
564 |
fraynaud |
242 |
$this->msg=$this->msg."<br><img src='../img/erreur.gif'> "._("date_notification_delai")." ". |
565 |
vpihour |
1127 |
$this->valF['archive_date_notification_delai']." < "._('date_evenement'); |
566 |
fraynaud |
242 |
// |
567 |
|
|
break; |
568 |
|
|
case "retour" : |
569 |
|
|
$valF['delai']= $this->valF['delai']; |
570 |
|
|
$valF['etat']= $this->valF['etat']; |
571 |
|
|
$valF['accord_tacite']= $this->valF['accord_tacite']; |
572 |
|
|
// la date_complet est celle de l evenement |
573 |
vpihour |
1127 |
$valF['date_complet']= $this->valF['date_evenement']; |
574 |
fraynaud |
242 |
$valF['date_limite'] = $this->moisdate($valF['date_complet'],$valF['delai']); |
575 |
|
|
$valF['date_notification_delai'] = $this->moisdate($valF['date_complet'],1); |
576 |
|
|
break; |
577 |
|
|
case "rejet" : |
578 |
|
|
//$valF['delai']=0; // *** delai a garder pour etat dpc |
579 |
|
|
$valF['etat']= $this->valF['etat']; |
580 |
|
|
$valF['accord_tacite']= $this->valF['accord_tacite']; |
581 |
|
|
// la date rejet est initialisee |
582 |
vpihour |
1127 |
$valF['date_rejet']= $this->valF['date_evenement']; |
583 |
fraynaud |
242 |
// les dates de depart et fin d instruction sont annulées |
584 |
|
|
$valF['date_limite'] =null; |
585 |
|
|
$valF['date_notification_delai'] =null; |
586 |
|
|
$valF['date_complet']=null; |
587 |
|
|
break; |
588 |
|
|
case "majoration" : |
589 |
|
|
$valF['delai']= $this->valF['archive_delai']+$this->valF['delai']; |
590 |
|
|
$valF['etat']= $this->valF['etat']; |
591 |
|
|
$valF['accord_tacite']= $this->valF['accord_tacite']; |
592 |
|
|
$valF['date_complet']=$this->valF['archive_date_complet']; |
593 |
|
|
// majoration de la date limite |
594 |
|
|
$valF['date_limite'] = $this->moisdate($valF['date_complet'],$valF['delai']); |
595 |
|
|
$valF['date_notification_delai'] = $this->moisdate($valF['date_complet'],1); |
596 |
|
|
// la date du courrier ne doit pas etre depasse par rapport au delai de |
597 |
|
|
// notification |
598 |
vpihour |
1127 |
if($this->valF['archive_date_notification_delai']<$this->valF['date_evenement']) |
599 |
fraynaud |
242 |
$this->msg=$this->msg."<br><img src='../img/erreur.gif'>"._("date_notification_delai"). |
600 |
vpihour |
1127 |
$this->valF['archive_date_notification_delai']." < "._('date_evenement'); |
601 |
fraynaud |
242 |
break; |
602 |
|
|
case "acceptation" : |
603 |
|
|
$valF['etat']= $this->valF['etat']; |
604 |
vpihour |
1127 |
$valF['date_decision']= $this->valF['date_evenement']; |
605 |
vpihour |
489 |
$valF['avis_decision']= $this->valF['avis_decision']; |
606 |
fraynaud |
242 |
// date de validite = date de l evenement + delai |
607 |
vpihour |
1127 |
$valF['date_validite'] = $this->moisdate($this->valF['date_evenement'],$this->valF['delai']); |
608 |
fraynaud |
242 |
break; |
609 |
|
|
case "refus" : |
610 |
|
|
$valF['etat']= $this->valF['etat']; |
611 |
vpihour |
1127 |
$valF['date_decision']= $this->valF['date_evenement']; |
612 |
vpihour |
489 |
$valF['avis_decision']= $this->valF['avis_decision']; |
613 |
fraynaud |
242 |
break; |
614 |
|
|
case "prolongation" : |
615 |
|
|
$valF['date_validite'] = $this->moisdate($this->valF['archive_date_validite'],$this->valF['delai']); |
616 |
|
|
break; |
617 |
|
|
case "sursis" : |
618 |
vpihour |
1127 |
$valF['date_limite'] = $this->moisdate($this->valF['date_evenement'],$this->valF['delai']); |
619 |
fraynaud |
242 |
$valF['etat']= $this->valF['etat']; |
620 |
|
|
$valF['accord_tacite']= $this->valF['accord_tacite']; |
621 |
vpihour |
489 |
$valF['avis_decision']= $this->valF['avis_decision']; |
622 |
vpihour |
1127 |
$valF['date_decision']= $this->valF['date_evenement']; |
623 |
fraynaud |
242 |
$temp = $valF['date_limite']; |
624 |
|
|
$valF['date_validite']= $this->moisdate($temp,2); |
625 |
|
|
break; |
626 |
|
|
case "execution" : |
627 |
|
|
$valF['etat']= $this->valF['etat']; |
628 |
vpihour |
1127 |
$valF['date_chantier'] = $this->valF['date_evenement']; |
629 |
fraynaud |
242 |
//echo $this->msg=$this->msg.$valF['date_chantier'].""; |
630 |
|
|
break; |
631 |
|
|
case "achevement" : |
632 |
|
|
$valF['etat']= $this->valF['etat']; |
633 |
vpihour |
1127 |
$valF['date_achevement'] = $this->valF['date_evenement']; |
634 |
fraynaud |
242 |
break; |
635 |
|
|
case "archivage" : |
636 |
|
|
$valF['etat']= $this->valF['etat']; |
637 |
vpihour |
1127 |
$valF['date_conformite'] = $this->valF['date_evenement']; |
638 |
fraynaud |
242 |
break; |
639 |
|
|
|
640 |
|
|
default: |
641 |
|
|
if ($this->valF['etat']!="") |
642 |
|
|
$valF['etat']= $this->valF['etat']; |
643 |
|
|
}// end switch |
644 |
fraynaud |
121 |
} // end param |
645 |
fraynaud |
20 |
if($valF!=""){ |
646 |
|
|
$cle= " dossier = '".$this->valF['dossier']."'"; |
647 |
fraynaud |
242 |
$res1= $db->autoExecute(DB_PREFIXE.'dossier',$valF,DB_AUTOQUERY_UPDATE,$cle); |
648 |
fraynaud |
20 |
if (database::isError($res1)) |
649 |
|
|
die($res->getMessage()); |
650 |
|
|
if ($DEBUG == 1) |
651 |
|
|
echo "La requête de mise à jour est effectuée.<br>"; |
652 |
|
|
$this->msg=$this->msg."<br>"._('enregistrement')." ". |
653 |
|
|
$this->valF['dossier']." "._('table')." dossier [". |
654 |
|
|
$db->affectedRows()." "._('enregistrement'). |
655 |
|
|
" "._('mis_a_jour')."]" ; |
656 |
|
|
} |
657 |
fmichon |
1005 |
// verification si envoi vers ERP est active |
658 |
|
|
if ($this->f->getParameter('option_erp') != "") { |
659 |
|
|
// la nature du dossier |
660 |
|
|
$nature_dossier = substr($this->idxformulaire,0,2); |
661 |
|
|
$dossier_erp = $this->getFromDB("SELECT erp FROM ".DB_PREFIXE."dossier WHERE dossier = '" . |
662 |
|
|
$this->valF['dossier'] . "'"); |
663 |
|
|
$evenement_libelle = $this->getFromDB( |
664 |
|
|
"SELECT libelle FROM ".DB_PREFIXE."evenement WHERE evenement = '" . |
665 |
|
|
$this->valF['evenement'] . "'"); |
666 |
|
|
if ($dossier_erp == 't') { |
667 |
|
|
// envoi du message en cas d'un PC qui est ERP et sur lequel un evenement |
668 |
|
|
// d'acceptation etait fait |
669 |
|
|
if ($nature_dossier == |
670 |
|
|
$this->f->getParameter('erp_evenement_accepter_dossier_PC') |
671 |
|
|
&& $this->valF['evenement'] == |
672 |
|
|
$this->f->getParameter('erp_evenement_accepter_sans_reserve')) { |
673 |
|
|
$msgenque = new MessageEnqueuer(); |
674 |
|
|
$msgenque->setDossierInstructionIdentifier($this->valF['dossier']); |
675 |
|
|
$msgenque->setDecision($evenement_libelle); |
676 |
|
|
$msgenque->enqueueMessage($msgenque::$ERP_ARRETE_PC_EFFECTUE); |
677 |
|
|
} |
678 |
|
|
if ($this->valF['evenement'] == |
679 |
|
|
$this->f->getParameter('erp_evenement_refuser_dossier')) { |
680 |
|
|
$msgenque = new MessageEnqueuer(); |
681 |
|
|
$msgenque->setDossierInstructionIdentifier($this->valF['dossier']); |
682 |
|
|
$msgenque->enqueueMessage($msgenque::$ERP_DECISION_CONFORMITE_EFFECTUE); |
683 |
|
|
} |
684 |
mlimic |
936 |
} |
685 |
fmichon |
1005 |
} // fin de if ($this->f->getParameter('option_erp') != "") |
686 |
fraynaud |
20 |
} |
687 |
mlimic |
910 |
|
688 |
|
|
|
689 |
|
|
/** |
690 |
|
|
* Fait une requette sql pour extraire la valeur d'un champ, et retourne |
691 |
|
|
* cette valeur |
692 |
|
|
* @param string $sql La requete sql a executer |
693 |
|
|
* @return La valeur du champs cherche, sinon NULL. En cas d'erreur de la BD |
694 |
|
|
* l'execution s'arrete. |
695 |
|
|
*/ |
696 |
|
|
function getFromDB($sql) { |
697 |
fmichon |
926 |
//$sql = "SELECT libelle FROM ".DB_PREFIXE."dossier WHERE dossier = '" . $dossier . "'"; |
698 |
mlimic |
910 |
$res = $this->db->limitquery($sql, 0, 1); |
699 |
|
|
$this->addToLog("getDossierERPSpecification(): db->limitquery(\"". |
700 |
|
|
str_replace(",",", ",$sql)."\", 0, 1);", VERBOSE_MODE); |
701 |
|
|
// Si une erreur survient on die |
702 |
|
|
if (database::isError($res, true)) { |
703 |
|
|
// Appel de la methode de recuperation des erreurs |
704 |
|
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), 'instruction'); |
705 |
|
|
} |
706 |
|
|
// retourne la nature du dossier |
707 |
|
|
while ($row =& $res->fetchRow()) { |
708 |
|
|
return $row[0]; |
709 |
|
|
} |
710 |
|
|
// la nature n'etait pas trouve, ce qui ne devrait pas se passer |
711 |
|
|
return NULL; |
712 |
fraynaud |
129 |
|
713 |
mlimic |
910 |
} |
714 |
|
|
|
715 |
|
|
|
716 |
fraynaud |
129 |
function triggermodifierapres($id,&$db,$val,$DEBUG) { |
717 |
|
|
/* |
718 |
vpihour |
1058 |
* cette fonction a pour objet de permettre de modifier la date courrier |
719 |
fraynaud |
129 |
*/ |
720 |
|
|
$valF=array(); |
721 |
fraynaud |
242 |
$sql= "select action from ".DB_PREFIXE."evenement where evenement =".$this->valF['evenement']; |
722 |
fraynaud |
129 |
$action = $db->getOne($sql); |
723 |
|
|
if (database::isError($action)) die($action->getMessage().$sql); |
724 |
fraynaud |
242 |
$sql="select * from ".DB_PREFIXE."action where action = '".$action."'"; |
725 |
fraynaud |
129 |
$res = $db->query($sql); |
726 |
|
|
if (database::isError($res)) die($res->getMessage().$sql); |
727 |
|
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
728 |
|
|
// application des regles sur le courrier + delai |
729 |
vpihour |
1127 |
if(preg_match("/date_evenement/",$row['regle_date_limite'])){ |
730 |
fraynaud |
129 |
$valF['date_limite']= $this->regle($row['regle_date_limite']); |
731 |
|
|
} |
732 |
vpihour |
1127 |
if(preg_match("/date_evenement/",$row['regle_date_complet'])){ |
733 |
fraynaud |
129 |
$valF['date_complet']= $this->regle($row['regle_date_complet']); |
734 |
|
|
} |
735 |
vpihour |
1127 |
if(preg_match("/date_evenement/",$row['regle_date_notification_delai'])){ |
736 |
fraynaud |
129 |
$valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']); |
737 |
|
|
} |
738 |
vpihour |
1127 |
if(preg_match("/date_evenement/",$row['regle_date_decision'])){ |
739 |
fraynaud |
129 |
$valF['date_decision']= $this->regle($row['regle_date_decision']); |
740 |
|
|
} |
741 |
vpihour |
1127 |
if(preg_match("/date_evenement/",$row['regle_date_rejet'])){ |
742 |
fraynaud |
129 |
$valF['date_rejet']= $this->regle($row['regle_date_rejet']); |
743 |
|
|
} |
744 |
vpihour |
1127 |
if(preg_match("/date_evenement/",$row['regle_date_validite'])){ |
745 |
fraynaud |
129 |
$valF['date_validite']= $this->regle($row['regle_date_validite']); |
746 |
|
|
} |
747 |
vpihour |
1127 |
if(preg_match("/date_evenement/",$row['regle_date_chantier'])){ |
748 |
fraynaud |
129 |
$valF['date_chantier']= $this->regle($row['regle_date_chantier']); |
749 |
|
|
} |
750 |
vpihour |
1127 |
if(preg_match("/date_evenement/",$row['regle_date_achevement'])){ |
751 |
fraynaud |
129 |
$valF['date_achevement']= $this->regle($row['regle_date_achevement']); |
752 |
|
|
} |
753 |
vpihour |
1127 |
if(preg_match("/date_evenement/",$row['regle_date_conformite'])){ |
754 |
fraynaud |
129 |
$valF['date_conformite']= $this->regle($row['regle_date_conformite']); |
755 |
|
|
} |
756 |
|
|
} // while |
757 |
|
|
if($valF!=array()){ |
758 |
|
|
$cle= " dossier = '".$this->valF['dossier']."'"; |
759 |
fraynaud |
242 |
$res1= $db->autoExecute(DB_PREFIXE.'dossier',$valF,DB_AUTOQUERY_UPDATE,$cle); |
760 |
fraynaud |
129 |
if (database::isError($res1)) |
761 |
|
|
die($res->getMessage()); |
762 |
|
|
if ($DEBUG == 1) |
763 |
|
|
echo "La requête de mise à jour est effectuée.<br>"; |
764 |
|
|
$this->msg=$this->msg."<br>"._('enregistrement')." ". |
765 |
|
|
$this->valF['dossier']." "._('table')." dossier [". |
766 |
|
|
$db->affectedRows()." "._('enregistrement'). |
767 |
|
|
" "._('mis_a_jour')."]" ; |
768 |
|
|
} |
769 |
|
|
} |
770 |
|
|
|
771 |
|
|
|
772 |
fraynaud |
20 |
|
773 |
|
|
// trigger before delete |
774 |
|
|
function triggersupprimer($id,&$db,$val,$DEBUG) { |
775 |
|
|
// archive en instruction (si suppression) [archive if delete instruction] |
776 |
|
|
$valF['delai']=$val['archive_delai']; |
777 |
|
|
$valF['accord_tacite']=$val['archive_accord_tacite']; |
778 |
|
|
$valF['etat']=$val['archive_etat']; |
779 |
fraynaud |
80 |
if($val['archive_avis']=='') |
780 |
vpihour |
489 |
$valF['avis_decision']= null; |
781 |
fraynaud |
80 |
else |
782 |
vpihour |
489 |
$valF['avis_decision']=$val['archive_avis']; |
783 |
fraynaud |
20 |
// if= compatibilite pgsql |
784 |
|
|
if($val['archive_date_complet']!='') |
785 |
|
|
$valF['date_complet']=$val['archive_date_complet']; |
786 |
|
|
if($val['archive_date_rejet']!='') |
787 |
|
|
$valF['date_rejet']= $val['archive_date_rejet']; |
788 |
|
|
if($val['archive_date_limite']!='') |
789 |
|
|
$valF['date_limite']= $val['archive_date_limite']; |
790 |
|
|
if($val['archive_date_notification_delai']!='') |
791 |
|
|
$valF['date_notification_delai']= $val['archive_date_notification_delai']; |
792 |
|
|
if($val['archive_date_decision']!='') |
793 |
|
|
$valF['date_decision']= $val['archive_date_decision']; |
794 |
|
|
if($val['archive_date_validite']!='') |
795 |
|
|
$valF['date_validite']= $val['archive_date_validite']; |
796 |
|
|
if($val['archive_date_achevement']!='') |
797 |
|
|
$valF['date_achevement']= $val['archive_date_achevement']; |
798 |
|
|
if($val['archive_date_chantier']!='') |
799 |
|
|
$valF['date_chantier']= $val['archive_date_chantier']; |
800 |
|
|
if($val['archive_date_conformite']!='') |
801 |
|
|
$valF['date_conformite']= $val['archive_date_conformite']; |
802 |
fraynaud |
80 |
|
803 |
fraynaud |
20 |
$cle= " dossier = '".$val['dossier']."'"; |
804 |
fraynaud |
242 |
$res= $db->autoExecute(DB_PREFIXE.'dossier',$valF,DB_AUTOQUERY_UPDATE,$cle); |
805 |
fraynaud |
20 |
if (database::isError($res)) |
806 |
|
|
die($res->getMessage()); |
807 |
|
|
else{ |
808 |
|
|
if ($DEBUG == 1) |
809 |
|
|
echo "La requête de mise à jour est effectuée.<br>"; |
810 |
|
|
} |
811 |
|
|
} |
812 |
|
|
// ============================================= |
813 |
|
|
// calcul de date avec ajout de mois (delais) |
814 |
|
|
// [add months (delay) and calculation final date] |
815 |
|
|
// LIMITE DE LA FONCTION si delai >24 MOIS |
816 |
|
|
// [limit : delay < 24 month] |
817 |
|
|
// ============================================= |
818 |
|
|
function moisdate($date,$delaimois) { |
819 |
|
|
$temp = explode("-" , $date); |
820 |
|
|
$jour = (int) $temp[2]; |
821 |
|
|
$mois = (int) $temp[1]; |
822 |
|
|
$annee = (int) $temp[0]; |
823 |
|
|
// calcul si delai superieur à 12 (limite 24) [delay > 24 month] |
824 |
|
|
if($delaimois>=12){ |
825 |
|
|
$delaimois=$delaimois-12; |
826 |
|
|
$annee=$annee+1; |
827 |
|
|
} |
828 |
|
|
if($delaimois>=12){ |
829 |
|
|
$delaimois=$delaimois-12; |
830 |
|
|
$annee=$annee+1; |
831 |
|
|
} |
832 |
|
|
// mois |
833 |
|
|
$mois=$mois+$delaimois; |
834 |
|
|
// calcul mois annee [calculation number of years if > 12 month] |
835 |
|
|
// nb de mois > à 12 |
836 |
|
|
if ($mois>12){ |
837 |
|
|
$mois=$mois-12; |
838 |
|
|
$annee=$annee+1; |
839 |
|
|
} |
840 |
|
|
// Calcul du nombre de jours dans le mois sélectionné [calculation number of days] |
841 |
|
|
switch($mois) { |
842 |
|
|
case "2": |
843 |
|
|
if ($annee % 4 == 0 && $annee % 100 != 0 || $annee % 400 == 0) |
844 |
|
|
$jourmax = 29; |
845 |
|
|
else |
846 |
|
|
$jourmax = 28; |
847 |
|
|
break; |
848 |
|
|
case "4": |
849 |
|
|
case "6": |
850 |
|
|
case "9": |
851 |
|
|
case "11": |
852 |
|
|
$jourmax = 30; |
853 |
|
|
break; |
854 |
|
|
default: |
855 |
|
|
$jourmax = 31; |
856 |
|
|
} |
857 |
|
|
if ($jour > $jourmax) |
858 |
|
|
$jour = $jourmax; |
859 |
|
|
//$dateretour=$annee."-".$mois."-".$jour; |
860 |
|
|
return $annee."-".$mois."-".$jour ; |
861 |
|
|
} |
862 |
|
|
|
863 |
vpihour |
1137 |
// Vérifie la restriction sur l'événement |
864 |
|
|
function verifier($val = array(), &$db, $DEBUG){ |
865 |
|
|
|
866 |
|
|
//Récupère la restriction |
867 |
|
|
$sql= "SELECT |
868 |
|
|
restriction |
869 |
|
|
FROM |
870 |
|
|
".DB_PREFIXE."evenement |
871 |
|
|
WHERE |
872 |
|
|
evenement =".$this->valF['evenement']; |
873 |
|
|
|
874 |
|
|
$res = $db->query($sql); |
875 |
|
|
$this->f->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE); |
876 |
|
|
$this->f->isDatabaseError(); |
877 |
|
|
|
878 |
|
|
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
879 |
|
|
|
880 |
|
|
//Test qu'une restriction est présente |
881 |
|
|
if ( isset($row['restriction']) && $row['restriction'] != "" ){ |
882 |
|
|
|
883 |
|
|
//Test si la restriction est valide |
884 |
|
|
if ( !$this->restrictionIsValid($row['restriction']) ){ |
885 |
|
|
|
886 |
|
|
$this->correct=false; |
887 |
|
|
$this->addToMessage(_("Restriction non valide")); |
888 |
|
|
} |
889 |
|
|
else { |
890 |
|
|
|
891 |
|
|
$this->correct = true; |
892 |
|
|
} |
893 |
|
|
} |
894 |
|
|
} |
895 |
|
|
|
896 |
fraynaud |
3 |
}// fin classe |
897 |
atreal |
208 |
?> |