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