From 27f76ab88cfdcf8e905533681eac4234859f01fe 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
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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
Signed-off-by: Anneli Österman <anneli.osterman@koha-suomi.fi>
Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com>
---
 .../prog/en/modules/circ/transferstoreceive.tt    | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 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 d656d9ee..c7f346a2 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/transferstoreceive.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/transferstoreceive.tt
@@ -55,14 +55,13 @@
                             >
                             <tbody
                                 >[% FOREACH reser IN branchesloo.reserv %]
-                                    [% SET tr_class = '' %]
-                                    [% IF ( reser.messcompa ) %]
-                                        [% tr_class = 'problem' %]
-                                    [% END %]
-                                    <tr class="[% tr_class | html %]">
-                                        <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
-                                        >
+                                    <tr>
+                                        <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.30.2