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