From 2891b0d5e62d3638cb1cafde2a1af90a21bcf23e Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Tue, 20 Feb 2024 12:52:43 +0000 Subject: [PATCH] Bug 18360: Allow to delete a cancelled order from open basket Doing this under flag of order_manage and not on the higher level of baskets. Starting here with a single order delete for cancelled lines. So deleting an open order line requires cancelling it first. Can be extended later if needed. Test plan: Pick an open basket with cancelled lines. Try to delete a few lines. Test that you cannot do this on an closed basket. (Bonus: manipulate URL with basketno, ordernumber and op=cud-delete-order.) Signed-off-by: Marcel de Rooy Signed-off-by: Michaela Sieber Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- acqui/basket.pl | 17 ++++++++++++- .../prog/en/modules/acqui/basket.tt | 25 ++++++++++++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/acqui/basket.pl b/acqui/basket.pl index fa22520c63..c5b86a5c19 100755 --- a/acqui/basket.pl +++ b/acqui/basket.pl @@ -119,7 +119,22 @@ $template->param( skip_confirm_reopen => 1) if $confirm_pref eq '2'; my @messages; -if ( $op eq 'cud-delete_confirm' ) { +if ( $op eq 'cud-delete-order' ) { + output_and_exit( $query, $cookie, $template, 'insufficient_permission' ) + unless $logged_in_patron->has_permission( { acquisition => 'order_manage' } ); + + # We only allow deleting cancelled line without biblionumber for now + my $ordernumber = $query->param('ordernumber'); + my $order = Koha::Acquisition::Orders->search( + { + biblionumber => undef, + ordernumber => $ordernumber, orderstatus => 'cancelled' + } + ); + $order->delete if $order; + $op = 'list'; + +} elsif ( $op eq 'cud-delete_confirm' ) { output_and_exit( $query, $cookie, $template, 'insufficient_permission' ) unless $logged_in_patron->has_permission( { acquisition => 'delete_baskets' } ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt index a41111c115..abc7ceed97 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt @@ -781,6 +781,7 @@ GST % GST Fund + Delete order @@ -844,11 +845,19 @@ [% order.total_tax_included | $Price %] [% order.tax_rate * 100 | html %] [% order.tax_value | $Price %] - [% order.budget_name | html %] + [% order.budget_name | html %] + + [% UNLESS closedate %]Delete[% END %] + [% END # /FOREACH order %] +
+ + + +
[% END # /IF (cancelledorders_loop) %]
@@ -1113,6 +1122,20 @@ window.location = "/cgi-bin/koha/acqui/basket.pl?op=edi_confirm&basketno=[% basketno | html %]"; } } + + $(document).ready(function() { + $(".delete_order").on('click', function(e) { + e.preventDefault(); + if( $(this).data('biblionumber') ) { + alert( _("Please delete the linked bibliographic record first.") ); + return false; + } else if( !confirm(_("Are you sure you want to delete this order line?")) ) { + return false; + } + $('#delete_order_form input[name="ordernumber"]').val( $(this).data('ordernumber') ); + $('#delete_order_form').submit(); + }); + }); [% ELSE %]