Bugzilla – Attachment 128870 Details for
Bug 27946
Add a charge per article request to patron categories
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27946: Add article request fee to circulation rules
Bug-27946-Add-article-request-fee-to-circulation-r.patch (text/plain), 7.18 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-12-22 20:40:53 UTC
(
hide
)
Description:
Bug 27946: Add article request fee to circulation rules
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-12-22 20:40:53 UTC
Size:
7.18 KB
patch
obsolete
>From 591c319d204ac98b180df01abef0afc76837f24a Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 8 Nov 2021 15:32:36 -0300 >Subject: [PATCH] Bug 27946: Add article request fee to circulation rules > >This patch adds a new circulation rule: article requests fee. > >It can be set per library and category. > >To test: >1. Try setting sdifferent numeric values, change, and delete them >=> SUCCESS: Things work as expected >2. Make sure rules are loaded correctly when re-entering the circ rules > page >=> SUCCESS: All good >3. Verify the data on the DB is stored as it should on each of your > tests: > $ koha-mysql kohadev > > SELECT * FROM circulation_rules \ > WHERE rule_name='article_request_fee'; >=> SUCCESS: All good (remember NULL => 'All' in the UI) >4. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/CirculationRules.pm | 3 + > admin/smart-rules.pl | 27 ++++++++ > .../prog/en/modules/admin/smart-rules.tt | 69 ++++++++++++++++++- > 3 files changed, 98 insertions(+), 1 deletion(-) > >diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm >index eb66f5f1a0..d2a97d480d 100644 >--- a/Koha/CirculationRules.pm >+++ b/Koha/CirculationRules.pm >@@ -76,6 +76,9 @@ our $RULE_KINDS = { > article_requests => { > scope => [ 'branchcode', 'categorycode', 'itemtype' ], > }, >+ article_request_fee => { >+ scope => [ 'branchcode', 'categorycode' ], >+ }, > open_article_requests_limit => { > scope => [ 'branchcode', 'categorycode' ], > }, >diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl >index 31ed87a83a..8f429ec6ae 100755 >--- a/admin/smart-rules.pl >+++ b/admin/smart-rules.pl >@@ -531,6 +531,33 @@ elsif ( $op eq "add-open-article-requests-limit" ) { > ); > } > } >+elsif ( $op eq "set-article-request-fee" ) { >+ >+ my $category = $input->param('article_request_fee_category'); >+ my $fee = strip_non_numeric( scalar $input->param('article_request_fee') ); >+ >+ Koha::Exceptions::Exception->throw("No value passed for article request fee") >+ if not defined $fee # There is a JS check for that >+ || $fee eq ''; >+ >+ Koha::CirculationRules->set_rules( >+ { categorycode => ( $category eq '*' ) ? undef : $category, >+ branchcode => ( $branch eq '*' ) ? undef : $branch, >+ rules => { article_request_fee => $fee }, >+ } >+ ); >+ >+} elsif ( $op eq 'del-article-request-fee' ) { >+ >+ my $category = $input->param('article_request_fee_category'); >+ >+ Koha::CirculationRules->set_rules( >+ { categorycode => ( $category eq '*' ) ? undef : $category, >+ branchcode => ( $branch eq '*' ) ? undef : $branch, >+ rules => { article_request_fee => undef }, >+ } >+ ); >+} > elsif ($op eq "add-branch-item") { > my $itemtype = $input->param('itemtype'); > my $holdallowed = $input->param('holdallowed'); >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 2d24283cbc..ca0a7fd39f 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 >@@ -787,7 +787,7 @@ > </div> > [% END %] > >- [% IF Koha.Preference('ArticleRequests') %] >+[% IF Koha.Preference('ArticleRequests') %] > <div id="open-article-requests-limit-patron-category" class="container"> > [% IF humanbranch %] > <h3>Daily open article requests limit for [% Branches.GetName( humanbranch ) | html %]</h3> >@@ -841,7 +841,66 @@ > </table> > </form> > </div> >+ <div id="article-request-fee-category" class="container"> >+ [% IF humanbranch %] >+ <h3>Article request fees for [% Branches.GetName( humanbranch ) | html %]</h3> >+ [% ELSE %] >+ <h3>Default article request fees</h3> > [% END %] >+ <p>Specify the article request fee for a given patron category.</p> >+ <form id="set-article-request-fee" method="post" action="/cgi-bin/koha/admin/smart-rules.pl"> >+ <input type="hidden" name="op" value="set-article-request-fee" /> >+ <input type="hidden" name="branch" value="[% current_branch | html %]"/> >+ <table> >+ <tr> >+ <th>Patron category</th> >+ <th>Fee</th> >+ <th> </th> >+ </tr> >+ [% FOREACH c IN categorycodes %] >+ [% SET c = '*' UNLESS c.defined AND c != '' %] >+ >+ [% SET article_request_fee = CirculationRules.Search( current_branch, c, undef, 'article_request_fee' ) %] >+ >+ [% IF ( article_request_fee.defined && article_request_fee != '' ) %] >+ <tr> >+ <td> >+ [% IF c == '*' %] >+ <em>All</em> >+ [% ELSE %] >+ [% Categories.GetName(c) | html %] >+ [% END %] >+ </td> >+ <td> >+ [% IF article_request_fee.defined && article_request_fee != '' %] >+ [% article_request_fee | html %] >+ [% ELSE %] >+ <span>0</span> >+ [% END %] >+ </td> >+ <td class="actions"> >+ <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=del-article-request-fee&article_request_fee_category=[% c | uri %]&branch=[% current_branch | uri %]"><i class="fa fa-trash"></i> Delete</a> >+ </td> >+ </tr> >+ [% END %] >+ [% END %] >+ <tr> >+ <td> >+ <select name="article_request_fee_category" id="article_request_fee_category"> >+ <option value="*">All</option> >+ [% FOREACH patron_category IN patron_categories%] >+ <option value="[% patron_category.categorycode | html %]">[% patron_category.description | html %]</option> >+ [% END %] >+ </select> >+ </td> >+ <td><input name="article_request_fee" 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> >+ </form> >+ </div> >+ >+[% END %] > > <div id="refund-lost-item-fee-on-return" class="container"> > [% IF current_branch == '*' %] >@@ -1237,6 +1296,14 @@ > } > return true; > }); >+ >+ $("#set-article-request-fee").on("submit", function(){ >+ if (! $("input[name='article_request_fee'").val().length){ >+ alert("Please set a valid value for the fee"); >+ return false; >+ } >+ return true; >+ }); > }); > </script> > [% END %] >-- >2.32.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 27946
:
120144
|
120145
|
120146
|
120147
|
122522
|
122529
|
122530
|
122531
|
122532
|
122552
|
123503
|
123504
|
123505
|
123506
|
123507
|
128660
|
128661
|
128662
|
128663
|
128664
|
128665
|
128868
|
128869
|
128870
|
128871
|
128872
|
128873
|
129141
|
129142
|
129143
|
129144
|
129145
|
129146
|
129147
|
129171
|
129172
|
129173
|
129174
|
129175
|
129176
|
129177