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