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