From a74f68c606531b474dbba0463587708f80262b65 Mon Sep 17 00:00:00 2001
From: Phil Ringnalda <phil@chetcolibrary.org>
Date: Fri, 21 Jun 2024 12:20:05 -0700
Subject: [PATCH] Bug 37152: Aquisitions basket and OPAC suggestion deletion
 should use the op cud-delete

Both deleting a basket in Aquisitions and deleting a suggestion in the OPAC
take care of the confirmation in a javascript modal, rather than having a
whole separate page for confirmation, so they should be using the op
cud-delete rather than either cud-delete_confirm (which shouldn't ever be
used) or delete_confirm (which they aren't doing, they already confirmed).

Test plan:
1. There's no wrong behavior to see, so apply patch and restart_all
2. Aquisitions - Vendor search for My Vendor - Click My Basket
3. Click Delete basket, in the popup again Delete basket
4. Click Show baskets for vendor My Vendor and verify the basket is gone
5. OPAC - Your account - Purchase suggestions
6. Create a suggestion, then click the checkbox for it, Delete selected,
   confirm
7. Verify the suggestion was deleted

Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
---
 acqui/basket.pl                                             | 2 +-
 koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt     | 6 +++---
 .../opac-tmpl/bootstrap/en/modules/opac-suggestions.tt      | 2 +-
 opac/opac-suggestions.pl                                    | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/acqui/basket.pl b/acqui/basket.pl
index 8cc57bbd10..38a555ef52 100755
--- a/acqui/basket.pl
+++ b/acqui/basket.pl
@@ -134,7 +134,7 @@ if ( $op eq 'cud-delete-order' ) {
     $order->delete if $order;
     $op = 'list';
 
-} elsif ( $op eq 'cud-delete_confirm' ) {
+} elsif ( $op eq 'cud-delete' ) {
 
     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 c815cadc75..651200ac25 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt
@@ -146,7 +146,7 @@
                                                     <button type="button" class="btn btn-primary" data-dismiss="modal">Cancel</button>
                                                     <form action="/cgi-bin/koha/acqui/basket.pl" method="post">
                                                         [% INCLUDE 'csrf-token.inc' %]
-                                                        <input type="hidden" name="op" value="cud-delete_confirm" />
+                                                        <input type="hidden" name="op" value="cud-delete" />
                                                         <input type="hidden" name="basketno" value="[% basketno | html %]" />
                                                         <input type="hidden" name="booksellerid" value="[% booksellerid | html %]" />
                                                         <input type="hidden" name="delbiblio" value="0" />
@@ -165,7 +165,7 @@
                                                     <button type="button" class="btn btn-primary" data-dismiss="modal">Cancel</button>
                                                     <form action="/cgi-bin/koha/acqui/basket.pl" method="post">
                                                         [% INCLUDE 'csrf-token.inc' %]
-                                                        <input type="hidden" name="op" value="cud-delete_confirm" />
+                                                        <input type="hidden" name="op" value="cud-delete" />
                                                         <input type="hidden" name="basketno" value="[% basketno | html %]" />
                                                         <input type="hidden" name="booksellerid" value="[% booksellerid | html %]" />
                                                         <input type="hidden" name="delbiblio" value="0" />
@@ -174,7 +174,7 @@
 
                                                     <form action="/cgi-bin/koha/acqui/basket.pl" method="post">
                                                         [% INCLUDE 'csrf-token.inc' %]
-                                                        <input type="hidden" name="op" value="cud-delete_confirm" />
+                                                        <input type="hidden" name="op" value="cud-delete" />
                                                         <input type="hidden" name="basketno" value="[% basketno | html %]" />
                                                         <input type="hidden" name="booksellerid" value="[% booksellerid | html %]" />
                                                         <input type="hidden" name="delbiblio" value="1" />
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt
index a1956df42b..7c5feb8d84 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt
@@ -374,7 +374,7 @@
                                 [% SET can_delete_suggestion = 0 %]
                                 <form action="/cgi-bin/koha/opac-suggestions.pl" method="post" id="delete_suggestions">
                                     [% INCLUDE 'csrf-token.inc' %]
-                                    <input type="hidden" name="op" value="cud-delete_confirm" />
+                                    <input type="hidden" name="op" value="cud-delete" />
                                     [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
                                         <div id="toolbar" class="toolbar clearfix">
                                         [% IF ( Koha.Preference('MaxTotalSuggestions') != '' && patrons_total_suggestions_count >= Koha.Preference('MaxTotalSuggestions') ) %]
diff --git a/opac/opac-suggestions.pl b/opac/opac-suggestions.pl
index 8a81e01b52..528bd9ccd7 100755
--- a/opac/opac-suggestions.pl
+++ b/opac/opac-suggestions.pl
@@ -232,7 +232,7 @@ my $suggestions = [ Koha::Suggestions->search_limited(
     }
 )->as_list ];
 
-if ( $op eq "cud-delete_confirm" ) {
+if ( $op eq "cud-delete" ) {
     my @delete_field = $input->multi_param("delete_field");
     foreach my $delete_field (@delete_field) {
         &DelSuggestion( $borrowernumber, $delete_field );
-- 
2.34.1