Bug 35043: Do not have \n or \t appear in PO files
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / csv-profiles.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% SET footerjs = 1 %]
4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>
6     [% IF op == 'add_form' %]
7         [% IF csv_profile %]
8             Modify a CSV profile &rsaquo;
9         [% ELSE %]
10             New CSV profile &rsaquo;
11         [% END %]
12     [% END %]
13     CSV export profiles &rsaquo; Tools &rsaquo; Koha
14 </title>
15 [% INCLUDE 'doc-head-close.inc' %]
16 </head>
17
18 <body id="tools_csv-profiles" class="tools">
19 [% INCLUDE 'header.inc' %]
20 [% INCLUDE 'cat-search.inc' %]
21
22 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
23     <ol>
24         <li>
25             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
26         </li>
27         <li>
28             <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
29         </li>
30         [% IF op == 'add_form' %]
31             <li>
32                 <a href="/cgi-bin/koha/tools/csv-profiles.pl">
33                     CSV profiles
34                 </a>
35             </li>
36             [% IF csv_profile %]
37                 <li>
38                     <a href="#" aria-current="page">Modify a CSV profile</a>
39                 </li>
40             [% ELSE %]
41                 <li>
42                     <a href="#" aria-current="page">New CSV profile</a>
43                 </li>
44             [% END %]
45         [% ELSE %]
46             <li>
47                 <a href="#" aria-current="page">
48                     CSV profiles
49                 </a>
50             </li>
51         [% END %]
52     </ol>
53 </nav>
54
55 <div class="main container-fluid">
56     <div class="row">
57         <div class="col-sm-10 col-sm-push-2">
58             <main>
59
60 [% FOR m IN messages %]
61     <div class="dialog [% m.type | html %]">
62         [% SWITCH m.code %]
63         [% CASE 'error_on_update' %]
64             <span>An error occurred when updating this CSV profile. Perhaps it already exists</span>
65         [% CASE 'error_on_insert' %]
66             <span>An error occurred when adding this CSV profile</span>
67         [% CASE 'error_on_delete' %]
68             <span>An error occurred when deleting this CSV profile. Check the logs</span>
69         [% CASE 'success_on_update' %]
70             <span>CSV profile updated successfully</span>
71         [% CASE 'success_on_insert' %]
72             <span>CSV profile added successfully</span>
73         [% CASE 'success_on_delete' %]
74             <span>CSV profile deleted successfully</span>
75         [% CASE 'already_exists' %]
76             <span>This CSV profile already exists</span>
77         [% CASE %]
78             <span>[% m.code | html %]</span>
79         [% END %]
80     </div>
81 [% END %]
82
83 [% BLOCK list_separator_options %]
84     [% IF selected_separator == ',' %]
85         <option value="," selected="selected">Comma (,)</option>
86     [% ELSE %]
87         <option value=",">Comma (,)</option>
88     [% END %]
89     [% IF selected_separator == '|' %]
90         <option value="|" selected="selected">Pipe (|)</option>
91     [% ELSE %]
92         <option value="|">Pipe (|)</option>
93     [% END %]
94     [% IF selected_separator == ';' %]
95         <option value=";" selected="selected">Semi-colon (;)</option>
96     [% ELSE %]
97         <option value=";">Semi-colon (;)</option>
98     [% END %]
99     [% IF selected_separator == '#' %]
100         <option value="#" selected="selected">Sharp (#)</option>
101     [% ELSE %]
102         <option value="#">Sharp (#)</option>
103     [% END %]
104     [% IF selected_separator == ' ' %]
105         <option value=" " selected="selected">Space ( )</option>
106     [% ELSE %]
107         <option value=" ">Space ( )</option>
108     [% END %]
109     [% tab_char = '\t' %]
110     [% IF selected_separator == '\t' %]
111         <option value="\t" selected="selected">Tabulation ([% tab_char | html %])</option>
112     [% ELSE %]
113         <option value="\t">Tabulation ([% tab_char | html %])</option>
114     [% END %]
115     [% new_line_char = '\n' %]
116     [% IF selected_separator == '\n' %]
117         <option value="\n" selected="selected">New line ([% new_line_char | html %])</option>
118     [% ELSE %]
119         <option value="\n">New line ([% new_line_char | html %])</option>
120     [% END %]
121 [% END %]
122
123 [% BLOCK type_description %]
124     [% IF type_code == 'marc' %] <span>MARC</span>
125     [% ELSIF type_code == 'sql' %] <span>SQL</span>
126     [% ELSE %] <span>Unknown type</span>
127     [% END %]
128 [% END %]
129
130 [% BLOCK used_for_description %]
131     [% IF used_for_code == 'export_records' %] <span>Export records</span>
132     [% ELSIF used_for_code == 'late_issues' %] <span>Late serial issues claims</span>
133     [% ELSIF used_for_code == 'late_orders' %] <span>Export late orders</span>
134     [% ELSIF used_for_code == 'export_basket' %] <span>Basket export in acquisition</span>
135     [% ELSIF used_for_code == 'export_lost_items' %] <span>Export lost items in report</span>
136     [% ELSE %] <span>Unknown usage</span>
137     [% END %]
138 [% END %]
139
140 [% IF op == 'add_form' %]
141     [% IF csv_profile %]
142         <h1>Modify a CSV profile</h1>
143     [% ELSE %]
144         <h1>New CSV profile</h1>
145     [% END %]
146
147     <form action="/cgi-bin/koha/tools/csv-profiles.pl" class="validated" method="post">
148         <input type="hidden" name="op" value="add_validate" />
149         <input type="hidden" name="export_format_id" value="[% csv_profile.export_format_id | html %]" />
150         <fieldset class="rows">
151             <ol>
152                 [% IF csv_profile %]
153                     <li><span class="label">Profile ID: </span>[% csv_profile.export_format_id | html %]</li>
154                 [% END %]
155                 <li>
156                     <label for="profile" class="required">Profile name: </label>
157                     <input type="text" name="profile" id="profile" value="[% csv_profile.profile | html %]" class="required">
158                     <span class="required">Required</span>
159                 </li>
160                 <li>
161                     <label for="type" class="required">Profile type: </label>
162                     <select id="type" name="type">
163                         [% FOREACH type IN [ 'marc' 'sql'] %]
164                         [% IF csv_profile.type == type %]
165                             <option value="[% type | html %]" selected="selected">[% PROCESS type_description type_code = type %]</option>
166                         [% ELSE %]
167                             <option value="[% type | html %]">[% PROCESS type_description type_code = type %]</option>
168                         [% END %]
169                         [% END %]
170                     </select>
171                     <span class="required">Required</span>
172                 </li>
173                 <li class="sql_specific">
174                     <label for="used_for_sql">Usage: </label>
175                     <select id="used_for_sql" name="used_for_sql">
176                         [% FOREACH used_for IN [ 'late_issues' 'late_orders', 'export_basket' 'export_lost_items' ] %]
177                         [% IF csv_profile.used_for == used_for %]
178                             <option value="[% used_for | html %]" selected="selected">[% PROCESS used_for_description used_for_code = used_for %]</option>
179                         [% ELSE %]
180                             <option value="[% used_for | html %]">[% PROCESS used_for_description used_for_code = used_for %]</option>
181                         [% END %]
182                         [% END %]
183                     </select>
184                 </li>
185                 <li class="marc_specific">
186                     <label for="used_for_marc">Usage: </label>
187                     <select id="used_for_marc" name="used_for_marc">
188                         [% FOREACH used_for IN [ 'export_records' ] %]
189                         [% IF csv_profile.used_for == used_for %]
190                             <option value="[% used_for | html %]" selected="selected">[% PROCESS used_for_description used_for_code = used_for %]</option>
191                         [% ELSE %]
192                             <option value="[% used_for | html %]">[% PROCESS used_for_description used_for_code = used_for %]</option>
193                         [% END %]
194                         [% END %]
195                     </select>
196                 </li>
197                 <li>
198                     <label for="description">Profile description: </label>
199                     <textarea cols="50" rows="2" name="description" id="description">[% csv_profile.description | html %]</textarea>
200                 </li>
201                 <li>
202                     <label for="csv_separator">CSV separator: </label>
203                     <select name="csv_separator" id="csv_separator">
204                         [% PROCESS list_separator_options selected_separator=csv_profile.csv_separator || ',' %]
205                     </select>
206                 </li>
207
208                 <li class="marc_specific">
209                     <label for="field_separator">Field separator: </label>
210                     <select name="field_separator" id="field_separator">
211                         [% PROCESS list_separator_options selected_separator=csv_profile.field_separator || '#' %]
212                     </select>
213                 </li>
214
215                 <li class="marc_specific"><label for="subfield_separator">Subfield separator: </label>
216                     <select name="subfield_separator" id="subfield_separator">
217                         [% PROCESS list_separator_options selected_separator=csv_profile.subfield_separator || '|'%]
218                     </select>
219                 </li>
220
221                 <li class="marc_specific"><label for="encoding">Encoding: </label>
222                     <select name="encoding" id="encoding">
223                         [% FOREACH encoding IN encodings %]
224                             [% IF csv_profile.encoding == encoding OR NOT csv_profile AND encoding == 'utf8' %]
225                                 <option selected="selected">[% encoding | html %]</option>
226                             [% ELSE %]
227                                 <option>[% encoding | html %]</option>
228                             [% END %]
229                         [% END %]
230                     </select>
231                 </li>
232
233                 <li class="marc_specific">
234                     <label for="staff_only">Only available on the staff interface: </label>
235                     [% IF csv_profile.staff_only %]
236                         <input type="checkbox" name="staff_only" id="staff_only" value="1" checked="checked">
237                     [% ELSE %]
238                         <input type="checkbox" name="staff_only" id="staff_only" value="1">
239                     [% END %]
240                 </li>
241
242                 <li class="marc_specific">
243                     <label for="marc_content" class="required">Profile MARC fields: </label>
244                     <textarea cols="50" rows="2" name="marc_content" id="marc_content">[% csv_profile.content | html %]</textarea>
245                     <span class="required">Required</span>
246                     <p>You have to define which fields or subfields you want to export, separated by pipes.</p>
247                     <p>You can also use your own headers (instead of the ones from Koha) by prefixing the field number with an header, followed by the equal sign.</p>
248                     <p>Example: Personal name=200|Entry element=210$a|300|009</p>
249                     <p>You can use Template Toolkit tags too. See the help page for more information.</p>
250                 </li>
251
252                 <li class="sql_specific">
253                     <label for="sql_content" class="required">Profile SQL fields: </label>
254                     <textarea cols="50" rows="2" name="sql_content" id="sql_content">[% csv_profile.content | html %]</textarea>
255                     <p>You have to define which fields you want to export, separated by pipes.</p>
256                     <p>You can also use your own headers (instead of the ones from Koha) by prefixing the field name with an header, followed by the equal sign.</p>
257                     <p>Example: Name=subscription.name|Title=subscription.title|Issue number=serial.serialseq</p>
258                     <p>For late issues claims you can use data from following tables: serial, subscription, biblio, biblioitems and aqbookseller.</p>
259                     <p>For basket exports you can use data from following tables: biblio, biblioitems, aqorders, aqbudgets and aqbasket.</p>
260                     <p>For exporting late orders you must provide a profile in Template Toolkit syntax to generate the CSV file.</p>
261                 </li>
262             </ol>
263         </fieldset>
264         <fieldset class="action">
265             <input type="submit" value="Submit" />
266             <a class="cancel" href="/cgi-bin/koha/tools/csv-profiles.pl">Cancel</a>
267         </fieldset>
268     </form>
269 [% END %]
270
271 [% IF op == 'delete_confirm' %]
272     <div class="dialog alert">
273         [% IF csv_profile %]
274             <h1>Delete CSV Profile "[% csv_profile.profile | html %]?"</h1>
275             <form action="/cgi-bin/koha/tools/csv-profiles.pl" method="post">
276                 <input type="hidden" name="op" value="delete_confirmed" />
277                 <input type="hidden" name="export_format_id" value="[% csv_profile.export_format_id | html %]" />
278                 <input type="submit" class="approve" value="Yes, delete" />
279             </form>
280             <form action="/cgi-bin/koha/tools/csv-profiles.pl" method="get">
281                 <input type="submit" class="deny" value="No, do not Delete" />
282             </form>
283         [% ELSE %]
284             This CSV Profile does not exist.
285         [% END %]
286     </div>
287 [% END %]
288
289 [% IF op == 'list' %]
290
291     <div id="toolbar" class="btn-toolbar">
292         <a class="btn btn-default" id="newcsvprofile" href="/cgi-bin/koha/tools/csv-profiles.pl?op=add_form"><i class="fa fa-plus"></i> New CSV profile</a>
293     </div>
294
295     <h1>CSV profiles</h1>
296
297     [% IF csv_profiles %]
298         <table id="table_csv_profiles">
299             <thead>
300                 <th>CSV profile ID</th>
301                 <th>Name</th>
302                 <th>Description</th>
303                 <th>Content</th>
304                 <th>CSV separator</th>
305                 <th>CSV type</th>
306                 <th>Usage</th>
307                 <th class="noExport">Actions</th>
308             </thead>
309             <tbody>
310                 [% FOREACH csv_profile IN csv_profiles %]
311                 <tr>
312                     <td>[% csv_profile.export_format_id | html %]</td>
313                     <td>[% csv_profile.profile | html %]</td>
314                     <td>[% csv_profile.description | html %]</td>
315                     <td>[% csv_profile.content | html | html_line_break %]</td>
316                     <td>[% csv_profile.csv_separator | html %]</td>
317                     <td>[% PROCESS type_description type_code = csv_profile.type %]</td>
318                     <td>[% PROCESS used_for_description used_for_code = csv_profile.used_for %]</td>
319                     <td class="actions">
320                         <a href="/cgi-bin/koha/tools/csv-profiles.pl?op=add_form&amp;export_format_id=[% csv_profile.export_format_id | uri %]" class="btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
321                         <a href="/cgi-bin/koha/tools/csv-profiles.pl?op=delete_confirm&amp;export_format_id=[% csv_profile.export_format_id | uri %]" class="btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</a>
322                     </td>
323                 </tr>
324                 [% END %]
325             </tbody>
326         </table>
327     [% ELSE %]
328         There is no CSV profile defined. <a href="/cgi-bin/koha/tools/csv-profiles.pl?op=add_form">Create a new CSV profile</a>.
329     [% END %]
330 [% END %]
331
332             </main>
333         </div> <!-- /.col-sm-10.col-sm-push-2 -->
334
335         <div class="col-sm-2 col-sm-pull-10">
336             <aside>
337                 [% INCLUDE 'tools-menu.inc' %]
338             </aside>
339         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
340      </div> <!-- /.row -->
341
342 [% MACRO jsinclude BLOCK %]
343     [% Asset.js("js/tools-menu.js") | $raw %]
344     <script>
345         function reloadPage(p) {
346             var id = p.value;
347             if (id != 0) { document.location = "/cgi-bin/koha/tools/csv-profiles.pl?op=add_form&amp;export_format_id=" + id; }
348         }
349         $(document).ready(function() {
350             $("#type").change(function(){
351                 if ( $(this).find("option:selected").val() == "marc" ) {
352                     $("li.marc_specific").show();
353                     $("#marc_content").attr("required", "required");
354                     $("li.sql_specific").hide();
355                     $("#sql_content").removeAttr("required");
356                 } else {
357                     $("li.marc_specific").hide();
358                     $("#marc_content").removeAttr("required");
359                     $("li.sql_specific").show();
360                     $("#sql_content").attr("required", "required");
361                 }
362             });
363             $("#type").change();
364         });
365     </script>
366 [% END %]
367
368 [% INCLUDE 'intranet-bottom.inc' %]