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