1 |
<?php |
2 |
/** |
3 |
* |
4 |
* |
5 |
* @package openmairie |
6 |
* @version SVN : $Id: om_etat.class.php 2152 2013-03-11 12:14:10Z fmichon $ |
7 |
*/ |
8 |
|
9 |
require_once "../gen/obj/om_etat.class.php"; |
10 |
|
11 |
class om_etat extends om_etat_gen { |
12 |
|
13 |
function om_etat($id, &$db, $debug) { |
14 |
$this->constructeur($id, $db, $debug); |
15 |
} |
16 |
|
17 |
function setOnchange(&$form, $maj) { |
18 |
// |
19 |
parent::setOnchange($form, $maj); |
20 |
// |
21 |
if ($this->getParameter("maj") == 1) { |
22 |
$form->setOnchange('om_sql','warn_user_query_change(form)'); |
23 |
} |
24 |
} |
25 |
|
26 |
function setLib(&$form, $maj) { |
27 |
// |
28 |
parent::setLib($form, $maj); |
29 |
// Ajout du libellé poour que la traduction soit prise en compte |
30 |
$form->setLib('merge_fields', _("merge_fields")); |
31 |
} |
32 |
|
33 |
function setType(&$form, $maj) { |
34 |
// |
35 |
parent::setType($form, $maj); |
36 |
// |
37 |
$form->setType('merge_fields', 'textareastatic'); |
38 |
// |
39 |
if ($maj == 0) { |
40 |
$form->setType('merge_fields', 'hidden'); |
41 |
} |
42 |
// ajouter et modifier |
43 |
if ($maj == 0 || $maj == 1) { |
44 |
// |
45 |
$form->setType('orientation', 'select'); |
46 |
$form->setType('format', 'select'); |
47 |
$form->setType('titreattribut', 'select'); |
48 |
$form->setType('corpsattribut', 'select'); |
49 |
$form->setType('titrefont', 'select'); |
50 |
$form->setType('corpsfont', 'select'); |
51 |
$form->setType('titrealign', 'select'); |
52 |
$form->setType('corpsalign', 'select'); |
53 |
$form->setType('titrebordure', 'select'); |
54 |
$form->setType('corpsbordure', 'select'); |
55 |
// |
56 |
$form->setType('logo', 'select'); |
57 |
// |
58 |
$form->setType('sousetat', 'select_multiple'); |
59 |
$form->setType('se_font', 'select'); |
60 |
$form->setType('se_couleurtexte', 'rvb'); |
61 |
// |
62 |
$form->setType('logotop', 'localisation_edition'); |
63 |
$form->setType('titretop', 'localisation_edition'); |
64 |
$form->setType('corpstop', 'localisation_edition'); |
65 |
} |
66 |
// supprimer et consulter |
67 |
if ($maj == 2 or $maj == 3) { |
68 |
// |
69 |
$form->setType('orientation', 'selectstatic'); |
70 |
$form->setType('format', 'selectstatic'); |
71 |
$form->setType('titreattribut', 'selectstatic'); |
72 |
$form->setType('corpsattribut', 'selectstatic'); |
73 |
$form->setType('titrefont', 'selectstatic'); |
74 |
$form->setType('corpsfont', 'selectstatic'); |
75 |
$form->setType('titrealign', 'selectstatic'); |
76 |
$form->setType('corpsalign', 'selectstatic'); |
77 |
$form->setType('titrebordure', 'selectstatic'); |
78 |
$form->setType('corpsbordure', 'selectstatic'); |
79 |
// |
80 |
$form->setType('logo', 'selectstatic'); |
81 |
// |
82 |
$form->setType('sousetat', 'select_multiple_static'); |
83 |
$form->setType('se_font', 'selectstatic'); |
84 |
} |
85 |
} |
86 |
|
87 |
function setSelect(&$form, $maj, &$db, $debug) { |
88 |
// |
89 |
parent::setSelect($form, $maj, $db, $debug); |
90 |
// |
91 |
$contenu = array(); |
92 |
$contenu[0] = array('P', 'L'); |
93 |
$contenu[1] = array(_('portrait'), _('paysage')); |
94 |
$form->setSelect('orientation', $contenu); |
95 |
// |
96 |
$contenu = array(); |
97 |
$contenu[0] = array('A4', 'A3'); |
98 |
$contenu[1] = array('A4', 'A3'); |
99 |
$form->setSelect('format', $contenu); |
100 |
// |
101 |
$contenu = array(); |
102 |
$contenu[0] = array('', 'I', 'B', 'U', 'BI', 'UI'); |
103 |
$contenu[1] = array(_('normal'), _('italique'), _('gras'), _('souligne'), _('italique').' '._('gras'), _('souligne').' '._('gras')); |
104 |
$form->setSelect('titreattribut', $contenu); |
105 |
$form->setSelect('corpsattribut', $contenu); |
106 |
$form->setSelect('footerattribut', $contenu); |
107 |
// |
108 |
$contenu = array(); |
109 |
$contenu[0] = array('helvetica', 'times', 'arial', 'courier'); |
110 |
$contenu[1] = array('helvetica', 'times', 'arial', 'courier'); |
111 |
$form->setSelect('titrefont', $contenu); |
112 |
$form->setSelect('corpsfont', $contenu); |
113 |
$form->setSelect('footerfont', $contenu); |
114 |
$form->setSelect('se_font', $contenu); |
115 |
// |
116 |
$contenu = array(); |
117 |
$contenu[0] = array('L', 'R', 'J', 'C'); |
118 |
$contenu[1] = array(_('gauche'), _('droite'), _('justifie'), _('centre')); |
119 |
$form->setSelect('titrealign', $contenu); |
120 |
$form->setSelect('corpsalign', $contenu); |
121 |
// |
122 |
$contenu = array(); |
123 |
$contenu[0] = array('0', '1'); |
124 |
$contenu[1] = array(_('sans'), _('avec')); |
125 |
$form->setSelect('titrebordure', $contenu); |
126 |
$form->setSelect('corpsbordure', $contenu); |
127 |
|
128 |
// LOCALISATION EDITION |
129 |
$config = array( |
130 |
"format" => "format", |
131 |
"orientation" => "orientation" |
132 |
); |
133 |
// Logo |
134 |
$contenu = $config; |
135 |
$contenu["x"] = "logoleft"; |
136 |
$contenu["y"] = "logotop"; |
137 |
$form->setSelect("logotop", $contenu); |
138 |
// Titre |
139 |
$contenu = $config; |
140 |
$contenu["x"] = "titreleft"; |
141 |
$contenu["y"] = "titretop"; |
142 |
$form->setSelect("titretop", $contenu); |
143 |
// Corps |
144 |
$contenu = $config; |
145 |
$contenu["x"] = "corpsleft"; |
146 |
$contenu["y"] = "corpstop"; |
147 |
$form->setSelect("corpstop", $contenu); |
148 |
|
149 |
// SOUS-ETATS ET LOGO |
150 |
if (file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php")) { |
151 |
include ("../sql/".$db->phptype."/".$this->table.".form.inc.php"); |
152 |
} |
153 |
$this->init_select($form, $db, $maj, $debug, "logo", |
154 |
$sql_om_logo, $sql_om_logo_by_id, false); |
155 |
$this->init_select($form, $db, $maj, $debug, "sousetat", |
156 |
$sql_om_sousetat, $sql_om_sousetat_by_id, false); |
157 |
|
158 |
|
159 |
} |
160 |
|
161 |
function setTaille(&$form, $maj) { |
162 |
// |
163 |
parent::setTaille($form, $maj); |
164 |
// |
165 |
$form->setTaille('sousetat', 10); |
166 |
} |
167 |
|
168 |
function setMax(&$form, $maj) { |
169 |
// |
170 |
parent::setMax($form, $maj); |
171 |
// |
172 |
$form->setMax('sousetat', 8); |
173 |
} |
174 |
|
175 |
function setLayout(&$form, $maj) { |
176 |
|
177 |
$form->setFieldset($this->clePrimaire, 'D', _('Edition'), "collapsible"); |
178 |
$form->setBloc($this->clePrimaire, 'D', "", ""); |
179 |
$form->setBloc('actif', 'F', "", ""); |
180 |
$form->setFieldset('orientation','D', _("Parametres generaux de l'edition"), "startClosed"); |
181 |
$form->setBloc('orientation','D', "", "col_12"); |
182 |
$form->setBloc('orientation','D', _("Orientation et format"), "col_4"); |
183 |
$form->setBloc('format','F', "", ""); |
184 |
$form->setBloc('logo','DF', _("Logo et positionnement"), "col_8"); |
185 |
$form->setBloc('logoleft','D', "", "group"); |
186 |
$form->setBloc('logotop','F'); |
187 |
$form->setBloc('logotop','F'); |
188 |
$form->setFieldset('logotop','F',''); |
189 |
$form->setFieldset('logotop','F',''); |
190 |
|
191 |
$form->setFieldset('titre','D', _('Titre'), "collapsible"); |
192 |
$form->setBloc('titre','DF', "", "fullwidth hidelabel"); |
193 |
$form->setFieldset('titreleft','D', _("Parametres du titre de l'edition"), "startClosed"); |
194 |
$form->setBloc('titreleft','D', _("Positionnement")); |
195 |
$form->setBloc('titreleft','D', "", "group"); |
196 |
$form->setBloc('titretop','F'); |
197 |
$form->setBloc('titrelargeur','D', "", "group"); |
198 |
$form->setBloc('titrehauteur','F'); |
199 |
$form->setBloc('titrehauteur','F'); |
200 |
$form->setBloc('titrefont','D', _("Style")); |
201 |
$form->setBloc('titrefont','D', "", "group"); |
202 |
$form->setBloc('titretaille','F'); |
203 |
$form->setBloc('titrebordure','D', "", "group"); |
204 |
$form->setBloc('titrealign','F'); |
205 |
$form->setBloc('titrealign','F'); |
206 |
$form->setFieldset('titrealign','F',''); |
207 |
$form->setFieldset('titrealign','F',''); |
208 |
|
209 |
$form->setFieldset('corps','D', _('Corps'), "collapsible"); |
210 |
$form->setBloc('corps','DF', "", "fullwidth hidelabel"); |
211 |
$form->setFieldset('corpsleft','D', _("Parametres du corps de l'edition"), "startClosed"); |
212 |
$form->setBloc('corpsleft','D', _("Positionnement")); |
213 |
$form->setBloc('corpsleft','D', "", "group"); |
214 |
$form->setBloc('corpstop','F'); |
215 |
$form->setBloc('corpslargeur','D', "", "group"); |
216 |
$form->setBloc('corpshauteur','F'); |
217 |
$form->setBloc('corpshauteur','F'); |
218 |
$form->setBloc('corpsfont','D', _("Style")); |
219 |
$form->setBloc('corpsfont','D', "", "group"); |
220 |
$form->setBloc('corpstaille','F'); |
221 |
$form->setBloc('corpsbordure','D', "", "group"); |
222 |
$form->setBloc('corpsalign','F'); |
223 |
$form->setBloc('corpsalign','F'); |
224 |
$form->setFieldset('corpsalign','F',''); |
225 |
$form->setFieldset('corpsalign','F',''); |
226 |
|
227 |
$form->setFieldset('om_sql','D', _('Champ(s) de fusion'), "collapsible"); |
228 |
$form->setFieldset('merge_fields','F',''); |
229 |
|
230 |
$form->setFieldset('sousetat','D', _("Sous-etat(s)"), "startClosed"); |
231 |
$form->setFieldset('se_couleurtexte','F',''); |
232 |
|
233 |
} |
234 |
|
235 |
function init_default_values() { |
236 |
// |
237 |
$this->form->setVal('orientation','P'); |
238 |
$this->form->setVal('format','A4'); |
239 |
// |
240 |
$this->form->setVal('logoleft', 10); |
241 |
$this->form->setVal('logotop', 10); |
242 |
// |
243 |
$this->form->setVal('titre',_('Texte du titre')); |
244 |
$this->form->setVal('titreleft',109); |
245 |
$this->form->setVal('titretop',16); |
246 |
$this->form->setVal('titrelargeur',0); |
247 |
$this->form->setVal('titrehauteur',10); |
248 |
$this->form->setVal('titrefont','arial'); |
249 |
$this->form->setVal('titreattribut','B'); |
250 |
$this->form->setVal('titretaille',20); |
251 |
$this->form->setVal('titrebordure',0); |
252 |
$this->form->setVal('titrealign','L'); |
253 |
// |
254 |
$this->form->setVal('corps',_('Texte du corps')); |
255 |
$this->form->setVal('corpsleft',14); |
256 |
$this->form->setVal('corpstop',66); |
257 |
$this->form->setVal('corpslargeur',110); |
258 |
$this->form->setVal('corpshauteur',5); |
259 |
$this->form->setVal('corpsfont','times'); |
260 |
$this->form->setVal('corpsattribut',''); |
261 |
$this->form->setVal('corpstaille',10); |
262 |
$this->form->setVal('corpsbordure',0); |
263 |
$this->form->setVal('corpsalign','J'); |
264 |
// |
265 |
$this->form->setVal('se_font','helvetica'); |
266 |
$this->form->setVal('se_margeleft',8); |
267 |
$this->form->setVal('se_margetop',5); |
268 |
$this->form->setVal('se_margeright',5); |
269 |
$this->form->setVal('se_couleurtexte','0-0-0'); |
270 |
} |
271 |
|
272 |
function setVal(&$form, $maj, $validation, &$db, $DEBUG=null) { |
273 |
// |
274 |
parent::setVal($form, $maj, $validation, $db, $DEBUG=null); |
275 |
// |
276 |
if ($validation == 0) { |
277 |
// |
278 |
if ($maj == 0) { |
279 |
// |
280 |
$this->init_default_values(); |
281 |
} |
282 |
} |
283 |
} |
284 |
|
285 |
function setValsousformulaire(&$form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire, &$db, $DEBUG=null) { |
286 |
// |
287 |
parent::setValsousformulaire($form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire, $db, $DEBUG); |
288 |
// |
289 |
if ($validation == 0) { |
290 |
// |
291 |
if ($maj == 0) { |
292 |
// |
293 |
$this->init_default_values(); |
294 |
} |
295 |
} |
296 |
} |
297 |
|
298 |
function verifier($val = array(), &$db = NULL, $DEBUG = false) { |
299 |
// On appelle la methode de la classe parent |
300 |
parent::verifier($val, $db, $DEBUG); |
301 |
// On verifie si il y a un autre id 'actif' pour la collectivite |
302 |
if ($this->valF['actif'] == "Oui") { |
303 |
// |
304 |
if ($this->getParameter("maj") == 0) { |
305 |
// |
306 |
$this->verifieractif($db, $val, $DEBUG, "]"); |
307 |
} else { |
308 |
// |
309 |
$this->verifieractif($db, $val, $DEBUG, $val[$this->clePrimaire]); |
310 |
} |
311 |
} |
312 |
} |
313 |
|
314 |
/** |
315 |
* verification sur existence d un etat deja actif pour la collectivite |
316 |
*/ |
317 |
function verifieractif(&$db, $val, $DEBUG, $id) { |
318 |
// |
319 |
$table = "om_etat"; |
320 |
$primary_key = "om_etat"; |
321 |
// |
322 |
$sql = " SELECT ".$table.".".$primary_key." "; |
323 |
$sql .= " FROM ".DB_PREFIXE."".$table." "; |
324 |
$sql .= " WHERE ".$table.".id='".$val['id']."' "; |
325 |
$sql .= " AND ".$table.".om_collectivite='".$val['om_collectivite']."' "; |
326 |
$sql .= " AND ".$table.".actif IS TRUE "; |
327 |
if ($id != "]") { |
328 |
$sql .=" AND ".$table.".".$primary_key."<>'".$id."' "; |
329 |
} |
330 |
// |
331 |
$res = $this->db->query($sql); |
332 |
$this->addToLog("db->query(\"".$sql."\");", VERBOSE_MODE); |
333 |
// |
334 |
if (database::isError($res)) { |
335 |
// |
336 |
die($res->getMessage()." => Echec ".$sql); |
337 |
} else { |
338 |
// |
339 |
$nbligne = $res->numrows(); |
340 |
if ($nbligne > 0) { |
341 |
$this->correct = false; |
342 |
$msg = $nbligne." "; |
343 |
$msg .= _("etat(s) existant(s) dans l'etat actif. Il ". |
344 |
"n'est pas possible d'avoir plus d'un etat"); |
345 |
$msg .= " \"".$val["id"]."\" "._("actif par collectivite."); |
346 |
$this->addToMessage($msg); |
347 |
} |
348 |
} |
349 |
} |
350 |
|
351 |
} |
352 |
|
353 |
?> |