From 27bb216172b977119adae7a03a6ab5bdfb6c2b7c Mon Sep 17 00:00:00 2001
From: Owen Leonard <oleonard@myacpl.org>
Date: Thu, 6 Feb 2025 15:23:43 +0000
Subject: [PATCH] Bug 39046: Use Bootstrap badge to indicate late transfers

This patch removes the error class from the table of late transfers.
Instead, the days late status is shown as a Bootstrap badge. The patch
also adds pluralization to the string so that it adapts based on the
number of late transfers.

To test you would ideally have multiple pending transfers to your
library, some late and some not. This will presumably require manually
updated your database to change the date of pending transfers.

- Make at least one transfer multiple days late by changing the
   `datesent` value to a date late enough to exceed the number of days
   defined in the TransfersMaxDaysWarning system preference.
- Make at least one transfer only one day late.
- When you go to Circulation -> Transfers to receive you should see
  badge-style labels on the transfers which are late.
  - The text of the labels should be correct according to the number: "1
    day late" or "XX days late"

Sponsored-by: Athens County Public Libraries
---
 .../prog/en/modules/circ/transferstoreceive.tt        | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/transferstoreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/transferstoreceive.tt
index 81bde6eead..f8865ff3be 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/transferstoreceive.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/transferstoreceive.tt
@@ -62,12 +62,13 @@
                 <th>&nbsp;</th>
             </tr></thead>
             <tbody>[% FOREACH reser IN branchesloo.reserv %]
-                [% IF ( reser.messcompa ) %]
-                <tr class="problem">
-                [% ELSE %]
                 <tr>
-                [% END %]
-                    <td data-order="[% reser.datetransfer | html %]"><p>[% reser.datetransfer | $KohaDates %]</p> [% IF ( reser.messcompa ) %]<span class="error">Transfer is [% reser.diff | html %] days late</span>[% END %]</td>
+                    <td data-order="[% reser.datetransfer | html %]">
+                        [% reser.datetransfer | $KohaDates %]
+                        [% IF ( reser.messcompa ) %]
+                            <span class="badge bg-warning text-dark">[% tnx('{count} day late', '{count} days late', reser.diff, { count = reser.diff }) %]</span>
+                        [% END %]
+                    </td>
                     <td>
                         [% INCLUDE 'biblio-title.inc' biblio=reser link = 1 %] [% IF ( reser.author ) %]by [% reser.author | html %][% END %]
                             [% IF ( reser.itemtype ) %] (<strong>[% reser.itemtype | html %]</strong>)[% END %]
-- 
2.39.5