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