Bug 3387 - WITHDRAWN items shouldn't check in
authorKyle M Hall <kyle@bywatersolutions.com>
Tue, 17 Jul 2012 13:42:59 +0000 (09:42 -0400)
committerPaul Poulain <paul.poulain@biblibre.com>
Mon, 1 Oct 2012 15:07:53 +0000 (17:07 +0200)
Adds a system preference BlockReturnOfWithdrawnItems to control
whether or not Koha should allow a withdrawn item to be returned
or not.

Also fixes the behavior where Koha will attempt to use a withdrawn
item to fill a hold.

Test Plan:
1) Set BlockReturnOfWithdrawnItems to "Block" ( this is the default )
2) Check an item out to a patron
3) Mark item as withdrawn
4) Attempt to return the item, you should still see the item on the
   borrower's record
5) Set BlockReturnOfWithdrawnItems to "Don't Block"
6) Attempt to return the item, you should see the item is no longer
   on the borrower's record.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
C4/Circulation.pm
circ/returns.pl
installer/data/mysql/sysprefs.sql
installer/data/mysql/updatedatabase.pl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt

index 71e13bb..f80f109 100644 (file)
@@ -1745,7 +1745,7 @@ sub AddReturn {
 
     if ( $item->{'wthdrawn'} ) { # book has been cancelled
         $messages->{'wthdrawn'} = 1;
-        $doreturn = 0;
+        $doreturn = 0 if C4::Context->preference("BlockReturnOfWithdrawnItems");
     }
 
     # case of a return of document (deal with issues and holdingbranch)
@@ -1833,7 +1833,7 @@ sub AddReturn {
 
     # find reserves.....
     # if we don't have a reserve with the status W, we launch the Checkreserves routine
-    my ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->{'itemnumber'} );
+    my ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->{'itemnumber'} ) unless ( $item->{'wthdrawn'} );
     if ($resfound) {
           $resrec->{'ResFound'} = $resfound;
         $messages->{'ResFound'} = $resrec;
index 743bf18..d93b7cd 100755 (executable)
@@ -285,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} = '&nbsp;';  # This seems clearly bogus.
-            $riborrowernumber{0}   = '&nbsp;';
-        }
         push( @inputloop, \%input );
     }
 }
@@ -438,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 ) {
@@ -610,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
index ae2c4ee..0798834 100644 (file)
@@ -384,3 +384,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('
 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('AuthDisplayHierarchy','0','Display authority hierarchies','','YesNo');
 INSERT INTO systempreferences (variable,value,explanation,type) VALUES('OPACdidyoumean',NULL,'Did you mean? configuration for the OPAC. Do not change, as this is controlled by /cgi-bin/koha/admin/didyoumean.pl.','Free');
 INSERT INTO systempreferences (variable,value,explanation,type) VALUES('INTRAdidyoumean',NULL,'Did you mean? configuration for the Intranet. Do not change, as this is controlled by /cgi-bin/koha/admin/didyoumean.pl.','Free');
+INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('BlockReturnOfWithdrawnItems', '1', '0', 'If enabled, items that are marked as withdrawn cannot be returned.', 'YesNo');
index b8b4047..db35f3a 100755 (executable)
@@ -5988,6 +5988,13 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
     SetVersion($DBversion);
 }
 
+$DBversion ="3.09.00.059";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+    $dbh->do("INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('BlockReturnOfWithdrawnItems', '1', '0', 'If enabled, items that are marked as withdrawn cannot be returned.', 'YesNo');");
+    print "Upgrade to $DBversion done (Add system preference BlockReturnOfWithdrawnItems)\n";
+    SetVersion($DBversion);
+}
+
 =head1 FUNCTIONS
 
 =head2 TableExists($table)
index 531b878..ec5ff1e 100644 (file)
@@ -285,6 +285,13 @@ Circulation:
                   alert: "display a message"
                   nothing : "do nothing"
             - .
+    Checkin Policy:
+        -
+            - pref: BlockReturnOfWithdrawnItems
+              choices:
+                  yes: Block
+                  no: "Don't block"
+            - returning of items that have been withdrawn.
     Holds Policy:
         -
             - pref: AllowHoldPolicyOverride
index 917855d..050ebd3 100644 (file)
@@ -334,7 +334,12 @@ $(document).ready(function () {
                         <p class="problem">Item was lost, now found.</p>
                     [% END %]
                     [% IF ( errmsgloo.withdrawn ) %]
-                        <p class="problem">Item is withdrawn.</p>
+                        [% IF BlockReturnOfWithdrawnItems %]
+                           <h3>Cannot Check In</h3>
+                           <p class="problem">Item is withdrawn. <strong>NOT CHECKED IN</strong></p>
+                        [% ELSE %]
+                           <p class="problem">Item is withdrawn.</p>
+                        [% END %]
                     [% END %]
                     [% IF ( errmsgloo.debarred ) %]
                         <p class="problem"><a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% errmsgloo.debarborrowernumber %]">[% errmsgloo.debarname %]([% errmsgloo.debarcardnumber %])</a> is now debarred until [% errmsgloo.debarred | $KohaDates %] </p>