1 |
<?php |
<?php |
2 |
//$Id$ |
//$Id$ |
3 |
//gen openMairie le 17/10/2012 17:46 |
//gen openMairie le 05/11/2012 19:24 |
4 |
|
|
5 |
require_once ("../obj/om_dbform.class.php"); |
require_once ("../obj/om_dbform.class.php"); |
6 |
|
|
27 |
$this->valF['libelle'] = $val['libelle']; |
$this->valF['libelle'] = $val['libelle']; |
28 |
$this->valF['description'] = $val['description']; |
$this->valF['description'] = $val['description']; |
29 |
$this->valF['chef'] = $val['chef']; |
$this->valF['chef'] = $val['chef']; |
30 |
|
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 |
} |
} |
41 |
|
|
42 |
//================================================= |
//================================================= |
55 |
function verifierAjout() { |
function verifierAjout() { |
56 |
//numero automatique -> pas de verfication de cle primaire |
//numero automatique -> pas de verfication de cle primaire |
57 |
} |
} |
58 |
|
/** |
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 |
|
|
65 |
|
// 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 |
//========================== |
//========================== |
88 |
// Formulaire [form] |
// Formulaire [form] |
96 |
$form->setType('libelle','text'); |
$form->setType('libelle','text'); |
97 |
$form->setType('description','textarea'); |
$form->setType('description','textarea'); |
98 |
$form->setType('chef','text'); |
$form->setType('chef','text'); |
99 |
|
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 |
}// fin ajout |
}// fin ajout |
118 |
if ($maj==1){ //modifier |
if ($maj==1){ //modifier |
119 |
$form->setType('direction','hiddenstatic'); |
$form->setType('direction','hiddenstatic'); |
121 |
$form->setType('libelle','text'); |
$form->setType('libelle','text'); |
122 |
$form->setType('description','textarea'); |
$form->setType('description','textarea'); |
123 |
$form->setType('chef','text'); |
$form->setType('chef','text'); |
124 |
|
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 |
}// fin modifier |
}// fin modifier |
143 |
if ($maj==2){ //supprimer |
if ($maj==2){ //supprimer |
144 |
$form->setType('direction','hiddenstatic'); |
$form->setType('direction','hiddenstatic'); |
146 |
$form->setType('libelle','hiddenstatic'); |
$form->setType('libelle','hiddenstatic'); |
147 |
$form->setType('description','hiddenstatic'); |
$form->setType('description','hiddenstatic'); |
148 |
$form->setType('chef','hiddenstatic'); |
$form->setType('chef','hiddenstatic'); |
149 |
|
$form->setType('om_validite_debut','hiddenstatic'); |
150 |
|
$form->setType('om_validite_fin','hiddenstatic'); |
151 |
}//fin supprimer |
}//fin supprimer |
152 |
if ($maj==3){ //consulter |
if ($maj==3){ //consulter |
153 |
$form->setType('direction','static'); |
$form->setType('direction','static'); |
155 |
$form->setType('libelle','static'); |
$form->setType('libelle','static'); |
156 |
$form->setType('description','textareastatic'); |
$form->setType('description','textareastatic'); |
157 |
$form->setType('chef','static'); |
$form->setType('chef','static'); |
158 |
|
$form->setType('om_validite_debut','datestatic'); |
159 |
|
$form->setType('om_validite_fin','datestatic'); |
160 |
}//fin consulter |
}//fin consulter |
161 |
} |
} |
162 |
|
|
163 |
function setOnchange(&$form,$maj) { |
function setOnchange(&$form,$maj) { |
164 |
//javascript controle client |
//javascript controle client |
165 |
$form->setOnchange('direction','VerifNum(this)'); |
$form->setOnchange('direction','VerifNum(this)'); |
166 |
|
$form->setOnchange('om_validite_debut','fdate(this)'); |
167 |
|
$form->setOnchange('om_validite_fin','fdate(this)'); |
168 |
} |
} |
169 |
/** |
/** |
170 |
* Methode setTaille |
* Methode setTaille |
175 |
$form->setTaille("libelle", 30); |
$form->setTaille("libelle", 30); |
176 |
$form->setTaille("description", 80); |
$form->setTaille("description", 80); |
177 |
$form->setTaille("chef", 30); |
$form->setTaille("chef", 30); |
178 |
|
$form->setTaille("om_validite_debut", 12); |
179 |
|
$form->setTaille("om_validite_fin", 12); |
180 |
} |
} |
181 |
|
|
182 |
/** |
/** |
185 |
function setMax(&$form, $maj) { |
function setMax(&$form, $maj) { |
186 |
$form->setMax("direction", 11); |
$form->setMax("direction", 11); |
187 |
$form->setMax("code", 20); |
$form->setMax("code", 20); |
188 |
$form->setMax("libelle", 40); |
$form->setMax("libelle", 100); |
189 |
$form->setMax("description", 6); |
$form->setMax("description", 6); |
190 |
$form->setMax("chef", 30); |
$form->setMax("chef", 30); |
191 |
|
$form->setMax("om_validite_debut", 12); |
192 |
|
$form->setMax("om_validite_fin", 12); |
193 |
} |
} |
194 |
|
|
195 |
|
|
200 |
$form->setLib('libelle',_('libelle')); |
$form->setLib('libelle',_('libelle')); |
201 |
$form->setLib('description',_('description')); |
$form->setLib('description',_('description')); |
202 |
$form->setLib('chef',_('chef')); |
$form->setLib('chef',_('chef')); |
203 |
|
$form->setLib('om_validite_debut',_('om_validite_debut')); |
204 |
|
$form->setLib('om_validite_fin',_('om_validite_fin')); |
205 |
} |
} |
206 |
|
|
207 |
//================================== |
//================================== |