Lines 24-30
use C4::Koha qw( GetAuthorisedValues );
Link Here
|
24 |
use CGI qw ( -utf8 ); |
24 |
use CGI qw ( -utf8 ); |
25 |
use HTML::Entities; |
25 |
use HTML::Entities; |
26 |
use C4::Biblio qw( GetBiblioData GetFrameworkCode ); |
26 |
use C4::Biblio qw( GetBiblioData GetFrameworkCode ); |
27 |
use C4::Items qw( GetHostItemsInfo GetItemsInfo ); |
|
|
28 |
use C4::Acquisition qw( GetOrderFromItemnumber GetBasket GetInvoice ); |
27 |
use C4::Acquisition qw( GetOrderFromItemnumber GetBasket GetInvoice ); |
29 |
use C4::Output qw( output_and_exit output_html_with_http_headers ); |
28 |
use C4::Output qw( output_and_exit output_html_with_http_headers ); |
30 |
use C4::Auth qw( get_template_and_user ); |
29 |
use C4::Auth qw( get_template_and_user ); |
Lines 102-134
my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
Link Here
|
102 |
# $dewey=~ s/\.$//; |
101 |
# $dewey=~ s/\.$//; |
103 |
# $data->{'dewey'}=$dewey; |
102 |
# $data->{'dewey'}=$dewey; |
104 |
|
103 |
|
105 |
my $fw = GetFrameworkCode($biblionumber); |
|
|
106 |
my @all_items= GetItemsInfo($biblionumber); |
107 |
my @items; |
108 |
my $patron = Koha::Patrons->find( $loggedinuser ); |
109 |
for my $itm (@all_items) { |
110 |
push @items, $itm unless ( $itm->{itemlost} && |
111 |
$patron->category->hidelostitems && |
112 |
!$showallitems && |
113 |
($itemnumber != $itm->{itemnumber})); |
114 |
} |
115 |
|
116 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
104 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
117 |
my $record = $biblio ? $biblio->metadata->record : undef; |
105 |
my $record = $biblio ? $biblio->metadata->record : undef; |
118 |
|
106 |
|
119 |
output_and_exit( $query, $cookie, $template, 'unknown_biblio') |
107 |
output_and_exit( $query, $cookie, $template, 'unknown_biblio') |
120 |
unless $biblio && $record; |
108 |
unless $biblio && $record; |
121 |
|
109 |
|
|
|
110 |
my $fw = GetFrameworkCode($biblionumber); |
111 |
my $all_items = $biblio->items( |
112 |
{}, |
113 |
{ |
114 |
# FIXME A different order is expected if at least one items.serial is true |
115 |
order_by => [ |
116 |
'homebranch.branchname', |
117 |
'me.enumchron', |
118 |
\"LDAP( me.copynumber, 8, '0' )", |
119 |
-asc => 'me.dateacessioned' |
120 |
], |
121 |
join => ['homebranch'] |
122 |
} |
123 |
); |
124 |
my @items; |
125 |
my $patron = Koha::Patrons->find( $loggedinuser ); |
126 |
while ( my $item = $all_items->next ) { |
127 |
push @items, $item |
128 |
unless $item->itemlost |
129 |
&& $patron->category->hidelostitems |
130 |
&& !$showallitems; |
131 |
} |
132 |
|
122 |
my $hostrecords; |
133 |
my $hostrecords; |
123 |
# adding items linked via host biblios |
134 |
my $hostitems = $biblio->host_items; |
124 |
my @hostitems = GetHostItemsInfo($record); |
135 |
if ( $hostitems->count ) { |
125 |
if (@hostitems){ |
136 |
$hostrecords = 1; |
126 |
$hostrecords =1; |
137 |
push @items, $hostitems->as_list; |
127 |
push (@items,@hostitems); |
|
|
128 |
} |
138 |
} |
129 |
|
139 |
|
130 |
my $totalcount=@all_items; |
140 |
my $totalcount = $all_items->count; |
131 |
my $showncount=@items; |
141 |
my $showncount = scalar @items; |
132 |
my $hiddencount = $totalcount - $showncount; |
142 |
my $hiddencount = $totalcount - $showncount; |
133 |
$data->{'count'}=$totalcount; |
143 |
$data->{'count'}=$totalcount; |
134 |
$data->{'showncount'}=$showncount; |
144 |
$data->{'showncount'}=$showncount; |
Lines 147-199
foreach ( keys %{$data} ) {
Link Here
|
147 |
$template->param( "$_" => defined $data->{$_} ? $data->{$_} : '' ); |
157 |
$template->param( "$_" => defined $data->{$_} ? $data->{$_} : '' ); |
148 |
} |
158 |
} |
149 |
|
159 |
|
150 |
($itemnumber) and @items = (grep {$_->{'itemnumber'} == $itemnumber} @items); |
160 |
my @item_data; |
151 |
foreach my $item (@items){ |
161 |
foreach my $item (@items){ |
152 |
$item->{object} = Koha::Items->find( $item->{itemnumber} ); |
162 |
|
153 |
$item->{'collection'} = $ccodes->{ $item->{ccode} } if $ccodes && $item->{ccode} && exists $ccodes->{ $item->{ccode} }; |
163 |
my $item_info = $item->unblessed; |
154 |
$item->{'itype'} = $itemtypes->{ $item->{'itype'} }->{'translated_description'} if exists $itemtypes->{ $item->{'itype'} }; |
164 |
$item_info->{object} = $item; |
155 |
$item->{'replacementprice'} = $item->{'replacementprice'}; |
165 |
$item_info->{itemtype} = $itemtypes->{$item->effective_itemtype}; |
156 |
if ( defined $item->{'copynumber'} ) { |
166 |
$item_info->{'ccode'} = $ccodes->{ $item->ccode } if $ccodes && $item->ccode && exists $ccodes->{ $item->ccode }; |
157 |
$item->{'displaycopy'} = 1; |
167 |
if ( defined $item->copynumber ) { |
158 |
if ( defined $copynumbers->{ $item->{'copynumber'} } ) { |
168 |
$item_info->{'displaycopy'} = 1; |
159 |
$item->{'copyvol'} = $copynumbers->{ $item->{'copynumber'} } |
169 |
if ( defined $copynumbers->{ $item_info->{'copynumber'} } ) { |
|
|
170 |
$item_info->{'copyvol'} = $copynumbers->{ $item_info->{'copynumber'} } |
160 |
} |
171 |
} |
161 |
else { |
172 |
else { |
162 |
$item->{'copyvol'} = $item->{'copynumber'}; |
173 |
$item_info->{'copyvol'} = $item_info->{'copynumber'}; |
163 |
} |
174 |
} |
164 |
} |
175 |
} |
165 |
|
176 |
|
166 |
# item has a host number if its biblio number does not match the current bib |
177 |
# item has a host number if its biblio number does not match the current bib |
167 |
if ($item->{biblionumber} ne $biblionumber){ |
178 |
if ($item->biblionumber ne $biblionumber){ |
168 |
$item->{hostbiblionumber} = $item->{biblionumber}; |
179 |
$item_info->{hostbiblionumber} = $item->{biblionumber}; |
169 |
$item->{hosttitle} = GetBiblioData($item->{biblionumber})->{title}; |
180 |
$item_info->{hosttitle} = $item->biblio->title; |
170 |
} |
181 |
} |
171 |
|
182 |
|
|
|
183 |
# FIXME The acquisition code below could be improved using methods from Koha:: objects |
172 |
my $order = GetOrderFromItemnumber( $item->{'itemnumber'} ); |
184 |
my $order = GetOrderFromItemnumber( $item->{'itemnumber'} ); |
173 |
$item->{'ordernumber'} = $order->{'ordernumber'}; |
185 |
$item_info->{'basketno'} = $order->{'basketno'}; |
174 |
$item->{'basketno'} = $order->{'basketno'}; |
186 |
$item_info->{'orderdate'} = $order->{'entrydate'}; |
175 |
$item->{'orderdate'} = $order->{'entrydate'}; |
187 |
if ($item_info->{'basketno'}){ |
176 |
if ($item->{'basketno'}){ |
188 |
my $basket = GetBasket($item_info->{'basketno'}); |
177 |
my $basket = GetBasket($item->{'basketno'}); |
|
|
178 |
my $bookseller = Koha::Acquisition::Booksellers->find( $basket->{booksellerid} ); |
189 |
my $bookseller = Koha::Acquisition::Booksellers->find( $basket->{booksellerid} ); |
179 |
$item->{'vendor'} = $bookseller->name; |
190 |
$item_info->{'vendor'} = $bookseller->name; |
180 |
} |
191 |
} |
181 |
$item->{'invoiceid'} = $order->{'invoiceid'}; |
192 |
$item_info->{'invoiceid'} = $order->{'invoiceid'}; |
182 |
if($item->{invoiceid}) { |
193 |
if($item_info->{invoiceid}) { |
183 |
my $invoice = GetInvoice($item->{invoiceid}); |
194 |
my $invoice = GetInvoice($item_info->{invoiceid}); |
184 |
$item->{invoicenumber} = $invoice->{invoicenumber} if $invoice; |
195 |
$item_info->{invoicenumber} = $invoice->{invoicenumber} if $invoice; |
185 |
} |
196 |
} |
186 |
$item->{'datereceived'} = $order->{'datereceived'}; |
197 |
$item_info->{'datereceived'} = $order->{'datereceived'}; |
187 |
|
198 |
|
188 |
if ($item->{notforloantext} or $item->{itemlost} or $item->{damaged} or $item->{withdrawn}) { |
199 |
if ( $item->notforloan |
189 |
$item->{status_advisory} = 1; |
200 |
|| $item->itemtype->notforloan |
|
|
201 |
|| $item->itemlost |
202 |
|| $item->damaged |
203 |
|| $item->withdrawn ) |
204 |
{ |
205 |
$item_info->{status_advisory} = 1; |
190 |
} |
206 |
} |
191 |
|
207 |
|
192 |
# Add paidfor info |
208 |
# Add paidfor info |
193 |
if ( $item->{itemlost} ) { |
209 |
if ( $item->itemlost ) { |
194 |
my $accountlines = Koha::Account::Lines->search( |
210 |
my $accountlines = Koha::Account::Lines->search( |
195 |
{ |
211 |
{ |
196 |
itemnumber => $item->{itemnumber}, |
212 |
itemnumber => $item->itemnumber, |
197 |
debit_type_code => 'LOST', |
213 |
debit_type_code => 'LOST', |
198 |
status => [ undef, { '<>' => 'RETURNED' } ], |
214 |
status => [ undef, { '<>' => 'RETURNED' } ], |
199 |
amountoutstanding => 0 |
215 |
amountoutstanding => 0 |
Lines 217-223
foreach my $item (@items){
Link Here
|
217 |
if ($payment_offsets->count) { |
233 |
if ($payment_offsets->count) { |
218 |
my $patron = $accountline->patron; |
234 |
my $patron = $accountline->patron; |
219 |
my $payment_offset = $payment_offsets->next; |
235 |
my $payment_offset = $payment_offsets->next; |
220 |
$item->{paidfor} = { patron => $patron, created_on => $payment_offset->created_on }; |
236 |
$item_info->{paidfor} = { patron => $patron, created_on => $payment_offset->created_on }; |
221 |
} |
237 |
} |
222 |
} |
238 |
} |
223 |
} |
239 |
} |
Lines 225-244
foreach my $item (@items){
Link Here
|
225 |
if (C4::Context->preference("IndependentBranches")) { |
241 |
if (C4::Context->preference("IndependentBranches")) { |
226 |
#verifying rights |
242 |
#verifying rights |
227 |
my $userenv = C4::Context->userenv(); |
243 |
my $userenv = C4::Context->userenv(); |
228 |
unless (C4::Context->IsSuperLibrarian() or ($userenv->{'branch'} eq $item->{'homebranch'})) { |
244 |
unless (C4::Context->IsSuperLibrarian() or ($userenv->{'branch'} eq $item->homebranch)) { |
229 |
$item->{'nomod'}=1; |
245 |
$item_info->{'nomod'}=1; |
230 |
} |
246 |
} |
231 |
} |
247 |
} |
232 |
if ($item->{'datedue'}) { |
248 |
push @item_data, $item_info; |
233 |
$item->{'issue'}= 1; |
|
|
234 |
} else { |
235 |
$item->{'issue'}= 0; |
236 |
} |
237 |
|
238 |
if ( $item->{'borrowernumber'} ) { |
239 |
my $curr_borrower = Koha::Patrons->find( $item->{borrowernumber} ); |
240 |
$item->{patron} = $curr_borrower; |
241 |
} |
242 |
} |
249 |
} |
243 |
|
250 |
|
244 |
my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] }); |
251 |
my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] }); |
Lines 293-299
$template->param(
Link Here
|
293 |
); |
300 |
); |
294 |
|
301 |
|
295 |
$template->param( |
302 |
$template->param( |
296 |
ITEM_DATA => \@items, |
303 |
ITEM_DATA => \@item_data, |
297 |
moredetailview => 1, |
304 |
moredetailview => 1, |
298 |
loggedinuser => $loggedinuser, |
305 |
loggedinuser => $loggedinuser, |
299 |
biblionumber => $biblionumber, |
306 |
biblionumber => $biblionumber, |