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