Bugzilla – Attachment 173720 Details for
Bug 14787
Allow confirm/continue option to circulation warnings at checkout
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14787: Remember confirmations for a patron session
Bug-14787-Remember-confirmations-for-a-patron-sess.patch (text/plain), 14.74 KB, created by
Matt Blenkinsop
on 2024-10-30 14:20:01 UTC
(
hide
)
Description:
Bug 14787: Remember confirmations for a patron session
Filename:
MIME Type:
Creator:
Matt Blenkinsop
Created:
2024-10-30 14:20:01 UTC
Size:
14.74 KB
patch
obsolete
>From 6032c555892101d9292f1b13a2ae0cff8d7d2128 Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >Date: Wed, 12 Jun 2024 08:59:54 +0000 >Subject: [PATCH] Bug 14787: Remember confirmations for a patron session > >This patch adds functionality that will remember whether an action has been confirmed for a particular patron for the session. While carrying out an action on that patron, if the same checkout confirmation message keeps appearing the user can now select to remember their confirmation while they are still working on that patron. When the user moves onto a new patron the confirmations then reset and accumulate again for the new patron. > >Test plan: >We're going to use rental fees as the example to prompt the checkout confirmation dialog. If you wish to use something else to test then feel free, it should work the same. Do not use patron debts though, as we already track a confirmation for this elsewhere and the test plan will appear to fail when in fact it is behaving as expected > >1) In system preferences set RentalFeesCheckoutConfirmation to 'ask' >2) Choose a patron and checkout an item to that patron that incurrs a rental charge (in KTD this will be any item that does not have an itype of 'BK', 'REF' or 'VM' >3) A dialog should display asking you to confirm the checkout. >4) There should be a checkbox on the dialog to "Remember for the session for this patron" >5) Click Yes, checkout out without checking this checkbox >6) Select another item and checkout - the dialog should display again >7) This time, check the checkbox and click Yes, check out >8) Checkout another item (depending on your fines limit settings, you may need to pay the rental charges before the system will allow you to checkout again so go ahead and do this) >9) This time the dialog should not appear as the system has remembered our confirmation for this patron for the session >10) Choose a new patron >11) Repeat steps 2 - 9 >12) It should work as outlined above >13) Sign off! >--- > circ/circulation.pl | 98 +++++++++++-------- > .../prog/en/modules/circ/circulation.tt | 18 +++- > koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 34 +++++++ > 3 files changed, 105 insertions(+), 45 deletions(-) > >diff --git a/circ/circulation.pl b/circ/circulation.pl >index 20c6649e1a4..c6b87f4f888 100755 >--- a/circ/circulation.pl >+++ b/circ/circulation.pl >@@ -463,53 +463,65 @@ if (@$barcodes && $op eq 'cud-checkout') { > } > } > >- if( $item and ( !$blocker or $force_allow_issue ) ){ >- my $confirm_required = 0; >- unless($issueconfirmed){ >- # Get the item title for more information >- my $materials = $item->materials; >- my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $biblio->frameworkcode, kohafield => 'items.materials', authorised_value => $materials }); >- $materials = $descriptions->{lib} // $materials; >- $template_params->{ADDITIONAL_MATERIALS} = $materials; >- $template_params->{itemhomebranch} = $item->homebranch; >- >- # pass needsconfirmation to template if issuing is possible and user hasn't yet confirmed. >- foreach my $needsconfirmation_key ( keys %$needsconfirmation ) { >- $template_params->{$needsconfirmation_key} = $needsconfirmation->{$needsconfirmation_key}; >- $template_params->{getTitleMessageIteminfo} = $biblio->title; >- $template_params->{getBarcodeMessageIteminfo} = $item->barcode; >- $template_params->{NEEDSCONFIRMATION} = 1; >- $confirm_required = 1; >- if ( $needsconfirmation_key eq 'BOOKED_TO_ANOTHER' ) { >- my $rule = Koha::CirculationRules->get_effective_rule( >- { >- rule_name => 'bookings_lead_period', >- itemtype => $item->effective_itemtype, >- branchcode => "*" >- } >- ); >- my $preparation_period = $rule ? $rule->rule_value : 1; >- my $reduceddue = >- dt_from_string( $$needsconfirmation{$needsconfirmation_key}->start_date ) >- ->subtract( days => $preparation_period ); >- $template_params->{reduceddue} = $reduceddue; >- } >- } >- } >- unless ($confirm_required) { >- my $switch_onsite_checkout = exists $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}; >- if ( C4::Context->preference('UseRecalls') && !$recall_id ) { >- my $recall = Koha::Recalls->find( >+ if( $item and ( !$blocker or $force_allow_issue ) ){ >+ my $confirm_required = 0; >+ unless($issueconfirmed){ >+ # Get the item title for more information >+ my $materials = $item->materials; >+ my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $biblio->frameworkcode, kohafield => 'items.materials', authorised_value => $materials }); >+ $materials = $descriptions->{lib} // $materials; >+ $template_params->{ADDITIONAL_MATERIALS} = $materials; >+ $template_params->{itemhomebranch} = $item->homebranch; >+ >+ my $patron_session_confirmation = $query->cookie('patronSessionConfirmation') || undef; >+ my ( $patron_for_session, $session_confirmations ) = split( /:/, $patron_session_confirmation, 2 ); >+ my $patron_match = $borrowernumber == $patron_for_session; >+ my @conf_keys = split( /\|/, $session_confirmations ); >+ $template_params->{sessionConfirmationKeys} = (); >+ >+ # pass needsconfirmation to template if issuing is possible and user hasn't yet confirmed. >+ foreach my $needsconfirmation_key ( keys %$needsconfirmation ) { >+ if ( $needsconfirmation_key eq 'BOOKED_TO_ANOTHER' ) { >+ my $rule = Koha::CirculationRules->get_effective_rule( > { >- biblio_id => $item->biblionumber, >- item_id => [ undef, $item->itemnumber ], >- status => [ 'requested', 'waiting' ], >- completed => 0, >- patron_id => $patron->borrowernumber, >+ rule_name => 'bookings_lead_period', >+ itemtype => $item->effective_itemtype, >+ branchcode => "*" > } > ); >- $recall_id = ( $recall and $recall->id ) ? $recall->id : undef; >+ my $preparation_period = $rule ? $rule->rule_value : 1; >+ my $reduceddue = >+ dt_from_string( $$needsconfirmation{$needsconfirmation_key}->start_date ) >+ ->subtract( days => $preparation_period ); >+ $template_params->{reduceddue} = $reduceddue; > } >+ next >+ if $patron_match >+ && scalar(@conf_keys) > 0 >+ && grep( { $needsconfirmation_key eq $_ } @conf_keys ); >+ >+ $template_params->{$needsconfirmation_key} = $needsconfirmation->{$needsconfirmation_key}; >+ $template_params->{getTitleMessageIteminfo} = $biblio->title; >+ $template_params->{getBarcodeMessageIteminfo} = $item->barcode; >+ $template_params->{NEEDSCONFIRMATION} = 1; >+ $confirm_required = 1; >+ push( @{ $template_params->{sessionConfirmationKeys} }, $needsconfirmation_key ); >+ } >+ } >+ unless ($confirm_required) { >+ my $switch_onsite_checkout = exists $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}; >+ if ( C4::Context->preference('UseRecalls') && !$recall_id ) { >+ my $recall = Koha::Recalls->find( >+ { >+ biblio_id => $item->biblionumber, >+ item_id => [ undef, $item->itemnumber ], >+ status => [ 'requested', 'waiting' ], >+ completed => 0, >+ patron_id => $patron->borrowernumber, >+ } >+ ); >+ $recall_id = ( $recall and $recall->id ) ? $recall->id : undef; >+ } > > # If booked (alerts or confirmation) update datedue to end of booking > if ( my $booked = $needsconfirmation->{BOOKED_EARLY} // $alerts->{BOOKED} ) { >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 c269d95ebef..1362ab08756 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -277,11 +277,14 @@ > </ul> > > [% IF CAN_user_circulate_force_checkout or HIGHHOLDS %] >- <form method="post" action="/cgi-bin/koha/circ/circulation.pl" autocomplete="off"> >+ <form method="post" action="/cgi-bin/koha/circ/circulation.pl" autocomplete="off" class="confirmation-required-form"> > [% INCLUDE 'csrf-token.inc' %] > <fieldset> > <input type="hidden" name="restoreduedatespec" /> > <input type="hidden" name="op" value="cud-checkout" /> >+ [% FOREACH conf IN sessionConfirmationKeys %] >+ <input type="hidden" name="session_confirmations" id="session_confirmations" value="[% conf | html %]" /> >+ [% END %] > > [% IF (forceallow) %]<input type="hidden" name="forceallow" value="1">[% END %] > >@@ -376,6 +379,10 @@ > [% IF ( RENEW_ISSUE ) %] > <button type="submit" class="btn btn-default approve" accesskey="y"><i class="fa fa-check"></i> Yes, renew (Y)</button> > [% ELSE %] >+ <p> >+ <label for="patron_session_confirmation">Remember for the session for this patron</label> >+ <input type="checkbox" id="patron_session_confirmation" name="patron_session_confirmation" /> >+ </p> > <button type="submit" class="btn btn-default approve" accesskey="y"><i class="fa fa-check"></i> Yes, check out (Y)</button> > [% END %] > >@@ -386,10 +393,13 @@ > [% END # /IF CAN_user_circulate_force_checkout or HIGHHOLDS %] > > [% IF ADDITIONAL_MATERIALS && !CAN_user_circulate_force_checkout %] >- <form method="post" action="/cgi-bin/koha/circ/circulation.pl" autocomplete="off"> >+ <form method="post" action="/cgi-bin/koha/circ/circulation.pl" autocomplete="off" class="confirmation-required-form"> > [% INCLUDE 'csrf-token.inc' %] > <input type="hidden" name="op" value="cud-checkout" /> > <input type="hidden" name="restoreduedatespec" /> >+ [% FOREACH conf IN sessionConfirmationKeys %] >+ <input type="hidden" name="session_confirmations" id="session_confirmations" value="[% conf | html %]" /> >+ [% END %] > > [% IF (forceallow) %]<input type="hidden" name="forceallow" value="1">[% END %] > >@@ -403,6 +413,10 @@ > [% IF ( RENEW_ISSUE ) %] > <button type="submit" class="btn btn-default approve" accesskey="y"><i class="fa fa-check"></i> Yes, renew (Y)</button> > [% ELSE %] >+ <p> >+ <label for="patron_session_confirmation">Remember for the session for this patron</label> >+ <input type="checkbox" id="patron_session_confirmation" name="patron_session_confirmation" /> >+ </p> > <button type="submit" class="btn btn-default approve" accesskey="y"><i class="fa fa-check"></i> Yes, check out (Y)</button> > [% END %] > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js >index b9dd65f390f..0802d15bb43 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js >@@ -1308,4 +1308,38 @@ $(document).ready(function() { > $("#return-claims-table").DataTable().search("is_unresolved").draw(); > }); > >+ $(".confirmation-required-form").on("submit", function (e) { >+ >+ var currentCookieValue = Cookies.get("patronSessionConfirmation") || ''; >+ var currentPatron = currentCookieValue.split(':')[0] || null; >+ >+ var rememberForSession = $('#patron_session_confirmation').is(":checked"); >+ var sessionConfirmations = [] >+ $('input[name^=session_confirmations]').each(function() { >+ sessionConfirmations.push($(this).val()); >+ }); >+ >+ if(currentPatron != borrowernumber && !rememberForSession) { >+ Cookies.set("patronSessionConfirmation", borrowernumber + ':', { sameSite: 'Lax' }); >+ return true >+ } >+ >+ if(currentPatron == borrowernumber && rememberForSession) { >+ sessionConfirmations.forEach(function(sessionConfirmation) { >+ currentCookieValue += sessionConfirmation + '|'; >+ }) >+ Cookies.set("patronSessionConfirmation", currentCookieValue, { sameSite: 'Lax' }); >+ return true >+ } >+ >+ if(currentPatron != borrowernumber && rememberForSession) { >+ var newCookieValue = borrowernumber + ':'; >+ sessionConfirmations.forEach(function(sessionConfirmation) { >+ newCookieValue += sessionConfirmation + '|'; >+ }) >+ Cookies.set("patronSessionConfirmation", newCookieValue, { sameSite: 'Lax' }); >+ return true >+ } >+ return true >+ }); > }); >-- >2.39.3 (Apple Git-146)
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 14787
:
167656
|
167657
|
171183
|
171184
|
173224
|
173225
|
173412
|
173413
|
173559
|
173560
| 173720 |
173721