Bug 41849: Add 'Cancel all holds in this hold group' button

To the same filled holds check in modal

Signed-off-by: Bob Bennhoff <bbennhoff@clicweb.org>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Pedro Amorim 2026-04-02 10:34:18 +00:00 committed by Lucas Gass
parent 5ae5ac3330
commit 15c63014ef
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 37 additions and 4 deletions

View File

@ -33,9 +33,7 @@
[% BLOCK display_hold_group_info %]
[% IF ( hold_group_id ) %]
<h4><strong>[% t('Part of a hold group') | html %]:</strong></h4>
<a target="_blank" href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% patron.borrowernumber | uri %]#holds_panel">
<i class="fa fa-fw fa-external-link-alt"></i> [% t("View patron's holds") | html %]
</a>
<a target="_blank" href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% patron.borrowernumber | uri %]#holds_panel"> <i class="fa fa-fw fa-external-link-alt"></i> [% t("View patron's holds") | html %] </a>
[% END %]
[% END %]
@ -787,7 +785,14 @@
[% END %]
</select>
[% END %]
<button type="button" class="btn btn-default deny cancel-hold" accesskey="X"> <i class="fa fa-trash-can"></i> Cancel hold (X) </button>
[% IF ( hold_group_id ) %]
<button type="button" class="btn btn-default deny cancel-hold-group" data-borrowernumber="[% patron.borrowernumber | html %]" data-holdgroupid="[% hold_group_id | html %]" accesskey="X">
<i class="fa fa-trash-can"></i> Cancel all holds in hold group (X)
</button>
<button type="button" class="btn btn-default deny cancel-hold" accesskey="X"> <i class="fa fa-trash-can"></i> Cancel this hold (X) </button>
[% ELSE %]
<button type="button" class="btn btn-default deny cancel-hold" accesskey="X"> <i class="fa fa-trash-can"></i> Cancel hold (X) </button>
[% END %]
</fieldset>
</div>
<!-- /.modal-footer -->
@ -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);
},
});
}
});
});
</script>
[% END %]