From af2e0d4a7b5cd0141fa125eb1d41074394150947 Mon Sep 17 00:00:00 2001 From: Nicolas Legrand Date: Fri, 27 Sep 2019 10:14:35 +0200 Subject: [PATCH] Bug 23686 - Check onsite checkout when the last checkout was an onsite one 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 --- circ/circulation.pl | 5 ++++- .../mysql/atomicupdate/bug_23686_autocheck_onsitecheckout.perl | 8 ++++++++ installer/data/mysql/sysprefs.sql | 1 + .../prog/en/modules/admin/preferences/circulation.pref | 6 ++++++ koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt | 4 ++++ 5 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug_23686_autocheck_onsitecheckout.perl diff --git a/circ/circulation.pl b/circ/circulation.pl index 74c42d8..c90b2ba 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -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 index 0000000..f486725 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_23686_autocheck_onsitecheckout.perl @@ -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') + }); +} diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 5b91642..32ebc35 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -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'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref index d5ea265..915d991 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -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 diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index 5fb4889..8680344 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -600,7 +600,11 @@ [% ELSE %] + [% IF Koha.Preference('OnSiteCheckoutAutoCheck') && onsite_checkout == "on" %] + + [% ELSE %] + [% END %] [% END %] [% END %] -- 2.1.4