Bug 32373 - Show date of restriction on patron screen
Summary: Show date of restriction on patron screen
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Matt Blenkinsop
QA Contact: Katrin Fischer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-11-29 21:54 UTC by Suzanne
Modified: 2023-12-28 20:42 UTC (History)
10 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact: Caroline Cyr La Rose
Documentation submission: https://gitlab.com/koha-community/koha-manual/-/merge_requests/691
Text to go in the release notes:
**Sponsored by** *PTFS Europe* This enhancement adds the date a restriction was added to patron restriction messages, for example: "Restricted since 31/12/2022: Patron's account is restricted until 31/12/2022 with the explanation:...".
Version(s) released in:
23.05.00


Attachments
Photo of patron account with restriction and flags (where I'd love to see the date they were placed) (27.58 KB, image/jpeg)
2022-11-29 21:54 UTC, Suzanne
Details
Bug 32373: Show patron restriction date (2.53 KB, patch)
2022-12-22 15:26 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Patch showing patron restriction date (48.93 KB, image/png)
2022-12-22 15:28 UTC, Matt Blenkinsop
Details
Bug 32373: Show patron restriction date (2.56 KB, patch)
2022-12-22 21:23 UTC, David Nind
Details | Diff | Splinter Review
Bug 32373: Show patron restriction date (2.88 MB, patch)
2022-12-23 10:39 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 32373: Show patron restriction date (4.02 KB, patch)
2022-12-23 11:32 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 32373: Show patron restriction date (4.04 KB, patch)
2022-12-23 19:56 UTC, David Nind
Details | Diff | Splinter Review
Bug 32373: Show patron restriction date (3.63 KB, patch)
2023-01-03 12:00 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 32373: (follow-up) Show patron restriction date (1.29 KB, patch)
2023-01-03 15:29 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 32373: Show patron restriction date (3.67 KB, patch)
2023-01-03 15:32 UTC, Lucas Gass
Details | Diff | Splinter Review
Bug 32373: (follow-up) Show patron restriction date (1.33 KB, patch)
2023-01-03 15:32 UTC, Lucas Gass
Details | Diff | Splinter Review
Bug 32373: Show patron restriction date (2.75 KB, patch)
2023-02-15 15:50 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 32373: Show patron restriction date (2.79 KB, patch)
2023-02-23 12:50 UTC, PTFS Europe Sandboxes
Details | Diff | Splinter Review
Bug 32373: Show patron restriction date (2.85 KB, patch)
2023-03-04 15:36 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 32373: Show patron restriction date (2.92 KB, patch)
2023-03-04 15:37 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Suzanne 2022-11-29 21:54:55 UTC
Created attachment 144337 [details]
Photo of patron account with restriction and flags (where I'd love to see the date they were placed)

It would be nice to see the date a restriction was placed, without having to go in and view the restrictions. We are planning to add a more detailed message about the restriction, so it would be nice to be able to look for the date without having to leave the page. It would also be nice to get a date for when the lost card and gone--no address flags were added. (See attached photo.)
Comment 1 Matt Blenkinsop 2022-12-22 15:26:41 UTC Comment hidden (obsolete)
Comment 2 Matt Blenkinsop 2022-12-22 15:28:00 UTC
Created attachment 144797 [details]
Patch showing patron restriction date
Comment 3 David Nind 2022-12-22 21:23:35 UTC Comment hidden (obsolete)
Comment 4 David Nind 2022-12-22 21:31:01 UTC
Hi Matt.

I've signed off, but should the date be displayed using the format set in the dateformat system preference? 

(Similar to the way the rest of the restriction message displays if an expiration date is set, for example I set the date format to dd/mm/yyyy: "Restricted since 2022-12-22: Patron's account is restricted until 31/12/2022 with the explanation: ...".)

I've also added a draft release note, and change the bug title to sentence case.

David
Comment 5 Matt Blenkinsop 2022-12-23 09:23:44 UTC
Hi David,

Its a good point about the date, I have used the timestamp that is created when a restriction is entered but this will be a generic SQL format. I will have a look at converting it to the syspref date format and re-submit.

Matt
Comment 6 Matt Blenkinsop 2022-12-23 10:39:40 UTC Comment hidden (obsolete)
Comment 7 Matt Blenkinsop 2022-12-23 11:32:55 UTC Comment hidden (obsolete)
Comment 8 David Nind 2022-12-23 19:56:30 UTC
Created attachment 144828 [details] [review]
Bug 32373: Show patron restriction date

When viewing a patron account with a restriction there is no way to see when the restriction was placed. This is available in the borrower_debarrments table and has now been added to the UI and matched to the 'dateformat' syspref. (Previous commit missed the moremember.tt render and the syspref formatting)

Test plan:
1) Create a restriction on a patron and navigate to that patron in Checkouts or the patron details page
2) There should be a message with details about the restriction but the creation date of the restriction won't be included in the message
3) Apply patch
4) The message should now say "Restricted since DATE" as in the screenshot attached.
5) Change the 'dateformat' syspref and refresh, the date should change to reflect the syspref

Signed-off-by: David Nind <david@davidnind.com>
Comment 9 David Nind 2022-12-23 19:58:10 UTC
(In reply to Matt Blenkinsop from comment #5)
> Hi David,
> 
> Its a good point about the date, I have used the timestamp that is created
> when a restriction is entered but this will be a generic SQL format. I will
> have a look at converting it to the syspref date format and re-submit.
> 
> Matt

Thanks Matt!

Now signed off.

David
Comment 10 Katrin Fischer 2022-12-27 22:26:04 UTC
Hi Matt, have a look at the KohaDates TT filter. It will format the date nicely for you according to the DAteFormat system preference.
Comment 11 Katrin Fischer 2022-12-27 22:27:51 UTC
Some of the variables have a little typo: $debarrment -> debarment

Might be nice to fix to avoid confusion in the future.
Comment 12 Matt Blenkinsop 2023-01-03 12:00:14 UTC
(In reply to Katrin Fischer from comment #10)
> Hi Matt, have a look at the KohaDates TT filter. It will format the date
> nicely for you according to the DAteFormat system preference.

Thanks for the hint Katrin, I have used the filter and also fixed the typo - resubmitted for sign-off
Comment 13 Matt Blenkinsop 2023-01-03 12:00:49 UTC
Created attachment 144931 [details] [review]
Bug 32373: Show patron restriction date

When viewing a patron account with a restriction there is no way to see when the restriction was placed. This is available in the borrower_debarrments table and has now been added to the UI and matched to the 'dateformat' syspref. (Previous commit missed the moremember.tt render and the syspref formatting - this is now being done with the KohaDates template filter)

Test plan:
1) Create a restriction on a patron and navigate to that patron in Checkouts or the patron details page
2) There should be a message with details about the restriction but the creation date of the restriction won't be included in the message
3) Apply patch
4) The message should now say "Restricted since DATE" as in the screenshot attached.
5) Change the 'dateformat' syspref and refresh, the date should change to reflect the syspref
Comment 14 Katrin Fischer 2023-01-03 13:56:24 UTC
I believe this could be removed again now, could you confirm?
-use Koha::DateUtils qw( dt_from_string );
+use Koha::DateUtils qw( dt_from_string format_sqldatetime );
Comment 15 Lucas Gass 2023-01-03 15:07:14 UTC
(In reply to Katrin Fischer from comment #14)
> I believe this could be removed again now, could you confirm?
> -use Koha::DateUtils qw( dt_from_string );
> +use Koha::DateUtils qw( dt_from_string format_sqldatetime );

Yes, it looks like 'format_sqldatetime' is not needed.
Comment 16 Matt Blenkinsop 2023-01-03 15:29:25 UTC
Created attachment 144942 [details] [review]
Bug 32373: (follow-up) Show patron restriction date

Unnecessary import of format_sqldatetime has now been removed

Test plan:
1) Create a restriction on a patron and navigate to that patron in Checkouts or the patron details page
2) There should be a message with details about the restriction but the creation date of the restriction won't be included in the message
3) Apply patch
4) The message should now say "Restricted since DATE" as in the screenshot attached.
5) Change the 'dateformat' syspref and refresh, the date should change to reflect the syspref
Comment 17 Lucas Gass 2023-01-03 15:32:13 UTC
Created attachment 144943 [details] [review]
Bug 32373: Show patron restriction date

When viewing a patron account with a restriction there is no way to see when the restriction was placed. This is available in the borrower_debarrments table and has now been added to the UI and matched to the 'dateformat' syspref. (Previous commit missed the moremember.tt render and the syspref formatting - this is now being done with the KohaDates template filter)

Test plan:
1) Create a restriction on a patron and navigate to that patron in Checkouts or the patron details page
2) There should be a message with details about the restriction but the creation date of the restriction won't be included in the message
3) Apply patch
4) The message should now say "Restricted since DATE" as in the screenshot attached.
5) Change the 'dateformat' syspref and refresh, the date should change to reflect the syspref

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 18 Lucas Gass 2023-01-03 15:32:17 UTC
Created attachment 144944 [details] [review]
Bug 32373: (follow-up) Show patron restriction date

Unnecessary import of format_sqldatetime has now been removed

Test plan:
1) Create a restriction on a patron and navigate to that patron in Checkouts or the patron details page
2) There should be a message with details about the restriction but the creation date of the restriction won't be included in the message
3) Apply patch
4) The message should now say "Restricted since DATE" as in the screenshot attached.
5) Change the 'dateformat' syspref and refresh, the date should change to reflect the syspref

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 19 Kyle M Hall 2023-02-10 19:21:22 UTC
Bug 31095 removed GetDebarments. This could be rewritten to use Koha::Patron::restrictions, and would require only template modifications.
Comment 20 Matt Blenkinsop 2023-02-15 15:50:31 UTC
Created attachment 146693 [details] [review]
Bug 32373: Show patron restriction date

This is a rebased submission following bug 31095 which removed the use of GetDebarments. This patch now uses $patron->restrictions to find the date and pass it to the template

Test plan:
1) Create a restriction on a patron and navigate to that patron in Checkouts or the patron details page
2) There should be a message with details about the restriction but the creation date of the restriction won't be included in the message
3) Apply patch
4) The message should now say "Restricted since DATE" as in the screenshot attached.
5) Change the 'dateformat' syspref and refresh, the date should change to reflect the syspref
Comment 21 Laura Escamilla 2023-02-15 18:31:12 UTC
I received the following error: "NameError: global name 'host' is not defined"


(In reply to Matt Blenkinsop from comment #20)
> Created attachment 146693 [details] [review] [review]
> Bug 32373: Show patron restriction date
> 
> This is a rebased submission following bug 31095 which removed the use of
> GetDebarments. This patch now uses $patron->restrictions to find the date
> and pass it to the template
> 
> Test plan:
> 1) Create a restriction on a patron and navigate to that patron in Checkouts
> or the patron details page
> 2) There should be a message with details about the restriction but the
> creation date of the restriction won't be included in the message
> 3) Apply patch
> 4) The message should now say "Restricted since DATE" as in the screenshot
> attached.
> 5) Change the 'dateformat' syspref and refresh, the date should change to
> reflect the syspref
Comment 22 Matt Blenkinsop 2023-02-16 09:23:27 UTC
Hi Laura,

Where are you seeing this error? I just applied the patch onto a fresh branch and can't see a similar error anywhere
Comment 23 Laura Escamilla 2023-02-16 11:51:54 UTC
(In reply to Matt Blenkinsop from comment #22)
> Hi Laura,
> 
> Where are you seeing this error? I just applied the patch onto a fresh
> branch and can't see a similar error anywhere

Please disregard the error message. It looks like it's exclusive to the Sandboxes. My apologies!
Comment 24 PTFS Europe Sandboxes 2023-02-23 12:50:06 UTC
Created attachment 147230 [details] [review]
Bug 32373: Show patron restriction date

This is a rebased submission following bug 31095 which removed the use of GetDebarments. This patch now uses $patron->restrictions to find the date and pass it to the template

Test plan:
1) Create a restriction on a patron and navigate to that patron in Checkouts or the patron details page
2) There should be a message with details about the restriction but the creation date of the restriction won't be included in the message
3) Apply patch
4) The message should now say "Restricted since DATE" as in the screenshot attached.
5) Change the 'dateformat' syspref and refresh, the date should change to reflect the syspref

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>
Comment 25 Sally 2023-02-23 12:51:19 UTC
Works as described, thanks for the patch.
Comment 26 Laura Escamilla 2023-02-23 14:37:12 UTC
(In reply to PTFS Europe Sandboxes from comment #24)
> Created attachment 147230 [details] [review] [review]
> Bug 32373: Show patron restriction date
> 
> This is a rebased submission following bug 31095 which removed the use of
> GetDebarments. This patch now uses $patron->restrictions to find the date
> and pass it to the template
> 
> Test plan:
> 1) Create a restriction on a patron and navigate to that patron in Checkouts
> or the patron details page
> 2) There should be a message with details about the restriction but the
> creation date of the restriction won't be included in the message
> 3) Apply patch
> 4) The message should now say "Restricted since DATE" as in the screenshot
> attached.
> 5) Change the 'dateformat' syspref and refresh, the date should change to
> reflect the syspref
> 
> Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>

Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Comment 27 Katrin Fischer 2023-03-04 15:36:26 UTC
Created attachment 147763 [details] [review]
Bug 32373: Show patron restriction date

This is a rebased submission following bug 31095 which removed the use of GetDebarments. This patch now uses $patron->restrictions to find the date and pass it to the template

Test plan:
1) Create a restriction on a patron and navigate to that patron in Checkouts or the patron details page
2) There should be a message with details about the restriction but the creation date of the restriction won't be included in the message
3) Apply patch
4) The message should now say "Restricted since DATE" as in the screenshot attached.
5) Change the 'dateformat' syspref and refresh, the date should change to reflect the syspref

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 28 Katrin Fischer 2023-03-04 15:37:17 UTC
Created attachment 147764 [details] [review]
Bug 32373: Show patron restriction date

This is a rebased submission following bug 31095 which removed the use of GetDebarments. This patch now uses $patron->restrictions to find the date and pass it to the template

Test plan:
1) Create a restriction on a patron and navigate to that patron in Checkouts or the patron details page
2) There should be a message with details about the restriction but the creation date of the restriction won't be included in the message
3) Apply patch
4) The message should now say "Restricted since DATE" as in the screenshot attached.
5) Change the 'dateformat' syspref and refresh, the date should change to reflect the syspref

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>
Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 29 Katrin Fischer 2023-03-04 15:38:06 UTC
Added Laura's sign-off line to the patch.
Thx, Matt!
Comment 30 Tomás Cohen Arazi 2023-03-31 10:38:00 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 31 Matt Blenkinsop 2023-04-11 11:33:12 UTC
Enhancement - not backporting to 22.11.x

Nice work everyone!