Bug 27631: tools and virtualshelves folders
[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     [% IF selected_separator == '\t' %]
110         <option value="\t" selected="selected">Tabulation (\t)</option>
111     [% ELSE %]
112         <option value="\t">Tabulation (\t)</option>
113     [% END %]
114     [% IF selected_separator == '\n' %]
115         <option value="\n" selected="selected">New line (\n)</option>
116     [% ELSE %]
117         <option value="\n">New line (\n)</option>
118     [% END %]
119 [% END %]
120
121 [% BLOCK type_description %]
122     [% IF type_code == 'marc' %] MARC
123     [% ELSIF type_code == 'sql' %] SQL
124     [% ELSE %] Unknown type
125     [% END %]
126 [% END %]
127
128 [% BLOCK used_for_description %]
129     [% IF used_for_code == 'export_records' %]<span> Export records</span>
130     [% ELSIF used_for_code == 'late_issues' %]<span> Late serial issues claims</span>
131     [% ELSIF used_for_code == 'late_orders' %]<span> Export late orders</span>
132     [% ELSIF used_for_code == 'export_basket' %]<span> Basket export in acquisition</span>
133     [% ELSIF used_for_code == 'export_lost_items' %]<span> Export lost items in report</span>
134     [% ELSE %]<span> Unknown usage</span>
135     [% END %]
136 [% END %]
137
138 [% IF op == 'add_form' %]
139     [% IF csv_profile %]
140         <h1>Modify a CSV profile</h1>
141     [% ELSE %]
142         <h1>New CSV profile</h1>
143     [% END %]
144
145     <form action="/cgi-bin/koha/tools/csv-profiles.pl" class="validated" method="post">
146         <input type="hidden" name="op" value="add_validate" />
147         <input type="hidden" name="export_format_id" value="[% csv_profile.export_format_id | html %]" />
148         <fieldset class="rows">
149             <ol>
150                 [% IF csv_profile %]
151                     <li><span class="label">Profile ID: </span>[% csv_profile.export_format_id | html %]</li>
152                 [% END %]
153                 <li>
154                     <label for="profile" class="required">Profile name: </label>
155                     <input type="text" name="profile" id="profile" value="[% csv_profile.profile | html %]" class="required">
156                     <span class="required">Required</span>
157                 </li>
158                 <li>
159                     <label for="type" class="required">Profile type: </label>
160                     <select id="type" name="type">
161                         [% FOREACH type IN [ 'marc' 'sql'] %]
162                         [% IF csv_profile.type == type %]
163                             <option value="[% type | html %]" selected="selected">[% PROCESS type_description type_code = type %]</option>
164                         [% ELSE %]
165                             <option value="[% type | html %]">[% PROCESS type_description type_code = type %]</option>
166                         [% END %]
167                         [% END %]
168                     </select>
169                     <span class="required">Required</span>
170                 </li>
171                 <li class="sql_specific">
172                     <label for="used_for_sql">Usage: </label>
173                     <select id="used_for_sql" name="used_for_sql">
174                         [% FOREACH used_for IN [ 'late_issues' 'late_orders', 'export_basket' 'export_lost_items' ] %]
175                         [% IF csv_profile.used_for == used_for %]
176                             <option value="[% used_for | html %]" selected="selected">[% PROCESS used_for_description used_for_code = used_for %]</option>
177                         [% ELSE %]
178                             <option value="[% used_for | html %]">[% PROCESS used_for_description used_for_code = used_for %]</option>
179                         [% END %]
180                         [% END %]
181                     </select>
182                 </li>
183                 <li class="marc_specific">
184                     <label for="used_for_marc">Usage: </label>
185                     <select id="used_for_marc" name="used_for_marc">
186                         [% FOREACH used_for IN [ 'export_records' ] %]
187                         [% IF csv_profile.used_for == used_for %]
188                             <option value="[% used_for | html %]" selected="selected">[% PROCESS used_for_description used_for_code = used_for %]</option>
189                         [% ELSE %]
190                             <option value="[% used_for | html %]">[% PROCESS used_for_description used_for_code = used_for %]</option>
191                         [% END %]
192                         [% END %]
193                     </select>
194                 </li>
195                 <li>
196                     <label for="description">Profile description: </label>
197                     <textarea cols="50" rows="2" name="description" id="description">[% csv_profile.description | html %]</textarea>
198                 </li>
199                 <li>
200                     <label for="csv_separator">CSV separator: </label>
201                     <select name="csv_separator" id="csv_separator">
202                         [% PROCESS list_separator_options selected_separator=csv_profile.csv_separator || ',' %]
203                     </select>
204                 </li>
205
206                 <li class="marc_specific">
207                     <label for="field_separator">Field separator: </label>
208                     <select name="field_separator" id="field_separator">
209                         [% PROCESS list_separator_options selected_separator=csv_profile.field_separator || '#' %]
210                     </select>
211                 </li>
212
213                 <li class="marc_specific"><label for="subfield_separator">Subfield separator: </label>
214                     <select name="subfield_separator" id="subfield_separator">
215                         [% PROCESS list_separator_options selected_separator=csv_profile.subfield_separator || '|'%]
216                     </select>
217                 </li>
218
219                 <li class="marc_specific"><label for="encoding">Encoding: </label>
220                     <select name="encoding" id="encoding">
221                         [% FOREACH encoding IN encodings %]
222                             [% IF csv_profile.encoding == encoding OR NOT csv_profile AND encoding == 'utf8' %]
223                                 <option selected="selected">[% encoding | html %]</option>
224                             [% ELSE %]
225                                 <option>[% encoding | html %]</option>
226                             [% END %]
227                         [% END %]
228                     </select>
229                 </li>
230
231                 <li class="marc_specific">
232                     <label for="staff_only">Only available on the staff interface: </label>
233                     [% IF csv_profile.staff_only %]
234                         <input type="checkbox" name="staff_only" id="staff_only" value="1" checked="checked">
235                     [% ELSE %]
236                         <input type="checkbox" name="staff_only" id="staff_only" value="1">
237                     [% END %]
238                 </li>
239
240                 <li class="marc_specific">
241                     <label for="marc_content" class="required">Profile MARC fields: </label>
242                     <textarea cols="50" rows="2" name="marc_content" id="marc_content">[% csv_profile.content | html %]</textarea>
243                     <span class="required">Required</span>
244                     <p>You have to define which fields or subfields you want to export, separated by pipes.</p>
245                     <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>
246                     <p>Example: Personal name=200|Entry element=210$a|300|009</p>
247                     <p>You can use Template Toolkit tags too. See the help page for more information.</p>
248                 </li>
249
250                 <li class="sql_specific">
251                     <label for="sql_content" class="required">Profile SQL fields: </label>
252                     <textarea cols="50" rows="2" name="sql_content" id="sql_content">[% csv_profile.content | html %]</textarea>
253                     <p>You have to define which fields you want to export, separated by pipes.</p>
254                     <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>
255                     <p>Example: Name=subscription.name|Title=subscription.title|Issue number=serial.serialseq</p>
256                     <p>For late issues claims you can use data from following tables: serial, subscription, biblio, biblioitems and aqbookseller.</p>
257                     <p>For basket exports you can use data from following tables: biblio, biblioitems, aqorders, aqbudgets and aqbasket.</p>
258                     <p>For exporting late orders you must provide a profile in Template Toolkit syntax to generate the CSV file.</p>
259                 </li>
260             </ol>
261         </fieldset>
262         <fieldset class="action">
263             <input type="submit" value="Submit" />
264             <a class="cancel" href="/cgi-bin/koha/tools/csv-profiles.pl">Cancel</a>
265         </fieldset>
266     </form>
267 [% END %]
268
269 [% IF op == 'delete_confirm' %]
270     <div class="dialog alert">
271         [% IF csv_profile %]
272             <h1>Delete CSV Profile "[% csv_profile.profile | html %]?"</h1>
273             <form action="/cgi-bin/koha/tools/csv-profiles.pl" method="post">
274                 <input type="hidden" name="op" value="delete_confirmed" />
275                 <input type="hidden" name="export_format_id" value="[% csv_profile.export_format_id | html %]" />
276                 <input type="submit" class="approve" value="Yes, delete" />
277             </form>
278             <form action="/cgi-bin/koha/tools/csv-profiles.pl" method="get">
279                 <input type="submit" class="deny" value="No, do not Delete" />
280             </form>
281         [% ELSE %]
282             This CSV Profile does not exist.
283         [% END %]
284     </div>
285 [% END %]
286
287 [% IF op == 'list' %]
288
289     <div id="toolbar" class="btn-toolbar">
290         <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>
291     </div>
292
293     <h1>CSV profiles</h1>
294
295     [% IF csv_profiles %]
296         <table id="table_csv_profiles">
297             <thead>
298                 <th>CSV profile ID</th>
299                 <th>Name</th>
300                 <th>Description</th>
301                 <th>Content</th>
302                 <th>CSV separator</th>
303                 <th>CSV type</th>
304                 <th>Usage</th>
305                 <th class="noExport">Actions</th>
306             </thead>
307             <tbody>
308                 [% FOREACH csv_profile IN csv_profiles %]
309                 <tr>
310                     <td>[% csv_profile.export_format_id | html %]</td>
311                     <td>[% csv_profile.profile | html %]</td>
312                     <td>[% csv_profile.description | html %]</td>
313                     <td>[% csv_profile.content | html | html_line_break %]</td>
314                     <td>[% csv_profile.csv_separator | html %]</td>
315                     <td>[% PROCESS type_description type_code = csv_profile.type %]</td>
316                     <td>[% PROCESS used_for_description used_for_code = csv_profile.used_for %]</td>
317                     <td class="actions">
318                         <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>
319                         <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>
320                     </td>
321                 </tr>
322                 [% END %]
323             </tbody>
324         </table>
325     [% ELSE %]
326         There is no CSV profile defined. <a href="/cgi-bin/koha/tools/csv-profiles.pl?op=add_form">Create a new CSV profile</a>.
327     [% END %]
328 [% END %]
329
330             </main>
331         </div> <!-- /.col-sm-10.col-sm-push-2 -->
332
333         <div class="col-sm-2 col-sm-pull-10">
334             <aside>
335                 [% INCLUDE 'tools-menu.inc' %]
336             </aside>
337         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
338      </div> <!-- /.row -->
339
340 [% MACRO jsinclude BLOCK %]
341     [% Asset.js("js/tools-menu.js") | $raw %]
342     <script>
343         function reloadPage(p) {
344             var id = p.value;
345             if (id != 0) { document.location = "/cgi-bin/koha/tools/csv-profiles.pl?op=add_form&amp;export_format_id=" + id; }
346         }
347         $(document).ready(function() {
348             $("#type").change(function(){
349                 if ( $(this).find("option:selected").val() == "marc" ) {
350                     $("li.marc_specific").show();
351                     $("#marc_content").attr("required", "required");
352                     $("li.sql_specific").hide();
353                     $("#sql_content").removeAttr("required");
354                 } else {
355                     $("li.marc_specific").hide();
356                     $("#marc_content").removeAttr("required");
357                     $("li.sql_specific").show();
358                     $("#sql_content").attr("required", "required");
359                 }
360             });
361             $("#type").change();
362         });
363     </script>
364 [% END %]
365
366 [% INCLUDE 'intranet-bottom.inc' %]