minor improvment : loads only the 1st sentence. Thus, avoid lllooonnnggg descriptions
[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 gettemplate
28   
29 my $query=new CGI;
30
31 my $includes = C4::Context->config('includes') ||
32         "/usr/local/www/hdl/htdocs/includes";
33 my $startfrom=$query->param('startfrom') || 0;
34
35
36 my $template = gettemplate("catalogue/moredetail.tmpl");
37
38 # get variables 
39
40 my $biblionumber=$query->param('bib');
41 my $title=$query->param('title');
42 my $bi=$query->param('bi');
43
44 my $data=bibitemdata($bi);
45 my $dewey = $data->{'dewey'};
46 $dewey =~ s/0+$//;
47 if ($dewey eq "000.") { $dewey = "";};
48 if ($dewey < 10){$dewey='00'.$dewey;}
49 if ($dewey < 100 && $dewey > 10){$dewey='0'.$dewey;}
50 if ($dewey <= 0){
51       $dewey='';
52 }
53 $dewey=~ s/\.$//;
54 $data->{'dewey'}=$dewey;
55
56 my @results;
57
58 my (@items)=itemissues($bi);
59 my $count=@items;
60 $data->{'count'}=$count;
61 my ($order,$ordernum)=getorder($bi,$biblionumber);
62
63
64 my $env;
65 $env->{itemcount}=1;
66
67 $results[0]=$data;
68
69 foreach my $item (@items){
70     $item->{'itemlost'}=~ s/0/No/;
71     $item->{'itemlost'}=~ s/1/Yes/;
72     $item->{'withdrawn'}=~ s/0/No/;
73     $item->{'withdrawn'}=~ s/1/Yes/;
74     $item->{'replacementprice'}+=0.00;
75     my $year=substr($item->{'timestamp0'},0,4);
76     my $mon=substr($item->{'timestamp0'},4,2);
77     my $day=substr($item->{'timestamp0'},6,2);
78     $item->{'timestamp0'}="$day/$mon/$year";
79     $item->{'dateaccessioned'} = slashifyDate($item->{'dateaccessioned'});
80     $item->{'datelastseen'} = slashifyDate($item->{'datelastseen'});
81     $item->{'ordernumber'} = $ordernum;
82     $item->{'booksellerinvoicenumber'} = $order->{'booksellerinvoicenumber'};
83
84     # FIXME - This should be "==", not "=", right?
85     if ($item->{'date_due'} = '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
93 $template->param(includesdir => $includes);
94 $template->param(BIBITEM_DATA => \@results);
95 $template->param(ITEM_DATA => \@items);
96 print "Content-Type: text/html\n\n", $template->output;
97