From 1014f9b26284a0c8568b83e4003b94be96791dca Mon Sep 17 00:00:00 2001
From: Lucas Gass <lucas@bywatersolutions.com>
Date: Tue, 5 Dec 2023 16:40:15 +0000
Subject: [PATCH] Bug 35488: Open holds tab by default on opac-user.pl after
 placing a hold

1 - Place a hold on the opac
2 - Note after placing the hold the URL is:
    http://localhost:8080/cgi-bin/koha/opac-user.pl?#opac-user-holds
3 - Note the holds tab is not active
4 - APPLY PATCH and restart_all
5 - Try steps 1 - 3 again, this time the holds tab should be opened.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
---
 koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt | 3 +++
 opac/opac-reserve.pl                                  | 2 +-
 opac/opac-user.pl                                     | 1 +
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt
index b183ebaef4..76f69b76c2 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt
@@ -1084,6 +1084,9 @@
             }
         }
         $(document).ready(function(){
+            [% IF ( opac_user_holds ) %]
+                $("#opac-user-views a[href='#opac-user-holds_panel']").tab("show");
+            [% END %]
             $('#opac-user-article-requests caption .count').html(AR_CAPTION_COUNT.format('[% current_article_requests.size | html %]'));
 
             $(".modal-nojs").addClass("modal").addClass("hide").removeClass("modal-nojs");
diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl
index 641b8c749d..fb1fcfe345 100755
--- a/opac/opac-reserve.pl
+++ b/opac/opac-reserve.pl
@@ -330,7 +330,7 @@ if ( $query->param('place_reserve') ) {
         }
     }
 
-    print $query->redirect("/cgi-bin/koha/opac-user.pl?" . ( @failed_holds ? "failed_holds=" . join('|',@failed_holds) : q|| ) . "#opac-user-holds");
+    print $query->redirect("/cgi-bin/koha/opac-user.pl?" . ( @failed_holds ? "failed_holds=" . join('|',@failed_holds) : q|| ) . "&opac-user-holds=1");
     exit;
 }
 
diff --git a/opac/opac-user.pl b/opac/opac-user.pl
index f5588c0aa3..72637f03ce 100755
--- a/opac/opac-user.pl
+++ b/opac/opac-user.pl
@@ -418,6 +418,7 @@ $template->param(
     AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'),
     OpacHoldNotes            => C4::Context->preference('OpacHoldNotes'),
     failed_holds             => scalar $query->param('failed_holds'),
+    opac_user_holds          => scalar $query->param('opac-user-holds') || 0,
 );
 
 # if not an empty string this indicates to return
-- 
2.43.0