Added copyright statement to all .pl and .pm files
[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
32 my $language='french';
33
34
35 my %configfile;
36 open (KC, "/etc/koha.conf");
37 while (<KC>) {
38  chomp;
39  (next) if (/^\s*#/);
40  if (/(.*)\s*=\s*(.*)/) {
41    my $variable=$1;
42    my $value=$2;
43    # Clean up white space at beginning and end
44    $variable=~s/^\s*//g;
45    $variable=~s/\s*$//g;
46    $value=~s/^\s*//g;
47    $value=~s/\s*$//g;
48    $configfile{$variable}=$value;
49  }
50 }
51
52 my $includes=$configfile{'includes'};
53 ($includes) || ($includes="/usr/local/www/hdl/htdocs/includes");
54 my $templatebase="catalogue/moredetail.tmpl";
55 my $startfrom=$query->param('startfrom');
56 ($startfrom) || ($startfrom=0);
57 my $theme=picktemplate($includes, $templatebase);
58
59 my $subject=$query->param('subject');
60 # if its a subject we need to use the subject.tmpl
61 if ($subject){
62   $templatebase=~ s/searchresults\.tmpl/subject\.tmpl/;
63 }
64 my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]);
65
66 # get variables 
67
68 my $biblionumber=$query->param('bib');
69 my $title=$query->param('title');
70 my $bi=$query->param('bi');
71
72 my $data=bibitemdata($bi);
73 my $dewey = $data->{'dewey'};
74 $dewey =~ s/0+$//;
75 if ($dewey eq "000.") { $dewey = "";};
76 if ($dewey < 10){$dewey='00'.$dewey;}
77 if ($dewey < 100 && $dewey > 10){$dewey='0'.$dewey;}
78 if ($dewey <= 0){
79       $dewey='';
80 }
81 $dewey=~ s/\.$//;
82 $data->{'dewey'}=$dewey;
83
84 my @results;
85
86 my (@items)=itemissues($bi);
87 my $count=@items;
88 $data->{'count'}=$count;
89 my ($order,$ordernum)=getorder($bi,$biblionumber);
90
91
92 my $env;
93 $env->{itemcount}=1;
94
95 $results[0]=$data;
96
97 foreach my $item (@items){
98     $item->{'itemlost'}=~ s/0/No/;
99     $item->{'itemlost'}=~ s/1/Yes/;
100     $item->{'withdrawn'}=~ s/0/No/;
101     $item->{'withdrawn'}=~ s/1/Yes/;
102     $item->{'replacementprice'}+=0.00;
103     my $year=substr($item->{'timestamp0'},0,4);
104     my $mon=substr($item->{'timestamp0'},4,2);
105     my $day=substr($item->{'timestamp0'},6,2);
106     $item->{'timestamp0'}="$day/$mon/$year";
107     $item->{'dateaccessioned'} = slashifyDate($item->{'dateaccessioned'});
108     $item->{'datelastseen'} = slashifyDate($item->{'datelastseen'});
109     $item->{'ordernumber'} = $ordernum;
110     $item->{'booksellerinvoicenumber'} = $order->{'booksellerinvoicenumber'};
111
112     if ($item->{'date_due'} = 'Available'){
113         $item->{'issue'}="<b>Available</b><br>";
114     } else {
115         $item->{'issue'}="<b>Currently on issue to:</b> <a href=/cgi-bin/koha/moremember.pl?bornum=$item->{'borrower0'}>$item->{'card'}</a><br>";
116     }
117           
118 }
119
120 $template->param(includesdir => $includes);
121 $template->param(BIBITEM_DATA => \@results);
122 $template->param(ITEM_DATA => \@items);
123 print "Content-Type: text/html\n\n", $template->output;
124