fixed a couple of bugs. Note this version of opac-reserve.pl is designed to work...
[koha.git] / moredetail.pl
1 #!/usr/bin/perl
2 # NOTE: Use standard 8-space tabs for this file (indents are 4 spaces)
3
4 # $Id$
5
6 # Copyright 2000-2003 Katipo Communications
7 #
8 # This file is part of Koha.
9 #
10 # Koha is free software; you can redistribute it and/or modify it under the
11 # terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 2 of the License, or (at your option) any later
13 # version.
14 #
15 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License along with
20 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
21 # Suite 330, Boston, MA  02111-1307 USA
22
23 use HTML::Template;
24 use strict;
25 require Exporter;
26 use C4::Koha;
27 use CGI;
28 use C4::Search;
29 use C4::Catalogue;
30 use C4::Output; # contains gettemplate
31 use C4::Auth;
32 use C4::Interface::CGI::Output;
33
34 my $query=new CGI;
35
36 # FIXME  subject is not exported to the template?
37 my $subject=$query->param('subject');
38
39 # if its a subject we need to use the subject.tmpl
40 my ($template, $loggedinuser, $cookie) = get_template_and_user({
41         template_name   => ($subject? 'catalogue/subject.tmpl':
42                                       'catalogue/moredetail.tmpl'),
43         query           => $query,
44         type            => "intranet",
45         authnotrequired => 0,
46         flagsrequired   => {catalogue => 1},
47     });
48
49 # get variables
50
51 my $biblionumber=$query->param('bib');
52 my $title=$query->param('title');
53 my $bi=$query->param('bi');
54
55 my $data=bibitemdata($bi);
56 my $dewey = $data->{'dewey'};
57 # FIXME Dewey is a string, not a number, & we should use a function
58 $dewey =~ s/0+$//;
59 if ($dewey eq "000.") { $dewey = "";};
60 if ($dewey < 10){$dewey='00'.$dewey;}
61 if ($dewey < 100 && $dewey > 10){$dewey='0'.$dewey;}
62 if ($dewey <= 0){
63       $dewey='';
64 }
65 $dewey=~ s/\.$//;
66 $data->{'dewey'}=$dewey;
67
68 my @results;
69
70 my (@items)=itemissues($bi);
71 my $count=@items;
72 $data->{'count'}=$count;
73 my ($order,$ordernum)=getorder($bi,$biblionumber);
74
75 my $env;
76 $env->{itemcount}=1;
77
78 $results[0]=$data;
79
80 foreach my $item (@items){
81     $item->{'itemlost'}=~ s/0/No/;
82     $item->{'itemlost'}=~ s/1/Yes/;
83     $item->{'withdrawn'}=~ s/0/No/;
84     $item->{'withdrawn'}=~ s/1/Yes/;
85     $item->{'replacementprice'}+=0.00;
86     my $year=substr($item->{'timestamp0'},0,4);
87     my $mon=substr($item->{'timestamp0'},4,2);
88     my $day=substr($item->{'timestamp0'},6,2);
89     $item->{'timestamp0'}="$day/$mon/$year";
90     $item->{'dateaccessioned'} = slashifyDate($item->{'dateaccessioned'});
91     $item->{'datelastseen'} = slashifyDate($item->{'datelastseen'});
92     $item->{'ordernumber'} = $ordernum;
93     $item->{'booksellerinvoicenumber'} = $order->{'booksellerinvoicenumber'};
94
95     # FIXME untranslatable strings
96     if ($item->{'date_due'} eq 'Available'){
97         $item->{'issue'}="<b>Available</b><br>";
98     } else {
99         $item->{'issue'}="<b>Currently on issue to:</b> <a href=/cgi-bin/koha/moremember.pl?bornum=$item->{'borrower0'}>$item->{'card'}</a><br>";
100     }
101 }
102
103 $template->param(BIBITEM_DATA => \@results);
104 $template->param(ITEM_DATA => \@items);
105 $template->param(loggedinuser => $loggedinuser);
106
107 output_html_with_http_headers $query, $cookie, $template->output;
108
109
110 # Local Variables:
111 # tab-width: 8
112 # End: