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