| 
      
            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 1913-1919
          sub AddReturn {
      
      
        Link Here
      
     | 
  
        
          | 1913 | 
                          . Dumper($issue->unblessed) . "\n";  | 
          1914 | 
                          . Dumper($issue->unblessed) . "\n";  | 
        
        
          | 1914 | 
              } else { | 
          1915 | 
              } else { | 
        
        
          | 1915 | 
                  $messages->{'NotIssued'} = $barcode; | 
          1916 | 
                  $messages->{'NotIssued'} = $barcode; | 
        
          
            
              | 1916 | 
                      $item->onloan(undef)->store if defined $item->onloan;  | 
              1917 | 
                      $item->onloan(undef)->store({skip_record_index=>1}) if defined $item->onloan; | 
            
        
          | 1917 | 
           | 
          1918 | 
           | 
        
        
          | 1918 | 
                  # even though item is not on loan, it may still be transferred;  therefore, get current branch info  | 
          1919 | 
                  # even though item is not on loan, it may still be transferred;  therefore, get current branch info  | 
        
        
          | 1919 | 
                  $doreturn = 0;  | 
          1920 | 
                  $doreturn = 0;  | 
        
  
    | 
      
            Lines 1941-1949
          sub AddReturn {
      
      
        Link Here
      
     | 
  
        
          | 1941 | 
                  if (defined $update_loc_rules->{_ALL_}) { | 
          1942 | 
                  if (defined $update_loc_rules->{_ALL_}) { | 
        
        
          | 1942 | 
                      if ($update_loc_rules->{_ALL_} eq '_PERM_') { $update_loc_rules->{_ALL_} = $item->permanent_location; } | 
          1943 | 
                      if ($update_loc_rules->{_ALL_} eq '_PERM_') { $update_loc_rules->{_ALL_} = $item->permanent_location; } | 
        
        
          | 1943 | 
                      if ($update_loc_rules->{_ALL_} eq '_BLANK_') { $update_loc_rules->{_ALL_} = ''; } | 
          1944 | 
                      if ($update_loc_rules->{_ALL_} eq '_BLANK_') { $update_loc_rules->{_ALL_} = ''; } | 
        
          
            
              | 1944 | 
                          if ( $item->location ne $update_loc_rules->{_ALL_}) { | 
              1945 | 
                          if ( defined $item->location && $item->location ne $update_loc_rules->{_ALL_}) { | 
            
        
          | 1945 | 
                          $messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{_ALL_} }; | 
          1946 | 
                          $messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{_ALL_} }; | 
        
          
            
              | 1946 | 
                              $item->location($update_loc_rules->{_ALL_})->store; | 
              1947 | 
                              $item->location($update_loc_rules->{_ALL_})->store({skip_record_index=>1}); | 
            
        
          | 1947 | 
                      }  | 
          1948 | 
                      }  | 
        
        
          | 1948 | 
                  }  | 
          1949 | 
                  }  | 
        
        
          | 1949 | 
                  else { | 
          1950 | 
                  else { | 
        
  
    | 
      
            Lines 1952-1958
          sub AddReturn {
      
      
        Link Here
      
     | 
  
        
          | 1952 | 
                          if ( $update_loc_rules->{$key} eq '_BLANK_') { $update_loc_rules->{$key} = '' ;} | 
          1953 | 
                          if ( $update_loc_rules->{$key} eq '_BLANK_') { $update_loc_rules->{$key} = '' ;} | 
        
        
          | 1953 | 
                          if ( ($item->location eq $key && $item->location ne $update_loc_rules->{$key}) || ($key eq '_BLANK_' && $item->location eq '' && $update_loc_rules->{$key} ne '') ) { | 
          1954 | 
                          if ( ($item->location eq $key && $item->location ne $update_loc_rules->{$key}) || ($key eq '_BLANK_' && $item->location eq '' && $update_loc_rules->{$key} ne '') ) { | 
        
        
          | 1954 | 
                              $messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{$key} }; | 
          1955 | 
                              $messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{$key} }; | 
        
          
            
              | 1955 | 
                                  $item->location($update_loc_rules->{$key})->store; | 
              1956 | 
                                  $item->location($update_loc_rules->{$key})->store({skip_record_index=>1}); | 
            
        
          | 1956 | 
                              last;  | 
          1957 | 
                              last;  | 
        
        
          | 1957 | 
                          }  | 
          1958 | 
                          }  | 
        
        
          | 1958 | 
                      }  | 
          1959 | 
                      }  | 
        
  
    | 
      
            Lines 1971-1977
          sub AddReturn {
      
      
        Link Here
      
     | 
  
        
          | 1971 | 
                      foreach my $key ( keys %$rules ) { | 
          1972 | 
                      foreach my $key ( keys %$rules ) { | 
        
        
          | 1972 | 
                          if ( $item->notforloan eq $key ) { | 
          1973 | 
                          if ( $item->notforloan eq $key ) { | 
        
        
          | 1973 | 
                              $messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$key} }; | 
          1974 | 
                              $messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$key} }; | 
        
          
            
              | 1974 | 
                                  $item->notforloan($rules->{$key})->store({ log_action => 0 }); | 
              1975 | 
                                  $item->notforloan($rules->{$key})->store({ log_action => 0, skip_record_index => 1 }); | 
            
        
          | 1975 | 
                              last;  | 
          1976 | 
                              last;  | 
        
        
          | 1976 | 
                          }  | 
          1977 | 
                          }  | 
        
        
          | 1977 | 
                      }  | 
          1978 | 
                      }  | 
        
  
    | 
      
            Lines 1985-1991
          sub AddReturn {
      
      
        Link Here
      
     | 
  
        
          | 1985 | 
                      Wrongbranch => $branch,  | 
          1986 | 
                      Wrongbranch => $branch,  | 
        
        
          | 1986 | 
                      Rightbranch => $message  | 
          1987 | 
                      Rightbranch => $message  | 
        
        
          | 1987 | 
                  };  | 
          1988 | 
                  };  | 
        
          
            
              | 1988 | 
                      $doreturn = 0;  | 
              1989 | 
                      my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); | 
            
            
               | 
               | 
              1990 | 
                      $indexer->index_records( $item->biblionumber, "specialUpdate", "biblioserver" );  | 
            
        
          | 1989 | 
                  return ( $doreturn, $messages, $issue, $patron_unblessed);  | 
          1991 | 
                  return ( $doreturn, $messages, $issue, $patron_unblessed);  | 
        
        
          | 1990 | 
              }  | 
          1992 | 
              }  | 
        
        
          | 1991 | 
           | 
          1993 | 
           | 
        
  
    | 
      
            Lines 2005-2011
          sub AddReturn {
      
      
        Link Here
      
     | 
  
        
          | 2005 | 
           | 
          2007 | 
           | 
        
        
          | 2006 | 
                  if ($patron) { | 
          2008 | 
                  if ($patron) { | 
        
        
          | 2007 | 
                      eval { | 
          2009 | 
                      eval { | 
        
          
            
              | 2008 | 
                              MarkIssueReturned( $borrowernumber, $item->itemnumber, $return_date, $patron->privacy );  | 
              2010 | 
                              MarkIssueReturned( $borrowernumber, $item->itemnumber, $return_date, $patron->privacy, { skip_record_index => 1} ); | 
            
        
          | 2009 | 
                      };  | 
          2011 | 
                      };  | 
        
        
          | 2010 | 
                      unless ( $@ ) { | 
          2012 | 
                      unless ( $@ ) { | 
        
        
          | 2011 | 
                          if (  | 
          2013 | 
                          if (  | 
        
  
    | 
      
            Lines 2021-2046
          sub AddReturn {
      
      
        Link Here
      
     | 
  
        
          | 2021 | 
                      } else { | 
          2023 | 
                      } else { | 
        
        
          | 2022 | 
                          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 );  | 
          2024 | 
                          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 );  | 
        
        
          | 2023 | 
           | 
          2025 | 
           | 
        
            
               | 
               | 
              2026 | 
                              my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); | 
            
            
              | 2027 | 
                              $indexer->index_records( $item->biblionumber, "specialUpdate", "biblioserver" );  | 
            
            
              | 2028 | 
               | 
            
        
          | 2024 | 
                          return ( 0, { WasReturned => 0, DataCorrupted => 1 }, $issue, $patron_unblessed ); | 
          2029 | 
                          return ( 0, { WasReturned => 0, DataCorrupted => 1 }, $issue, $patron_unblessed ); | 
        
        
          | 2025 | 
                      }  | 
          2030 | 
                      }  | 
        
        
          | 2026 | 
           | 
          2031 | 
           | 
        
        
          | 2027 | 
                      # FIXME is the "= 1" right?  This could be the borrower hash.  | 
          2032 | 
                      # FIXME is the "= 1" right?  This could be the borrower hash.  | 
        
        
          | 2028 | 
                      $messages->{'WasReturned'} = 1; | 
          2033 | 
                      $messages->{'WasReturned'} = 1; | 
        
        
          | 2029 | 
           | 
          2034 | 
           | 
        
            
               | 
               | 
              2035 | 
                      } else { | 
            
            
              | 2036 | 
                          $item->onloan(undef)->store({ log_action => 0 , skip_record_index => 1 }); | 
            
        
          | 2030 | 
                  }  | 
          2037 | 
                  }  | 
        
            
              | 2031 | 
               | 
               | 
               | 
            
            
              | 2032 | 
                      $item->onloan(undef)->store({ log_action => 0 }); | 
            
        
          | 2033 | 
              }  | 
          2038 | 
              }  | 
        
        
          | 2034 | 
           | 
          2039 | 
           | 
        
        
          | 2035 | 
              # the holdingbranch is updated if the document is returned to another location.  | 
          2040 | 
              # the holdingbranch is updated if the document is returned to another location.  | 
        
        
          | 2036 | 
              # this is always done regardless of whether the item was on loan or not  | 
          2041 | 
              # this is always done regardless of whether the item was on loan or not  | 
        
        
          | 2037 | 
              if ($item->holdingbranch ne $branch) { | 
          2042 | 
              if ($item->holdingbranch ne $branch) { | 
        
          
            
              | 2038 | 
                      $item->holdingbranch($branch)->store;  | 
              2043 | 
                      $item->holdingbranch($branch)->store({ skip_record_index => 1 }); | 
            
        
          | 2039 | 
              }  | 
          2044 | 
              }  | 
        
        
          | 2040 | 
           | 
          2045 | 
           | 
        
        
          | 2041 | 
              my $item_was_lost = $item->itemlost;  | 
          2046 | 
              my $item_was_lost = $item->itemlost;  | 
        
        
          | 2042 | 
              my $leave_item_lost = C4::Context->preference("BlockReturnOfLostItems") ? 1 : 0; | 
          2047 | 
              my $leave_item_lost = C4::Context->preference("BlockReturnOfLostItems") ? 1 : 0; | 
        
          
            
              | 2043 | 
                  my $updated_item = ModDateLastSeen( $item->itemnumber, $leave_item_lost ); # will unset itemlost if needed  | 
              2048 | 
                  my $updated_item = ModDateLastSeen( $item->itemnumber, $leave_item_lost, { skip_record_index => 1 } ); # will unset itemlost if needed | 
            
        
          | 2044 | 
           | 
          2049 | 
           | 
        
        
          | 2045 | 
              # fix up the accounts.....  | 
          2050 | 
              # fix up the accounts.....  | 
        
        
          | 2046 | 
              if ( $item_was_lost ) { | 
          2051 | 
              if ( $item_was_lost ) { | 
        
  
    | 
      
            Lines 2166-2172
          sub AddReturn {
      
      
        Link Here
      
     | 
  
        
          | 2166 | 
                     )) { | 
          2171 | 
                     )) { | 
        
        
          | 2167 | 
                      $debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s, %s)", $item->itemnumber,$branch, $returnbranch, $transfer_trigger;  | 
          2172 | 
                      $debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s, %s)", $item->itemnumber,$branch, $returnbranch, $transfer_trigger;  | 
        
        
          | 2168 | 
                      $debug and warn "item: " . Dumper($item->unblessed);  | 
          2173 | 
                      $debug and warn "item: " . Dumper($item->unblessed);  | 
        
          
            
              | 2169 | 
                          ModItemTransfer($item->itemnumber, $branch, $returnbranch, $transfer_trigger);  | 
              2174 | 
                          ModItemTransfer($item->itemnumber, $branch, $returnbranch, $transfer_trigger, { skip_record_index => 1 }); | 
            
        
          | 2170 | 
                      $messages->{'WasTransfered'} = 1; | 
          2175 | 
                      $messages->{'WasTransfered'} = 1; | 
        
        
          | 2171 | 
                  } else { | 
          2176 | 
                  } else { | 
        
        
          | 2172 | 
                      $messages->{'NeedsTransfer'} = $returnbranch; | 
          2177 | 
                      $messages->{'NeedsTransfer'} = $returnbranch; | 
        
  
    | 
      
            Lines 2187-2192
          sub AddReturn {
      
      
        Link Here
      
     | 
  
        
          | 2187 | 
                  }  | 
          2192 | 
                  }  | 
        
        
          | 2188 | 
              }  | 
          2193 | 
              }  | 
        
        
          | 2189 | 
           | 
          2194 | 
           | 
        
            
               | 
               | 
              2195 | 
                  my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); | 
            
            
              | 2196 | 
                  $indexer->index_records( $item->biblionumber, "specialUpdate", "biblioserver" );  | 
            
            
              | 2197 | 
               | 
            
        
          | 2190 | 
              if ( $doreturn and $issue ) { | 
          2198 | 
              if ( $doreturn and $issue ) { | 
        
        
          | 2191 | 
                  my $checkin = Koha::Old::Checkouts->find($issue->id);  | 
          2199 | 
                  my $checkin = Koha::Old::Checkouts->find($issue->id);  | 
        
        
          | 2192 | 
           | 
          2200 | 
           | 
        
  
    | 
      
            Lines 2203-2209
          sub AddReturn {
      
      
        Link Here
      
     | 
  
        
          | 2203 | 
           | 
          2211 | 
           | 
        
        
          | 2204 | 
          =head2 MarkIssueReturned  | 
          2212 | 
          =head2 MarkIssueReturned  | 
        
        
          | 2205 | 
           | 
          2213 | 
           | 
        
          
            
              | 2206 | 
                MarkIssueReturned($borrowernumber, $itemnumber, $returndate, $privacy);  | 
              2214 | 
                MarkIssueReturned($borrowernumber, $itemnumber, $returndate, $privacy, [$params] );  | 
            
        
          | 2207 | 
           | 
          2215 | 
           | 
        
        
          | 2208 | 
          Unconditionally marks an issue as being returned by  | 
          2216 | 
          Unconditionally marks an issue as being returned by  | 
        
        
          | 2209 | 
          moving the C<issues> row to C<old_issues> and  | 
          2217 | 
          moving the C<issues> row to C<old_issues> and  | 
        
  
    | 
      
            Lines 2219-2228
          Ideally, this function would be internal to C<C4::Circulation>,
      
      
        Link Here
      
     | 
  
        
          | 2219 | 
          not exported, but it is currently used in misc/cronjobs/longoverdue.pl  | 
          2227 | 
          not exported, but it is currently used in misc/cronjobs/longoverdue.pl  | 
        
        
          | 2220 | 
          and offline_circ/process_koc.pl.  | 
          2228 | 
          and offline_circ/process_koc.pl.  | 
        
        
          | 2221 | 
           | 
          2229 | 
           | 
        
            
               | 
               | 
              2230 | 
              The last optional parameter allos passing skip_record_index to the item store call.  | 
            
            
              | 2231 | 
               | 
            
        
          | 2222 | 
          =cut  | 
          2232 | 
          =cut  | 
        
        
          | 2223 | 
           | 
          2233 | 
           | 
        
        
          | 2224 | 
          sub MarkIssueReturned { | 
          2234 | 
          sub MarkIssueReturned { | 
        
          
            
              | 2225 | 
                  my ( $borrowernumber, $itemnumber, $returndate, $privacy ) = @_;  | 
              2235 | 
                  my ( $borrowernumber, $itemnumber, $returndate, $privacy, $params ) = @_;  | 
            
        
          | 2226 | 
           | 
          2236 | 
           | 
        
        
          | 2227 | 
              # Retrieve the issue  | 
          2237 | 
              # Retrieve the issue  | 
        
        
          | 2228 | 
              my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return; | 
          2238 | 
              my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return; | 
        
  
    | 
      
            Lines 2268-2274
          sub MarkIssueReturned {
      
      
        Link Here
      
     | 
  
        
          | 2268 | 
                  # And finally delete the issue  | 
          2278 | 
                  # And finally delete the issue  | 
        
        
          | 2269 | 
                  $issue->delete;  | 
          2279 | 
                  $issue->delete;  | 
        
        
          | 2270 | 
           | 
          2280 | 
           | 
        
          
            
              | 2271 | 
                      $issue->item->onloan(undef)->store({ log_action => 0 }); | 
              2281 | 
                      $issue->item->onloan(undef)->store({ log_action => 0, skip_record_index => $params->{skip_record_index} }); | 
            
        
          | 2272 | 
           | 
          2282 | 
           | 
        
        
          | 2273 | 
                  if ( C4::Context->preference('StoreLastBorrower') ) { | 
          2283 | 
                  if ( C4::Context->preference('StoreLastBorrower') ) { | 
        
        
          | 2274 | 
                      my $item = Koha::Items->find( $itemnumber );  | 
          2284 | 
                      my $item = Koha::Items->find( $itemnumber );  |