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