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
::Members
; # to use GetMember
34 use C4
::Search
; # enabled_staff_search_views
36 use Koha
::Acquisition
::Booksellers
;
37 use Koha
::AuthorisedValues
;
45 my ($template, $loggedinuser, $cookie) = get_template_and_user
(
47 template_name
=> 'catalogue/moredetail.tt',
51 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'},
65 my $hidepatronname = C4
::Context
->preference("HidePatronName");
69 my $biblionumber=$query->param('biblionumber');
70 $biblionumber = HTML
::Entities
::encode
($biblionumber);
71 my $title=$query->param('title');
72 my $bi=$query->param('bi');
73 $bi = $biblionumber unless $bi;
74 my $itemnumber = $query->param('itemnumber');
75 my $data = &GetBiblioData
($biblionumber);
76 my $dewey = $data->{'dewey'};
77 my $showallitems = $query->param('showallitems');
79 #coping with subscriptions
80 my $subscriptionsnumber = CountSubscriptionFromBiblionumber
($biblionumber);
82 # FIXME Dewey is a string, not a number, & we should use a function
84 # if ($dewey eq "000.") { $dewey = "";};
85 # if ($dewey < 10){$dewey='00'.$dewey;}
86 # if ($dewey < 100 && $dewey > 10){$dewey='0'.$dewey;}
91 # $data->{'dewey'}=$dewey;
93 my $fw = GetFrameworkCode
($biblionumber);
94 my @all_items= GetItemsInfo
($biblionumber);
96 my $patron = Koha
::Patrons
->find( $loggedinuser );
97 for my $itm (@all_items) {
98 push @items, $itm unless ( $itm->{itemlost
} &&
99 $patron->category->hidelostitems &&
101 ($itemnumber != $itm->{itemnumber
}));
104 my $record=GetMarcBiblio
($biblionumber);
107 # adding items linked via host biblios
108 my @hostitems = GetHostItemsInfo
($record);
111 push (@items,@hostitems);
114 my $subtitle = GetRecordValue
('subtitle', $record, $fw);
116 my $totalcount=@all_items;
117 my $showncount=@items;
118 my $hiddencount = $totalcount - $showncount;
119 $data->{'count'}=$totalcount;
120 $data->{'showncount'}=$showncount;
121 $data->{'hiddencount'}=$hiddencount; # can be zero
124 { map { $_->{authorised_value
} => $_->{lib
} } Koha
::AuthorisedValues
->get_descriptions_by_koha_field( { frameworkcode
=> $fw, kohafield
=> 'items.ccode' } ) };
126 { map { $_->{authorised_value
} => $_->{lib
} } Koha
::AuthorisedValues
->get_descriptions_by_koha_field( { frameworkcode
=> $fw, kohafield
=> 'items.copynumber' } ) };
127 my $itemtypes = GetItemTypes
;
129 $data->{'itemtypename'} = $itemtypes->{$data->{'itemtype'}}->{'translated_description'};
130 $data->{'rentalcharge'} = sprintf( "%.2f", $data->{'rentalcharge'} );
131 foreach ( keys %{$data} ) {
132 $template->param( "$_" => defined $data->{$_} ?
$data->{$_} : '' );
135 ($itemnumber) and @items = (grep {$_->{'itemnumber'} == $itemnumber} @items);
136 foreach my $item (@items){
137 $item->{object
} = Koha
::Items
->find( $item->{itemnumber
} );
138 $item->{'collection'} = $ccodes->{ $item->{ccode
} } if ($ccodes);
139 $item->{'itype'} = $itemtypes->{ $item->{'itype'} }->{'translated_description'};
140 $item->{'replacementprice'} = sprintf( "%.2f", $item->{'replacementprice'} );
141 if ( defined $item->{'copynumber'} ) {
142 $item->{'displaycopy'} = 1;
143 if ( defined $copynumbers->{ $item->{'copynumber'} } ) {
144 $item->{'copyvol'} = $copynumbers->{ $item->{'copynumber'} }
147 $item->{'copyvol'} = $item->{'copynumber'};
151 # item has a host number if its biblio number does not match the current bib
152 if ($item->{biblionumber
} ne $biblionumber){
153 $item->{hostbiblionumber
} = $item->{biblionumber
};
154 $item->{hosttitle
} = GetBiblioData
($item->{biblionumber
})->{title
};
157 my $order = GetOrderFromItemnumber
( $item->{'itemnumber'} );
158 $item->{'ordernumber'} = $order->{'ordernumber'};
159 $item->{'basketno'} = $order->{'basketno'};
160 $item->{'orderdate'} = $order->{'entrydate'};
161 if ($item->{'basketno'}){
162 my $basket = GetBasket
($item->{'basketno'});
163 my $bookseller = Koha
::Acquisition
::Booksellers
->find( $basket->{booksellerid
} );
164 $item->{'vendor'} = $bookseller->name;
166 $item->{'invoiceid'} = $order->{'invoiceid'};
167 if($item->{invoiceid
}) {
168 my $invoice = GetInvoice
($item->{invoiceid
});
169 $item->{invoicenumber
} = $invoice->{invoicenumber
} if $invoice;
171 $item->{'datereceived'} = $order->{'datereceived'};
173 if ($item->{notforloantext
} or $item->{itemlost
} or $item->{damaged
} or $item->{withdrawn
}) {
174 $item->{status_advisory
} = 1;
177 if (C4
::Context
->preference("IndependentBranches")) {
179 my $userenv = C4
::Context
->userenv();
180 unless (C4
::Context
->IsSuperLibrarian() or ($userenv->{'branch'} eq $item->{'homebranch'})) {
184 if ($item->{'datedue'}) {
190 unless ($hidepatronname) {
191 if ( $item->{'borrowernumber'} ) {
192 my $curr_borrower = GetMember
('borrowernumber' => $item->{'borrowernumber'} );
193 $item->{borrowerfirstname
} = $curr_borrower->{'firstname'};
194 $item->{borrowersurname
} = $curr_borrower->{'surname'};
200 my $mss = Koha
::MarcSubfieldStructures
->search({ frameworkcode
=> $fw, kohafield
=> 'items.itemlost', authorised_value
=> { not => undef } });
202 $template->param( itemlostloop
=> GetAuthorisedValues
( $mss->next->authorised_value ) );
204 $mss = Koha
::MarcSubfieldStructures
->search({ frameworkcode
=> $fw, kohafield
=> 'items.damaged', authorised_value
=> { not => undef } });
206 $template->param( itemdamagedloop
=> GetAuthorisedValues
( $mss->next->authorised_value ) );
208 $mss = Koha
::MarcSubfieldStructures
->search({ frameworkcode
=> $fw, kohafield
=> 'items.withdrawn', authorised_value
=> { not => undef } });
210 $template->param( itemwithdrawnloop
=> GetAuthorisedValues
( $mss->next->authorised_value) );
213 $template->param(count
=> $data->{'count'},
214 subscriptionsnumber
=> $subscriptionsnumber,
215 subscriptiontitle
=> $data->{title
},
216 C4
::Search
::enabled_staff_search_views
,
220 ITEM_DATA
=> \
@items,
222 loggedinuser
=> $loggedinuser,
223 biblionumber
=> $biblionumber,
224 biblioitemnumber
=> $bi,
225 itemnumber
=> $itemnumber,
226 z3950_search_params
=> C4
::Search
::z3950_search_args
(GetBiblioData
($biblionumber)),
227 subtitle
=> $subtitle,
228 hidepatronname
=> $hidepatronname,
230 $template->param(ONLY_ONE
=> 1) if ( $itemnumber && $showncount != @items );
231 $template->{'VARS'}->{'searchid'} = $query->param('searchid');
233 my @allorders_using_biblio = GetOrdersByBiblionumber
($biblionumber);
234 my @deletedorders_using_biblio;
235 my @orders_using_biblio;
237 my @baskets_deletedorders;
239 foreach my $myorder (@allorders_using_biblio) {
240 my $basket = $myorder->{'basketno'};
241 if ((defined $myorder->{'datecancellationprinted'}) and ($myorder->{'datecancellationprinted'} ne '0000-00-00') ){
242 push @deletedorders_using_biblio, $myorder;
243 unless (grep(/^$basket$/, @baskets_deletedorders)){
244 push @baskets_deletedorders,$myorder->{'basketno'};
248 push @orders_using_biblio, $myorder;
249 unless (grep(/^$basket$/, @baskets_orders)){
250 push @baskets_orders,$myorder->{'basketno'};
255 my $count_orders_using_biblio = scalar @orders_using_biblio ;
256 $template->param (countorders
=> $count_orders_using_biblio);
258 my $count_deletedorders_using_biblio = scalar @deletedorders_using_biblio ;
259 $template->param (countdeletedorders
=> $count_deletedorders_using_biblio);
261 my $biblio = Koha
::Biblios
->find( $biblionumber );
262 my $holds = $biblio->holds;
263 $template->param( holdcount
=> $holds->count );
265 output_html_with_http_headers
$query, $cookie, $template->output;