Lines 1006-1012
sub CanBookBeIssued {
Link Here
|
1006 |
|
1006 |
|
1007 |
my $patron = Koha::Patrons->find( $issue->borrowernumber ); |
1007 |
my $patron = Koha::Patrons->find( $issue->borrowernumber ); |
1008 |
|
1008 |
|
1009 |
my ( $can_be_returned, $message ) = CanBookBeReturned( $item_unblessed, C4::Context->userenv->{branch} ); |
1009 |
my ( $can_be_returned, $message ) = CanBookBeReturned( $item_object, C4::Context->userenv->{branch} ); |
1010 |
|
1010 |
|
1011 |
if ( !$can_be_returned ) { |
1011 |
if ( !$can_be_returned ) { |
1012 |
$issuingimpossible{RETURN_IMPOSSIBLE} = 1; |
1012 |
$issuingimpossible{RETURN_IMPOSSIBLE} = 1; |
Lines 1364-1370
Check whether the item can be returned to the provided branch
Link Here
|
1364 |
|
1364 |
|
1365 |
=over 4 |
1365 |
=over 4 |
1366 |
|
1366 |
|
1367 |
=item C<$item> is a hash of item information as returned Koha::Items->find->unblessed (Temporary, should be a Koha::Item instead) |
1367 |
=item C<$item> is a Koha::Item object |
1368 |
|
1368 |
|
1369 |
=item C<$branch> is the branchcode where the return is taking place |
1369 |
=item C<$branch> is the branchcode where the return is taking place |
1370 |
|
1370 |
|
Lines 1387-1408
sub CanBookBeReturned {
Link Here
|
1387 |
my $allowreturntobranch = C4::Context->preference("AllowReturnToBranch") || 'anywhere'; |
1387 |
my $allowreturntobranch = C4::Context->preference("AllowReturnToBranch") || 'anywhere'; |
1388 |
|
1388 |
|
1389 |
# assume return is allowed to start |
1389 |
# assume return is allowed to start |
1390 |
my $allowed = 1; |
1390 |
my $allowed = 1; |
|
|
1391 |
my $to_branch = $branch; |
1391 |
my $message; |
1392 |
my $message; |
1392 |
|
1393 |
|
1393 |
# identify all cases where return is forbidden |
1394 |
# identify all cases where return is forbidden |
1394 |
if ( $allowreturntobranch eq 'homebranch' && $branch ne $item->{'homebranch'} ) { |
1395 |
if ( $allowreturntobranch eq 'homebranch' && $branch ne $item->homebranch ) { |
1395 |
$allowed = 0; |
1396 |
$allowed = 0; |
1396 |
$message = $item->{'homebranch'}; |
1397 |
$message = $to_branch = $item->homebranch; |
1397 |
} elsif ( $allowreturntobranch eq 'holdingbranch' && $branch ne $item->{'holdingbranch'} ) { |
1398 |
} elsif ( $allowreturntobranch eq 'holdingbranch' && $branch ne $item->holdingbranch ) { |
1398 |
$allowed = 0; |
1399 |
$allowed = 0; |
1399 |
$message = $item->{'holdingbranch'}; |
1400 |
$message = $to_branch = $item->holdingbranch; |
1400 |
} elsif ( $allowreturntobranch eq 'homeorholdingbranch' |
1401 |
} elsif ( $allowreturntobranch eq 'homeorholdingbranch' |
1401 |
&& $branch ne $item->{'homebranch'} |
1402 |
&& $branch ne $item->homebranch |
1402 |
&& $branch ne $item->{'holdingbranch'} ) |
1403 |
&& $branch ne $item->holdingbranch ) |
1403 |
{ |
1404 |
{ |
1404 |
$allowed = 0; |
1405 |
$allowed = 0; |
1405 |
$message = $item->{'homebranch'}; # FIXME: choice of homebranch is arbitrary |
1406 |
$message = $to_branch = $item->homebranch; # FIXME: choice of homebranch is arbitrary |
|
|
1407 |
} |
1408 |
|
1409 |
# Make sure there are no branch transfer limits between item's current |
1410 |
# branch (holdinbranch) and the return branch |
1411 |
my $to_library = Koha::Libraries->find($to_branch); |
1412 |
if ( !$item->can_be_transferred( { to => $to_library } ) ) { |
1413 |
$allowed = 0; |
1414 |
$message = $item->homebranch; |
1406 |
} |
1415 |
} |
1407 |
|
1416 |
|
1408 |
return ( $allowed, $message ); |
1417 |
return ( $allowed, $message ); |
Lines 1671-1677
sub AddIssue {
Link Here
|
1671 |
|
1680 |
|
1672 |
# This book is currently on loan, but not to the person |
1681 |
# This book is currently on loan, but not to the person |
1673 |
# who wants to borrow it now. mark it returned before issuing to the new borrower |
1682 |
# who wants to borrow it now. mark it returned before issuing to the new borrower |
1674 |
my ( $allowed, $message ) = CanBookBeReturned( $item_unblessed, C4::Context->userenv->{branch} ); |
1683 |
my ( $allowed, $message ) = CanBookBeReturned( $item_object, C4::Context->userenv->{branch} ); |
1675 |
return unless $allowed; |
1684 |
return unless $allowed; |
1676 |
AddReturn( $item_object->barcode, C4::Context->userenv->{'branch'} ); |
1685 |
AddReturn( $item_object->barcode, C4::Context->userenv->{'branch'} ); |
1677 |
|
1686 |
|
Lines 2130-2135
This book has was returned to the wrong branch. The value is a hashref
Link Here
|
2130 |
so that C<$messages->{Wrongbranch}->{Wrongbranch}> and C<$messages->{Wrongbranch}->{Rightbranch}> |
2139 |
so that C<$messages->{Wrongbranch}->{Wrongbranch}> and C<$messages->{Wrongbranch}->{Rightbranch}> |
2131 |
contain the branchcode of the incorrect and correct return library, respectively. |
2140 |
contain the branchcode of the incorrect and correct return library, respectively. |
2132 |
|
2141 |
|
|
|
2142 |
=item C<Transferlimit> |
2143 |
|
2144 |
A transfer limit exists between item's holding branch and the return branch. |
2145 |
|
2133 |
=item C<ResFound> |
2146 |
=item C<ResFound> |
2134 |
|
2147 |
|
2135 |
The item was reserved. The value is a reference-to-hash whose keys are |
2148 |
The item was reserved. The value is a reference-to-hash whose keys are |
Lines 2284-2295
sub AddReturn {
Link Here
|
2284 |
} |
2297 |
} |
2285 |
|
2298 |
|
2286 |
# check if the return is allowed at this branch |
2299 |
# check if the return is allowed at this branch |
2287 |
my ( $returnallowed, $message ) = CanBookBeReturned( $item->unblessed, $branch ); |
2300 |
my ( $returnallowed, $message ) = CanBookBeReturned( $item, $branch ); |
|
|
2301 |
|
2288 |
unless ($returnallowed) { |
2302 |
unless ($returnallowed) { |
2289 |
$messages->{'Wrongbranch'} = { |
2303 |
$messages->{'Wrongbranch'} = { |
2290 |
Wrongbranch => $branch, |
2304 |
Wrongbranch => $branch, |
2291 |
Rightbranch => $message |
2305 |
Rightbranch => $message |
2292 |
}; |
2306 |
} if $message; |
2293 |
$doreturn = 0; |
2307 |
$doreturn = 0; |
2294 |
my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); |
2308 |
my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); |
2295 |
$indexer->index_records( $item->biblionumber, "specialUpdate", "biblioserver" ); |
2309 |
$indexer->index_records( $item->biblionumber, "specialUpdate", "biblioserver" ); |
2296 |
- |
|
|