Bug 26111: Add "Serials" (SER) to the reports dictionnary
[koha.git] / authorities / export.pl
blobfbb675eec0b05877230b1fd35c6d827bebff3548
1 #!/usr/bin/perl
2 use Modern::Perl;
4 use C4::Record;
5 use C4::Auth;
6 use C4::Output;
7 use C4::AuthoritiesMarc;
8 use CGI qw ( -utf8 );
10 my $query = new CGI;
11 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
13 template_name => "tools/export.tt",
14 query => $query,
15 type => "intranet",
16 authnotrequired => 0,
17 flagsrequired => { catalogue => 1 },
18 debug => 1,
22 my $op = $query->param("op");
23 my $format = $query->param("format");
24 my $error = '';
25 if ( $op eq "export" ) {
26 my $authid = $query->param("authid");
27 if ($authid) {
29 my $marc = GetAuthority($authid);
31 if ( $format =~ /marcxml/ ) {
32 $marc = marc2marcxml($marc, 'UTF-8', C4::Context->preference("marcflavour") eq 'UNIMARC' ? 'UNIMARCAUTH' : 'MARC21' );
34 elsif ($format=~ /mads/) {
35 $marc = marc2madsxml($marc);
37 elsif ( $format =~ /marc8/ ) {
38 $marc = changeEncoding( $marc, "MARC", "MARC21", "MARC-8" );
39 $marc = $marc->as_usmarc();
41 elsif ( $format =~ /utf8/ ) {
42 C4::Charset::SetUTF8Flag( $marc, 1 );
43 $marc = $marc->as_usmarc();
45 print $query->header(
46 -type => 'application/octet-stream',
47 -attachment => "auth-$authid.$format"
49 print $marc;