From 9414c62415a7de4ce97ecb08546b4227c48808fa 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 | 6 +++++- 4 files changed, 24 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 e5f95f3..5ec20e7 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1021,6 +1021,22 @@ sub CanBookBeIssued { returndate => output_pref($returndate), }; } + + # 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 9ef6ef6..d1f3987 100755 --- a/admin/smart-rules.pl +++ b/admin/smart-rules.pl @@ -128,6 +128,7 @@ elsif ($op eq 'add') { my $rentaldiscount = $input->param('rentaldiscount'); my $opacitemholds = $input->param('opacitemholds') || 0; my $overduefinescap = $input->param('overduefinescap') || undef; + my $decreaseloanholds = $input->param('decreaseloanholds'); $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty"; my $schema = Koha::Database->new()->schema(); @@ -156,6 +157,7 @@ elsif ($op eq 'add') { onshelfholds => $onshelfholds, opacitemholds => $opacitemholds, overduefinescap => $overduefinescap, + decreaseloanholds => $decreaseloanholds, }; $rs->update_or_create($params); 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 84ffcd8..5b79724 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 @@ -158,6 +158,7 @@ for="tobranch">Clone these rules to:   @@ -222,7 +223,8 @@ for="tobranch">Clone these rules to: Edit Delete @@ -292,6 +294,7 @@ for="tobranch">Clone these rules to: Force + @@ -320,6 +323,7 @@ for="tobranch">Clone these rules to:   -- 1.7.10.4