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

(-)a/admin/import_export_authtype.pl (-5 / +1 lines)
Lines 61-70 if ($action eq 'export' && $input->request_method() eq 'GET') { Link Here
61
        binmode(STDOUT,':encoding(UTF-8)');
61
        binmode(STDOUT,':encoding(UTF-8)');
62
        print $input->header(-type => 'application/vnd.ms-excel', -attachment => 'export_' . $authtypecode . '.csv');
62
        print $input->header(-type => 'application/vnd.ms-excel', -attachment => 'export_' . $authtypecode . '.csv');
63
        print $strXml;
63
        print $strXml;
64
    } elsif ($format eq 'excel') {
65
        # Excel-xml file
66
        print $input->header(-type => 'application/excel', -attachment => 'export_' . $authtypecode . '.xml');
67
        print $strXml;
68
    } else {
64
    } else {
69
        # ODS file
65
        # ODS file
70
        my $strODS = '';
66
        my $strODS = '';
Lines 81-87 if ($action eq 'export' && $input->request_method() eq 'GET') { Link Here
81
    }
77
    }
82
    my $filename = $input->param($fieldname);
78
    my $filename = $input->param($fieldname);
83
    # upload the input file
79
    # upload the input file
84
    if ($filename && $filename =~ /\.(csv|ods|xml)$/i) {
80
    if ($filename && $filename =~ /\.(csv|ods)$/i) {
85
        my $extension = $1;
81
        my $extension = $1;
86
        my $uploadFd = $input->upload($fieldname);
82
        my $uploadFd = $input->upload($fieldname);
87
        if ($uploadFd && !$input->cgi_error) {
83
        if ($uploadFd && !$input->cgi_error) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authtypes.tt (-6 / +5 lines)
Lines 191-200 Authority types › Administration › Koha Link Here
191
                      <li><a href="auth_tag_structure.pl?authtypecode=[% authority_type.authtypecode | uri %]" class="button parameters"><i class="fa fa-eye"></i> MARC structure</a></li>
191
                      <li><a href="auth_tag_structure.pl?authtypecode=[% authority_type.authtypecode | uri %]" class="button parameters"><i class="fa fa-eye"></i> MARC structure</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>
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 | 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>
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, .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 | 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>
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, .ods)"><i class="fa fa-download"></i> Import</a></li>
198
                    </ul>
198
                    </ul>
199
                  </div>
199
                  </div>
200
200
Lines 211-217 Authority types &rsaquo; Administration &rsaquo; Koha Link Here
211
                                <fieldset>
211
                                <fieldset>
212
                                    <input type="hidden" name="authtypecode" value="[% authority_type.authtypecode | html %]" />
212
                                    <input type="hidden" name="authtypecode" value="[% authority_type.authtypecode | html %]" />
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>
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 | 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 | 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>
214
                                    <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>
215
                                </fieldset>
217
                            </div>
216
                            </div>
Lines 230-236 Authority types &rsaquo; Administration &rsaquo; Koha Link Here
230
                            <div class="modal-content">
229
                            <div class="modal-content">
231
                            <div class="modal-header">
230
                            <div class="modal-header">
232
                                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
231
                                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
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>
232
                                <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, .ods)</h3>
234
                            </div>
233
                            </div>
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">
234
                            <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">
235
                                <div class="modal-body">
(-)a/koha-tmpl/intranet-tmpl/prog/js/authtype.js (-5 / +4 lines)
Lines 39-47 $(document).ready(function() { Link Here
39
39
40
    $('input.input_import').change( function() {
40
    $('input.input_import').change( function() {
41
        var filename = $(this).val();
41
        var filename = $(this).val();
42
        if ( ! /(?:\.csv|\.ods|\.xml)$/.test(filename)) {
42
        if ( ! /(?:\.csv|\.ods)$/.test(filename)) {
43
            $(this).css("background-color","yellow");
43
            $(this).css("background-color","yellow");
44
            alert(_("Please select a CSV (.csv), ODS (.ods) or XML (.xml) spreadsheet file."));
44
            alert(_("Please select a CSV (.csv) or ODS (.ods) spreadsheet file."));
45
            $(this).val("");
45
            $(this).val("");
46
            $(this).css("background-color","white");
46
            $(this).css("background-color","white");
47
        }
47
        }
Lines 55-61 $(document).ready(function() { Link Here
55
    $('form.form_import').submit(function() {
55
    $('form.form_import').submit(function() {
56
        var id = $(this).attr('id');
56
        var id = $(this).attr('id');
57
        var obj = $('#' + id + ' input:file');
57
        var obj = $('#' + id + ' input:file');
58
        if (/(?:\.csv|\.ods|\.xml)$/.test(obj.val())) {
58
        if (/(?:\.csv|\.ods)$/.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"))) {
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();
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>"));
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>"));
Lines 73-79 $(document).ready(function() { Link Here
73
            }
73
            }
74
        }
74
        }
75
        obj.css("background-color","yellow");
75
        obj.css("background-color","yellow");
76
        alert(_("Please select a CSV (.csv), ODS (.ods) or XML (.xml) spreadsheet file."));
76
        alert(_("Please select a CSV (.csv) or ODS (.ods) spreadsheet file."));
77
        obj.val("");
77
        obj.val("");
78
        bj.css("background-color","white");
78
        bj.css("background-color","white");
79
        return false;
79
        return false;
80
- 

Return to bug 13952