Lines 993-999
sub CanBookBeIssued {
Link Here
|
993 |
|
993 |
|
994 |
my $patron = Koha::Patrons->find( $issue->borrowernumber ); |
994 |
my $patron = Koha::Patrons->find( $issue->borrowernumber ); |
995 |
|
995 |
|
996 |
my ( $can_be_returned, $message ) = CanBookBeReturned( $item_unblessed, C4::Context->userenv->{branch} ); |
996 |
my ( $can_be_returned, $message ) = CanBookBeReturned( $item_object, C4::Context->userenv->{branch} ); |
997 |
|
997 |
|
998 |
if ( !$can_be_returned ) { |
998 |
if ( !$can_be_returned ) { |
999 |
$issuingimpossible{RETURN_IMPOSSIBLE} = 1; |
999 |
$issuingimpossible{RETURN_IMPOSSIBLE} = 1; |
Lines 1343-1349
Check whether the item can be returned to the provided branch
Link Here
|
1343 |
|
1343 |
|
1344 |
=over 4 |
1344 |
=over 4 |
1345 |
|
1345 |
|
1346 |
=item C<$item> is a hash of item information as returned Koha::Items->find->unblessed (Temporary, should be a Koha::Item instead) |
1346 |
=item C<$item> is a Koha::Item object |
1347 |
|
1347 |
|
1348 |
=item C<$branch> is the branchcode where the return is taking place |
1348 |
=item C<$branch> is the branchcode where the return is taking place |
1349 |
|
1349 |
|
Lines 1362-1387
Returns:
Link Here
|
1362 |
=cut |
1362 |
=cut |
1363 |
|
1363 |
|
1364 |
sub CanBookBeReturned { |
1364 |
sub CanBookBeReturned { |
1365 |
my ($item, $branch) = @_; |
1365 |
my ($item, $branch) = @_; |
1366 |
my $allowreturntobranch = C4::Context->preference("AllowReturnToBranch") || 'anywhere'; |
1366 |
my $allowreturntobranch = C4::Context->preference("AllowReturnToBranch") || 'anywhere'; |
1367 |
|
1367 |
|
1368 |
# assume return is allowed to start |
1368 |
# assume return is allowed to start |
1369 |
my $allowed = 1; |
1369 |
my $allowed = 1; |
1370 |
my $message; |
1370 |
my $to_branch = $branch; |
1371 |
|
1371 |
my $message; |
1372 |
# identify all cases where return is forbidden |
1372 |
|
1373 |
if ($allowreturntobranch eq 'homebranch' && $branch ne $item->{'homebranch'}) { |
1373 |
# identify all cases where return is forbidden |
1374 |
$allowed = 0; |
1374 |
if ($allowreturntobranch eq 'homebranch' && $branch ne $item->homebranch) { |
1375 |
$message = $item->{'homebranch'}; |
1375 |
$allowed = 0; |
1376 |
} elsif ($allowreturntobranch eq 'holdingbranch' && $branch ne $item->{'holdingbranch'}) { |
1376 |
$message = $to_branch = $item->homebranch; |
1377 |
$allowed = 0; |
1377 |
} elsif ($allowreturntobranch eq 'holdingbranch' && $branch ne $item->holdingbranch) { |
1378 |
$message = $item->{'holdingbranch'}; |
1378 |
$allowed = 0; |
1379 |
} elsif ($allowreturntobranch eq 'homeorholdingbranch' && $branch ne $item->{'homebranch'} && $branch ne $item->{'holdingbranch'}) { |
1379 |
$message = $to_branch = $item->holdingbranch; |
1380 |
$allowed = 0; |
1380 |
} elsif ($allowreturntobranch eq 'homeorholdingbranch' && $branch ne $item->homebranch && $branch ne $item->holdingbranch) { |
1381 |
$message = $item->{'homebranch'}; # FIXME: choice of homebranch is arbitrary |
1381 |
$allowed = 0; |
1382 |
} |
1382 |
$message = $to_branch = $item->homebranch; # FIXME: choice of homebranch is arbitrary |
1383 |
|
1383 |
} |
1384 |
return ($allowed, $message); |
1384 |
|
|
|
1385 |
# Make sure there are no branch transfer limits between item's current |
1386 |
# branch (holdinbranch) and the return branch |
1387 |
my $to_library = Koha::Libraries->find($to_branch); |
1388 |
if (!$item->can_be_transferred({ to => $to_library })) { |
1389 |
$allowed = 0; |
1390 |
$message = $item->homebranch; |
1391 |
} |
1392 |
|
1393 |
return ($allowed, $message); |
1385 |
} |
1394 |
} |
1386 |
|
1395 |
|
1387 |
=head2 CheckHighHolds |
1396 |
=head2 CheckHighHolds |
Lines 1640-1646
sub AddIssue {
Link Here
|
1640 |
if ( $actualissue and not $switch_onsite_checkout ) { |
1649 |
if ( $actualissue and not $switch_onsite_checkout ) { |
1641 |
# This book is currently on loan, but not to the person |
1650 |
# This book is currently on loan, but not to the person |
1642 |
# who wants to borrow it now. mark it returned before issuing to the new borrower |
1651 |
# who wants to borrow it now. mark it returned before issuing to the new borrower |
1643 |
my ( $allowed, $message ) = CanBookBeReturned( $item_unblessed, C4::Context->userenv->{branch} ); |
1652 |
my ( $allowed, $message ) = CanBookBeReturned( $item_object, C4::Context->userenv->{branch} ); |
1644 |
return unless $allowed; |
1653 |
return unless $allowed; |
1645 |
AddReturn( $item_object->barcode, C4::Context->userenv->{'branch'} ); |
1654 |
AddReturn( $item_object->barcode, C4::Context->userenv->{'branch'} ); |
1646 |
# AddReturn certainly has side-effects, like onloan => undef |
1655 |
# AddReturn certainly has side-effects, like onloan => undef |
Lines 2090-2095
This book has was returned to the wrong branch. The value is a hashref
Link Here
|
2090 |
so that C<$messages->{Wrongbranch}->{Wrongbranch}> and C<$messages->{Wrongbranch}->{Rightbranch}> |
2099 |
so that C<$messages->{Wrongbranch}->{Wrongbranch}> and C<$messages->{Wrongbranch}->{Rightbranch}> |
2091 |
contain the branchcode of the incorrect and correct return library, respectively. |
2100 |
contain the branchcode of the incorrect and correct return library, respectively. |
2092 |
|
2101 |
|
|
|
2102 |
=item C<Transferlimit> |
2103 |
|
2104 |
A transfer limit exists between item's holding branch and the return branch. |
2105 |
|
2093 |
=item C<ResFound> |
2106 |
=item C<ResFound> |
2094 |
|
2107 |
|
2095 |
The item was reserved. The value is a reference-to-hash whose keys are |
2108 |
The item was reserved. The value is a reference-to-hash whose keys are |
Lines 2242-2253
sub AddReturn {
Link Here
|
2242 |
} |
2255 |
} |
2243 |
|
2256 |
|
2244 |
# check if the return is allowed at this branch |
2257 |
# check if the return is allowed at this branch |
2245 |
my ($returnallowed, $message) = CanBookBeReturned($item->unblessed, $branch); |
2258 |
my ($returnallowed, $message) = CanBookBeReturned($item, $branch); |
|
|
2259 |
|
2246 |
unless ($returnallowed){ |
2260 |
unless ($returnallowed){ |
2247 |
$messages->{'Wrongbranch'} = { |
2261 |
$messages->{'Wrongbranch'} = { |
2248 |
Wrongbranch => $branch, |
2262 |
Wrongbranch => $branch, |
2249 |
Rightbranch => $message |
2263 |
Rightbranch => $message |
2250 |
}; |
2264 |
} if $message; |
2251 |
$doreturn = 0; |
2265 |
$doreturn = 0; |
2252 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); |
2266 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); |
2253 |
$indexer->index_records( $item->biblionumber, "specialUpdate", "biblioserver" ); |
2267 |
$indexer->index_records( $item->biblionumber, "specialUpdate", "biblioserver" ); |
2254 |
- |
|
|