script to edit the item subcategory table.
[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::Acquisition;
30 use C4::Output; # contains gettemplate
31 use C4::Auth;
32 use C4::Interface::CGI::Output;
33 use C4::Date;
34
35 my $query=new CGI;
36
37 # FIXME  subject is not exported to the template?
38 my $subject=$query->param('subject');
39
40 # if its a subject we need to use the subject.tmpl
41 my ($template, $loggedinuser, $cookie) = get_template_and_user({
42         template_name   => ($subject? 'catalogue/subject.tmpl':
43                                       'catalogue/moredetail.tmpl'),
44         query           => $query,
45         type            => "intranet",
46         authnotrequired => 0,
47         flagsrequired   => {catalogue => 1},
48     });
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 # FIXME Dewey is a string, not a number, & we should use a function
59 $dewey =~ s/0+$//;
60 if ($dewey eq "000.") { $dewey = "";};
61 if ($dewey < 10){$dewey='00'.$dewey;}
62 if ($dewey < 100 && $dewey > 10){$dewey='0'.$dewey;}
63 if ($dewey <= 0){
64       $dewey='';
65 }
66 $dewey=~ s/\.$//;
67 $data->{'dewey'}=$dewey;
68
69 my @results;
70
71 my (@items)=itemissues($bi);
72 my $count=@items;
73 $data->{'count'}=$count;
74 my ($order,$ordernum)=getorder($bi,$biblionumber);
75
76 my $env;
77 $env->{itemcount}=1;
78
79 $results[0]=$data;
80
81 foreach my $item (@items){
82     $item->{'replacementprice'}=sprintf("%.2f", $item->{'replacementprice'});
83     $item->{'datelastborrowed'}= format_date($item->{'datelastborrowed'});
84     $item->{'dateaccessioned'} = format_date($item->{'dateaccessioned'});
85     $item->{'datelastseen'} = format_date($item->{'datelastseen'});
86     $item->{'ordernumber'} = $ordernum;
87     $item->{'booksellerinvoicenumber'} = $order->{'booksellerinvoicenumber'};
88
89     if ($item->{'date_due'} eq 'Available'){
90                 $item->{'issue'}= 0;
91     } else {
92                 $item->{'date_due'} = format_date($item->{'date_due'});
93                 $item->{'issue'}= 1;
94                 $item->{'borrowernumber'} = $item->{'borrower'};
95                 $item->{'cardnumber'} = $item->{'card'};
96     }
97 }
98
99 $template->param(BIBITEM_DATA => \@results);
100 $template->param(ITEM_DATA => \@items);
101 $template->param(loggedinuser => $loggedinuser);
102
103 output_html_with_http_headers $query, $cookie, $template->output;
104
105
106 # Local Variables:
107 # tab-width: 8
108 # End: