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