Bug 8945: Update lists help for 3.10
[koha_fer] / circ / returns.pl
index 83817a8..d93b7cd 100755 (executable)
@@ -28,7 +28,7 @@ script to execute returns of books
 =cut
 
 use strict;
-#use warnings; FIXME - Bug 2505
+use warnings;
 
 use CGI;
 use DateTime;
@@ -212,18 +212,13 @@ if ($barcode) {
         }
     }
 
-    if ( C4::Context->preference("ReturnToShelvingCart") ) {
-        my $item = GetItem( $itemnumber );
-        $item->{'location'} = 'CART';
-        ModItem( $item, $item->{'biblionumber'}, $item->{'itemnumber'} );
-    }
-
 #
 # save the return
 #
     ( $returned, $messages, $issueinformation, $borrower ) =
       AddReturn( $barcode, $userenv_branch, $exemptfine, $dropboxmode);     # do the return
-    my $homeorholdingbranchreturn = C4::Context->preference('HomeOrHoldingBranchReturn') or 'homebranch';
+    my $homeorholdingbranchreturn = C4::Context->preference('HomeOrHoldingBranchReturn');
+    $homeorholdingbranchreturn ||= 'homebranch';
 
     # get biblio description
     my $biblio = GetBiblioFromItemNumber($itemnumber);
@@ -249,7 +244,7 @@ if ($barcode) {
     );
 
     if ($returned) {
-        my $time_now = DateTime->now( time_zone => C4::Context->tz )->truncate( to => 'minutes');
+        my $time_now = DateTime->now( time_zone => C4::Context->tz )->truncate( to => 'minute');
         my $duedate = $issueinformation->{date_due}->strftime('%Y-%m-%d %H:%M');
         $returneditems{0}      = $barcode;
         $riborrowernumber{0}   = $borrower->{'borrowernumber'};
@@ -290,15 +285,6 @@ if ($barcode) {
         $input{duedate}   = 0;
         $returneditems{0} = $barcode;
         $riduedate{0}     = 0;
-        if ( $messages->{'wthdrawn'} ) {
-            $input{withdrawn}      = 1;
-            $input{borrowernumber} = 'Item Cancelled';  # FIXME: should be in display layer ?
-            $riborrowernumber{0}   = 'Item Cancelled';
-        }
-        else {
-            $input{borrowernumber} = ' ';  # This seems clearly bogus.
-            $riborrowernumber{0}   = ' ';
-        }
         push( @inputloop, \%input );
     }
 }
@@ -336,7 +322,6 @@ if ( $messages->{'Wrongbranch'} ){
 # case of wrong transfert, if the document wasn't transfered to the right library (according to branchtransfer (tobranch) BDD)
 
 if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) {
-    $messages->{'WrongTransfer'} = GetBranchName( $messages->{'WrongTransfer'} );
     $template->param(
         WrongTransfer  => 1,
         TransferWaitingAt => $messages->{'WrongTransfer'},
@@ -444,7 +429,7 @@ foreach my $code ( keys %$messages ) {
     }
     elsif ( $code eq 'wthdrawn' ) {
         $err{withdrawn} = 1;
-        $exit_required_p = 1;
+        $exit_required_p = 1 if C4::Context->preference("BlockReturnOfWithdrawnItems");
     }
     elsif ( ( $code eq 'IsPermanent' ) && ( not $messages->{'ResFound'} ) ) {
         if ( $messages->{'IsPermanent'} ne $userenv_branch ) {
@@ -579,6 +564,7 @@ foreach ( sort { $a <=> $b } keys %returneditems ) {
 
         #        my %ri;
         my $biblio = GetBiblioFromItemNumber(GetItemnumberFromBarcode($bar_code));
+        my $item   = GetItem( GetItemnumberFromBarcode($bar_code) );
         # fix up item type for display
         $biblio->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $biblio->{'itype'} : $biblio->{'itemtype'};
         $ri{itembiblionumber} = $biblio->{'biblionumber'};
@@ -590,6 +576,8 @@ foreach ( sort { $a <=> $b } keys %returneditems ) {
         $ri{ccode}            = $biblio->{'ccode'};
         $ri{itemnumber}       = $biblio->{'itemnumber'};
         $ri{barcode}          = $bar_code;
+        $ri{homebranch}       = $item->{'homebranch'};
+        $ri{holdingbranch}    = $item->{'holdingbranch'};
 
         $ri{location}         = $biblio->{'location'};
         my $shelfcode = $ri{'location'};
@@ -613,6 +601,7 @@ $template->param(
     dropboxdate    => output_pref($dropboxdate),
     overduecharges => $overduecharges,
     soundon        => C4::Context->preference("SoundOn"),
+    BlockReturnOfWithdrawnItems => C4::Context->preference("BlockReturnOfWithdrawnItems"),
 );
 
 ### Comment out rotating collections for now to allow it a little more time to bake