synch'ing 2.2 and head
[koha.git] / opac / opac-basket.pl
1 #!/usr/bin/perl
2 use strict;
3 require Exporter;
4 use CGI;
5 use C4::Search;
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         push (@results, $dat);
50 }
51
52 my $resultsarray=\@results;
53 # my $itemsarray=\@items;
54
55 $template->param(BIBLIO_RESULTS => $resultsarray,
56                              LibraryName => C4::Context->preference("LibraryName"),
57                                 suggestion => C4::Context->preference("suggestion"),
58                                 virtualshelves => C4::Context->preference("virtualshelves"),
59 );
60
61 output_html_with_http_headers $query, $cookie, $template->output;