Browse Source

Bug 27945: Terminology: max daily => open requests limit

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
21.11.x
Tomas Cohen Arazi 2 months ago
committed by Jonathan Druart
parent
commit
788afd38c7
  1. 2
      Koha/CirculationRules.pm
  2. 2
      Koha/Patron.pm
  3. 28
      admin/smart-rules.pl
  4. 22
      koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt
  5. 4
      t/db_dependent/Koha/Patron.t

2
Koha/CirculationRules.pm

@ -76,7 +76,7 @@ our $RULE_KINDS = {
article_requests => {
scope => [ 'branchcode', 'categorycode', 'itemtype' ],
},
max_daily_article_requests => {
open_article_requests_limit => {
scope => [ 'branchcode', 'categorycode' ],
},

2
Koha/Patron.pm

@ -979,7 +979,7 @@ sub can_request_article {
{
branchcode => $library_id,
categorycode => $self->categorycode,
rule_name => 'max_daily_article_requests'
rule_name => 'open_article_requests_limit'
}
);

28
admin/smart-rules.pl

@ -458,27 +458,27 @@ 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') );
elsif ( $op eq "add-open-article-requests-limit" ) {
my $categorycode = $input->param('categorycode');
my $open_article_requests_limit = strip_non_numeric( scalar $input->param('open_article_requests_limit') );
Koha::Exceptions::Exception->throw("No value passed for article request limit")
if not defined $max_daily_article_requests # There is a JS check for that
|| $max_daily_article_requests eq '';
if not defined $open_article_requests_limit # There is a JS check for that
|| $open_article_requests_limit eq '';
if ( $branch eq "*" ) {
if ( $categorycode eq "*" ) {
Koha::CirculationRules->set_rules(
{ categorycode => undef,
branchcode => undef,
rules => { max_daily_article_requests => $max_daily_article_requests, }
rules => { open_article_requests_limit => $open_article_requests_limit, }
}
);
} else {
Koha::CirculationRules->set_rules(
{ categorycode => $categorycode,
branchcode => undef,
rules => { max_daily_article_requests => $max_daily_article_requests, }
rules => { open_article_requests_limit => $open_article_requests_limit, }
}
);
}
@ -486,32 +486,32 @@ elsif ( $op eq "add-max-daily-article-requests" ) {
Koha::CirculationRules->set_rules(
{ categorycode => undef,
branchcode => $branch,
rules => { max_daily_article_requests => $max_daily_article_requests, }
rules => { open_article_requests_limit => $open_article_requests_limit, }
}
);
} else {
Koha::CirculationRules->set_rules(
{ categorycode => $categorycode,
branchcode => $branch,
rules => { max_daily_article_requests => $max_daily_article_requests, }
rules => { open_article_requests_limit => $open_article_requests_limit, }
}
);
}
} elsif ( $op eq 'del-max-daily-article-requests' ) {
} elsif ( $op eq 'del-open-article-requests-limit' ) {
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, }
rules => { open_article_requests_limit => undef, }
}
);
} else {
Koha::CirculationRules->set_rules(
{ categorycode => $categorycode,
branchcode => undef,
rules => { max_daily_article_requests => undef, }
rules => { open_article_requests_limit => undef, }
}
);
}
@ -519,14 +519,14 @@ elsif ( $op eq "add-max-daily-article-requests" ) {
Koha::CirculationRules->set_rules(
{ branchcode => $branch,
categorycode => undef,
rules => { max_daily_article_requests => undef, }
rules => { open_article_requests_limit => undef, }
}
);
} else {
Koha::CirculationRules->set_rules(
{ categorycode => $categorycode,
branchcode => $branch,
rules => { max_daily_article_requests => undef, }
rules => { open_article_requests_limit => undef, }
}
);
}

22
koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt

@ -788,15 +788,15 @@
[% END %]
[% IF Koha.Preference('ArticleRequests') %]
<div id="max-daily-article-requests-patron-category" class="container">
<div id="open-article-requests-limit-patron-category" class="container">
[% IF humanbranch %]
<h3>Article requests limits for [% Branches.GetName( humanbranch ) | html %]</h3>
<h3>Daily open article requests limit for [% Branches.GetName( humanbranch ) | html %]</h3>
[% ELSE %]
<h3>Default article requests limits</h3>
<h3>Default open article requests limit</h3>
[% END %]
<p>Specify the maximum number simultaneous current article requests a patron of a given category can have.</p>
<form id="set-article-requests-daily-limit" method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
<input type="hidden" name="op" value="add-max-daily-article-requests" />
<input type="hidden" name="op" value="add-open-article-requests-limit" />
<input type="hidden" name="branch" value="[% current_branch | html %]"/>
<table>
<tr>
@ -806,23 +806,23 @@
</tr>
[% FOREACH c IN categorycodes %]
[% NEXT UNLESS c %]
[% SET max_daily_article_requests = CirculationRules.Search( branchcode, c, undef, 'max_daily_article_requests' ) %]
[% SET open_article_requests_limit = CirculationRules.Search( branchcode, c, undef, 'open_article_requests_limit' ) %]
[% IF ( max_daily_article_requests.defined && max_daily_article_requests != '' ) %]
[% IF ( open_article_requests_limit.defined && open_article_requests_limit != '' ) %]
<tr>
<td>
[% Categories.GetName(c) | html %]
</td>
<td>
[% IF max_daily_article_requests.defined && max_daily_article_requests != '' %]
[% max_daily_article_requests | html %]
[% IF open_article_requests_limit.defined && open_article_requests_limit != '' %]
[% open_article_requests_limit | html %]
[% ELSE %]
<span>Unlimited</span>
[% END %]
</td>
<td class="actions">
<a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=del-max-daily-article-requests&amp;categorycode=[% c | html %]&amp;branch=[% current_branch | html %]"><i class="fa fa-trash"></i> Delete</a>
<a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=del-open-article-requests-limit&amp;categorycode=[% c | html %]&amp;branch=[% current_branch | html %]"><i class="fa fa-trash"></i> Delete</a>
</td>
</tr>
[% END %]
@ -835,7 +835,7 @@
[% END %]
</select>
</td>
<td><input name="max_daily_article_requests" size="3" type="text" /></td>
<td><input name="open_article_requests_limit" size="3" type="text" /></td>
<td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</td>
</tr>
</table>
@ -1231,7 +1231,7 @@
});
$("#set-article-requests-daily-limit").on("submit", function(){
if (! $("input[name='max_daily_article_requests'").val().length){
if (! $("input[name='open_article_requests_limit'").val().length){
alert("Please set a daily limit for this patron's category");
return false;
}

4
t/db_dependent/Koha/Patron.t

@ -738,7 +738,7 @@ subtest 'can_request_article() tests' => sub {
{
categorycode => undef,
branchcode => $library_1->id,
rule_name => 'max_daily_article_requests',
rule_name => 'open_article_requests_limit',
rule_value => 4,
}
);
@ -802,7 +802,7 @@ subtest 'can_request_article() tests' => sub {
{
categorycode => undef,
branchcode => $library_2->id,
rule_name => 'max_daily_article_requests',
rule_name => 'open_article_requests_limit',
rule_value => 3,
}
);

Loading…
Cancel
Save