Bug 7435: corrects Fund selectbox in addneworder
[koha.git] / catalogue / export.pl
1 #!/usr/bin/perl
2 use strict;
3 #use warnings; FIXME - Bug 2505
4
5 use C4::Record;
6 use C4::Auth;
7 use C4::Output;
8 use C4::Biblio;
9 use CGI;
10
11
12
13 my $query = new CGI;
14 my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
15                                                                      template_name   => "tools/export.tt",
16                                                                      query           => $query,
17                                                                      type            => "intranet",
18                                                                      authnotrequired => 0,
19                                                                      flagsrequired   => { tools => 'export_catalog' },
20                                                                      debug           => 1,
21                                                                      });
22
23 my $op=$query->param("op");
24 my $format=$query->param("format");
25 if ($op eq "export") {
26         my $biblionumber = $query->param("bib");
27                 if ($biblionumber){
28
29                         my $marc = GetMarcBiblio($biblionumber, 1);
30
31                         if ($format =~ /endnote/) {
32                                 $marc = marc2endnote($marc);
33                                 $format = 'endnote';
34                         }
35                         elsif ($format =~ /marcxml/) {
36                                 $marc = marc2marcxml($marc);
37                         }
38                         elsif ($format=~ /mods/) {
39                                 $marc = marc2modsxml($marc);
40                         }
41                         elsif ($format =~ /dc/) {
42                                 my $error;
43                                 ($error,$marc) = marc2dcxml($marc,1);
44                                 $format = "dublin-core.xml";
45                         }
46                         elsif ($format =~ /marc8/) {
47                                 $marc = changeEncoding($marc,"MARC","MARC21","MARC-8");
48                                 $marc = $marc->as_usmarc();
49                         }
50                         elsif ($format =~ /utf8/) {
51                                 C4::Charset::SetUTF8Flag($marc, 1);
52                                 $marc = $marc->as_usmarc();
53                         }
54                         print $query->header(
55                                 -type => 'application/octet-stream',
56                 -attachment=>"bib-$biblionumber.$format");
57                         print $marc;
58                 }
59 }