Bugzilla – Attachment 135839 Details for
Bug 22456
Allow patrons to cancel their waiting holds
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22456: Add waiting_hold_cancellation circulation rule
Bug-22456-Add-waitingholdcancellation-circulation-.patch (text/plain), 9.22 KB, created by
Tomás Cohen Arazi (tcohen)
on 2022-06-08 20:50:04 UTC
(
hide
)
Description:
Bug 22456: Add waiting_hold_cancellation circulation rule
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2022-06-08 20:50:04 UTC
Size:
9.22 KB
patch
obsolete
>From 2a4f00c0c8036de0effcd6db1d235fed61c3e9b7 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 18 Apr 2022 17:54:14 -0300 >Subject: [PATCH] Bug 22456: Add waiting_hold_cancellation circulation rule > >This patch adds handling for the waiting_hold_cancellation circulation >rule. It is set no 'No' by default in the atomic update, if not >previously set. > >Handling in the rules editor is added, in its own section. > >To test: >1. Apply this patch >2. Run: > $ updatedatabase >=> SUCCESS: All good >3. Verify that the syspref is set: > $ koha-mysql kohadev > > SELECT * FROM circulation_rules WHERE rule_name='waiting_hold_cancellation'; >=> SUCCESS: Set to 0 >4. Play with the rules editor, changing things back and forth, things > should work, including library-specific and global/defualt settings. >=> SUCCESS: It works >=> SUCCESS: Texts are idiomatic >5. Sign off :-D > >Sponsored-by: Montgomery County Public Libraries > >Signed-off-by: David Nind <david@davidnind.com> >--- > Koha/CirculationRules.pm | 4 + > admin/smart-rules.pl | 33 ++++++++ > .../data/mysql/atomicupdate/bug_22456.pl | 16 ++++ > .../prog/en/modules/admin/smart-rules.tt | 83 +++++++++++++++++++ > 4 files changed, 136 insertions(+) > >diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm >index fbfbe2e6ec..f77ffc3bb2 100644 >--- a/Koha/CirculationRules.pm >+++ b/Koha/CirculationRules.pm >@@ -110,6 +110,10 @@ our $RULE_KINDS = { > hardduedatecompare => { > scope => [ 'branchcode', 'categorycode', 'itemtype' ], > }, >+ waiting_hold_cancellation => { >+ scope => [ 'branchcode', 'categorycode', 'itemtype' ], >+ can_be_blank => 0, >+ }, > holds_per_day => { > scope => [ 'branchcode', 'categorycode', 'itemtype' ], > }, >diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl >index b7f2ae643e..d8fffaf924 100755 >--- a/admin/smart-rules.pl >+++ b/admin/smart-rules.pl >@@ -660,8 +660,41 @@ elsif ( $op eq 'mod-refund-lost-item-fee-rule' ) { > } > ); > } >+} elsif ( $op eq "set-waiting-hold-cancellation" ) { >+ >+ my $category = $input->param('waiting_hold_cancellation_category'); >+ my $itemtype = $input->param('waiting_hold_cancellation_itemtype'); >+ my $policy = strip_non_numeric( scalar $input->param('waiting_hold_cancellation_policy') ) >+ ? 1 >+ : 0; >+ >+ Koha::Exception->throw("No value passed for waiting holds cancellation policy") >+ if not defined $policy # There is a JS check for that >+ || $policy eq ''; >+ >+ Koha::CirculationRules->set_rules( >+ { categorycode => ( $category eq '*' ) ? undef : $category, >+ itemtype => ( $itemtype eq '*' ) ? undef : $itemtype, >+ branchcode => ( $branch eq '*' ) ? undef : $branch, >+ rules => { waiting_hold_cancellation => $policy }, >+ } >+ ); >+ >+} elsif ( $op eq 'del-waiting-hold-cancellation' ) { >+ >+ my $category = $input->param('waiting_hold_cancellation_category'); >+ my $itemtype = $input->param('waiting_hold_cancellation_itemtype'); >+ >+ Koha::CirculationRules->set_rules( >+ { categorycode => ( $category eq '*' ) ? undef : $category, >+ itemtype => ( $itemtype eq '*' ) ? undef : $itemtype, >+ branchcode => ( $branch eq '*' ) ? undef : $branch, >+ rules => { waiting_hold_cancellation => undef }, >+ } >+ ); > } > >+ > my $refundLostItemFeeRule = Koha::CirculationRules->find({ branchcode => ($branch eq '*') ? undef : $branch, rule_name => 'lostreturn' }); > my $defaultLostItemFeeRule = Koha::CirculationRules->find({ branchcode => undef, rule_name => 'lostreturn' }); > $template->param( >diff --git a/installer/data/mysql/atomicupdate/bug_22456.pl b/installer/data/mysql/atomicupdate/bug_22456.pl >index 3d094a5fdb..611e8da7e6 100755 >--- a/installer/data/mysql/atomicupdate/bug_22456.pl >+++ b/installer/data/mysql/atomicupdate/bug_22456.pl >@@ -17,5 +17,21 @@ return { > ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; > }); > } >+ >+ my ($count) = $dbh->selectrow_array(q{ >+ SELECT COUNT(*) >+ FROM circulation_rules >+ WHERE rule_name = 'waiting_hold_cancellation' >+ }); >+ >+ unless ( $count ) { >+ $dbh->do(q{ >+ INSERT INTO circulation_rules (rule_name, rule_value) >+ VALUES ('waiting_hold_cancellation', 0) >+ }); >+ } >+ else { >+ say $out "Found already existing 'waiting_hold_cancellation' circulation rules on the DB. Please review."; >+ } > }, > }; >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 62e2f5639a..fa33a678ce 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 >@@ -836,6 +836,89 @@ > </div> > [% END %] > >+ <div id="waiting-hold-cancel-category" class="container"> >+ [% IF humanbranch %] >+ <h3>Waiting hold cancellation policy for [% Branches.GetName( humanbranch ) | html %]</h3> >+ [% ELSE %] >+ <h3>Default waiting hold cancellation policy</h3> >+ [% END %] >+ <p>Specify if waiting holds can be cancelled for a given patron category.</p> >+ <form id="set-waiting-hold-cancellation" method="post" action="/cgi-bin/koha/admin/smart-rules.pl"> >+ <input type="hidden" name="op" value="set-waiting-hold-cancellation" /> >+ <input type="hidden" name="branch" value="[% current_branch | html %]"/> >+ <table> >+ <tr> >+ <th>Patron category</th> >+ <th>Item type</th> >+ <th>Cancellation allowed</th> >+ <th> </th> >+ </tr> >+ [% FOREACH c IN categorycodes %] >+ [% SET c = '*' UNLESS c.defined AND c != '' %] >+ [% FOREACH i IN itemtypes %] >+ [% SET i = '*' UNLESS i.defined AND i != '' %] >+ >+ [% SET waiting_hold_cancellation = CirculationRules.Search( current_branch, c, i, 'waiting_hold_cancellation' ) %] >+ >+ [% IF ( waiting_hold_cancellation.defined && waiting_hold_cancellation != '' ) %] >+ <tr> >+ <td> >+ [% IF c == '*' %] >+ <em>All</em> >+ [% ELSE %] >+ [% Categories.GetName(c) | html %] >+ [% END %] >+ </td> >+ <td> >+ [% IF i == '*' %] >+ <em>All</em> >+ [% ELSE %] >+ [% ItemTypes.GetDescription(i,1) | html %] >+ [% END %] >+ </td> >+ <td> >+ [% IF waiting_hold_cancellation %] >+ <span>Yes</span> >+ [% ELSE %] >+ <span>No</span> >+ [% END %] >+ </td> >+ <td class="actions"> >+ <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=del-waiting-hold-cancellation&waiting_hold_cancellation_category=[% c | uri %]&waiting_hold_cancellation_itemtype=[% i | uri %]&branch=[% current_branch | uri %]"><i class="fa fa-trash"></i> Delete</a> >+ </td> >+ </tr> >+ [% END %] >+ [% END %] >+ [% END %] >+ <tr> >+ <td> >+ <select name="waiting_hold_cancellation_category" id="waiting_hold_cancellation_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> >+ <select name="waiting_hold_cancellation_itemtype" id="waiting_hold_cancellation_itemtype"> >+ <option value="*">All</option> >+ [% FOREACH itemtype IN itemtypeloop %] >+ <option value="[% itemtype.itemtype | html %]">[% ItemTypes.GetDescription(itemtype.itemtype) | html %]</option> >+ [% END %] >+ </select> >+ </td> >+ <td> >+ <select name="waiting_hold_cancellation_policy" id="waiting_hold_cancellation_policy"> >+ <option value="0" selected>No</option> >+ <option value="1">Yes</option> >+ </select> >+ </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> >+ > [% IF Koha.Preference('ArticleRequests') %] > <div id="open-article-requests-limit-patron-category" class="container"> > [% IF humanbranch %] >-- >2.34.1
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 22456
:
135165
|
135166
|
135167
|
135168
|
135169
|
135170
|
135171
|
135319
|
135320
|
135321
|
135322
|
135323
|
135324
|
135325
|
135326
|
135349
|
135350
|
135351
|
135352
|
135396
|
135397
|
135398
|
135399
|
135400
|
135401
|
135402
|
135403
|
135404
|
135405
|
135406
|
135407
|
135408
|
135409
|
135410
|
135411
|
135430
|
135830
|
135831
|
135832
|
135838
|
135839
|
135840
|
135841
|
135842
|
135843
|
135844
|
135845
|
135846
|
137580
|
137581
|
137582
|
137583
|
137584
|
137585
|
137586
|
137587
|
137588
|
137589
|
137591
|
138209
|
138210
|
138211
|
138212
|
138213
|
138214
|
138215
|
138216
|
138217
|
138218