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