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