introducint marcflavour in systempref file : used for character decoding
[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 use C4::Auth;
31   
32 my $query=new CGI;
33
34 my $includes = C4::Context->config('includes') ||
35         "/usr/local/www/hdl/htdocs/includes";
36 my $startfrom=$query->param('startfrom') || 0;
37
38 my $subject=$query->param('subject');
39 # if its a subject we need to use the subject.tmpl
40 my $template;
41 if ($subject){
42         $template = gettemplate("catalogue/subject.tmpl");
43 } else {
44         $template = gettemplate("catalogue/moredetail.tmpl");
45 }
46 my $flagsrequired;
47 $flagsrequired->{catalogue}=1;
48 my ($loggedinuser, $cookie, $sessionID) = checkauth($query, 0, $flagsrequired);
49
50 # get variables 
51
52 my $biblionumber=$query->param('bib');
53 my $title=$query->param('title');
54 my $bi=$query->param('bi');
55
56 my $data=bibitemdata($bi);
57 my $dewey = $data->{'dewey'};
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     if ($item->{'date_due'} eq 'Available'){
96         $item->{'issue'}="<b>Available</b><br>";
97     } else {
98         $item->{'issue'}="<b>Currently on issue to:</b> <a href=/cgi-bin/koha/moremember.pl?bornum=$item->{'borrower0'}>$item->{'card'}</a><br>";
99     }
100 }
101
102 $template->param(includesdir => $includes);
103 $template->param(BIBITEM_DATA => \@results);
104 $template->param(ITEM_DATA => \@items);
105 $template->param(loggedinuser => $loggedinuser);
106 print "Content-Type: text/html\n\n", $template->output;
107