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
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 my ($template, $loggedinuser, $cookie) = get_template_and_user
(
46 template_name
=> 'catalogue/moredetail.tt',
50 flagsrequired
=> { catalogue
=> 1 },
54 if($query->cookie("holdfor")){
55 my $holdfor_patron = GetMember
('borrowernumber' => $query->cookie("holdfor"));
57 holdfor
=> $query->cookie("holdfor"),
58 holdfor_surname
=> $holdfor_patron->{'surname'},
59 holdfor_firstname
=> $holdfor_patron->{'firstname'},
60 holdfor_cardnumber
=> $holdfor_patron->{'cardnumber'},
64 my $hidepatronname = C4
::Context
->preference("HidePatronName");
68 my $biblionumber=$query->param('biblionumber');
69 $biblionumber = HTML
::Entities
::encode
($biblionumber);
70 my $title=$query->param('title');
71 my $bi=$query->param('bi');
72 $bi = $biblionumber unless $bi;
73 my $itemnumber = $query->param('itemnumber');
74 my $data = &GetBiblioData
($biblionumber);
75 my $dewey = $data->{'dewey'};
76 my $showallitems = $query->param('showallitems');
78 #coping with subscriptions
79 my $subscriptionsnumber = CountSubscriptionFromBiblionumber
($biblionumber);
81 # FIXME Dewey is a string, not a number, & we should use a function
83 # if ($dewey eq "000.") { $dewey = "";};
84 # if ($dewey < 10){$dewey='00'.$dewey;}
85 # if ($dewey < 100 && $dewey > 10){$dewey='0'.$dewey;}
90 # $data->{'dewey'}=$dewey;
92 my $fw = GetFrameworkCode
($biblionumber);
93 my @all_items= GetItemsInfo
($biblionumber);
95 for my $itm (@all_items) {
96 push @items, $itm unless ( $itm->{itemlost
} &&
97 GetHideLostItemsPreference
($loggedinuser) &&
99 ($itemnumber != $itm->{itemnumber
}));
102 my $record=GetMarcBiblio
($biblionumber);
105 # adding items linked via host biblios
106 my @hostitems = GetHostItemsInfo
($record);
109 push (@items,@hostitems);
112 my $subtitle = GetRecordValue
('subtitle', $record, $fw);
114 my $totalcount=@all_items;
115 my $showncount=@items;
116 my $hiddencount = $totalcount - $showncount;
117 $data->{'count'}=$totalcount;
118 $data->{'showncount'}=$showncount;
119 $data->{'hiddencount'}=$hiddencount; # can be zero
121 my $ccodes= GetKohaAuthorisedValues
('items.ccode',$fw);
122 my $copynumbers = GetKohaAuthorisedValues
('items.copynumber',$fw);
123 my $itemtypes = GetItemTypes
;
125 $data->{'itemtypename'} = $itemtypes->{$data->{'itemtype'}}->{'translated_description'};
126 $data->{'rentalcharge'} = sprintf( "%.2f", $data->{'rentalcharge'} );
127 foreach ( keys %{$data} ) {
128 $template->param( "$_" => defined $data->{$_} ?
$data->{$_} : '' );
131 ($itemnumber) and @items = (grep {$_->{'itemnumber'} == $itemnumber} @items);
132 foreach my $item (@items){
133 $item->{itemlostloop
}= GetAuthorisedValues
(GetAuthValCode
('items.itemlost',$fw),$item->{itemlost
}) if GetAuthValCode
('items.itemlost',$fw);
134 $item->{itemdamagedloop
}= GetAuthorisedValues
(GetAuthValCode
('items.damaged',$fw),$item->{damaged
}) if GetAuthValCode
('items.damaged',$fw);
135 $item->{'collection'} = $ccodes->{ $item->{ccode
} } if ($ccodes);
136 $item->{'itype'} = $itemtypes->{ $item->{'itype'} }->{'translated_description'};
137 $item->{'replacementprice'} = sprintf( "%.2f", $item->{'replacementprice'} );
138 if ( defined $item->{'copynumber'} ) {
139 $item->{'displaycopy'} = 1;
140 if ( defined $copynumbers->{ $item->{'copynumber'} } ) {
141 $item->{'copyvol'} = $copynumbers->{ $item->{'copynumber'} }
144 $item->{'copyvol'} = $item->{'copynumber'};
148 # item has a host number if its biblio number does not match the current bib
149 if ($item->{biblionumber
} ne $biblionumber){
150 $item->{hostbiblionumber
} = $item->{biblionumber
};
151 $item->{hosttitle
} = GetBiblioData
($item->{biblionumber
})->{title
};
154 my $order = GetOrderFromItemnumber
( $item->{'itemnumber'} );
155 $item->{'ordernumber'} = $order->{'ordernumber'};
156 $item->{'basketno'} = $order->{'basketno'};
157 $item->{'orderdate'} = $order->{'entrydate'};
158 if ($item->{'basketno'}){
159 my $basket = GetBasket
($item->{'basketno'});
160 my $bookseller = Koha
::Acquisition
::Bookseller
->fetch({ id
=> $basket->{booksellerid
} });
161 $item->{'vendor'} = $bookseller->{'name'};
163 $item->{'invoiceid'} = $order->{'invoiceid'};
164 if($item->{invoiceid
}) {
165 my $invoice = GetInvoice
($item->{invoiceid
});
166 $item->{invoicenumber
} = $invoice->{invoicenumber
} if $invoice;
168 $item->{'datereceived'} = $order->{'datereceived'};
170 if ($item->{notforloantext
} or $item->{itemlost
} or $item->{damaged
} or $item->{withdrawn
}) {
171 $item->{status_advisory
} = 1;
174 if (C4
::Context
->preference("IndependentBranches")) {
176 my $userenv = C4
::Context
->userenv();
177 unless (C4
::Context
->IsSuperLibrarian() or ($userenv->{'branch'} eq $item->{'homebranch'})) {
181 $item->{'homebranchname'} = GetBranchName
($item->{'homebranch'});
182 $item->{'holdingbranchname'} = GetBranchName
($item->{'holdingbranch'});
183 if ($item->{'datedue'}) {
189 unless ($hidepatronname) {
190 if ( $item->{'borrowernumber'} ) {
191 my $curr_borrower = GetMember
('borrowernumber' => $item->{'borrowernumber'} );
192 $item->{borrowerfirstname
} = $curr_borrower->{'firstname'};
193 $item->{borrowersurname
} = $curr_borrower->{'surname'};
198 $template->param(count
=> $data->{'count'},
199 subscriptionsnumber
=> $subscriptionsnumber,
200 subscriptiontitle
=> $data->{title
},
201 C4
::Search
::enabled_staff_search_views
,
205 ITEM_DATA
=> \
@items,
207 loggedinuser
=> $loggedinuser,
208 biblionumber
=> $biblionumber,
209 biblioitemnumber
=> $bi,
210 itemnumber
=> $itemnumber,
211 z3950_search_params
=> C4
::Search
::z3950_search_args
(GetBiblioData
($biblionumber)),
212 subtitle
=> $subtitle,
213 hidepatronname
=> $hidepatronname,
215 $template->param(ONLY_ONE
=> 1) if ( $itemnumber && $showncount != @items );
216 $template->{'VARS'}->{'searchid'} = $query->param('searchid');
218 my @allorders_using_biblio = GetOrdersByBiblionumber
($biblionumber);
219 my @deletedorders_using_biblio;
220 my @orders_using_biblio;
222 my @baskets_deletedorders;
224 foreach my $myorder (@allorders_using_biblio) {
225 my $basket = $myorder->{'basketno'};
226 if ((defined $myorder->{'datecancellationprinted'}) and ($myorder->{'datecancellationprinted'} ne '0000-00-00') ){
227 push @deletedorders_using_biblio, $myorder;
228 unless (grep(/^$basket$/, @baskets_deletedorders)){
229 push @baskets_deletedorders,$myorder->{'basketno'};
233 push @orders_using_biblio, $myorder;
234 unless (grep(/^$basket$/, @baskets_orders)){
235 push @baskets_orders,$myorder->{'basketno'};
240 my $count_orders_using_biblio = scalar @orders_using_biblio ;
241 $template->param (countorders
=> $count_orders_using_biblio);
243 my $count_deletedorders_using_biblio = scalar @deletedorders_using_biblio ;
244 $template->param (countdeletedorders
=> $count_deletedorders_using_biblio);
246 my $holds = GetReservesFromBiblionumber
({ biblionumber
=> $biblionumber, all_dates
=> 1 });
247 my $holdcount = scalar( @
$holds );
248 $template->param( holdcount
=> scalar ( @
$holds ) );
250 output_html_with_http_headers
$query, $cookie, $template->output;