Lines 353-395
if ($barcode) {
Link Here
|
353 |
} |
353 |
} |
354 |
} |
354 |
} |
355 |
|
355 |
|
356 |
# Mark missing bundle items as lost and report unexpected items |
|
|
357 |
if ( $item->is_bundle ) { |
358 |
my $BundleLostValue = C4::Context->preference('BundleLostValue'); |
359 |
my $barcodes = $query->param('verify-items-bundle-contents-barcodes'); |
360 |
my @barcodes = map { s/^\s+|\s+$//gr } ( split /\n/, $barcodes ); |
361 |
my $expected_items = { map { $_->barcode => $_ } $item->bundle_items->as_list }; |
362 |
my $verify_items = Koha::Items->search( { barcode => { 'in' => \@barcodes } } ); |
363 |
my @unexpected_items; |
364 |
my @missing_items; |
365 |
my @bundle_items; |
366 |
while ( my $verify_item = $verify_items->next ) { |
367 |
# Fix and lost statuses |
368 |
$verify_item->itemlost(0); |
369 |
|
370 |
# Expected item, remove from lookup table |
371 |
if ( delete $expected_items->{$verify_item->barcode} ) { |
372 |
push @bundle_items, $verify_item; |
373 |
} |
374 |
# Unexpected item, warn and remove from bundle |
375 |
else { |
376 |
$verify_item->remove_from_bundle; |
377 |
push @unexpected_items, $verify_item; |
378 |
} |
379 |
# Store results |
380 |
$verify_item->store(); |
381 |
} |
382 |
for my $missing_item ( keys %{$expected_items} ) { |
383 |
my $bundle_item = $expected_items->{$missing_item}; |
384 |
$bundle_item->itemlost($BundleLostValue)->store(); |
385 |
push @missing_items, $bundle_item; |
386 |
} |
387 |
$template->param( |
388 |
unexpected_items => \@unexpected_items, |
389 |
missing_items => \@missing_items, |
390 |
bundle_items => \@bundle_items |
391 |
); |
392 |
} |
393 |
} elsif ( C4::Context->preference('ShowAllCheckins') and !$messages->{'BadBarcode'} and !$needs_confirm and !$bundle_confirm ) { |
356 |
} elsif ( C4::Context->preference('ShowAllCheckins') and !$messages->{'BadBarcode'} and !$needs_confirm and !$bundle_confirm ) { |
394 |
$input{duedate} = 0; |
357 |
$input{duedate} = 0; |
395 |
$returneditems{0} = $barcode; |
358 |
$returneditems{0} = $barcode; |
Lines 407-412
if ($barcode) {
Link Here
|
407 |
items_bundle_return_confirmation => 1, |
370 |
items_bundle_return_confirmation => 1, |
408 |
); |
371 |
); |
409 |
} |
372 |
} |
|
|
373 |
|
374 |
# Mark missing bundle items as lost and report unexpected items |
375 |
if ( $item->is_bundle && $query->param('confirm_items_bundle_return') ) { |
376 |
my $BundleLostValue = C4::Context->preference('BundleLostValue'); |
377 |
my $barcodes = $query->param('verify-items-bundle-contents-barcodes'); |
378 |
my @barcodes = map { s/^\s+|\s+$//gr } ( split /\n/, $barcodes ); |
379 |
my $expected_items = { map { $_->barcode => $_ } $item->bundle_items->as_list }; |
380 |
my $verify_items = Koha::Items->search( { barcode => { 'in' => \@barcodes } } ); |
381 |
my @unexpected_items; |
382 |
my @missing_items; |
383 |
my @bundle_items; |
384 |
while ( my $verify_item = $verify_items->next ) { |
385 |
# Fix and lost statuses |
386 |
$verify_item->itemlost(0); |
387 |
|
388 |
# Update last_seen |
389 |
$verify_item->datelastseen( dt_from_string()->ymd() ); |
390 |
|
391 |
# Update last_borrowed if actual checkin |
392 |
$verify_item->datelastborrowed( dt_from_string()->ymd() ) if $issue; |
393 |
|
394 |
# Expected item, remove from lookup table |
395 |
if ( delete $expected_items->{$verify_item->barcode} ) { |
396 |
push @bundle_items, $verify_item; |
397 |
} |
398 |
# Unexpected item, warn and remove from bundle |
399 |
else { |
400 |
$verify_item->remove_from_bundle; |
401 |
push @unexpected_items, $verify_item; |
402 |
} |
403 |
|
404 |
# Store results |
405 |
$verify_item->store(); |
406 |
} |
407 |
for my $missing_item ( keys %{$expected_items} ) { |
408 |
my $bundle_item = $expected_items->{$missing_item}; |
409 |
$bundle_item->itemlost($BundleLostValue)->store(); |
410 |
# Add return_claim record if this is an actual checkin |
411 |
if ($issue) { |
412 |
$bundle_item->_result->create_related( |
413 |
'return_claims', |
414 |
{ |
415 |
issue_id => $issue->issue_id, |
416 |
itemnumber => $bundle_item->itemnumber, |
417 |
borrowernumber => $issue->borrowernumber, |
418 |
created_by => C4::Context->userenv()->{number}, |
419 |
created_on => dt_from_string |
420 |
} |
421 |
); |
422 |
} |
423 |
push @missing_items, $bundle_item; |
424 |
# NOTE: We cannot use C4::LostItem here because the item itself doesn't have a checkout |
425 |
# and thus would not get charged.. it's checked out as part of the bundle. |
426 |
if ( C4::Context->preference('WhenLostChargeReplacementFee') && $issue ) { |
427 |
C4::Accounts::chargelostitem( |
428 |
$issue->borrowernumber, |
429 |
$bundle_item->itemnumber, |
430 |
$bundle_item->replacementprice, |
431 |
sprintf( "%s %s %s", |
432 |
$bundle_item->biblio->title || q{}, |
433 |
$bundle_item->barcode || q{}, |
434 |
$bundle_item->itemcallnumber || q{}, |
435 |
), |
436 |
); |
437 |
} |
438 |
} |
439 |
$template->param( |
440 |
unexpected_items => \@unexpected_items, |
441 |
missing_items => \@missing_items, |
442 |
bundle_items => \@bundle_items |
443 |
); |
444 |
} |
410 |
} |
445 |
} |
411 |
$template->param( inputloop => \@inputloop ); |
446 |
$template->param( inputloop => \@inputloop ); |
412 |
|
447 |
|