3 # Copyright 2000-2003 Katipo Communications
4 # parts copyright 2010 BibLibre
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with Koha; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #use warnings; FIXME - Bug 2505
30 use C4
::Bookseller
qw(GetBookSellerFromId);
31 use C4
::Output
; # contains gettemplate
34 use C4
::Circulation
; # to use itemissues
35 use C4
::Members
; # to use GetMember
36 use C4
::Search
; # enabled_staff_search_views
37 use C4
::Members qw
/GetHideLostItemsPreference/;
42 # FIXME subject is not exported to the template?
43 my $subject=$query->param('subject');
45 # if its a subject we need to use the subject.tmpl
46 my ($template, $loggedinuser, $cookie) = get_template_and_user
({
47 template_name
=> ($subject?
'catalogue/subject.tmpl':
48 'catalogue/moredetail.tmpl'),
52 flagsrequired
=> {catalogue
=> 1},
55 if($query->cookie("holdfor")){
56 my $holdfor_patron = GetMember
('borrowernumber' => $query->cookie("holdfor"));
58 holdfor
=> $query->cookie("holdfor"),
59 holdfor_surname
=> $holdfor_patron->{'surname'},
60 holdfor_firstname
=> $holdfor_patron->{'firstname'},
61 holdfor_cardnumber
=> $holdfor_patron->{'cardnumber'},
67 my $biblionumber=$query->param('biblionumber');
68 my $title=$query->param('title');
69 my $bi=$query->param('bi');
70 $bi = $biblionumber unless $bi;
71 my $itemnumber = $query->param('itemnumber');
72 my $data = &GetBiblioData
($biblionumber);
73 my $dewey = $data->{'dewey'};
74 my $showallitems = $query->param('showallitems');
76 #coping with subscriptions
77 my $subscriptionsnumber = CountSubscriptionFromBiblionumber
($biblionumber);
79 # FIXME Dewey is a string, not a number, & we should use a function
81 # if ($dewey eq "000.") { $dewey = "";};
82 # if ($dewey < 10){$dewey='00'.$dewey;}
83 # if ($dewey < 100 && $dewey > 10){$dewey='0'.$dewey;}
88 # $data->{'dewey'}=$dewey;
90 my $fw = GetFrameworkCode
($biblionumber);
91 my @all_items= GetItemsInfo
($biblionumber);
93 for my $itm (@all_items) {
94 push @items, $itm unless ( $itm->{itemlost
} &&
95 GetHideLostItemsPreference
($loggedinuser) &&
97 ($itemnumber != $itm->{itemnumber
}));
100 my $record=GetMarcBiblio
($biblionumber);
103 # adding items linked via host biblios
104 my @hostitems = GetHostItemsInfo
($record);
107 push (@items,@hostitems);
110 my $subtitle = GetRecordValue
('subtitle', $record, $fw);
112 my $totalcount=@all_items;
113 my $showncount=@items;
114 my $hiddencount = $totalcount - $showncount;
115 $data->{'count'}=$totalcount;
116 $data->{'showncount'}=$showncount;
117 $data->{'hiddencount'}=$hiddencount; # can be zero
119 my $ccodes= GetKohaAuthorisedValues
('items.ccode',$fw);
120 my $itemtypes = GetItemTypes
;
122 $data->{'itemtypename'} = $itemtypes->{$data->{'itemtype'}}->{'description'};
123 $data->{'rentalcharge'} = sprintf( "%.2f", $data->{'rentalcharge'} );
124 foreach ( keys %{$data} ) {
125 $template->param( "$_" => defined $data->{$_} ?
$data->{$_} : '' );
128 ($itemnumber) and @items = (grep {$_->{'itemnumber'} == $itemnumber} @items);
129 foreach my $item (@items){
130 $item->{itemlostloop
}= GetAuthorisedValues
(GetAuthValCode
('items.itemlost',$fw),$item->{itemlost
}) if GetAuthValCode
('items.itemlost',$fw);
131 $item->{itemdamagedloop
}= GetAuthorisedValues
(GetAuthValCode
('items.damaged',$fw),$item->{damaged
}) if GetAuthValCode
('items.damaged',$fw);
132 $item->{'collection'} = $ccodes->{ $item->{ccode
} } if ($ccodes);
133 $item->{'itype'} = $itemtypes->{ $item->{'itype'} }->{'description'};
134 $item->{'replacementprice'} = sprintf( "%.2f", $item->{'replacementprice'} );
135 $item->{'copyvol'} = $item->{'copynumber'};
137 # item has a host number if its biblio number does not match the current bib
138 if ($item->{biblionumber
} ne $biblionumber){
139 $item->{hostbiblionumber
} = $item->{biblionumber
};
140 $item->{hosttitle
} = GetBiblioData
($item->{biblionumber
})->{title
};
143 my $order = GetOrderFromItemnumber
( $item->{'itemnumber'} );
144 my $basket = GetBasket
( $order->{'basketno'} );
145 $item->{'booksellerid'} = $basket->{'booksellerid'};
146 $item->{'ordernumber'} = $order->{'ordernumber'};
147 $item->{'basketno'} = $order->{'basketno'};
148 $item->{'booksellerinvoicenumber'} = $order->{'booksellerinvoicenumber'};
149 $item->{'orderdate'} = $order->{'entrydate'};
150 if ($item->{'basketno'}){
151 my $basket = GetBasket
($item->{'basketno'});
152 my $bookseller = GetBookSellerFromId
($basket->{'booksellerid'});
153 $item->{'vendor'} = $bookseller->{'name'};
155 $item->{'datereceived'} = $order->{'datereceived'};
157 if ($item->{notforloantext
} or $item->{itemlost
} or $item->{damaged
} or $item->{wthdrawn
}) {
158 $item->{status_advisory
} = 1;
161 if (C4
::Context
->preference("IndependantBranches")) {
163 my $userenv = C4
::Context
->userenv();
164 unless (($userenv->{'flags'} == 1) or ($userenv->{'branch'} eq $item->{'homebranch'})) {
168 $item->{'homebranchname'} = GetBranchName
($item->{'homebranch'});
169 $item->{'holdingbranchname'} = GetBranchName
($item->{'holdingbranch'});
170 if ($item->{'datedue'}) {
176 $template->param(count
=> $data->{'count'},
177 subscriptionsnumber
=> $subscriptionsnumber,
178 subscriptiontitle
=> $data->{title
},
179 C4
::Search
::enabled_staff_search_views
,
183 ITEM_DATA
=> \
@items,
185 loggedinuser
=> $loggedinuser,
186 biblionumber
=> $biblionumber,
187 biblioitemnumber
=> $bi,
188 itemnumber
=> $itemnumber,
189 z3950_search_params
=> C4
::Search
::z3950_search_args
(GetBiblioData
($biblionumber)),
190 subtitle
=> $subtitle,
192 $template->param(ONLY_ONE
=> 1) if ( $itemnumber && $showncount != @items );
194 output_html_with_http_headers
$query, $cookie, $template->output;