Bug 8612: [Follow-up] Make usage and type different columns in table
[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
106     [% ELSIF type_code == 'sql' %] SQL
107     [% ELSE %] Unknown type
108     [% END %]
109 [% END %]
110
111 [% BLOCK used_for_description %]
112     [% IF used_for_code == 'export_records' %] Export records
113     [% ELSIF used_for_code == 'late_issues' %] Late serial issues claims
114     [% ELSIF used_for_code == 'export_basket' %] Basket export in acquisition
115     [% ELSE %] Unknown usage
116     [% END %]
117 [% END %]
118
119 [% IF op == 'add_form' %]
120     [% IF csv_profile %]
121         <h1>Modify a CSV profile</h1>
122     [% ELSE %]
123         <h1>New CSV profile</h1>
124     [% END %]
125
126     <form action="/cgi-bin/koha/tools/csv-profiles.pl" class="validated" method="post">
127         <input type="hidden" name="op" value="add_validate" />
128         <input type="hidden" name="export_format_id" value="[% csv_profile.export_format_id %]" />
129         <fieldset class="rows">
130             <ol>
131                 [% IF csv_profile %]
132                     <li><span class="label">Profile ID: </span>[% csv_profile.export_format_id %]</li>
133                 [% END %]
134                 <li>
135                     <label for="profile" class="required">Profile name: </label>
136                     <input type="text" name="profile" id="profile" value="[% csv_profile.profile %]" class="required">
137                     <span class="required">Required</span>
138                 </li>
139                 <li>
140                     <label for="type" class="required">Profile type: </label>
141                     <select id="type" name="type">
142                         [% FOREACH type IN [ 'marc' 'sql'] %]
143                         [% IF csv_profile.type == type %]
144                             <option value="[% type %]" selected="selected">[% PROCESS type_description type_code = type %]</option>
145                         [% ELSE %]
146                             <option value="[% type %]">[% PROCESS type_description type_code = type %]</option>
147                         [% END %]
148                         [% END %]
149                     </select>
150                     <span class="required">Required</span>
151                 </li>
152                 <li class="sql_specific">
153                     <label for="used_for_sql">Usage: </label>
154                     <select id="used_for_sql" name="used_for_sql">
155                         [% FOREACH used_for IN [ 'late_issues' 'export_basket' ] %]
156                         [% IF csv_profile.used_for == used_for %]
157                             <option value="[% used_for %]" selected="selected">[% PROCESS used_for_description used_for_code = used_for %]</option>
158                         [% ELSE %]
159                             <option value="[% used_for %]">[% PROCESS used_for_description used_for_code = used_for %]</option>
160                         [% END %]
161                         [% END %]
162                     </select>
163                 </li>
164                 <li class="marc_specific">
165                     <label for="used_for_marc">Usage: </label>
166                     <select id="used_for_marc" name="used_for_marc">
167                         [% FOREACH used_for IN [ 'export_records' ] %]
168                         [% IF csv_profile.used_for == used_for %]
169                             <option value="[% used_for %]" selected="selected">[% PROCESS used_for_description used_for_code = used_for %]</option>
170                         [% ELSE %]
171                             <option value="[% used_for %]">[% PROCESS used_for_description used_for_code = used_for %]</option>
172                         [% END %]
173                         [% END %]
174                     </select>
175                 </li>
176                 <li>
177                     <label for="description">Profile description: </label>
178                     <textarea cols="50" rows="2" name="description" id="description">[% csv_profile.description %]</textarea>
179                 </li>
180                 <li>
181                     <label for="csv_separator">CSV separator: </label>
182                     <select name="csv_separator" id="csv_separator">
183                         [% PROCESS list_separator_options selected_separator=csv_profile.csv_separator || ',' %]
184                     </select>
185                 </li>
186
187                 <li class="marc_specific">
188                     <label for="field_separator">Field separator: </label>
189                     <select name="field_separator" id="field_separator">
190                         [% PROCESS list_separator_options selected_separator=csv_profile.field_separator || '#' %]
191                     </select>
192                 </li>
193
194                 <li class="marc_specific"><label for="subfield_separator">Subfield separator: </label>
195                     <select name="subfield_separator" id="subfield_separator">
196                         [% PROCESS list_separator_options selected_separator=csv_profile.subfield_separator || '|'%]
197                     </select>
198                 </li>
199
200                 <li class="marc_specific"><label for="encoding">Encoding: </label>
201                     <select name="encoding" id="encoding">
202                         [% FOREACH encoding IN encodings %]
203                             [% IF csv_profile.encoding == encoding
204                                 OR NOT csv_profile AND encoding == 'utf8' %]
205                                 <option selected="selected">[% encoding %]</option>
206                             [% ELSE %]
207                                 <option>[% encoding %]</option>
208                             [% END %]
209                         [% END %]
210                     </select>
211                 </li>
212
213                 <li class="marc_specific">
214                     <label for="marc_content" class="required">Profile MARC fields: </label>
215                     <textarea cols="50" rows="2" name="marc_content" id="marc_content">[% csv_profile.content %]</textarea>
216                     <span class="required">Required</span>
217                     <p>You have to define which fields or subfields you want to export, separated by pipes.</p>
218                     <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>
219                     <p>Example: Personal name=200|Entry element=210$a|300|009</p>
220                     <p>You can use Template Toolkit tags too. See the help page for more information.</p>
221                 </li>
222
223                 <li class="sql_specific">
224                     <label for="late_issues_content" class="required">Profile SQL fields: </label>
225                     <textarea cols="50" rows="2" name="sql_content" id="sql_content">[% csv_profile.content %]</textarea>
226                     <p>You have to define which fields you want to export, separated by pipes.</p>
227                     <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>
228                     <p>Example: Name=subscription.name|Title=subscription.title|Issue number=serial.serialseq</p>
229                     <p>For late issues claims you can use data from following tables: serial, subscription, biblio, biblioitems and aqbookseller.</p>
230                     <p>For basket exports you can use data from following tables: biblio, biblioitems, aqorders, aqbudgets and aqbasket.</p>
231                 </li>
232             </ol>
233         </fieldset>
234         <fieldset class="action">
235             <input type="submit" value="Submit" />
236             <a class="cancel" href="/cgi-bin/koha/tools/csv-profiles.pl">Cancel</a>
237         </fieldset>
238     </form>
239 [% END %]
240
241 [% IF op == 'delete_confirm' %]
242     <div class="dialog alert">
243         [% IF csv_profile %]
244             <h3>Delete CSV Profile "[% csv_profile.profile %]?"</h3>
245             <form action="/cgi-bin/koha/tools/csv-profiles.pl" method="post">
246                 <input type="hidden" name="op" value="delete_confirmed" />
247                 <input type="hidden" name="export_format_id" value="[% csv_profile.export_format_id %]" />
248                 <input type="submit" class="approve" value="Yes, delete" />
249             </form>
250             <form action="/cgi-bin/koha/tools/csv-profiles.pl" method="get">
251                 <input type="submit" class="deny" value="No, do not Delete" />
252             </form>
253         [% ELSE %]
254             This CSV Profile does not exist.
255         [% END %]
256     </div>
257 [% END %]
258
259 [% IF op == 'list' %]
260
261     <div id="toolbar" class="btn-toolbar">
262         <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>
263     </div>
264
265     <h2>CSV profiles</h2>
266
267     [% IF csv_profiles %]
268         <table id="table_csv_profiles">
269             <thead>
270                 <th>CSV profile ID</th>
271                 <th>Name</th>
272                 <th>Description</th>
273                 <th>Content</th>
274                 <th>CSV separator</th>
275                 <th>CSV type</th>
276                 <th>Usage</th>
277                 <th>&nbsp;</th>
278                 <th>&nbsp;</th>
279             </thead>
280             <tbody>
281                 [% FOREACH csv_profile IN csv_profiles %]
282                 <tr>
283                     <td>[% csv_profile.export_format_id %]</td>
284                     <td>[% csv_profile.profile %]</td>
285                     <td>[% csv_profile.description %]</td>
286                     <td>[% csv_profile.content %]</td>
287                     <td>[% csv_profile.csv_separator %]</td>
288                     <td>[% PROCESS type_description type_code = csv_profile.type %]</td>
289                     <td>[% PROCESS used_for_description used_for_code = csv_profile.used_for %]</td>
290                     <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>
291                     <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>
292                 </tr>
293                 [% END %]
294             </tbody>
295         </table>
296     [% ELSE %]
297         There is no CSV profile defined. <a href="/cgi-bin/koha/tools/csv-profiles.pl?op=add_form">Create a new CSV profile</a>.
298     [% END %]
299 [% END %]
300
301 </div>
302 </div>
303 <div class="yui-b noprint">
304 [% INCLUDE 'tools-menu.inc' %]
305 </div>
306 </div>
307 [% INCLUDE 'intranet-bottom.inc' %]