Bug 19080: Fix member vs borrowernumber in delmember
[koha.git] / catalogue / export.pl
blobc10686c12b34be8695ecf45724c6b817bec8c095
1 #!/usr/bin/perl
2 use strict;
3 #use warnings; FIXME - Bug 2505
5 use C4::Record;
6 use C4::Auth;
7 use C4::Output;
8 use C4::Biblio;
9 use CGI qw ( -utf8 );
10 use C4::Ris;
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 => { catalogue => 1 },
21 debug => 1,
22 });
24 my $op=$query->param("op");
25 my $format=$query->param("format");
26 my $error = '';
27 if ($op eq "export") {
28 my $biblionumber = $query->param("bib");
29 if ($biblionumber){
31 my $marc = GetMarcBiblio({
32 biblionumber => $biblionumber,
33 embed_items => 1 });
35 if ($format =~ /endnote/) {
36 $marc = marc2endnote($marc);
37 $format = 'endnote';
39 elsif ($format =~ /marcxml/) {
40 $marc = marc2marcxml($marc);
41 $format = "marcxml";
43 elsif ($format=~ /mods/) {
44 $marc = marc2modsxml($marc);
45 $format = "mods";
47 elsif ($format =~ /ris/) {
48 $marc = marc2ris($marc);
49 $format = "ris";
51 elsif ($format =~ /bibtex/) {
52 $marc = marc2bibtex($marc);
53 $format = "bibtex";
55 elsif ($format =~ /dc$/) {
56 $marc = marc2dcxml(undef, undef, $biblionumber, $format);
57 $format = "dublin-core.xml";
59 elsif ($format =~ /marc8/) {
60 $marc = changeEncoding($marc,"MARC","MARC21","MARC-8");
61 $marc = $marc->as_usmarc();
62 $format = "marc8";
64 elsif ($format =~ /utf8/) {
65 C4::Charset::SetUTF8Flag($marc, 1);
66 $marc = $marc->as_usmarc();
67 $format = "utf8";
69 elsif ($format =~ /marcstd/) {
70 C4::Charset::SetUTF8Flag($marc,1);
71 ($error, $marc) = marc2marc($marc, 'marcstd', C4::Context->preference('marcflavour'));
72 $format = "marcstd";
74 if ( $format =~ /utf8/ or $format =~ /marcstd/ ) {
75 binmode STDOUT, ':encoding(UTF-8)';
77 print $query->header(
78 -type => 'application/octet-stream',
79 -attachment=>"bib-$biblionumber.$format");
80 print $marc;