Merging from rel-1-2 to trunk
[koha.git] / opac / opac-detail.pl
1 #!/usr/bin/perl
2 use strict;
3 require Exporter;
4 use C4::Output;  # contains gettemplate
5 use CGI;
6 use C4::Search;
7 use C4::Auth;
8
9 my $query=new CGI;
10
11
12 my $flagsrequired;
13 $flagsrequired->{borrow}=1;
14
15 my ($loggedinuser, $cookie, $sessionID) = checkauth($query, 1, $flagsrequired);
16
17
18 my $template = gettemplate ("opac-detail.tmpl", "opac");
19
20 $template->param(loggedinuser => $loggedinuser);
21
22 my $biblionumber=$query->param('bib');
23 $template->param(biblionumber => $biblionumber);
24
25
26 # change back when ive fixed request.pl
27 my @items                                 = &ItemInfo(undef, $biblionumber, 'opac');
28 my $dat                                   = &bibdata($biblionumber);
29 my ($authorcount, $addauthor)             = &addauthor($biblionumber);
30 my ($webbiblioitemcount, @webbiblioitems) = &getwebbiblioitems($biblionumber);
31 my ($websitecount, @websites)             = &getwebsites($biblionumber);
32
33 $dat->{'count'}=@items;
34
35 $dat->{'additional'}=$addauthor->[0]->{'author'};
36 for (my $i = 1; $i < $authorcount; $i++) {
37         $dat->{'additional'} .= "|" . $addauthor->[$i]->{'author'};
38 } # for
39
40 my $norequests = 1;
41 foreach my $itm (@items) {
42     $norequests = 0 unless $itm->{'notforloan'};
43 }
44
45 $template->param(norequests => $norequests);
46
47
48
49 my @results;
50
51 $results[0]=$dat;
52
53 my $resultsarray=\@results;
54 my $itemsarray=\@items;
55 my $webarray=\@webbiblioitems;
56 my $sitearray=\@websites;
57
58
59 my $startfrom=$query->param('startfrom');
60 ($startfrom) || ($startfrom=0);
61
62 my $count=1;
63
64 # now to get the items into a hash we can use and whack that thru
65 $template->param(startfrom => $startfrom+1);
66 $template->param(endat => $startfrom+20);
67 $template->param(numrecords => $count);
68 my $nextstartfrom=($startfrom+20<$count-20) ? ($startfrom+20) : ($count-20);
69 my $prevstartfrom=($startfrom-20>0) ? ($startfrom-20) : (0);
70 $template->param(nextstartfrom => $nextstartfrom);
71 $template->param(prevstartfrom => $prevstartfrom);
72
73 $template->param(BIBLIO_RESULTS => $resultsarray);
74 $template->param(ITEM_RESULTS => $itemsarray);
75 $template->param(WEB_RESULTS => $webarray);
76 $template->param(SITE_RESULTS => $sitearray);
77
78 print "Content-Type: text/html\n\n", $template->output;
79