merging arens + my modifs/bugfixes
[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::Acquisitions;
29 <<<<<<< moredetail.pl
30 use C4::Output;
31
32 =======
33 use C4::Output; # contains gettemplate
34
35 >>>>>>> 1.14
36 my $query=new CGI;
37
38 my $includes = C4::Context->config('includes') ||
39         "/usr/local/www/hdl/htdocs/includes";
40 my $startfrom=$query->param('startfrom') || 0;
41
42 my $subject=$query->param('subject');
43 # if its a subject we need to use the subject.tmpl
44 my $template;
45 if ($subject){
46         $template = gettemplate("catalogue/subject.tmpl");
47 } else {
48         $template = gettemplate("catalogue/moredetail.tmpl");
49 }
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 $dewey =~ s/0+$//;
58 if ($dewey eq "000.") { $dewey = "";};
59 if ($dewey < 10){$dewey='00'.$dewey;}
60 if ($dewey < 100 && $dewey > 10){$dewey='0'.$dewey;}
61 if ($dewey <= 0){
62       $dewey='';
63 }
64 $dewey=~ s/\.$//;
65 $data->{'dewey'}=$dewey;
66
67 my @results;
68
69 my (@items)=itemissues($bi);
70 my $count=@items;
71 $data->{'count'}=$count;
72 my ($order,$ordernum)=getorder($bi,$biblionumber);
73
74 $results[0]=$data;
75
76 foreach my $item (@items){
77     $item->{'itemlost'}=~ s/0/No/;
78     $item->{'itemlost'}=~ s/1/Yes/;
79     $item->{'withdrawn'}=~ s/0/No/;
80     $item->{'withdrawn'}=~ s/1/Yes/;
81     $item->{'replacementprice'}+=0.00;
82     my $year=substr($item->{'timestamp0'},0,4);
83     my $mon=substr($item->{'timestamp0'},4,2);
84     my $day=substr($item->{'timestamp0'},6,2);
85     $item->{'timestamp0'}="$day/$mon/$year";
86     $item->{'dateaccessioned'} = slashifyDate($item->{'dateaccessioned'});
87     $item->{'datelastseen'} = slashifyDate($item->{'datelastseen'});
88     $item->{'ordernumber'} = $ordernum;
89     $item->{'booksellerinvoicenumber'} = $order->{'booksellerinvoicenumber'};
90
91     # FIXME - This should be "==", not "=", right?
92     if ($item->{'date_due'} = 'Available'){
93         $item->{'issue'}="<b>Available</b><br>";
94     } else {
95         $item->{'issue'}="<b>Currently on issue to:</b> <a href=/cgi-bin/koha/moremember.pl?bornum=$item->{'borrower0'}>$item->{'card'}</a><br>";
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