From e049cc2c10a3b5c1b5d81d964ae799651d5d066d Mon Sep 17 00:00:00 2001
From: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Date: Wed, 27 Sep 2023 12:35:58 -0400
Subject: [PATCH] Bug 34901: Display transit status on patron holds tab only if
 hold found value is "T"

Check the transit status of the *hold* in addition to the transit status
of the *item*, to avoid displaying a misleading transit status on
item-level holds when the item is actually in transit for a different
hold

To test:
1. Create a record-level hold for Patron A for pickup at a library other
   than the logged-in library
2. Check in an item to fill that hold
3. Put an item-level hold on that same item for Patron B at a different
   library other than the logged-in library
4. Open Patron A's and Patron B's account details pages in separate tabs
--> Note that the Holds tab on Patron A's account detail page correctly
    shows that their hold is in-transit
--> Note that the Holds tab on Patron B's account detail page incorrectly
    shows that their hold on the same item is also in-transit
4. Apply patch
5. Clear browser cache
6. Refresh both patrons' account details pages
--> Confirm that the holds tab on Patron A's account still correctly
    says their hold is in-transit
--> Confirm that the holds tab on Patron B's account now correctly shows
    a blank status for their hold
7. Cancel Patron A's hold
8. Check in the item again to put it in transit for Patron B's hold
9. Reload Patron B's account page
--> Confirm that the holds tab on Patron B's account now correctly says
    their hold is in-transit

Signed-off-by: Tuomas Kunttu <tuomas.kunttu@kouvola.fi>
---
 koha-tmpl/intranet-tmpl/prog/js/holds.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/js/holds.js b/koha-tmpl/intranet-tmpl/prog/js/holds.js
index 01538ebc31..7004ae6ab8 100644
--- a/koha-tmpl/intranet-tmpl/prog/js/holds.js
+++ b/koha-tmpl/intranet-tmpl/prog/js/holds.js
@@ -300,9 +300,9 @@ $(document).ready(function() {
 
                                     }
 
-                                } else if ( oObj.transferred ) {
+                                } else if ( oObj.found == "T" && oObj.transferred ) {
                                     data += __("Item is <strong>in transit</strong> from %s since %s").format(oObj.from_branch, oObj.date_sent);
-                                } else if ( oObj.not_transferred ) {
+                                } else if ( oObj.found == "T" && oObj.not_transferred ) {
                                     data += __("Item hasn't been transferred yet from %s").format(oObj.not_transferred_by);
                                 }
                                 data += "</em>";
-- 
2.30.2