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