removes warning
[koha.git] / export / marc.pl
1 #!/usr/bin/perl
2 use HTML::Template;
3 use strict;
4 require Exporter;
5 use C4::Database;
6 use C4::Output;  # contains gettemplate
7 use C4::Biblio;
8 use CGI;
9 use C4::Auth;
10
11 my $query = new CGI;
12 my $op=$query->param("op");
13 if ($op eq "export") {
14         print $query->header('Content-Type: text/marc');
15         my $start_bib = $query->param("start_bib");
16         my $end_bib = $query->param("end_bib");
17         my $dbh=C4::Context->dbh;
18         my $query;
19         if ($start_bib && $end_bib) {
20                 $query = "select bibid from marc_biblio where bibid >=$start_bib and bibid <=$end_bib order by bibid";
21         } else {
22                 $query = "select bibid from marc_biblio order by bibid";
23         }
24         my $sth=$dbh->prepare($query);
25         $sth->execute;
26         while (my ($bibid) = $sth->fetchrow) {
27                 my $record = MARCgetbiblio($dbh,$bibid);
28
29                 print $record->as_usmarc();
30         }
31 } else {
32         my ($template, $loggedinuser, $cookie)
33         = get_template_and_user({template_name => "export/marc.tmpl",
34                                         query => $query,
35                                         type => "intranet",
36                                         authnotrequired => 0,
37                                         flagsrequired => {parameters => 1},
38                                         debug => 1,
39                                         });
40         print  $query->header(-cookie => $cookie), $template->output;
41 }
42