/[openfoncier]/trunk/gen/obj/service.class.php
ViewVC logotype

Contents of /trunk/gen/obj/service.class.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 501 - (show annotations)
Mon Oct 15 09:04:04 2012 UTC (12 years, 3 months ago) by vpihour
File size: 13596 byte(s)
Modification de tables

1 <?php
2 //$Id$
3 //gen openMairie le 15/10/2012 10:59
4
5 require_once ("../obj/om_dbform.class.php");
6
7 class service_gen extends om_dbform {
8 var $table="service";
9 var $clePrimaire="service";
10 var $typeCle="N";
11 var $required_field=array(
12 "abrege",
13 "libelle",
14 "service"
15 );
16 var $retourformulaire;
17
18 function setvalF($val) {
19 //affectation valeur formulaire
20 $this->valF['abrege'] = $val['abrege'];
21 $this->valF['libelle'] = $val['libelle'];
22 if ($val['adresse'] == "") {
23 $this->valF['adresse'] = ""; // -> default
24 } else {
25 $this->valF['adresse'] = $val['adresse'];
26 }
27 if ($val['adresse2'] == "") {
28 $this->valF['adresse2'] = ""; // -> default
29 } else {
30 $this->valF['adresse2'] = $val['adresse2'];
31 }
32 if ($val['cp'] == "") {
33 $this->valF['cp'] = ""; // -> default
34 } else {
35 $this->valF['cp'] = $val['cp'];
36 }
37 if ($val['ville'] == "") {
38 $this->valF['ville'] = ""; // -> default
39 } else {
40 $this->valF['ville'] = $val['ville'];
41 }
42 if ($val['email'] == "") {
43 $this->valF['email'] = ""; // -> default
44 } else {
45 $this->valF['email'] = $val['email'];
46 }
47 if (!is_numeric($val['delai'])) {
48 $this->valF['delai'] = NULL;
49 } else {
50 $this->valF['delai'] = $val['delai'];
51 }
52 if (!is_numeric($val['service'])) {
53 $this->valF['service'] = ""; // -> requis
54 } else {
55 $this->valF['service'] = $val['service'];
56 }
57 if ($val['consultation_papier'] == 1 || $val['consultation_papier'] == "t" || $val['consultation_papier'] == "Oui") {
58 $this->valF['consultation_papier'] = true;
59 } else {
60 $this->valF['consultation_papier'] = false;
61 }
62 if ($val['choix_consultation'] == 1 || $val['choix_consultation'] == "t" || $val['choix_consultation'] == "Oui") {
63 $this->valF['choix_consultation'] = true;
64 } else {
65 $this->valF['choix_consultation'] = false;
66 }
67 if ($val['notification_email'] == 1 || $val['notification_email'] == "t" || $val['notification_email'] == "Oui") {
68 $this->valF['notification_email'] = true;
69 } else {
70 $this->valF['notification_email'] = false;
71 }
72 if ($val['om_validite_debut'] != "") {
73 $this->valF['om_validite_debut'] = $this->dateDB($val['om_validite_debut']);
74 } else {
75 $this->valF['om_validite_debut'] = NULL;
76 }
77 if ($val['om_validite_fin'] != "") {
78 $this->valF['om_validite_fin'] = $this->dateDB($val['om_validite_fin']);
79 } else {
80 $this->valF['om_validite_fin'] = NULL;
81 }
82 if ($val['type_consultation'] == "") {
83 $this->valF['type_consultation'] = NULL;
84 } else {
85 $this->valF['type_consultation'] = $val['type_consultation'];
86 }
87 }
88
89 //=================================================
90 //cle primaire automatique [automatic primary key]
91 //==================================================
92
93 function setId(&$db) {
94 //numero automatique
95 $this->valF[$this->clePrimaire] = $db->nextId(DB_PREFIXE.$this->table);
96 }
97
98 function setValFAjout($val) {
99 //numero automatique -> pas de controle ajout cle primaire
100 }
101
102 function verifierAjout() {
103 //numero automatique -> pas de verfication de cle primaire
104 }
105 /**
106 * Methode verifier
107 */
108 function verifier($val = array(), &$db = NULL, $DEBUG = false) {
109 // On appelle la methode de la classe parent
110 parent::verifier($val, $db, $DEBUG);
111
112 // gestion des dates de validites
113 $date_debut = $this->valF['om_validite_debut'];
114 $date_fin = $this->valF['om_validite_fin'];
115
116 if ($date_debut != '' and $date_fin != '') {
117
118 $date_debut = explode('-', $this->valF['om_validite_debut']);
119 $date_fin = explode('-', $this->valF['om_validite_fin']);
120
121 $time_debut = mktime(0, 0, 0, $date_debut[1], $date_debut[2],
122 $date_debut[0]);
123 $time_fin = mktime(0, 0, 0, $date_fin[1], $date_fin[2],
124 $date_fin[0]);
125
126 if ($time_debut > $time_fin or $time_debut == $time_fin) {
127 $this->correct = false;
128 $this->addToMessage(_('La date de fin de validite doit etre future a la de debut de validite.'));
129 }
130 }
131 }
132
133
134 //==========================
135 // Formulaire [form]
136 //==========================
137
138 function setType(&$form,$maj) {
139 //type
140 if ($maj==0){ //ajout
141 $form->setType('service','hidden');// cle automatique
142 $form->setType('abrege','text');
143 $form->setType('libelle','text');
144 $form->setType('adresse','text');
145 $form->setType('adresse2','text');
146 $form->setType('cp','text');
147 $form->setType('ville','text');
148 $form->setType('email','text');
149 $form->setType('delai','text');
150 $form->setType('consultation_papier','checkbox');
151 $form->setType('choix_consultation','checkbox');
152 $form->setType('notification_email','checkbox');
153 if ($this->f->isAccredited(array($this->table.'_modifier_validite',
154 $this->table))) {
155 if($this->retourformulaire=='')
156 $form->setType('om_validite_debut','date');
157 else
158 $form->setType('om_validite_debut','date2');
159 } else {
160 $form->setType('om_validite_debut','hiddenstaticdate');
161 }
162 if ($this->f->isAccredited(array($this->table.'_modifier_validite',
163 $this->table))) {
164 if($this->retourformulaire=='')
165 $form->setType('om_validite_fin','date');
166 else
167 $form->setType('om_validite_fin','date2');
168 } else {
169 $form->setType('om_validite_fin','hiddenstaticdate');
170 }
171 $form->setType('type_consultation','text');
172 }// fin ajout
173 if ($maj==1){ //modifier
174 $form->setType('service','hiddenstatic');
175 $form->setType('abrege','text');
176 $form->setType('libelle','text');
177 $form->setType('adresse','text');
178 $form->setType('adresse2','text');
179 $form->setType('cp','text');
180 $form->setType('ville','text');
181 $form->setType('email','text');
182 $form->setType('delai','text');
183 $form->setType('consultation_papier','checkbox');
184 $form->setType('choix_consultation','checkbox');
185 $form->setType('notification_email','checkbox');
186 if ($this->f->isAccredited(array($this->table.'_modifier_validite',
187 $this->table))) {
188 if($this->retourformulaire=='')
189 $form->setType('om_validite_debut','date');
190 else
191 $form->setType('om_validite_debut','date2');
192 } else {
193 $form->setType('om_validite_debut','hiddenstaticdate');
194 }
195 if ($this->f->isAccredited(array($this->table.'_modifier_validite',
196 $this->table))) {
197 if($this->retourformulaire=='')
198 $form->setType('om_validite_fin','date');
199 else
200 $form->setType('om_validite_fin','date2');
201 } else {
202 $form->setType('om_validite_fin','hiddenstaticdate');
203 }
204 $form->setType('type_consultation','text');
205 }// fin modifier
206 if ($maj==2){ //supprimer
207 $form->setType('abrege','hiddenstatic');
208 $form->setType('libelle','hiddenstatic');
209 $form->setType('adresse','hiddenstatic');
210 $form->setType('adresse2','hiddenstatic');
211 $form->setType('cp','hiddenstatic');
212 $form->setType('ville','hiddenstatic');
213 $form->setType('email','hiddenstatic');
214 $form->setType('delai','hiddenstatic');
215 $form->setType('service','hiddenstatic');
216 $form->setType('consultation_papier','hiddenstatic');
217 $form->setType('choix_consultation','hiddenstatic');
218 $form->setType('notification_email','hiddenstatic');
219 $form->setType('om_validite_debut','hiddenstatic');
220 $form->setType('om_validite_fin','hiddenstatic');
221 $form->setType('type_consultation','hiddenstatic');
222 }//fin supprimer
223 if ($maj==3){ //consulter
224 $form->setType('service','static');
225 $form->setType('abrege','static');
226 $form->setType('libelle','static');
227 $form->setType('adresse','static');
228 $form->setType('adresse2','static');
229 $form->setType('cp','static');
230 $form->setType('ville','static');
231 $form->setType('email','static');
232 $form->setType('delai','static');
233 $form->setType('consultation_papier','checkboxstatic');
234 $form->setType('choix_consultation','checkboxstatic');
235 $form->setType('notification_email','checkboxstatic');
236 $form->setType('om_validite_debut','datestatic');
237 $form->setType('om_validite_fin','datestatic');
238 $form->setType('type_consultation','static');
239 }//fin consulter
240 }
241
242 function setOnchange(&$form,$maj) {
243 //javascript controle client
244 $form->setOnchange('delai','VerifNum(this)');
245 $form->setOnchange('service','VerifNum(this)');
246 $form->setOnchange('om_validite_debut','fdate(this)');
247 $form->setOnchange('om_validite_fin','fdate(this)');
248 }
249 /**
250 * Methode setTaille
251 */
252 function setTaille(&$form, $maj) {
253 $form->setTaille("abrege", 10);
254 $form->setTaille("libelle", 30);
255 $form->setTaille("adresse", 30);
256 $form->setTaille("adresse2", 30);
257 $form->setTaille("cp", 10);
258 $form->setTaille("ville", 30);
259 $form->setTaille("email", 30);
260 $form->setTaille("delai", 11);
261 $form->setTaille("service", 11);
262 $form->setTaille("consultation_papier", 1);
263 $form->setTaille("choix_consultation", 1);
264 $form->setTaille("notification_email", 1);
265 $form->setTaille("om_validite_debut", 12);
266 $form->setTaille("om_validite_fin", 12);
267 $form->setTaille("type_consultation", 30);
268 }
269
270 /**
271 * Methode setMax
272 */
273 function setMax(&$form, $maj) {
274 $form->setMax("abrege", 5);
275 $form->setMax("libelle", 70);
276 $form->setMax("adresse", 40);
277 $form->setMax("adresse2", 39);
278 $form->setMax("cp", 5);
279 $form->setMax("ville", 30);
280 $form->setMax("email", 50);
281 $form->setMax("delai", 11);
282 $form->setMax("service", 11);
283 $form->setMax("consultation_papier", 1);
284 $form->setMax("choix_consultation", 1);
285 $form->setMax("notification_email", 1);
286 $form->setMax("om_validite_debut", 12);
287 $form->setMax("om_validite_fin", 12);
288 $form->setMax("type_consultation", 70);
289 }
290
291
292 function setLib(&$form,$maj) {
293 //libelle des champs
294 $form->setLib('abrege',_('abrege'));
295 $form->setLib('libelle',_('libelle'));
296 $form->setLib('adresse',_('adresse'));
297 $form->setLib('adresse2',_('adresse2'));
298 $form->setLib('cp',_('cp'));
299 $form->setLib('ville',_('ville'));
300 $form->setLib('email',_('email'));
301 $form->setLib('delai',_('delai'));
302 $form->setLib('service',_('service'));
303 $form->setLib('consultation_papier',_('consultation_papier'));
304 $form->setLib('choix_consultation',_('choix_consultation'));
305 $form->setLib('notification_email',_('notification_email'));
306 $form->setLib('om_validite_debut',_('om_validite_debut'));
307 $form->setLib('om_validite_fin',_('om_validite_fin'));
308 $form->setLib('type_consultation',_('type_consultation'));
309 }
310
311 //==================================
312 // sous Formulaire [subform]
313 //==================================
314
315 function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire,&$db,$DEBUG=null){
316 $this->retourformulaire = $retourformulaire;
317 }// fin setValsousformulaire
318
319 //==================================
320 // cle secondaire [secondary key]
321 //==================================
322 /**
323 * Methode clesecondaire
324 */
325 function cleSecondaire($id, &$db = NULL, $val = array(), $DEBUG = false) {
326 // On appelle la methode de la classe parent
327 parent::cleSecondaire($id, $db, $val, $DEBUG);
328 // Verification de la cle secondaire : consultation
329 $this->rechercheTable($db, "consultation", "service", $id);
330 // Verification de la cle secondaire : lien_service_om_utilisateur
331 $this->rechercheTable($db, "lien_service_om_utilisateur", "service", $id);
332 // Verification de la cle secondaire : lien_service_service_categorie
333 $this->rechercheTable($db, "lien_service_service_categorie", "service", $id);
334 }
335
336
337 }// fin classe
338 ?>

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26