|
Lines 956-962
sub CanBookBeIssued {
Link Here
|
| 956 |
|
956 |
|
| 957 |
my $patron = Koha::Patrons->find( $issue->borrowernumber ); |
957 |
my $patron = Koha::Patrons->find( $issue->borrowernumber ); |
| 958 |
|
958 |
|
| 959 |
my ( $can_be_returned, $message ) = CanBookBeReturned( $item_unblessed, C4::Context->userenv->{branch} ); |
959 |
my ( $can_be_returned, $message ) = CanBookBeReturned( $item_object, C4::Context->userenv->{branch} ); |
| 960 |
|
960 |
|
| 961 |
unless ( $can_be_returned ) { |
961 |
unless ( $can_be_returned ) { |
| 962 |
$issuingimpossible{RETURN_IMPOSSIBLE} = 1; |
962 |
$issuingimpossible{RETURN_IMPOSSIBLE} = 1; |
|
Lines 1208-1214
Check whether the item can be returned to the provided branch
Link Here
|
| 1208 |
|
1208 |
|
| 1209 |
=over 4 |
1209 |
=over 4 |
| 1210 |
|
1210 |
|
| 1211 |
=item C<$item> is a hash of item information as returned Koha::Items->find->unblessed (Temporary, should be a Koha::Item instead) |
1211 |
=item C<$item> is a Koha::Item object |
| 1212 |
|
1212 |
|
| 1213 |
=item C<$branch> is the branchcode where the return is taking place |
1213 |
=item C<$branch> is the branchcode where the return is taking place |
| 1214 |
|
1214 |
|
|
Lines 1227-1252
Returns:
Link Here
|
| 1227 |
=cut |
1227 |
=cut |
| 1228 |
|
1228 |
|
| 1229 |
sub CanBookBeReturned { |
1229 |
sub CanBookBeReturned { |
| 1230 |
my ($item, $branch) = @_; |
1230 |
my ($item, $branch) = @_; |
| 1231 |
my $allowreturntobranch = C4::Context->preference("AllowReturnToBranch") || 'anywhere'; |
1231 |
my $allowreturntobranch = C4::Context->preference("AllowReturnToBranch") || 'anywhere'; |
| 1232 |
|
1232 |
|
| 1233 |
# assume return is allowed to start |
1233 |
# assume return is allowed to start |
| 1234 |
my $allowed = 1; |
1234 |
my $allowed = 1; |
| 1235 |
my $message; |
1235 |
my $to_branch = $branch; |
| 1236 |
|
1236 |
my $message; |
| 1237 |
# identify all cases where return is forbidden |
1237 |
|
| 1238 |
if ($allowreturntobranch eq 'homebranch' && $branch ne $item->{'homebranch'}) { |
1238 |
# identify all cases where return is forbidden |
| 1239 |
$allowed = 0; |
1239 |
if ($allowreturntobranch eq 'homebranch' && $branch ne $item->homebranch) { |
| 1240 |
$message = $item->{'homebranch'}; |
1240 |
$allowed = 0; |
| 1241 |
} elsif ($allowreturntobranch eq 'holdingbranch' && $branch ne $item->{'holdingbranch'}) { |
1241 |
$message = $to_branch = $item->homebranch; |
| 1242 |
$allowed = 0; |
1242 |
} elsif ($allowreturntobranch eq 'holdingbranch' && $branch ne $item->holdingbranch) { |
| 1243 |
$message = $item->{'holdingbranch'}; |
1243 |
$allowed = 0; |
| 1244 |
} elsif ($allowreturntobranch eq 'homeorholdingbranch' && $branch ne $item->{'homebranch'} && $branch ne $item->{'holdingbranch'}) { |
1244 |
$message = $to_branch = $item->holdingbranch; |
| 1245 |
$allowed = 0; |
1245 |
} elsif ($allowreturntobranch eq 'homeorholdingbranch' && $branch ne $item->homebranch && $branch ne $item->holdingbranch) { |
| 1246 |
$message = $item->{'homebranch'}; # FIXME: choice of homebranch is arbitrary |
1246 |
$allowed = 0; |
| 1247 |
} |
1247 |
$message = $to_branch = $item->homebranch; # FIXME: choice of homebranch is arbitrary |
| 1248 |
|
1248 |
} |
| 1249 |
return ($allowed, $message); |
1249 |
|
|
|
1250 |
# Make sure there are no branch transfer limits between item's current |
| 1251 |
# branch (holdinbranch) and the return branch |
| 1252 |
my $to_library = Koha::Libraries->find($to_branch); |
| 1253 |
if (!$item->can_be_transferred({ to => $to_library })) { |
| 1254 |
$allowed = 0; |
| 1255 |
$message = $item->homebranch; |
| 1256 |
} |
| 1257 |
|
| 1258 |
return ($allowed, $message); |
| 1250 |
} |
1259 |
} |
| 1251 |
|
1260 |
|
| 1252 |
=head2 CheckHighHolds |
1261 |
=head2 CheckHighHolds |
|
Lines 1470-1476
sub AddIssue {
Link Here
|
| 1470 |
if ( $actualissue and not $switch_onsite_checkout ) { |
1479 |
if ( $actualissue and not $switch_onsite_checkout ) { |
| 1471 |
# This book is currently on loan, but not to the person |
1480 |
# This book is currently on loan, but not to the person |
| 1472 |
# who wants to borrow it now. mark it returned before issuing to the new borrower |
1481 |
# who wants to borrow it now. mark it returned before issuing to the new borrower |
| 1473 |
my ( $allowed, $message ) = CanBookBeReturned( $item_unblessed, C4::Context->userenv->{branch} ); |
1482 |
my ( $allowed, $message ) = CanBookBeReturned( $item_object, C4::Context->userenv->{branch} ); |
| 1474 |
return unless $allowed; |
1483 |
return unless $allowed; |
| 1475 |
AddReturn( $item_object->barcode, C4::Context->userenv->{'branch'} ); |
1484 |
AddReturn( $item_object->barcode, C4::Context->userenv->{'branch'} ); |
| 1476 |
} |
1485 |
} |
|
Lines 1907-1912
This book has was returned to the wrong branch. The value is a hashref
Link Here
|
| 1907 |
so that C<$messages->{Wrongbranch}->{Wrongbranch}> and C<$messages->{Wrongbranch}->{Rightbranch}> |
1916 |
so that C<$messages->{Wrongbranch}->{Wrongbranch}> and C<$messages->{Wrongbranch}->{Rightbranch}> |
| 1908 |
contain the branchcode of the incorrect and correct return library, respectively. |
1917 |
contain the branchcode of the incorrect and correct return library, respectively. |
| 1909 |
|
1918 |
|
|
|
1919 |
=item C<Transferlimit> |
| 1920 |
|
| 1921 |
A transfer limit exists between item's holding branch and the return branch. |
| 1922 |
|
| 1910 |
=item C<ResFound> |
1923 |
=item C<ResFound> |
| 1911 |
|
1924 |
|
| 1912 |
The item was reserved. The value is a reference-to-hash whose keys are |
1925 |
The item was reserved. The value is a reference-to-hash whose keys are |
|
Lines 2030-2041
sub AddReturn {
Link Here
|
| 2030 |
} |
2043 |
} |
| 2031 |
|
2044 |
|
| 2032 |
# check if the return is allowed at this branch |
2045 |
# check if the return is allowed at this branch |
| 2033 |
my ($returnallowed, $message) = CanBookBeReturned($item->unblessed, $branch); |
2046 |
my ($returnallowed, $message) = CanBookBeReturned($item, $branch); |
|
|
2047 |
|
| 2034 |
unless ($returnallowed){ |
2048 |
unless ($returnallowed){ |
| 2035 |
$messages->{'Wrongbranch'} = { |
2049 |
$messages->{'Wrongbranch'} = { |
| 2036 |
Wrongbranch => $branch, |
2050 |
Wrongbranch => $branch, |
| 2037 |
Rightbranch => $message |
2051 |
Rightbranch => $message |
| 2038 |
}; |
2052 |
} if $message; |
|
|
2053 |
|
| 2039 |
$doreturn = 0; |
2054 |
$doreturn = 0; |
| 2040 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); |
2055 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); |
| 2041 |
$indexer->index_records( $item->biblionumber, "specialUpdate", "biblioserver" ); |
2056 |
$indexer->index_records( $item->biblionumber, "specialUpdate", "biblioserver" ); |
| 2042 |
- |
|
|