1 |
<?php |
2 |
//$Id$ |
3 |
//gen openMairie le 12/11/2012 12:53 |
4 |
|
5 |
require_once ("../obj/om_dbform.class.php"); |
6 |
|
7 |
class division_gen extends om_dbform { |
8 |
var $table="division"; |
9 |
var $clePrimaire="division"; |
10 |
var $typeCle="N"; |
11 |
var $required_field=array( |
12 |
"chef", |
13 |
"code", |
14 |
"direction", |
15 |
"division", |
16 |
"libelle" |
17 |
); |
18 |
var $retourformulaire; |
19 |
|
20 |
function setvalF($val) { |
21 |
//affectation valeur formulaire |
22 |
if (!is_numeric($val['division'])) { |
23 |
$this->valF['division'] = ""; // -> requis |
24 |
} else { |
25 |
$this->valF['division'] = $val['division']; |
26 |
} |
27 |
$this->valF['code'] = $val['code']; |
28 |
$this->valF['libelle'] = $val['libelle']; |
29 |
$this->valF['description'] = $val['description']; |
30 |
$this->valF['chef'] = $val['chef']; |
31 |
if (!is_numeric($val['direction'])) { |
32 |
$this->valF['direction'] = ""; // -> requis |
33 |
} else { |
34 |
$this->valF['direction'] = $val['direction']; |
35 |
} |
36 |
if ($val['om_validite_debut'] != "") { |
37 |
$this->valF['om_validite_debut'] = $this->dateDB($val['om_validite_debut']); |
38 |
} else { |
39 |
$this->valF['om_validite_debut'] = NULL; |
40 |
} |
41 |
if ($val['om_validite_fin'] != "") { |
42 |
$this->valF['om_validite_fin'] = $this->dateDB($val['om_validite_fin']); |
43 |
} else { |
44 |
$this->valF['om_validite_fin'] = NULL; |
45 |
} |
46 |
} |
47 |
|
48 |
//================================================= |
49 |
//cle primaire automatique [automatic primary key] |
50 |
//================================================== |
51 |
|
52 |
function setId(&$db) { |
53 |
//numero automatique |
54 |
$this->valF[$this->clePrimaire] = $db->nextId(DB_PREFIXE.$this->table); |
55 |
} |
56 |
|
57 |
function setValFAjout($val) { |
58 |
//numero automatique -> pas de controle ajout cle primaire |
59 |
} |
60 |
|
61 |
function verifierAjout() { |
62 |
//numero automatique -> pas de verfication de cle primaire |
63 |
} |
64 |
/** |
65 |
* Methode verifier |
66 |
*/ |
67 |
function verifier($val = array(), &$db = NULL, $DEBUG = false) { |
68 |
// On appelle la methode de la classe parent |
69 |
parent::verifier($val, $db, $DEBUG); |
70 |
|
71 |
// gestion des dates de validites |
72 |
$date_debut = $this->valF['om_validite_debut']; |
73 |
$date_fin = $this->valF['om_validite_fin']; |
74 |
|
75 |
if ($date_debut != '' and $date_fin != '') { |
76 |
|
77 |
$date_debut = explode('-', $this->valF['om_validite_debut']); |
78 |
$date_fin = explode('-', $this->valF['om_validite_fin']); |
79 |
|
80 |
$time_debut = mktime(0, 0, 0, $date_debut[1], $date_debut[2], |
81 |
$date_debut[0]); |
82 |
$time_fin = mktime(0, 0, 0, $date_fin[1], $date_fin[2], |
83 |
$date_fin[0]); |
84 |
|
85 |
if ($time_debut > $time_fin or $time_debut == $time_fin) { |
86 |
$this->correct = false; |
87 |
$this->addToMessage(_('La date de fin de validite doit etre future a la de debut de validite.')); |
88 |
} |
89 |
} |
90 |
} |
91 |
|
92 |
|
93 |
//========================== |
94 |
// Formulaire [form] |
95 |
//========================== |
96 |
|
97 |
function setType(&$form,$maj) { |
98 |
//type |
99 |
if ($maj==0){ //ajout |
100 |
$form->setType('division','hidden');// cle automatique |
101 |
$form->setType('code','text'); |
102 |
$form->setType('libelle','text'); |
103 |
$form->setType('description','textarea'); |
104 |
$form->setType('chef','text'); |
105 |
|
106 |
if($this->retourformulaire=='direction' |
107 |
and $form->val['direction'] == $this->getParameter('idxformulaire')) { |
108 |
$form->setType('direction','selecthiddenstatic'); |
109 |
} else { |
110 |
$form->setType('direction','select'); |
111 |
} |
112 |
if ($this->f->isAccredited(array($this->table.'_modifier_validite', |
113 |
$this->table))) { |
114 |
if($this->retourformulaire=='') |
115 |
$form->setType('om_validite_debut','date'); |
116 |
else |
117 |
$form->setType('om_validite_debut','date2'); |
118 |
} else { |
119 |
$form->setType('om_validite_debut','hiddenstaticdate'); |
120 |
} |
121 |
if ($this->f->isAccredited(array($this->table.'_modifier_validite', |
122 |
$this->table))) { |
123 |
if($this->retourformulaire=='') |
124 |
$form->setType('om_validite_fin','date'); |
125 |
else |
126 |
$form->setType('om_validite_fin','date2'); |
127 |
} else { |
128 |
$form->setType('om_validite_fin','hiddenstaticdate'); |
129 |
} |
130 |
}// fin ajout |
131 |
if ($maj==1){ //modifier |
132 |
$form->setType('division','hiddenstatic'); |
133 |
$form->setType('code','text'); |
134 |
$form->setType('libelle','text'); |
135 |
$form->setType('description','textarea'); |
136 |
$form->setType('chef','text'); |
137 |
|
138 |
if($this->retourformulaire=='direction' |
139 |
and $form->val['direction'] == $this->getParameter('idxformulaire')) { |
140 |
$form->setType('direction','selecthiddenstatic'); |
141 |
} else { |
142 |
$form->setType('direction','select'); |
143 |
} |
144 |
if ($this->f->isAccredited(array($this->table.'_modifier_validite', |
145 |
$this->table))) { |
146 |
if($this->retourformulaire=='') |
147 |
$form->setType('om_validite_debut','date'); |
148 |
else |
149 |
$form->setType('om_validite_debut','date2'); |
150 |
} else { |
151 |
$form->setType('om_validite_debut','hiddenstaticdate'); |
152 |
} |
153 |
if ($this->f->isAccredited(array($this->table.'_modifier_validite', |
154 |
$this->table))) { |
155 |
if($this->retourformulaire=='') |
156 |
$form->setType('om_validite_fin','date'); |
157 |
else |
158 |
$form->setType('om_validite_fin','date2'); |
159 |
} else { |
160 |
$form->setType('om_validite_fin','hiddenstaticdate'); |
161 |
} |
162 |
}// fin modifier |
163 |
if ($maj==2){ //supprimer |
164 |
$form->setType('division','hiddenstatic'); |
165 |
$form->setType('code','hiddenstatic'); |
166 |
$form->setType('libelle','hiddenstatic'); |
167 |
$form->setType('description','hiddenstatic'); |
168 |
$form->setType('chef','hiddenstatic'); |
169 |
$form->setType('direction','selectstatic'); |
170 |
$form->setType('om_validite_debut','hiddenstatic'); |
171 |
$form->setType('om_validite_fin','hiddenstatic'); |
172 |
}//fin supprimer |
173 |
if ($maj==3){ //consulter |
174 |
$form->setType('division','static'); |
175 |
$form->setType('code','static'); |
176 |
$form->setType('libelle','static'); |
177 |
$form->setType('description','textareastatic'); |
178 |
$form->setType('chef','static'); |
179 |
$form->setType('direction','selectstatic'); |
180 |
$form->setType('om_validite_debut','datestatic'); |
181 |
$form->setType('om_validite_fin','datestatic'); |
182 |
}//fin consulter |
183 |
} |
184 |
|
185 |
function setOnchange(&$form,$maj) { |
186 |
//javascript controle client |
187 |
$form->setOnchange('division','VerifNum(this)'); |
188 |
$form->setOnchange('direction','VerifNum(this)'); |
189 |
$form->setOnchange('om_validite_debut','fdate(this)'); |
190 |
$form->setOnchange('om_validite_fin','fdate(this)'); |
191 |
} |
192 |
/** |
193 |
* Methode setTaille |
194 |
*/ |
195 |
function setTaille(&$form, $maj) { |
196 |
$form->setTaille("division", 11); |
197 |
$form->setTaille("code", 20); |
198 |
$form->setTaille("libelle", 30); |
199 |
$form->setTaille("description", 80); |
200 |
$form->setTaille("chef", 30); |
201 |
$form->setTaille("direction", 11); |
202 |
$form->setTaille("om_validite_debut", 12); |
203 |
$form->setTaille("om_validite_fin", 12); |
204 |
} |
205 |
|
206 |
/** |
207 |
* Methode setMax |
208 |
*/ |
209 |
function setMax(&$form, $maj) { |
210 |
$form->setMax("division", 11); |
211 |
$form->setMax("code", 20); |
212 |
$form->setMax("libelle", 100); |
213 |
$form->setMax("description", 6); |
214 |
$form->setMax("chef", 100); |
215 |
$form->setMax("direction", 11); |
216 |
$form->setMax("om_validite_debut", 12); |
217 |
$form->setMax("om_validite_fin", 12); |
218 |
} |
219 |
|
220 |
|
221 |
function setLib(&$form,$maj) { |
222 |
//libelle des champs |
223 |
$form->setLib('division',_('division')); |
224 |
$form->setLib('code',_('code')); |
225 |
$form->setLib('libelle',_('libelle')); |
226 |
$form->setLib('description',_('description')); |
227 |
$form->setLib('chef',_('chef')); |
228 |
$form->setLib('direction',_('direction')); |
229 |
$form->setLib('om_validite_debut',_('om_validite_debut')); |
230 |
$form->setLib('om_validite_fin',_('om_validite_fin')); |
231 |
} |
232 |
|
233 |
function setSelect(&$form, $maj,&$db,$debug) { |
234 |
if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php")) |
235 |
include ("../sql/".$db->phptype."/".$this->table.".form.inc.php"); |
236 |
elseif(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc")) |
237 |
include ("../sql/".$db->phptype."/".$this->table.".form.inc"); |
238 |
|
239 |
// direction |
240 |
$this->init_select($form, $db, $maj, $debug, "direction", |
241 |
$sql_direction, $sql_direction_by_id, true); |
242 |
}// fin select |
243 |
|
244 |
//================================== |
245 |
// sous Formulaire [subform] |
246 |
//================================== |
247 |
|
248 |
function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire,&$db,$DEBUG=null){ |
249 |
$this->retourformulaire = $retourformulaire; |
250 |
if($validation == 0) { |
251 |
if($retourformulaire =='direction') |
252 |
$form->setVal('direction', $idxformulaire); |
253 |
}// fin validation |
254 |
}// fin setValsousformulaire |
255 |
|
256 |
//================================== |
257 |
// cle secondaire [secondary key] |
258 |
//================================== |
259 |
/** |
260 |
* Methode clesecondaire |
261 |
*/ |
262 |
function cleSecondaire($id, &$db = NULL, $val = array(), $DEBUG = false) { |
263 |
// On appelle la methode de la classe parent |
264 |
parent::cleSecondaire($id, $db, $val, $DEBUG); |
265 |
// Verification de la cle secondaire : dossier |
266 |
$this->rechercheTable($db, "dossier", "division", $id); |
267 |
// Verification de la cle secondaire : instructeur |
268 |
$this->rechercheTable($db, "instructeur", "division", $id); |
269 |
} |
270 |
|
271 |
|
272 |
}// fin classe |
273 |
?> |