road to 1.3.2
[koha.git] / moredetail.pl
1 #!/usr/bin/perl
2
3 # $Id$
4
5 # Copyright 2000-2002 Katipo Communications
6 #
7 # This file is part of Koha.
8 #
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
12 # version.
13 #
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License along with
19 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 # Suite 330, Boston, MA  02111-1307 USA
21
22 use HTML::Template;
23 use strict;
24 require Exporter;
25 use C4::Koha;
26 use CGI;
27 use C4::Search;
28 use C4::Catalogue;
29 use C4::Output; # contains gettemplate
30 my $query=new CGI;
31
32 my $includes = C4::Context->config('includes') ||
33         "/usr/local/www/hdl/htdocs/includes";
34 my $startfrom=$query->param('startfrom') || 0;
35
36 my $subject=$query->param('subject');
37 # if its a subject we need to use the subject.tmpl
38 my $template;
39 if ($subject){
40         $template = gettemplate("catalogue/subject.tmpl");
41 } else {
42         $template = gettemplate("catalogue/moredetail.tmpl");
43 }
44
45 my $biblionumber=$query->param('bib');
46 my $title=$query->param('title');
47 my $bi=$query->param('bi');
48
49 my $data=bibitemdata($bi);
50 my $dewey = $data->{'dewey'};
51 $dewey =~ s/0+$//;
52 if ($dewey eq "000.") { $dewey = "";};
53 if ($dewey < 10){$dewey='00'.$dewey;}
54 if ($dewey < 100 && $dewey > 10){$dewey='0'.$dewey;}
55 if ($dewey <= 0){
56       $dewey='';
57 }
58 $dewey=~ s/\.$//;
59 $data->{'dewey'}=$dewey;
60
61 my @results;
62
63 my (@items)=itemissues($bi);
64 my $count=@items;
65 $data->{'count'}=$count;
66 my ($order,$ordernum)=getorder($bi,$biblionumber);
67
68 $results[0]=$data;
69
70 foreach my $item (@items){
71     $item->{'itemlost'}=~ s/0/No/;
72     $item->{'itemlost'}=~ s/1/Yes/;
73     $item->{'withdrawn'}=~ s/0/No/;
74     $item->{'withdrawn'}=~ s/1/Yes/;
75     $item->{'replacementprice'}+=0.00;
76     my $year=substr($item->{'timestamp0'},0,4);
77     my $mon=substr($item->{'timestamp0'},4,2);
78     my $day=substr($item->{'timestamp0'},6,2);
79     $item->{'timestamp0'}="$day/$mon/$year";
80     $item->{'dateaccessioned'} = slashifyDate($item->{'dateaccessioned'});
81     $item->{'datelastseen'} = slashifyDate($item->{'datelastseen'});
82     $item->{'ordernumber'} = $ordernum;
83     $item->{'booksellerinvoicenumber'} = $order->{'booksellerinvoicenumber'};
84
85     if ($item->{'date_due'} eq 'Available'){
86         $item->{'issue'}="<b>Available</b><br>";
87     } else {
88         $item->{'issue'}="<b>Currently on issue to:</b> <a href=/cgi-bin/koha/moremember.pl?bornum=$item->{'borrower0'}>$item->{'card'}</a><br>";
89     }
90 }
91
92 $template->param(includesdir => $includes);
93 $template->param(BIBITEM_DATA => \@results);
94 $template->param(ITEM_DATA => \@items);
95 print "Content-Type: text/html\n\n", $template->output;
96