Lines 33-39
use C4::Koha qw(
Link Here
|
33 |
use C4::Serials qw( CountSubscriptionFromBiblionumber SearchSubscriptions GetLatestSerials ); |
33 |
use C4::Serials qw( CountSubscriptionFromBiblionumber SearchSubscriptions GetLatestSerials ); |
34 |
use C4::Output qw( output_html_with_http_headers ); |
34 |
use C4::Output qw( output_html_with_http_headers ); |
35 |
use C4::Biblio qw( GetBiblioData GetFrameworkCode ); |
35 |
use C4::Biblio qw( GetBiblioData GetFrameworkCode ); |
36 |
use C4::Items qw( GetAnalyticsCount GetHostItemsInfo GetItemsInfo ); |
36 |
use C4::Items qw( GetAnalyticsCount ); |
37 |
use C4::Circulation qw( GetTransfers ); |
37 |
use C4::Circulation qw( GetTransfers ); |
38 |
use C4::Reserves; |
38 |
use C4::Reserves; |
39 |
use C4::Serials qw( CountSubscriptionFromBiblionumber SearchSubscriptions GetLatestSerials ); |
39 |
use C4::Serials qw( CountSubscriptionFromBiblionumber SearchSubscriptions GetLatestSerials ); |
Lines 57-62
use Koha::Plugins;
Link Here
|
57 |
use Koha::Recalls; |
57 |
use Koha::Recalls; |
58 |
use Koha::SearchEngine::Search; |
58 |
use Koha::SearchEngine::Search; |
59 |
use Koha::SearchEngine::QueryBuilder; |
59 |
use Koha::SearchEngine::QueryBuilder; |
|
|
60 |
use Koha::Serial::Items; |
60 |
|
61 |
|
61 |
my $query = CGI->new(); |
62 |
my $query = CGI->new(); |
62 |
|
63 |
|
Lines 157-180
$template->param(
Link Here
|
157 |
content_identifier_exists => $content_identifier_exists, |
158 |
content_identifier_exists => $content_identifier_exists, |
158 |
); |
159 |
); |
159 |
|
160 |
|
160 |
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } }; |
161 |
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } }; |
161 |
|
162 |
|
162 |
my $dbh = C4::Context->dbh; |
163 |
my $all_items = $biblio->items( |
163 |
|
164 |
{}, |
164 |
my @all_items = GetItemsInfo( $biblionumber ); |
165 |
{ |
|
|
166 |
# FIXME A different order is expected if at least one items.serial is true |
167 |
order_by => [ |
168 |
'homebranch.branchname', |
169 |
'me.enumchron', |
170 |
\"LDAP( me.copynumber, 8, '0' )", |
171 |
-asc => 'me.dateacessioned' |
172 |
], |
173 |
join => ['homebranch'] |
174 |
} |
175 |
); |
165 |
my @items; |
176 |
my @items; |
166 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
177 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
167 |
for my $itm (@all_items) { |
178 |
while ( my $item = $all_items->next ) { |
168 |
push @items, $itm unless ( $itm->{itemlost} && $patron->category->hidelostitems && !$showallitems); |
179 |
push @items, $item |
|
|
180 |
unless $item->itemlost |
181 |
&& $patron->category->hidelostitems |
182 |
&& !$showallitems; |
169 |
} |
183 |
} |
170 |
|
184 |
|
171 |
# flag indicating existence of at least one item linked via a host record |
185 |
# flag indicating existence of at least one item linked via a host record |
172 |
my $hostrecords; |
186 |
my $hostrecords; |
173 |
# adding items linked via host biblios |
187 |
# adding items linked via host biblios |
174 |
my @hostitems = GetHostItemsInfo($marc_record); |
188 |
my $hostitems = $biblio->host_items; |
175 |
if (@hostitems){ |
189 |
if ( $hostitems->count ) { |
176 |
$hostrecords =1; |
190 |
$hostrecords = 1; |
177 |
push (@items,@hostitems); |
191 |
push @items, $hostitems->as_list; |
178 |
} |
192 |
} |
179 |
|
193 |
|
180 |
my $dat = &GetBiblioData($biblionumber); |
194 |
my $dat = &GetBiblioData($biblionumber); |
Lines 281-289
if ( defined $dat->{'itemtype'} ) {
Link Here
|
281 |
$dat->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $dat->{itemtype} }{imageurl} ); |
295 |
$dat->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $dat->{itemtype} }{imageurl} ); |
282 |
} |
296 |
} |
283 |
|
297 |
|
284 |
$dat->{'count'} = scalar @all_items + @hostitems; |
298 |
$dat->{'count'} = $all_items->count + $hostitems->count; |
285 |
$dat->{'showncount'} = scalar @items + @hostitems; |
299 |
$dat->{'showncount'} = scalar @items + $hostitems->count; |
286 |
$dat->{'hiddencount'} = scalar @all_items + @hostitems - scalar @items; |
300 |
$dat->{'hiddencount'} = $all_items->count + $hostitems->count - scalar @items; |
287 |
|
301 |
|
288 |
my $shelflocations = |
302 |
my $shelflocations = |
289 |
{ map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.location' } ) }; |
303 |
{ map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.location' } ) }; |
Lines 325-384
if ($currentbranch and C4::Context->preference('SeparateHoldings')) {
Link Here
|
325 |
} |
339 |
} |
326 |
my $separatebranch = C4::Context->preference('SeparateHoldingsBranch') || 'homebranch'; |
340 |
my $separatebranch = C4::Context->preference('SeparateHoldingsBranch') || 'homebranch'; |
327 |
my ( $itemloop_has_images, $otheritemloop_has_images ); |
341 |
my ( $itemloop_has_images, $otheritemloop_has_images ); |
328 |
foreach my $item (@items) { |
|
|
329 |
my $itembranchcode = $item->{$separatebranch}; |
330 |
|
342 |
|
331 |
$item->{imageurl} = defined $item->{itype} ? getitemtypeimagelocation('intranet', $itemtypes->{ $item->{itype} }{imageurl}) |
343 |
foreach my $item (@items) { |
332 |
: ''; |
344 |
my $itembranchcode = $item->$separatebranch; |
333 |
|
345 |
|
334 |
$item->{datedue} = format_sqldatetime($item->{datedue}); |
346 |
my $item_info = $item->unblessed; |
|
|
347 |
$item_info->{itemtype} = $itemtypes->{$item->effective_itemtype}; |
335 |
|
348 |
|
336 |
#get shelf location and collection code description if they are authorised value. |
349 |
#get shelf location and collection code description if they are authorised value. |
337 |
# same thing for copy number |
350 |
# same thing for copy number |
338 |
my $shelfcode = $item->{'location'}; |
351 |
my $shelfcode = $item->location; |
339 |
$item->{'location'} = $shelflocations->{$shelfcode} if ( defined( $shelfcode ) && defined($shelflocations) && exists( $shelflocations->{$shelfcode} ) ); |
352 |
$item_info->{'location'} = $shelflocations->{$shelfcode} if ( defined( $shelfcode ) && defined($shelflocations) && exists( $shelflocations->{$shelfcode} ) ); |
340 |
my $ccode = $item->{'ccode'}; |
353 |
my $ccode = $item->ccode; |
341 |
$item->{'ccode'} = $collections->{$ccode} if ( defined( $ccode ) && defined($collections) && exists( $collections->{$ccode} ) ); |
354 |
$item_info->{'ccode'} = $collections->{$ccode} if ( defined( $ccode ) && defined($collections) && exists( $collections->{$ccode} ) ); |
342 |
my $copynumber = $item->{'copynumber'}; |
355 |
my $copynumber = $item->{'copynumber'}; |
343 |
$item->{'copynumber'} = $copynumbers->{$copynumber} if ( defined($copynumber) && defined($copynumbers) && exists( $copynumbers->{$copynumber} ) ); |
356 |
$item_info->{'copynumber'} = $copynumbers->{$copynumber} if ( defined($copynumber) && defined($copynumbers) && exists( $copynumbers->{$copynumber} ) ); |
344 |
foreach (qw(ccode enumchron copynumber stocknumber itemnotes itemnotes_nonpublic uri publisheddate)) { # Warning when removing GetItemsInfo - publisheddate (at least) is not part of the items table |
357 |
foreach (qw(ccode enumchron copynumber stocknumber itemnotes itemnotes_nonpublic uri )) { |
345 |
$itemfields{$_} = 1 if ( $item->{$_} ); |
358 |
$itemfields{$_} = 1 if $item->$_; |
|
|
359 |
} |
360 |
|
361 |
# FIXME The following must be Koha::Item->serial |
362 |
my $serial_item = Koha::Serial::Items->find($item->itemnumber); |
363 |
if ( $serial_item ) { |
364 |
$item_info->{serial} = $serial_item; |
365 |
$itemfields{publisheddate} = 1; |
346 |
} |
366 |
} |
347 |
|
367 |
|
348 |
# checking for holds |
368 |
# checking for holds |
349 |
my $item_object = Koha::Items->find( $item->{itemnumber} ); |
369 |
my $holds = $item->current_holds; |
350 |
my $holds = $item_object->current_holds; |
|
|
351 |
if ( my $first_hold = $holds->next ) { |
370 |
if ( my $first_hold = $holds->next ) { |
352 |
$item->{first_hold} = $first_hold; |
371 |
$item_info->{first_hold} = $first_hold; |
353 |
} |
372 |
} |
354 |
|
373 |
|
355 |
if ( my $checkout = $item_object->checkout ) { |
374 |
$item_info->{checkout} = $item->checkout; |
356 |
$item->{CheckedOutFor} = $checkout->patron; |
|
|
357 |
} |
358 |
|
375 |
|
359 |
# Check the transit status |
376 |
# Check the transit status |
360 |
my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($item->{itemnumber}); |
377 |
my $transfer = $item->get_transfer; |
361 |
if ( defined( $transfertwhen ) && ( $transfertwhen ne '' ) ) { |
378 |
if ( $transfer ) { |
362 |
$item->{transfertwhen} = $transfertwhen; |
379 |
$item_info->{transfertwhen} = $transfer->datesent; |
363 |
$item->{transfertfrom} = $transfertfrom; |
380 |
$item_info->{transfertfrom} = $transfer->frombranch; |
364 |
$item->{transfertto} = $transfertto; |
381 |
$item_info->{transfertto} = $transfer->tobranch; |
365 |
$item->{nocancel} = 1; |
382 |
$item_info->{nocancel} = 1; |
366 |
} |
383 |
} |
367 |
|
384 |
|
368 |
foreach my $f (qw( itemnotes )) { |
385 |
foreach my $f (qw( itemnotes )) { |
369 |
if ($item->{$f}) { |
386 |
if ($item_info->{$f}) { |
370 |
$item->{$f} =~ s|\n|<br />|g; |
387 |
$item_info->{$f} =~ s|\n|<br />|g; |
371 |
$itemfields{$f} = 1; |
388 |
$itemfields{$f} = 1; |
372 |
} |
389 |
} |
373 |
} |
390 |
} |
374 |
|
391 |
|
375 |
#item has a host number if its biblio number does not match the current bib |
392 |
#item has a host number if its biblio number does not match the current bib |
376 |
|
393 |
|
377 |
if ($item->{biblionumber} ne $biblionumber){ |
394 |
if ($item->biblionumber ne $biblionumber){ |
378 |
$item->{hostbiblionumber} = $item->{biblionumber}; |
395 |
$item_info->{hostbiblionumber} = $item->biblionumber; |
379 |
$item->{hosttitle} = GetBiblioData($item->{biblionumber})->{title}; |
396 |
$item_info->{hosttitle} = $item->biblio->title; |
380 |
} |
397 |
} |
381 |
|
398 |
|
382 |
|
399 |
|
383 |
if ( $analyze ) { |
400 |
if ( $analyze ) { |
384 |
# count if item is used in analytical bibliorecords |
401 |
# count if item is used in analytical bibliorecords |
Lines 386-437
foreach my $item (@items) {
Link Here
|
386 |
my $countanalytics = C4::Context->preference('EasyAnalyticalRecords') ? GetAnalyticsCount($item->{itemnumber}) : 0; |
403 |
my $countanalytics = C4::Context->preference('EasyAnalyticalRecords') ? GetAnalyticsCount($item->{itemnumber}) : 0; |
387 |
if ($countanalytics > 0){ |
404 |
if ($countanalytics > 0){ |
388 |
$analytics_flag=1; |
405 |
$analytics_flag=1; |
389 |
$item->{countanalytics} = $countanalytics; |
406 |
$item_info->{countanalytics} = $countanalytics; |
390 |
} |
407 |
} |
391 |
} |
408 |
} |
392 |
|
409 |
|
393 |
if (defined($item->{'materials'}) && $item->{'materials'} =~ /\S/){ |
410 |
if (defined($item->materials) && $item->materials =~ /\S/){ |
394 |
$materials_flag = 1; |
411 |
$materials_flag = 1; |
395 |
if (defined $materials_map{ $item->{materials} }) { |
412 |
if (defined $materials_map{ $item->materials }) { |
396 |
$item->{materials} = $materials_map{ $item->{materials} }; |
413 |
$item_info->{materials} = $materials_map{ $item->materials }; |
397 |
} |
414 |
} |
398 |
} |
415 |
} |
399 |
|
416 |
|
400 |
if ( C4::Context->preference('UseCourseReserves') ) { |
417 |
if ( C4::Context->preference('UseCourseReserves') ) { |
401 |
$item->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $item->{'itemnumber'} ); |
418 |
$item_info->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $item->itemnumber ); |
402 |
} |
|
|
403 |
|
404 |
if ( C4::Context->preference('IndependentBranches') ) { |
405 |
my $userenv = C4::Context->userenv(); |
406 |
if ( not C4::Context->IsSuperLibrarian() |
407 |
and $userenv->{branch} ne $item->{homebranch} ) { |
408 |
$item->{cannot_be_edited} = 1; |
409 |
} |
410 |
} |
419 |
} |
411 |
|
420 |
|
412 |
if ( C4::Context->preference("LocalCoverImages") == 1 ) { |
421 |
if ( C4::Context->preference("LocalCoverImages") == 1 ) { |
413 |
$item->{cover_images} = $item_object->cover_images; |
422 |
$item_info->{cover_images} = $item->cover_images; |
414 |
} |
423 |
} |
415 |
|
424 |
|
416 |
if ( C4::Context->preference('UseRecalls') ) { |
425 |
if ( C4::Context->preference('UseRecalls') ) { |
417 |
my $recall = Koha::Recalls->find({ item_id => $item->{itemnumber}, completed => 0 }); |
426 |
my $recall = Koha::Recalls->find({ item_id => $item->{itemnumber}, completed => 0 }); |
418 |
if ( defined $recall ) { |
427 |
if ( defined $recall ) { |
419 |
$item->{recalled} = 1; |
428 |
$item_info->{recalled} = 1; |
420 |
$item->{recall} = $recall; |
429 |
$item_info->{recall} = $recall; |
|
|
430 |
} |
431 |
} |
432 |
|
433 |
if ( C4::Context->preference('IndependentBranches') ) { |
434 |
my $userenv = C4::Context->userenv(); |
435 |
if ( not C4::Context->IsSuperLibrarian() |
436 |
and $userenv->{branch} ne $item->homebranch ) { |
437 |
$item_info->{cannot_be_edited} = 1; |
438 |
$item_info->{not_same_branch} = 1; |
421 |
} |
439 |
} |
422 |
} |
440 |
} |
423 |
|
441 |
|
424 |
if ($currentbranch and C4::Context->preference('SeparateHoldings')) { |
442 |
if ($currentbranch and C4::Context->preference('SeparateHoldings')) { |
425 |
if ($itembranchcode and $itembranchcode eq $currentbranch) { |
443 |
if ($itembranchcode and $itembranchcode eq $currentbranch) { |
426 |
push @itemloop, $item; |
444 |
push @itemloop, $item_info; |
427 |
$itemloop_has_images++ if $item_object->cover_images->count; |
445 |
$itemloop_has_images++ if $item->cover_images->count; |
428 |
} else { |
446 |
} else { |
429 |
push @otheritemloop, $item; |
447 |
push @otheritemloop, $item_info; |
430 |
$otheritemloop_has_images++ if $item_object->cover_images->count; |
448 |
$otheritemloop_has_images++ if $item->cover_images->count; |
431 |
} |
449 |
} |
432 |
} else { |
450 |
} else { |
433 |
push @itemloop, $item; |
451 |
push @itemloop, $item_info; |
434 |
$itemloop_has_images++ if $item_object->cover_images->count; |
452 |
$itemloop_has_images++ if $item->cover_images->count; |
435 |
} |
453 |
} |
436 |
} |
454 |
} |
437 |
|
455 |
|