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