From 7270703b3555810aa5ed5863c848085733d0c373 Mon Sep 17 00:00:00 2001 From: Baptiste Wojtkowski Date: Thu, 27 Jun 2024 16:11:03 +0200 Subject: [PATCH] Bug 34756: Cancelling a hold does not cancel the related transfer When a hold is confirmed and its pickup location is different from the item's location, a transfer is initiated. If the hold is cancelled, the item remains in transfer whereas it is no longer needed at the transfer destination. Is this normal behaviour ? It seems that staff users should at least see a message about the transfer and maybe have the ability to cancel it. Steps to reproduce: 1. Create an item at library A 2. Place a hold on this item with a pickup location at library B 3. Check in the item at library A 4. Confirm the hold. The item should now be in transit to library B 5. Cancel the hold. There is no message about the probably useless transfer. NEW TEST PLAN 1. Create an item at library A 2. Place a hold on this item with a pickup location at library B 3. Check in the item at library A 3-bis. Try to cancel the hold: notice there is no message 4. Confirm the hold. The item should now be in transit to library B 5. Cancel the hold. There is now a message to propose you to cancel the related transfer 6. Do not check the checkbox. There is no hold but still a transfer 7. Repeat the whole process checking the checkbox. Thers is no hold and the transfer has been cancelled. --- koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc | 2 +- .../intranet-tmpl/prog/en/modules/reserve/request.tt | 8 ++++++++ reserve/request.pl | 7 +++++++ 3 files changed, 16 insertions(+), 1 deletion(-) 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 af0e79c..0356084 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc @@ -237,7 +237,7 @@ [%- END -%] [%- END -%] - + 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 335aa63..67b8af5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -1457,6 +1457,8 @@ [% END %] [% END %] +
+ @@ -1852,9 +1854,15 @@ $("#cancel_modal_form #inputs").empty(); let reserve_id = cancel_link.data('id'); let biblionumber = cancel_link.data('biblionumber'); + let transfer = cancel_link.data('transfer'); $("#cancel_modal_form #inputs").append(''); $("#cancel_modal_form #inputs").append(''); $("#cancel_modal_form #inputs").append(''); + if(transfer){ + $("#transfer-cancellation").empty() + $("#transfer-cancellation").append(''); + $("#transfer-cancellation").append(' '); + } $('#cancelModal').modal(); return false; }); diff --git a/reserve/request.pl b/reserve/request.pl index 5d08877..75456bc 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -113,7 +113,13 @@ if ( $op eq 'cud-move' ) { elsif ( $op eq 'cud-cancel' ) { my $reserve_id = $input->param('reserve_id'); my $cancellation_reason = $input->param("cancellation-reason"); + my $transfer = $input->param("transfer-cancel") ? "1" : "0"; my $hold = Koha::Holds->find($reserve_id); + + if( $transfer ) { + warn($hold->item()->get_transfer); + $hold->item()->get_transfer->cancel( { reason => 'Manual', 'force' => '1' } ); + } $hold->cancel( { cancellation_reason => $cancellation_reason } ) if $hold; } elsif ( $op eq 'cud-setLowestPriority' ) { @@ -627,6 +633,7 @@ if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) $reserve{'found'} = $res->is_found(); $reserve{'inprocessing'} = $res->is_in_processing(); $reserve{'intransit'} = $res->is_in_transit(); + $reserve{'transfer'} = $res->item()->get_transfer() ? '1' : '0'; } elsif ( $res->priority() > 0 ) { if ( my $item = $res->item() ) { -- 2.43.0