Bug 23686: Check onsite checkout when the last checkout was an onsite one
authorNicolas Legrand <nicolas.legrand@bulac.fr>
Fri, 27 Sep 2019 08:14:35 +0000 (10:14 +0200)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 3 Oct 2019 09:47:31 +0000 (10:47 +0100)
Prevent from checking again and again the onsite checkout box when
doing onsite checkouts in batches. If preceding checkout was an onsite
one, the box will be checked.

Test plan:

1. enable  OnSiteCheckouts
2. make your circulation rules able to checkout onsite
3. onsite checkout a document
4. you should return to the checkout page, the box isn't checked
5. apply patch
6. updatedatabase.pl
7. redo steps 3, it should again print a checkout page with an
   unchecked onsite checkout box
8. enable  OnSiteCheckoutAutoCheck system preference
9. redo step 3
10. when returning to the checkout page, the onsite checkout box
    should be already checked

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

circ/circulation.pl
installer/data/mysql/atomicupdate/bug_23686_autocheck_onsitecheckout.perl [new file with mode: 0644]
installer/data/mysql/sysprefs.sql
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt

index 74c42d8..c90b2ba 100755 (executable)
@@ -148,9 +148,12 @@ my $force_allow_issue = $query->param('forceallow') || 0;
 if (!C4::Auth::haspermission( C4::Context->userenv->{id} , { circulate => 'force_checkout' } )) {
     $force_allow_issue = 0;
 }
-
 my $onsite_checkout = $query->param('onsite_checkout');
 
+if (C4::Context->preference("OnSiteCheckoutAutoCheck") && $onsite_checkout eq "on") {
+    $template->param(onsite_checkout => $onsite_checkout);
+}
+
 my @failedrenews = $query->multi_param('failedrenew');    # expected to be itemnumbers
 our %renew_failed = ();
 for (@failedrenews) { $renew_failed{$_} = 1; }
diff --git a/installer/data/mysql/atomicupdate/bug_23686_autocheck_onsitecheckout.perl b/installer/data/mysql/atomicupdate/bug_23686_autocheck_onsitecheckout.perl
new file mode 100644 (file)
index 0000000..f486725
--- /dev/null
@@ -0,0 +1,8 @@
+$DBversion = 'XXX';
+if( CheckVersion( $DBversion ) ) {
+
+    $dbh->do(qq{
+        INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES
+        ('OnSiteCheckoutAutoCheck','0','','onsite Checkout by default if last checkout was an onsite checkout box','YesNo')
+    });
+}
index 5b91642..32ebc35 100644 (file)
@@ -243,6 +243,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
 ('RecordedBooksLibraryID','','','Library ID for RecordedBooks integration','Integer'),
 ('OnSiteCheckouts','0','','Enable/Disable the on-site checkouts feature','YesNo'),
 ('OnSiteCheckoutsForce','0','','Enable/Disable the on-site for all cases (Even if a user is debarred, etc.)','YesNo'),
+('OnSiteCheckoutAutoCheck','0','','onsite Checkout by default if last checkout was an onsite checkout box','YesNo'),
 ('INTRAdidyoumean','',NULL,'Did you mean? configuration for the Intranet. Do not change, as this is controlled by /cgi-bin/koha/admin/didyoumean.pl.','Free'),
 ('IntranetBiblioDefaultView','normal','normal|marc|isbd|labeled_marc','Choose the default detail view in the staff interface; choose between normal, labeled_marc, marc or isbd','Choice'),
 ('intranetbookbag','1','','If ON, enables display of Cart feature in the intranet','YesNo'),
index d5ea265..915d991 100644 (file)
@@ -160,6 +160,12 @@ Circulation:
 
     Checkout Policy:
         -
+            - pref: OnSiteCheckoutAutoCheck
+              choices:
+                  yes: Enable
+                  no: Don't enable
+            - onsite checkout by default if last checkout was an onsite one
+        -
             - pref: AutoReturnCheckedOutItems
               choices:
                   yes: Don't
index 5fb4889..8680344 100644 (file)
                                                                     <input type="hidden" name="onsite_checkout" checked="checked" value="1" />
                                                                 </div>
                                                             [% ELSE %]
+                                                                [% IF Koha.Preference('OnSiteCheckoutAutoCheck') && onsite_checkout == "on" %]
+                                                                <input type="checkbox" id="onsite_checkout" name="onsite_checkout" class="circ_setting" checked="checked" /> <label for="onsite_checkout">On-site checkout</label>
+                                                                [% ELSE %]
                                                                 <input type="checkbox" id="onsite_checkout" name="onsite_checkout" class="circ_setting" /> <label for="onsite_checkout">On-site checkout</label>
+                                                                [% END %]
                                                             [% END %]
                                                         </div>
                                                     [% END %]