@@ -, +, @@ --- Koha/CirculationRules.pm | 4 ++ admin/smart-rules.pl | 69 +++++++++++++++++++ .../data/mysql/atomicupdate/bug_27945.pl | 16 +++++ .../prog/en/modules/admin/smart-rules.tt | 56 +++++++++++++++ 4 files changed, 145 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug_27945.pl --- a/Koha/CirculationRules.pm +++ a/Koha/CirculationRules.pm @@ -76,6 +76,10 @@ our $RULE_KINDS = { article_requests => { scope => [ 'branchcode', 'categorycode', 'itemtype' ], }, + max_daily_article_requests => { + scope => [ 'branchcode', 'categorycode' ], + }, + auto_renew => { scope => [ 'branchcode', 'categorycode', 'itemtype' ], }, --- a/admin/smart-rules.pl +++ a/admin/smart-rules.pl @@ -457,6 +457,75 @@ elsif ($op eq "add-branch-cat") { ); } } +elsif ( $op eq "add-max-daily-article-requests" ) { + my $categorycode = $input->param('categorycode'); + my $max_daily_article_requests = strip_non_numeric( scalar $input->param('max_daily_article_requests') ); + + if ( $branch eq "*" ) { + if ( $categorycode eq "*" ) { + Koha::CirculationRules->set_rules( + { categorycode => undef, + branchcode => undef, + rules => { max_daily_article_requests => $max_daily_article_requests, } + } + ); + } else { + Koha::CirculationRules->set_rules( + { categorycode => $categorycode, + branchcode => undef, + rules => { max_daily_article_requests => $max_daily_article_requests, } + } + ); + } + } elsif ( $categorycode eq "*" ) { + Koha::CirculationRules->set_rules( + { categorycode => undef, + branchcode => $branch, + rules => { max_daily_article_requests => $max_daily_article_requests, } + } + ); + } else { + Koha::CirculationRules->set_rules( + { categorycode => $categorycode, + branchcode => $branch, + rules => { max_daily_article_requests => $max_daily_article_requests, } + } + ); + } +} elsif ( $op eq 'del-max-daily-article-requests' ) { + my $categorycode = $input->param('categorycode'); + if ( $branch eq "*" ) { + if ( $categorycode eq "*" ) { + Koha::CirculationRules->set_rules( + { branchcode => undef, + categorycode => undef, + rules => { max_daily_article_requests => undef, } + } + ); + } else { + Koha::CirculationRules->set_rules( + { categorycode => $categorycode, + branchcode => undef, + rules => { max_daily_article_requests => undef, } + } + ); + } + } elsif ( $categorycode eq "*" ) { + Koha::CirculationRules->set_rules( + { branchcode => $branch, + categorycode => undef, + rules => { max_daily_article_requests => undef, } + } + ); + } else { + Koha::CirculationRules->set_rules( + { categorycode => $categorycode, + branchcode => $branch, + rules => { max_daily_article_requests => undef, } + } + ); + } +} elsif ($op eq "add-branch-item") { my $itemtype = $input->param('itemtype'); my $holdallowed = $input->param('holdallowed'); --- a/installer/data/mysql/atomicupdate/bug_27945.pl +++ a/installer/data/mysql/atomicupdate/bug_27945.pl @@ -0,0 +1,16 @@ +use Modern::Perl; + +return { + bug_number => "27945", + description => "Add max_daily_article_requests circulation rule", + up => sub { + my ($args) = @_; + my ($dbh) = @$args{qw(dbh)}; + + # Do you stuffs here + $dbh->do(q{ + INSERT IGNORE INTO circulation_rules (branchcode, categorycode, itemtype, rule_name, rule_value) + VALUES (NULL, NULL, NULL, 'max_daily_article_requests', NULL); + }); + }, + } --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt @@ -787,6 +787,62 @@ [% END %] + [% IF Koha.Preference('ArticleRequests') %] +
Specify the maximum number simultaneous current article requests a patron of a given category can have.
+ +