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);
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/;
38 use C4
::Reserves
qw(GetReservesFromBiblionumber);
43 # FIXME subject is not exported to the template?
44 my $subject=$query->param('subject');
46 # if its a subject we need to use the subject.tmpl
47 my ($template, $loggedinuser, $cookie) = get_template_and_user
({
48 template_name
=> ($subject?
'catalogue/subject.tmpl':
49 'catalogue/moredetail.tmpl'),
53 flagsrequired
=> {catalogue
=> 1},
56 if($query->cookie("holdfor")){
57 my $holdfor_patron = GetMember
('borrowernumber' => $query->cookie("holdfor"));
59 holdfor
=> $query->cookie("holdfor"),
60 holdfor_surname
=> $holdfor_patron->{'surname'},
61 holdfor_firstname
=> $holdfor_patron->{'firstname'},
62 holdfor_cardnumber
=> $holdfor_patron->{'cardnumber'},
66 my $hidepatronname = C4
::Context
->preference("HidePatronName");
70 my $biblionumber=$query->param('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 for my $itm (@all_items) {
97 push @items, $itm unless ( $itm->{itemlost
} &&
98 GetHideLostItemsPreference
($loggedinuser) &&
100 ($itemnumber != $itm->{itemnumber
}));
103 my $record=GetMarcBiblio
($biblionumber);
106 # adding items linked via host biblios
107 my @hostitems = GetHostItemsInfo
($record);
110 push (@items,@hostitems);
113 my $subtitle = GetRecordValue
('subtitle', $record, $fw);
115 my $totalcount=@all_items;
116 my $showncount=@items;
117 my $hiddencount = $totalcount - $showncount;
118 $data->{'count'}=$totalcount;
119 $data->{'showncount'}=$showncount;
120 $data->{'hiddencount'}=$hiddencount; # can be zero
122 my $ccodes= GetKohaAuthorisedValues
('items.ccode',$fw);
123 my $copynumbers = GetKohaAuthorisedValues
('items.copynumber',$fw);
124 my $itemtypes = GetItemTypes
;
126 $data->{'itemtypename'} = $itemtypes->{$data->{'itemtype'}}->{'description'};
127 $data->{'rentalcharge'} = sprintf( "%.2f", $data->{'rentalcharge'} );
128 foreach ( keys %{$data} ) {
129 $template->param( "$_" => defined $data->{$_} ?
$data->{$_} : '' );
132 ($itemnumber) and @items = (grep {$_->{'itemnumber'} == $itemnumber} @items);
133 foreach my $item (@items){
134 $item->{itemlostloop
}= GetAuthorisedValues
(GetAuthValCode
('items.itemlost',$fw),$item->{itemlost
}) if GetAuthValCode
('items.itemlost',$fw);
135 $item->{itemdamagedloop
}= GetAuthorisedValues
(GetAuthValCode
('items.damaged',$fw),$item->{damaged
}) if GetAuthValCode
('items.damaged',$fw);
136 $item->{'collection'} = $ccodes->{ $item->{ccode
} } if ($ccodes);
137 $item->{'itype'} = $itemtypes->{ $item->{'itype'} }->{'description'};
138 $item->{'replacementprice'} = sprintf( "%.2f", $item->{'replacementprice'} );
139 if ( defined $item->{'copynumber'} ) {
140 $item->{'displaycopy'} = 1;
141 if ( defined $copynumbers->{ $item->{'copynumber'} } ) {
142 $item->{'copyvol'} = $copynumbers->{ $item->{'copynumber'} }
145 $item->{'copyvol'} = $item->{'copynumber'};
149 # item has a host number if its biblio number does not match the current bib
150 if ($item->{biblionumber
} ne $biblionumber){
151 $item->{hostbiblionumber
} = $item->{biblionumber
};
152 $item->{hosttitle
} = GetBiblioData
($item->{biblionumber
})->{title
};
155 my $order = GetOrderFromItemnumber
( $item->{'itemnumber'} );
156 $item->{'ordernumber'} = $order->{'ordernumber'};
157 $item->{'basketno'} = $order->{'basketno'};
158 $item->{'orderdate'} = $order->{'entrydate'};
159 if ($item->{'basketno'}){
160 my $basket = GetBasket
($item->{'basketno'});
161 my $bookseller = GetBookSellerFromId
($basket->{'booksellerid'});
162 $item->{'vendor'} = $bookseller->{'name'};
164 $item->{'invoiceid'} = $order->{'invoiceid'};
165 if($item->{invoiceid
}) {
166 my $invoice = GetInvoice
($item->{invoiceid
});
167 $item->{invoicenumber
} = $invoice->{invoicenumber
} if $invoice;
169 $item->{'datereceived'} = $order->{'datereceived'};
171 if ($item->{notforloantext
} or $item->{itemlost
} or $item->{damaged
} or $item->{withdrawn
}) {
172 $item->{status_advisory
} = 1;
175 if (C4
::Context
->preference("IndependentBranches")) {
177 my $userenv = C4
::Context
->userenv();
178 unless (C4
::Context
->IsSuperLibrarian() or ($userenv->{'branch'} eq $item->{'homebranch'})) {
182 $item->{'homebranchname'} = GetBranchName
($item->{'homebranch'});
183 $item->{'holdingbranchname'} = GetBranchName
($item->{'holdingbranch'});
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'};
199 $template->param(count
=> $data->{'count'},
200 subscriptionsnumber
=> $subscriptionsnumber,
201 subscriptiontitle
=> $data->{title
},
202 C4
::Search
::enabled_staff_search_views
,
206 ITEM_DATA
=> \
@items,
208 loggedinuser
=> $loggedinuser,
209 biblionumber
=> $biblionumber,
210 biblioitemnumber
=> $bi,
211 itemnumber
=> $itemnumber,
212 z3950_search_params
=> C4
::Search
::z3950_search_args
(GetBiblioData
($biblionumber)),
213 subtitle
=> $subtitle,
214 hidepatronname
=> $hidepatronname,
216 $template->param(ONLY_ONE
=> 1) if ( $itemnumber && $showncount != @items );
217 $template->{'VARS'}->{'searchid'} = $query->param('searchid');
220 my ( $holdcount, $holds ) = GetReservesFromBiblionumber
($biblionumber,1);
221 $template->param( holdcount
=> $holdcount, holds
=> $holds );
223 output_html_with_http_headers
$query, $cookie, $template->output;