Bugzilla – Attachment 105114 Details for
Bug 25534
Add ability to specifying and store a reason when cancelling a hold
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25534: Add ability to send an email specifying a reason when canceling a hold
Bug-25534-Add-ability-to-send-an-email-specifying-.patch (text/plain), 13.14 KB, created by
Kyle M Hall (khall)
on 2020-05-19 18:57:47 UTC
(
hide
)
Description:
Bug 25534: Add ability to send an email specifying a reason when canceling a hold
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2020-05-19 18:57:47 UTC
Size:
13.14 KB
patch
obsolete
>From 78a4ccc961f10d43887e05f7cd421bd14ae55508 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Mon, 18 May 2020 13:32:45 -0400 >Subject: [PATCH] Bug 25534: Add ability to send an email specifying a reason > when canceling a hold > >Some libraries would like to be able to cancel a hold with the option to >specify a reason. Providing a reason would generate an email to that >patron. > >Test Plan: >1) Apply this patch >2) Run updatedatabase.pl >3) Restart all the things! >4) Create new AV category "HOLD_CANCELLATION", add some cancelation reasons >5) Add new Holds module notice "HOLD_CANCELLATION", add an email version. > A quick test version would be "Reason: <<reserves.cancellation_reason>>" >-- >[% USE AuthorisedValues %] >Reason: [% AuthorisedValues.GetByCode( 'CANCELLATION_REASON', hold.cancellation_reason, 'IS_OPAC' ) %] > >[% IF hold.cancellation_reason == "MY_AV_VALUE" %] >IF perhaps you'd like to have a much longer explanation than just the >one sentence in the AV description, you can use IF blocks using Template >Toolkit markup! >[% END %] >-- >6) Place a hold for a patron >7) On request.pl, select the 'del' option for the hold >8) Select a cancellation reason and choose "Update hold(s)" >9) Note a new message has been queue for the patron with the cancelation reason >11) Test again from circulation.pl >12) Test again from moremember.pl >10) Cancel a hold with no reason, note no email is generated >11) Delete your authorised values, not the feature is disabled >12) Reinstate the authorised values, but delete the notice, > you should now be able to cancel a hold with a reason, > but no email will be generated >--- > C4/Letters.pm | 2 +- > C4/Reserves.pm | 9 ++--- > Koha/Hold.pm | 33 +++++++++++++++++++ > .../prog/en/includes/holds_table.inc | 8 +++-- > .../prog/en/modules/circ/circulation.tt | 10 ++++++ > .../prog/en/modules/members/moremember.tt | 10 ++++++ > .../prog/en/modules/reserve/request.tt | 13 ++++++++ > reserve/modrequest.pl | 2 ++ > 8 files changed, 79 insertions(+), 8 deletions(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index 1036c461f3..b6766891c2 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -1519,7 +1519,7 @@ sub _get_tt_params { > module => 'Koha::Holds', > singular => 'hold', > plural => 'holds', >- fk => [ 'borrowernumber', 'biblionumber' ], >+ pk => 'reserve_id', > }, > serial => { > module => 'Koha::Serials', >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 9f8d31637a..b2af4b6bd1 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -970,6 +970,7 @@ sub ModReserve { > my $suspend_until = $params->{'suspend_until'}; > my $borrowernumber = $params->{'borrowernumber'}; > my $biblionumber = $params->{'biblionumber'}; >+ my $cancellation_reason = $params->{'cancellation_reason'}; > > return if $rank eq "W"; > return if $rank eq "n"; >@@ -987,7 +988,7 @@ sub ModReserve { > $hold ||= Koha::Holds->find($reserve_id); > > if ( $rank eq "del" ) { >- $hold->cancel; >+ $hold->cancel({ cancellation_reason => $cancellation_reason }); > } > elsif ($rank =~ /^\d+/ and $rank > 0) { > logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, Dumper($hold->unblessed) ) >@@ -1172,7 +1173,7 @@ sub ModReserveAffect { > > =head2 ModReserveCancelAll > >- ($messages,$nextreservinfo) = &ModReserveCancelAll($itemnumber,$borrowernumber); >+ ($messages,$nextreservinfo) = &ModReserveCancelAll($itemnumber,$borrowernumber,$reason); > > function to cancel reserv,check other reserves, and transfer document if it's necessary > >@@ -1181,12 +1182,12 @@ function to cancel reserv,check other reserves, and transfer document if it's ne > sub ModReserveCancelAll { > my $messages; > my $nextreservinfo; >- my ( $itemnumber, $borrowernumber ) = @_; >+ my ( $itemnumber, $borrowernumber, $cancellation_reason ) = @_; > > #step 1 : cancel the reservation > my $holds = Koha::Holds->search({ itemnumber => $itemnumber, borrowernumber => $borrowernumber }); > return unless $holds->count; >- $holds->next->cancel; >+ $holds->next->cancel({ cancellation_reason => $cancellation_reason }); > > #step 2 launch the subroutine of the others reserves > ( $messages, $nextreservinfo ) = GetOtherReserves($itemnumber); >diff --git a/Koha/Hold.pm b/Koha/Hold.pm >index e8d9e0cc2c..62252b83d9 100644 >--- a/Koha/Hold.pm >+++ b/Koha/Hold.pm >@@ -24,8 +24,10 @@ use Carp; > use Data::Dumper qw(Dumper); > > use C4::Context qw(preference); >+use C4::Letters; > use C4::Log; > >+use Koha::AuthorisedValues; > use Koha::DateUtils qw(dt_from_string output_pref); > use Koha::Patrons; > use Koha::Biblios; >@@ -356,6 +358,37 @@ sub cancel { > sub { > $self->cancellationdate( dt_from_string->strftime( '%Y-%m-%d %H:%M:%S' ) ); > $self->priority(0); >+ $self->cancellation_reason( $params->{cancellation_reason} ); >+ $self->store(); >+ >+ if ( $params->{cancellation_reason} ) { >+ my $letter = C4::Letters::GetPreparedLetter( >+ module => 'reserves', >+ letter_code => 'HOLD_CANCELLATION', >+ message_transport_type => 'email', >+ branchcode => $self->borrower->branchcode, >+ lang => $self->borrower->lang, >+ tables => { >+ branches => $self->borrower->branchcode, >+ borrowers => $self->borrowernumber, >+ items => $self->itemnumber, >+ biblio => $self->biblionumber, >+ biblioitems => $self->biblionumber, >+ reserves => $self->unblessed, >+ } >+ ); >+ >+ if ($letter) { >+ C4::Letters::EnqueueLetter( >+ { >+ letter => $letter, >+ borrowernumber => $self->borrowernumber, >+ message_transport_type => 'email', >+ } >+ ); >+ } >+ } >+ > $self->_move_to_old; > $self->SUPER::delete(); # Do not add a DELETE log > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc >index a10e281d3b..00b777c526 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc >@@ -1,4 +1,6 @@ > [% USE Koha %] >+[% SET hold_cancellation = AuthorisedValues.GetAuthValueDropbox('HOLD_CANCELLATION') %] >+[% USE AuthorisedValues %] > <table> > <tr> > [% IF ( CAN_user_reserveforothers_modify_holds_priority ) %] >@@ -31,10 +33,10 @@ > <input type="hidden" name="borrowernumber" value="[% hold.borrowernumber | html %]" /> > <input type="hidden" name="biblionumber" value="[% hold.biblionumber | html %]" /> > [% IF Koha.Preference('HoldsSplitQueue') == "nothing" && !hold.found %] >- <select name="rank-request"> >+ <select name="rank-request" class="rank-request" data-hold-id="[% hold.reserve_id %]"> > [% ELSE %] >- <input type="hidden" name="rank-request" value="[% hold.priority | html %]"> >- <select name="rank-request" disabled="disabled"> >+ <input type="hidden" name="rank-request" class="rank-request" value="[% hold.priority | html %]" data-hold-id="[% hold.reserve_id %]"> >+ <select name="rank-request" class="rank-request" disabled="disabled" data-hold-id="[% hold.reserve_id %]"> > [% END %] > [% IF ( hold.found ) %] > [% IF ( hold.intransit ) %] >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 b8ec599508..1845f0012a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -939,6 +939,16 @@ > > <fieldset class="action"> > <input type="submit" class="cancel" name="submit" value="Cancel marked holds" /> >+ >+ [% SET hold_cancellation = AuthorisedValues.GetAuthValueDropbox('HOLD_CANCELLATION') %] >+ [% IF hold_cancellation %] >+ <select name="cancellation-reason"> >+ <option value="">No reason given</option> >+ [% FOREACH reason IN hold_cancellation %] >+ <option value="[% reason.authorised_value | html %]">[% reason.lib | html %]</option> >+ [% END %] >+ </select> >+ [% END %] > </fieldset> > </form> > >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 a6016d68d1..68370a176a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >@@ -819,6 +819,16 @@ > > <fieldset class="action"> > <input type="submit" class="cancel" name="submit" value="Cancel marked holds" /> >+ >+ [% SET hold_cancellation = AuthorisedValues.GetAuthValueDropbox('HOLD_CANCELLATION') %] >+ [% IF hold_cancellation %] >+ <select name="cancellation-reason"> >+ <option value="">No reason given</option> >+ [% FOREACH reason IN hold_cancellation %] >+ <option value="[% reason.authorised_value | html %]">[% reason.lib | html %]</option> >+ [% END %] >+ </select> >+ [% END %] > </fieldset> > </form> > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >index 2f5f0ebdb7..2da776f128 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >@@ -906,6 +906,19 @@ > [% END # /IF biblioloo.reserveloop %] > [% END # FOREACH biblioloo %] > >+ <fieldset class="action"> >+ [% SET hold_cancellation = AuthorisedValues.GetAuthValueDropbox('HOLD_CANCELLATION') %] >+ [% IF hold_cancellation %] >+ <label for="cancellation-reason">Cancellation reason: </label> >+ <select class="cancellation-reason" name="cancellation-reason" id="cancellation-reason"> >+ <option value="">No reason given</option> >+ [% FOREACH reason IN hold_cancellation %] >+ <option value="[% reason.authorised_value | html %]">[% reason.lib | html %]</option> >+ [% END %] >+ </select> >+ [% END %] >+ </fieldset> >+ > <fieldset class="action"> > <input type="submit" name="submit" value="Update hold(s)" /> > </fieldset> >diff --git a/reserve/modrequest.pl b/reserve/modrequest.pl >index 6c134efe3a..83196ff33c 100755 >--- a/reserve/modrequest.pl >+++ b/reserve/modrequest.pl >@@ -71,6 +71,7 @@ else { > for (my $i=0;$i<$count;$i++){ > undef $itemnumber[$i] if !$itemnumber[$i]; > my $suspend_until = $query->param( "suspend_until_" . $reserve_id[$i] ); >+ my $cancellation_reason = $query->param("cancellation-reason"); > my $params = { > rank => $rank[$i], > reserve_id => $reserve_id[$i], >@@ -78,6 +79,7 @@ else { > branchcode => $branch[$i], > itemnumber => $itemnumber[$i], > defined $suspend_until ? ( suspend_until => $suspend_until ) : (), >+ cancellation_reason => $cancellation_reason, > }; > if (C4::Context->preference('AllowHoldDateInFuture')) { > $params->{reservedate} = $reservedates[$i] ? dt_from_string($reservedates[$i]) : undef; >-- >2.24.2 (Apple Git-127)
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 25534
:
105034
|
105035
|
105036
|
105077
|
105078
|
105079
|
105105
|
105106
|
105108
|
105109
|
105110
|
105111
|
105112
|
105113
|
105114
|
105115
|
105116
|
105117
|
105118
|
105119
|
105120
|
105121
|
105122
|
105147
|
105148
|
105149
|
105150
|
105151
|
108476
|
108477
|
108478
|
108479
|
108480
|
108481
|
108746
|
108747
|
108748
|
108749
|
108750
|
108751
|
108752
|
108753
|
108754
|
108755
|
108756
|
108757
|
108805
|
108806
|
108891
|
108892
|
108893
|
108894
|
108895
|
108896
|
108897
|
108898
|
108899
|
108900
|
108901
|
108902
|
108903
|
108904
|
108977
|
108985
|
108986
|
108990
|
114026
|
114027
|
114788