diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm index 81590785e3..b9fc11c941 100644 --- a/Koha/CirculationRules.pm +++ b/Koha/CirculationRules.pm @@ -112,6 +112,10 @@ our $RULE_KINDS = { hardduedatecompare => { scope => [ 'branchcode', 'categorycode', 'itemtype' ], }, + waiting_hold_cancellation => { + scope => [ 'branchcode', 'categorycode', 'itemtype' ], + can_be_blank => 0, + }, holds_per_day => { scope => [ 'branchcode', 'categorycode', 'itemtype' ], }, diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl index b7f2ae643e..d8fffaf924 100755 --- a/admin/smart-rules.pl +++ b/admin/smart-rules.pl @@ -660,8 +660,41 @@ elsif ( $op eq 'mod-refund-lost-item-fee-rule' ) { } ); } +} elsif ( $op eq "set-waiting-hold-cancellation" ) { + + my $category = $input->param('waiting_hold_cancellation_category'); + my $itemtype = $input->param('waiting_hold_cancellation_itemtype'); + my $policy = strip_non_numeric( scalar $input->param('waiting_hold_cancellation_policy') ) + ? 1 + : 0; + + Koha::Exception->throw("No value passed for waiting holds cancellation policy") + if not defined $policy # There is a JS check for that + || $policy eq ''; + + Koha::CirculationRules->set_rules( + { categorycode => ( $category eq '*' ) ? undef : $category, + itemtype => ( $itemtype eq '*' ) ? undef : $itemtype, + branchcode => ( $branch eq '*' ) ? undef : $branch, + rules => { waiting_hold_cancellation => $policy }, + } + ); + +} elsif ( $op eq 'del-waiting-hold-cancellation' ) { + + my $category = $input->param('waiting_hold_cancellation_category'); + my $itemtype = $input->param('waiting_hold_cancellation_itemtype'); + + Koha::CirculationRules->set_rules( + { categorycode => ( $category eq '*' ) ? undef : $category, + itemtype => ( $itemtype eq '*' ) ? undef : $itemtype, + branchcode => ( $branch eq '*' ) ? undef : $branch, + rules => { waiting_hold_cancellation => undef }, + } + ); } + my $refundLostItemFeeRule = Koha::CirculationRules->find({ branchcode => ($branch eq '*') ? undef : $branch, rule_name => 'lostreturn' }); my $defaultLostItemFeeRule = Koha::CirculationRules->find({ branchcode => undef, rule_name => 'lostreturn' }); $template->param( diff --git a/installer/data/mysql/atomicupdate/bug_22456.pl b/installer/data/mysql/atomicupdate/bug_22456.pl index df6e42da84..d7cef277b2 100755 --- a/installer/data/mysql/atomicupdate/bug_22456.pl +++ b/installer/data/mysql/atomicupdate/bug_22456.pl @@ -17,5 +17,21 @@ return { ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; }); } + + my ($count) = $dbh->selectrow_array(q{ + SELECT COUNT(*) + FROM circulation_rules + WHERE rule_name = 'waiting_hold_cancellation' + }); + + unless ( $count ) { + $dbh->do(q{ + INSERT INTO circulation_rules (rule_name, rule_value) + VALUES ('waiting_hold_cancellation', 0) + }); + } + else { + say $out "Found already existing 'waiting_hold_cancellation' circulation rules on the DB. Please review."; + } }, }; 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 1e8bc8907e..6727885768 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 @@ -845,6 +845,89 @@ [% END %] +
Specify if waiting holds can be cancelled for a given patron category.
+ +