From ffae0400a70d1435033cfea45a87e7515bfc94ca Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 2 Apr 2026 10:34:18 +0000 Subject: [PATCH] Bug 41849: Add 'Cancel all holds in this hold group' button To the same filled holds check in modal Signed-off-by: Bob Bennhoff Signed-off-by: Andrew Fuerste Henry Signed-off-by: Lucas Gass (cherry picked from commit 15c63014ef7dc66d72630c02d89f04a19cce8932) Signed-off-by: Jacob O'Mara --- .../prog/en/modules/circ/returns.tt | 41 +++++++++++++++++-- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt index f033573bd8..10eb4e1e24 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt @@ -33,9 +33,7 @@ [% BLOCK display_hold_group_info %] [% IF ( hold_group_id ) %]

[% t('Part of a hold group') | html %]:

- - [% t("View patron's holds") | html %] - + [% t("View patron's holds") | html %] [% END %] [% END %] @@ -785,7 +783,14 @@ [% END %] [% END %] - + [% IF ( hold_group_id ) %] + + + [% ELSE %] + + [% END %] @@ -1787,6 +1792,34 @@ }); [% END %] [% END %] + + $(".cancel-hold-group").on("click", function (e) { + e.preventDefault(); + + const borrowernumber = $(this).data("borrowernumber"); + const hold_group_id = $(this).data("holdgroupid"); + + // Assuming you have a reason input with id #cancellation_reason + const reason = $("#cancellation-reason").val() || ""; + + if (confirm(_("Are you sure you want to cancel all holds in this hold's group?"))) { + $.ajax({ + url: `/api/v1/patrons/${borrowernumber}/hold_groups/${hold_group_id}/cancel`, + type: "POST", + contentType: "application/json", + data: JSON.stringify({ + cancellation_reason: reason, + }), + success: function (response) { + location.reload(); + }, + error: function (xhr) { + alert(_("An error occurred while cancelling the hold group.")); + console.error(xhr.responseText); + }, + }); + } + }); }); [% END %]