|
Lines 1018-1024
sub CanBookBeIssued {
Link Here
|
| 1018 |
|
1018 |
|
| 1019 |
my $patron = Koha::Patrons->find( $issue->borrowernumber ); |
1019 |
my $patron = Koha::Patrons->find( $issue->borrowernumber ); |
| 1020 |
|
1020 |
|
| 1021 |
my ( $can_be_returned, $message ) = CanBookBeReturned( $item_unblessed, C4::Context->userenv->{branch} ); |
1021 |
my ( $can_be_returned, $message ) = CanBookBeReturned( $item_object, C4::Context->userenv->{branch} ); |
| 1022 |
|
1022 |
|
| 1023 |
if ( !$can_be_returned ) { |
1023 |
if ( !$can_be_returned ) { |
| 1024 |
$issuingimpossible{RETURN_IMPOSSIBLE} = 1; |
1024 |
$issuingimpossible{RETURN_IMPOSSIBLE} = 1; |
|
Lines 1381-1387
Check whether the item can be returned to the provided branch
Link Here
|
| 1381 |
|
1381 |
|
| 1382 |
=over 4 |
1382 |
=over 4 |
| 1383 |
|
1383 |
|
| 1384 |
=item C<$item> is a hash of item information as returned Koha::Items->find->unblessed (Temporary, should be a Koha::Item instead) |
1384 |
=item C<$item> is a Koha::Item object |
| 1385 |
|
1385 |
|
| 1386 |
=item C<$branch> is the branchcode where the return is taking place |
1386 |
=item C<$branch> is the branchcode where the return is taking place |
| 1387 |
|
1387 |
|
|
Lines 1404-1425
sub CanBookBeReturned {
Link Here
|
| 1404 |
my $allowreturntobranch = C4::Context->preference("AllowReturnToBranch") || 'anywhere'; |
1404 |
my $allowreturntobranch = C4::Context->preference("AllowReturnToBranch") || 'anywhere'; |
| 1405 |
|
1405 |
|
| 1406 |
# assume return is allowed to start |
1406 |
# assume return is allowed to start |
| 1407 |
my $allowed = 1; |
1407 |
my $allowed = 1; |
|
|
1408 |
my $to_branch = $branch; |
| 1408 |
my $message; |
1409 |
my $message; |
| 1409 |
|
1410 |
|
| 1410 |
# identify all cases where return is forbidden |
1411 |
# identify all cases where return is forbidden |
| 1411 |
if ( $allowreturntobranch eq 'homebranch' && $branch ne $item->{'homebranch'} ) { |
1412 |
if ( $allowreturntobranch eq 'homebranch' && $branch ne $item->homebranch ) { |
| 1412 |
$allowed = 0; |
1413 |
$allowed = 0; |
| 1413 |
$message = $item->{'homebranch'}; |
1414 |
$message = $to_branch = $item->homebranch; |
| 1414 |
} elsif ( $allowreturntobranch eq 'holdingbranch' && $branch ne $item->{'holdingbranch'} ) { |
1415 |
} elsif ( $allowreturntobranch eq 'holdingbranch' && $branch ne $item->holdingbranch ) { |
| 1415 |
$allowed = 0; |
1416 |
$allowed = 0; |
| 1416 |
$message = $item->{'holdingbranch'}; |
1417 |
$message = $to_branch = $item->holdingbranch; |
| 1417 |
} elsif ( $allowreturntobranch eq 'homeorholdingbranch' |
1418 |
} elsif ( $allowreturntobranch eq 'homeorholdingbranch' |
| 1418 |
&& $branch ne $item->{'homebranch'} |
1419 |
&& $branch ne $item->homebranch |
| 1419 |
&& $branch ne $item->{'holdingbranch'} ) |
1420 |
&& $branch ne $item->holdingbranch ) |
| 1420 |
{ |
1421 |
{ |
| 1421 |
$allowed = 0; |
1422 |
$allowed = 0; |
| 1422 |
$message = $item->{'homebranch'}; # FIXME: choice of homebranch is arbitrary |
1423 |
$message = $to_branch = $item->homebranch; # FIXME: choice of homebranch is arbitrary |
|
|
1424 |
} |
| 1425 |
|
| 1426 |
# Make sure there are no branch transfer limits between item's current |
| 1427 |
# branch (holdinbranch) and the return branch |
| 1428 |
my $to_library = Koha::Libraries->find($to_branch); |
| 1429 |
if ( !$item->can_be_transferred( { to => $to_library } ) ) { |
| 1430 |
$allowed = 0; |
| 1431 |
$message = $item->homebranch; |
| 1423 |
} |
1432 |
} |
| 1424 |
|
1433 |
|
| 1425 |
return ( $allowed, $message ); |
1434 |
return ( $allowed, $message ); |
|
Lines 1696-1702
sub AddIssue {
Link Here
|
| 1696 |
|
1705 |
|
| 1697 |
# This book is currently on loan, but not to the person |
1706 |
# This book is currently on loan, but not to the person |
| 1698 |
# who wants to borrow it now. mark it returned before issuing to the new borrower |
1707 |
# who wants to borrow it now. mark it returned before issuing to the new borrower |
| 1699 |
my ( $allowed, $message ) = CanBookBeReturned( $item_unblessed, C4::Context->userenv->{branch} ); |
1708 |
my ( $allowed, $message ) = CanBookBeReturned( $item_object, C4::Context->userenv->{branch} ); |
| 1700 |
return unless $allowed; |
1709 |
return unless $allowed; |
| 1701 |
AddReturn( $item_object->barcode, C4::Context->userenv->{'branch'} ); |
1710 |
AddReturn( $item_object->barcode, C4::Context->userenv->{'branch'} ); |
| 1702 |
|
1711 |
|
|
Lines 2214-2219
This book has was returned to the wrong branch. The value is a hashref
Link Here
|
| 2214 |
so that C<$messages->{Wrongbranch}->{Wrongbranch}> and C<$messages->{Wrongbranch}->{Rightbranch}> |
2223 |
so that C<$messages->{Wrongbranch}->{Wrongbranch}> and C<$messages->{Wrongbranch}->{Rightbranch}> |
| 2215 |
contain the branchcode of the incorrect and correct return library, respectively. |
2224 |
contain the branchcode of the incorrect and correct return library, respectively. |
| 2216 |
|
2225 |
|
|
|
2226 |
=item C<Transferlimit> |
| 2227 |
|
| 2228 |
A transfer limit exists between item's holding branch and the return branch. |
| 2229 |
|
| 2217 |
=item C<ResFound> |
2230 |
=item C<ResFound> |
| 2218 |
|
2231 |
|
| 2219 |
The item was reserved. The value is a reference-to-hash whose keys are |
2232 |
The item was reserved. The value is a reference-to-hash whose keys are |
|
Lines 2368-2379
sub AddReturn {
Link Here
|
| 2368 |
} |
2381 |
} |
| 2369 |
|
2382 |
|
| 2370 |
# check if the return is allowed at this branch |
2383 |
# check if the return is allowed at this branch |
| 2371 |
my ( $returnallowed, $message ) = CanBookBeReturned( $item->unblessed, $branch ); |
2384 |
my ( $returnallowed, $message ) = CanBookBeReturned( $item, $branch ); |
|
|
2385 |
|
| 2372 |
unless ($returnallowed) { |
2386 |
unless ($returnallowed) { |
| 2373 |
$messages->{'Wrongbranch'} = { |
2387 |
$messages->{'Wrongbranch'} = { |
| 2374 |
Wrongbranch => $branch, |
2388 |
Wrongbranch => $branch, |
| 2375 |
Rightbranch => $message |
2389 |
Rightbranch => $message |
| 2376 |
}; |
2390 |
} if $message; |
| 2377 |
$doreturn = 0; |
2391 |
$doreturn = 0; |
| 2378 |
my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); |
2392 |
my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); |
| 2379 |
$indexer->index_records( $item->biblionumber, "specialUpdate", "biblioserver" ); |
2393 |
$indexer->index_records( $item->biblionumber, "specialUpdate", "biblioserver" ); |
| 2380 |
- |
|
|