1 |
<?php |
2 |
/** |
3 |
* DBFORM - 'architecte' - Surcharge gen. |
4 |
* |
5 |
* Ce script permet de définir la classe 'architecte'. |
6 |
* |
7 |
* @package openads |
8 |
* @version SVN : $Id$ |
9 |
*/ |
10 |
|
11 |
require_once "../gen/obj/architecte.class.php"; |
12 |
|
13 |
class architecte extends architecte_gen { |
14 |
|
15 |
// {{{ Gestion de la confidentialité des données spécifiques |
16 |
|
17 |
/** |
18 |
* Définition des actions disponibles sur la classe. |
19 |
* |
20 |
* @return void |
21 |
*/ |
22 |
function init_class_actions() { |
23 |
|
24 |
parent::init_class_actions(); |
25 |
|
26 |
// ACTION - 001 - modifier |
27 |
// Modifie la condition et le libellé du bouton modifier |
28 |
$this->class_actions[1]["condition"] = array("is_not_frequent"); |
29 |
|
30 |
// ACTION - 100 - non_frequent |
31 |
// Finalise l'enregistrement |
32 |
$this->class_actions[100] = array( |
33 |
"identifier" => "non_frequent", |
34 |
"portlet" => array( |
35 |
"type" => "action-direct", |
36 |
"libelle" => _("Marquer non frequent"), |
37 |
"order" => 100, |
38 |
"class" => "radiation-16", |
39 |
), |
40 |
"view" => "formulaire", |
41 |
"method" => "set_non_frequent", |
42 |
"permission_suffix" => "modifier_frequent", |
43 |
"condition" => array("is_frequent"), |
44 |
); |
45 |
|
46 |
// ACTION - 110 - recuperer_frequent |
47 |
// Finalise l'enregistrement |
48 |
$this->class_actions[110] = array( |
49 |
"identifier" => "recuperer_frequent", |
50 |
"view" => "formulaire", |
51 |
"method" => "modifier", |
52 |
"button" => "valider", |
53 |
"permission_suffix" => "modifier", |
54 |
); |
55 |
} |
56 |
|
57 |
//}}} |
58 |
|
59 |
/** |
60 |
* Clause select pour la requête de sélection des données de l'enregistrement. |
61 |
* |
62 |
* @return array |
63 |
*/ |
64 |
function get_var_sql_forminc__champs() { |
65 |
return array( |
66 |
"architecte", |
67 |
"nom", |
68 |
"prenom", |
69 |
"adresse1", |
70 |
"adresse2", |
71 |
"cp", |
72 |
"ville", |
73 |
"pays", |
74 |
"inscription", |
75 |
"conseil_regional", |
76 |
"nom_cabinet", |
77 |
"telephone", |
78 |
"fax", |
79 |
"email", |
80 |
"note", |
81 |
"frequent", |
82 |
); |
83 |
} |
84 |
|
85 |
/** |
86 |
* Retourne true si pétitionnaire frequent false sinon. |
87 |
* |
88 |
* @return boolean retourne true si frequent false sinon. |
89 |
*/ |
90 |
function is_frequent() { |
91 |
if($this->getVal("frequent") == 't') { |
92 |
return true; |
93 |
} |
94 |
return false; |
95 |
} |
96 |
|
97 |
/** |
98 |
* Retourne false si pétitionnaire frequent true sinon. |
99 |
* |
100 |
* @return boolean retourne false si frequent true sinon. |
101 |
*/ |
102 |
function is_not_frequent() { |
103 |
return !$this->is_frequent(); |
104 |
} |
105 |
|
106 |
/** |
107 |
* TREATMENT - set_non_frequent. |
108 |
* |
109 |
* Cette methode permet de passer le pétitionnaire en non fréquent. |
110 |
* |
111 |
* @return boolean true si maj effectué false sinon |
112 |
*/ |
113 |
function set_non_frequent($val) { |
114 |
// Cette méthode permet d'exécuter une routine en début des méthodes |
115 |
// dites de TREATMENT. |
116 |
$this->begin_treatment(__METHOD__); |
117 |
|
118 |
if($this->getVal("frequent") == 't') { |
119 |
$this->correct = true; |
120 |
$this->valF["frequent"] = false; |
121 |
|
122 |
$res = $this->f->db->autoExecute( |
123 |
DB_PREFIXE.$this->table, |
124 |
$this->valF, |
125 |
DB_AUTOQUERY_UPDATE, |
126 |
$this->clePrimaire."=".$this->getVal($this->clePrimaire) |
127 |
); |
128 |
if ($this->f->isDatabaseError($res, true)) { |
129 |
// Appel de la methode de recuperation des erreurs |
130 |
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
131 |
$this->correct = false; |
132 |
// Termine le traitement |
133 |
return $this->end_treatment(__METHOD__, false); |
134 |
} else { |
135 |
$this->addToMessage(_("Mise a jour effectuee avec succes")); |
136 |
return $this->end_treatment(__METHOD__, true); |
137 |
} |
138 |
|
139 |
} else { |
140 |
$this->addToMessage(_("Element deja frequent")); |
141 |
} |
142 |
|
143 |
// Termine le traitement |
144 |
return $this->end_treatment(__METHOD__, false); |
145 |
} |
146 |
|
147 |
/** |
148 |
* Ajout des blocs pour la gestion des architectes fréquents |
149 |
*/ |
150 |
function setType(&$form, $maj) { |
151 |
parent::setType($form, $maj); |
152 |
if ($maj < 2) { //ajouter et modifier [add and modify] |
153 |
$form->setType('email', 'mail'); |
154 |
} |
155 |
// MODE recup_frequent |
156 |
if ($maj == 110) { |
157 |
//Affichage d'un message d'information |
158 |
$this->addToMessage(_("Architecte frequent non modifiable")); |
159 |
$form->setType("architecte", "hiddenstatic"); |
160 |
$form->setType("nom", "static"); |
161 |
$form->setType("prenom", "static"); |
162 |
$form->setType("adresse1", "static"); |
163 |
$form->setType("adresse2", "static"); |
164 |
$form->setType("cp", "static"); |
165 |
$form->setType("ville", "static"); |
166 |
$form->setType("pays", "static"); |
167 |
$form->setType("inscription", "static"); |
168 |
$form->setType("telephone", "static"); |
169 |
$form->setType("fax", "static"); |
170 |
$form->setType("email", "static"); |
171 |
$form->setType("note", "static"); |
172 |
$form->setType("frequent", "checkboxstatic"); |
173 |
$form->setType("nom_cabinet", "static"); |
174 |
$form->setType("conseil_regional", "static"); |
175 |
} |
176 |
} |
177 |
|
178 |
function setLayout(&$form, $maj){ |
179 |
|
180 |
$form->setBloc('architecte','D',"", "alignForm"); |
181 |
// |
182 |
$form->setBloc('architecte','DF',"", "group"); |
183 |
// |
184 |
$form->setBloc('architecte','F'); |
185 |
|
186 |
if($this->getVal('frequent') != 't' || $maj == 0 ) { |
187 |
$form->setBloc('nom','D',"","group alignForm civilite_architecte ".($maj<2 ? "search_fields ":"")); |
188 |
} else { |
189 |
$form->setBloc('nom','D',"","group alignForm"); |
190 |
} |
191 |
|
192 |
//$form->setBloc('nom','D',"", "group civilite_architecte ".($maj<2 ? "search_fields":"")); |
193 |
$form->setBloc('prenom','F'); |
194 |
|
195 |
$form->setBloc('adresse1','D',"", "adresse_architecte alignForm"); |
196 |
// |
197 |
$form->setBloc('adresse1','DF',"", "group"); |
198 |
$form->setBloc('adresse2','DF',"", "group"); |
199 |
$form->setBloc('cp','DF',"", "group"); |
200 |
$form->setBloc('ville','DF',"", "group"); |
201 |
$form->setBloc('pays','DF',"", "group"); |
202 |
// |
203 |
$form->setBloc('pays','F'); |
204 |
|
205 |
$form->setBloc('inscription','D',"", "complement_architecte alignForm"); |
206 |
// |
207 |
$form->setBloc('inscription','DF',"", "group"); |
208 |
$form->setBloc('conseil_regional','DF',"", "group"); |
209 |
$form->setBloc('nom_cabinet','DF',"", "group"); |
210 |
$form->setBloc('telephone','DF',"", "group"); |
211 |
$form->setBloc('fax','DF',"", "group"); |
212 |
$form->setBloc('email','DF',"", "group"); |
213 |
$form->setBloc('note','DF',"", "group"); |
214 |
// |
215 |
$form->setBloc('note','F'); |
216 |
} |
217 |
|
218 |
/** |
219 |
* SETTER_FORM - setVal (setVal). |
220 |
* |
221 |
* @return void |
222 |
*/ |
223 |
function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) { |
224 |
parent::setVal($form, $maj, $validation); |
225 |
// |
226 |
$form->setVal("pays", "France"); |
227 |
} |
228 |
|
229 |
function setLib(&$form,$maj) { |
230 |
// |
231 |
parent::setLib($form, $maj); |
232 |
$form->setLib('frequent',"<span class=\"om-form-button copy-16\" |
233 |
title=\""._("Sauvegarder cet architecte")."\">"._("Sauvegarder (architecte frequent)")."</span>"); |
234 |
|
235 |
} |
236 |
|
237 |
/** |
238 |
* Ajout d'un champs caché permettant de linker l'id du demandeur |
239 |
* recement ajouté |
240 |
**/ |
241 |
function sousFormSpecificContent($maj) { |
242 |
|
243 |
$id_architecte = $this->getVal("architecte"); |
244 |
if(isset($this->valF["architecte"]) AND !empty($this->valF["architecte"])) { |
245 |
echo "<input id=\"id_retour\" name=\"idRetour\" type=\"hidden\" value=\"". |
246 |
$this->valF["architecte"]."\" />"; |
247 |
} elseif(isset($id_architecte) AND !empty($id_architecte) AND $maj == 110) { |
248 |
echo "<input id=\"id_retour\" name=\"idRetour\" type=\"hidden\" value=\"". |
249 |
$this->getVal("architecte")."\" />"; |
250 |
} |
251 |
} |
252 |
|
253 |
/** |
254 |
* Synthèse de l'architecte pour le formulaire des données techniques |
255 |
*/ |
256 |
function afficherSynthese() { |
257 |
|
258 |
$nom = $this->getVal('nom'); |
259 |
$prenom = $this->getVal('prenom'); |
260 |
|
261 |
//Affichage du bouton pour ajout si dans un objet qui n'est pas en BDD |
262 |
if ( $this->getParameter("maj") === 0 ){ |
263 |
printf ("<span class=\"om-form-button add-16 add_architecte\" |
264 |
onclick=\"popupIt('architecte', |
265 |
'".OM_ROUTE_SOUSFORM."&obj=architecte&action=0'+ |
266 |
'&retourformulaire=donnees_techniques', 860, 'auto', |
267 |
getObjId, 'architecte');\"". |
268 |
">"); |
269 |
printf(_("Saisir un(e) architecte")); |
270 |
} |
271 |
//Affichage du bouton de suppression sinon |
272 |
else { |
273 |
// |
274 |
printf ("<span class=\"om-form-button delete-16 add_architecte\" |
275 |
onclick=\"setDataFrequent('','architecte');\"". |
276 |
"title=\""); |
277 |
printf(_("Supprimer")); |
278 |
printf("\">"); |
279 |
printf(" "); |
280 |
printf("</span>"); |
281 |
// |
282 |
printf ("<span class=\"om-form-button edit-16 add_architecte\" |
283 |
onclick=\"popupIt('architecte', |
284 |
'".OM_ROUTE_SOUSFORM."&obj=architecte&action=1&idx=".$this->getVal($this->clePrimaire)."'+ |
285 |
'&retourformulaire=donnees_techniques', 860, 'auto', |
286 |
getObjId, '".$this->clePrimaire."');\"". |
287 |
"title=\""); |
288 |
printf(_("editer")); |
289 |
printf("\">"); |
290 |
printf("%s %s",$nom,$prenom); |
291 |
} |
292 |
printf ("</span>"); |
293 |
} |
294 |
|
295 |
/** |
296 |
* Le bouton de modification est masqué si on est en modification d'un architecte fréquent |
297 |
*/ |
298 |
function boutonsousformulaire($datasubmit, $maj, $val=null) { |
299 |
if($this->getVal('frequent') != 't' || $maj == 0 ) { |
300 |
if (!$this->correct) { |
301 |
// |
302 |
switch ($maj) { |
303 |
case 0: |
304 |
$bouton = _("Ajouter"); |
305 |
break; |
306 |
case 1: |
307 |
$bouton = _("Modifier"); |
308 |
break; |
309 |
case 2: |
310 |
$bouton = _("Supprimer"); |
311 |
break; |
312 |
} |
313 |
// |
314 |
echo "<input type=\"button\" value=\"".$bouton."\" "; |
315 |
echo "onclick=\"affichersform('".$this->get_absolute_class_name()."', '$datasubmit', this.form);\" "; |
316 |
echo "class=\"om-button\" />"; |
317 |
} |
318 |
} |
319 |
} |
320 |
|
321 |
|
322 |
/** |
323 |
* Indique si la redirection vers le lien de retour est activée ou non. |
324 |
* |
325 |
* L'objectif de cette méthode est de permettre d'activer ou de désactiver |
326 |
* la redirection dans certains contextes. |
327 |
* |
328 |
* @return boolean |
329 |
*/ |
330 |
function is_back_link_redirect_activated() { |
331 |
// |
332 |
if ($this->getParameter("retourformulaire") === 'donnees_techniques') { |
333 |
// |
334 |
return false; |
335 |
} |
336 |
|
337 |
// |
338 |
return true; |
339 |
} |
340 |
|
341 |
/** |
342 |
* Permet de modifier le fil d'Ariane depuis l'objet pour un formulaire |
343 |
* @param string $ent Fil d'Ariane récupéréré |
344 |
* @return Fil d'Ariane |
345 |
*/ |
346 |
function getFormTitle($ent) { |
347 |
// |
348 |
$out = $ent; |
349 |
if ($this->getVal($this->clePrimaire) != "") { |
350 |
$out .= "<span class=\"libelle\"> -> ".$this->getVal($this->clePrimaire)." ".$this->getVal('prenom')." ".$this->getVal('nom')."</span>"; |
351 |
} |
352 |
return $out; |
353 |
} |
354 |
|
355 |
}// fin classe |
356 |
|
357 |
|