Commit | Line | Data |
---|---|---|
31874f6f | 1 | {**************************************************************************} |
2 | {* *} | |
179afa7f | 3 | {* Copyright (C) 2003-2008 Polytechnique.org *} |
31874f6f | 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 | ||
0d75939a | 23 | {if $form_title} |
24 | <h1>{$form_title}</h1> | |
25 | {/if} | |
26 | ||
31874f6f | 27 | <script type="text/javascript">//<![CDATA[ |
28 | {literal} | |
29 | function showValue(key, box) | |
30 | { | |
31 | var span_value = document.getElementById('csv_user_value_span[' + key + ']'); | |
32 | var span_cond = document.getElementById('csv_cond_value_span[' + key + ']'); | |
33 | var i = box.selectedIndex; | |
34 | if (box.options[i].value == "user_value") { | |
35 | span_value.style.display = ""; | |
36 | span_cond.style.display = "none"; | |
37 | } else if(box.options[i].value == "cond_value") { | |
38 | span_value.style.display = "none"; | |
39 | span_cond.style.display = ""; | |
40 | } else { | |
41 | span_value.style.display = "none"; | |
42 | span_conf.style.display = "none"; | |
43 | } | |
44 | } | |
45 | function showCond(key, box) | |
46 | { | |
47 | var line = document.getElementById('csv_cond_value[' + key + ']'); | |
48 | var i = box.selectedIndex; | |
49 | if (box.options[i].value == "defined") { | |
50 | line.style.display = "none"; | |
51 | } else { | |
52 | line.style.display = ""; | |
53 | } | |
54 | } | |
55 | function gotoPage(page) | |
56 | { | |
57 | document.getElementById('csv_next_page').value = page; | |
58 | document.getElementById('csv_form').submit(); | |
59 | return false; | |
60 | } | |
61 | {/literal} | |
62 | //]]></script> | |
63 | <form action="{$csv_path}" method="post" id="csv_form"> | |
e61326ed | 64 | {xsrf_token_field} |
252c8ee0 FB |
65 | <div class="center" style="padding-bottom: 1em"> |
66 | Import d'un CSV : | |
31874f6f | 67 | {if $csv_page eq 'source'} |
252c8ee0 FB |
68 | <span class="erreur">Choisir la source</span> |
69 | {else} | |
70 | <a href="{$csv_path}" onclick="return gotoPage('source');">Choisir la source</a> | |
71 | {/if} | |
72 | » | |
73 | {if $csv_page eq 'values'} | |
74 | <span class="erreur">Définir les valeurs</span> | |
75 | {elseif $smarty.session.csv} | |
76 | <a href="{$csv_path}" onclick="return gotoPage('values');">Définir les valeurs</a> | |
77 | {else} | |
78 | Définir les valeurs | |
79 | {/if} | |
80 | » | |
81 | {if $csv_page eq 'valid'} | |
82 | <span class="erreur">Vérifier et valider</span> | |
83 | {elseif $csv_action} | |
84 | <a href="{$csv_path}" onclick="return gotoPage('valid');">Vérifier et valider</a> | |
85 | {else} | |
86 | Vérifier et valider | |
87 | {/if} | |
88 | </div> | |
89 | {if $csv_page eq 'source'} | |
90 | <div> | |
91 | <textarea name="csv_source" rows="20" cols="80">{$smarty.session.csv|default:$smarty.session.csv_source}</textarea><br /> | |
92 | Entrez les données sous la forme suivante (avec | |
93 | <input type="text" name="csv_separator" value="{$smarty.session.csv_separator|default:";"}" maxlength="1" size="1" /> | |
94 | comme séparateur) :<br/> | |
95 | <pre class="center">TITRE1{$smarty.session.csv_separator|default:";"}TITRE2{$smarty.session.csv_separator|default:";"}... | |
2f95cd8f | 96 | val1_1{$smarty.session.csv_separator|default:";"}val1_2{$smarty.session.csv_separator|default:";"}... |
97 | val2_1{$smarty.session.csv_separator|default:";"}val2_2{$smarty.session.csv_separator|default:";"}... | |
98 | val3_1{$smarty.session.csv_separator|default:";"}val3_2{$smarty.session.csv_separator|default:";"}...</pre> | |
252c8ee0 FB |
99 | </div> |
100 | {elseif $csv_page eq 'values'} | |
31874f6f | 101 | <div class="center"> |
e8439508 | 102 | Action à effectuer si l'entrée existe : |
31874f6f | 103 | <select name="csv_action" onchange="this.form.submit()"> |
2f95cd8f | 104 | <option value="insert" {if $smarty.session.csv_action eq 'insert'}selected="selected"{/if}> |
31874f6f | 105 | ne rien faire |
106 | </option> | |
2f95cd8f | 107 | <option value="replace" {if $smarty.session.csv_action eq 'replace'}selected="selected"{/if}> |
a7de4ef7 | 108 | remplacer par la nouvelle entrée |
31874f6f | 109 | </option> |
a6613b2e | 110 | {if $csv_key} |
2f95cd8f | 111 | <option value="update" {if $smarty.session.csv_action eq 'update'}selected="selected"{/if}> |
a7de4ef7 | 112 | mettre à jour les champs sélectionnés |
31874f6f | 113 | </option> |
a6613b2e | 114 | {/if} |
31874f6f | 115 | </select> |
116 | </div> | |
117 | <table class="bicol"> | |
118 | <tr> | |
119 | <th>Champ</th> | |
120 | <th colspan="2">Valeur</th> | |
2f95cd8f | 121 | {if $smarty.session.csv_action eq 'update'} |
a7de4ef7 | 122 | <th>MàJ</th> |
31874f6f | 123 | {/if} |
124 | </tr> | |
125 | {foreach from=$csv_fields item=f} | |
126 | <tr class="{cycle values="pair,impair"}"> | |
a6613b2e | 127 | <td>{$csv_field_desc[$f]|default:$f}</td> |
31874f6f | 128 | <td> |
129 | <select name="csv_value[{$f}]" onchange="showValue('{$f}', this);"> | |
2f95cd8f | 130 | <option value="" {if !$smarty.session.csv_value[$f]}selected="selected"{/if}> |
31874f6f | 131 | Vide |
132 | </option> | |
2f95cd8f | 133 | <option value="user_value" {if $smarty.session.csv_value[$f] eq "user_value"}selected="selected"{/if}> |
31874f6f | 134 | Entrer la valeur |
135 | </option> | |
2f95cd8f | 136 | <option value="cond_value" {if $smarty.session.csv_value[$f] eq "cond_value"}selected="selected"{/if}> |
31874f6f | 137 | Valeur conditionnelle |
138 | </option> | |
139 | <optgroup label="Colonnes du CSV"> | |
140 | {foreach from=$csv_index item=col} | |
2f95cd8f | 141 | <option value="{$col}" {if $smarty.session.csv_value[$f] eq $col}selected="selected"{/if}>{$col}</option> |
31874f6f | 142 | {/foreach} |
143 | </optgroup> | |
144 | {if $csv_functions|count} | |
145 | <optgroup label="Fonctions"> | |
146 | {foreach from=$csv_functions key=func item=desc} | |
2f95cd8f | 147 | <option value="{$func}" {if $smarty.session.csv_value[$f] eq $func}selected="selected"{/if}>{$desc.desc}</option> |
31874f6f | 148 | {/foreach} |
149 | </optgroup> | |
150 | {/if} | |
151 | </select> | |
152 | </td> | |
153 | <td> | |
2f95cd8f | 154 | <span id="csv_user_value_span[{$f}]" {if $smarty.session.csv_value[$f] neq "user_value"}style="display: none"{/if}> |
155 | <input type="text" name="csv_user_value[{$f}]" value="{$smarty.session.csv_user_value[$f]}" /> | |
31874f6f | 156 | </span> |
2f95cd8f | 157 | <span id="csv_cond_value_span[{$f}]" {if $smarty.session.csv_value[$f] neq "cond_value"}style="display: none"{/if}> |
31874f6f | 158 | Si |
159 | <select name="csv_cond_field[{$f}]"> | |
160 | {foreach from=$csv_index item=col} | |
2f95cd8f | 161 | <option value="{$col}" {if $smarty.session.csv_cond_field_value[$f] eq $col}selected="selected"{/if}> |
31874f6f | 162 | {$col} |
163 | </option> | |
164 | {/foreach} | |
165 | </select> | |
166 | <select name="csv_cond[{$f}]" onchange="showCond('{$f}', this)"> | |
2f95cd8f | 167 | <option value="defined" {if $smarty.session.csv_cond[$f] eq "defined"}selected="selected"{/if}> |
a7de4ef7 | 168 | défini |
31874f6f | 169 | </option> |
2f95cd8f | 170 | <option value="equals" {if $smarty.session.csv_cond[$f] eq "equals"}selected="selected"{/if}> |
a7de4ef7 | 171 | est égale à |
31874f6f | 172 | </option> |
2f95cd8f | 173 | <option value="contains" {if $smarty.session.csv_cond[$f] eq "contains"}selected="selected"{/if}> |
31874f6f | 174 | contient |
175 | </option> | |
2f95cd8f | 176 | <option value="contained" {if $smarty.session.csv_cond[$f] eq "contained"}selected="selected"{/if}> |
31874f6f | 177 | est contenu dans |
178 | </option> | |
2f95cd8f | 179 | <option value="greater" {if $smarty.session.csv_cond[$f] eq "greater"}selected="selected"{/if}> |
a7de4ef7 | 180 | supérieur à |
31874f6f | 181 | </option> |
2f95cd8f | 182 | <option value="greater_or_equal" {if $smarty.session.csv_cond[$f] eq "greater_or_equal"}selected="selected"{/if}> |
a7de4ef7 | 183 | supérieur ou égal à |
31874f6f | 184 | </option> |
2f95cd8f | 185 | <option value="lower" {if $smarty.session.csv_cond[$f] eq "lower"}selected="selected"{/if}> |
a7de4ef7 | 186 | inférieur à |
31874f6f | 187 | </option> |
2f95cd8f | 188 | <option value="lower_or_equal" {if $smarty.session.csv_cond[$f] eq "lower_or_equal"}selected="selected"{/if}> |
a7de4ef7 | 189 | inférieur ou égal à |
31874f6f | 190 | </option> |
191 | </select> | |
2f95cd8f | 192 | <span id="csv_cond_value[{$f}]" {if $smarty.session.csv_cond[$f] eq "defined" || !$smarty.session.csv_cond[$f]}style="display: none"{/if}> |
193 | <input type="text" name="csv_cond_value[{$f}]" value="{$smarty.session.csv_cond_value[$f]}" /> | |
31874f6f | 194 | </span> |
2f95cd8f | 195 | <br />Alors <input type="text" name="csv_cond_then[{$f}]" value="{$smarty.session.csv_cond_then[$f]}" /> |
196 | <br />Sinon <input type="text" name="csv_cond_else[{$f}]" value="{$smarty.session.csv_cond_else[$f]}" /> | |
31874f6f | 197 | </span> |
198 | </td> | |
2f95cd8f | 199 | {if $smarty.session.csv_action eq 'update'} |
31874f6f | 200 | <td class="center"> |
2f95cd8f | 201 | <input type="checkbox" name="csv_update[{$f}]" {if $smarty.session.csv_update[$f]}checked="checked"{/if} /> |
31874f6f | 202 | </td> |
203 | {/if} | |
204 | </tr> | |
205 | {/foreach} | |
206 | </table> | |
207 | {elseif $csv_page eq 'valid'} | |
208 | {if !$csv_done} | |
209 | <table class="bicol"> | |
210 | <tr> | |
211 | {foreach from=$csv_fields item=f} | |
a6613b2e | 212 | <th>{$csv_field_desc[$f]|default:$f}</th> |
31874f6f | 213 | {/foreach} |
214 | </tr> | |
215 | {foreach from=$csv_preview item=assoc} | |
216 | <tr class="{cycle values="pair,impair"}"> | |
217 | {foreach from=$csv_fields item=f} | |
218 | <td>{$assoc[$f]}</td> | |
219 | {/foreach} | |
220 | <tr> | |
221 | {/foreach} | |
222 | </table> | |
223 | {else} | |
a7de4ef7 | 224 | Les données ont été ajoutées. |
31874f6f | 225 | {/if} |
226 | {/if} | |
31874f6f | 227 | |
228 | {if !$csv_done} | |
252c8ee0 | 229 | <div class="center"> |
31874f6f | 230 | <input type="hidden" name="csv_page" value="{$csv_page}" /> |
231 | <input type="hidden" id="csv_next_page" name="csv_next_page" value="{$csv_page}" /> | |
31874f6f | 232 | {if $csv_page eq 'source'} |
233 | <input type="submit" name="csv_valid" value="Changer le CSV" /> | |
234 | {elseif $csv_page eq 'values'} | |
a7de4ef7 | 235 | <input type="submit" name="csv_valid" value="Aperçu" /> |
31874f6f | 236 | {elseif $csv_page eq 'valid'} |
237 | <input type="submit" name="csv_valid" value="Valider" /> | |
238 | {/if} | |
252c8ee0 | 239 | </div> |
31874f6f | 240 | {/if} |
31874f6f | 241 | </form> |
242 | ||
a7de4ef7 | 243 | {* vim:set et sws=2 sts=2 sw=2 enc=utf-8: *} |