Lines 59-64
use Koha::Config::SysPrefs;
Link Here
|
59 |
use Koha::Charges::Fees; |
59 |
use Koha::Charges::Fees; |
60 |
use Koha::Util::SystemPreferences; |
60 |
use Koha::Util::SystemPreferences; |
61 |
use Koha::Checkouts::ReturnClaims; |
61 |
use Koha::Checkouts::ReturnClaims; |
|
|
62 |
use Koha::SearchEngine::Indexer; |
62 |
use Carp; |
63 |
use Carp; |
63 |
use List::MoreUtils qw( uniq any ); |
64 |
use List::MoreUtils qw( uniq any ); |
64 |
use Scalar::Util qw( looks_like_number ); |
65 |
use Scalar::Util qw( looks_like_number ); |
Lines 1880-1886
sub AddReturn {
Link Here
|
1880 |
. Dumper($issue->unblessed) . "\n"; |
1881 |
. Dumper($issue->unblessed) . "\n"; |
1881 |
} else { |
1882 |
} else { |
1882 |
$messages->{'NotIssued'} = $barcode; |
1883 |
$messages->{'NotIssued'} = $barcode; |
1883 |
$item->onloan(undef)->store if defined $item->onloan; |
1884 |
$item->onloan(undef)->store({skip_record_index=>1}) if defined $item->onloan; |
1884 |
|
1885 |
|
1885 |
# even though item is not on loan, it may still be transferred; therefore, get current branch info |
1886 |
# even though item is not on loan, it may still be transferred; therefore, get current branch info |
1886 |
$doreturn = 0; |
1887 |
$doreturn = 0; |
Lines 1908-1916
sub AddReturn {
Link Here
|
1908 |
if (defined $update_loc_rules->{_ALL_}) { |
1909 |
if (defined $update_loc_rules->{_ALL_}) { |
1909 |
if ($update_loc_rules->{_ALL_} eq '_PERM_') { $update_loc_rules->{_ALL_} = $item->permanent_location; } |
1910 |
if ($update_loc_rules->{_ALL_} eq '_PERM_') { $update_loc_rules->{_ALL_} = $item->permanent_location; } |
1910 |
if ($update_loc_rules->{_ALL_} eq '_BLANK_') { $update_loc_rules->{_ALL_} = ''; } |
1911 |
if ($update_loc_rules->{_ALL_} eq '_BLANK_') { $update_loc_rules->{_ALL_} = ''; } |
1911 |
if ( $item->location ne $update_loc_rules->{_ALL_}) { |
1912 |
if ( defined $item->location && $item->location ne $update_loc_rules->{_ALL_}) { |
1912 |
$messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{_ALL_} }; |
1913 |
$messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{_ALL_} }; |
1913 |
$item->location($update_loc_rules->{_ALL_})->store; |
1914 |
$item->location($update_loc_rules->{_ALL_})->store({skip_record_index=>1}); |
1914 |
} |
1915 |
} |
1915 |
} |
1916 |
} |
1916 |
else { |
1917 |
else { |
Lines 1919-1925
sub AddReturn {
Link Here
|
1919 |
if ( $update_loc_rules->{$key} eq '_BLANK_') { $update_loc_rules->{$key} = '' ;} |
1920 |
if ( $update_loc_rules->{$key} eq '_BLANK_') { $update_loc_rules->{$key} = '' ;} |
1920 |
if ( ($item->location eq $key && $item->location ne $update_loc_rules->{$key}) || ($key eq '_BLANK_' && $item->location eq '' && $update_loc_rules->{$key} ne '') ) { |
1921 |
if ( ($item->location eq $key && $item->location ne $update_loc_rules->{$key}) || ($key eq '_BLANK_' && $item->location eq '' && $update_loc_rules->{$key} ne '') ) { |
1921 |
$messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{$key} }; |
1922 |
$messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{$key} }; |
1922 |
$item->location($update_loc_rules->{$key})->store; |
1923 |
$item->location($update_loc_rules->{$key})->store({skip_record_index=>1}); |
1923 |
last; |
1924 |
last; |
1924 |
} |
1925 |
} |
1925 |
} |
1926 |
} |
Lines 1938-1944
sub AddReturn {
Link Here
|
1938 |
foreach my $key ( keys %$rules ) { |
1939 |
foreach my $key ( keys %$rules ) { |
1939 |
if ( $item->notforloan eq $key ) { |
1940 |
if ( $item->notforloan eq $key ) { |
1940 |
$messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$key} }; |
1941 |
$messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$key} }; |
1941 |
$item->notforloan($rules->{$key})->store({ log_action => 0 }); |
1942 |
$item->notforloan($rules->{$key})->store({ log_action => 0, skip_record_index => 1 }); |
1942 |
last; |
1943 |
last; |
1943 |
} |
1944 |
} |
1944 |
} |
1945 |
} |
Lines 1952-1958
sub AddReturn {
Link Here
|
1952 |
Wrongbranch => $branch, |
1953 |
Wrongbranch => $branch, |
1953 |
Rightbranch => $message |
1954 |
Rightbranch => $message |
1954 |
}; |
1955 |
}; |
1955 |
$doreturn = 0; |
1956 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); |
|
|
1957 |
$indexer->index_records( $item->biblionumber, "specialUpdate", "biblioserver" ); |
1956 |
return ( $doreturn, $messages, $issue, $patron_unblessed); |
1958 |
return ( $doreturn, $messages, $issue, $patron_unblessed); |
1957 |
} |
1959 |
} |
1958 |
|
1960 |
|
Lines 1972-1978
sub AddReturn {
Link Here
|
1972 |
|
1974 |
|
1973 |
if ($patron) { |
1975 |
if ($patron) { |
1974 |
eval { |
1976 |
eval { |
1975 |
MarkIssueReturned( $borrowernumber, $item->itemnumber, $return_date, $patron->privacy ); |
1977 |
MarkIssueReturned( $borrowernumber, $item->itemnumber, $return_date, $patron->privacy, { skip_record_index => 1} ); |
1976 |
}; |
1978 |
}; |
1977 |
unless ( $@ ) { |
1979 |
unless ( $@ ) { |
1978 |
if ( |
1980 |
if ( |
Lines 1988-2013
sub AddReturn {
Link Here
|
1988 |
} else { |
1990 |
} else { |
1989 |
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 ); |
1991 |
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 ); |
1990 |
|
1992 |
|
|
|
1993 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); |
1994 |
$indexer->index_records( $item->biblionumber, "specialUpdate", "biblioserver" ); |
1995 |
|
1991 |
return ( 0, { WasReturned => 0, DataCorrupted => 1 }, $issue, $patron_unblessed ); |
1996 |
return ( 0, { WasReturned => 0, DataCorrupted => 1 }, $issue, $patron_unblessed ); |
1992 |
} |
1997 |
} |
1993 |
|
1998 |
|
1994 |
# FIXME is the "= 1" right? This could be the borrower hash. |
1999 |
# FIXME is the "= 1" right? This could be the borrower hash. |
1995 |
$messages->{'WasReturned'} = 1; |
2000 |
$messages->{'WasReturned'} = 1; |
1996 |
|
2001 |
|
|
|
2002 |
} else { |
2003 |
$item->onloan(undef)->store({ log_action => 0 , skip_record_index => 1 }); |
1997 |
} |
2004 |
} |
1998 |
|
|
|
1999 |
$item->onloan(undef)->store({ log_action => 0 }); |
2000 |
} |
2005 |
} |
2001 |
|
2006 |
|
2002 |
# the holdingbranch is updated if the document is returned to another location. |
2007 |
# the holdingbranch is updated if the document is returned to another location. |
2003 |
# this is always done regardless of whether the item was on loan or not |
2008 |
# this is always done regardless of whether the item was on loan or not |
2004 |
my $item_holding_branch = $item->holdingbranch; |
2009 |
my $item_holding_branch = $item->holdingbranch; |
2005 |
if ($item->holdingbranch ne $branch) { |
2010 |
if ($item->holdingbranch ne $branch) { |
2006 |
$item->holdingbranch($branch)->store; |
2011 |
$item->holdingbranch($branch)->store({ skip_record_index => 1 }); |
2007 |
} |
2012 |
} |
2008 |
|
2013 |
|
2009 |
my $leave_item_lost = C4::Context->preference("BlockReturnOfLostItems") ? 1 : 0; |
2014 |
my $leave_item_lost = C4::Context->preference("BlockReturnOfLostItems") ? 1 : 0; |
2010 |
ModDateLastSeen( $item->itemnumber, $leave_item_lost ); |
2015 |
ModDateLastSeen( $item->itemnumber, $leave_item_lost, { skip_record_index => 1 } ); |
2011 |
|
2016 |
|
2012 |
# check if we have a transfer for this document |
2017 |
# check if we have a transfer for this document |
2013 |
my ($datesent,$frombranch,$tobranch) = GetTransfers( $item->itemnumber ); |
2018 |
my ($datesent,$frombranch,$tobranch) = GetTransfers( $item->itemnumber ); |
Lines 2144-2150
sub AddReturn {
Link Here
|
2144 |
)) { |
2149 |
)) { |
2145 |
$debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s, %s)", $item->itemnumber,$branch, $returnbranch, $transfer_trigger; |
2150 |
$debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s, %s)", $item->itemnumber,$branch, $returnbranch, $transfer_trigger; |
2146 |
$debug and warn "item: " . Dumper($item->unblessed); |
2151 |
$debug and warn "item: " . Dumper($item->unblessed); |
2147 |
ModItemTransfer($item->itemnumber, $branch, $returnbranch, $transfer_trigger); |
2152 |
ModItemTransfer($item->itemnumber, $branch, $returnbranch, $transfer_trigger, { skip_record_index => 1 }); |
2148 |
$messages->{'WasTransfered'} = 1; |
2153 |
$messages->{'WasTransfered'} = 1; |
2149 |
} else { |
2154 |
} else { |
2150 |
$messages->{'NeedsTransfer'} = $returnbranch; |
2155 |
$messages->{'NeedsTransfer'} = $returnbranch; |
Lines 2165-2176
sub AddReturn {
Link Here
|
2165 |
} |
2170 |
} |
2166 |
} |
2171 |
} |
2167 |
|
2172 |
|
|
|
2173 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); |
2174 |
$indexer->index_records( $item->biblionumber, "specialUpdate", "biblioserver" ); |
2175 |
|
2168 |
return ( $doreturn, $messages, $issue, ( $patron ? $patron->unblessed : {} )); |
2176 |
return ( $doreturn, $messages, $issue, ( $patron ? $patron->unblessed : {} )); |
2169 |
} |
2177 |
} |
2170 |
|
2178 |
|
2171 |
=head2 MarkIssueReturned |
2179 |
=head2 MarkIssueReturned |
2172 |
|
2180 |
|
2173 |
MarkIssueReturned($borrowernumber, $itemnumber, $returndate, $privacy); |
2181 |
MarkIssueReturned($borrowernumber, $itemnumber, $returndate, $privacy, [$params] ); |
2174 |
|
2182 |
|
2175 |
Unconditionally marks an issue as being returned by |
2183 |
Unconditionally marks an issue as being returned by |
2176 |
moving the C<issues> row to C<old_issues> and |
2184 |
moving the C<issues> row to C<old_issues> and |
Lines 2186-2195
Ideally, this function would be internal to C<C4::Circulation>,
Link Here
|
2186 |
not exported, but it is currently used in misc/cronjobs/longoverdue.pl |
2194 |
not exported, but it is currently used in misc/cronjobs/longoverdue.pl |
2187 |
and offline_circ/process_koc.pl. |
2195 |
and offline_circ/process_koc.pl. |
2188 |
|
2196 |
|
|
|
2197 |
The last optional parameter allos passing skip_record_index to the item store call. |
2198 |
|
2189 |
=cut |
2199 |
=cut |
2190 |
|
2200 |
|
2191 |
sub MarkIssueReturned { |
2201 |
sub MarkIssueReturned { |
2192 |
my ( $borrowernumber, $itemnumber, $returndate, $privacy ) = @_; |
2202 |
my ( $borrowernumber, $itemnumber, $returndate, $privacy, $params ) = @_; |
2193 |
|
2203 |
|
2194 |
# Retrieve the issue |
2204 |
# Retrieve the issue |
2195 |
my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return; |
2205 |
my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return; |
Lines 2235-2241
sub MarkIssueReturned {
Link Here
|
2235 |
# And finally delete the issue |
2245 |
# And finally delete the issue |
2236 |
$issue->delete; |
2246 |
$issue->delete; |
2237 |
|
2247 |
|
2238 |
$issue->item->onloan(undef)->store({ log_action => 0 }); |
2248 |
$issue->item->onloan(undef)->store({ log_action => 0, skip_record_index => $params->{skip_record_index} }); |
2239 |
|
2249 |
|
2240 |
if ( C4::Context->preference('StoreLastBorrower') ) { |
2250 |
if ( C4::Context->preference('StoreLastBorrower') ) { |
2241 |
my $item = Koha::Items->find( $itemnumber ); |
2251 |
my $item = Koha::Items->find( $itemnumber ); |