1 |
<?php |
2 |
/** |
3 |
* Ce fichier est destine a permettre la surcharge de certaines methodes de |
4 |
* la classe om_formulaire pour des besoins specifiques de l'application |
5 |
* |
6 |
* @package openmairie_exemple |
7 |
* @version SVN : $Id$ |
8 |
*/ |
9 |
|
10 |
/** |
11 |
* |
12 |
*/ |
13 |
require_once PATH_OPENMAIRIE."om_formulaire.class.php"; |
14 |
|
15 |
/** |
16 |
* |
17 |
*/ |
18 |
class om_formulaire extends formulaire { |
19 |
|
20 |
/** |
21 |
* La valeur du champ est passe par le controle hidden |
22 |
* |
23 |
* @param string $champ Nom du champ |
24 |
* @param integer $validation |
25 |
* @param boolean $DEBUG Parametre inutilise |
26 |
*/ |
27 |
function referencescadastralesstatic($champ, $validation, $DEBUG = false) { |
28 |
|
29 |
// |
30 |
foreach (explode(';', $this->val[$champ]) as $key => $ref) { |
31 |
echo "<span class=\"reference-cadastrale-".$key."\">"; |
32 |
echo $ref; |
33 |
echo "</span> "; |
34 |
} |
35 |
} |
36 |
|
37 |
/** |
38 |
* Liste de données |
39 |
* |
40 |
* @param string $champ Nom du champ |
41 |
* @param integer $validation |
42 |
* @param boolean $DEBUG Parametre inutilise |
43 |
*/ |
44 |
function select_multiple_static($champ,$validation,$DEBUG = false){ |
45 |
|
46 |
$selected_values = explode(",", $this->val[$champ]); |
47 |
// |
48 |
echo "<ul"; |
49 |
echo " name=\"".$champ."[]\""; |
50 |
echo " class=\"select_multiple_static\""; |
51 |
if (!$this->correct) { |
52 |
if (isset($this->onchange) and $this->onchange[$champ] != "") { |
53 |
echo " onchange=\"".$this->onchange[$champ]."\""; |
54 |
} |
55 |
if (isset($this->onkeyup) and $this->onkeyup[$champ] != "") { |
56 |
echo " onkeyup=\"".$this->onkeyup[$champ]."\""; |
57 |
} |
58 |
if (isset($this->onclick) and $this->onclick[$champ] != "") { |
59 |
echo " onclick=\"".$this->onclick[$champ]."\""; |
60 |
} |
61 |
} |
62 |
echo " >\n"; |
63 |
// |
64 |
$k = 0; |
65 |
foreach ($this->select[$champ] as $elem) { |
66 |
while ($k <count($elem)) { |
67 |
echo "<li> "; |
68 |
echo $this->select[$champ][1][$k]; |
69 |
echo "</li>\n"; |
70 |
$k++; |
71 |
} |
72 |
} |
73 |
// |
74 |
echo "</ul>\n"; |
75 |
} |
76 |
|
77 |
function tableau($champ,$validation,$DEBUG = false) { |
78 |
// Ouverture du tableau |
79 |
echo "<table class='om-form-tab-table'>"; |
80 |
|
81 |
// Affichage des entêtes de colonnes |
82 |
echo "<tr class='om-form-tab-tr'>"; |
83 |
foreach ($this->select[$champ]["column_header"] as $value) { |
84 |
echo "<th"; |
85 |
// Si l'entête de colonne n'est pas vide |
86 |
if($value != "") { |
87 |
// Ajoute la classe à l'élément |
88 |
echo " class='om-form-tab-th'"; |
89 |
} |
90 |
echo ">"; |
91 |
//echo "<th class='om-form-tab-th'>"; |
92 |
echo $value; |
93 |
echo "</th>"; |
94 |
} |
95 |
echo "</tr>"; |
96 |
|
97 |
// Initialisation des variables |
98 |
$k=0; |
99 |
$keys = array_keys($this->select[$champ]["values"]); |
100 |
$values = array_values($this->select[$champ]["values"]); |
101 |
|
102 |
// Affichage de chaque ligne |
103 |
for ($i=0; $i<count($this->select[$champ]["row_header"]); $i++) { |
104 |
echo "<tr class='om-form-tab-tr'>"; |
105 |
|
106 |
// Affichage de l'entête de ligne |
107 |
echo "<th"; |
108 |
// Si l'entête de ligne n'est pas vide |
109 |
if($this->select[$champ]["row_header"][$i] != "") { |
110 |
// Ajoute la classe à l'élément |
111 |
echo " class='om-form-tab-th'"; |
112 |
} |
113 |
echo ">"; |
114 |
echo $this->select[$champ]["row_header"][$i]; |
115 |
echo "</th>"; |
116 |
|
117 |
// Affichage des champs |
118 |
for ($j=0; $j<count($this->select[$champ]["column_header"])-1; $j++) { |
119 |
echo "<td class='om-form-tab-td'>"; |
120 |
|
121 |
// Appel de la méthode définie dans setType |
122 |
if (method_exists($this, $this->type[$keys[$i+$j*count($this->select[$champ]["row_header"])]])) { |
123 |
$function=$this->type[$keys[$i+$j*count($this->select[$champ]["row_header"])]]; |
124 |
|
125 |
$this->$function($keys[$i+$j*count($this->select[$champ]["row_header"])], $validation); |
126 |
} else { |
127 |
$this->statiq($keys[$i+$j*count($this->select[$champ]["row_header"])], $validation); |
128 |
} |
129 |
echo "</td>"; |
130 |
$k++; |
131 |
} |
132 |
echo "</tr>"; |
133 |
} |
134 |
echo "</table>"; |
135 |
} |
136 |
|
137 |
/** |
138 |
* Au clique affiche un pop-up contenant le formulaire en ajout de l'objet $champ |
139 |
* @param string $champ Nom du champ |
140 |
* @param integer $validation |
141 |
* @param boolean $DEBUG Parametre inutilise |
142 |
*/ |
143 |
function manage_with_popup($champ,$validation,$DEBUG = false){ |
144 |
|
145 |
//Si on a pas de valeur on affiche un bouton d'ajout |
146 |
if ($this->val[$champ]==''){ |
147 |
printf ("<span class=\"om-form-button add-16 add_".$champ."\" |
148 |
onclick=\"popupIt('".$champ."', |
149 |
'../scr/sousform.php?obj=".$champ."&action=0'+ |
150 |
'&retourformulaire=".$this->getParameter('obj')."', 860, 'auto', |
151 |
getObjId, '".$this->select[$champ]["obj"]."');\"". |
152 |
">"); |
153 |
printf(_("Saisir un(e) %s"),$champ); |
154 |
printf ("</span>"); |
155 |
} |
156 |
//On affiche les données enregistrées et un bouton de suppression |
157 |
else { |
158 |
// |
159 |
printf ("<span class=\"om-form-button delete-16 add_".$champ."\" |
160 |
onclick=\"setDataFrequent('','".$this->getParameter('obj')."');\"". |
161 |
"title=\""); |
162 |
printf(_("Supprimer")); |
163 |
printf("\">"); |
164 |
printf(" "); |
165 |
printf("</span>"); |
166 |
// |
167 |
|
168 |
// |
169 |
printf ("<span class=\"om-form-button edit-16 add_".$champ."\" |
170 |
onclick=\"popupIt('".$champ."', |
171 |
'../scr/sousform.php?obj=".$champ."&action=1&idx=".$this->val[$champ]."'+ |
172 |
'&retourformulaire=".$this->getParameter('obj')."', 860, 'auto', |
173 |
getObjId, '".$this->select[$champ]["obj"]."');\"". |
174 |
"title=\""); |
175 |
printf(_("editer")); |
176 |
printf("\">"); |
177 |
printf(isset($this->select[$champ]["data"])?$this->select[$champ]["data"]:_("Aucun libelle pour la donnee")); |
178 |
printf("</span>"); |
179 |
} |
180 |
// |
181 |
printf ("<input"); |
182 |
printf (" type=\"hidden\""); |
183 |
printf (" name=\"".$champ."\""); |
184 |
printf (" id=\"".$champ."\" "); |
185 |
printf (" value=\"".$this->val[$champ]."\""); |
186 |
printf (" class=\"champFormulaire\""); |
187 |
if (!$this->correct) { |
188 |
if (isset($this->onchange) and $this->onchange[$champ] != "") { |
189 |
printf (" onchange=\"".$this->onchange[$champ]."\""); |
190 |
} |
191 |
if (isset($this->onkeyup) and $this->onkeyup[$champ] != "") { |
192 |
printf (" onkeyup=\"".$this->onkeyup[$champ]."\""); |
193 |
} |
194 |
if (isset($this->onclick) and $this->onclick[$champ] != "") { |
195 |
printf (" onclick=\"".$this->onclick[$champ]."\""); |
196 |
} |
197 |
} else { |
198 |
printf (" disabled=\"disabled\""); |
199 |
} |
200 |
printf (" />\n"); |
201 |
// |
202 |
} |
203 |
|
204 |
/** |
205 |
* La valeur du champ est passé par le champ input hidden |
206 |
* @param string $champ Nom du champ |
207 |
* @param integer $validation |
208 |
* @param boolean $DEBUG Parametre inutilise |
209 |
*/ |
210 |
function checkboxhiddenstatic($champ, $validation, $DEBUG = false) { |
211 |
|
212 |
// Input de type hidden pour passé la valeur à la validation du |
213 |
// formulaire |
214 |
echo "<input"; |
215 |
echo " type=\"hidden\""; |
216 |
echo " id=\"".$champ."\""; |
217 |
echo " name=\"".$champ."\""; |
218 |
echo " value=\"".$this->val[$champ]."\""; |
219 |
echo " class=\"champFormulaire\""; |
220 |
echo " />\n"; |
221 |
|
222 |
// Affichage de la valeur 'Oui' ou 'Non' |
223 |
if ($this->val[$champ] == 1 || $this->val[$champ] == "t" |
224 |
|| $this->val[$champ] == "Oui") { |
225 |
$value = "Oui"; |
226 |
} else { |
227 |
$value = "Non"; |
228 |
} |
229 |
echo "<span id=\"".$champ."\" class=\"field_value\">$value</span>"; |
230 |
} |
231 |
} |
232 |
|
233 |
?> |