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> |
a6613b2e |
108 | {if $csv_key} |
31874f6f |
109 | <option value="update" {if $smarty.request.csv_action eq 'update'}selected="selected"{/if}> |
110 | mettre à jour les champs sélectionnés |
111 | </option> |
a6613b2e |
112 | {/if} |
31874f6f |
113 | </select> |
114 | </div> |
115 | <table class="bicol"> |
116 | <tr> |
117 | <th>Champ</th> |
118 | <th colspan="2">Valeur</th> |
119 | {if $smarty.request.csv_action eq 'update'} |
120 | <th>MàJ</th> |
121 | {/if} |
122 | </tr> |
123 | {foreach from=$csv_fields item=f} |
124 | <tr class="{cycle values="pair,impair"}"> |
a6613b2e |
125 | <td>{$csv_field_desc[$f]|default:$f}</td> |
31874f6f |
126 | <td> |
127 | <select name="csv_value[{$f}]" onchange="showValue('{$f}', this);"> |
128 | <option value="" {if !$smarty.request.csv_value[$f]}selected="selected"{/if}> |
129 | Vide |
130 | </option> |
131 | <option value="user_value" {if $smarty.request.csv_value[$f] eq "user_value"}selected="selected"{/if}> |
132 | Entrer la valeur |
133 | </option> |
134 | <option value="cond_value" {if $smarty.request.csv_value[$f] eq "cond_value"}selected="selected"{/if}> |
135 | Valeur conditionnelle |
136 | </option> |
137 | <optgroup label="Colonnes du CSV"> |
138 | {foreach from=$csv_index item=col} |
139 | <option value="{$col}" {if $smarty.request.csv_value[$f] eq $col}selected="selected"{/if}>{$col}</option> |
140 | {/foreach} |
141 | </optgroup> |
142 | {if $csv_functions|count} |
143 | <optgroup label="Fonctions"> |
144 | {foreach from=$csv_functions key=func item=desc} |
145 | <option value="{$func}" {if $smarty.request.csv_value[$f] eq $func}selected="selected"{/if}>{$desc.desc}</option> |
146 | {/foreach} |
147 | </optgroup> |
148 | {/if} |
149 | </select> |
150 | </td> |
151 | <td> |
152 | <span id="csv_user_value_span[{$f}]" {if $smarty.request.csv_value[$f] neq "user_value"}style="display: none"{/if}> |
153 | <input type="text" name="csv_user_value[{$f}]" value="{$smarty.request.csv_user_value[$f]}" /> |
154 | </span> |
155 | <span id="csv_cond_value_span[{$f}]" {if $smarty.request.csv_value[$f] neq "cond_value"}style="display: none"{/if}> |
156 | Si |
157 | <select name="csv_cond_field[{$f}]"> |
158 | {foreach from=$csv_index item=col} |
159 | <option value="{$col}" {if $smarty.request.csv_cond_field_value[$f] eq $col}selected="selected"{/if}> |
160 | {$col} |
161 | </option> |
162 | {/foreach} |
163 | </select> |
164 | <select name="csv_cond[{$f}]" onchange="showCond('{$f}', this)"> |
165 | <option value="defined" {if $smarty.request.csv_cond[$f] eq "defined"}selected="selected"{/if}> |
166 | défini |
167 | </option> |
168 | <option value="equals" {if $smarty.request.csv_cond[$f] eq "equals"}selected="selected"{/if}> |
169 | est égale à |
170 | </option> |
171 | <option value="contains" {if $smarty.request.csv_cond[$f] eq "contains"}selected="selected"{/if}> |
172 | contient |
173 | </option> |
174 | <option value="contained" {if $smarty.request.csv_cond[$f] eq "contained"}selected="selected"{/if}> |
175 | est contenu dans |
176 | </option> |
177 | <option value="greater" {if $smarty.request.csv_cond[$f] eq "greater"}selected="selected"{/if}> |
178 | supérieur à |
179 | </option> |
180 | <option value="greater_or_equal" {if $smarty.request.csv_cond[$f] eq "greater_or_equal"}selected="selected"{/if}> |
181 | supérieur ou égal à |
182 | </option> |
183 | <option value="lower" {if $smarty.request.csv_cond[$f] eq "lower"}selected="selected"{/if}> |
184 | inférieur à |
185 | </option> |
186 | <option value="lower_or_equal" {if $smarty.request.csv_cond[$f] eq "lower_or_equal"}selected="selected"{/if}> |
187 | inférieur ou égal à |
188 | </option> |
189 | </select> |
190 | <span id="csv_cond_value[{$f}]" {if $smarty.request.csv_cond[$f] eq "defined" || !$smarty.request.csv_cond[$f]}style="display: none"{/if}> |
191 | <input type="text" name="csv_cond_value[{$f}]" value="{$smarty.request.csv_cond_value[$f]}" /> |
192 | </span> |
193 | <br />Alors <input type="text" name="csv_cond_then[{$f}]" value="{$smarty.request.csv_cond_then[$f]}" /> |
194 | <br />Sinon <input type="text" name="csv_cond_else[{$f}]" value="{$smarty.request.csv_cond_else[$f]}" /> |
195 | </span> |
196 | </td> |
197 | {if $smarty.request.csv_action eq 'update'} |
198 | <td class="center"> |
199 | <input type="checkbox" name="csv_update[{$f}]" {if $smarty.request.csv_update[$f]}checked="checked"{/if} /> |
200 | </td> |
201 | {/if} |
202 | </tr> |
203 | {/foreach} |
204 | </table> |
205 | {elseif $csv_page eq 'valid'} |
206 | {if !$csv_done} |
207 | <table class="bicol"> |
208 | <tr> |
209 | {foreach from=$csv_fields item=f} |
a6613b2e |
210 | <th>{$csv_field_desc[$f]|default:$f}</th> |
31874f6f |
211 | {/foreach} |
212 | </tr> |
213 | {foreach from=$csv_preview item=assoc} |
214 | <tr class="{cycle values="pair,impair"}"> |
215 | {foreach from=$csv_fields item=f} |
216 | <td>{$assoc[$f]}</td> |
217 | {/foreach} |
218 | <tr> |
219 | {/foreach} |
220 | </table> |
221 | {else} |
222 | Les données ont été ajoutées. |
223 | {/if} |
224 | {/if} |
225 | </td> |
226 | </tr> |
227 | |
228 | {if !$csv_done} |
229 | <tr> |
230 | <td class="center"> |
231 | <input type="hidden" name="csv_page" value="{$csv_page}" /> |
232 | <input type="hidden" id="csv_next_page" name="csv_next_page" value="{$csv_page}" /> |
233 | <input type="hidden" name="csv" value="{$csv}" /> |
234 | {if $csv_page neq 'values'} |
235 | <input type="hidden" name="csv_action" value="{$smarty.request.csv_action}" /> |
236 | {foreach from=$csv_fields item=f} |
237 | <input type="hidden" name="csv_value[{$f}]" value="{$smarty.request.csv_value[$f]}" /> |
238 | <input type="hidden" name="csv_user_value[{$f}]" value="{$smarty.request.csv_user_value[$f]}" /> |
239 | <input type="hidden" name="csv_cond_field[{$f}]" value="{$smarty.request.csv_cond_field[$f]}" /> |
240 | <input type="hidden" name="csv_cond[{$f}]" value="{$smarty.request.csv_cond[$f]}" /> |
241 | <input type="hidden" name="csv_cond_value[{$f}]" value="{$smarty.request.csv_cond_value[$f]}" /> |
242 | <input type="hidden" name="csv_cond_then[{$f}]" value="{$smarty.request.csv_cond_then[$f]}" /> |
243 | <input type="hidden" name="csv_cond_else[{$f}]" value="{$smarty.request.csv_cond_else[$f]}" /> |
244 | <input type="hidden" name="csv_update[{$f}]" value="{$smarty.request.csv_update[$f]}" /> |
245 | {/foreach} |
246 | {/if} |
247 | {if $csv_page eq 'source'} |
248 | <input type="submit" name="csv_valid" value="Changer le CSV" /> |
249 | {elseif $csv_page eq 'values'} |
250 | <input type="submit" name="csv_valid" value="Aperçu" /> |
251 | {elseif $csv_page eq 'valid'} |
252 | <input type="submit" name="csv_valid" value="Valider" /> |
253 | {/if} |
254 | </td> |
255 | </tr> |
256 | {/if} |
257 | </table> |
258 | </td> |
259 | </tr> |
260 | </table> |
261 | </form> |
262 | |
263 | {* vim:set et sws=2 sts=2 sw=2: *} |