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