|
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 60-65
use Koha::Plugins;
Link Here
|
| 60 |
use Koha::Recalls; |
60 |
use Koha::Recalls; |
| 61 |
use Koha::SearchEngine::Search; |
61 |
use Koha::SearchEngine::Search; |
| 62 |
use Koha::SearchEngine::QueryBuilder; |
62 |
use Koha::SearchEngine::QueryBuilder; |
|
|
63 |
use Koha::Serial::Items; |
| 63 |
|
64 |
|
| 64 |
my $query = CGI->new(); |
65 |
my $query = CGI->new(); |
| 65 |
|
66 |
|
|
Lines 189-212
$template->param(
Link Here
|
| 189 |
content_identifier_exists => $content_identifier_exists, |
190 |
content_identifier_exists => $content_identifier_exists, |
| 190 |
); |
191 |
); |
| 191 |
|
192 |
|
| 192 |
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } }; |
193 |
my $itemtypes = { map { $_->itemtype => $_ } @{ Koha::ItemTypes->search_with_localization->as_list } }; |
| 193 |
|
194 |
my $all_items = $biblio->items->search_ordered; |
| 194 |
my $dbh = C4::Context->dbh; |
|
|
| 195 |
|
| 196 |
my @all_items = GetItemsInfo( $biblionumber ); |
| 197 |
my @items; |
195 |
my @items; |
| 198 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
196 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
| 199 |
for my $itm (@all_items) { |
197 |
while ( my $item = $all_items->next ) { |
| 200 |
push @items, $itm unless ( $itm->{itemlost} && $patron->category->hidelostitems && !$showallitems); |
198 |
push @items, $item |
|
|
199 |
unless $item->itemlost |
| 200 |
&& $patron->category->hidelostitems |
| 201 |
&& !$showallitems; |
| 201 |
} |
202 |
} |
| 202 |
|
203 |
|
| 203 |
# flag indicating existence of at least one item linked via a host record |
204 |
# flag indicating existence of at least one item linked via a host record |
| 204 |
my $hostrecords; |
205 |
my $hostrecords; |
| 205 |
# adding items linked via host biblios |
206 |
# adding items linked via host biblios |
| 206 |
my @hostitems = GetHostItemsInfo($marc_record); |
207 |
my $hostitems = $biblio->host_items; |
| 207 |
if (@hostitems){ |
208 |
if ( $hostitems->count ) { |
| 208 |
$hostrecords =1; |
209 |
$hostrecords = 1; |
| 209 |
push (@items,@hostitems); |
210 |
push @items, $hostitems->as_list; |
| 210 |
} |
211 |
} |
| 211 |
|
212 |
|
| 212 |
my $dat = &GetBiblioData($biblionumber); |
213 |
my $dat = &GetBiblioData($biblionumber); |
|
Lines 317-328
if ( C4::Context->preference('suggestion') ) {
Link Here
|
| 317 |
} |
318 |
} |
| 318 |
|
319 |
|
| 319 |
if ( defined $dat->{'itemtype'} ) { |
320 |
if ( defined $dat->{'itemtype'} ) { |
| 320 |
$dat->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $dat->{itemtype} }{imageurl} ); |
321 |
$dat->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $dat->{itemtype} }->imageurl ); |
| 321 |
} |
322 |
} |
| 322 |
|
323 |
|
| 323 |
$dat->{'count'} = scalar @all_items + @hostitems; |
324 |
$dat->{'count'} = $all_items->count + $hostitems->count; |
| 324 |
$dat->{'showncount'} = scalar @items + @hostitems; |
325 |
$dat->{'showncount'} = scalar @items + $hostitems->count; |
| 325 |
$dat->{'hiddencount'} = scalar @all_items + @hostitems - scalar @items; |
326 |
$dat->{'hiddencount'} = $all_items->count + $hostitems->count - scalar @items; |
| 326 |
|
327 |
|
| 327 |
my $shelflocations = |
328 |
my $shelflocations = |
| 328 |
{ map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.location' } ) }; |
329 |
{ map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.location' } ) }; |
|
Lines 364-424
if ($currentbranch and C4::Context->preference('SeparateHoldings')) {
Link Here
|
| 364 |
} |
365 |
} |
| 365 |
my $separatebranch = C4::Context->preference('SeparateHoldingsBranch') || 'homebranch'; |
366 |
my $separatebranch = C4::Context->preference('SeparateHoldingsBranch') || 'homebranch'; |
| 366 |
my ( $itemloop_has_images, $otheritemloop_has_images ); |
367 |
my ( $itemloop_has_images, $otheritemloop_has_images ); |
| 367 |
foreach my $item (@items) { |
|
|
| 368 |
my $itembranchcode = $item->{$separatebranch}; |
| 369 |
|
368 |
|
| 370 |
$item->{imageurl} = defined $item->{itype} ? getitemtypeimagelocation('intranet', $itemtypes->{ $item->{itype} }{imageurl}) |
369 |
foreach my $item (@items) { |
| 371 |
: ''; |
370 |
my $itembranchcode = $item->$separatebranch; |
| 372 |
|
371 |
|
| 373 |
$item->{datedue} = format_sqldatetime($item->{datedue}); |
372 |
my $item_info = $item->unblessed; |
|
|
373 |
$item_info->{itemtype} = $itemtypes->{$item->effective_itemtype}; |
| 374 |
|
374 |
|
| 375 |
#get shelf location and collection code description if they are authorised value. |
375 |
#get shelf location and collection code description if they are authorised value. |
| 376 |
# same thing for copy number |
376 |
# same thing for copy number |
| 377 |
my $shelfcode = $item->{'location'}; |
377 |
my $shelfcode = $item->location; |
| 378 |
$item->{'location'} = $shelflocations->{$shelfcode} if ( defined( $shelfcode ) && defined($shelflocations) && exists( $shelflocations->{$shelfcode} ) ); |
378 |
$item_info->{'location'} = $shelflocations->{$shelfcode} if ( defined( $shelfcode ) && defined($shelflocations) && exists( $shelflocations->{$shelfcode} ) ); |
| 379 |
my $ccode = $item->{'ccode'}; |
379 |
my $ccode = $item->ccode; |
| 380 |
$item->{'ccode'} = $collections->{$ccode} if ( defined( $ccode ) && defined($collections) && exists( $collections->{$ccode} ) ); |
380 |
$item_info->{'ccode'} = $collections->{$ccode} if ( defined( $ccode ) && defined($collections) && exists( $collections->{$ccode} ) ); |
| 381 |
my $copynumber = $item->{'copynumber'}; |
381 |
my $copynumber = $item->{'copynumber'}; |
| 382 |
$item->{'copynumber'} = $copynumbers->{$copynumber} if ( defined($copynumber) && defined($copynumbers) && exists( $copynumbers->{$copynumber} ) ); |
382 |
$item_info->{'copynumber'} = $copynumbers->{$copynumber} if ( defined($copynumber) && defined($copynumbers) && exists( $copynumbers->{$copynumber} ) ); |
| 383 |
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 |
383 |
foreach (qw(ccode enumchron copynumber stocknumber itemnotes itemnotes_nonpublic uri )) { |
| 384 |
$itemfields{$_} = 1 if ( $item->{$_} ); |
384 |
$itemfields{$_} = 1 if $item->$_; |
|
|
385 |
} |
| 386 |
|
| 387 |
# FIXME The following must be Koha::Item->serial |
| 388 |
my $serial_item = Koha::Serial::Items->find($item->itemnumber); |
| 389 |
if ( $serial_item ) { |
| 390 |
$item_info->{serial} = $serial_item; |
| 391 |
$itemfields{publisheddate} = 1; |
| 385 |
} |
392 |
} |
| 386 |
|
393 |
|
|
|
394 |
$item_info->{object} = $item; |
| 395 |
|
| 387 |
# checking for holds |
396 |
# checking for holds |
| 388 |
my $item_object = Koha::Items->find( $item->{itemnumber} ); |
397 |
my $holds = $item->current_holds; |
| 389 |
$item->{object} = $item_object; |
|
|
| 390 |
my $holds = $item_object->current_holds; |
| 391 |
if ( my $first_hold = $holds->next ) { |
398 |
if ( my $first_hold = $holds->next ) { |
| 392 |
$item->{first_hold} = $first_hold; |
399 |
$item_info->{first_hold} = $first_hold; |
| 393 |
} |
400 |
} |
| 394 |
|
401 |
|
| 395 |
if ( my $checkout = $item_object->checkout ) { |
402 |
$item_info->{checkout} = $item->checkout; |
| 396 |
$item->{CheckedOutFor} = $checkout->patron; |
|
|
| 397 |
} |
| 398 |
|
403 |
|
| 399 |
# Check the transit status |
404 |
# Check the transit status |
| 400 |
my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($item->{itemnumber}); |
405 |
my $transfer = $item->get_transfer; |
| 401 |
if ( defined( $transfertwhen ) && ( $transfertwhen ne '' ) ) { |
406 |
if ( $transfer ) { |
| 402 |
$item->{transfertwhen} = $transfertwhen; |
407 |
$item_info->{transfertwhen} = $transfer->datesent; |
| 403 |
$item->{transfertfrom} = $transfertfrom; |
408 |
$item_info->{transfertfrom} = $transfer->frombranch; |
| 404 |
$item->{transfertto} = $transfertto; |
409 |
$item_info->{transfertto} = $transfer->tobranch; |
| 405 |
$item->{nocancel} = 1; |
410 |
$item_info->{nocancel} = 1; |
| 406 |
} |
411 |
} |
| 407 |
|
412 |
|
| 408 |
foreach my $f (qw( itemnotes )) { |
413 |
foreach my $f (qw( itemnotes )) { |
| 409 |
if ($item->{$f}) { |
414 |
if ($item_info->{$f}) { |
| 410 |
$item->{$f} =~ s|\n|<br />|g; |
415 |
$item_info->{$f} =~ s|\n|<br />|g; |
| 411 |
$itemfields{$f} = 1; |
416 |
$itemfields{$f} = 1; |
| 412 |
} |
417 |
} |
| 413 |
} |
418 |
} |
| 414 |
|
419 |
|
| 415 |
#item has a host number if its biblio number does not match the current bib |
420 |
#item has a host number if its biblio number does not match the current bib |
| 416 |
|
421 |
|
| 417 |
if ($item->{biblionumber} ne $biblionumber){ |
422 |
if ($item->biblionumber ne $biblionumber){ |
| 418 |
$item->{hostbiblionumber} = $item->{biblionumber}; |
423 |
$item_info->{hostbiblionumber} = $item->biblionumber; |
| 419 |
$item->{hosttitle} = GetBiblioData($item->{biblionumber})->{title}; |
424 |
$item_info->{hosttitle} = $item->biblio->title; |
| 420 |
} |
425 |
} |
| 421 |
|
426 |
|
| 422 |
|
427 |
|
| 423 |
if ( $analyze ) { |
428 |
if ( $analyze ) { |
| 424 |
# count if item is used in analytical bibliorecords |
429 |
# count if item is used in analytical bibliorecords |
|
Lines 426-490
foreach my $item (@items) {
Link Here
|
| 426 |
my $countanalytics = GetAnalyticsCount( $item->{itemnumber} ); |
431 |
my $countanalytics = GetAnalyticsCount( $item->{itemnumber} ); |
| 427 |
if ($countanalytics > 0){ |
432 |
if ($countanalytics > 0){ |
| 428 |
$analytics_flag=1; |
433 |
$analytics_flag=1; |
| 429 |
$item->{countanalytics} = $countanalytics; |
434 |
$item_info->{countanalytics} = $countanalytics; |
| 430 |
} |
435 |
} |
| 431 |
} |
436 |
} |
| 432 |
|
437 |
|
| 433 |
if (defined($item->{'materials'}) && $item->{'materials'} =~ /\S/){ |
438 |
if (defined($item->materials) && $item->materials =~ /\S/){ |
| 434 |
$materials_flag = 1; |
439 |
$materials_flag = 1; |
| 435 |
if (defined $materials_map{ $item->{materials} }) { |
440 |
if (defined $materials_map{ $item->materials }) { |
| 436 |
$item->{materials} = $materials_map{ $item->{materials} }; |
441 |
$item_info->{materials} = $materials_map{ $item->materials }; |
| 437 |
} |
442 |
} |
| 438 |
} |
443 |
} |
| 439 |
|
444 |
|
| 440 |
if ( C4::Context->preference('UseCourseReserves') ) { |
445 |
if ( C4::Context->preference('UseCourseReserves') ) { |
| 441 |
$item->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $item->{'itemnumber'} ); |
446 |
$item_info->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $item->itemnumber ); |
| 442 |
} |
|
|
| 443 |
|
| 444 |
if ( C4::Context->preference('IndependentBranches') ) { |
| 445 |
my $userenv = C4::Context->userenv(); |
| 446 |
if ( not C4::Context->IsSuperLibrarian() |
| 447 |
and $userenv->{branch} ne $item->{homebranch} ) { |
| 448 |
$item->{cannot_be_edited} = 1; |
| 449 |
} |
| 450 |
} |
447 |
} |
| 451 |
|
448 |
|
| 452 |
if ( C4::Context->preference("LocalCoverImages") == 1 ) { |
449 |
if ( C4::Context->preference("LocalCoverImages") == 1 ) { |
| 453 |
$item->{cover_images} = $item_object->cover_images; |
450 |
$item_info->{cover_images} = $item->cover_images; |
| 454 |
} |
451 |
} |
| 455 |
|
452 |
|
| 456 |
if ( C4::Context->preference('UseRecalls') ) { |
453 |
if ( C4::Context->preference('UseRecalls') ) { |
| 457 |
my $recall = Koha::Recalls->find({ item_id => $item->{itemnumber}, completed => 0 }); |
454 |
$item_info->{recall} = $item->recall; |
| 458 |
if ( defined $recall ) { |
455 |
} |
| 459 |
$item->{recalled} = 1; |
456 |
|
| 460 |
$item->{recall} = $recall; |
457 |
if ( C4::Context->preference('IndependentBranches') ) { |
|
|
458 |
my $userenv = C4::Context->userenv(); |
| 459 |
if ( not C4::Context->IsSuperLibrarian() |
| 460 |
and $userenv->{branch} ne $item->homebranch ) { |
| 461 |
$item_info->{cannot_be_edited} = 1; |
| 462 |
$item_info->{not_same_branch} = 1; |
| 461 |
} |
463 |
} |
| 462 |
} |
464 |
} |
| 463 |
|
465 |
|
| 464 |
if ( $item_object->is_bundle ) { |
466 |
if ( $item->is_bundle ) { |
| 465 |
$item->{bundled} = |
467 |
$item_info->{bundled} = |
| 466 |
$item_object->bundle_items->search( { itemlost => { '!=' => 0 } } ) |
468 |
$item->bundle_items->search( { itemlost => { '!=' => 0 } } ) |
| 467 |
->count; |
469 |
->count; |
| 468 |
$item->{bundled_lost} = |
470 |
$item_info->{bundled_lost} = |
| 469 |
$item_object->bundle_items->search( { itemlost => 0 } )->count; |
471 |
$item->bundle_items->search( { itemlost => 0 } )->count; |
| 470 |
$item->{is_bundle} = 1; |
472 |
$item_info->{is_bundle} = 1; |
| 471 |
} |
473 |
} |
| 472 |
|
474 |
|
| 473 |
if ($item_object->in_bundle) { |
475 |
if ($item->in_bundle) { |
| 474 |
$item->{bundle_host} = $item_object->bundle_host; |
476 |
$item_info->{bundle_host} = $item->bundle_host; |
| 475 |
} |
477 |
} |
| 476 |
|
478 |
|
| 477 |
if ($currentbranch and C4::Context->preference('SeparateHoldings')) { |
479 |
if ($currentbranch and C4::Context->preference('SeparateHoldings')) { |
| 478 |
if ($itembranchcode and $itembranchcode eq $currentbranch) { |
480 |
if ($itembranchcode and $itembranchcode eq $currentbranch) { |
| 479 |
push @itemloop, $item; |
481 |
push @itemloop, $item_info; |
| 480 |
$itemloop_has_images++ if $item_object->cover_images->count; |
482 |
$itemloop_has_images++ if $item->cover_images->count; |
| 481 |
} else { |
483 |
} else { |
| 482 |
push @otheritemloop, $item; |
484 |
push @otheritemloop, $item_info; |
| 483 |
$otheritemloop_has_images++ if $item_object->cover_images->count; |
485 |
$otheritemloop_has_images++ if $item->cover_images->count; |
| 484 |
} |
486 |
} |
| 485 |
} else { |
487 |
} else { |
| 486 |
push @itemloop, $item; |
488 |
push @itemloop, $item_info; |
| 487 |
$itemloop_has_images++ if $item_object->cover_images->count; |
489 |
$itemloop_has_images++ if $item->cover_images->count; |
| 488 |
} |
490 |
} |
| 489 |
} |
491 |
} |
| 490 |
|
492 |
|