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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authtypes.tt (-95 / +16 lines)
Lines 158-183 Link Here
158
                            <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>
158
                            <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>
159
                            [% 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 %]
159
                            [% 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 %]
160
                            <!-- Button to trigger modal -->
160
                            <!-- Button to trigger modal -->
161
                            <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>
161
                            <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>
162
                            <!-- Button to trigger modal -->
162
                            <!-- Button to trigger modal -->
163
                            <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>
163
                            <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>
164
                        </ul>
164
                        </ul>
165
165
166
                        <!-- Modal for export -->
166
                        <!-- Modal for export -->
167
                        <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">
167
                        <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">
168
                        <div class="modal-dialog">
168
                        <div class="modal-dialog">
169
                        <div class="modal-content">
169
                        <div class="modal-content">
170
                        <div class="modal-header">
170
                        <div class="modal-header">
171
                            <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
171
                            <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
172
                            <h3 id="exportLabelexportModal_[% authority_type.authtypecode %][% loop.count %]">Export [% authority_type.authtypetext %] authority type</h3>
172
                            <h3 id="exportLabelexportModal_[% authority_type.authtypecode | html %][% loop.count | html %]">Export [% authority_type.authtypetext | html %] authority type</h3>
173
                        </div>
173
                        </div>
174
                        <form action="import_export_authtype.pl" name="form_[% authority_type.authtypecode %]" method="get" target="_blank" class="form_export">
174
                        <form action="/cgi-bin/koha/admin/import_export_authtype.pl" name="form_[% authority_type.authtypecode | html %]" method="get" target="_blank" class="form_export">
175
                            <div class="modal-body">
175
                            <div class="modal-body">
176
                                <fieldset>
176
                                <fieldset>
177
                                    <input type="hidden" name="authtypecode" value="[% authority_type.authtypecode %]" />
177
                                    <input type="hidden" name="authtypecode" value="[% authority_type.authtypecode | html %]" />
178
                                    <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>
178
                                    <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>
179
                                    <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>
179
                                    <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>
180
                                    <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>
180
                                    <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>
181
                                </fieldset>
181
                                </fieldset>
182
                            </div>
182
                            </div>
183
                            <div class="modal-footer">
183
                            <div class="modal-footer">
Lines 190-208 Link Here
190
                        </div>
190
                        </div>
191
191
192
                        <!-- Modal for import -->
192
                        <!-- Modal for import -->
193
                        <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">
193
                        <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">
194
                            <div class="modal-dialog">
194
                            <div class="modal-dialog">
195
                            <div class="modal-content">
195
                            <div class="modal-content">
196
                            <div class="modal-header">
196
                            <div class="modal-header">
197
                                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
197
                                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
198
                                <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>
198
                                <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>
199
                            </div>
199
                            </div>
200
                            <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">
200
                            <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">
201
                                <div class="modal-body">
201
                                <div class="modal-body">
202
                                    <input type="hidden" name="authtypecode" value="[% authority_type.authtypecode %]" />
202
                                    <input type="hidden" name="authtypecode" value="[% authority_type.authtypecode | html %]" />
203
                                    <input type="hidden" name="action" value="import" />
203
                                    <input type="hidden" name="action" value="import" />
204
                                    <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>
204
                                    <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>
205
                                    <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>
205
                                    <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>
206
                                </div>
206
                                </div>
207
                                <div class="modal-footer">
207
                                <div class="modal-footer">
208
                                    <button type="submit" class="btn btn-default">Import</button>
208
                                    <button type="submit" class="btn btn-default">Import</button>
Lines 233-317 Link Here
233
[% MACRO jsinclude BLOCK %]
233
[% MACRO jsinclude BLOCK %]
234
    [% INCLUDE 'datatables.inc' %]
234
    [% INCLUDE 'datatables.inc' %]
235
    [% Asset.js("js/admin-menu.js") | $raw %]
235
    [% Asset.js("js/admin-menu.js") | $raw %]
236
    <script>
236
    [% Asset.js("js/authtype.js") | $raw %]
237
        var importing = false;
238
239
        $(document).ready(function() {
240
            $("#authtypes").dataTable($.extend(true, {}, dataTablesDefaults, {
241
                "aoColumnDefs": [
242
                    { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
243
                    { "aTargets": [ 0, 1 ], "sType": "natural" },
244
                ],
245
                "sPaginationType": "full"
246
            }));
247
            $("#authtypecode").on("blur",function(){
248
                toUC(this);
249
            });
250
251
            $("body").css("cursor", "auto");
252
            $('.import_export_options').hide();
253
            $('a.import_export_fw').click(function() {
254
                if (!importing) {
255
                    $('.import_export_options').hide();
256
                    $(this).next().show('slide');
257
                }
258
                return false;
259
            });
260
261
            $('.import_export_close').click(function() {
262
                if (!importing) {
263
                    $('.import_export_options').fadeOut('fast');
264
                    $("body").css("cursor", "auto");
265
                    return false;
266
                }
267
            });
268
            $('.input_import').val("");
269
270
            var matches = new RegExp("\\?error_import_export=(.+)$").exec(window.location.search);
271
            if (matches && matches.length > 1) {
272
                alert(_("Error importing the authority type %s").format(decodeURIComponent(matches[1])));
273
            }
274
275
            $('input.input_import').change( function() {
276
                var filename = $(this).val();
277
                if ( ! /(?:\.csv|\.ods|\.xml)$/.test(filename)) {
278
                    $(this).css("background-color","yellow");
279
                    alert(_("Please select a CSV (.csv), ODS (.ods) or XML (.xml) spreadsheet file."));
280
                    $(this).val("");
281
                    $(this).css("background-color","white");
282
                }
283
            });
284
            $('form.form_export').submit(function() {
285
                $('.modal').modal("hide");
286
                return true;
287
            });
288
            $('form.form_import').submit(function() {
289
                var id = $(this).attr('id');
290
                var obj = $('#' + id + ' input:file');
291
                if (/(?:\.csv|\.ods|\.xml)$/.test(obj.val())) {
292
                    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"))) {
293
                        var authtypecode = $('#' + id + ' input:hidden[name=authtypecode]').val();
294
                        $('#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>"));
295
                        if (navigator.userAgent.toLowerCase().indexOf('msie') != -1) {
296
                            var timestamp = new Date().getTime();
297
                            $('#importing_' + authtypecode).find("img").attr('src', '[% interface %]/[% theme %]/img/loading-small.gif' + '?' +timestamp);
298
                        }
299
                        $('#importing_' + authtypecode).css('display', 'block');
300
                        if (navigator.userAgent.toLowerCase().indexOf('firefox') == -1) $("body").css("cursor", "progress");
301
                        importing = true;
302
                        $(".modal-footer,.closebtn").hide();
303
                        return true;
304
                    } else {
305
                        return false;
306
                    }
307
                }
308
                obj.css("background-color","yellow");
309
                alert(_("Please select a CSV (.csv), ODS (.ods) or XML (.xml) spreadsheet file."));
310
                obj.val("");
311
                obj.css("background-color","white");
312
                return false;
313
            });
314
        });
315
    </script>
316
[% END %]
237
[% END %]
317
[% INCLUDE 'intranet-bottom.inc' %]
238
[% 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