Merged with arensb-context branch: use C4::Context->dbh instead of
[koha.git] / html-template / moredetail.pl
1 #!/usr/bin/perl
2
3 # Copyright 2000-2002 Katipo Communications
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
11 #
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA  02111-1307 USA
19
20 use HTML::Template;
21 use strict;
22 require Exporter;
23 use C4::Context;
24 use C4::Koha;
25 use CGI;
26 use C4::Search;
27 use C4::Acquisitions;
28 use C4::Output; # contains picktemplate
29   
30 my $query=new CGI;
31
32 my $includes = C4::Context->config('includes') ||
33         "/usr/local/www/hdl/htdocs/includes";
34 my $templatebase="catalogue/moredetail.tmpl";
35 my $startfrom=$query->param('startfrom') || 0;
36 my $theme=picktemplate($includes, $templatebase);
37
38 my $subject=$query->param('subject');
39 # if its a subject we need to use the subject.tmpl
40 if ($subject){
41   $templatebase=~ s/searchresults\.tmpl/subject\.tmpl/;
42 }
43 my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]);
44
45 # get variables 
46
47 my $biblionumber=$query->param('bib');
48 my $title=$query->param('title');
49 my $bi=$query->param('bi');
50
51 my $data=bibitemdata($bi);
52 my $dewey = $data->{'dewey'};
53 $dewey =~ s/0+$//;
54 if ($dewey eq "000.") { $dewey = "";};
55 if ($dewey < 10){$dewey='00'.$dewey;}
56 if ($dewey < 100 && $dewey > 10){$dewey='0'.$dewey;}
57 if ($dewey <= 0){
58       $dewey='';
59 }
60 $dewey=~ s/\.$//;
61 $data->{'dewey'}=$dewey;
62
63 my @results;
64
65 my (@items)=itemissues($bi);
66 my $count=@items;
67 $data->{'count'}=$count;
68 my ($order,$ordernum)=getorder($bi,$biblionumber);
69
70 my $env;
71 $env->{itemcount}=1;
72
73 $results[0]=$data;
74
75 $template->param(includesdir => $includes);
76 $template->param(BIBITEM_DATA => \@results);
77 $template->param(ITEM_DATA => \@items);
78 print "Content-Type: text/html\n\n", $template->output;
79