7 use C4::Interface::CGI::Output;
8 use C4::Output; # contains gettemplate
14 my $op=$query->param("op");
15 my $dbh=C4::Context->dbh;
17 if ($op eq "export") {
18 print $query->header('Content-Type: text/marc');
19 my $start_bib = $query->param("start_bib");
20 my $end_bib = $query->param("end_bib");
21 my $format = $query->param("format");
22 my $branch = $query->param("branch");
23 my $start_callnumber = $query->param("start_callnumber");
24 my $end_callnumber = $query->param("end_callnumber");
25 my $limit = $query->param("limit");
27 $strsth="select bibid from marc_biblio ";
28 if ($start_bib && $end_bib) {
29 $strsth.=" where biblionumber>=$start_bib and biblionumber<=$end_bib ";
31 if ($strsth=~/ where/){
32 $strsth=~s/ where (.*)/,biblioitems where biblioitems.biblionumber=marc_biblio.biblionumber and biblioitems.itemtype=\'$format\' and $1/;
34 $strsth.=",biblioitems where biblioitems.biblionumber=marc_biblio.biblionumber and biblioitems.itemtype=\'$format\'";
37 if ($strsth=~/ where/){
38 $strsth=~s/ where (.*)/,items where items.biblionumber=marc_biblio.biblionumber and items.homebranch=\'$branch\' and $1/;
40 $strsth.=",items where items.biblionumber=marc_biblio.biblionumber and items.homebranch=\'$branch\'";
42 } elsif ($start_callnumber && $end_callnumber) {
43 $start_callnumber=~s/\*/\%/g;
44 $start_callnumber=~s/\?/\_/g;
45 $end_callnumber=~s/\*/\%/g;
46 $end_callnumber=~s/\?/\_/g;
47 if ($strsth=~/,items/){
48 $strsth.=" and items.itemcallnumber between \'$start_callnumber\' and \'$end_callnumber\'";
50 if ($strsth=~/ where/){
51 $strsth=~s/ where (.*)/,items where items.biblionumber=marc_biblio.biblionumber and items.itemcallnumber between \'$start_callnumber\' and \'$end_callnumber\' and $1/;
53 $strsth=~",items where items.biblionumber=marc_biblio.biblionumber and items.itemcallnumber between \'$start_callnumber\' and \'$end_callnumber\' ";
57 $strsth.=" order by marc_biblio.biblionumber ";
58 $strsth.= "LIMIT 0,$limit " if ($limit);
59 warn "requĂȘte marc.pl : ".$strsth;
60 my $req=$dbh->prepare($strsth);
62 while (my ($bibid) = $req->fetchrow) {
63 my $record = MARCgetbiblio($dbh,$bibid);
65 print $record->as_usmarc();
68 my $sth=$dbh->prepare("Select itemtype,description from itemtypes order by description");
74 while (my ($value,$lib) = $sth->fetchrow_array) {
75 push @itemtype, $value;
76 $itemtypes{$value}=$lib;
79 my $CGIitemtype=CGI::scrolling_list( -name => 'format',
80 -values => \@itemtype,
82 -labels => \%itemtypes,
87 my $branches = getallbranches;
89 foreach my $thisbranch (keys %$branches) {
90 # my $selected = 1 if $thisbranch eq $branch;
91 my %row =(value => $thisbranch,
92 # selected => $selected,
93 branchname => $branches->{$thisbranch}->{'branchname'},
95 push @branchloop, \%row;
98 my ($template, $loggedinuser, $cookie)
99 = get_template_and_user({template_name => "export/marc.tmpl",
102 authnotrequired => 0,
103 flagsrequired => {parameters => 1, management => 1, tools => 1},
106 $template->param(branchloop=>\@branchloop,CGIitemtype=>$CGIitemtype);
107 output_html_with_http_headers $query, $cookie, $template->output;