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