Bugzilla – Attachment 114531 Details for
Bug 8137
Checkout limit for all libraries
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8137: Add Default checkout limit by patron category with priority.
Bug-8137-Add-Default-checkout-limit-by-patron-cate.patch (text/plain), 8.37 KB, created by
Andrew Fuerste-Henry
on 2020-12-18 17:01:22 UTC
(
hide
)
Description:
Bug 8137: Add Default checkout limit by patron category with priority.
Filename:
MIME Type:
Creator:
Andrew Fuerste-Henry
Created:
2020-12-18 17:01:22 UTC
Size:
8.37 KB
patch
obsolete
>From 98bf73f65960ec82506f6ce4aa87025176394dc7 Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Wed, 28 Jun 2017 13:50:20 +0000 >Subject: [PATCH] Bug 8137: Add Default checkout limit by patron category with > priority. > >This patch add the ability to make a 'Default checkout limit by patron category' >rule has priority. When a rule has priority, it overrides all others >for the same categorycode. For "normal" rule, the behavior is the same >than before (like a default rule if no one is specified at branch level). >Rule with priority can only be created on the circulation and fine rules >page for *all libraries*. The goal is to allow librarian to limit the >total number of checkouts by patron category for all libraries. > >test plan: > > - Create a rule with 4 checkouts allowed in default checkout limit > table > for a patron category and make it has priority, > - create more permissive rules for all other branches (at least 5 > checkouts allowed), > - Checkout items of different branches for a patron with the same > category, > - Patron should be limited to 4 checkouts > >https://bugs.koha-community.org/show_bug.cgi?id=8137 > >Rebased: 2018-03-14, by: Alex Arnaud <alex.arnaud@biblibre.com> >Rebased: 2020-07-23, by: Arthur Suzuki <arthur.suzuki@biblibre.com> > >Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> >--- > admin/smart-rules.pl | 6 ++++++ > .../Bug_8137-add-column-has_priority.sql | 5 +++++ > .../prog/en/modules/admin/smart-rules.tt | 15 ++++++++++++++ > t/db_dependent/Circulation/Branch.t | 24 ++++++++++++++++++++++ > 4 files changed, 50 insertions(+) > create 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 b1fa57b4da..4abcf04c0d 100755 >--- a/admin/smart-rules.pl >+++ b/admin/smart-rules.pl >@@ -409,6 +409,8 @@ elsif ($op eq "add-branch-cat") { > my $max_holds = $input->param('max_holds'); > $max_holds =~ s/\s//g; > $max_holds = undef if $max_holds !~ /^\d+/; >+ my $has_priority = $input->param('has_priority'); >+ $has_priority = $has_priority ? 1 : 0; > > if ($branch eq "*") { > if ($categorycode eq "*") { >@@ -424,6 +426,7 @@ elsif ($op eq "add-branch-cat") { > } > ); > } else { >+ > Koha::CirculationRules->set_rules( > { > categorycode => $categorycode, >@@ -432,6 +435,7 @@ elsif ($op eq "add-branch-cat") { > max_holds => $max_holds, > patron_maxissueqty => $patron_maxissueqty, > patron_maxonsiteissueqty => $patron_maxonsiteissueqty, >+ has_priority => $has_priority, > } > } > ); >@@ -445,6 +449,7 @@ elsif ($op eq "add-branch-cat") { > max_holds => $max_holds, > patron_maxissueqty => $patron_maxissueqty, > patron_maxonsiteissueqty => $patron_maxonsiteissueqty, >+ has_priority => $has_priority, > } > } > ); >@@ -457,6 +462,7 @@ elsif ($op eq "add-branch-cat") { > max_holds => $max_holds, > patron_maxissueqty => $patron_maxissueqty, > patron_maxonsiteissueqty => $patron_maxonsiteissueqty, >+ has_priority => $has_priority, > } > } > ); >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 >new file mode 100644 >index 0000000000..fc7c42fcc0 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/Bug_8137-add-column-has_priority.sql >@@ -0,0 +1,5 @@ >+ALTER TABLE default_borrower_circ_rules ADD has_priority INT(1) DEFAULT 0; >+ALTER TABLE default_borrower_circ_rules DROP foreign key borrower_borrower_circ_rules_ibfk_1; >+ALTER TABLE default_borrower_circ_rules DROP primary key; >+ALTER TABLE default_borrower_circ_rules ADD primary key(categorycode, has_priority); >+ALTER TABLE default_borrower_circ_rules ADD CONSTRAINT borrower_borrower_circ_rules_ibfk_1 FOREIGN KEY (categorycode) REFERENCES categories (categorycode) ON DELETE CASCADE ON UPDATE CASCADE; >\ No newline at end of file >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 1aae3e0ba1..c4ab140e30 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 >@@ -690,6 +690,10 @@ > <p>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. > </p> >+ <p> >+ <b>Has priority: </b>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. >+ </p> > <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl"> > <input type="hidden" name="op" value="add-branch-cat" /> > <input type="hidden" name="branch" value="[% current_branch | html %]"/> >@@ -699,6 +703,7 @@ > <th>Total current checkouts allowed</th> > <th>Total current on-site checkouts allowed</th> > <th>Total holds allowed</th> >+ [% UNLESS humanbranch %]<th>Has priority</th>[% END %] > <th> </th> > </tr> > [% FOREACH c IN categorycodes %] >@@ -737,6 +742,11 @@ > <span>Unlimited</span> > [% END %] > </td> >+ [% UNLESS humanbranch %] >+ <td> >+ <input type="checkbox" [% IF branch_cat_rule_loo.has_priority %]checked[% END %] disabled/> >+ </td> >+ [% END %] > > <td class="actions"> > <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&categorycode=[% c | html %]&branch=[% current_branch | html %]"><i class="fa fa-trash"></i> Delete</a> >@@ -755,6 +765,11 @@ > <td><input name="patron_maxissueqty" size="3" type="text" /></td> > <td><input name="patron_maxonsiteissueqty" size="3" type="text" /></td> > <td><input name="max_holds" size="3" type="text" /></td> >+ [% UNLESS humanbranch %] >+ <td> >+ <input type="checkbox" name="has_priority"/> >+ </td> >+ [% END %] > <td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</td> > </tr> > </table> >diff --git a/t/db_dependent/Circulation/Branch.t b/t/db_dependent/Circulation/Branch.t >index c8fe89dc97..06f8c2fe0e 100755 >--- a/t/db_dependent/Circulation/Branch.t >+++ b/t/db_dependent/Circulation/Branch.t >@@ -232,7 +232,15 @@ Koha::CirculationRules->set_rules( > } > ); > >+$query = q| >+ INSERT INTO default_borrower_circ_rules >+ (categorycode, maxissueqty, maxonsiteissueqty, has_priority) >+ VALUES( ?, ?, ?, ? ) >+|; >+$dbh->do($query, {}, $samplecat->{categorycode}, 3, 3, 0); >+ > #Test GetBranchBorrowerCircRule >+# > is_deeply( > GetBranchBorrowerCircRule(), > { patron_maxissueqty => 4, patron_maxonsiteissueqty => 5 }, >@@ -257,6 +265,22 @@ is_deeply( > "GetBranchBorrower with wrong parameters returns the patron_maxissueqty and patron_maxonsiteissueqty of default_circ_rules" > ); > >+$query = q| >+ INSERT INTO default_borrower_circ_rules >+ (categorycode, maxissueqty, maxonsiteissueqty, has_priority) >+ VALUES( ?, ?, ?, ? ) >+|; >+$dbh->do($query, {}, $samplecat->{categorycode}, 3, 3, 1); >+ >+is_deeply( >+ GetBranchBorrowerCircRule( >+ $samplebranch1->{branchcode}, >+ $samplecat->{categorycode} >+ ), >+ { maxissueqty => 3, maxonsiteissueqty => 3, has_priority => 1 }, >+ "GetBranchBorrower returns the rule having priority" >+); >+ > #Test GetBranchItemRule > my @lazy_any = ( 'hold_fulfillment_policy' => 'any' ); > is_deeply( >-- >2.11.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 8137
:
9705
|
9706
|
11079
|
64703
|
64704
|
64791
|
64891
|
72831
|
72832
|
107207
|
107208
|
107209
|
107459
|
111368
|
111369
|
111370
|
112640
|
113797
|
113882
|
114531
|
114532
|
114533
|
114534
|
116676
|
116677
|
116678
|
116679
|
116680
|
145476
|
145477
|
145478
|
145479
|
145480
|
152040
|
152041
|
152042
|
152043
|
152044
|
152045
|
156316
|
156317
|
156318
|
156319
|
156320
|
156321
|
156322
|
159712
|
162367
|
167208
|
167923
|
168119
|
169084
|
169696
|
169700
|
169727
|
169927
|
169928
|
170411
|
173605
|
173608
|
175837
|
175838
|
177464