3 # Copyright 2000-2003 Katipo Communications
5 # This file is part of Koha.
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
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.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #use warnings; FIXME - Bug 2505
29 use C4::Output; # contains gettemplate
32 use C4::Dates qw/format_date/;
33 use C4::Circulation; # to use itemissues
34 use C4::Search; # enabled_staff_search_views
38 # FIXME subject is not exported to the template?
39 my $subject=$query->param('subject');
41 # if its a subject we need to use the subject.tmpl
42 my ($template, $loggedinuser, $cookie) = get_template_and_user({
43 template_name => ($subject? 'catalogue/subject.tmpl':
44 'catalogue/moredetail.tmpl'),
48 flagsrequired => {catalogue => 1},
53 my $biblionumber=$query->param('biblionumber');
54 my $title=$query->param('title');
55 my $bi=$query->param('bi');
56 $bi = $biblionumber unless $bi;
57 my $data=GetBiblioData($biblionumber);
58 my $dewey = $data->{'dewey'};
60 #coping with subscriptions
61 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
63 # FIXME Dewey is a string, not a number, & we should use a function
65 # if ($dewey eq "000.") { $dewey = "";};
66 # if ($dewey < 10){$dewey='00'.$dewey;}
67 # if ($dewey < 100 && $dewey > 10){$dewey='0'.$dewey;}
72 # $data->{'dewey'}=$dewey;
75 my $fw = GetFrameworkCode($biblionumber);
76 my @items= GetItemsInfo($biblionumber);
78 $data->{'count'}=$count;
80 my $ccodes= GetKohaAuthorisedValues('items.ccode',$fw);
81 my $itemtypes = GetItemTypes;
83 $data->{'itemtypename'} = $itemtypes->{$data->{'itemtype'}}->{'description'};
86 ($itemnumber) and @items = (grep {$_->{'itemnumber'} == $itemnumber} @items);
87 foreach my $item (@items){
88 $item->{itemlostloop}= GetAuthorisedValues(GetAuthValCode('items.itemlost',$fw),$item->{itemlost}) if GetAuthValCode('items.itemlost',$fw);
89 $item->{itemdamagedloop}= GetAuthorisedValues(GetAuthValCode('items.damaged',$fw),$item->{damaged}) if GetAuthValCode('items.damaged',$fw);
90 $item->{'collection'} = $ccodes->{ $item->{ccode} };
91 $item->{'itype'} = $itemtypes->{ $item->{'itype'} }->{'description'};
92 $item->{'replacementprice'} = sprintf( "%.2f", $item->{'replacementprice'} );
93 $item->{'datelastborrowed'} = format_date( $item->{'datelastborrowed'} );
94 $item->{'dateaccessioned'} = format_date( $item->{'dateaccessioned'} );
95 $item->{'datelastseen'} = format_date( $item->{'datelastseen'} );
96 $item->{'copyvol'} = $item->{'copynumber'};
98 my $order = GetOrderFromItemnumber( $item->{'itemnumber'} );
99 $item->{'ordernumber'} = $order->{'ordernumber'};
100 $item->{'basketno'} = $order->{'basketno'};
101 $item->{'booksellerinvoicenumber'} = $order->{'booksellerinvoicenumber'};
103 if ($item->{notforloantext} or $item->{itemlost} or $item->{damaged} or $item->{wthdrawn}) {
104 $item->{status_advisory} = 1;
107 if (C4::Context->preference("IndependantBranches")) {
109 my $userenv = C4::Context->userenv();
110 unless (($userenv->{'flags'} == 1) or ($userenv->{'branch'} eq $item->{'homebranch'})) {
114 $item->{'homebranchname'} = GetBranchName($item->{'homebranch'});
115 $item->{'holdingbranchname'} = GetBranchName($item->{'holdingbranch'});
116 if ($item->{'datedue'}) {
117 $item->{'datedue'} = format_date($item->{'datedue'});
123 $template->param(count => $data->{'count'},
124 subscriptionsnumber => $subscriptionsnumber,
125 subscriptiontitle => $data->{title},
126 C4::Search::enabled_staff_search_views,
128 $template->param(BIBITEM_DATA => \@results);
129 $template->param(ITEM_DATA => \@items);
130 $template->param(moredetailview => 1);
131 $template->param(loggedinuser => $loggedinuser);
132 $template->param(biblionumber => $biblionumber);
133 $template->param(biblioitemnumber => $bi);
134 $template->param(itemnumber => $itemnumber);
135 $template->param(ONLY_ONE => 1) if ( $itemnumber && $count != @items );
136 $template->param(z3950_search_params => C4::Search::z3950_search_args(GetBiblioData($biblionumber)));
138 output_html_with_http_headers $query, $cookie, $template->output;