Bugzilla – Attachment 116919 Details for
Bug 23415
Notify patron fines when renewing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23415: Notify patron fines when renewing
0001-Bug-23415-Notify-patron-fines-when-renewing.patch (text/plain), 11.25 KB, created by
Emmi Takkinen
on 2021-02-16 11:43:19 UTC
(
hide
)
Description:
Bug 23415: Notify patron fines when renewing
Filename:
MIME Type:
Creator:
Emmi Takkinen
Created:
2021-02-16 11:43:19 UTC
Size:
11.25 KB
patch
obsolete
>From 9ceb2c03a24c87d908d5a983459ea6ba1ec1713c Mon Sep 17 00:00:00 2001 >From: Emmi Takkinen <emmi.takkinen@outlook.com> >Date: Tue, 6 Aug 2019 11:13:33 +0300 >Subject: [PATCH 1/4] Bug 23415: Notify patron fines when renewing >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >It is possible to renew items for patron who has fines over accepted >limit on renew page or from checkout list. This patch adds confirmation >alerts to these renew actions when patron has fines over >"noissuescharge" syspref. > >Test plan: >1. Have patron with checkouts and fines over allowed limit >2. Renew checkouts either from renew page or checkout list >=> renew is successful >3. Apply patch >4. Repeat steps 1 and 2 >=> On renew page an alert is displayed and user has to confirm >renew >=> When renew is done from checkout list confirmation pop-up >is displayed > >Signed-off-by: Anneli Ãsterman <anneli.osterman@koha-suomi.fi> > >Signed-off-by: Kelly McElligott <kelly@bywatersolutions.com> >--- > circ/circulation.pl | 2 +- > circ/renew.pl | 20 ++++- > .../prog/en/modules/circ/circulation.tt | 4 + > .../prog/en/modules/circ/renew.tt | 10 +++ > .../prog/en/modules/members/moremember.tt | 4 + > koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 78 +++++++++++-------- > 6 files changed, 84 insertions(+), 34 deletions(-) > >diff --git a/circ/circulation.pl b/circ/circulation.pl >index ee3878ca13..be919e7934 100755 >--- a/circ/circulation.pl >+++ b/circ/circulation.pl >@@ -286,7 +286,7 @@ if ($patron) { > $template->param( > overduecount => $overdues->count, > issuecount => $issues->count, >- finetotal => $balance, >+ fines => $balance, > ); > > if ( $patron and $patron->is_debarred ) { >diff --git a/circ/renew.pl b/circ/renew.pl >index acce7770af..3ea9a02113 100755 >--- a/circ/renew.pl >+++ b/circ/renew.pl >@@ -28,6 +28,7 @@ use C4::Koha; > use Koha::DateUtils; > use Koha::Database; > use Koha::BiblioFrameworks; >+use Koha::Patrons; > > my $cgi = CGI->new; > >@@ -49,10 +50,11 @@ $barcode = barcodedecode($barcode) if( $barcode && C4::Context->preference('item > my $override_limit = $cgi->param('override_limit'); > my $override_holds = $cgi->param('override_holds'); > my $hard_due_date = $cgi->param('hard_due_date'); >+my $override_debt = $cgi->param('override_debt'); > > my ( $item, $issue, $borrower ); > my $error = q{}; >-my ( $soonest_renew_date, $latest_auto_renew_date ); >+my ( $soonest_renew_date, $latest_auto_renew_date, $balance ); > > if ($barcode) { > $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace >@@ -65,7 +67,10 @@ if ($barcode) { > if ($issue) { > > $borrower = $issue->borrower(); >- >+ my $patron = Koha::Patrons->find($borrower->borrowernumber); >+ $balance = $patron->account->balance; >+ my $amountlimit = C4::Context->preference("noissuescharge"); >+ > if ( ( $borrower->debarred() || q{} ) lt dt_from_string()->ymd() ) { > my $can_renew; > ( $can_renew, $error ) = >@@ -94,6 +99,16 @@ if ($barcode) { > $item->itemnumber(), > ); > } >+ >+ if ( $balance > $amountlimit ) { >+ $error = "too_much_debt"; >+ $can_renew = 0; >+ if($override_debt){ >+ $can_renew = 1; >+ $error = undef; >+ } >+ } >+ > if ($can_renew) { > my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; > my $date_due; >@@ -134,6 +149,7 @@ if ($barcode) { > error => $error, > soonestrenewdate => $soonest_renew_date, > latestautorenewdate => $latest_auto_renew_date, >+ balance => $balance, > ); > } > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >index a4f7369bb2..df2a5e4869 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -1113,6 +1113,10 @@ > > [% UNLESS ( patron.borrowernumber ) %][% UNLESS ( borrowers ) %]window.onload=function(){ $('#findborrower').focus(); };[% END %][% END %] > >+ var amountlimit = "[% Koha.Preference('noissuescharge') %]"; >+ var fines = "[% fines %]"; >+ var MSG_CONFRIM_RENEW = _("The patron has a debt of %s.\n Are you sure you want to renew checkout(s)?").format(fines); >+ > // On-site checkout > function toggle_onsite_checkout(){ > if ( $("#onsite_checkout").prop('checked') ) { >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt >index 3ff63d043a..b771256b11 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt >@@ -2,6 +2,7 @@ > [% USE Asset %] > [% USE Koha %] > [% USE KohaDates %] >+[% USE Price %] > [% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > >@@ -147,8 +148,17 @@ > <p>Item is not allowed renewal.</p> > > [% ELSIF error == "onsite_checkout" %] >+ > <p>Item cannot be renewed because it's an onsite checkout</p> > >+ [% ELSIF error == "too_much_debt" %] >+ >+ <li>The patron has a debt of [% balance | $Price %].</li> >+ <form method="post" action="/cgi-bin/koha/circ/renew.pl"> >+ <input type="hidden" name="barcode" value="[% item.barcode | html %]"/> >+ <input type="hidden" name="override_debt" value="1" /> >+ <button type="submit" class="approve"><i class="fa fa-check"></i>Renew checkout(s)</button> >+ </form> > [% ELSE %] > > [% error | html %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >index 7b7fd26e67..a9680c01e6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >@@ -946,6 +946,10 @@ > > columns_settings_issues_table = [% TablesSettings.GetColumns( 'members', 'moremember', 'issues-table', 'json' ) | $raw %] > >+ var amountlimit = "[% Koha.Preference('noissuescharge') %]"; >+ var fines = "[% fines %]"; >+ var MSG_CONFRIM_RENEW = _("The patron has a debt of %s.\n Are you sure you want to renew checkout(s)?").format(fines); >+ > $(document).ready(function() { > > if ( $('#clubs-tab').length ) { >diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js >index b5347c0bae..6653105192 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js >@@ -146,7 +146,16 @@ $(document).ready(function() { > > var itemnumber = $(this).val(); > >- $(this).parent().parent().replaceWith("<img id='renew_" + itemnumber + "' src='" + interface + "/" + theme + "/img/spinner-small.gif' />"); >+ var can_renew = true; >+ >+ if( parseFloat(fines) > parseFloat(amountlimit) ) { >+ var result = confirm(MSG_CONFRIM_RENEW); >+ if(result){ >+ can_renew = true; >+ }else{ >+ can_renew = false; >+ } >+ } > > var params = { > itemnumber: itemnumber, >@@ -170,36 +179,10 @@ $(document).ready(function() { > params.date_due = dueDate > } > >- $.post( "/cgi-bin/koha/svc/renew", params, function( data ) { >- var id = "#renew_" + data.itemnumber; >- >- var content = ""; >- if ( data.renew_okay ) { >- content = __("Renewed, due:") + " " + data.date_due; >- $('#date_due_' + data.itemnumber).replaceWith( data.date_due ); >- } else { >- content = __("Renew failed:") + " "; >- if ( data.error == "no_checkout" ) { >- content += __("not checked out"); >- } else if ( data.error == "too_many" ) { >- content += __("too many renewals"); >- } else if ( data.error == "too_unseen" ) { >- content += __("too many consecutive renewals without being seen by the library"); >- } else if ( data.error == "on_reserve" ) { >- content += __("on hold"); >- } else if ( data.error == "restriction" ) { >- content += __("Not allowed: patron restricted"); >- } else if ( data.error == "overdue" ) { >- content += __("Not allowed: overdue"); >- } else if ( data.error ) { >- content += data.error; >- } else { >- content += __("reason unknown"); >- } >- } >- >- $(id).replaceWith( content ); >- }, "json") >+ if(can_renew) { >+ $(this).parent().parent().replaceWith("<img id='renew_" + itemnumber + "' src='" + interface + "/" + theme + "/img/spinner-small.gif' />"); >+ renew(params); >+ } > }); > > // Refocus on barcode field if it exists >@@ -211,6 +194,39 @@ $(document).ready(function() { > return false; > }); > >+ function renew(params){ >+ $.post( "/cgi-bin/koha/svc/renew", params, function( data ) { >+ var id = "#renew_" + data.itemnumber; >+ >+ var content = ""; >+ if ( data.renew_okay ) { >+ content = __("Renewed, due:") + " " + data.date_due; >+ $('#date_due_' + data.itemnumber).replaceWith( data.date_due ); >+ } else { >+ content = __("Renew failed:") + " "; >+ if ( data.error == "no_checkout" ) { >+ content += __("not checked out"); >+ } else if ( data.error == "too_many" ) { >+ content += __("too many renewals"); >+ } else if ( data.error == "too_unseen" ) { >+ content += __("too many consecutive renewals without being seen by the library"); >+ } else if ( data.error == "on_reserve" ) { >+ content += __("on hold"); >+ } else if ( data.error == "restriction" ) { >+ content += __("Not allowed: patron restricted"); >+ } else if ( data.error == "overdue" ) { >+ content += __("Not allowed: overdue"); >+ } else if ( data.error ) { >+ content += data.error; >+ } else { >+ content += __("reason unknown"); >+ } >+ } >+ >+ $(id).replaceWith( content ); >+ }, "json") >+ } >+ > $("#RenewAll").on("click",function(){ > $("#CheckAllRenewals").click(); > $("#UncheckAllCheckins").click(); >-- >2.25.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 23415
:
92039
|
92541
|
98442
|
98634
|
98996
|
98997
|
105893
|
105894
|
108392
|
109871
|
109872
|
109876
|
109880
|
116919
|
116920
|
116921
|
116922
|
118175
|
118176
|
118177
|
118178
|
118183
|
119300
|
119301
|
119302
|
119303
|
121472
|
139670
|
139671
|
139672
|
139673
|
139674
|
146415
|
148198
|
148199
|
148200
|
148201
|
148202
|
152776
|
152777
|
152778
|
152779
|
152780
|
152781
|
154595
|
154596
|
154597
|
154598
|
154599
|
154600
|
158302
|
158303
|
158304
|
158305
|
158306
|
158307
|
161964
|
161965
|
161966
|
161967
|
161968
|
161969
|
162171
|
162172
|
162173
|
162174
|
162175
|
162176
|
162177
|
162178
|
162179
|
162180
|
171620
|
171621
|
171622
|
171623
|
171983
|
171984
|
171985
|
171986
|
172906
|
172907
|
172908
|
172909
|
172910