From 2ccafb604601551094182b62deb62dfa88dab93a Mon Sep 17 00:00:00 2001 From: Eivin Giske Skaaren Date: Mon, 21 Sep 2015 21:45:24 +0000 Subject: [PATCH] Bug 14866: Make high holds work with different item types This patch adds the possibility to set decreased loan periods for high holds items in issuingrules via smart-rules.pl. If a rule exist with a value set for a high holds item and the decreaseLoanHighHolds syspref is active then the value of the rule will be used instead of the syspref value. To test: 1. Create testbranch, dump mysql as needed.. 2. Apply patch 3. Update database perl installer/data/mysql/updatedatabase.pl misc/devel/update_dbix_class_files.pl --db_name=koha_instance --db_user=koha_instance --db_passwd=thepassword 4. Enable decreaseLoanHighHolds sysprefs if not already active 5. Create rule for library/item in http://your_staff_client/cgi-bin/koha/admin/smart-rules.pl Set Decrease loan holds to your wanted value. 6. Check out an item with holds and see that the value from the rule is used instead of the syspref --- C4/Circulation.pm | 16 ++++++++++++++++ admin/smart-rules.pl | 2 ++ .../atomicupdate/bug_14866-add_decreaseloanholds.sql | 1 + .../intranet-tmpl/prog/en/modules/admin/smart-rules.tt | 5 ++++- 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug_14866-add_decreaseloanholds.sql diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 7bd789c..242d673 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1045,6 +1045,22 @@ sub CanBookBeIssued { }; } } + + # Decrease loan period for item if rule exist in smart-rules.pl + # Overrides decreaseLoanHighHoldsValue syspref + my $branch = _GetCircControlBranch($item,$borrower); + my $issuingrule = GetIssuingRule($borrower->{categorycode}, $item->{itype}, $branch); + my $issuedate = DateTime->now( time_zone => C4::Context->tz() ); + my $calendar = Koha::Calendar->new( branchcode => $branch ); + my $reduced_datedue = $calendar->addDate( $issuedate, $issuingrule->{decreaseloanholds} ); + + if ( defined($issuingrule->{decreaseloanholds}) ) { + $needsconfirmation{HIGHHOLDS} = { + num_holds => $num, + duration => $issuingrule->{decreaseloanholds}, + returndate => output_pref($reduced_datedue), + } + } } if ( diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl index fe0c9c2..ebd255b 100755 --- a/admin/smart-rules.pl +++ b/admin/smart-rules.pl @@ -160,6 +160,7 @@ elsif ($op eq 'add') { my $article_requests = $input->param('article_requests') || 'no'; my $overduefinescap = $input->param('overduefinescap') || undef; my $cap_fine_to_replacement_price = $input->param('cap_fine_to_replacement_price') eq 'on'; + my $decreaseloanholds = $input->param('decreaseloanholds'); $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty, $cap_fine_to_replacement_price"; my $params = { @@ -193,6 +194,7 @@ elsif ($op eq 'add') { overduefinescap => $overduefinescap, cap_fine_to_replacement_price => $cap_fine_to_replacement_price, article_requests => $article_requests, + decreaseloanholds => $decreaseloanholds, }; my $issuingrule = Koha::IssuingRules->find({categorycode => $bor, itemtype => $itemtype, branchcode => $br}); diff --git a/installer/data/mysql/atomicupdate/bug_14866-add_decreaseloanholds.sql b/installer/data/mysql/atomicupdate/bug_14866-add_decreaseloanholds.sql new file mode 100644 index 0000000..c041a1c --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_14866-add_decreaseloanholds.sql @@ -0,0 +1 @@ +ALTER TABLE issuingrules ADD decreaseloanholds INTEGER; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt index 86226cb..f4dd8bc 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt @@ -91,6 +91,7 @@ On shelf holds allowed Item level holds Article requests + Decrease loan holds (day) Rental discount (%) Actions @@ -200,6 +201,7 @@ Don't allow [% END %] + [% rule.decreaseloanholds %] [% IF rule.article_requests == 'no' %] No @@ -216,7 +218,6 @@ Edit Delete - [% END %] @@ -311,6 +312,7 @@ + @@ -348,6 +350,7 @@ On shelf holds allowed Item level holds Article requests + Decrease loan holds (day) Rental discount (%)   -- 2.1.4