From f7173143853c37e44dec29e42068ee9ca68d4b6c Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 18 May 2022 16:16:58 -0300 Subject: [PATCH] Bug 22456: Allow requesting cancellation from the OPAC Sponsored-by: Montgomery County Public Libraries Signed-off-by: David Nind Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- .../bootstrap/en/includes/holds-table.inc | 17 ++++++++++--- .../bootstrap/en/modules/opac-user.tt | 13 ++++++++++ opac/opac-modrequest.pl | 25 +++++++++++++++---- 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc index d3c84c93b7..c659300642 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc @@ -152,10 +152,19 @@ [% IF ( HOLD.is_cancelable_from_opac ) %]
- - - -
+ + + + + [% ELSIF HOLD.cancellation_requests.count > 0 %] + + [% ELSIF HOLD.is_waiting && HOLD.cancellation_requestable_from_opac %] +
+ + + + +
[% END %] [% END # / IF onlyinfo %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt index c4d0815697..11275fab5f 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -1056,6 +1056,19 @@ ); }); + $(".btn-req-delete-hold").on("click", function(e){ + e.preventDefault(); + var hold_title = $(this).data("title"); + var reserve_id = $(this).data("reserve_id"); + confirmModal( hold_title, _("Are you sure you want to request cancelling this hold?"), _("Yes"), _("No"), function( result ){ + $("#bootstrap-confirm-box-modal").remove() + if( result ){ + $("#req_cancel_hold_" + reserve_id ).submit(); + } + } + ); + }); + $(".btn-delete-article-request").on("click", function(e){ e.preventDefault(); var article_request = $(this).data("title"); diff --git a/opac/opac-modrequest.pl b/opac/opac-modrequest.pl index 05b01a836a..5d83ea3f97 100755 --- a/opac/opac-modrequest.pl +++ b/opac/opac-modrequest.pl @@ -26,9 +26,9 @@ use Modern::Perl; use CGI qw ( -utf8 ); use C4::Output; -use C4::Reserves qw( CanReserveBeCanceledFromOpac ); use C4::Auth qw( get_template_and_user ); use Koha::Holds; + my $query = CGI->new; my ( $template, $borrowernumber, $cookie ) = get_template_and_user( @@ -40,11 +40,26 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( ); my $reserve_id = $query->param('reserve_id'); +my $cancellation_request = $query->param('cancellation_request'); + +if ( $reserve_id && $borrowernumber ) { + + my $hold = Koha::Holds->find($reserve_id); + + unless ( $hold->borrowernumber == $borrowernumber ) { -if ($reserve_id && $borrowernumber) { - if ( CanReserveBeCanceledFromOpac($reserve_id, $borrowernumber) ) { - my $hold = Koha::Holds->find( $reserve_id ); - $hold->cancel if $hold; + # whatcha tryin to do? + print $query->redirect('/cgi-bin/koha/errors/403.pl'); + exit; + } + + if ($cancellation_request) { + $hold->add_cancellation_request + if $hold->cancellation_requestable_from_opac; + } + else { + $hold->cancel + if $hold->is_cancelable_from_opac; } } -- 2.39.5