fixes to moredetail.pl to allow status editing using updateitem.pl
[koha.git] / catalogue / moredetail.pl
1 #!/usr/bin/perl
2
3 # Copyright 2000-2003 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
21 use strict;
22 require Exporter;
23 use C4::Koha;
24 use CGI;
25 use C4::Biblio;             # to use &GetBiblioItemData &GetItemsByBiblioitemnumber
26 use C4::Acquisition;
27 use C4::Output;             # contains gettemplate
28 use C4::Auth;
29 use C4::Date;
30 use C4::Circulation;  # to use itemissues
31
32 my $query=new CGI;
33
34 # FIXME  subject is not exported to the template?
35 my $subject=$query->param('subject');
36
37 # if its a subject we need to use the subject.tmpl
38 my ($template, $loggedinuser, $cookie) = get_template_and_user({
39     template_name   => ($subject? 'catalogue/subject.tmpl':
40                       'catalogue/moredetail.tmpl'),
41     query           => $query,
42     type            => "intranet",
43     authnotrequired => 0,
44     flagsrequired   => {catalogue => 1},
45     });
46
47 # get variables
48
49 my $biblionumber=$query->param('biblionumber');
50 my $title=$query->param('title');
51 my $bi=$query->param('bi');
52 $bi = $biblionumber unless $bi;
53 my $data=GetBiblioItemData($bi);
54 my $dewey = $data->{'dewey'};
55
56 # FIXME Dewey is a string, not a number, & we should use a function
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= GetItemsByBiblioitemnumber($bi);
70 my $count=@$items;
71 $data->{'count'}=$count;
72
73 my $ordernum = GetOrderNumber($biblionumber,$bi);
74 my $order = GetOrder($ordernum);
75
76 $results[0]=$data;
77
78 foreach my $item (@$items){
79         $item->{itemlostloop}= GetAuthorisedValues('LOST',$item->{itemlost});
80         $item->{itemdamagedloop}= GetAuthorisedValues('DAMAGED',$item->{damaged});
81     $item->{'replacementprice'}=sprintf("%.2f", $item->{'replacementprice'});
82     $item->{'datelastborrowed'}= format_date($item->{'datelastborrowed'});
83     $item->{'dateaccessioned'} = format_date($item->{'dateaccessioned'});
84     $item->{'datelastseen'} = format_date($item->{'datelastseen'});
85     $item->{'ordernumber'} = $ordernum;
86     $item->{'booksellerinvoicenumber'} = $order->{'booksellerinvoicenumber'};
87
88     if ($item->{'date_due'} eq ''){
89         $item->{'issue'}= 0;
90     } else {
91         $item->{'date_due'} = format_date($item->{'date_due'});
92         $item->{'issue'}= 1;
93     }
94 }
95
96 $template->param(BIBITEM_DATA => \@results);
97 $template->param(ITEM_DATA => $items);
98 $template->param(loggedinuser => $loggedinuser);
99 $template->param(biblionumber => $biblionumber);
100
101 output_html_with_http_headers $query, $cookie, $template->output;
102