Bug 14889: QA Follow-up
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / biblio_framework.tt
1 [% INCLUDE 'doc-head-open.inc' %]
2 <title>Koha &rsaquo; Administration &rsaquo; MARC frameworks
3 [% IF op == 'add_form' %]
4 &rsaquo; [% IF framework %]Modify framework text[% ELSE %]Add framework[% END %]
5 [% ELSIF op == 'delete_confirm' %]
6 &rsaquo; Delete framework for [% framework.frameworktext %] ([% framework.frameworkcode %])?
7 [% END %]
8 </title>
9 [% INCLUDE 'doc-head-close.inc' %]
10 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
11 [% INCLUDE 'datatables.inc' %]
12 <script type="text/javascript">
13 /* Import/Export from/to spreadsheet */
14
15     var importing = false;
16
17     $(document).ready(function() {
18         $("#table_biblio_frameworks").dataTable($.extend(true, {}, dataTablesDefaults, {
19             "aoColumnDefs": [
20                 { "aTargets": [ -1, -2, -3, -4, -5 ], "bSortable": false, "bSearchable": false },
21                 { "aTargets": [ 0, 1 ], "sType": "natural" },
22             ],
23             "bSort": true,
24             "sPaginationType": "four_button"
25         }));
26
27         $("body").css("cursor", "auto");
28         $('.import_export_options').hide();
29         $('a.import_export_fw').click(function() {
30             if (!importing) {
31                 $('.import_export_options').hide();
32                 $(this).next().show('slide');
33             }
34             return false;
35         });
36         $('.import_export_close').click(function() {
37             if (!importing) {
38                 $('.import_export_options').fadeOut('fast');
39                 $("body").css("cursor", "auto");
40                 return false;
41             }
42         });
43         $('.input_import').val("");
44
45         var matches = new RegExp("\\?error_import_export=(.+)$").exec(window.location.search);
46         if (matches && matches.length > 1) {
47             alert(_("Error importing the framework %s").format(decodeURIComponent(matches[1])));
48         }
49
50         $('input.input_import').change( function() {
51             var filename = $(this).val();
52             if ( ! /(?:\.csv|\.ods|\.xml)$/.test(filename)) {
53                 $(this).css("background-color","yellow");
54                 alert(_("Please select an ods or xml file"));
55                 $(this).val("");
56                 $(this).css("background-color","white");
57             }
58         });
59         $('form.form_export').submit(function() {
60             $('.modal').modal("hide");
61             return true;
62         });
63         $('form.form_import').submit(function() {
64             var id = $(this).attr('id');
65             var obj = $('#' + id + ' input:file');
66             if (/(?:\.csv|\.ods|\.xml)$/.test(obj.val())) {
67                 if (confirm(_("Do you really want to import the framework fields and subfields? This will overwrite the current configuration. For safety reasons please use the export option to make a backup"))) {
68                     var frameworkcode = $('#' + id + ' input:hidden[name=frameworkcode]').val();
69                     $('#importing_' + frameworkcode).find("span").html(_("Importing to framework: %s. Importing from file: %s").format("<strong>" + frameworkcode + "</strong>", "<i>" + obj.val().replace(new RegExp("^.+[/\\\\]"),"") + "</i>"));
70                     if (navigator.userAgent.toLowerCase().indexOf('msie') != -1) {
71                         var timestamp = new Date().getTime();
72                         $('#importing_' + frameworkcode).find("img").attr('src', '[% interface %]/[% theme %]/img/loading-small.gif' + '?' +timestamp);
73                     }
74                     $('#importing_' + frameworkcode).css('display', 'block');
75                     if (navigator.userAgent.toLowerCase().indexOf('firefox') == -1) $("body").css("cursor", "progress");
76                     importing = true;
77                     $(".modal-footer,.closebtn").hide();
78                     return true;
79                 } else
80                     return false;
81             }
82             obj.css("background-color","yellow");
83             alert(_("Please select an spreadsheet (csv, ods, xml) file"));
84             obj.val("");
85             obj.css("background-color","white");
86             return false;
87         });
88     });
89
90 </script>
91
92 </head>
93 <body id="admin_biblio_framework" class="admin">
94 [% INCLUDE 'header.inc' %]
95 [% INCLUDE 'cat-search.inc' %]
96
97 <div id="breadcrumbs">
98         <a href="/cgi-bin/koha/mainpage.pl">Home</a>
99 &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
100 &rsaquo; <a href="/cgi-bin/koha/admin/biblio_framework.pl">MARC frameworks</a>
101 [% IF op == 'add_form' %]
102 &rsaquo; [% IF framework %]Modify framework text[% ELSE %]Add framework[% END %]
103 [% ELSIF op == 'delete_confirm' %]
104 &rsaquo; Delete framework for [% framework.frameworktext %] ([% framework.frameworkcode %])?
105 [% END %]
106 </div>
107
108 <div id="doc3" class="yui-t2">
109   <div id="bd">
110     <div id="yui-main">
111       <div class="yui-b">
112
113 [% FOR m IN messages %]
114     <div class="dialog [% m.type %]">
115         [% SWITCH m.code %]
116         [% CASE 'error_on_update' %]
117             An error occurred when updating this framework. Perhaps it already exists.
118         [% CASE 'error_on_insert' %]
119             An error occurred when adding this framework. The framework might already exist.
120         [% CASE 'error_on_delete' %]
121             An error occurred when deleting this framework. Check the logs.
122         [% CASE 'success_on_update' %]
123             Framework updated successfully.
124         [% CASE 'success_on_insert' %]
125             Framework added successfully.
126         [% CASE 'success_on_delete' %]
127             Framework deleted successfully.
128         [% CASE 'already_exists' %]
129             This framework code already exists.
130         [% CASE %]
131             [% m.code %]
132         [% END %]
133     </div>
134 [% END %]
135
136
137
138 [% IF op == 'list'%]
139     <div id="toolbar" class="btn-toolbar">
140         <a class="btn btn-small" id="newframework" href="/cgi-bin/koha/admin/biblio_framework.pl?op=add_form"><i class="fa fa-plus"></i> New framework</a>
141     </div>
142 [% END %]
143
144 [% IF op == 'add_form' %]
145     <h1>[% IF framework %]Modify framework text[% ELSE %]Add framework[% END %]</h1>
146     <form action="/cgi-bin/koha/admin/biblio_framework.pl" name="Aform" method="post" class="validated">
147         <input type="hidden" name="op" value="add_validate" />
148         <fieldset class="rows">
149             <ol>
150                 [% IF framework %]
151                     <li>
152                         <span class="label">Framework code: </span>
153                         <input type="hidden" id="frameworkcode" name="frameworkcode" value="[% framework.frameworkcode %]" />[% framework.frameworkcode %]
154                     </li>
155                 [% ELSE %]
156                     <li>
157                         <label for="frameworkcode" class="required">Framework code: </label>
158                         <input type="text" id="frameworkcode" name="frameworkcode" size="4" maxlength="4" onblur="toUC(this)" required="required" class="required" />
159                         <span class="required">Required</span>
160                     </li>
161                 [% END %]
162                 <li>
163                     <label for="description" class="required">Description: </label>
164                     <input type="text" name="frameworktext" id="description" size="40" maxlength="80" value="[% framework.frameworktext |html %]" required="required" class="required" />
165                     <span class="required">Required</span>
166                 </li>
167             </ol>
168         </fieldset>
169         <fieldset class="action">
170             <input type="submit" value="Submit" class="submit" />
171         </fieldset>
172     </form>
173 [% END %]
174
175 [% IF op == 'delete_confirm' %]
176     <div class="dialog alert">
177         <h3>Delete framework for [% framework.frameworktext %] ([% framework.frameworkcode %])?</h3>
178         [% IF biblios_use_this_framework %]
179            <p><strong>This framework is used [% biblios_use_this_framework %] times</strong>.</p>
180         [% END %]
181         <form class="inline" action="/cgi-bin/koha/admin/biblio_framework.pl" method="post">
182             <input type="hidden" name="op" value="delete_confirmed" />
183             <input type="hidden" name="frameworkcode" value="[% framework.frameworkcode %]" />
184             <input type="submit" class="approve" value="Yes, delete this framework!" />
185         </form>
186         <form class="inline" action="/cgi-bin/koha/admin/biblio_framework.pl" method="get">
187             <input type="submit" class="deny" value="No, do not delete!" />
188         </form>
189     </div>
190 [% END %]
191
192 [% IF op == 'list' %]
193 <h1>MARC frameworks</h1>
194 <p>Framework name, then go to MARC biblio to set MARC editor parameters</p>
195 <table id="table_biblio_frameworks">
196     <thead>
197     <tr>
198         <th>Code</th>
199         <th>Description</th>
200         <th>&nbsp;</th>
201         <th>Edit</th>
202         <th>Delete</th>
203         <th title="Export framework structure (fields, subfields) to a spreadsheet file (.csv, .xml, .ods)">Export</th>
204         <th title="Import framework structure (fields, subfields) from a spreadsheet file (.csv, .xml, .ods)">Import</th>
205     </tr>
206     </thead>
207     <tbody>
208     <tr>
209         <td>&nbsp;</td>
210         <td>Default framework</td>
211         <td><a href="marctagstructure.pl?frameworkcode=">MARC structure</a></td>
212         <td>&nbsp;</td>
213         <td>&nbsp;</td>
214         <td>
215
216             <!-- Button to trigger modal -->
217             <a href="#" data-toggle="modal" data-target="#exportModal_default">Export</a>
218             <!-- Modal -->
219             <div class="modal hide" id="exportModal_default" tabindex="-1" role="dialog" aria-labelledby="exportLabelexportModal_default" aria-hidden="true">
220                 <div class="modal-header">
221                     <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
222                     <h3 id="exportLabelexportModal_default">Export default framework</h3>
223                 </div>
224                 <form action="import_export_framework.pl" name="form_defaul" method="get" target="_blank"  class="form_export">
225                     <div class="modal-body">
226                         <fieldset>
227                             <input type="hidden" name="frameworkcode" value="" />
228                             <p><label for="csv_type_export_default"><input type="radio" name="type_export_defaul" value="csv" id="csv_type_export_default" checked="checked" /> Export to CSV spreadsheet</label></p>
229                             <p><label for="xml_type_export_default"><input type="radio" name="type_export_default" value="excel" id="xml_type_export_default" /> Export to Excel with XML format, compatible with OpenOffice/LibreOffice as well</label></p>
230                             <p><label for="ods_type_export_default"><input type="radio" name="type_export_default" value="ods" id="ods_type_export_default" /> Export to OpenDocument spreadsheet format</label></p>
231
232                         </fieldset>
233                     </div>
234                     <div class="modal-footer">
235                         <button type="submit" class="btn">Export</button>
236                         <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
237                     </div>
238                 </form>
239             </div>
240
241         </td>
242         <td>
243
244             <!-- Button to trigger modal -->
245             <a href="#" data-toggle="modal" data-target="#importModal_[% framework.frameworkcode %][% frameworks.count %]">Import</a>
246             <!-- Modal -->
247             <div class="modal hide" id="importModal_[% framework.frameworkcode %][% frameworks.count %]" tabindex="-1" role="dialog" aria-labelledby="importLabelexportModal_default[% frameworks.count %]" aria-hidden="true">
248                 <div class="modal-header">
249                     <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
250                     <h3 id="importLabelexportModal_[% framework.frameworkcode %][% frameworks.count %]">Import default framework structure (fields and subfields) from a spreadsheet file (.csv, .xml, .ods)</h3>
251                 </div>
252                 <form action="/cgi-bin/koha/admin/import_export_framework.pl" name="form_i_default" id="form_i_default" method="post" enctype="multipart/form-data" class="form_import">
253                     <div class="modal-body">
254                             <input type="hidden" name="frameworkcode" value="default" />
255                             <input type="hidden" name="action" value="import" />
256                             <p><label for="file_import_default">Upload file:</label> <input type="file" name="file_import_default" id="file_import_default" class="input_import" /></p>
257                             <div id="importing_default" style="display:none" class="importing"><img src="[% interface %]/[% theme %]/img/loading-small.gif" alt="" /><span class="importing_msg"></span></div>
258                     </div>
259                     <div class="modal-footer">
260                         <button type="submit" class="btn">Import</button>
261                         <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Close</button>
262                     </div>
263                 </form>
264             </div>
265
266         </td>
267     </tr>
268     <!-- note highlight assignment appears backwards because we already have a normal row for Default -->
269     [% FOREACH loo IN frameworks %]
270         <tr>
271             <td>[% loo.frameworkcode %]</td>
272             <td>[% loo.frameworktext %]</td>
273             <td><a href="marctagstructure.pl?frameworkcode=[% loo.frameworkcode %]" >MARC structure</a></td>
274             <td><a href="/cgi-bin/koha/admin/biblio_framework.pl?op=add_form&amp;frameworkcode=[% loo.frameworkcode |html %]">Edit</a></td>
275             <td><a href="/cgi-bin/koha/admin/biblio_framework.pl?op=delete_confirm&amp;frameworkcode=[% loo.frameworkcode |html %]">Delete</a></td>
276             <td>
277
278                 <!-- Button to trigger modal -->
279                 <a href="#" data-toggle="modal" data-target="#exportModal_[% loo.frameworkcode %][% loop.count %]">Export</a>
280                 <!-- Modal -->
281                 <div class="modal hide" id="exportModal_[% loo.frameworkcode %][% loop.count %]" tabindex="-1" role="dialog" aria-labelledby="exportLabelexportModal_[% loo.frameworkcode %][% loop.count %]" aria-hidden="true">
282                     <div class="modal-header">
283                         <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
284                         <h3 id="exportLabelexportModal_[% loo.frameworkcode %][% loop.count %]">Export [% loo.frameworktext %] framework</h3>
285                     </div>
286                     <form action="import_export_framework.pl" name="form_[% loo.frameworkcode %]" method="get" target="_blank"  class="form_export">
287                         <div class="modal-body">
288                             <fieldset>
289                                 <input type="hidden" name="frameworkcode" value="[% loo.frameworkcode %]" />
290                                 <p><label for="csv_type_export_[% loo.frameworkcode %][% loop.count %]"><input type="radio" name="type_export_[% loo.frameworkcode %]" value="csv" id="csv_type_export_[% loo.frameworkcode %][% loop.count %]" checked="checked" /> Export to CSV spreadsheet</label></p>
291                                 <p><label for="xml_type_export_[% loo.frameworkcode %][% loop.count %]"><input type="radio" name="type_export_[% loo.frameworkcode %]" value="excel" id="xml_type_export_[% loo.frameworkcode %][% loop.count %]" /> Export to Excel with XML format, compatible with OpenOffice/LibreOffice as well</label></p>
292                                 <p><label for="ods_type_export_[% loo.frameworkcode %][% loop.count %]"><input type="radio" name="type_export_[% loo.frameworkcode %]" value="ods" id="ods_type_export_[% loo.frameworkcode %][% loop.count %]" /> Export to OpenDocument spreadsheet format</label></p>
293
294                             </fieldset>
295                         </div>
296                         <div class="modal-footer">
297                             <button type="submit" class="btn">Export</button>
298                             <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
299                         </div>
300                     </form>
301                 </div>
302             </td>
303             <td>
304
305                 <!-- Button to trigger modal -->
306                 <a href="#" data-toggle="modal" data-target="#importModal_[% loo.frameworkcode %][% loop.count %]">Import</a>
307                 <!-- Modal -->
308                 <div class="modal hide" id="importModal_[% loo.frameworkcode %][% loop.count %]" tabindex="-1" role="dialog" aria-labelledby="importLabelexportModal_[% loo.frameworkcode %][% loop.count %]" aria-hidden="true">
309                     <div class="modal-header">
310                         <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
311                         <h3 id="importLabelexportModal_[% loo.frameworkcode %][% loop.count %]">Import [% loo.frameworkcode %] framework structure (fields and subfields) from a spreadsheet file (.csv, .xml, .ods)</h3>
312                     </div>
313                     <form action="/cgi-bin/koha/admin/import_export_framework.pl" name="form_i_[% loo.frameworkcode %]" id="form_i_[% loo.frameworkcode %]" method="post" enctype="multipart/form-data" class="form_import">
314                         <div class="modal-body">
315                                 <input type="hidden" name="frameworkcode" value="[% loo.frameworkcode %]" />
316                                 <input type="hidden" name="action" value="import" />
317                                 <p><label for="file_import_[% loo.frameworkcode %]">Upload file:</label> <input type="file" name="file_import_[% loo.frameworkcode %]" id="file_import_[% loo.frameworkcode %]" class="input_import" /></p>
318                                 <div id="importing_[% loo.frameworkcode %]" style="display:none" class="importing"><img src="[% interface %]/[% theme %]/img/loading-small.gif" alt="" /><span class="importing_msg"></span></div>
319                         </div>
320                         <div class="modal-footer">
321                             <button type="submit" class="btn">Import</button>
322                             <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Close</button>
323                         </div>
324                     </form>
325                 </div>
326         </td>
327         </tr>
328     [% END %]
329 </table>
330
331 [% END %]
332     </div>
333   </div>
334 <div class="yui-b">
335 [% INCLUDE 'admin-menu.inc' %]
336   </div>
337 </div>
338 [% INCLUDE 'intranet-bottom.inc' %]