DBREV - Bug 15675 - Add issue_id column to accountlines and use it for updating fines
[koha.git] / authorities / export.pl
blob6b79ffb6569b9078d1620d852200673701666312
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
5 use C4::Record;
6 use C4::Auth;
7 use C4::Output;
8 use C4::AuthoritiesMarc;
9 use CGI qw ( -utf8 );
11 my $query = new CGI;
12 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
14 template_name => "tools/export.tt",
15 query => $query,
16 type => "intranet",
17 authnotrequired => 0,
18 flagsrequired => { catalogue => 1 },
19 debug => 1,
23 my $op = $query->param("op");
24 my $format = $query->param("format");
25 my $error = '';
26 if ( $op eq "export" ) {
27 my $authid = $query->param("authid");
28 if ($authid) {
30 my $marc = GetAuthority($authid);
32 if ( $format =~ /marcxml/ ) {
33 $marc = marc2marcxml($marc, 'UTF-8', C4::Context->preference("marcflavour") eq 'UNIMARC' ? 'UNIMARCAUTH' : 'MARC21' );
35 elsif ($format=~ /mads/) {
36 $marc = marc2madsxml($marc);
38 elsif ( $format =~ /marc8/ ) {
39 $marc = changeEncoding( $marc, "MARC", "MARC21", "MARC-8" );
40 $marc = $marc->as_usmarc();
42 elsif ( $format =~ /utf8/ ) {
43 C4::Charset::SetUTF8Flag( $marc, 1 );
44 $marc = $marc->as_usmarc();
46 print $query->header(
47 -type => 'application/octet-stream',
48 -attachment => "auth-$authid.$format"
50 print $marc;