*** empty log message ***
[koha.git] / 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::Koha;
24 use CGI;
25 use C4::Search;
26 use C4::Acquisitions;
27 use C4::Output; # contains picktemplate
28   
29 my $query=new CGI;
30
31 my $includes = C4::Context->config('includes') ||
32         "/usr/local/www/hdl/htdocs/includes";
33 my $templatebase="catalogue/moredetail.tmpl";
34 my $startfrom=$query->param('startfrom') || 0;
35 my $theme=picktemplate($includes, $templatebase);
36
37 my $subject=$query->param('subject');
38 # if its a subject we need to use the subject.tmpl
39 if ($subject){
40   $templatebase=~ s/searchresults\.tmpl/subject\.tmpl/;
41 }
42 my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]);
43
44 # get variables 
45
46 my $biblionumber=$query->param('bib');
47 my $title=$query->param('title');
48 my $bi=$query->param('bi');
49
50 my $data=bibitemdata($bi);
51 my $dewey = $data->{'dewey'};
52 $dewey =~ s/0+$//;
53 if ($dewey eq "000.") { $dewey = "";};
54 if ($dewey < 10){$dewey='00'.$dewey;}
55 if ($dewey < 100 && $dewey > 10){$dewey='0'.$dewey;}
56 if ($dewey <= 0){
57       $dewey='';
58 }
59 $dewey=~ s/\.$//;
60 $data->{'dewey'}=$dewey;
61
62 my @results;
63
64 my (@items)=itemissues($bi);
65 my $count=@items;
66 $data->{'count'}=$count;
67 my ($order,$ordernum)=getorder($bi,$biblionumber);
68
69
70 my $env;
71 $env->{itemcount}=1;
72
73 $results[0]=$data;
74
75 foreach my $item (@items){
76     $item->{'itemlost'}=~ s/0/No/;
77     $item->{'itemlost'}=~ s/1/Yes/;
78     $item->{'withdrawn'}=~ s/0/No/;
79     $item->{'withdrawn'}=~ s/1/Yes/;
80     $item->{'replacementprice'}+=0.00;
81     my $year=substr($item->{'timestamp0'},0,4);
82     my $mon=substr($item->{'timestamp0'},4,2);
83     my $day=substr($item->{'timestamp0'},6,2);
84     $item->{'timestamp0'}="$day/$mon/$year";
85     $item->{'dateaccessioned'} = slashifyDate($item->{'dateaccessioned'});
86     $item->{'datelastseen'} = slashifyDate($item->{'datelastseen'});
87     $item->{'ordernumber'} = $ordernum;
88     $item->{'booksellerinvoicenumber'} = $order->{'booksellerinvoicenumber'};
89
90     # FIXME - This should be "==", not "=", right?
91     if ($item->{'date_due'} = 'Available'){
92         $item->{'issue'}="<b>Available</b><br>";
93     } else {
94         $item->{'issue'}="<b>Currently on issue to:</b> <a href=/cgi-bin/koha/moremember.pl?bornum=$item->{'borrower0'}>$item->{'card'}</a><br>";
95     }
96           
97 }
98
99 $template->param(includesdir => $includes);
100 $template->param(BIBITEM_DATA => \@results);
101 $template->param(ITEM_DATA => \@items);
102 print "Content-Type: text/html\n\n", $template->output;
103