merged in changes from the rel-1-2 branch into the main branch. Some of the default...
[koha.git] / opac / opac-detail.pl
1 #!/usr/bin/perl
2 use strict;
3 require Exporter;
4 use CGI;
5 use C4::Search;
6 use C4::Auth;
7
8 my $query=new CGI;
9 my ($template, $borrowernumber, $cookie) 
10     = get_template_and_user({template_name => "opac-detail.tmpl",
11                              query => $query,
12                              type => "opac",
13                              authnotrequired => 1,
14                              flagsrequired => {borrow => 1},
15                              });
16
17 my $biblionumber=$query->param('bib');
18 $template->param(biblionumber => $biblionumber);
19
20
21 # change back when ive fixed request.pl
22 my @items                                 = &ItemInfo(undef, $biblionumber, 'opac');
23 my $dat                                   = &bibdata($biblionumber);
24 my ($authorcount, $addauthor)             = &addauthor($biblionumber);
25 my ($webbiblioitemcount, @webbiblioitems) = &getwebbiblioitems($biblionumber);
26 my ($websitecount, @websites)             = &getwebsites($biblionumber);
27
28 $dat->{'count'}=@items;
29
30 $dat->{'additional'}=$addauthor->[0]->{'author'};
31 for (my $i = 1; $i < $authorcount; $i++) {
32         $dat->{'additional'} .= "|" . $addauthor->[$i]->{'author'};
33 } # for
34
35 my $norequests = 1;
36 foreach my $itm (@items) {
37     $norequests = 0 unless $itm->{'notforloan'};
38     $itm->{$itm->{'publictype'}} = 1;
39 }
40
41 $template->param(norequests => $norequests);
42
43 my @results = ($dat,);
44
45 my $resultsarray=\@results;
46 my $itemsarray=\@items;
47 my $webarray=\@webbiblioitems;
48 my $sitearray=\@websites;
49
50 $template->param(BIBLIO_RESULTS => $resultsarray);
51 $template->param(ITEM_RESULTS => $itemsarray);
52 $template->param(WEB_RESULTS => $webarray);
53 $template->param(SITE_RESULTS => $sitearray);
54
55 print $query->header(-cookie => $cookie), $template->output;
56