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 90994b30aa..7eed2e5591 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 %]
@@ -787,7 +785,14 @@
[% END %]
[% END %]
-
+ [% IF ( hold_group_id ) %]
+
+
+ [% ELSE %]
+
+ [% END %]
@@ -1804,6 +1809,34 @@
});
}
}
+
+ $(".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 %]