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 |
|
|
$sql="select max(instruction) from 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 |
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 |
|
|
//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 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 |
fraynaud |
47 |
// *** attention en dur le CU |
216 |
fraynaud |
46 |
|
217 |
|
|
|
218 |
fraynaud |
20 |
$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 |
fraynaud |
196 |
$form->setRegroupe('complement','D',_('complement'), "collapsible"); |
265 |
fraynaud |
20 |
$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 evenement where evenement =".$this->valF['evenement']; |
292 |
|
|
$res = $db->query($sql); |
293 |
fraynaud |
129 |
if (database::isError($res)) die($res->getMessage()); |
294 |
fraynaud |
20 |
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 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 |
fraynaud |
123 |
function regle($regle){ |
345 |
|
|
$temp = explode ("+",$regle); |
346 |
atreal |
208 |
//echo '|'.$regle; |
347 |
fraynaud |
124 |
// cas rejet |
348 |
fraynaud |
129 |
if($regle=="null") // 1 dimension -> null |
349 |
fraynaud |
124 |
return null; |
350 |
|
|
if(sizeof($temp)==1) // 1 dimension |
351 |
|
|
if($temp[0]=="archive_date_depot") // initialisation avec le depot |
352 |
fraynaud |
123 |
return $this->$regle; |
353 |
fraynaud |
124 |
else // cas general |
354 |
fraynaud |
123 |
return $this->valF[$regle]; |
355 |
fraynaud |
124 |
if(sizeof($temp)==2){ // 2 dimensions |
356 |
|
|
if($temp[0]=="archive_date_depot") //initialisation avec le depot |
357 |
fraynaud |
123 |
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 |
fraynaud |
124 |
if($temp[0]=="archive_delai") // majoration de delai |
362 |
|
|
return $this->valF[$temp[0]]+$this->valF[$temp[1]]; |
363 |
|
|
// cas general 2 dimensions |
364 |
fraynaud |
123 |
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 |
fraynaud |
124 |
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 |
fraynaud |
123 |
} |
381 |
|
|
|
382 |
|
|
|
383 |
|
|
|
384 |
fraynaud |
20 |
// ================================================================== |
385 |
|
|
// valeur dossier apres modification [values dossier after action] |
386 |
|
|
// ================================================================== |
387 |
|
|
function triggerajouterapres($id,&$db,$val,$DEBUG) { |
388 |
fraynaud |
47 |
// mise a null au lieu de "" / voir compatibilite mysql |
389 |
|
|
// voir parametrage CU en dur |
390 |
|
|
// voir parametrage des actions en dur |
391 |
fraynaud |
123 |
$param=1; |
392 |
fraynaud |
121 |
if($param==1){ |
393 |
|
|
$sql="select * from 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 |
fraynaud |
123 |
$valF['etat']= $this->regle($row['regle_etat']); |
400 |
fraynaud |
121 |
} |
401 |
|
|
if($row['regle_delai']!=''){ |
402 |
fraynaud |
123 |
$valF['delai']= $this->regle($row['regle_delai']); |
403 |
fraynaud |
121 |
} |
404 |
|
|
if($row['regle_accord_tacite']!=''){ |
405 |
fraynaud |
123 |
$valF['accord_tacite']= $this->regle($row['regle_accord_tacite']); |
406 |
fraynaud |
121 |
} |
407 |
fraynaud |
124 |
if($row['regle_avis']!=''){ |
408 |
|
|
$valF['avis']= $this->regle($row['regle_avis']); |
409 |
|
|
} |
410 |
fraynaud |
121 |
if($row['regle_date_limite']!=''){ |
411 |
fraynaud |
123 |
$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 |
fraynaud |
124 |
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 |
fraynaud |
121 |
} |
438 |
|
|
}else{ |
439 |
fraynaud |
20 |
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 |
fraynaud |
121 |
$valF['date_complet']= $this->archive_date_depot; // **** |
446 |
fraynaud |
20 |
$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 |
fraynaud |
47 |
$valF['date_limite'] =null; |
481 |
|
|
$valF['date_notification_delai'] =null; |
482 |
|
|
$valF['date_complet']=null; |
483 |
fraynaud |
20 |
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 |
fraynaud |
47 |
//echo $this->msg=$this->msg.$valF['date_chantier'].""; |
526 |
fraynaud |
20 |
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 |
fraynaud |
47 |
|
536 |
|
|
default: |
537 |
fraynaud |
20 |
if ($this->valF['etat']!="") |
538 |
|
|
$valF['etat']= $this->valF['etat']; |
539 |
|
|
}// end switch |
540 |
fraynaud |
121 |
} // end param |
541 |
fraynaud |
20 |
// mise à jour dossier [modify dossier] |
542 |
atreal |
208 |
//if($param==1){ // parametrage en table |
543 |
|
|
// echo "<br>"; |
544 |
|
|
// print_r($valF); |
545 |
|
|
//} |
546 |
fraynaud |
20 |
if($valF!=""){ |
547 |
|
|
$cle= " dossier = '".$this->valF['dossier']."'"; |
548 |
|
|
$res1= $db->autoExecute('dossier',$valF,DB_AUTOQUERY_UPDATE,$cle); |
549 |
|
|
if (database::isError($res1)) |
550 |
|
|
die($res->getMessage()); |
551 |
|
|
if ($DEBUG == 1) |
552 |
|
|
echo "La requête de mise à jour est effectuée.<br>"; |
553 |
|
|
$this->msg=$this->msg."<br>"._('enregistrement')." ". |
554 |
|
|
$this->valF['dossier']." "._('table')." dossier [". |
555 |
|
|
$db->affectedRows()." "._('enregistrement'). |
556 |
|
|
" "._('mis_a_jour')."]" ; |
557 |
|
|
} |
558 |
|
|
} |
559 |
fraynaud |
129 |
|
560 |
|
|
function triggermodifierapres($id,&$db,$val,$DEBUG) { |
561 |
|
|
/* |
562 |
|
|
* cette fonction apour objet de permettre de modifier la date courrier |
563 |
|
|
*/ |
564 |
|
|
$valF=array(); |
565 |
|
|
$sql= "select action from evenement where evenement =".$this->valF['evenement']; |
566 |
|
|
$action = $db->getOne($sql); |
567 |
|
|
if (database::isError($action)) die($action->getMessage().$sql); |
568 |
|
|
$sql="select * from action where action = '".$action."'"; |
569 |
|
|
$res = $db->query($sql); |
570 |
|
|
if (database::isError($res)) die($res->getMessage().$sql); |
571 |
|
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
572 |
|
|
// application des regles sur le courrier + delai |
573 |
|
|
if(preg_match("/datecourrier/",$row['regle_date_limite'])){ |
574 |
|
|
$valF['date_limite']= $this->regle($row['regle_date_limite']); |
575 |
|
|
} |
576 |
|
|
if(preg_match("/datecourrier/",$row['regle_date_complet'])){ |
577 |
|
|
$valF['date_complet']= $this->regle($row['regle_date_complet']); |
578 |
|
|
} |
579 |
|
|
if(preg_match("/datecourrier/",$row['regle_date_notification_delai'])){ |
580 |
|
|
$valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']); |
581 |
|
|
} |
582 |
|
|
if(preg_match("/datecourrier/",$row['regle_date_decision'])){ |
583 |
|
|
$valF['date_decision']= $this->regle($row['regle_date_decision']); |
584 |
|
|
} |
585 |
|
|
if(preg_match("/datecourrier/",$row['regle_date_rejet'])){ |
586 |
|
|
$valF['date_rejet']= $this->regle($row['regle_date_rejet']); |
587 |
|
|
} |
588 |
|
|
if(preg_match("/datecourrier/",$row['regle_date_validite'])){ |
589 |
|
|
$valF['date_validite']= $this->regle($row['regle_date_validite']); |
590 |
|
|
} |
591 |
|
|
if(preg_match("/datecourrier/",$row['regle_date_chantier'])){ |
592 |
|
|
$valF['date_chantier']= $this->regle($row['regle_date_chantier']); |
593 |
|
|
} |
594 |
|
|
if(preg_match("/datecourrier/",$row['regle_date_achevement'])){ |
595 |
|
|
$valF['date_achevement']= $this->regle($row['regle_date_achevement']); |
596 |
|
|
} |
597 |
|
|
if(preg_match("/datecourrier/",$row['regle_date_conformite'])){ |
598 |
|
|
$valF['date_conformite']= $this->regle($row['regle_date_conformite']); |
599 |
|
|
} |
600 |
|
|
} // while |
601 |
|
|
if($valF!=array()){ |
602 |
|
|
$cle= " dossier = '".$this->valF['dossier']."'"; |
603 |
|
|
$res1= $db->autoExecute('dossier',$valF,DB_AUTOQUERY_UPDATE,$cle); |
604 |
|
|
if (database::isError($res1)) |
605 |
|
|
die($res->getMessage()); |
606 |
|
|
if ($DEBUG == 1) |
607 |
|
|
echo "La requête de mise à jour est effectuée.<br>"; |
608 |
|
|
$this->msg=$this->msg."<br>"._('enregistrement')." ". |
609 |
|
|
$this->valF['dossier']." "._('table')." dossier [". |
610 |
|
|
$db->affectedRows()." "._('enregistrement'). |
611 |
|
|
" "._('mis_a_jour')."]" ; |
612 |
|
|
} |
613 |
|
|
} |
614 |
|
|
|
615 |
|
|
|
616 |
fraynaud |
20 |
|
617 |
|
|
// trigger before delete |
618 |
|
|
function triggersupprimer($id,&$db,$val,$DEBUG) { |
619 |
|
|
// archive en instruction (si suppression) [archive if delete instruction] |
620 |
|
|
$valF['delai']=$val['archive_delai']; |
621 |
|
|
$valF['accord_tacite']=$val['archive_accord_tacite']; |
622 |
|
|
$valF['etat']=$val['archive_etat']; |
623 |
fraynaud |
80 |
if($val['archive_avis']=='') |
624 |
|
|
$valF['avis']= null; |
625 |
|
|
else |
626 |
|
|
$valF['avis']=$val['archive_avis']; |
627 |
fraynaud |
20 |
// if= compatibilite pgsql |
628 |
|
|
if($val['archive_date_complet']!='') |
629 |
|
|
$valF['date_complet']=$val['archive_date_complet']; |
630 |
|
|
if($val['archive_date_rejet']!='') |
631 |
|
|
$valF['date_rejet']= $val['archive_date_rejet']; |
632 |
|
|
if($val['archive_date_limite']!='') |
633 |
|
|
$valF['date_limite']= $val['archive_date_limite']; |
634 |
|
|
if($val['archive_date_notification_delai']!='') |
635 |
|
|
$valF['date_notification_delai']= $val['archive_date_notification_delai']; |
636 |
|
|
if($val['archive_date_decision']!='') |
637 |
|
|
$valF['date_decision']= $val['archive_date_decision']; |
638 |
|
|
if($val['archive_date_validite']!='') |
639 |
|
|
$valF['date_validite']= $val['archive_date_validite']; |
640 |
|
|
if($val['archive_date_achevement']!='') |
641 |
|
|
$valF['date_achevement']= $val['archive_date_achevement']; |
642 |
|
|
if($val['archive_date_chantier']!='') |
643 |
|
|
$valF['date_chantier']= $val['archive_date_chantier']; |
644 |
|
|
if($val['archive_date_conformite']!='') |
645 |
|
|
$valF['date_conformite']= $val['archive_date_conformite']; |
646 |
fraynaud |
80 |
|
647 |
fraynaud |
20 |
$cle= " dossier = '".$val['dossier']."'"; |
648 |
|
|
$res= $db->autoExecute('dossier',$valF,DB_AUTOQUERY_UPDATE,$cle); |
649 |
|
|
if (database::isError($res)) |
650 |
|
|
die($res->getMessage()); |
651 |
|
|
else{ |
652 |
|
|
if ($DEBUG == 1) |
653 |
|
|
echo "La requête de mise à jour est effectuée.<br>"; |
654 |
|
|
} |
655 |
|
|
} |
656 |
|
|
// ============================================= |
657 |
|
|
// calcul de date avec ajout de mois (delais) |
658 |
|
|
// [add months (delay) and calculation final date] |
659 |
|
|
// LIMITE DE LA FONCTION si delai >24 MOIS |
660 |
|
|
// [limit : delay < 24 month] |
661 |
|
|
// ============================================= |
662 |
|
|
function moisdate($date,$delaimois) { |
663 |
|
|
$temp = explode("-" , $date); |
664 |
|
|
$jour = (int) $temp[2]; |
665 |
|
|
$mois = (int) $temp[1]; |
666 |
|
|
$annee = (int) $temp[0]; |
667 |
|
|
// calcul si delai superieur à 12 (limite 24) [delay > 24 month] |
668 |
|
|
if($delaimois>=12){ |
669 |
|
|
$delaimois=$delaimois-12; |
670 |
|
|
$annee=$annee+1; |
671 |
|
|
} |
672 |
|
|
if($delaimois>=12){ |
673 |
|
|
$delaimois=$delaimois-12; |
674 |
|
|
$annee=$annee+1; |
675 |
|
|
} |
676 |
|
|
// mois |
677 |
|
|
$mois=$mois+$delaimois; |
678 |
|
|
// calcul mois annee [calculation number of years if > 12 month] |
679 |
|
|
// nb de mois > à 12 |
680 |
|
|
if ($mois>12){ |
681 |
|
|
$mois=$mois-12; |
682 |
|
|
$annee=$annee+1; |
683 |
|
|
} |
684 |
|
|
// Calcul du nombre de jours dans le mois sélectionné [calculation number of days] |
685 |
|
|
switch($mois) { |
686 |
|
|
case "2": |
687 |
|
|
if ($annee % 4 == 0 && $annee % 100 != 0 || $annee % 400 == 0) |
688 |
|
|
$jourmax = 29; |
689 |
|
|
else |
690 |
|
|
$jourmax = 28; |
691 |
|
|
break; |
692 |
|
|
case "4": |
693 |
|
|
case "6": |
694 |
|
|
case "9": |
695 |
|
|
case "11": |
696 |
|
|
$jourmax = 30; |
697 |
|
|
break; |
698 |
|
|
default: |
699 |
|
|
$jourmax = 31; |
700 |
|
|
} |
701 |
|
|
if ($jour > $jourmax) |
702 |
|
|
$jour = $jourmax; |
703 |
|
|
//$dateretour=$annee."-".$mois."-".$jour; |
704 |
|
|
return $annee."-".$mois."-".$jour ; |
705 |
|
|
} |
706 |
|
|
|
707 |
fraynaud |
3 |
}// fin classe |
708 |
atreal |
208 |
?> |