|
Lines 58-63
use Koha::Config::SysPrefs;
Link Here
|
| 58 |
use Koha::Charges::Fees; |
58 |
use Koha::Charges::Fees; |
| 59 |
use Koha::Util::SystemPreferences; |
59 |
use Koha::Util::SystemPreferences; |
| 60 |
use Koha::Checkouts::ReturnClaims; |
60 |
use Koha::Checkouts::ReturnClaims; |
|
|
61 |
use Koha::SearchEngine::Indexer; |
| 61 |
use Carp; |
62 |
use Carp; |
| 62 |
use List::MoreUtils qw( uniq any ); |
63 |
use List::MoreUtils qw( uniq any ); |
| 63 |
use Scalar::Util qw( looks_like_number ); |
64 |
use Scalar::Util qw( looks_like_number ); |
|
Lines 1887-1893
sub AddReturn {
Link Here
|
| 1887 |
. Dumper($issue->unblessed) . "\n"; |
1888 |
. Dumper($issue->unblessed) . "\n"; |
| 1888 |
} else { |
1889 |
} else { |
| 1889 |
$messages->{'NotIssued'} = $barcode; |
1890 |
$messages->{'NotIssued'} = $barcode; |
| 1890 |
$item->onloan(undef)->store if defined $item->onloan; |
1891 |
$item->onloan(undef)->store({skip_record_index=>1}) if defined $item->onloan; |
| 1891 |
|
1892 |
|
| 1892 |
# even though item is not on loan, it may still be transferred; therefore, get current branch info |
1893 |
# even though item is not on loan, it may still be transferred; therefore, get current branch info |
| 1893 |
$doreturn = 0; |
1894 |
$doreturn = 0; |
|
Lines 1915-1923
sub AddReturn {
Link Here
|
| 1915 |
if (defined $update_loc_rules->{_ALL_}) { |
1916 |
if (defined $update_loc_rules->{_ALL_}) { |
| 1916 |
if ($update_loc_rules->{_ALL_} eq '_PERM_') { $update_loc_rules->{_ALL_} = $item->permanent_location; } |
1917 |
if ($update_loc_rules->{_ALL_} eq '_PERM_') { $update_loc_rules->{_ALL_} = $item->permanent_location; } |
| 1917 |
if ($update_loc_rules->{_ALL_} eq '_BLANK_') { $update_loc_rules->{_ALL_} = ''; } |
1918 |
if ($update_loc_rules->{_ALL_} eq '_BLANK_') { $update_loc_rules->{_ALL_} = ''; } |
| 1918 |
if ( $item->location ne $update_loc_rules->{_ALL_}) { |
1919 |
if ( defined $item->location && $item->location ne $update_loc_rules->{_ALL_}) { |
| 1919 |
$messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{_ALL_} }; |
1920 |
$messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{_ALL_} }; |
| 1920 |
$item->location($update_loc_rules->{_ALL_})->store; |
1921 |
$item->location($update_loc_rules->{_ALL_})->store({skip_record_index=>1}); |
| 1921 |
} |
1922 |
} |
| 1922 |
} |
1923 |
} |
| 1923 |
else { |
1924 |
else { |
|
Lines 1926-1932
sub AddReturn {
Link Here
|
| 1926 |
if ( $update_loc_rules->{$key} eq '_BLANK_') { $update_loc_rules->{$key} = '' ;} |
1927 |
if ( $update_loc_rules->{$key} eq '_BLANK_') { $update_loc_rules->{$key} = '' ;} |
| 1927 |
if ( ($item->location eq $key && $item->location ne $update_loc_rules->{$key}) || ($key eq '_BLANK_' && $item->location eq '' && $update_loc_rules->{$key} ne '') ) { |
1928 |
if ( ($item->location eq $key && $item->location ne $update_loc_rules->{$key}) || ($key eq '_BLANK_' && $item->location eq '' && $update_loc_rules->{$key} ne '') ) { |
| 1928 |
$messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{$key} }; |
1929 |
$messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{$key} }; |
| 1929 |
$item->location($update_loc_rules->{$key})->store; |
1930 |
$item->location($update_loc_rules->{$key})->store({skip_record_index=>1}); |
| 1930 |
last; |
1931 |
last; |
| 1931 |
} |
1932 |
} |
| 1932 |
} |
1933 |
} |
|
Lines 1945-1951
sub AddReturn {
Link Here
|
| 1945 |
foreach my $key ( keys %$rules ) { |
1946 |
foreach my $key ( keys %$rules ) { |
| 1946 |
if ( $item->notforloan eq $key ) { |
1947 |
if ( $item->notforloan eq $key ) { |
| 1947 |
$messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$key} }; |
1948 |
$messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$key} }; |
| 1948 |
$item->notforloan($rules->{$key})->store({ log_action => 0 }); |
1949 |
$item->notforloan($rules->{$key})->store({ log_action => 0, skip_record_index => 1 }); |
| 1949 |
last; |
1950 |
last; |
| 1950 |
} |
1951 |
} |
| 1951 |
} |
1952 |
} |
|
Lines 1959-1965
sub AddReturn {
Link Here
|
| 1959 |
Wrongbranch => $branch, |
1960 |
Wrongbranch => $branch, |
| 1960 |
Rightbranch => $message |
1961 |
Rightbranch => $message |
| 1961 |
}; |
1962 |
}; |
| 1962 |
$doreturn = 0; |
1963 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); |
|
|
1964 |
$indexer->index_records( $item->biblionumber, "specialUpdate", "biblioserver" ); |
| 1963 |
return ( $doreturn, $messages, $issue, $patron_unblessed); |
1965 |
return ( $doreturn, $messages, $issue, $patron_unblessed); |
| 1964 |
} |
1966 |
} |
| 1965 |
|
1967 |
|
|
Lines 1979-1985
sub AddReturn {
Link Here
|
| 1979 |
|
1981 |
|
| 1980 |
if ($patron) { |
1982 |
if ($patron) { |
| 1981 |
eval { |
1983 |
eval { |
| 1982 |
MarkIssueReturned( $borrowernumber, $item->itemnumber, $return_date, $patron->privacy ); |
1984 |
MarkIssueReturned( $borrowernumber, $item->itemnumber, $return_date, $patron->privacy, { skip_record_index => 1} ); |
| 1983 |
}; |
1985 |
}; |
| 1984 |
unless ( $@ ) { |
1986 |
unless ( $@ ) { |
| 1985 |
if ( |
1987 |
if ( |
|
Lines 1995-2020
sub AddReturn {
Link Here
|
| 1995 |
} else { |
1997 |
} else { |
| 1996 |
carp "The checkin for the following issue failed, Please go to the about page, section 'data corrupted' to know how to fix this problem ($@)" . Dumper( $issue->unblessed ); |
1998 |
carp "The checkin for the following issue failed, Please go to the about page, section 'data corrupted' to know how to fix this problem ($@)" . Dumper( $issue->unblessed ); |
| 1997 |
|
1999 |
|
|
|
2000 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); |
| 2001 |
$indexer->index_records( $item->biblionumber, "specialUpdate", "biblioserver" ); |
| 2002 |
|
| 1998 |
return ( 0, { WasReturned => 0, DataCorrupted => 1 }, $issue, $patron_unblessed ); |
2003 |
return ( 0, { WasReturned => 0, DataCorrupted => 1 }, $issue, $patron_unblessed ); |
| 1999 |
} |
2004 |
} |
| 2000 |
|
2005 |
|
| 2001 |
# FIXME is the "= 1" right? This could be the borrower hash. |
2006 |
# FIXME is the "= 1" right? This could be the borrower hash. |
| 2002 |
$messages->{'WasReturned'} = 1; |
2007 |
$messages->{'WasReturned'} = 1; |
| 2003 |
|
2008 |
|
|
|
2009 |
} else { |
| 2010 |
$item->onloan(undef)->store({ log_action => 0 , skip_record_index => 1 }); |
| 2004 |
} |
2011 |
} |
| 2005 |
|
|
|
| 2006 |
$item->onloan(undef)->store({ log_action => 0 }); |
| 2007 |
} |
2012 |
} |
| 2008 |
|
2013 |
|
| 2009 |
# the holdingbranch is updated if the document is returned to another location. |
2014 |
# the holdingbranch is updated if the document is returned to another location. |
| 2010 |
# this is always done regardless of whether the item was on loan or not |
2015 |
# this is always done regardless of whether the item was on loan or not |
| 2011 |
if ($item->holdingbranch ne $branch) { |
2016 |
if ($item->holdingbranch ne $branch) { |
| 2012 |
$item->holdingbranch($branch)->store; |
2017 |
$item->holdingbranch($branch)->store({ skip_record_index => 1 }); |
| 2013 |
} |
2018 |
} |
| 2014 |
|
2019 |
|
| 2015 |
my $item_was_lost = $item->itemlost; |
2020 |
my $item_was_lost = $item->itemlost; |
| 2016 |
my $leave_item_lost = C4::Context->preference("BlockReturnOfLostItems") ? 1 : 0; |
2021 |
my $leave_item_lost = C4::Context->preference("BlockReturnOfLostItems") ? 1 : 0; |
| 2017 |
my $updated_item = ModDateLastSeen( $item->itemnumber, $leave_item_lost ); # will unset itemlost if needed |
2022 |
my $updated_item = ModDateLastSeen( $item->itemnumber, $leave_item_lost, { skip_record_index => 1 } ); # will unset itemlost if needed |
| 2018 |
|
2023 |
|
| 2019 |
# fix up the accounts..... |
2024 |
# fix up the accounts..... |
| 2020 |
if ( $item_was_lost ) { |
2025 |
if ( $item_was_lost ) { |
|
Lines 2139-2145
sub AddReturn {
Link Here
|
| 2139 |
)) { |
2144 |
)) { |
| 2140 |
$debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s, %s)", $item->itemnumber,$branch, $returnbranch, $transfer_trigger; |
2145 |
$debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s, %s)", $item->itemnumber,$branch, $returnbranch, $transfer_trigger; |
| 2141 |
$debug and warn "item: " . Dumper($item->unblessed); |
2146 |
$debug and warn "item: " . Dumper($item->unblessed); |
| 2142 |
ModItemTransfer($item->itemnumber, $branch, $returnbranch, $transfer_trigger); |
2147 |
ModItemTransfer($item->itemnumber, $branch, $returnbranch, $transfer_trigger, { skip_record_index => 1 }); |
| 2143 |
$messages->{'WasTransfered'} = 1; |
2148 |
$messages->{'WasTransfered'} = 1; |
| 2144 |
} else { |
2149 |
} else { |
| 2145 |
$messages->{'NeedsTransfer'} = $returnbranch; |
2150 |
$messages->{'NeedsTransfer'} = $returnbranch; |
|
Lines 2160-2165
sub AddReturn {
Link Here
|
| 2160 |
} |
2165 |
} |
| 2161 |
} |
2166 |
} |
| 2162 |
|
2167 |
|
|
|
2168 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); |
| 2169 |
$indexer->index_records( $item->biblionumber, "specialUpdate", "biblioserver" ); |
| 2170 |
|
| 2163 |
if ( $doreturn and $issue ) { |
2171 |
if ( $doreturn and $issue ) { |
| 2164 |
my $checkin = Koha::Old::Checkouts->find($issue->id); |
2172 |
my $checkin = Koha::Old::Checkouts->find($issue->id); |
| 2165 |
|
2173 |
|
|
Lines 2176-2182
sub AddReturn {
Link Here
|
| 2176 |
|
2184 |
|
| 2177 |
=head2 MarkIssueReturned |
2185 |
=head2 MarkIssueReturned |
| 2178 |
|
2186 |
|
| 2179 |
MarkIssueReturned($borrowernumber, $itemnumber, $returndate, $privacy); |
2187 |
MarkIssueReturned($borrowernumber, $itemnumber, $returndate, $privacy, [$params] ); |
| 2180 |
|
2188 |
|
| 2181 |
Unconditionally marks an issue as being returned by |
2189 |
Unconditionally marks an issue as being returned by |
| 2182 |
moving the C<issues> row to C<old_issues> and |
2190 |
moving the C<issues> row to C<old_issues> and |
|
Lines 2192-2201
Ideally, this function would be internal to C<C4::Circulation>,
Link Here
|
| 2192 |
not exported, but it is currently used in misc/cronjobs/longoverdue.pl |
2200 |
not exported, but it is currently used in misc/cronjobs/longoverdue.pl |
| 2193 |
and offline_circ/process_koc.pl. |
2201 |
and offline_circ/process_koc.pl. |
| 2194 |
|
2202 |
|
|
|
2203 |
The last optional parameter allos passing skip_record_index to the item store call. |
| 2204 |
|
| 2195 |
=cut |
2205 |
=cut |
| 2196 |
|
2206 |
|
| 2197 |
sub MarkIssueReturned { |
2207 |
sub MarkIssueReturned { |
| 2198 |
my ( $borrowernumber, $itemnumber, $returndate, $privacy ) = @_; |
2208 |
my ( $borrowernumber, $itemnumber, $returndate, $privacy, $params ) = @_; |
| 2199 |
|
2209 |
|
| 2200 |
# Retrieve the issue |
2210 |
# Retrieve the issue |
| 2201 |
my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return; |
2211 |
my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return; |
|
Lines 2241-2247
sub MarkIssueReturned {
Link Here
|
| 2241 |
# And finally delete the issue |
2251 |
# And finally delete the issue |
| 2242 |
$issue->delete; |
2252 |
$issue->delete; |
| 2243 |
|
2253 |
|
| 2244 |
$issue->item->onloan(undef)->store({ log_action => 0 }); |
2254 |
$issue->item->onloan(undef)->store({ log_action => 0, skip_record_index => $params->{skip_record_index} }); |
| 2245 |
|
2255 |
|
| 2246 |
if ( C4::Context->preference('StoreLastBorrower') ) { |
2256 |
if ( C4::Context->preference('StoreLastBorrower') ) { |
| 2247 |
my $item = Koha::Items->find( $itemnumber ); |
2257 |
my $item = Koha::Items->find( $itemnumber ); |