From 300279476709e983552c5dc38d5a7842eeb56dff Mon Sep 17 00:00:00 2001 From: Thibaud Guillot Date: Thu, 5 Jan 2023 16:30:27 +0100 Subject: [PATCH] Bug 8137: (follow-up) Rebased on master Made some adjustments to make the patch work, I tested it and apprently it works as expected but I'm interested in your feedback otherwise --- admin/smart-rules.pl | 8 +- .../Bug_8137-add-column-has_priority.pl | 17 ++ .../Bug_8137-add-column-has_priority.sql | 2 - .../prog/en/modules/admin/smart-rules.tt | 149 ++---------------- 4 files changed, 31 insertions(+), 145 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/Bug_8137-add-column-has_priority.pl delete mode 100644 installer/data/mysql/atomicupdate/Bug_8137-add-column-has_priority.sql diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl index e323aed9f2..3dfa880d28 100755 --- a/admin/smart-rules.pl +++ b/admin/smart-rules.pl @@ -71,7 +71,7 @@ if ($op eq 'delete') { my $itemtype = $input->param('itemtype'); my $categorycode = $input->param('categorycode'); my $has_priority = $input->param('has_priority') ? 1 : undef; - $debug and warn "deleting $1 $2 $branch"; + warn "deleting $1 $2 $branch"; Koha::CirculationRules->set_rules( { @@ -387,12 +387,12 @@ elsif ($op eq "set-branch-defaults") { branchcode => undef, has_priority => $has_priority, rules => { - patron_maxissueqty => $patron_maxissueqty, - patron_maxonsiteissueqty => $patron_maxonsiteissueqty, - patron_has_priority => $has_priority, + patron_maxissueqty => $patron_maxissueqty, + patron_maxonsiteissueqty => $patron_maxonsiteissueqty, } } ); + } else { Koha::CirculationRules->set_rules( { diff --git a/installer/data/mysql/atomicupdate/Bug_8137-add-column-has_priority.pl b/installer/data/mysql/atomicupdate/Bug_8137-add-column-has_priority.pl new file mode 100644 index 0000000000..85cdb1c89b --- /dev/null +++ b/installer/data/mysql/atomicupdate/Bug_8137-add-column-has_priority.pl @@ -0,0 +1,17 @@ + +use Modern::Perl; + +return { + bug_number => "BUG_NUMBER", + description => "A single line description", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + # Do you stuffs here + $dbh->do(q{ + ALTER TABLE circulation_rules ADD has_priority INT(1) DEFAULT NULL AFTER itemtype; + }); + # Print useful stuff here + say $out "Added column 'has_priority' to table circulation_rules"; + }, +}; diff --git a/installer/data/mysql/atomicupdate/Bug_8137-add-column-has_priority.sql b/installer/data/mysql/atomicupdate/Bug_8137-add-column-has_priority.sql deleted file mode 100644 index a368b4e69e..0000000000 --- a/installer/data/mysql/atomicupdate/Bug_8137-add-column-has_priority.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE circulation_rules ADD has_priority INT(1) DEFAULT NULL AFTER itemtype; -ALTER TABLE circulation_rules ADD KEY (branchcode , categorycode, itemtype, has_priority); 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 e22c224c3d..103791376a 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 @@ -117,7 +117,7 @@ Item type Actions Note - [% UNLESS humanbranch %]Has priority[% END %] + [% UNLESS humanbranch %] Has priority[% END %] Current checkouts allowed Current on-site checkouts allowed Loan period @@ -786,7 +786,7 @@ [% IF ( show_branch_cat_rule_form ) %]
-

[% IF humanbranch %]Checkout, hold policy by patron category for [% Branches.GetName( humanbranch ) | html %][% ELSE %]Default checkout, hold policy by patron category[% END %]

+

[% IF humanbranch %]Checkout, hold policy by patron category for [% Branches.GetName( humanbranch ) | html %][% ELSE %]Default checkout, hold policy by patron category[% END %]

For this library, you can specify the maximum number of loans that a patron of a given category can make, regardless of the item type.

@@ -855,13 +855,12 @@ [% END %] [% END %] - - - Delete - - - [% END %] - [% END %] + + Delete + + + [% END %] + [% END %] +   @@ -1301,136 +1301,7 @@ [% SET holdallowed = CirculationRules.Search( branchcode, undef, i.itemtype, 'holdallowed' ) %] [% SET hold_fulfillment_policy = CirculationRules.Search( branchcode, undef, i.itemtype, 'hold_fulfillment_policy' ) %] [% SET returnbranch = CirculationRules.Search( branchcode, undef, i.itemtype, 'returnbranch' ) %] - - - - - - - Unset - - - - -
- [% IF ( show_branch_cat_rule_form ) %] -
-

[% IF humanbranch %]Checkout, hold policy by patron category for [% Branches.GetName( humanbranch ) | html %][% ELSE %]Default checkout, hold policy by patron category[% END %]

-

For this library, you can specify the maximum number of loans that - a patron of a given category can make, regardless of the item type. -

-

If the total amount loanable for a given patron category is left blank, - no limit applies, except possibly for a limit you define for a specific item type. -

-

- Has priority: If checked, the rule will override those for all branches. Else - it behaves like a default one: used if no rule existe for the coresponding branch. -

-
- - - - - - - - - [% UNLESS humanbranch %][% END %] - - - [% FOREACH c IN categorycodes %] - [% NEXT UNLESS c %] - [% SET patron_maxissueqty = CirculationRules.Search( branchcode, c, undef, 'patron_maxissueqty' ) %] - [% SET patron_maxonsiteissueqty = CirculationRules.Search( branchcode, c, undef, 'patron_maxonsiteissueqty' ) %] - [% SET max_holds = CirculationRules.Search( branchcode, c, undef, 'max_holds' ) %] - - [% IF ( patron_maxissueqty.defined && patron_maxissueqty != '' ) || ( patron_maxonsiteissueqty.defined && patron_maxonsiteissueqty != '' ) || ( max_holds.defined && max_holds != '' ) %] - - - - - - [% UNLESS humanbranch %] - - [% END %] - - - - [% END %] - [% END %] - - - - - - [% UNLESS humanbranch %] - - [% END %] - - -
Patron categoryTotal current checkouts allowedTotal current on-site checkouts allowedTotal holds allowedHas priority 
- [% IF c == undef %] - Default - [% ELSE %] - [% Categories.GetName(c) | html %] - [% END %] - - [% IF patron_maxissueqty.defined && patron_maxissueqty != '' %] - [% patron_maxissueqty | html %] - [% ELSE %] - Unlimited - [% END %] - - [% IF patron_maxonsiteissueqty.defined && patron_maxonsiteissueqty != '' %] - [% patron_maxonsiteissueqty | html %] - [% ELSE %] - Unlimited - [% END %] - - [% IF max_holds.defined && max_holds != '' %] - [% max_holds | html %] - [% ELSE %] - Unlimited - [% END %] - - - - Delete -
- - - -
-
-
- [% END %] - + [% IF holdallowed || hold_fulfillment_policy || returnbranch %] -- 2.25.1