1 |
<?php |
2 |
//$Id$ |
3 |
//gen openMairie le 18/10/2010 16:23 |
4 |
require_once ("../gen/obj/om_etat.class.php"); |
5 |
|
6 |
class om_etat extends om_etat_gen { |
7 |
|
8 |
var $maj; |
9 |
var $retourformulaire; |
10 |
|
11 |
function om_etat($id,&$db,$debug) { |
12 |
$this->constructeur($id,$db,$debug); |
13 |
}// fin constructeur |
14 |
|
15 |
function verifier($val, &$db, $DEBUG) { |
16 |
parent::verifier($val, $db, $DEBUG); |
17 |
$f=" ! "; |
18 |
$imgv="<img src='../app/img/punaise.png' style='vertical-align:middle' hspace='2' border='0'>"; |
19 |
if ($this->valF['id']==""){ |
20 |
$this->msg= $this->msg.$imgv._('identifiant')." "._('obligatoire').$f; |
21 |
$this->correct=False; |
22 |
}else |
23 |
// verification si il y a un autre id "actif" pour la collectivite |
24 |
if($this->valF['actif']=="Oui") |
25 |
if($this->maj==0) |
26 |
$this->verifieractif($db, $val, $DEBUG,']'); |
27 |
else |
28 |
$this->verifieractif($db, $val, $DEBUG,$val['om_etat']); |
29 |
} |
30 |
|
31 |
/** |
32 |
* |
33 |
*/ |
34 |
function setType(&$form,$maj) { |
35 |
parent :: setType($form,$maj); |
36 |
$form->setType('image', 'hidden'); |
37 |
if ($maj < 2) { //ajouter et modifier |
38 |
$form->setType('actif', 'checkbox'); |
39 |
$form->setType('orientation', 'select'); |
40 |
$form->setType('format', 'select'); |
41 |
$form->setType('titreattribut', 'select'); |
42 |
$form->setType('corpsattribut', 'select'); |
43 |
$form->setType('footerattribut', 'select'); |
44 |
$form->setType('titrefont', 'select'); |
45 |
$form->setType('corpsfont', 'select'); |
46 |
$form->setType('footerfont', 'select'); |
47 |
$form->setType('se_font', 'select'); |
48 |
$form->setType('titrealign', 'select'); |
49 |
$form->setType('corpsalign', 'select'); |
50 |
$form->setType('titrebordure', 'select'); |
51 |
$form->setType('corpsbordure', 'select'); |
52 |
$form->setType('titre', 'textarea'); |
53 |
$form->setType('corps', 'textarea'); |
54 |
$form->setType('sql', 'textarea'); |
55 |
$form->setType('om_sousetat', 'select'); |
56 |
$form->setType('sousetat', 'textareamulti'); |
57 |
if($this->retourformulaire=='om_collectivite'){ |
58 |
$form->setType('logotop', 'localisation2'); |
59 |
$form->setType('titretop', 'localisation2'); |
60 |
$form->setType('corpstop', 'localisation2'); |
61 |
$form->setType('se_couleurtexte', 'rvb2'); |
62 |
$form->setType('logo', 'upload2'); |
63 |
}else{ |
64 |
$form->setType('logotop', 'localisation'); |
65 |
$form->setType('titretop', 'localisation'); |
66 |
$form->setType('corpstop', 'localisation'); |
67 |
$form->setType('se_couleurtexte', 'rvb'); |
68 |
$form->setType('logo', 'upload'); |
69 |
} |
70 |
} |
71 |
} |
72 |
|
73 |
function setTaille(&$form, $maj) { |
74 |
parent :: setTaille($form, $maj); |
75 |
$form->setTaille('sousetat', 50); |
76 |
$form->setTaille('corps', 120); |
77 |
$form->setTaille('om_sql', 120); |
78 |
$form->setTaille('id', 20); |
79 |
$form->setTaille('libelle', 20); |
80 |
} |
81 |
|
82 |
function setMax(&$form, $maj) { |
83 |
parent :: setMax($form, $maj); |
84 |
$form->setMax('sousetat', 8); |
85 |
$form->setMax('corps', 30); |
86 |
$form->setMax('om_sql', 5); |
87 |
} |
88 |
|
89 |
|
90 |
/** |
91 |
* |
92 |
*/ |
93 |
function setSelect(&$form, $maj, $db, $debug) { |
94 |
parent :: setSelect($form, $maj, $db, $debug); |
95 |
// |
96 |
$contenu=array(); |
97 |
$contenu[0]=array('P','L'); |
98 |
$contenu[1]=array(_("portrait"),_("paysage")); |
99 |
$form->setSelect("orientation",$contenu); |
100 |
// |
101 |
$contenu=array(); |
102 |
$contenu[0]=array('A4','A3'); |
103 |
$contenu[1]=array('A4','A3'); |
104 |
$form->setSelect("format",$contenu); |
105 |
// |
106 |
$contenu=array(); |
107 |
$contenu[0]=array('','I','B','U','BI','UI'); |
108 |
$contenu[1]=array(_("normal"),_("italique"),_("gras"),_("souligne"),_("italique")." "._("gras"),_("souligne")." "._("gras")); |
109 |
$form->setSelect("titreattribut",$contenu); |
110 |
$form->setSelect("corpsattribut",$contenu); |
111 |
$form->setSelect("footerattribut",$contenu); |
112 |
// |
113 |
$contenu=array(); |
114 |
$contenu[0]=array('helvetica','times','arial','courier'); |
115 |
$contenu[1]=array('helvetica','times','arial','courier'); |
116 |
$form->setSelect("titrefont",$contenu); |
117 |
$form->setSelect("corpsfont",$contenu); |
118 |
$form->setSelect("footerfont",$contenu); |
119 |
$form->setSelect("se_font",$contenu); |
120 |
// |
121 |
$contenu=array(); |
122 |
$contenu[0]=array('L','R','J','C'); |
123 |
$contenu[1]=array(_("gauche"),_("droite"),_("justifie"),_("centre")); |
124 |
$form->setSelect("titrealign",$contenu); |
125 |
$form->setSelect("corpsalign",$contenu); |
126 |
// |
127 |
$contenu=array(); |
128 |
$contenu[0]=array('0','1'); |
129 |
$contenu[1]=array(_("sans"),_("avec")); |
130 |
$form->setSelect("titrebordure",$contenu); |
131 |
$form->setSelect("corpsbordure",$contenu); |
132 |
// position geographique |
133 |
$contenu=array(); |
134 |
$contenu[0]=array('image','logoleft'); |
135 |
$form->setSelect("logotop",$contenu); |
136 |
$contenu=array(); |
137 |
$contenu[0]=array('image','titreleft'); |
138 |
$form->setSelect("titretop",$contenu); |
139 |
$contenu=array(); |
140 |
$contenu[0]=array('image','corpsleft'); |
141 |
$form->setSelect("corpstop",$contenu); |
142 |
|
143 |
// parametre textareamulti |
144 |
$contenu=array(); |
145 |
$contenu[0] ="om_sousetat"; |
146 |
$form->setSelect("sousetat",$contenu); |
147 |
|
148 |
// om_sousetat |
149 |
if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc")) |
150 |
include ("../sql/".$db->phptype."/".$this->table.".form.inc"); |
151 |
$contenu=array(); |
152 |
$res = $db->query($sql_om_sousetat); |
153 |
if (database::isError($res)) |
154 |
die($res->getMessage().$sql_om_sousetat); |
155 |
else{ |
156 |
if ($debug == 1) |
157 |
echo " la requete ".$sql_om_sousetat." est executee<br>"; |
158 |
$contenu[0][0]=''; |
159 |
$contenu[1][0]=_('choisir')." "._('om_sousetat'); |
160 |
$k=1; |
161 |
while ($row=& $res->fetchRow()){ |
162 |
$contenu[0][$k]=$row[0]; |
163 |
$contenu[1][$k]=$row[1]; |
164 |
$k++; |
165 |
} |
166 |
$form->setSelect('om_sousetat',$contenu); |
167 |
} |
168 |
} |
169 |
|
170 |
/** |
171 |
* |
172 |
*/ |
173 |
function setRegroupe(&$form, $maj) { |
174 |
|
175 |
$form->setRegroupe('om_collectivite','D',_('om_collectivite'), "collapsible"); |
176 |
$form->setRegroupe('id','G',''); |
177 |
$form->setRegroupe('libelle','G',''); |
178 |
$form->setRegroupe('actif','F',''); |
179 |
|
180 |
$form->setRegroupe('orientation', 'D', _("Parametres generaux du document"), "startClosed"); |
181 |
$form->setRegroupe('format','G',''); |
182 |
$form->setRegroupe('footerfont','G',''); |
183 |
$form->setRegroupe('footerattribut','G',''); |
184 |
$form->setRegroupe('footertaille','G',''); |
185 |
$form->setRegroupe('logo','G',''); |
186 |
$form->setRegroupe('logoleft','G',''); |
187 |
$form->setRegroupe('logotop','F',''); |
188 |
|
189 |
$form->setRegroupe('titreleft','D',_("Parametres du titre du document"), "startClosed"); |
190 |
$form->setRegroupe('titretop','G',''); |
191 |
$form->setRegroupe('titrelargeur','G',''); |
192 |
$form->setRegroupe('titrehauteur','G',''); |
193 |
$form->setRegroupe('titrefont','G',''); |
194 |
$form->setRegroupe('titreattribut','G',''); |
195 |
$form->setRegroupe('titretaille','G',''); |
196 |
$form->setRegroupe('titrebordure','G',''); |
197 |
$form->setRegroupe('titrealign','F',''); |
198 |
|
199 |
$form->setRegroupe('corpsleft','D',_("Parametres du corps du document"), "startClosed"); |
200 |
$form->setRegroupe('corpstop','G',''); |
201 |
$form->setRegroupe('corpslargeur','G',''); |
202 |
$form->setRegroupe('corpshauteur','G',''); |
203 |
$form->setRegroupe('corpsfont','G',''); |
204 |
$form->setRegroupe('corpsattribut','G',''); |
205 |
$form->setRegroupe('corpstaille','G',''); |
206 |
$form->setRegroupe('corpsbordure','G',''); |
207 |
$form->setRegroupe('corpsalign','F',''); |
208 |
|
209 |
$form->setRegroupe('om_sousetat','D', _("Sous etat(s) : selection"), "startClosed"); |
210 |
$form->setRegroupe('sousetat','F', ''); |
211 |
|
212 |
|
213 |
$form->setRegroupe('se_font','D', _("Sous etat(s) : police / marges / couleur"), "startClosed"); |
214 |
$form->setRegroupe('se_margeleft','G',''); |
215 |
$form->setRegroupe('se_margetop','G',''); |
216 |
$form->setRegroupe('se_margeright','G',''); |
217 |
$form->setRegroupe('se_couleurtexte','F',''); |
218 |
|
219 |
} |
220 |
|
221 |
/** |
222 |
* |
223 |
*/ |
224 |
function setGroupe(&$form, $maj) { |
225 |
|
226 |
$form->setGroupe('om_collectivite','D'); |
227 |
$form->setGroupe('id','G'); |
228 |
$form->setGroupe('libelle','G'); |
229 |
$form->setGroupe('actif','F'); |
230 |
|
231 |
$form->setGroupe('orientation','D'); |
232 |
$form->setGroupe('format','F'); |
233 |
|
234 |
$form->setGroupe('footerfont','D'); |
235 |
$form->setGroupe('footerattribut','G'); |
236 |
$form->setGroupe('footertaille','F'); |
237 |
|
238 |
$form->setGroupe('logo','D'); |
239 |
$form->setGroupe('logoleft','G'); |
240 |
$form->setGroupe('logotop','F'); |
241 |
|
242 |
$form->setGroupe('titreleft','D'); |
243 |
$form->setGroupe('titretop','G'); |
244 |
$form->setGroupe('titrelargeur','G'); |
245 |
$form->setGroupe('titrehauteur','F'); |
246 |
|
247 |
$form->setGroupe('titrefont','D'); |
248 |
$form->setGroupe('titreattribut','G'); |
249 |
$form->setGroupe('titretaille','G'); |
250 |
$form->setGroupe('titrebordure','G'); |
251 |
$form->setGroupe('titrealign','F'); |
252 |
|
253 |
$form->setGroupe('corpsleft','D'); |
254 |
$form->setGroupe('corpstop','G'); |
255 |
$form->setGroupe('corpslargeur','G'); |
256 |
$form->setGroupe('corpshauteur','F'); |
257 |
|
258 |
$form->setGroupe('corpsfont','D'); |
259 |
$form->setGroupe('corpsattribut','G'); |
260 |
$form->setGroupe('corpstaille','G'); |
261 |
$form->setGroupe('corpsbordure','G'); |
262 |
$form->setGroupe('corpsalign','F'); |
263 |
|
264 |
$form->setGroupe('om_sousetat','D'); |
265 |
$form->setGroupe('sousetat','F'); |
266 |
|
267 |
$form->setGroupe('se_font','D'); |
268 |
$form->setGroupe('se_margeleft','G'); |
269 |
$form->setGroupe('se_margetop','G'); |
270 |
$form->setGroupe('se_margeright','G'); |
271 |
$form->setGroupe('se_couleurtexte','F'); |
272 |
|
273 |
} |
274 |
|
275 |
/** |
276 |
* |
277 |
*/ |
278 |
function setLib(&$form, $maj) { |
279 |
|
280 |
$form->setLib('footerattribut',_('mise_en_forme')." "._('du')." "._('texte')); |
281 |
$form->setLib('titreleft',_('left')); |
282 |
$form->setLib('titretop',_('top')); |
283 |
$form->setLib('titrelargeur',_('largeur')); |
284 |
$form->setLib('titrehauteur',_('hauteur')); |
285 |
$form->setLib('titrefont',_('font')); |
286 |
$form->setLib('titreattribut',_('mise_en_forme')." "._('du')." "._('texte')); |
287 |
$form->setLib('titretaille',_('taille')); |
288 |
$form->setLib('titrebordure',_('bordure')); |
289 |
$form->setLib('titrealign',''); |
290 |
|
291 |
$form->setLib('titre',_('titre')); |
292 |
|
293 |
$form->setLib('corps',_('corps')); |
294 |
$form->setLib('corpsleft',_('left')); |
295 |
$form->setLib('corpstop',_('top')); |
296 |
|
297 |
$form->setLib('corpslargeur',_('largeur')); |
298 |
$form->setLib('corpshauteur',_('hauteur')); |
299 |
$form->setLib('corpsfont',_('font')); |
300 |
$form->setLib('corpsattribut',_('mise_en_forme')." "._('du')." "._('texte')); |
301 |
$form->setLib('corpstaille',_('taille')); |
302 |
$form->setLib('corpsbordure',_('bordure')); |
303 |
$form->setLib('corpsalign',''); |
304 |
|
305 |
$form->setLib('om_sousetat',_('sous_etat')); |
306 |
$form->setLib('sousetat',''); |
307 |
$form->setLib('se_font',_('font')); |
308 |
$form->setLib('se_margeleft',_('marges')." "._('left')); |
309 |
$form->setLib('se_margetop',_('marges')." "._('haute')); |
310 |
$form->setLib('se_margeright',_('marges')." "._('droite')); |
311 |
$form->setLib('se_couleurtexte',_('couleur')); |
312 |
|
313 |
} |
314 |
|
315 |
/** |
316 |
* |
317 |
*/ |
318 |
function setVal(&$form, $maj, $validation, &$db, $DEBUG=null) { |
319 |
parent::setVal($form, $maj, $validation, $db, $DEBUG=null); |
320 |
$this->maj=$maj; |
321 |
if ($validation == 0) { |
322 |
if ($maj == 0) { |
323 |
// ======================= a rajouter au generateur =========== |
324 |
//if($_SESSION['niveau']==1) |
325 |
// $form->setVal('om_collectivite', $_SESSION['collectivite']); |
326 |
// ============================================================= |
327 |
$form->setVal('orientation','P'); |
328 |
$form->setVal('format','A4'); |
329 |
$form->setVal('footerfont','helvetica'); |
330 |
$form->setVal('footerattribut','I'); |
331 |
$form->setVal('footertaille',8); |
332 |
$form->setVal('logo','logopdf.png'); |
333 |
$form->setVal('logoleft', 10); |
334 |
$form->setVal('logotop', 10); |
335 |
$form->setVal('titre',_("Texte du titre")); |
336 |
$form->setVal('titreleft',109); |
337 |
$form->setVal('titretop',16); |
338 |
$form->setVal('titrelargeur',0); |
339 |
$form->setVal('titrehauteur',10); |
340 |
$form->setVal('titrefont','arial'); |
341 |
$form->setVal('titreattribut','B'); |
342 |
$form->setVal('titretaille',20); |
343 |
$form->setVal('titrebordure',0); |
344 |
$form->setVal('titrealign','L'); |
345 |
$form->setVal('corps',_("Texte du corps")); |
346 |
$form->setVal('corpsleft',14); |
347 |
$form->setVal('corpstop',66); |
348 |
$form->setVal('corpslargeur',110); |
349 |
$form->setVal('corpshauteur',5); |
350 |
$form->setVal('corpsfont','times'); |
351 |
$form->setVal('corpsattribut',''); |
352 |
$form->setVal('corpstaille',10); |
353 |
$form->setVal('corpsbordure',0); |
354 |
$form->setVal('corpsalign','J'); |
355 |
$form->setVal('om_sql',' select ... from ... where ... = &idx'); |
356 |
$form->setVal('sousetat',''); |
357 |
$form->setVal('se_font','helvetica'); |
358 |
$form->setVal('se_margeleft',8); |
359 |
$form->setVal('se_margetop',5); |
360 |
$form->setVal('se_margeright',5); |
361 |
$form->setVal('se_couleurtexte','0-0-0'); |
362 |
} |
363 |
|
364 |
|
365 |
|
366 |
} |
367 |
|
368 |
} |
369 |
function setValsousformulaire(&$form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire, &$db, $DEBUG=null) { |
370 |
$this->maj=$maj; |
371 |
$this->retourformulaire=$retourformulaire; |
372 |
if ($validation==0) { |
373 |
if ($maj == 0){ |
374 |
$form->setVal($retourformulaire, $idxformulaire); |
375 |
$form->setVal('orientation','P'); |
376 |
$form->setVal('format','A4'); |
377 |
$form->setVal('footerfont','helvetica'); |
378 |
$form->setVal('footerattribut','I'); |
379 |
$form->setVal('footertaille',8); |
380 |
$form->setVal('logo','logopdf.png'); |
381 |
$form->setVal('logoleft', 10); |
382 |
$form->setVal('logotop', 10); |
383 |
$form->setVal('titre',_("Texte du titre")); |
384 |
$form->setVal('titreleft',109); |
385 |
$form->setVal('titretop',16); |
386 |
$form->setVal('titrelargeur',0); |
387 |
$form->setVal('titrehauteur',10); |
388 |
$form->setVal('titrefont','arial'); |
389 |
$form->setVal('titreattribut','B'); |
390 |
$form->setVal('titretaille',20); |
391 |
$form->setVal('titrebordure',0); |
392 |
$form->setVal('titrealign','L'); |
393 |
$form->setVal('corps',_("Texte du corps")); |
394 |
$form->setVal('corpsleft',14); |
395 |
$form->setVal('corpstop',66); |
396 |
$form->setVal('corpslargeur',110); |
397 |
$form->setVal('corpshauteur',5); |
398 |
$form->setVal('corpsfont','times'); |
399 |
$form->setVal('corpsattribut',''); |
400 |
$form->setVal('corpstaille',10); |
401 |
$form->setVal('corpsbordure',0); |
402 |
$form->setVal('corpsalign','J'); |
403 |
$form->setVal('om_sql',' select ... from ... where ... = &idx'); |
404 |
$form->setVal('sousetat',''); |
405 |
$form->setVal('se_font','helvetica'); |
406 |
$form->setVal('se_margeleft',8); |
407 |
$form->setVal('se_margetop',5); |
408 |
$form->setVal('se_margeright',5); |
409 |
$form->setVal('se_couleurtexte','0-0-0'); |
410 |
}} |
411 |
} |
412 |
|
413 |
/** |
414 |
* verification sur existence d un etat deja actif pour la collectivite |
415 |
*/ |
416 |
function verifieractif(&$db, $val, $DEBUG,$id){ |
417 |
$sql = "select om_etat from ".DB_PREFIXE."om_etat where id ='".$val['id']."'"; |
418 |
$sql.= " and om_collectivite ='".$val['om_collectivite']."'"; |
419 |
$sql.= " and actif ='Oui'"; |
420 |
if($id!=']') |
421 |
$sql.=" and om_etat !='".$id."'"; |
422 |
$res = $db->query($sql); |
423 |
if($DEBUG==1) echo $sql; |
424 |
if (database::isError($res)) |
425 |
die($res->getMessage(). " => Echec ".$sql); |
426 |
else{ |
427 |
$nbligne=$res->numrows(); |
428 |
if ($nbligne>0){ |
429 |
$this->msg= $this->msg." ".$nbligne." "._("etat")." "._("existant"). |
430 |
" "._("actif")." ! "._("vous ne pouvez avoir qu un etat")." '". |
431 |
$val['id']."' "._("actif")." "._("par collectivite"); |
432 |
$this->correct=False; |
433 |
} |
434 |
} |
435 |
} |
436 |
|
437 |
}// fin classe |
438 |
?> |