1 |
<?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 $ |
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 |
require_once ("../gen/obj/instruction.class.php"); |
21 |
|
22 |
class instruction extends instruction_gen { |
23 |
|
24 |
var $archive_date_depot; // specific |
25 |
var $retourformulaire; // specific |
26 |
var $idxformulaire; // specific |
27 |
|
28 |
function instruction($id,&$db,$debug) { |
29 |
$this->constructeur($id,$db,$debug); |
30 |
}// fin constructeur |
31 |
|
32 |
function setvalF($val){ |
33 |
$this->valF['instruction'] = $val['instruction']; |
34 |
$this->valF['destinataire'] = $val['destinataire']; |
35 |
$this->valF['lettretype'] = $val['lettretype']; |
36 |
$this->valF['dossier'] = $val['dossier']; |
37 |
if($val['datecourrier']!="") |
38 |
$this->valF['datecourrier'] = $this->dateDB($val['datecourrier']); |
39 |
$this->valF['complement'] = $val['complement']; |
40 |
$this->valF['complement2'] = $val['complement2']; |
41 |
$this->valF['evenement'] = $val['evenement']; |
42 |
$this->valF['delai'] = $val['delai']; // necessaire pour maj datecourrier |
43 |
} |
44 |
|
45 |
|
46 |
function cleSecondaire($id,&$db,$val,$DEBUG) { |
47 |
parent::cleSecondaire($id,$db,$val,$DEBUG); |
48 |
// controle suppression cle secondaire [secondary key delete control] |
49 |
// ------------------------------------------------------------------------------------ |
50 |
// specifique detruire que le dernier [specific instruction : delete the last event ] |
51 |
// ------------------------------------------------------------------------------------ |
52 |
$dernierevenement=''; |
53 |
$sql="select max(instruction) from ".DB_PREFIXE."instruction where dossier ='". |
54 |
$this->idxformulaire."'"; |
55 |
$dernierevenement = $db->getOne($sql); |
56 |
if($dernierevenement==$id){ |
57 |
$this->correct=true; |
58 |
$this->msg="<br>"._('destruction_chronologique')." ok <br>"; |
59 |
}else{ |
60 |
$this->msg="<br>"._('destruction_evenement')." : ".$dernierevenement. |
61 |
"<br>"._('destruction_chronologique'); |
62 |
$this->correct=false; |
63 |
} |
64 |
} |
65 |
|
66 |
function verifier($val,&$db,$DEBUG){ |
67 |
$this->correct=True; |
68 |
$imgv=""; |
69 |
$f=" ! "; |
70 |
$imgv="<img src='../app/img/punaise.png' style='vertical-align:middle' hspace='2' border='0'>"; |
71 |
// obligatoire |
72 |
if ($this->valF['destinataire']==""){ |
73 |
$this->correct=false; |
74 |
$this->msg= $this->msg.$imgv." "._('instruction')." ". |
75 |
_('obligatoire').$f; |
76 |
} |
77 |
if ($val['datecourrier']==""){ |
78 |
$this->correct=false; |
79 |
$this->msg= $this->msg.$imgv." "._('datecourrier')." ". |
80 |
_('obligatoire').$f; |
81 |
} |
82 |
if ($val['evenement']==""){ |
83 |
$this->correct=false; |
84 |
$this->msg= $this->msg.$imgv." "._('evenement')." ". |
85 |
_('obligatoire').$f; |
86 |
} |
87 |
}//verifier |
88 |
|
89 |
function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire){ |
90 |
if ($validation==0) { |
91 |
if ($maj == 0){ |
92 |
$form->setVal("destinataire", $idxformulaire); |
93 |
$form->setVal("dossier", $idxformulaire); |
94 |
$form->setVal("datecourrier", date('Y-m-d')); |
95 |
} |
96 |
$form->setVal("bible_auto","bible_auto()"); |
97 |
$form->setVal("bible","bible()"); |
98 |
$form->setVal("bible2","bible2()"); |
99 |
} |
100 |
$this->retourformulaire=$retourformulaire; |
101 |
$this->idxformulaire=$idxformulaire; |
102 |
} |
103 |
|
104 |
function setType(&$form,$maj) { |
105 |
if ($maj < 2) { //ajouter et modifier |
106 |
$form->setType('destinataire', 'hidden'); |
107 |
$form->setType('lettretype', 'hiddenstatic'); |
108 |
$form->setType('complement', 'textarea'); |
109 |
$form->setType('complement2', 'textarea'); |
110 |
$form->setType('complement3', 'hidden'); |
111 |
$form->setType('bible3', 'hidden'); |
112 |
$form->setType('complement4', 'hidden'); |
113 |
$form->setType('bible4', 'hidden'); |
114 |
$form->setType('complement5', 'hidden'); |
115 |
$form->setType('bible5', 'hidden'); |
116 |
$form->setType('complement6', 'hidden'); |
117 |
$form->setType('bible6', 'hidden'); |
118 |
$form->setType('complement7', 'hidden'); |
119 |
$form->setType('bible7', 'hidden'); |
120 |
$form->setType('complement8', 'hidden'); |
121 |
$form->setType('bible8', 'hidden'); |
122 |
$form->setType('complement9', 'hidden'); |
123 |
$form->setType('bible9', 'hidden'); |
124 |
$form->setType('complement10', 'hidden'); |
125 |
$form->setType('bible10', 'hidden'); |
126 |
$form->setType('complement11', 'hidden'); |
127 |
$form->setType('bible11', 'hidden'); |
128 |
$form->setType('complement12', 'hidden'); |
129 |
$form->setType('bible12', 'hidden'); |
130 |
$form->setType('complement13', 'hidden'); |
131 |
$form->setType('bible13', 'hidden'); |
132 |
$form->setType('complement14', 'hidden'); |
133 |
$form->setType('bible14', 'hidden'); |
134 |
$form->setType('complement15', 'hidden'); |
135 |
$form->setType('bible15', 'hidden'); |
136 |
$form->setType('bible_auto', 'httpclick'); |
137 |
$form->setType('bible', 'httpclick'); |
138 |
$form->setType('bible2', 'httpclick'); |
139 |
$form->setType('dossier', 'hiddenstatic'); |
140 |
$form->setType('delai', 'hidden'); |
141 |
$form->setType('etat', 'hidden'); |
142 |
$form->setType('accord_tacite', 'hidden'); |
143 |
$form->setType('action', 'hidden'); |
144 |
$form->setType('delai_notification', 'hidden'); |
145 |
$form->setType('avis', 'hidden'); |
146 |
$form->setType('archive_delai', 'hidden'); |
147 |
$form->setType('archive_etat', 'hidden'); |
148 |
$form->setType('archive_accord_tacite', 'hidden'); |
149 |
$form->setType('archive_avis', 'hidden'); |
150 |
$form->setType('archive_date_complet', 'hidden'); |
151 |
$form->setType('archive_date_rejet', 'hidden'); |
152 |
$form->setType('archive_date_limite', 'hidden'); |
153 |
$form->setType('archive_date_notification_delai', 'hidden'); |
154 |
$form->setType('archive_date_decision', 'hidden'); |
155 |
$form->setType('archive_date_validite', 'hidden'); |
156 |
$form->setType('archive_date_achevement', 'hidden'); |
157 |
$form->setType('archive_date_conformite', 'hidden'); |
158 |
$form->setType('archive_date_chantier', 'hidden'); |
159 |
$form->setType('libelle', 'hiddenstatic'); |
160 |
if($maj==0){ // add |
161 |
$form->setType('instruction', 'hiddenstatic'); |
162 |
$form->setType('evenement', 'select'); |
163 |
$form->setType('datecourrier', 'date2'); |
164 |
}else{ // modify |
165 |
$form->setType('instruction', 'hiddenstatic'); |
166 |
$form->setType('evenement', 'hiddenstatic'); |
167 |
//$form->setType('datecourrier', 'hiddenstaticdate'); |
168 |
$form->setType('datecourrier', 'date2'); |
169 |
// necessaire pour calcul de date en modification |
170 |
$form->setType('delai', 'hiddenstatic'); |
171 |
} |
172 |
}else{ // supprimer [delete] |
173 |
$form->setType('instruction', 'hiddenstatic'); |
174 |
$form->setType('dossier', 'hiddenstatic'); |
175 |
$form->setType('archive_delai', 'hiddenstatic'); |
176 |
$form->setType('archive_etat', 'hiddenstatic'); |
177 |
$form->setType('archive_accord_tacite', 'hiddenstatic'); |
178 |
$form->setType('archive_avis', 'hiddenstatic'); |
179 |
$form->setType('archive_date_complet', 'hiddenstatic'); |
180 |
$form->setType('archive_date_rejet', 'hiddenstatic'); |
181 |
$form->setType('archive_date_limite', 'hiddenstatic'); |
182 |
$form->setType('archive_date_notification_delai', 'hiddenstatic'); |
183 |
$form->setType('archive_date_decision', 'hiddenstatic'); |
184 |
$form->setType('archive_date_validite', 'hiddenstatic'); |
185 |
$form->setType('archive_date_achevement', 'hiddenstatic'); |
186 |
} |
187 |
} |
188 |
|
189 |
function setTaille(&$form,$maj){ |
190 |
$form->setTaille('complement', 120); |
191 |
$form->setTaille('complement2', 120); |
192 |
$form->setTaille('datecourrier', 12); |
193 |
} |
194 |
|
195 |
function setMax(&$form,$maj){ |
196 |
$form->setMax('complement',12 ); |
197 |
$form->setMax('complement2',12 ); |
198 |
} |
199 |
|
200 |
//function setSelect(&$form, $maj,&$db,$DEBUG,$idxformulaire) { |
201 |
function setSelect(&$form, $maj,&$db,$DEBUG) { |
202 |
if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc")) |
203 |
include ("../sql/".$db->phptype."/".$this->table.".form.inc"); |
204 |
if($maj<2){ |
205 |
// *** evenement *** |
206 |
$contenu=array(); |
207 |
// etat du dossier |
208 |
$sql="select etat from ".DB_PREFIXE."dossier where dossier ='". |
209 |
$this->idxformulaire."'"; |
210 |
$etat_dossier = $db->getOne($sql); |
211 |
$nature_dossier= substr($this->idxformulaire,0,2); |
212 |
// recherche des evenement de transition |
213 |
$sql= $sql_transition." where transition.etat ='".$etat_dossier."' and (evenement.nature ='". |
214 |
$nature_dossier."' or (nature ='T' and nature !='CU')) order by evenement.action"; |
215 |
// *** attention en dur le CU |
216 |
|
217 |
|
218 |
$res = $db->query($sql); |
219 |
if (database::isError($res)) |
220 |
die($res->getMessage()); |
221 |
$contenu[0][0]=""; |
222 |
$contenu[1][0]=_('choisir')." "._('evenement'); |
223 |
$k=1; |
224 |
while ($row=& $res->fetchRow()){ |
225 |
if($maj==0){ // ajouter |
226 |
$contenu[0][$k]=$row[0]; |
227 |
$contenu[1][$k]=$row[1]; |
228 |
$k++; |
229 |
}else{ |
230 |
// select hiddenstatic |
231 |
$contenu[0][$k]=$row[0]; |
232 |
$contenu[1][$k]=$row[1]; |
233 |
$k++; |
234 |
} |
235 |
} |
236 |
$form->setSelect("evenement",$contenu); |
237 |
// lien bible_auto [link] |
238 |
$contenu=array(); |
239 |
$contenu[0]=" automatique "; |
240 |
$form->setSelect("bible_auto",$contenu); |
241 |
// lien bible1 |
242 |
$contenu=array(); |
243 |
$contenu[0]=" Bible "; |
244 |
$form->setSelect("bible",$contenu); |
245 |
// lien bible2 |
246 |
$contenu=array(); |
247 |
$contenu[0]=" Bible "; |
248 |
$form->setSelect("bible2",$contenu); |
249 |
} |
250 |
} // function select |
251 |
|
252 |
function setGroupe(&$form,$maj){ |
253 |
$form->setGroupe('evenement','D'); |
254 |
$form->setGroupe('libelle','G'); |
255 |
$form->setGroupe('datecourrier','G'); |
256 |
$form->setGroupe('lettretype','F'); |
257 |
} |
258 |
|
259 |
function setRegroupe(&$form,$maj){ |
260 |
$form->setRegroupe('evenement','D',_('evenement'), "collapsible"); |
261 |
$form->setRegroupe('libelle','G',''); |
262 |
$form->setRegroupe('datecourrier','G',''); |
263 |
$form->setRegroupe('lettretype','F',''); |
264 |
$form->setRegroupe('complement','D',_('complement'), "collapsible"); |
265 |
$form->setRegroupe('bible_auto','G',''); |
266 |
$form->setRegroupe('bible','F',''); |
267 |
$form->setRegroupe('complement2','D',_('complement2'), "startClosed"); |
268 |
$form->setRegroupe('bible2','F',''); |
269 |
} |
270 |
|
271 |
function setLib(&$form,$maj) { |
272 |
parent :: setLib($form,$maj); |
273 |
$form->setLib('libelle',' '); |
274 |
$form->setLib('bible_auto',""); |
275 |
$form->setLib('bible',""); |
276 |
$form->setLib('bible2',""); |
277 |
$form->setLib('lettretype',"->"._(" courrier ")); |
278 |
$form->setLib('datecourrier',_(" du ")); |
279 |
} |
280 |
|
281 |
function setOnchange(&$form,$maj){ |
282 |
$form->setOnchange("datecourrier","fdate(this)"); |
283 |
} |
284 |
|
285 |
// ================================================================== |
286 |
// trigger avant modification données [trigger before modify data] |
287 |
// ================================================================== |
288 |
function triggerajouter($id,&$db,$val,$DEBUG) { |
289 |
// mise a jour instruction avec evenement |
290 |
// [modify instruction with evenement] |
291 |
$sql= "select * from ".DB_PREFIXE."evenement where evenement =".$this->valF['evenement']; |
292 |
$res = $db->query($sql); |
293 |
if (database::isError($res)) die($res->getMessage()); |
294 |
if ($DEBUG == 1) |
295 |
echo " la requete ".$sql." est exécutée<br>"; |
296 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
297 |
$this->valF['action']=$row['action']; |
298 |
$this->valF['delai']=$row['delai']; |
299 |
$this->valF['etat']=$row['etat']; |
300 |
$this->valF['accord_tacite']=$row['accord_tacite']; |
301 |
$this->valF['delai_notification']=$row['delai_notification']; |
302 |
$this->valF['avis']=$row['avis']; |
303 |
if($row['lettretype']!="") |
304 |
$this->valF['lettretype']=$row['lettretype']; |
305 |
else |
306 |
$this->valF['lettretype']="standard"; |
307 |
} |
308 |
$sql= "select * from ".DB_PREFIXE."dossier where dossier = '".$this->valF['dossier']."'"; |
309 |
$res = $db->query($sql); |
310 |
if (database::isError($res)) |
311 |
die($res->getMessage()); |
312 |
if ($DEBUG == 1) |
313 |
echo " la requete ".$sql." est exécutée<br>"; |
314 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
315 |
// |
316 |
$this->archive_date_depot = $row['date_depot']; |
317 |
// archive en instruction (si suppression) |
318 |
$this->valF['archive_delai']=$row['delai']; |
319 |
$this->valF['archive_accord_tacite']=$row['accord_tacite']; |
320 |
$this->valF['archive_etat']=$row['etat']; |
321 |
$this->valF['archive_avis']=$row['avis']; |
322 |
// compatibilite pgsql |
323 |
if($row['date_complet']!='') |
324 |
$this->valF['archive_date_complet']=$row['date_complet']; |
325 |
if($row['date_rejet']!='') |
326 |
$this->valF['archive_date_rejet']= $row['date_rejet']; |
327 |
if($row['date_limite']!='') |
328 |
$this->valF['archive_date_limite']= $row['date_limite']; |
329 |
if($row['date_notification_delai']!='') |
330 |
$this->valF['archive_date_notification_delai']= $row['date_notification_delai']; |
331 |
if($row['date_decision']!='') |
332 |
$this->valF['archive_date_decision']= $row['date_decision']; |
333 |
if($row['date_validite']!='') |
334 |
$this->valF['archive_date_validite']= $row['date_validite']; |
335 |
if($row['date_achevement']!='') |
336 |
$this->valF['archive_date_achevement']= $row['date_achevement']; |
337 |
if($row['date_chantier']!='') |
338 |
$this->valF['archive_date_chantier']= $row['date_chantier']; |
339 |
if($row['date_conformite']!='') |
340 |
$this->valF['archive_date_conformite']= $row['date_conformite']; |
341 |
} |
342 |
} |
343 |
|
344 |
function regle($regle){ |
345 |
$temp = explode ("+",$regle); |
346 |
//echo '|'.$regle; |
347 |
// cas rejet |
348 |
if($regle=="null") // 1 dimension -> null |
349 |
return null; |
350 |
if(sizeof($temp)==1) // 1 dimension |
351 |
if($temp[0]=="archive_date_depot") // initialisation avec le depot |
352 |
return $this->$regle; |
353 |
else // cas general |
354 |
return $this->valF[$regle]; |
355 |
if(sizeof($temp)==2){ // 2 dimensions |
356 |
if($temp[0]=="archive_date_depot") //initialisation avec le depot |
357 |
if(is_numeric($temp[1])) |
358 |
return $this->moisdate($this->$temp[0], $temp[1]); |
359 |
else |
360 |
return $this->moisdate($this->$temp[0], $this->valF[$temp[1]]); |
361 |
if($temp[0]=="archive_delai") // majoration de delai |
362 |
return $this->valF[$temp[0]]+$this->valF[$temp[1]]; |
363 |
// cas general 2 dimensions |
364 |
if(is_numeric($temp[1])) |
365 |
return $this->moisdate($this->valF[$temp[0]], $temp[1]); |
366 |
else |
367 |
return $this->moisdate($this->valF[$temp[0]], $this->valF[$temp[1]]); |
368 |
} |
369 |
if(sizeof($temp)==3){ // 3 dimensions |
370 |
// cas date de validite de sursis |
371 |
if(is_numeric($temp[1])) |
372 |
$temp1 = $this->moisdate($this->valF[$temp[0]], $temp[1]); |
373 |
else |
374 |
$temp1 = $this->moisdate($this->valF[$temp[0]], $this->valF[$temp[1]]); |
375 |
if(is_numeric($temp[2])) |
376 |
return $this->moisdate($temp1, $temp[2]); |
377 |
else |
378 |
return $this->moisdate($temp1, $this->valF[$temp[2]]); |
379 |
} |
380 |
} |
381 |
|
382 |
|
383 |
|
384 |
// ================================================================== |
385 |
// valeur dossier apres modification [values dossier after action] |
386 |
// ================================================================== |
387 |
function triggerajouterapres($id,&$db,$val,$DEBUG) { |
388 |
// mise a null au lieu de "" / voir compatibilite mysql |
389 |
// voir parametrage CU en dur |
390 |
// voir parametrage des actions en dur |
391 |
$param=1; |
392 |
if($param==1){ |
393 |
$sql="select * from ".DB_PREFIXE."action where action = '".$this->valF['action']."'"; |
394 |
$res = $db->query($sql); |
395 |
if (database::isError($res)) |
396 |
die($res->getMessage()); |
397 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
398 |
if($row['regle_etat']!=''){ |
399 |
$valF['etat']= $this->regle($row['regle_etat']); |
400 |
} |
401 |
if($row['regle_delai']!=''){ |
402 |
$valF['delai']= $this->regle($row['regle_delai']); |
403 |
} |
404 |
if($row['regle_accord_tacite']!=''){ |
405 |
$valF['accord_tacite']= $this->regle($row['regle_accord_tacite']); |
406 |
} |
407 |
if($row['regle_avis']!=''){ |
408 |
$valF['avis']= $this->regle($row['regle_avis']); |
409 |
} |
410 |
if($row['regle_date_limite']!=''){ |
411 |
$valF['date_limite']= $this->regle($row['regle_date_limite']); |
412 |
} |
413 |
if($row['regle_date_complet']!=''){ |
414 |
$valF['date_complet']= $this->regle($row['regle_date_complet']); |
415 |
} |
416 |
if($row['regle_date_notification_delai']!=''){ |
417 |
$valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']); |
418 |
} |
419 |
if($row['regle_date_decision']!=''){ |
420 |
$valF['date_decision']= $this->regle($row['regle_date_decision']); |
421 |
} |
422 |
if($row['regle_date_rejet']!=''){ |
423 |
$valF['date_rejet']= $this->regle($row['regle_date_rejet']); |
424 |
} |
425 |
if($row['regle_date_validite']!=''){ |
426 |
$valF['date_validite']= $this->regle($row['regle_date_validite']); |
427 |
} |
428 |
if($row['regle_date_chantier']!=''){ |
429 |
$valF['date_chantier']= $this->regle($row['regle_date_chantier']); |
430 |
} |
431 |
if($row['regle_date_achevement']!=''){ |
432 |
$valF['date_achevement']= $this->regle($row['regle_date_achevement']); |
433 |
} |
434 |
if($row['regle_date_conformite']!=''){ |
435 |
$valF['date_conformite']= $this->regle($row['regle_date_conformite']); |
436 |
} |
437 |
} |
438 |
}else{ |
439 |
switch ($this->valF['action']) { |
440 |
case "initialisation" : |
441 |
$valF['delai']= $this->valF['delai']; |
442 |
$valF['etat']= $this->valF['etat']; |
443 |
$valF['accord_tacite']= $this->valF['accord_tacite']; |
444 |
// la date_complet est la date de depot |
445 |
$valF['date_complet']= $this->archive_date_depot; // **** |
446 |
$valF['date_limite'] = $this->moisdate($valF['date_complet'],$valF['delai']); |
447 |
$valF['date_notification_delai'] = $this->moisdate($valF['date_complet'],1); |
448 |
break; |
449 |
case "notification" : |
450 |
$valF['delai']= $this->valF['delai']; |
451 |
$valF['etat']= $this->valF['etat']; |
452 |
$valF['accord_tacite']= $this->valF['accord_tacite']; |
453 |
// la date_complet est celle precedemment saisie |
454 |
$valF['date_complet']=$this->valF['archive_date_complet']; |
455 |
$valF['date_limite'] = $this->moisdate($valF['date_complet'],$valF['delai']); |
456 |
$valF['date_notification_delai'] = $this->moisdate($valF['date_complet'],1); |
457 |
// la date du courrier ne doit pas etre depasse par rapport au delai de |
458 |
// notification [verify notification date] |
459 |
if($this->valF['archive_date_notification_delai']<$this->valF['datecourrier']) |
460 |
$this->msg=$this->msg."<br><img src='../img/erreur.gif'> "._("date_notification_delai")." ". |
461 |
$this->valF['archive_date_notification_delai']." < "._('datecourrier'); |
462 |
// |
463 |
break; |
464 |
case "retour" : |
465 |
$valF['delai']= $this->valF['delai']; |
466 |
$valF['etat']= $this->valF['etat']; |
467 |
$valF['accord_tacite']= $this->valF['accord_tacite']; |
468 |
// la date_complet est celle de l evenement |
469 |
$valF['date_complet']= $this->valF['datecourrier']; |
470 |
$valF['date_limite'] = $this->moisdate($valF['date_complet'],$valF['delai']); |
471 |
$valF['date_notification_delai'] = $this->moisdate($valF['date_complet'],1); |
472 |
break; |
473 |
case "rejet" : |
474 |
//$valF['delai']=0; // *** delai a garder pour etat dpc |
475 |
$valF['etat']= $this->valF['etat']; |
476 |
$valF['accord_tacite']= $this->valF['accord_tacite']; |
477 |
// la date rejet est initialisee |
478 |
$valF['date_rejet']= $this->valF['datecourrier']; |
479 |
// les dates de depart et fin d instruction sont annulées |
480 |
$valF['date_limite'] =null; |
481 |
$valF['date_notification_delai'] =null; |
482 |
$valF['date_complet']=null; |
483 |
break; |
484 |
case "majoration" : |
485 |
$valF['delai']= $this->valF['archive_delai']+$this->valF['delai']; |
486 |
$valF['etat']= $this->valF['etat']; |
487 |
$valF['accord_tacite']= $this->valF['accord_tacite']; |
488 |
$valF['date_complet']=$this->valF['archive_date_complet']; |
489 |
// majoration de la date limite |
490 |
$valF['date_limite'] = $this->moisdate($valF['date_complet'],$valF['delai']); |
491 |
$valF['date_notification_delai'] = $this->moisdate($valF['date_complet'],1); |
492 |
// la date du courrier ne doit pas etre depasse par rapport au delai de |
493 |
// notification |
494 |
if($this->valF['archive_date_notification_delai']<$this->valF['datecourrier']) |
495 |
$this->msg=$this->msg."<br><img src='../img/erreur.gif'>"._("date_notification_delai"). |
496 |
$this->valF['archive_date_notification_delai']." < "._('datecourrier'); |
497 |
break; |
498 |
case "acceptation" : |
499 |
$valF['etat']= $this->valF['etat']; |
500 |
$valF['date_decision']= $this->valF['datecourrier']; |
501 |
$valF['avis']= $this->valF['avis']; |
502 |
// date de validite = date de l evenement + delai |
503 |
$valF['date_validite'] = $this->moisdate($this->valF['datecourrier'],$this->valF['delai']); |
504 |
break; |
505 |
case "refus" : |
506 |
$valF['etat']= $this->valF['etat']; |
507 |
$valF['date_decision']= $this->valF['datecourrier']; |
508 |
$valF['avis']= $this->valF['avis']; |
509 |
break; |
510 |
case "prolongation" : |
511 |
$valF['date_validite'] = $this->moisdate($this->valF['archive_date_validite'],$this->valF['delai']); |
512 |
break; |
513 |
case "sursis" : |
514 |
$valF['date_limite'] = $this->moisdate($this->valF['datecourrier'],$this->valF['delai']); |
515 |
$valF['etat']= $this->valF['etat']; |
516 |
$valF['accord_tacite']= $this->valF['accord_tacite']; |
517 |
$valF['avis']= $this->valF['avis']; |
518 |
$valF['date_decision']= $this->valF['datecourrier']; |
519 |
$temp = $valF['date_limite']; |
520 |
$valF['date_validite']= $this->moisdate($temp,2); |
521 |
break; |
522 |
case "execution" : |
523 |
$valF['etat']= $this->valF['etat']; |
524 |
$valF['date_chantier'] = $this->valF['datecourrier']; |
525 |
//echo $this->msg=$this->msg.$valF['date_chantier'].""; |
526 |
break; |
527 |
case "achevement" : |
528 |
$valF['etat']= $this->valF['etat']; |
529 |
$valF['date_achevement'] = $this->valF['datecourrier']; |
530 |
break; |
531 |
case "archivage" : |
532 |
$valF['etat']= $this->valF['etat']; |
533 |
$valF['date_conformite'] = $this->valF['datecourrier']; |
534 |
break; |
535 |
|
536 |
default: |
537 |
if ($this->valF['etat']!="") |
538 |
$valF['etat']= $this->valF['etat']; |
539 |
}// end switch |
540 |
} // end param |
541 |
if($valF!=""){ |
542 |
$cle= " dossier = '".$this->valF['dossier']."'"; |
543 |
$res1= $db->autoExecute(DB_PREFIXE.'dossier',$valF,DB_AUTOQUERY_UPDATE,$cle); |
544 |
if (database::isError($res1)) |
545 |
die($res->getMessage()); |
546 |
if ($DEBUG == 1) |
547 |
echo "La requête de mise à jour est effectuée.<br>"; |
548 |
$this->msg=$this->msg."<br>"._('enregistrement')." ". |
549 |
$this->valF['dossier']." "._('table')." dossier [". |
550 |
$db->affectedRows()." "._('enregistrement'). |
551 |
" "._('mis_a_jour')."]" ; |
552 |
} |
553 |
} |
554 |
|
555 |
function triggermodifierapres($id,&$db,$val,$DEBUG) { |
556 |
/* |
557 |
* cette fonction apour objet de permettre de modifier la date courrier |
558 |
*/ |
559 |
$valF=array(); |
560 |
$sql= "select action from ".DB_PREFIXE."evenement where evenement =".$this->valF['evenement']; |
561 |
$action = $db->getOne($sql); |
562 |
if (database::isError($action)) die($action->getMessage().$sql); |
563 |
$sql="select * from ".DB_PREFIXE."action where action = '".$action."'"; |
564 |
$res = $db->query($sql); |
565 |
if (database::isError($res)) die($res->getMessage().$sql); |
566 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
567 |
// application des regles sur le courrier + delai |
568 |
if(preg_match("/datecourrier/",$row['regle_date_limite'])){ |
569 |
$valF['date_limite']= $this->regle($row['regle_date_limite']); |
570 |
} |
571 |
if(preg_match("/datecourrier/",$row['regle_date_complet'])){ |
572 |
$valF['date_complet']= $this->regle($row['regle_date_complet']); |
573 |
} |
574 |
if(preg_match("/datecourrier/",$row['regle_date_notification_delai'])){ |
575 |
$valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']); |
576 |
} |
577 |
if(preg_match("/datecourrier/",$row['regle_date_decision'])){ |
578 |
$valF['date_decision']= $this->regle($row['regle_date_decision']); |
579 |
} |
580 |
if(preg_match("/datecourrier/",$row['regle_date_rejet'])){ |
581 |
$valF['date_rejet']= $this->regle($row['regle_date_rejet']); |
582 |
} |
583 |
if(preg_match("/datecourrier/",$row['regle_date_validite'])){ |
584 |
$valF['date_validite']= $this->regle($row['regle_date_validite']); |
585 |
} |
586 |
if(preg_match("/datecourrier/",$row['regle_date_chantier'])){ |
587 |
$valF['date_chantier']= $this->regle($row['regle_date_chantier']); |
588 |
} |
589 |
if(preg_match("/datecourrier/",$row['regle_date_achevement'])){ |
590 |
$valF['date_achevement']= $this->regle($row['regle_date_achevement']); |
591 |
} |
592 |
if(preg_match("/datecourrier/",$row['regle_date_conformite'])){ |
593 |
$valF['date_conformite']= $this->regle($row['regle_date_conformite']); |
594 |
} |
595 |
} // while |
596 |
if($valF!=array()){ |
597 |
$cle= " dossier = '".$this->valF['dossier']."'"; |
598 |
$res1= $db->autoExecute(DB_PREFIXE.'dossier',$valF,DB_AUTOQUERY_UPDATE,$cle); |
599 |
if (database::isError($res1)) |
600 |
die($res->getMessage()); |
601 |
if ($DEBUG == 1) |
602 |
echo "La requête de mise à jour est effectuée.<br>"; |
603 |
$this->msg=$this->msg."<br>"._('enregistrement')." ". |
604 |
$this->valF['dossier']." "._('table')." dossier [". |
605 |
$db->affectedRows()." "._('enregistrement'). |
606 |
" "._('mis_a_jour')."]" ; |
607 |
} |
608 |
} |
609 |
|
610 |
|
611 |
|
612 |
// trigger before delete |
613 |
function triggersupprimer($id,&$db,$val,$DEBUG) { |
614 |
// archive en instruction (si suppression) [archive if delete instruction] |
615 |
$valF['delai']=$val['archive_delai']; |
616 |
$valF['accord_tacite']=$val['archive_accord_tacite']; |
617 |
$valF['etat']=$val['archive_etat']; |
618 |
if($val['archive_avis']=='') |
619 |
$valF['avis']= null; |
620 |
else |
621 |
$valF['avis']=$val['archive_avis']; |
622 |
// if= compatibilite pgsql |
623 |
if($val['archive_date_complet']!='') |
624 |
$valF['date_complet']=$val['archive_date_complet']; |
625 |
if($val['archive_date_rejet']!='') |
626 |
$valF['date_rejet']= $val['archive_date_rejet']; |
627 |
if($val['archive_date_limite']!='') |
628 |
$valF['date_limite']= $val['archive_date_limite']; |
629 |
if($val['archive_date_notification_delai']!='') |
630 |
$valF['date_notification_delai']= $val['archive_date_notification_delai']; |
631 |
if($val['archive_date_decision']!='') |
632 |
$valF['date_decision']= $val['archive_date_decision']; |
633 |
if($val['archive_date_validite']!='') |
634 |
$valF['date_validite']= $val['archive_date_validite']; |
635 |
if($val['archive_date_achevement']!='') |
636 |
$valF['date_achevement']= $val['archive_date_achevement']; |
637 |
if($val['archive_date_chantier']!='') |
638 |
$valF['date_chantier']= $val['archive_date_chantier']; |
639 |
if($val['archive_date_conformite']!='') |
640 |
$valF['date_conformite']= $val['archive_date_conformite']; |
641 |
|
642 |
$cle= " dossier = '".$val['dossier']."'"; |
643 |
$res= $db->autoExecute(DB_PREFIXE.'dossier',$valF,DB_AUTOQUERY_UPDATE,$cle); |
644 |
if (database::isError($res)) |
645 |
die($res->getMessage()); |
646 |
else{ |
647 |
if ($DEBUG == 1) |
648 |
echo "La requête de mise à jour est effectuée.<br>"; |
649 |
} |
650 |
} |
651 |
// ============================================= |
652 |
// calcul de date avec ajout de mois (delais) |
653 |
// [add months (delay) and calculation final date] |
654 |
// LIMITE DE LA FONCTION si delai >24 MOIS |
655 |
// [limit : delay < 24 month] |
656 |
// ============================================= |
657 |
function moisdate($date,$delaimois) { |
658 |
$temp = explode("-" , $date); |
659 |
$jour = (int) $temp[2]; |
660 |
$mois = (int) $temp[1]; |
661 |
$annee = (int) $temp[0]; |
662 |
// calcul si delai superieur à 12 (limite 24) [delay > 24 month] |
663 |
if($delaimois>=12){ |
664 |
$delaimois=$delaimois-12; |
665 |
$annee=$annee+1; |
666 |
} |
667 |
if($delaimois>=12){ |
668 |
$delaimois=$delaimois-12; |
669 |
$annee=$annee+1; |
670 |
} |
671 |
// mois |
672 |
$mois=$mois+$delaimois; |
673 |
// calcul mois annee [calculation number of years if > 12 month] |
674 |
// nb de mois > à 12 |
675 |
if ($mois>12){ |
676 |
$mois=$mois-12; |
677 |
$annee=$annee+1; |
678 |
} |
679 |
// Calcul du nombre de jours dans le mois sélectionné [calculation number of days] |
680 |
switch($mois) { |
681 |
case "2": |
682 |
if ($annee % 4 == 0 && $annee % 100 != 0 || $annee % 400 == 0) |
683 |
$jourmax = 29; |
684 |
else |
685 |
$jourmax = 28; |
686 |
break; |
687 |
case "4": |
688 |
case "6": |
689 |
case "9": |
690 |
case "11": |
691 |
$jourmax = 30; |
692 |
break; |
693 |
default: |
694 |
$jourmax = 31; |
695 |
} |
696 |
if ($jour > $jourmax) |
697 |
$jour = $jourmax; |
698 |
//$dateretour=$annee."-".$mois."-".$jour; |
699 |
return $annee."-".$mois."-".$jour ; |
700 |
} |
701 |
|
702 |
}// fin classe |
703 |
?> |