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