Lines 393-435
if ($barcode) {
Link Here
|
393 |
} |
393 |
} |
394 |
} |
394 |
} |
395 |
|
395 |
|
396 |
# Mark missing bundle items as lost and report unexpected items |
|
|
397 |
if ( $item->is_bundle ) { |
398 |
my $BundleLostValue = C4::Context->preference('BundleLostValue'); |
399 |
my $barcodes = $query->param('verify-items-bundle-contents-barcodes'); |
400 |
my @barcodes = map { s/^\s+|\s+$//gr } ( split /\n/, $barcodes ); |
401 |
my $expected_items = { map { $_->barcode => $_ } $item->bundle_items->as_list }; |
402 |
my $verify_items = Koha::Items->search( { barcode => { 'in' => \@barcodes } } ); |
403 |
my @unexpected_items; |
404 |
my @missing_items; |
405 |
my @bundle_items; |
406 |
while ( my $verify_item = $verify_items->next ) { |
407 |
# Fix and lost statuses |
408 |
$verify_item->itemlost(0); |
409 |
|
410 |
# Expected item, remove from lookup table |
411 |
if ( delete $expected_items->{$verify_item->barcode} ) { |
412 |
push @bundle_items, $verify_item; |
413 |
} |
414 |
# Unexpected item, warn and remove from bundle |
415 |
else { |
416 |
$verify_item->remove_from_bundle; |
417 |
push @unexpected_items, $verify_item; |
418 |
} |
419 |
# Store results |
420 |
$verify_item->store(); |
421 |
} |
422 |
for my $missing_item ( keys %{$expected_items} ) { |
423 |
my $bundle_item = $expected_items->{$missing_item}; |
424 |
$bundle_item->itemlost($BundleLostValue)->store(); |
425 |
push @missing_items, $bundle_item; |
426 |
} |
427 |
$template->param( |
428 |
unexpected_items => \@unexpected_items, |
429 |
missing_items => \@missing_items, |
430 |
bundle_items => \@bundle_items |
431 |
); |
432 |
} |
433 |
} elsif ( C4::Context->preference('ShowAllCheckins') and !$messages->{'BadBarcode'} and !$needs_confirm and !$bundle_confirm ) { |
396 |
} elsif ( C4::Context->preference('ShowAllCheckins') and !$messages->{'BadBarcode'} and !$needs_confirm and !$bundle_confirm ) { |
434 |
$input{duedate} = 0; |
397 |
$input{duedate} = 0; |
435 |
$returneditems{0} = $barcode; |
398 |
$returneditems{0} = $barcode; |
Lines 447-452
if ($barcode) {
Link Here
|
447 |
items_bundle_return_confirmation => 1, |
410 |
items_bundle_return_confirmation => 1, |
448 |
); |
411 |
); |
449 |
} |
412 |
} |
|
|
413 |
|
414 |
# Mark missing bundle items as lost and report unexpected items |
415 |
if ( $item->is_bundle && $query->param('confirm_items_bundle_return') ) { |
416 |
my $BundleLostValue = C4::Context->preference('BundleLostValue'); |
417 |
my $barcodes = $query->param('verify-items-bundle-contents-barcodes'); |
418 |
my @barcodes = map { s/^\s+|\s+$//gr } ( split /\n/, $barcodes ); |
419 |
my $expected_items = { map { $_->barcode => $_ } $item->bundle_items->as_list }; |
420 |
my $verify_items = Koha::Items->search( { barcode => { 'in' => \@barcodes } } ); |
421 |
my @unexpected_items; |
422 |
my @missing_items; |
423 |
my @bundle_items; |
424 |
while ( my $verify_item = $verify_items->next ) { |
425 |
# Fix and lost statuses |
426 |
$verify_item->itemlost(0); |
427 |
|
428 |
# Update last_seen |
429 |
$verify_item->datelastseen( dt_from_string()->ymd() ); |
430 |
|
431 |
# Update last_borrowed if actual checkin |
432 |
$verify_item->datelastborrowed( dt_from_string()->ymd() ) if $issue; |
433 |
|
434 |
# Expected item, remove from lookup table |
435 |
if ( delete $expected_items->{$verify_item->barcode} ) { |
436 |
push @bundle_items, $verify_item; |
437 |
} |
438 |
# Unexpected item, warn and remove from bundle |
439 |
else { |
440 |
$verify_item->remove_from_bundle; |
441 |
push @unexpected_items, $verify_item; |
442 |
} |
443 |
|
444 |
# Store results |
445 |
$verify_item->store(); |
446 |
} |
447 |
for my $missing_item ( keys %{$expected_items} ) { |
448 |
my $bundle_item = $expected_items->{$missing_item}; |
449 |
$bundle_item->itemlost($BundleLostValue)->store(); |
450 |
# Add return_claim record if this is an actual checkin |
451 |
if ($issue) { |
452 |
$bundle_item->_result->create_related( |
453 |
'return_claims', |
454 |
{ |
455 |
issue_id => $issue->issue_id, |
456 |
itemnumber => $bundle_item->itemnumber, |
457 |
borrowernumber => $issue->borrowernumber, |
458 |
created_by => C4::Context->userenv()->{number}, |
459 |
created_on => dt_from_string |
460 |
} |
461 |
); |
462 |
} |
463 |
push @missing_items, $bundle_item; |
464 |
# NOTE: We cannot use C4::LostItem here because the item itself doesn't have a checkout |
465 |
# and thus would not get charged.. it's checked out as part of the bundle. |
466 |
if ( C4::Context->preference('WhenLostChargeReplacementFee') && $issue ) { |
467 |
C4::Accounts::chargelostitem( |
468 |
$issue->borrowernumber, |
469 |
$bundle_item->itemnumber, |
470 |
$bundle_item->replacementprice, |
471 |
sprintf( "%s %s %s", |
472 |
$bundle_item->biblio->title || q{}, |
473 |
$bundle_item->barcode || q{}, |
474 |
$bundle_item->itemcallnumber || q{}, |
475 |
), |
476 |
); |
477 |
} |
478 |
} |
479 |
$template->param( |
480 |
unexpected_items => \@unexpected_items, |
481 |
missing_items => \@missing_items, |
482 |
bundle_items => \@bundle_items |
483 |
); |
484 |
} |
450 |
} |
485 |
} |
451 |
$template->param( inputloop => \@inputloop ); |
486 |
$template->param( inputloop => \@inputloop ); |
452 |
|
487 |
|