|
Lines 980-986
sub CanBookBeIssued {
Link Here
|
| 980 |
|
980 |
|
| 981 |
my $patron = Koha::Patrons->find( $issue->borrowernumber ); |
981 |
my $patron = Koha::Patrons->find( $issue->borrowernumber ); |
| 982 |
|
982 |
|
| 983 |
my ( $can_be_returned, $message ) = CanBookBeReturned( $item_unblessed, C4::Context->userenv->{branch} ); |
983 |
my ( $can_be_returned, $message ) = CanBookBeReturned( $item_object, C4::Context->userenv->{branch} ); |
| 984 |
|
984 |
|
| 985 |
unless ( $can_be_returned ) { |
985 |
unless ( $can_be_returned ) { |
| 986 |
$issuingimpossible{RETURN_IMPOSSIBLE} = 1; |
986 |
$issuingimpossible{RETURN_IMPOSSIBLE} = 1; |
|
Lines 1294-1300
Check whether the item can be returned to the provided branch
Link Here
|
| 1294 |
|
1294 |
|
| 1295 |
=over 4 |
1295 |
=over 4 |
| 1296 |
|
1296 |
|
| 1297 |
=item C<$item> is a hash of item information as returned Koha::Items->find->unblessed (Temporary, should be a Koha::Item instead) |
1297 |
=item C<$item> is a Koha::Item object |
| 1298 |
|
1298 |
|
| 1299 |
=item C<$branch> is the branchcode where the return is taking place |
1299 |
=item C<$branch> is the branchcode where the return is taking place |
| 1300 |
|
1300 |
|
|
Lines 1313-1338
Returns:
Link Here
|
| 1313 |
=cut |
1313 |
=cut |
| 1314 |
|
1314 |
|
| 1315 |
sub CanBookBeReturned { |
1315 |
sub CanBookBeReturned { |
| 1316 |
my ($item, $branch) = @_; |
1316 |
my ($item, $branch) = @_; |
| 1317 |
my $allowreturntobranch = C4::Context->preference("AllowReturnToBranch") || 'anywhere'; |
1317 |
my $allowreturntobranch = C4::Context->preference("AllowReturnToBranch") || 'anywhere'; |
| 1318 |
|
1318 |
|
| 1319 |
# assume return is allowed to start |
1319 |
# assume return is allowed to start |
| 1320 |
my $allowed = 1; |
1320 |
my $allowed = 1; |
| 1321 |
my $message; |
1321 |
my $to_branch = $branch; |
| 1322 |
|
1322 |
my $message; |
| 1323 |
# identify all cases where return is forbidden |
1323 |
|
| 1324 |
if ($allowreturntobranch eq 'homebranch' && $branch ne $item->{'homebranch'}) { |
1324 |
# identify all cases where return is forbidden |
| 1325 |
$allowed = 0; |
1325 |
if ($allowreturntobranch eq 'homebranch' && $branch ne $item->homebranch) { |
| 1326 |
$message = $item->{'homebranch'}; |
1326 |
$allowed = 0; |
| 1327 |
} elsif ($allowreturntobranch eq 'holdingbranch' && $branch ne $item->{'holdingbranch'}) { |
1327 |
$message = $to_branch = $item->homebranch; |
| 1328 |
$allowed = 0; |
1328 |
} elsif ($allowreturntobranch eq 'holdingbranch' && $branch ne $item->holdingbranch) { |
| 1329 |
$message = $item->{'holdingbranch'}; |
1329 |
$allowed = 0; |
| 1330 |
} elsif ($allowreturntobranch eq 'homeorholdingbranch' && $branch ne $item->{'homebranch'} && $branch ne $item->{'holdingbranch'}) { |
1330 |
$message = $to_branch = $item->holdingbranch; |
| 1331 |
$allowed = 0; |
1331 |
} elsif ($allowreturntobranch eq 'homeorholdingbranch' && $branch ne $item->homebranch && $branch ne $item->holdingbranch) { |
| 1332 |
$message = $item->{'homebranch'}; # FIXME: choice of homebranch is arbitrary |
1332 |
$allowed = 0; |
| 1333 |
} |
1333 |
$message = $to_branch = $item->homebranch; # FIXME: choice of homebranch is arbitrary |
| 1334 |
|
1334 |
} |
| 1335 |
return ($allowed, $message); |
1335 |
|
|
|
1336 |
# Make sure there are no branch transfer limits between item's current |
| 1337 |
# branch (holdinbranch) and the return branch |
| 1338 |
my $to_library = Koha::Libraries->find($to_branch); |
| 1339 |
if (!$item->can_be_transferred({ to => $to_library })) { |
| 1340 |
$allowed = 0; |
| 1341 |
$message = $item->homebranch; |
| 1342 |
} |
| 1343 |
|
| 1344 |
return ($allowed, $message); |
| 1336 |
} |
1345 |
} |
| 1337 |
|
1346 |
|
| 1338 |
=head2 CheckHighHolds |
1347 |
=head2 CheckHighHolds |
|
Lines 1588-1594
sub AddIssue {
Link Here
|
| 1588 |
if ( $actualissue and not $switch_onsite_checkout ) { |
1597 |
if ( $actualissue and not $switch_onsite_checkout ) { |
| 1589 |
# This book is currently on loan, but not to the person |
1598 |
# This book is currently on loan, but not to the person |
| 1590 |
# who wants to borrow it now. mark it returned before issuing to the new borrower |
1599 |
# who wants to borrow it now. mark it returned before issuing to the new borrower |
| 1591 |
my ( $allowed, $message ) = CanBookBeReturned( $item_unblessed, C4::Context->userenv->{branch} ); |
1600 |
my ( $allowed, $message ) = CanBookBeReturned( $item_object, C4::Context->userenv->{branch} ); |
| 1592 |
return unless $allowed; |
1601 |
return unless $allowed; |
| 1593 |
AddReturn( $item_object->barcode, C4::Context->userenv->{'branch'} ); |
1602 |
AddReturn( $item_object->barcode, C4::Context->userenv->{'branch'} ); |
| 1594 |
# AddReturn certainly has side-effects, like onloan => undef |
1603 |
# AddReturn certainly has side-effects, like onloan => undef |
|
Lines 2018-2023
This book has was returned to the wrong branch. The value is a hashref
Link Here
|
| 2018 |
so that C<$messages->{Wrongbranch}->{Wrongbranch}> and C<$messages->{Wrongbranch}->{Rightbranch}> |
2027 |
so that C<$messages->{Wrongbranch}->{Wrongbranch}> and C<$messages->{Wrongbranch}->{Rightbranch}> |
| 2019 |
contain the branchcode of the incorrect and correct return library, respectively. |
2028 |
contain the branchcode of the incorrect and correct return library, respectively. |
| 2020 |
|
2029 |
|
|
|
2030 |
=item C<Transferlimit> |
| 2031 |
|
| 2032 |
A transfer limit exists between item's holding branch and the return branch. |
| 2033 |
|
| 2021 |
=item C<ResFound> |
2034 |
=item C<ResFound> |
| 2022 |
|
2035 |
|
| 2023 |
The item was reserved. The value is a reference-to-hash whose keys are |
2036 |
The item was reserved. The value is a reference-to-hash whose keys are |
|
Lines 2154-2165
sub AddReturn {
Link Here
|
| 2154 |
} |
2167 |
} |
| 2155 |
|
2168 |
|
| 2156 |
# check if the return is allowed at this branch |
2169 |
# check if the return is allowed at this branch |
| 2157 |
my ($returnallowed, $message) = CanBookBeReturned($item->unblessed, $branch); |
2170 |
my ($returnallowed, $message) = CanBookBeReturned($item, $branch); |
|
|
2171 |
|
| 2158 |
unless ($returnallowed){ |
2172 |
unless ($returnallowed){ |
| 2159 |
$messages->{'Wrongbranch'} = { |
2173 |
$messages->{'Wrongbranch'} = { |
| 2160 |
Wrongbranch => $branch, |
2174 |
Wrongbranch => $branch, |
| 2161 |
Rightbranch => $message |
2175 |
Rightbranch => $message |
| 2162 |
}; |
2176 |
} if $message; |
|
|
2177 |
|
| 2163 |
$doreturn = 0; |
2178 |
$doreturn = 0; |
| 2164 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); |
2179 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); |
| 2165 |
$indexer->index_records( $item->biblionumber, "specialUpdate", "biblioserver" ); |
2180 |
$indexer->index_records( $item->biblionumber, "specialUpdate", "biblioserver" ); |
| 2166 |
- |
|
|