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
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # Koha is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with Koha; if not, see <http://www.gnu.org/licenses>.
23 #use warnings; FIXME - Bug 2505
33 use C4
::Circulation
; # to use itemissues
34 use C4
::Members
; # to use GetMember
35 use C4
::Search
; # enabled_staff_search_views
36 use C4
::Members qw
/GetHideLostItemsPreference/;
37 use C4
::Reserves
qw(GetReservesFromBiblionumber);
39 use Koha
::Acquisition
::Bookseller
;
44 # FIXME subject is not exported to the template?
45 my $subject=$query->param('subject');
47 # if its a subject we need to use the subject.tt
48 my ($template, $loggedinuser, $cookie) = get_template_and_user
(
50 template_name
=> ( $subject
51 ?
'catalogue/subject.tt'
52 : 'catalogue/moredetail.tt'),
56 flagsrequired
=> { catalogue
=> 1 },
60 if($query->cookie("holdfor")){
61 my $holdfor_patron = GetMember
('borrowernumber' => $query->cookie("holdfor"));
63 holdfor
=> $query->cookie("holdfor"),
64 holdfor_surname
=> $holdfor_patron->{'surname'},
65 holdfor_firstname
=> $holdfor_patron->{'firstname'},
66 holdfor_cardnumber
=> $holdfor_patron->{'cardnumber'},
70 my $hidepatronname = C4
::Context
->preference("HidePatronName");
74 my $biblionumber=$query->param('biblionumber');
75 my $title=$query->param('title');
76 my $bi=$query->param('bi');
77 $bi = $biblionumber unless $bi;
78 my $itemnumber = $query->param('itemnumber');
79 my $data = &GetBiblioData
($biblionumber);
80 my $dewey = $data->{'dewey'};
81 my $showallitems = $query->param('showallitems');
83 #coping with subscriptions
84 my $subscriptionsnumber = CountSubscriptionFromBiblionumber
($biblionumber);
86 # FIXME Dewey is a string, not a number, & we should use a function
88 # if ($dewey eq "000.") { $dewey = "";};
89 # if ($dewey < 10){$dewey='00'.$dewey;}
90 # if ($dewey < 100 && $dewey > 10){$dewey='0'.$dewey;}
95 # $data->{'dewey'}=$dewey;
97 my $fw = GetFrameworkCode
($biblionumber);
98 my @all_items= GetItemsInfo
($biblionumber);
100 for my $itm (@all_items) {
101 push @items, $itm unless ( $itm->{itemlost
} &&
102 GetHideLostItemsPreference
($loggedinuser) &&
104 ($itemnumber != $itm->{itemnumber
}));
107 my $record=GetMarcBiblio
($biblionumber);
110 # adding items linked via host biblios
111 my @hostitems = GetHostItemsInfo
($record);
114 push (@items,@hostitems);
117 my $subtitle = GetRecordValue
('subtitle', $record, $fw);
119 my $totalcount=@all_items;
120 my $showncount=@items;
121 my $hiddencount = $totalcount - $showncount;
122 $data->{'count'}=$totalcount;
123 $data->{'showncount'}=$showncount;
124 $data->{'hiddencount'}=$hiddencount; # can be zero
126 my $ccodes= GetKohaAuthorisedValues
('items.ccode',$fw);
127 my $copynumbers = GetKohaAuthorisedValues
('items.copynumber',$fw);
128 my $itemtypes = GetItemTypes
;
130 $data->{'itemtypename'} = $itemtypes->{$data->{'itemtype'}}->{'description'};
131 $data->{'rentalcharge'} = sprintf( "%.2f", $data->{'rentalcharge'} );
132 foreach ( keys %{$data} ) {
133 $template->param( "$_" => defined $data->{$_} ?
$data->{$_} : '' );
136 ($itemnumber) and @items = (grep {$_->{'itemnumber'} == $itemnumber} @items);
137 foreach my $item (@items){
138 $item->{itemlostloop
}= GetAuthorisedValues
(GetAuthValCode
('items.itemlost',$fw),$item->{itemlost
}) if GetAuthValCode
('items.itemlost',$fw);
139 $item->{itemdamagedloop
}= GetAuthorisedValues
(GetAuthValCode
('items.damaged',$fw),$item->{damaged
}) if GetAuthValCode
('items.damaged',$fw);
140 $item->{'collection'} = $ccodes->{ $item->{ccode
} } if ($ccodes);
141 $item->{'itype'} = $itemtypes->{ $item->{'itype'} }->{'description'};
142 $item->{'replacementprice'} = sprintf( "%.2f", $item->{'replacementprice'} );
143 if ( defined $item->{'copynumber'} ) {
144 $item->{'displaycopy'} = 1;
145 if ( defined $copynumbers->{ $item->{'copynumber'} } ) {
146 $item->{'copyvol'} = $copynumbers->{ $item->{'copynumber'} }
149 $item->{'copyvol'} = $item->{'copynumber'};
153 # item has a host number if its biblio number does not match the current bib
154 if ($item->{biblionumber
} ne $biblionumber){
155 $item->{hostbiblionumber
} = $item->{biblionumber
};
156 $item->{hosttitle
} = GetBiblioData
($item->{biblionumber
})->{title
};
159 my $order = GetOrderFromItemnumber
( $item->{'itemnumber'} );
160 $item->{'ordernumber'} = $order->{'ordernumber'};
161 $item->{'basketno'} = $order->{'basketno'};
162 $item->{'orderdate'} = $order->{'entrydate'};
163 if ($item->{'basketno'}){
164 my $basket = GetBasket
($item->{'basketno'});
165 my $bookseller = Koha
::Acquisition
::Bookseller
->fetch({ id
=> $basket->{booksellerid
} });
166 $item->{'vendor'} = $bookseller->{'name'};
168 $item->{'invoiceid'} = $order->{'invoiceid'};
169 if($item->{invoiceid
}) {
170 my $invoice = GetInvoice
($item->{invoiceid
});
171 $item->{invoicenumber
} = $invoice->{invoicenumber
} if $invoice;
173 $item->{'datereceived'} = $order->{'datereceived'};
175 if ($item->{notforloantext
} or $item->{itemlost
} or $item->{damaged
} or $item->{withdrawn
}) {
176 $item->{status_advisory
} = 1;
179 if (C4
::Context
->preference("IndependentBranches")) {
181 my $userenv = C4
::Context
->userenv();
182 unless (C4
::Context
->IsSuperLibrarian() or ($userenv->{'branch'} eq $item->{'homebranch'})) {
186 $item->{'homebranchname'} = GetBranchName
($item->{'homebranch'});
187 $item->{'holdingbranchname'} = GetBranchName
($item->{'holdingbranch'});
188 if ($item->{'datedue'}) {
194 unless ($hidepatronname) {
195 if ( $item->{'borrowernumber'} ) {
196 my $curr_borrower = GetMember
('borrowernumber' => $item->{'borrowernumber'} );
197 $item->{borrowerfirstname
} = $curr_borrower->{'firstname'};
198 $item->{borrowersurname
} = $curr_borrower->{'surname'};
203 $template->param(count
=> $data->{'count'},
204 subscriptionsnumber
=> $subscriptionsnumber,
205 subscriptiontitle
=> $data->{title
},
206 C4
::Search
::enabled_staff_search_views
,
210 ITEM_DATA
=> \
@items,
212 loggedinuser
=> $loggedinuser,
213 biblionumber
=> $biblionumber,
214 biblioitemnumber
=> $bi,
215 itemnumber
=> $itemnumber,
216 z3950_search_params
=> C4
::Search
::z3950_search_args
(GetBiblioData
($biblionumber)),
217 subtitle
=> $subtitle,
218 hidepatronname
=> $hidepatronname,
220 $template->param(ONLY_ONE
=> 1) if ( $itemnumber && $showncount != @items );
221 $template->{'VARS'}->{'searchid'} = $query->param('searchid');
223 my @allorders_using_biblio = GetOrdersByBiblionumber
($biblionumber);
224 my @deletedorders_using_biblio;
225 my @orders_using_biblio;
227 my @baskets_deletedorders;
229 foreach my $myorder (@allorders_using_biblio) {
230 my $basket = $myorder->{'basketno'};
231 if ((defined $myorder->{'datecancellationprinted'}) and ($myorder->{'datecancellationprinted'} ne '0000-00-00') ){
232 push @deletedorders_using_biblio, $myorder;
233 unless (grep(/^$basket$/, @baskets_deletedorders)){
234 push @baskets_deletedorders,$myorder->{'basketno'};
238 push @orders_using_biblio, $myorder;
239 unless (grep(/^$basket$/, @baskets_orders)){
240 push @baskets_orders,$myorder->{'basketno'};
245 my $count_orders_using_biblio = scalar @orders_using_biblio ;
246 $template->param (countorders
=> $count_orders_using_biblio);
248 my $count_deletedorders_using_biblio = scalar @deletedorders_using_biblio ;
249 $template->param (countdeletedorders
=> $count_deletedorders_using_biblio);
251 my $holds = GetReservesFromBiblionumber
({ biblionumber
=> $biblionumber, all_dates
=> 1 });
252 my $holdcount = scalar( @
$holds );
253 $template->param( holdcount
=> scalar ( @
$holds ) );
255 output_html_with_http_headers
$query, $cookie, $template->output;