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 |
|
|
|
22 |
|
|
class instruction extends instruction_gen { |
23 |
|
|
|
24 |
fraynaud |
20 |
var $archive_date_depot; // specific |
25 |
|
|
var $retourformulaire; // specific |
26 |
|
|
var $idxformulaire; // specific |
27 |
fraynaud |
3 |
|
28 |
fraynaud |
20 |
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 |
fraynaud |
129 |
$this->valF['delai'] = $val['delai']; // necessaire pour maj datecourrier |
43 |
fraynaud |
20 |
} |
44 |
|
|
|
45 |
|
|
|
46 |
|
|
function cleSecondaire($id,&$db,$val,$DEBUG) { |
47 |
fraynaud |
129 |
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 |
fraynaud |
20 |
$dernierevenement=''; |
53 |
fraynaud |
242 |
$sql="select max(instruction) from ".DB_PREFIXE."instruction where dossier ='". |
54 |
fraynaud |
20 |
$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 |
fraynaud |
116 |
$imgv="<img src='../app/img/punaise.png' style='vertical-align:middle' hspace='2' border='0'>"; |
71 |
fraynaud |
20 |
// 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 |
fraynaud |
121 |
//$form->setType('datecourrier', 'hiddenstaticdate'); |
168 |
|
|
$form->setType('datecourrier', 'date2'); |
169 |
fraynaud |
129 |
// necessaire pour calcul de date en modification |
170 |
|
|
$form->setType('delai', 'hiddenstatic'); |
171 |
fraynaud |
20 |
} |
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 |
fraynaud |
265 |
|
201 |
fraynaud |
20 |
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 |
fraynaud |
242 |
$sql="select etat from ".DB_PREFIXE."dossier where dossier ='". |
209 |
fraynaud |
20 |
$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 |
fraynaud |
265 |
|
216 |
fraynaud |
298 |
echo $sql; |
217 |
|
|
|
218 |
fraynaud |
47 |
// *** attention en dur le CU |
219 |
fraynaud |
46 |
|
220 |
|
|
|
221 |
fraynaud |
20 |
$res = $db->query($sql); |
222 |
|
|
if (database::isError($res)) |
223 |
|
|
die($res->getMessage()); |
224 |
|
|
$contenu[0][0]=""; |
225 |
|
|
$contenu[1][0]=_('choisir')." "._('evenement'); |
226 |
|
|
$k=1; |
227 |
|
|
while ($row=& $res->fetchRow()){ |
228 |
|
|
if($maj==0){ // ajouter |
229 |
|
|
$contenu[0][$k]=$row[0]; |
230 |
|
|
$contenu[1][$k]=$row[1]; |
231 |
|
|
$k++; |
232 |
|
|
}else{ |
233 |
|
|
// select hiddenstatic |
234 |
|
|
$contenu[0][$k]=$row[0]; |
235 |
|
|
$contenu[1][$k]=$row[1]; |
236 |
|
|
$k++; |
237 |
|
|
} |
238 |
|
|
} |
239 |
|
|
$form->setSelect("evenement",$contenu); |
240 |
|
|
// lien bible_auto [link] |
241 |
|
|
$contenu=array(); |
242 |
|
|
$contenu[0]=" automatique "; |
243 |
|
|
$form->setSelect("bible_auto",$contenu); |
244 |
|
|
// lien bible1 |
245 |
|
|
$contenu=array(); |
246 |
|
|
$contenu[0]=" Bible "; |
247 |
|
|
$form->setSelect("bible",$contenu); |
248 |
|
|
// lien bible2 |
249 |
|
|
$contenu=array(); |
250 |
|
|
$contenu[0]=" Bible "; |
251 |
|
|
$form->setSelect("bible2",$contenu); |
252 |
|
|
} |
253 |
|
|
} // function select |
254 |
|
|
|
255 |
|
|
function setGroupe(&$form,$maj){ |
256 |
|
|
$form->setGroupe('evenement','D'); |
257 |
|
|
$form->setGroupe('libelle','G'); |
258 |
|
|
$form->setGroupe('datecourrier','G'); |
259 |
|
|
$form->setGroupe('lettretype','F'); |
260 |
|
|
} |
261 |
|
|
|
262 |
|
|
function setRegroupe(&$form,$maj){ |
263 |
|
|
$form->setRegroupe('evenement','D',_('evenement'), "collapsible"); |
264 |
|
|
$form->setRegroupe('libelle','G',''); |
265 |
|
|
$form->setRegroupe('datecourrier','G',''); |
266 |
|
|
$form->setRegroupe('lettretype','F',''); |
267 |
fraynaud |
196 |
$form->setRegroupe('complement','D',_('complement'), "collapsible"); |
268 |
fraynaud |
20 |
$form->setRegroupe('bible_auto','G',''); |
269 |
|
|
$form->setRegroupe('bible','F',''); |
270 |
|
|
$form->setRegroupe('complement2','D',_('complement2'), "startClosed"); |
271 |
|
|
$form->setRegroupe('bible2','F',''); |
272 |
|
|
} |
273 |
|
|
|
274 |
|
|
function setLib(&$form,$maj) { |
275 |
|
|
parent :: setLib($form,$maj); |
276 |
|
|
$form->setLib('libelle',' '); |
277 |
|
|
$form->setLib('bible_auto',""); |
278 |
|
|
$form->setLib('bible',""); |
279 |
|
|
$form->setLib('bible2',""); |
280 |
|
|
$form->setLib('lettretype',"->"._(" courrier ")); |
281 |
|
|
$form->setLib('datecourrier',_(" du ")); |
282 |
|
|
} |
283 |
|
|
|
284 |
|
|
function setOnchange(&$form,$maj){ |
285 |
|
|
$form->setOnchange("datecourrier","fdate(this)"); |
286 |
|
|
} |
287 |
|
|
|
288 |
|
|
// ================================================================== |
289 |
|
|
// trigger avant modification données [trigger before modify data] |
290 |
|
|
// ================================================================== |
291 |
|
|
function triggerajouter($id,&$db,$val,$DEBUG) { |
292 |
|
|
// mise a jour instruction avec evenement |
293 |
|
|
// [modify instruction with evenement] |
294 |
fraynaud |
242 |
$sql= "select * from ".DB_PREFIXE."evenement where evenement =".$this->valF['evenement']; |
295 |
fraynaud |
20 |
$res = $db->query($sql); |
296 |
fraynaud |
129 |
if (database::isError($res)) die($res->getMessage()); |
297 |
fraynaud |
20 |
if ($DEBUG == 1) |
298 |
|
|
echo " la requete ".$sql." est exécutée<br>"; |
299 |
|
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
300 |
|
|
$this->valF['action']=$row['action']; |
301 |
|
|
$this->valF['delai']=$row['delai']; |
302 |
|
|
$this->valF['etat']=$row['etat']; |
303 |
|
|
$this->valF['accord_tacite']=$row['accord_tacite']; |
304 |
|
|
$this->valF['delai_notification']=$row['delai_notification']; |
305 |
|
|
$this->valF['avis']=$row['avis']; |
306 |
|
|
if($row['lettretype']!="") |
307 |
|
|
$this->valF['lettretype']=$row['lettretype']; |
308 |
|
|
else |
309 |
|
|
$this->valF['lettretype']="standard"; |
310 |
|
|
} |
311 |
fraynaud |
242 |
$sql= "select * from ".DB_PREFIXE."dossier where dossier = '".$this->valF['dossier']."'"; |
312 |
fraynaud |
20 |
$res = $db->query($sql); |
313 |
|
|
if (database::isError($res)) |
314 |
|
|
die($res->getMessage()); |
315 |
|
|
if ($DEBUG == 1) |
316 |
|
|
echo " la requete ".$sql." est exécutée<br>"; |
317 |
|
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
318 |
|
|
// |
319 |
|
|
$this->archive_date_depot = $row['date_depot']; |
320 |
|
|
// archive en instruction (si suppression) |
321 |
|
|
$this->valF['archive_delai']=$row['delai']; |
322 |
|
|
$this->valF['archive_accord_tacite']=$row['accord_tacite']; |
323 |
|
|
$this->valF['archive_etat']=$row['etat']; |
324 |
|
|
$this->valF['archive_avis']=$row['avis']; |
325 |
|
|
// compatibilite pgsql |
326 |
|
|
if($row['date_complet']!='') |
327 |
|
|
$this->valF['archive_date_complet']=$row['date_complet']; |
328 |
|
|
if($row['date_rejet']!='') |
329 |
|
|
$this->valF['archive_date_rejet']= $row['date_rejet']; |
330 |
|
|
if($row['date_limite']!='') |
331 |
|
|
$this->valF['archive_date_limite']= $row['date_limite']; |
332 |
|
|
if($row['date_notification_delai']!='') |
333 |
|
|
$this->valF['archive_date_notification_delai']= $row['date_notification_delai']; |
334 |
|
|
if($row['date_decision']!='') |
335 |
|
|
$this->valF['archive_date_decision']= $row['date_decision']; |
336 |
|
|
if($row['date_validite']!='') |
337 |
|
|
$this->valF['archive_date_validite']= $row['date_validite']; |
338 |
|
|
if($row['date_achevement']!='') |
339 |
|
|
$this->valF['archive_date_achevement']= $row['date_achevement']; |
340 |
|
|
if($row['date_chantier']!='') |
341 |
|
|
$this->valF['archive_date_chantier']= $row['date_chantier']; |
342 |
|
|
if($row['date_conformite']!='') |
343 |
|
|
$this->valF['archive_date_conformite']= $row['date_conformite']; |
344 |
|
|
} |
345 |
|
|
} |
346 |
|
|
|
347 |
fraynaud |
123 |
function regle($regle){ |
348 |
|
|
$temp = explode ("+",$regle); |
349 |
atreal |
208 |
//echo '|'.$regle; |
350 |
fraynaud |
124 |
// cas rejet |
351 |
fraynaud |
129 |
if($regle=="null") // 1 dimension -> null |
352 |
fraynaud |
124 |
return null; |
353 |
|
|
if(sizeof($temp)==1) // 1 dimension |
354 |
|
|
if($temp[0]=="archive_date_depot") // initialisation avec le depot |
355 |
fraynaud |
123 |
return $this->$regle; |
356 |
fraynaud |
124 |
else // cas general |
357 |
fraynaud |
123 |
return $this->valF[$regle]; |
358 |
fraynaud |
124 |
if(sizeof($temp)==2){ // 2 dimensions |
359 |
|
|
if($temp[0]=="archive_date_depot") //initialisation avec le depot |
360 |
fraynaud |
123 |
if(is_numeric($temp[1])) |
361 |
|
|
return $this->moisdate($this->$temp[0], $temp[1]); |
362 |
|
|
else |
363 |
|
|
return $this->moisdate($this->$temp[0], $this->valF[$temp[1]]); |
364 |
fraynaud |
124 |
if($temp[0]=="archive_delai") // majoration de delai |
365 |
|
|
return $this->valF[$temp[0]]+$this->valF[$temp[1]]; |
366 |
|
|
// cas general 2 dimensions |
367 |
fraynaud |
123 |
if(is_numeric($temp[1])) |
368 |
|
|
return $this->moisdate($this->valF[$temp[0]], $temp[1]); |
369 |
|
|
else |
370 |
|
|
return $this->moisdate($this->valF[$temp[0]], $this->valF[$temp[1]]); |
371 |
|
|
} |
372 |
fraynaud |
124 |
if(sizeof($temp)==3){ // 3 dimensions |
373 |
|
|
// cas date de validite de sursis |
374 |
|
|
if(is_numeric($temp[1])) |
375 |
|
|
$temp1 = $this->moisdate($this->valF[$temp[0]], $temp[1]); |
376 |
|
|
else |
377 |
|
|
$temp1 = $this->moisdate($this->valF[$temp[0]], $this->valF[$temp[1]]); |
378 |
|
|
if(is_numeric($temp[2])) |
379 |
|
|
return $this->moisdate($temp1, $temp[2]); |
380 |
|
|
else |
381 |
|
|
return $this->moisdate($temp1, $this->valF[$temp[2]]); |
382 |
|
|
} |
383 |
fraynaud |
123 |
} |
384 |
|
|
|
385 |
|
|
|
386 |
|
|
|
387 |
fraynaud |
20 |
// ================================================================== |
388 |
|
|
// valeur dossier apres modification [values dossier after action] |
389 |
|
|
// ================================================================== |
390 |
|
|
function triggerajouterapres($id,&$db,$val,$DEBUG) { |
391 |
fraynaud |
47 |
// mise a null au lieu de "" / voir compatibilite mysql |
392 |
|
|
// voir parametrage CU en dur |
393 |
|
|
// voir parametrage des actions en dur |
394 |
fraynaud |
123 |
$param=1; |
395 |
fraynaud |
121 |
if($param==1){ |
396 |
fraynaud |
242 |
$sql="select * from ".DB_PREFIXE."action where action = '".$this->valF['action']."'"; |
397 |
fraynaud |
121 |
$res = $db->query($sql); |
398 |
|
|
if (database::isError($res)) |
399 |
|
|
die($res->getMessage()); |
400 |
|
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
401 |
|
|
if($row['regle_etat']!=''){ |
402 |
fraynaud |
123 |
$valF['etat']= $this->regle($row['regle_etat']); |
403 |
fraynaud |
121 |
} |
404 |
|
|
if($row['regle_delai']!=''){ |
405 |
fraynaud |
123 |
$valF['delai']= $this->regle($row['regle_delai']); |
406 |
fraynaud |
121 |
} |
407 |
|
|
if($row['regle_accord_tacite']!=''){ |
408 |
fraynaud |
123 |
$valF['accord_tacite']= $this->regle($row['regle_accord_tacite']); |
409 |
fraynaud |
121 |
} |
410 |
fraynaud |
124 |
if($row['regle_avis']!=''){ |
411 |
|
|
$valF['avis']= $this->regle($row['regle_avis']); |
412 |
|
|
} |
413 |
fraynaud |
121 |
if($row['regle_date_limite']!=''){ |
414 |
fraynaud |
123 |
$valF['date_limite']= $this->regle($row['regle_date_limite']); |
415 |
|
|
} |
416 |
|
|
if($row['regle_date_complet']!=''){ |
417 |
|
|
$valF['date_complet']= $this->regle($row['regle_date_complet']); |
418 |
|
|
} |
419 |
|
|
if($row['regle_date_notification_delai']!=''){ |
420 |
|
|
$valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']); |
421 |
|
|
} |
422 |
fraynaud |
124 |
if($row['regle_date_decision']!=''){ |
423 |
|
|
$valF['date_decision']= $this->regle($row['regle_date_decision']); |
424 |
|
|
} |
425 |
|
|
if($row['regle_date_rejet']!=''){ |
426 |
|
|
$valF['date_rejet']= $this->regle($row['regle_date_rejet']); |
427 |
|
|
} |
428 |
|
|
if($row['regle_date_validite']!=''){ |
429 |
|
|
$valF['date_validite']= $this->regle($row['regle_date_validite']); |
430 |
|
|
} |
431 |
|
|
if($row['regle_date_chantier']!=''){ |
432 |
|
|
$valF['date_chantier']= $this->regle($row['regle_date_chantier']); |
433 |
|
|
} |
434 |
|
|
if($row['regle_date_achevement']!=''){ |
435 |
|
|
$valF['date_achevement']= $this->regle($row['regle_date_achevement']); |
436 |
|
|
} |
437 |
|
|
if($row['regle_date_conformite']!=''){ |
438 |
|
|
$valF['date_conformite']= $this->regle($row['regle_date_conformite']); |
439 |
|
|
} |
440 |
fraynaud |
121 |
} |
441 |
|
|
}else{ |
442 |
fraynaud |
242 |
switch ($this->valF['action']) { |
443 |
|
|
case "initialisation" : |
444 |
|
|
$valF['delai']= $this->valF['delai']; |
445 |
|
|
$valF['etat']= $this->valF['etat']; |
446 |
|
|
$valF['accord_tacite']= $this->valF['accord_tacite']; |
447 |
|
|
// la date_complet est la date de depot |
448 |
|
|
$valF['date_complet']= $this->archive_date_depot; // **** |
449 |
|
|
$valF['date_limite'] = $this->moisdate($valF['date_complet'],$valF['delai']); |
450 |
|
|
$valF['date_notification_delai'] = $this->moisdate($valF['date_complet'],1); |
451 |
|
|
break; |
452 |
|
|
case "notification" : |
453 |
|
|
$valF['delai']= $this->valF['delai']; |
454 |
|
|
$valF['etat']= $this->valF['etat']; |
455 |
|
|
$valF['accord_tacite']= $this->valF['accord_tacite']; |
456 |
|
|
// la date_complet est celle precedemment saisie |
457 |
|
|
$valF['date_complet']=$this->valF['archive_date_complet']; |
458 |
|
|
$valF['date_limite'] = $this->moisdate($valF['date_complet'],$valF['delai']); |
459 |
|
|
$valF['date_notification_delai'] = $this->moisdate($valF['date_complet'],1); |
460 |
|
|
// la date du courrier ne doit pas etre depasse par rapport au delai de |
461 |
|
|
// notification [verify notification date] |
462 |
|
|
if($this->valF['archive_date_notification_delai']<$this->valF['datecourrier']) |
463 |
|
|
$this->msg=$this->msg."<br><img src='../img/erreur.gif'> "._("date_notification_delai")." ". |
464 |
|
|
$this->valF['archive_date_notification_delai']." < "._('datecourrier'); |
465 |
|
|
// |
466 |
|
|
break; |
467 |
|
|
case "retour" : |
468 |
|
|
$valF['delai']= $this->valF['delai']; |
469 |
|
|
$valF['etat']= $this->valF['etat']; |
470 |
|
|
$valF['accord_tacite']= $this->valF['accord_tacite']; |
471 |
|
|
// la date_complet est celle de l evenement |
472 |
|
|
$valF['date_complet']= $this->valF['datecourrier']; |
473 |
|
|
$valF['date_limite'] = $this->moisdate($valF['date_complet'],$valF['delai']); |
474 |
|
|
$valF['date_notification_delai'] = $this->moisdate($valF['date_complet'],1); |
475 |
|
|
break; |
476 |
|
|
case "rejet" : |
477 |
|
|
//$valF['delai']=0; // *** delai a garder pour etat dpc |
478 |
|
|
$valF['etat']= $this->valF['etat']; |
479 |
|
|
$valF['accord_tacite']= $this->valF['accord_tacite']; |
480 |
|
|
// la date rejet est initialisee |
481 |
|
|
$valF['date_rejet']= $this->valF['datecourrier']; |
482 |
|
|
// les dates de depart et fin d instruction sont annulées |
483 |
|
|
$valF['date_limite'] =null; |
484 |
|
|
$valF['date_notification_delai'] =null; |
485 |
|
|
$valF['date_complet']=null; |
486 |
|
|
break; |
487 |
|
|
case "majoration" : |
488 |
|
|
$valF['delai']= $this->valF['archive_delai']+$this->valF['delai']; |
489 |
|
|
$valF['etat']= $this->valF['etat']; |
490 |
|
|
$valF['accord_tacite']= $this->valF['accord_tacite']; |
491 |
|
|
$valF['date_complet']=$this->valF['archive_date_complet']; |
492 |
|
|
// majoration de la date limite |
493 |
|
|
$valF['date_limite'] = $this->moisdate($valF['date_complet'],$valF['delai']); |
494 |
|
|
$valF['date_notification_delai'] = $this->moisdate($valF['date_complet'],1); |
495 |
|
|
// la date du courrier ne doit pas etre depasse par rapport au delai de |
496 |
|
|
// notification |
497 |
|
|
if($this->valF['archive_date_notification_delai']<$this->valF['datecourrier']) |
498 |
|
|
$this->msg=$this->msg."<br><img src='../img/erreur.gif'>"._("date_notification_delai"). |
499 |
fraynaud |
20 |
$this->valF['archive_date_notification_delai']." < "._('datecourrier'); |
500 |
fraynaud |
242 |
break; |
501 |
|
|
case "acceptation" : |
502 |
|
|
$valF['etat']= $this->valF['etat']; |
503 |
|
|
$valF['date_decision']= $this->valF['datecourrier']; |
504 |
|
|
$valF['avis']= $this->valF['avis']; |
505 |
|
|
// date de validite = date de l evenement + delai |
506 |
|
|
$valF['date_validite'] = $this->moisdate($this->valF['datecourrier'],$this->valF['delai']); |
507 |
|
|
break; |
508 |
|
|
case "refus" : |
509 |
|
|
$valF['etat']= $this->valF['etat']; |
510 |
|
|
$valF['date_decision']= $this->valF['datecourrier']; |
511 |
|
|
$valF['avis']= $this->valF['avis']; |
512 |
|
|
break; |
513 |
|
|
case "prolongation" : |
514 |
|
|
$valF['date_validite'] = $this->moisdate($this->valF['archive_date_validite'],$this->valF['delai']); |
515 |
|
|
break; |
516 |
|
|
case "sursis" : |
517 |
|
|
$valF['date_limite'] = $this->moisdate($this->valF['datecourrier'],$this->valF['delai']); |
518 |
|
|
$valF['etat']= $this->valF['etat']; |
519 |
|
|
$valF['accord_tacite']= $this->valF['accord_tacite']; |
520 |
|
|
$valF['avis']= $this->valF['avis']; |
521 |
|
|
$valF['date_decision']= $this->valF['datecourrier']; |
522 |
|
|
$temp = $valF['date_limite']; |
523 |
|
|
$valF['date_validite']= $this->moisdate($temp,2); |
524 |
|
|
break; |
525 |
|
|
case "execution" : |
526 |
|
|
$valF['etat']= $this->valF['etat']; |
527 |
|
|
$valF['date_chantier'] = $this->valF['datecourrier']; |
528 |
|
|
//echo $this->msg=$this->msg.$valF['date_chantier'].""; |
529 |
|
|
break; |
530 |
|
|
case "achevement" : |
531 |
|
|
$valF['etat']= $this->valF['etat']; |
532 |
|
|
$valF['date_achevement'] = $this->valF['datecourrier']; |
533 |
|
|
break; |
534 |
|
|
case "archivage" : |
535 |
|
|
$valF['etat']= $this->valF['etat']; |
536 |
|
|
$valF['date_conformite'] = $this->valF['datecourrier']; |
537 |
|
|
break; |
538 |
|
|
|
539 |
|
|
default: |
540 |
|
|
if ($this->valF['etat']!="") |
541 |
|
|
$valF['etat']= $this->valF['etat']; |
542 |
|
|
}// end switch |
543 |
fraynaud |
121 |
} // end param |
544 |
fraynaud |
20 |
if($valF!=""){ |
545 |
|
|
$cle= " dossier = '".$this->valF['dossier']."'"; |
546 |
fraynaud |
242 |
$res1= $db->autoExecute(DB_PREFIXE.'dossier',$valF,DB_AUTOQUERY_UPDATE,$cle); |
547 |
fraynaud |
20 |
if (database::isError($res1)) |
548 |
|
|
die($res->getMessage()); |
549 |
|
|
if ($DEBUG == 1) |
550 |
|
|
echo "La requête de mise à jour est effectuée.<br>"; |
551 |
|
|
$this->msg=$this->msg."<br>"._('enregistrement')." ". |
552 |
|
|
$this->valF['dossier']." "._('table')." dossier [". |
553 |
|
|
$db->affectedRows()." "._('enregistrement'). |
554 |
|
|
" "._('mis_a_jour')."]" ; |
555 |
|
|
} |
556 |
|
|
} |
557 |
fraynaud |
129 |
|
558 |
|
|
function triggermodifierapres($id,&$db,$val,$DEBUG) { |
559 |
|
|
/* |
560 |
|
|
* cette fonction apour objet de permettre de modifier la date courrier |
561 |
|
|
*/ |
562 |
|
|
$valF=array(); |
563 |
fraynaud |
242 |
$sql= "select action from ".DB_PREFIXE."evenement where evenement =".$this->valF['evenement']; |
564 |
fraynaud |
129 |
$action = $db->getOne($sql); |
565 |
|
|
if (database::isError($action)) die($action->getMessage().$sql); |
566 |
fraynaud |
242 |
$sql="select * from ".DB_PREFIXE."action where action = '".$action."'"; |
567 |
fraynaud |
129 |
$res = $db->query($sql); |
568 |
|
|
if (database::isError($res)) die($res->getMessage().$sql); |
569 |
|
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
570 |
|
|
// application des regles sur le courrier + delai |
571 |
|
|
if(preg_match("/datecourrier/",$row['regle_date_limite'])){ |
572 |
|
|
$valF['date_limite']= $this->regle($row['regle_date_limite']); |
573 |
|
|
} |
574 |
|
|
if(preg_match("/datecourrier/",$row['regle_date_complet'])){ |
575 |
|
|
$valF['date_complet']= $this->regle($row['regle_date_complet']); |
576 |
|
|
} |
577 |
|
|
if(preg_match("/datecourrier/",$row['regle_date_notification_delai'])){ |
578 |
|
|
$valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']); |
579 |
|
|
} |
580 |
|
|
if(preg_match("/datecourrier/",$row['regle_date_decision'])){ |
581 |
|
|
$valF['date_decision']= $this->regle($row['regle_date_decision']); |
582 |
|
|
} |
583 |
|
|
if(preg_match("/datecourrier/",$row['regle_date_rejet'])){ |
584 |
|
|
$valF['date_rejet']= $this->regle($row['regle_date_rejet']); |
585 |
|
|
} |
586 |
|
|
if(preg_match("/datecourrier/",$row['regle_date_validite'])){ |
587 |
|
|
$valF['date_validite']= $this->regle($row['regle_date_validite']); |
588 |
|
|
} |
589 |
|
|
if(preg_match("/datecourrier/",$row['regle_date_chantier'])){ |
590 |
|
|
$valF['date_chantier']= $this->regle($row['regle_date_chantier']); |
591 |
|
|
} |
592 |
|
|
if(preg_match("/datecourrier/",$row['regle_date_achevement'])){ |
593 |
|
|
$valF['date_achevement']= $this->regle($row['regle_date_achevement']); |
594 |
|
|
} |
595 |
|
|
if(preg_match("/datecourrier/",$row['regle_date_conformite'])){ |
596 |
|
|
$valF['date_conformite']= $this->regle($row['regle_date_conformite']); |
597 |
|
|
} |
598 |
|
|
} // while |
599 |
|
|
if($valF!=array()){ |
600 |
|
|
$cle= " dossier = '".$this->valF['dossier']."'"; |
601 |
fraynaud |
242 |
$res1= $db->autoExecute(DB_PREFIXE.'dossier',$valF,DB_AUTOQUERY_UPDATE,$cle); |
602 |
fraynaud |
129 |
if (database::isError($res1)) |
603 |
|
|
die($res->getMessage()); |
604 |
|
|
if ($DEBUG == 1) |
605 |
|
|
echo "La requête de mise à jour est effectuée.<br>"; |
606 |
|
|
$this->msg=$this->msg."<br>"._('enregistrement')." ". |
607 |
|
|
$this->valF['dossier']." "._('table')." dossier [". |
608 |
|
|
$db->affectedRows()." "._('enregistrement'). |
609 |
|
|
" "._('mis_a_jour')."]" ; |
610 |
|
|
} |
611 |
|
|
} |
612 |
|
|
|
613 |
|
|
|
614 |
fraynaud |
20 |
|
615 |
|
|
// trigger before delete |
616 |
|
|
function triggersupprimer($id,&$db,$val,$DEBUG) { |
617 |
|
|
// archive en instruction (si suppression) [archive if delete instruction] |
618 |
|
|
$valF['delai']=$val['archive_delai']; |
619 |
|
|
$valF['accord_tacite']=$val['archive_accord_tacite']; |
620 |
|
|
$valF['etat']=$val['archive_etat']; |
621 |
fraynaud |
80 |
if($val['archive_avis']=='') |
622 |
|
|
$valF['avis']= null; |
623 |
|
|
else |
624 |
|
|
$valF['avis']=$val['archive_avis']; |
625 |
fraynaud |
20 |
// if= compatibilite pgsql |
626 |
|
|
if($val['archive_date_complet']!='') |
627 |
|
|
$valF['date_complet']=$val['archive_date_complet']; |
628 |
|
|
if($val['archive_date_rejet']!='') |
629 |
|
|
$valF['date_rejet']= $val['archive_date_rejet']; |
630 |
|
|
if($val['archive_date_limite']!='') |
631 |
|
|
$valF['date_limite']= $val['archive_date_limite']; |
632 |
|
|
if($val['archive_date_notification_delai']!='') |
633 |
|
|
$valF['date_notification_delai']= $val['archive_date_notification_delai']; |
634 |
|
|
if($val['archive_date_decision']!='') |
635 |
|
|
$valF['date_decision']= $val['archive_date_decision']; |
636 |
|
|
if($val['archive_date_validite']!='') |
637 |
|
|
$valF['date_validite']= $val['archive_date_validite']; |
638 |
|
|
if($val['archive_date_achevement']!='') |
639 |
|
|
$valF['date_achevement']= $val['archive_date_achevement']; |
640 |
|
|
if($val['archive_date_chantier']!='') |
641 |
|
|
$valF['date_chantier']= $val['archive_date_chantier']; |
642 |
|
|
if($val['archive_date_conformite']!='') |
643 |
|
|
$valF['date_conformite']= $val['archive_date_conformite']; |
644 |
fraynaud |
80 |
|
645 |
fraynaud |
20 |
$cle= " dossier = '".$val['dossier']."'"; |
646 |
fraynaud |
242 |
$res= $db->autoExecute(DB_PREFIXE.'dossier',$valF,DB_AUTOQUERY_UPDATE,$cle); |
647 |
fraynaud |
20 |
if (database::isError($res)) |
648 |
|
|
die($res->getMessage()); |
649 |
|
|
else{ |
650 |
|
|
if ($DEBUG == 1) |
651 |
|
|
echo "La requête de mise à jour est effectuée.<br>"; |
652 |
|
|
} |
653 |
|
|
} |
654 |
|
|
// ============================================= |
655 |
|
|
// calcul de date avec ajout de mois (delais) |
656 |
|
|
// [add months (delay) and calculation final date] |
657 |
|
|
// LIMITE DE LA FONCTION si delai >24 MOIS |
658 |
|
|
// [limit : delay < 24 month] |
659 |
|
|
// ============================================= |
660 |
|
|
function moisdate($date,$delaimois) { |
661 |
|
|
$temp = explode("-" , $date); |
662 |
|
|
$jour = (int) $temp[2]; |
663 |
|
|
$mois = (int) $temp[1]; |
664 |
|
|
$annee = (int) $temp[0]; |
665 |
|
|
// calcul si delai superieur à 12 (limite 24) [delay > 24 month] |
666 |
|
|
if($delaimois>=12){ |
667 |
|
|
$delaimois=$delaimois-12; |
668 |
|
|
$annee=$annee+1; |
669 |
|
|
} |
670 |
|
|
if($delaimois>=12){ |
671 |
|
|
$delaimois=$delaimois-12; |
672 |
|
|
$annee=$annee+1; |
673 |
|
|
} |
674 |
|
|
// mois |
675 |
|
|
$mois=$mois+$delaimois; |
676 |
|
|
// calcul mois annee [calculation number of years if > 12 month] |
677 |
|
|
// nb de mois > à 12 |
678 |
|
|
if ($mois>12){ |
679 |
|
|
$mois=$mois-12; |
680 |
|
|
$annee=$annee+1; |
681 |
|
|
} |
682 |
|
|
// Calcul du nombre de jours dans le mois sélectionné [calculation number of days] |
683 |
|
|
switch($mois) { |
684 |
|
|
case "2": |
685 |
|
|
if ($annee % 4 == 0 && $annee % 100 != 0 || $annee % 400 == 0) |
686 |
|
|
$jourmax = 29; |
687 |
|
|
else |
688 |
|
|
$jourmax = 28; |
689 |
|
|
break; |
690 |
|
|
case "4": |
691 |
|
|
case "6": |
692 |
|
|
case "9": |
693 |
|
|
case "11": |
694 |
|
|
$jourmax = 30; |
695 |
|
|
break; |
696 |
|
|
default: |
697 |
|
|
$jourmax = 31; |
698 |
|
|
} |
699 |
|
|
if ($jour > $jourmax) |
700 |
|
|
$jour = $jourmax; |
701 |
|
|
//$dateretour=$annee."-".$mois."-".$jour; |
702 |
|
|
return $annee."-".$mois."-".$jour ; |
703 |
|
|
} |
704 |
|
|
|
705 |
fraynaud |
3 |
}// fin classe |
706 |
atreal |
208 |
?> |