31874f6f |
1 | {**************************************************************************} |
2 | {* *} |
3 | {* Copyright (C) 2003-2006 Polytechnique.org *} |
4 | {* http://opensource.polytechnique.org/ *} |
5 | {* *} |
6 | {* This program is free software; you can redistribute it and/or modify *} |
7 | {* it under the terms of the GNU General Public License as published by *} |
8 | {* the Free Software Foundation; either version 2 of the License, or *} |
9 | {* (at your option) any later version. *} |
10 | {* *} |
11 | {* This program is distributed in the hope that it will be useful, *} |
12 | {* but WITHOUT ANY WARRANTY; without even the implied warranty of *} |
13 | {* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *} |
14 | {* GNU General Public License for more details. *} |
15 | {* *} |
16 | {* You should have received a copy of the GNU General Public License *} |
17 | {* along with this program; if not, write to the Free Software *} |
18 | {* Foundation, Inc., *} |
19 | {* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *} |
20 | {* *} |
21 | {**************************************************************************} |
22 | |
23 | <script type="text/javascript">//<![CDATA[ |
24 | {literal} |
25 | function showValue(key, box) |
26 | { |
27 | var span_value = document.getElementById('csv_user_value_span[' + key + ']'); |
28 | var span_cond = document.getElementById('csv_cond_value_span[' + key + ']'); |
29 | var i = box.selectedIndex; |
30 | if (box.options[i].value == "user_value") { |
31 | span_value.style.display = ""; |
32 | span_cond.style.display = "none"; |
33 | } else if(box.options[i].value == "cond_value") { |
34 | span_value.style.display = "none"; |
35 | span_cond.style.display = ""; |
36 | } else { |
37 | span_value.style.display = "none"; |
38 | span_conf.style.display = "none"; |
39 | } |
40 | } |
41 | function showCond(key, box) |
42 | { |
43 | var line = document.getElementById('csv_cond_value[' + key + ']'); |
44 | var i = box.selectedIndex; |
45 | if (box.options[i].value == "defined") { |
46 | line.style.display = "none"; |
47 | } else { |
48 | line.style.display = ""; |
49 | } |
50 | } |
51 | function gotoPage(page) |
52 | { |
53 | document.getElementById('csv_next_page').value = page; |
54 | document.getElementById('csv_form').submit(); |
55 | return false; |
56 | } |
57 | {/literal} |
58 | //]]></script> |
59 | <form action="{$csv_path}" method="post" id="csv_form"> |
60 | <table class="cadre_a_onglet" cellpadding="0" cellspacing="0" style="width: 98%; margin-left:1%;"> |
61 | <tr> |
62 | <td> |
63 | <ul id="onglet"> |
64 | {if $csv_page eq 'source'} |
65 | <li class="actif">1 - Choisir<br />la source</li> |
66 | {else} |
67 | <li><a href="{$csv_path}" onclick="return gotoPage('source');">1 - Choisir<br />la source</a></li> |
68 | {/if} |
69 | {if $csv_page eq 'values'} |
70 | <li class="actif">2 - Définir<br />les valeurs</li> |
71 | {elseif $csv} |
72 | <li><a href="{$csv_path}" onclick="return gotoPage('values');">2 - Définir<br />les valeurs</a></li> |
73 | {else} |
74 | <li>2 - Définir<br />les valeurs</li> |
75 | {/if} |
76 | {if $csv_page eq 'valid'} |
77 | <li class="actif">3 - Vérifier<br />et valider</li> |
78 | {elseif $csv_action} |
79 | <li><a href="{$csv_path}" onclick="return gotoPage('valid');">3 - Vérifier<br />et valider</a></li> |
80 | {else} |
81 | <li>3 - Vérifier<br />et valider</li> |
82 | {/if} |
83 | </ul> |
84 | </td> |
85 | </tr> |
86 | <tr> |
87 | <td class="conteneur_tab"> |
88 | <table style="width: 100%"> |
89 | <tr> |
90 | <td> |
91 | {if $csv_page eq 'source'} |
92 | <textarea name="csv_source" rows="20" cols="80">{$csv|default:$smarty.request.csv_source}</textarea><br /> |
93 | Entrez les données sous la forme :<br /> |
94 | <pre class="center">TITRE1;TITRE2;... |
95 | val1_1;val1_2;... |
96 | val2_1;val2_2;... |
97 | val3_1;val3_2;...</pre> |
98 | {elseif $csv_page eq 'values'} |
99 | <div class="center"> |
100 | Action à effectuer si l'entrée existe : |
101 | <select name="csv_action" onchange="this.form.submit()"> |
102 | <option value="insert" {if $smarty.request.csv_action eq 'insert'}selected="selected"{/if}> |
103 | ne rien faire |
104 | </option> |
105 | <option value="replace" {if $smarty.request.csv_action eq 'replace'}selected="selected"{/if}> |
106 | remplacer par la nouvelle entrée |
107 | </option> |
108 | <option value="update" {if $smarty.request.csv_action eq 'update'}selected="selected"{/if}> |
109 | mettre à jour les champs sélectionnés |
110 | </option> |
111 | </select> |
112 | </div> |
113 | <table class="bicol"> |
114 | <tr> |
115 | <th>Champ</th> |
116 | <th colspan="2">Valeur</th> |
117 | {if $smarty.request.csv_action eq 'update'} |
118 | <th>MàJ</th> |
119 | {/if} |
120 | </tr> |
121 | {foreach from=$csv_fields item=f} |
122 | <tr class="{cycle values="pair,impair"}"> |
123 | <td>{$f}</td> |
124 | <td> |
125 | <select name="csv_value[{$f}]" onchange="showValue('{$f}', this);"> |
126 | <option value="" {if !$smarty.request.csv_value[$f]}selected="selected"{/if}> |
127 | Vide |
128 | </option> |
129 | <option value="user_value" {if $smarty.request.csv_value[$f] eq "user_value"}selected="selected"{/if}> |
130 | Entrer la valeur |
131 | </option> |
132 | <option value="cond_value" {if $smarty.request.csv_value[$f] eq "cond_value"}selected="selected"{/if}> |
133 | Valeur conditionnelle |
134 | </option> |
135 | <optgroup label="Colonnes du CSV"> |
136 | {foreach from=$csv_index item=col} |
137 | <option value="{$col}" {if $smarty.request.csv_value[$f] eq $col}selected="selected"{/if}>{$col}</option> |
138 | {/foreach} |
139 | </optgroup> |
140 | {if $csv_functions|count} |
141 | <optgroup label="Fonctions"> |
142 | {foreach from=$csv_functions key=func item=desc} |
143 | <option value="{$func}" {if $smarty.request.csv_value[$f] eq $func}selected="selected"{/if}>{$desc.desc}</option> |
144 | {/foreach} |
145 | </optgroup> |
146 | {/if} |
147 | </select> |
148 | </td> |
149 | <td> |
150 | <span id="csv_user_value_span[{$f}]" {if $smarty.request.csv_value[$f] neq "user_value"}style="display: none"{/if}> |
151 | <input type="text" name="csv_user_value[{$f}]" value="{$smarty.request.csv_user_value[$f]}" /> |
152 | </span> |
153 | <span id="csv_cond_value_span[{$f}]" {if $smarty.request.csv_value[$f] neq "cond_value"}style="display: none"{/if}> |
154 | Si |
155 | <select name="csv_cond_field[{$f}]"> |
156 | {foreach from=$csv_index item=col} |
157 | <option value="{$col}" {if $smarty.request.csv_cond_field_value[$f] eq $col}selected="selected"{/if}> |
158 | {$col} |
159 | </option> |
160 | {/foreach} |
161 | </select> |
162 | <select name="csv_cond[{$f}]" onchange="showCond('{$f}', this)"> |
163 | <option value="defined" {if $smarty.request.csv_cond[$f] eq "defined"}selected="selected"{/if}> |
164 | défini |
165 | </option> |
166 | <option value="equals" {if $smarty.request.csv_cond[$f] eq "equals"}selected="selected"{/if}> |
167 | est égale à |
168 | </option> |
169 | <option value="contains" {if $smarty.request.csv_cond[$f] eq "contains"}selected="selected"{/if}> |
170 | contient |
171 | </option> |
172 | <option value="contained" {if $smarty.request.csv_cond[$f] eq "contained"}selected="selected"{/if}> |
173 | est contenu dans |
174 | </option> |
175 | <option value="greater" {if $smarty.request.csv_cond[$f] eq "greater"}selected="selected"{/if}> |
176 | supérieur à |
177 | </option> |
178 | <option value="greater_or_equal" {if $smarty.request.csv_cond[$f] eq "greater_or_equal"}selected="selected"{/if}> |
179 | supérieur ou égal à |
180 | </option> |
181 | <option value="lower" {if $smarty.request.csv_cond[$f] eq "lower"}selected="selected"{/if}> |
182 | inférieur à |
183 | </option> |
184 | <option value="lower_or_equal" {if $smarty.request.csv_cond[$f] eq "lower_or_equal"}selected="selected"{/if}> |
185 | inférieur ou égal à |
186 | </option> |
187 | </select> |
188 | <span id="csv_cond_value[{$f}]" {if $smarty.request.csv_cond[$f] eq "defined" || !$smarty.request.csv_cond[$f]}style="display: none"{/if}> |
189 | <input type="text" name="csv_cond_value[{$f}]" value="{$smarty.request.csv_cond_value[$f]}" /> |
190 | </span> |
191 | <br />Alors <input type="text" name="csv_cond_then[{$f}]" value="{$smarty.request.csv_cond_then[$f]}" /> |
192 | <br />Sinon <input type="text" name="csv_cond_else[{$f}]" value="{$smarty.request.csv_cond_else[$f]}" /> |
193 | </span> |
194 | </td> |
195 | {if $smarty.request.csv_action eq 'update'} |
196 | <td class="center"> |
197 | <input type="checkbox" name="csv_update[{$f}]" {if $smarty.request.csv_update[$f]}checked="checked"{/if} /> |
198 | </td> |
199 | {/if} |
200 | </tr> |
201 | {/foreach} |
202 | </table> |
203 | {elseif $csv_page eq 'valid'} |
204 | {if !$csv_done} |
205 | <table class="bicol"> |
206 | <tr> |
207 | {foreach from=$csv_fields item=f} |
208 | <th>{$f}</th> |
209 | {/foreach} |
210 | </tr> |
211 | {foreach from=$csv_preview item=assoc} |
212 | <tr class="{cycle values="pair,impair"}"> |
213 | {foreach from=$csv_fields item=f} |
214 | <td>{$assoc[$f]}</td> |
215 | {/foreach} |
216 | <tr> |
217 | {/foreach} |
218 | </table> |
219 | {else} |
220 | Les données ont été ajoutées. |
221 | {/if} |
222 | {/if} |
223 | </td> |
224 | </tr> |
225 | |
226 | {if !$csv_done} |
227 | <tr> |
228 | <td class="center"> |
229 | <input type="hidden" name="csv_page" value="{$csv_page}" /> |
230 | <input type="hidden" id="csv_next_page" name="csv_next_page" value="{$csv_page}" /> |
231 | <input type="hidden" name="csv" value="{$csv}" /> |
232 | {if $csv_page neq 'values'} |
233 | <input type="hidden" name="csv_action" value="{$smarty.request.csv_action}" /> |
234 | {foreach from=$csv_fields item=f} |
235 | <input type="hidden" name="csv_value[{$f}]" value="{$smarty.request.csv_value[$f]}" /> |
236 | <input type="hidden" name="csv_user_value[{$f}]" value="{$smarty.request.csv_user_value[$f]}" /> |
237 | <input type="hidden" name="csv_cond_field[{$f}]" value="{$smarty.request.csv_cond_field[$f]}" /> |
238 | <input type="hidden" name="csv_cond[{$f}]" value="{$smarty.request.csv_cond[$f]}" /> |
239 | <input type="hidden" name="csv_cond_value[{$f}]" value="{$smarty.request.csv_cond_value[$f]}" /> |
240 | <input type="hidden" name="csv_cond_then[{$f}]" value="{$smarty.request.csv_cond_then[$f]}" /> |
241 | <input type="hidden" name="csv_cond_else[{$f}]" value="{$smarty.request.csv_cond_else[$f]}" /> |
242 | <input type="hidden" name="csv_update[{$f}]" value="{$smarty.request.csv_update[$f]}" /> |
243 | {/foreach} |
244 | {/if} |
245 | {if $csv_page eq 'source'} |
246 | <input type="submit" name="csv_valid" value="Changer le CSV" /> |
247 | {elseif $csv_page eq 'values'} |
248 | <input type="submit" name="csv_valid" value="Aperçu" /> |
249 | {elseif $csv_page eq 'valid'} |
250 | <input type="submit" name="csv_valid" value="Valider" /> |
251 | {/if} |
252 | </td> |
253 | </tr> |
254 | {/if} |
255 | </table> |
256 | </td> |
257 | </tr> |
258 | </table> |
259 | </form> |
260 | |
261 | {* vim:set et sws=2 sts=2 sw=2: *} |