Head & rel_2_2 merged
[koha.git] / opac / opac-basket.pl
1 #!/usr/bin/perl
2 use strict;
3 require Exporter;
4 use CGI;
5 use C4::Biblio;
6 use C4::Auth;
7 use C4::Interface::CGI::Output;
8 use HTML::Template;
9
10 my $query=new CGI;
11
12 my ($template, $borrowernumber, $cookie)
13     = get_template_and_user({template_name => "opac-basket.tmpl",
14                              query => $query,
15                              type => "opac",
16                              authnotrequired => 1,
17                              flagsrequired => {borrow => 1},
18                          });
19
20
21 my $bib_list=$query->param('bib_list');
22 my $print_basket=$query->param('print');
23 my $verbose = $query->param('verbose');
24
25 if($verbose) { $template->param(verbose => 1); }
26 if ($print_basket) { $template->param(print_basket => 1); }
27
28 my @bibs = split(/\//, $bib_list);
29 my @results;
30
31 my $num = 1;
32 foreach my $biblionumber (@bibs) {
33         $template->param(biblionumber => $biblionumber);
34
35         my $dat                                   = &bibdata($biblionumber);
36         my ($authorcount, $addauthor)             = &addauthor($biblionumber);
37         my @items                                 = &ItemInfo(undef, $biblionumber, 'opac');
38
39         $dat->{'additional'}=$addauthor->[0]->{'author'};
40         for (my $i = 1; $i < $authorcount; $i++) {
41                         $dat->{'additional'} .= "|" . $addauthor->[$i]->{'author'};
42         } # for
43         if($num % 2 == 1){
44                 $dat->{'even'} = 1;
45         }
46         $num++;
47         $dat->{'biblionumber'} = $biblionumber;
48         $dat->{ITEM_RESULTS} = \@items;
49         if (C4::Context->preference("BiblioDefaultView") eq "normal") {
50              $dat->{dest} = "opac-detail.pl";
51         } elsif (C4::Context->preference("BiblioDefaultView") eq "marc") {
52              $dat->{dest} ="opac-MARCdetail.pl";
53         } else {
54              $dat->{dest} = "opac-ISBDdetail.pl";
55         }
56         push (@results, $dat);
57 }
58
59 my $resultsarray=\@results;
60 # my $itemsarray=\@items;
61
62 $template->param(BIBLIO_RESULTS => $resultsarray,
63 );
64
65 output_html_with_http_headers $query, $cookie, $template->output;