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