View | Details | Raw Unified | Return to bug 13952
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authtypes.tt (-130 / +51 lines)
Lines 192-252 Authority types › Administration › Koha Link Here
192
                      <li><a href="/cgi-bin/koha/admin/authtypes.pl?op=add_form&amp;authtypecode=[% authority_type.authtypecode | uri %]"><i class="fa fa-pencil"></i> Edit</a></li>
192
                      <li><a href="/cgi-bin/koha/admin/authtypes.pl?op=add_form&amp;authtypecode=[% authority_type.authtypecode | uri %]"><i class="fa fa-pencil"></i> Edit</a></li>
193
                      [% IF authority_type.authtypecode %]<li><a href="/cgi-bin/koha/admin/authtypes.pl?op=delete_confirm&amp;authtypecode=[% authority_type.authtypecode | uri %]"><i class="fa fa-trash"></i> Delete</a></li>[% END %]
193
                      [% IF authority_type.authtypecode %]<li><a href="/cgi-bin/koha/admin/authtypes.pl?op=delete_confirm&amp;authtypecode=[% authority_type.authtypecode | uri %]"><i class="fa fa-trash"></i> Delete</a></li>[% END %]
194
                      <!-- Button to trigger modal -->
194
                      <!-- Button to trigger modal -->
195
                      <li><a href="#" data-toggle="modal" data-target="#exportModal_[% authority_type.authtypecode %][% loop.count %]" title="Export authority type (fields, subfields) to a spreadsheet file (.csv, .xml, .ods)"><i class="fa fa-upload"></i> Export</a></li>
195
                      <li><a href="#" data-toggle="modal" data-target="#exportModal_[% authority_type.authtypecode | html %][% loop.count | html %]" title="Export authority type (fields, subfields) to a spreadsheet file (.csv, .xml, .ods)"><i class="fa fa-upload"></i> Export</a></li>
196
                      <!-- Button to trigger modal -->
196
                      <!-- Button to trigger modal -->
197
                      <li><a href="#" data-toggle="modal" data-target="#importModal_[% authority_type.authtypecode %][% loop.count %]" title="Import authority type (fields, subfields) from a spreadsheet file (.csv, .xml, .ods)"><i class="fa fa-download"></i> Import</a></li>
197
                      <li><a href="#" data-toggle="modal" data-target="#importModal_[% authority_type.authtypecode | html %][% loop.count | html %]" title="Import authority type (fields, subfields) from a spreadsheet file (.csv, .xml, .ods)"><i class="fa fa-download"></i> Import</a></li>
198
                    </ul>
198
                    </ul>
199
                  </div>
199
                  </div>
200
200
201
                  <!-- Modal for export -->
201
                        <!-- Modal for export -->
202
                  <div class="modal" id="exportModal_[% authority_type.authtypecode %][% loop.count %]" tabindex="-1" role="dialog" aria-labelledby="exportLabelexportModal_[% authority_type.authtypecode %][% loop.count %]" aria-hidden="true">
202
                        <div class="modal" id="exportModal_[% authority_type.authtypecode | html %][% loop.count | html %]" tabindex="-1" role="dialog" aria-labelledby="exportLabelexportModal_[% authority_type.authtypecode | html %][% loop.count | html %]" aria-hidden="true">
203
                      <div class="modal-dialog">
203
                        <div class="modal-dialog">
204
                          <div class="modal-content">
204
                        <div class="modal-content">
205
                              <div class="modal-header">
205
                        <div class="modal-header">
206
                                  <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
206
                            <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
207
                                  <h3 id="exportLabelexportModal_[% authority_type.authtypecode %][% loop.count %]">Export [% authority_type.authtypetext %] authority type</h3>
207
                            <h3 id="exportLabelexportModal_[% authority_type.authtypecode | html %][% loop.count | html %]">Export [% authority_type.authtypetext | html %] authority type</h3>
208
                              </div>
208
                        </div>
209
                              <form action="import_export_authtype.pl" name="form_[% authority_type.authtypecode %]" method="get" target="_blank" class="form_export">
209
                        <form action="/cgi-bin/koha/admin/import_export_authtype.pl" name="form_[% authority_type.authtypecode | html %]" method="get" target="_blank" class="form_export">
210
                                  <div class="modal-body">
210
                            <div class="modal-body">
211
                                      <fieldset>
211
                                <fieldset>
212
                                          <input type="hidden" name="authtypecode" value="[% authority_type.authtypecode %]" />
212
                                    <input type="hidden" name="authtypecode" value="[% authority_type.authtypecode | html %]" />
213
                                          <p><label for="csv_type_export_[% authority_type.authtypecode %][% loop.count %]"><input type="radio" name="type_export_[% authority_type.authtypecode %]" value="csv" id="csv_type_export_[% authority_type.authtypecode %][% loop.count %]" checked="checked" /> Export to CSV spreadsheet</label></p>
213
                                    <p><label for="csv_type_export_[% authority_type.authtypecode | html %][% loop.count | html %]"><input type="radio" name="type_export_[% authority_type.authtypecode | html %]" value="csv" id="csv_type_export_[% authority_type.authtypecode | html %][% loop.count | html %]" checked="checked" /> Export to CSV spreadsheet</label></p>
214
                                          <p><label for="xml_type_export_[% authority_type.authtypecode %][% loop.count %]"><input type="radio" name="type_export_[% authority_type.authtypecode %]" value="excel" id="xml_type_export_[% authority_type.authtypecode %][% loop.count %]" /> Export to Excel with XML format, compatible with OpenOffice/LibreOffice as well</label></p>
214
                                    <p><label for="xml_type_export_[% authority_type.authtypecode | html %][% loop.count | html %]"><input type="radio" name="type_export_[% authority_type.authtypecode | html %]" value="excel" id="xml_type_export_[% authority_type.authtypecode | html %][% loop.count | html %]" /> Export to Excel with XML format, compatible with OpenOffice/LibreOffice as well</label></p>
215
                                          <p><label for="ods_type_export_[% authority_type.authtypecode %][% loop.count %]"><input type="radio" name="type_export_[% authority_type.authtypecode %]" value="ods" id="ods_type_export_[% authority_type.authtypecode %][% loop.count %]" /> Export to OpenDocument spreadsheet format</label></p>
215
                                    <p><label for="ods_type_export_[% authority_type.authtypecode | html %][% loop.count | html %]"><input type="radio" name="type_export_[% authority_type.authtypecode | html %]" value="ods" id="ods_type_export_[% authority_type.authtypecode | html %][% loop.count | html %]" /> Export to OpenDocument spreadsheet format</label></p>
216
                                      </fieldset>
216
                                </fieldset>
217
                                  </div>
217
                            </div>
218
                                  <div class="modal-footer">
218
                            <div class="modal-footer">
219
                                      <button type="submit" class="btn btn-default">Export</button>
219
                                <button type="submit" class="btn btn-default">Export</button>
220
                                      <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
220
                                <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
221
                                  </div>
221
                            </div>
222
                              </form>
222
                        </form>
223
                          </div>
223
                        </div>
224
                      </div>
224
                        </div>
225
                  </div>
225
                        </div>
226
226
227
                  <!-- Modal for import -->
227
                        <!-- Modal for import -->
228
                  <div class="modal" id="importModal_[% authority_type.authtypecode %][% loop.count %]" tabindex="-1" role="dialog" aria-labelledby="importLabelexportModal_[% authority_type.authtypecode %][% loop.count %]" aria-hidden="true">
228
                        <div class="modal" id="importModal_[% authority_type.authtypecode | html %][% loop.count | html %]" tabindex="-1" role="dialog" aria-labelledby="importLabelexportModal_[% authority_type.authtypecode | html %][% loop.count | html %]" aria-hidden="true">
229
                      <div class="modal-dialog">
229
                            <div class="modal-dialog">
230
                          <div class="modal-content">
230
                            <div class="modal-content">
231
                              <div class="modal-header">
231
                            <div class="modal-header">
232
                                  <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
232
                                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
233
                                  <h3 id="importLabelexportModal_[% authority_type.authtypecode %][% loop.count %]">Import [% authority_type.authtypecode %] authority type (fields and subfields) from a spreadsheet file (.csv, .xml, .ods)</h3>
233
                                <h3 id="importLabelexportModal_[% authority_type.authtypecode | html %][% loop.count | html %]">Import [% authority_type.authtypecode | html %] authority type (fields and subfields) from a spreadsheet file (.csv, .xml, .ods)</h3>
234
                              </div>
234
                            </div>
235
                              <form action="/cgi-bin/koha/admin/import_export_authtype.pl" name="form_i_[% authority_type.authtypecode %]" id="form_i_[% authority_type.authtypecode %]" method="post" enctype="multipart/form-data" class="form_import">
235
                            <form action="/cgi-bin/koha/admin/import_export_authtype.pl" name="form_i_[% authority_type.authtypecode | html %]" id="form_i_[% authority_type.authtypecode | html %]" method="post" enctype="multipart/form-data" class="form_import">
236
                                  <div class="modal-body">
236
                                <div class="modal-body">
237
                                      <input type="hidden" name="authtypecode" value="[% authority_type.authtypecode %]" />
237
                                    <input type="hidden" name="authtypecode" value="[% authority_type.authtypecode | html %]" />
238
                                      <input type="hidden" name="action" value="import" />
238
                                    <input type="hidden" name="action" value="import" />
239
                                      <p><label for="file_import_[% authority_type.authtypecode %]">Upload file:</label> <input type="file" name="file_import_[% authority_type.authtypecode %]" id="file_import_[% authority_type.authtypecode %]" class="input_import" /></p>
239
                                    <p><label for="file_import_[% authority_type.authtypecode | html %]">Upload file:</label> <input type="file" name="file_import_[% authority_type.authtypecode | html %]" id="file_import_[% authority_type.authtypecode | html %]" class="input_import" /></p>
240
                                      <div id="importing_[% authority_type.authtypecode %]" style="display:none" class="importing"><img src="[% interface %]/[% theme %]/img/loading-small.gif" alt="" /><span class="importing_msg"></span></div>
240
                                    <div id="importing_[% authority_type.authtypecode | html %]" style="display:none" class="importing"><img src="[% interface | html %]/[% theme | html %]/img/loading-small.gif" alt="" /><span class="importing_msg"></span></div>
241
                                  </div>
241
                                </div>
242
                                  <div class="modal-footer">
242
                                <div class="modal-footer">
243
                                      <button type="submit" class="btn btn-default">Import</button>
243
                                    <button type="submit" class="btn btn-default">Import</button>
244
                                      <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Close</button>
244
                                    <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Close</button>
245
                                  </div>
245
                                </div>
246
                              </form>
246
                            </form>
247
                          </div>
247
                            </div>
248
                      </div>
248
                            </div>
249
                  </div>
249
                        </div>
250
                </td>
250
                </td>
251
            </tr>
251
            </tr>
252
        [% END %]
252
        [% END %]
Lines 267-351 Authority types &rsaquo; Administration &rsaquo; Koha Link Here
267
[% MACRO jsinclude BLOCK %]
267
[% MACRO jsinclude BLOCK %]
268
    [% INCLUDE 'datatables.inc' %]
268
    [% INCLUDE 'datatables.inc' %]
269
    [% Asset.js("js/admin-menu.js") | $raw %]
269
    [% Asset.js("js/admin-menu.js") | $raw %]
270
    <script>
270
    [% Asset.js("js/authtype.js") | $raw %]
271
        var importing = false;
272
273
        $(document).ready(function() {
274
            $("#authtypes").dataTable($.extend(true, {}, dataTablesDefaults, {
275
                "aoColumnDefs": [
276
                    { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
277
                    { "aTargets": [ 0, 1 ], "sType": "natural" },
278
                ],
279
                "sPaginationType": "full"
280
            }));
281
            $("#authtypecode").on("blur",function(){
282
                toUC(this);
283
            });
284
285
            $("body").css("cursor", "auto");
286
            $('.import_export_options').hide();
287
            $('a.import_export_fw').click(function() {
288
                if (!importing) {
289
                    $('.import_export_options').hide();
290
                    $(this).next().show('slide');
291
                }
292
                return false;
293
            });
294
295
            $('.import_export_close').click(function() {
296
                if (!importing) {
297
                    $('.import_export_options').fadeOut('fast');
298
                    $("body").css("cursor", "auto");
299
                    return false;
300
                }
301
            });
302
            $('.input_import').val("");
303
304
            var matches = new RegExp("\\?error_import_export=(.+)$").exec(window.location.search);
305
            if (matches && matches.length > 1) {
306
                alert(_("Error importing the authority type %s").format(decodeURIComponent(matches[1])));
307
            }
308
309
            $('input.input_import').change( function() {
310
                var filename = $(this).val();
311
                if ( ! /(?:\.csv|\.ods|\.xml)$/.test(filename)) {
312
                    $(this).css("background-color","yellow");
313
                    alert(_("Please select a CSV (.csv), ODS (.ods) or XML (.xml) spreadsheet file."));
314
                    $(this).val("");
315
                    $(this).css("background-color","white");
316
                }
317
            });
318
            $('form.form_export').submit(function() {
319
                $('.modal').modal("hide");
320
                return true;
321
            });
322
            $('form.form_import').submit(function() {
323
                var id = $(this).attr('id');
324
                var obj = $('#' + id + ' input:file');
325
                if (/(?:\.csv|\.ods|\.xml)$/.test(obj.val())) {
326
                    if (confirm(_("Do you really want to import the authority type fields and subfields? This will overwrite the current configuration. For safety reasons please use the export option to make a backup"))) {
327
                        var authtypecode = $('#' + id + ' input:hidden[name=authtypecode]').val();
328
                        $('#importing_' + authtypecode).find("span").html(_("Importing to authority type: %s. Importing from file: %s").format("<strong>" + authtypecode + "</strong>", "<i>" + obj.val().replace(new RegExp("^.+[/\\\\]"),"") + "</i>"));
329
                        if (navigator.userAgent.toLowerCase().indexOf('msie') != -1) {
330
                            var timestamp = new Date().getTime();
331
                            $('#importing_' + authtypecode).find("img").attr('src', '[% interface %]/[% theme %]/img/loading-small.gif' + '?' +timestamp);
332
                        }
333
                        $('#importing_' + authtypecode).css('display', 'block');
334
                        if (navigator.userAgent.toLowerCase().indexOf('firefox') == -1) $("body").css("cursor", "progress");
335
                        importing = true;
336
                        $(".modal-footer,.closebtn").hide();
337
                        return true;
338
                    } else {
339
                        return false;
340
                    }
341
                }
342
                obj.css("background-color","yellow");
343
                alert(_("Please select a CSV (.csv), ODS (.ods) or XML (.xml) spreadsheet file."));
344
                obj.val("");
345
                obj.css("background-color","white");
346
                return false;
347
            });
348
        });
349
    </script>
350
[% END %]
271
[% END %]
351
[% INCLUDE 'intranet-bottom.inc' %]
272
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/authtype.js (-1 / +85 lines)
Line 0 Link Here
0
- 
1
/* Import/export from/to a spreadsheet */
2
3
var importing = false;
4
5
$(document).ready(function() {
6
    $("#authtypes").dataTable($.extend(true, {}, dataTablesDefaults, {
7
        "aoColumnDefs": [
8
            { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
9
            { "aTargets": [ 0, 1 ], "sType": "natural" },
10
        ],
11
        "bSort": true,
12
        "sPaginationType": "full"
13
    }));
14
15
    $("body").css("cursor", "auto");
16
    $('.import_export_options').hide();
17
    $('a.import_export_fw').click(function() {
18
        if (!importing) {
19
            $('.import_export_options').hide();
20
            $(this).next().show('slide');
21
        }
22
        return false;
23
    });
24
25
    $('.import_export_close').click(function() {
26
        if (!importing) {
27
            $('.import_export_options').fadeOut('fast');
28
            $("body").css("cursor", "auto");
29
            return false;
30
        }
31
    });
32
33
    $('.input_import').val("");
34
35
    var matches = new RegExp("\\?error_import_export=(.+)$").exec(window.location.search);
36
    if (matches && matches.length > 1) {
37
        alert(_("Error importing the authority type %s").format(decodeURIComponent(matches[1])));
38
    }
39
40
    $('input.input_import').change( function() {
41
        var filename = $(this).val();
42
        if ( ! /(?:\.csv|\.ods|\.xml)$/.test(filename)) {
43
            $(this).css("background-color","yellow");
44
            alert(_("Please select a CSV (.csv), ODS (.ods) or XML (.xml) spreadsheet file."));
45
            $(this).val("");
46
            $(this).css("background-color","white");
47
        }
48
    });
49
50
    $('form.form_export').submit(function() {
51
        $('.modal').modal("hide");
52
        return true;
53
    });
54
55
    $('form.form_import').submit(function() {
56
        var id = $(this).attr('id');
57
        var obj = $('#' + id + ' input:file');
58
        if (/(?:\.csv|\.ods|\.xml)$/.test(obj.val())) {
59
            if (confirm(_("Do you really want to import the authority type fields and subfields? This will overwrite the current configuration. For safety reasons please use the export option to make a backup"))) {
60
                var authtypecode = $('#' + id + ' input:hidden[name=authtypecode]').val();
61
                $('#importing_' + authtypecode).find("span").html(_("Importing to authority type: %s. Importing from file: %s").format("<strong>" + authtypecode + "</strong>", "<i>" + obj.val().replace(new RegExp("^.+[/\\\\]"),"") + "</i>"));
62
                if (navigator.userAgent.toLowerCase().indexOf('msie') != -1) {
63
                    var timestamp = new Date().getTime();
64
                    $('#importing_' + authtypecode).find("img").attr('src', '[% interface | html %]/[% theme | html %]/img/loading-small.gif' + '?' +timestamp);
65
                }
66
                $('#importing_' + authtypecode).css('display', 'block');
67
                if (navigator.userAgent.toLowerCase().indexOf('firefox') == -1) $("body").css("cursor", "progress");
68
                importing = true;
69
                $(".modal-footer,.closebtn").hide();
70
                return true;
71
            } else {
72
                return false;
73
            }
74
        }
75
        obj.css("background-color","yellow");
76
        alert(_("Please select a CSV (.csv), ODS (.ods) or XML (.xml) spreadsheet file."));
77
        obj.val("");
78
        bj.css("background-color","white");
79
        return false;
80
    });
81
    $("#authtypecode").on("blur",function(){
82
        toUC(this);
83
    });
84
85
});

Return to bug 13952