MT 1882 : ccode search in serials/subscription-bib-search.pl
[koha.git] / opac / opac-export.pl
blob0e2d94f915c769f1ed3adb8914fc6b3261e0165d
1 #!/usr/bin/perl
2 use HTML::Template::Pro;
3 use strict;
4 use warnings;
6 use C4::Record;
7 use C4::Auth;
8 use C4::Output;
9 use C4::Biblio;
10 use CGI;
11 use C4::Auth;
12 use C4::Ris;
14 my $query = new CGI;
15 my $op=$query->param("op");
16 my $format=$query->param("format");
17 if ($op eq "export") {
18 my $biblionumber = $query->param("bib");
19 my $dbh=C4::Context->dbh;
20 my $sth;
21 if ($biblionumber) {
22 $sth=$dbh->prepare("SELECT marc FROM biblioitems WHERE biblionumber =?");
23 $sth->execute($biblionumber);
25 while (my ($marc) = $sth->fetchrow) {
26 if ($marc){
28 if ($format =~ /endnote/) {
29 $marc = marc2endnote($marc);
30 $format = 'endnote';
32 elsif ($format =~ /marcxml/) {
33 $marc = marc2marcxml($marc);
35 elsif ($format=~ /mods/) {
36 $marc = marc2modsxml($marc);
38 elsif ($format =~ /ris/) {
39 $marc = marc2ris(MARC::Record->new_from_usmarc($marc));
41 elsif ($format =~ /bibtex/) {
42 my $error;
43 ($error,$marc) = marc2bibtex(C4::Biblio::GetMarcBiblio($biblionumber),$biblionumber);
44 }elsif ($format =~ /dc/) {
45 my $error;
46 ($error,$marc) = marc2dcxml($marc,1);
47 $format = "dublin-core.xml";
49 elsif ($format =~ /marc8/) {
50 $marc = changeEncoding($marc,"MARC","MARC21","MARC-8");
51 $marc = $marc->as_usmarc();
53 elsif ($format =~ /utf8/) {
54 #default
56 print $query->header(
57 -type => 'application/octet-stream',
58 -attachment=>"bib-$biblionumber.$format");
59 print $marc;