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