@@ -, +, @@ $ updatedatabase $ koha-mysql kohadev > SELECT * FROM circulation_rules WHERE rule_name='waiting_hold_cancellation'; should work, including library-specific and global/defualt settings. --- Koha/CirculationRules.pm | 4 + admin/smart-rules.pl | 33 ++++++++ .../data/mysql/atomicupdate/bug_22456.pl | 16 ++++ .../prog/en/modules/admin/smart-rules.tt | 83 +++++++++++++++++++ 4 files changed, 136 insertions(+) --- a/Koha/CirculationRules.pm +++ a/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' ], }, --- a/admin/smart-rules.pl +++ a/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( --- a/installer/data/mysql/atomicupdate/bug_22456.pl +++ a/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."; + } }, }; --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt @@ -845,6 +845,89 @@ [% END %] +
+ [% IF humanbranch %] +

Waiting hold cancellation policy for [% Branches.GetName( humanbranch ) | html %]

+ [% ELSE %] +

Default waiting hold cancellation policy

+ [% END %] +

Specify if waiting holds can be cancelled for a given patron category.

+
+ + + + + + + + + + [% FOREACH c IN categorycodes %] + [% SET c = '*' UNLESS c.defined AND c != '' %] + [% FOREACH i IN itemtypes %] + [% SET i = '*' UNLESS i.defined AND i != '' %] + + [% SET waiting_hold_cancellation = CirculationRules.Search( current_branch, c, i, 'waiting_hold_cancellation' ) %] + + [% IF ( waiting_hold_cancellation.defined && waiting_hold_cancellation != '' ) %] + + + + + + + [% END %] + [% END %] + [% END %] + + + + + + +
Patron categoryItem typeCancellation allowed 
+ [% IF c == '*' %] + All + [% ELSE %] + [% Categories.GetName(c) | html %] + [% END %] + + [% IF i == '*' %] + All + [% ELSE %] + [% ItemTypes.GetDescription(i,1) | html %] + [% END %] + + [% IF waiting_hold_cancellation %] + Yes + [% ELSE %] + No + [% END %] + + Delete +
+ + + + + +
+
+
+ [% IF Koha.Preference('ArticleRequests') %]
[% IF humanbranch %] --