|
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 $dbh = C4::Context->dbh; |
| 163 |
|
164 |
|
| 164 |
my @all_items = GetItemsInfo( $biblionumber ); |
165 |
my $all_items = $biblio->items; |
| 165 |
my @items; |
166 |
my @items; |
| 166 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
167 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
| 167 |
for my $itm (@all_items) { |
168 |
while ( my $item = $all_items->next ) { |
| 168 |
push @items, $itm unless ( $itm->{itemlost} && $patron->category->hidelostitems && !$showallitems); |
169 |
push @items, $item |
|
|
170 |
unless $item->itemlost |
| 171 |
&& $patron->category->hidelostitems |
| 172 |
&& !$showallitems; |
| 169 |
} |
173 |
} |
| 170 |
|
174 |
|
| 171 |
# flag indicating existence of at least one item linked via a host record |
175 |
# flag indicating existence of at least one item linked via a host record |
| 172 |
my $hostrecords; |
176 |
my $hostrecords; |
| 173 |
# adding items linked via host biblios |
177 |
# adding items linked via host biblios |
| 174 |
my @hostitems = GetHostItemsInfo($marc_record); |
178 |
my $hostitems = $biblio->host_items; |
| 175 |
if (@hostitems){ |
179 |
if ( $hostitems->count ) { |
| 176 |
$hostrecords =1; |
180 |
$hostrecords = 1; |
| 177 |
push (@items,@hostitems); |
181 |
push @items, $hostitems->as_list; |
| 178 |
} |
182 |
} |
| 179 |
|
183 |
|
| 180 |
my $dat = &GetBiblioData($biblionumber); |
184 |
my $dat = &GetBiblioData($biblionumber); |
|
Lines 281-289
if ( defined $dat->{'itemtype'} ) {
Link Here
|
| 281 |
$dat->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $dat->{itemtype} }{imageurl} ); |
285 |
$dat->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $dat->{itemtype} }{imageurl} ); |
| 282 |
} |
286 |
} |
| 283 |
|
287 |
|
| 284 |
$dat->{'count'} = scalar @all_items + @hostitems; |
288 |
$dat->{'count'} = $all_items->count + $hostitems->count; |
| 285 |
$dat->{'showncount'} = scalar @items + @hostitems; |
289 |
$dat->{'showncount'} = scalar @items + $hostitems->count; |
| 286 |
$dat->{'hiddencount'} = scalar @all_items + @hostitems - scalar @items; |
290 |
$dat->{'hiddencount'} = $all_items->count + $hostitems->count - scalar @items; |
| 287 |
|
291 |
|
| 288 |
my $shelflocations = |
292 |
my $shelflocations = |
| 289 |
{ map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.location' } ) }; |
293 |
{ 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 |
} |
329 |
} |
| 326 |
my $separatebranch = C4::Context->preference('SeparateHoldingsBranch') || 'homebranch'; |
330 |
my $separatebranch = C4::Context->preference('SeparateHoldingsBranch') || 'homebranch'; |
| 327 |
my ( $itemloop_has_images, $otheritemloop_has_images ); |
331 |
my ( $itemloop_has_images, $otheritemloop_has_images ); |
| 328 |
foreach my $item (@items) { |
|
|
| 329 |
my $itembranchcode = $item->{$separatebranch}; |
| 330 |
|
332 |
|
| 331 |
$item->{imageurl} = defined $item->{itype} ? getitemtypeimagelocation('intranet', $itemtypes->{ $item->{itype} }{imageurl}) |
333 |
foreach my $item (@items) { |
| 332 |
: ''; |
334 |
my $itembranchcode = $item->$separatebranch; |
| 333 |
|
335 |
|
| 334 |
$item->{datedue} = format_sqldatetime($item->{datedue}); |
336 |
my $item_info = $item->unblessed; |
|
|
337 |
$item_info->{itemtype} = $itemtypes->{$item->effective_itemtype}; |
| 335 |
|
338 |
|
| 336 |
#get shelf location and collection code description if they are authorised value. |
339 |
#get shelf location and collection code description if they are authorised value. |
| 337 |
# same thing for copy number |
340 |
# same thing for copy number |
| 338 |
my $shelfcode = $item->{'location'}; |
341 |
my $shelfcode = $item->location; |
| 339 |
$item->{'location'} = $shelflocations->{$shelfcode} if ( defined( $shelfcode ) && defined($shelflocations) && exists( $shelflocations->{$shelfcode} ) ); |
342 |
$item_info->{'location'} = $shelflocations->{$shelfcode} if ( defined( $shelfcode ) && defined($shelflocations) && exists( $shelflocations->{$shelfcode} ) ); |
| 340 |
my $ccode = $item->{'ccode'}; |
343 |
my $ccode = $item->ccode; |
| 341 |
$item->{'ccode'} = $collections->{$ccode} if ( defined( $ccode ) && defined($collections) && exists( $collections->{$ccode} ) ); |
344 |
$item_info->{'ccode'} = $collections->{$ccode} if ( defined( $ccode ) && defined($collections) && exists( $collections->{$ccode} ) ); |
| 342 |
my $copynumber = $item->{'copynumber'}; |
345 |
my $copynumber = $item->{'copynumber'}; |
| 343 |
$item->{'copynumber'} = $copynumbers->{$copynumber} if ( defined($copynumber) && defined($copynumbers) && exists( $copynumbers->{$copynumber} ) ); |
346 |
$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 |
347 |
foreach (qw(ccode enumchron copynumber stocknumber itemnotes itemnotes_nonpublic uri )) { |
| 345 |
$itemfields{$_} = 1 if ( $item->{$_} ); |
348 |
$itemfields{$_} = 1 if $item->$_; |
|
|
349 |
} |
| 350 |
|
| 351 |
# FIXME The following must be Koha::Item->serial |
| 352 |
my $serial_item = Koha::Serial::Items->find($item->itemnumber); |
| 353 |
if ( $serial_item ) { |
| 354 |
$item_info->{serial} = $serial_item->serialid; # FIXME Not returning a Koha::Object! |
| 355 |
$itemfields{publisheddate} = 1; |
| 346 |
} |
356 |
} |
| 347 |
|
357 |
|
| 348 |
# checking for holds |
358 |
# checking for holds |
| 349 |
my $item_object = Koha::Items->find( $item->{itemnumber} ); |
359 |
my $holds = $item->current_holds; |
| 350 |
my $holds = $item_object->current_holds; |
|
|
| 351 |
if ( my $first_hold = $holds->next ) { |
360 |
if ( my $first_hold = $holds->next ) { |
| 352 |
$item->{first_hold} = $first_hold; |
361 |
$item_info->{first_hold} = $first_hold; |
| 353 |
} |
362 |
} |
| 354 |
|
363 |
|
| 355 |
if ( my $checkout = $item_object->checkout ) { |
364 |
$item_info->{checkout} = $item->checkout; |
| 356 |
$item->{CheckedOutFor} = $checkout->patron; |
|
|
| 357 |
} |
| 358 |
|
365 |
|
| 359 |
# Check the transit status |
366 |
# Check the transit status |
| 360 |
my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($item->{itemnumber}); |
367 |
my $transfer = $item->get_transfer; |
| 361 |
if ( defined( $transfertwhen ) && ( $transfertwhen ne '' ) ) { |
368 |
if ( $transfer ) { |
| 362 |
$item->{transfertwhen} = $transfertwhen; |
369 |
$item_info->{transfertwhen} = $transfer->datesent; |
| 363 |
$item->{transfertfrom} = $transfertfrom; |
370 |
$item_info->{transfertfrom} = $transfer->frombranch; |
| 364 |
$item->{transfertto} = $transfertto; |
371 |
$item_info->{transfertto} = $transfer->tobranch; |
| 365 |
$item->{nocancel} = 1; |
372 |
$item_info->{nocancel} = 1; |
| 366 |
} |
373 |
} |
| 367 |
|
374 |
|
| 368 |
foreach my $f (qw( itemnotes )) { |
375 |
foreach my $f (qw( itemnotes )) { |
| 369 |
if ($item->{$f}) { |
376 |
if ($item_info->{$f}) { |
| 370 |
$item->{$f} =~ s|\n|<br />|g; |
377 |
$item_info->{$f} =~ s|\n|<br />|g; |
| 371 |
$itemfields{$f} = 1; |
378 |
$itemfields{$f} = 1; |
| 372 |
} |
379 |
} |
| 373 |
} |
380 |
} |
| 374 |
|
381 |
|
| 375 |
#item has a host number if its biblio number does not match the current bib |
382 |
#item has a host number if its biblio number does not match the current bib |
| 376 |
|
383 |
|
| 377 |
if ($item->{biblionumber} ne $biblionumber){ |
384 |
if ($item->biblionumber ne $biblionumber){ |
| 378 |
$item->{hostbiblionumber} = $item->{biblionumber}; |
385 |
$item_info->{hostbiblionumber} = $item->biblionumber; |
| 379 |
$item->{hosttitle} = GetBiblioData($item->{biblionumber})->{title}; |
386 |
$item_info->{hosttitle} = $item->biblio->title; |
| 380 |
} |
387 |
} |
| 381 |
|
388 |
|
| 382 |
|
389 |
|
| 383 |
if ( $analyze ) { |
390 |
if ( $analyze ) { |
| 384 |
# count if item is used in analytical bibliorecords |
391 |
# 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; |
393 |
my $countanalytics = C4::Context->preference('EasyAnalyticalRecords') ? GetAnalyticsCount($item->{itemnumber}) : 0; |
| 387 |
if ($countanalytics > 0){ |
394 |
if ($countanalytics > 0){ |
| 388 |
$analytics_flag=1; |
395 |
$analytics_flag=1; |
| 389 |
$item->{countanalytics} = $countanalytics; |
396 |
$item_info->{countanalytics} = $countanalytics; |
| 390 |
} |
397 |
} |
| 391 |
} |
398 |
} |
| 392 |
|
399 |
|
| 393 |
if (defined($item->{'materials'}) && $item->{'materials'} =~ /\S/){ |
400 |
if (defined($item->materials) && $item->materials =~ /\S/){ |
| 394 |
$materials_flag = 1; |
401 |
$materials_flag = 1; |
| 395 |
if (defined $materials_map{ $item->{materials} }) { |
402 |
if (defined $materials_map{ $item->materials }) { |
| 396 |
$item->{materials} = $materials_map{ $item->{materials} }; |
403 |
$item_info->{materials} = $materials_map{ $item->materials }; |
| 397 |
} |
404 |
} |
| 398 |
} |
405 |
} |
| 399 |
|
406 |
|
| 400 |
if ( C4::Context->preference('UseCourseReserves') ) { |
407 |
if ( C4::Context->preference('UseCourseReserves') ) { |
| 401 |
$item->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $item->{'itemnumber'} ); |
408 |
$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 |
} |
409 |
} |
| 411 |
|
410 |
|
| 412 |
if ( C4::Context->preference("LocalCoverImages") == 1 ) { |
411 |
if ( C4::Context->preference("LocalCoverImages") == 1 ) { |
| 413 |
$item->{cover_images} = $item_object->cover_images; |
412 |
$item_info->{cover_images} = $item->cover_images; |
| 414 |
} |
413 |
} |
| 415 |
|
414 |
|
| 416 |
if ( C4::Context->preference('UseRecalls') ) { |
415 |
if ( C4::Context->preference('UseRecalls') ) { |
| 417 |
my $recall = Koha::Recalls->find({ item_id => $item->{itemnumber}, completed => 0 }); |
416 |
my $recall = Koha::Recalls->find({ item_id => $item->{itemnumber}, completed => 0 }); |
| 418 |
if ( defined $recall ) { |
417 |
if ( defined $recall ) { |
| 419 |
$item->{recalled} = 1; |
418 |
$item_info->{recalled} = 1; |
| 420 |
$item->{recall} = $recall; |
419 |
$item_info->{recall} = $recall; |
|
|
420 |
} |
| 421 |
} |
| 422 |
|
| 423 |
if ( C4::Context->preference('IndependentBranches') ) { |
| 424 |
my $userenv = C4::Context->userenv(); |
| 425 |
if ( not C4::Context->IsSuperLibrarian() |
| 426 |
and $userenv->{branch} ne $item->homebranch ) { |
| 427 |
$item_info->{cannot_be_edited} = 1; |
| 421 |
} |
428 |
} |
| 422 |
} |
429 |
} |
| 423 |
|
430 |
|
| 424 |
if ($currentbranch and C4::Context->preference('SeparateHoldings')) { |
431 |
if ($currentbranch and C4::Context->preference('SeparateHoldings')) { |
| 425 |
if ($itembranchcode and $itembranchcode eq $currentbranch) { |
432 |
if ($itembranchcode and $itembranchcode eq $currentbranch) { |
| 426 |
push @itemloop, $item; |
433 |
push @itemloop, $item_info; |
| 427 |
$itemloop_has_images++ if $item_object->cover_images->count; |
434 |
$itemloop_has_images++ if $item->cover_images->count; |
| 428 |
} else { |
435 |
} else { |
| 429 |
push @otheritemloop, $item; |
436 |
push @otheritemloop, $item_info; |
| 430 |
$otheritemloop_has_images++ if $item_object->cover_images->count; |
437 |
$otheritemloop_has_images++ if $item->cover_images->count; |
| 431 |
} |
438 |
} |
| 432 |
} else { |
439 |
} else { |
| 433 |
push @itemloop, $item; |
440 |
push @itemloop, $item_info; |
| 434 |
$itemloop_has_images++ if $item_object->cover_images->count; |
441 |
$itemloop_has_images++ if $item->cover_images->count; |
| 435 |
} |
442 |
} |
| 436 |
} |
443 |
} |
| 437 |
|
444 |
|