Bug 32610

Summary: Add ability to specify patron attribute as a date
Product: Koha Reporter: Lucas Gass <lucas>
Component: PatronsAssignee: Katrin Fischer <katrin.fischer>
Status: Failed QA --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: andrewfh, caroline.cyr-la-rose, gmcharlt, indradg, jonathan.druart, kyle.m.hall, m.de.rooy, martin.renvoize, pedro.amorim, shi-yao.wang
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20958
Change sponsored?: Unsponsored Patch complexity: Medium patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Bug 32610: Add borrower_attribute_types.is_date to the database
Bug 32610: [DO NOT PUSH] DBIC Update
Bug 32610: Add date option to extended patron attributes administration page
Bug 32610: Add date extended patron attributes to patron module
Bug 32610: Add date extended patron attributes to the OPAC
Bug 32610: Add date extended patron attribute handling to overdues report
Bug 32610: Add borrower_attribute_types.is_date to the database
Bug 32610: [DO NOT PUSH] DBIC Update
Bug 32610: Add date option to extended patron attributes administration page
Bug 32610: Add date extended patron attributes to patron module
Bug 32610: Add date extended patron attributes to the OPAC
Bug 32610: Add date extended patron attribute handling to overdues report
Bug 32610: Add borrower_attribute_types.is_date to the database
Bug 32610: [DO NOT PUSH] DBIC Update
Bug 32610: Add date option to extended patron attributes administration page
Bug 32610: Add date extended patron attributes to patron module
Bug 32610: Add date extended patron attributes to the OPAC
Bug 32610: Add date extended patron attribute handling to overdues report
Bug 32610: Remove data-date_to and tweak comment
Bug 32610: Add borrower_attribute_types.is_date to the database
Bug 32610: [DO NOT PUSH] DBIC Update
Bug 32610: Add date option to extended patron attributes administration page
Bug 32610: Add date extended patron attributes to patron module
Bug 32610: Add date extended patron attributes to the OPAC
Bug 32610: Add date extended patron attribute handling to overdues report
Bug 32610: Remove data-date_to and tweak comment

Description Lucas Gass 2023-01-11 17:51:04 UTC
Sometimes libraries use patron extended attributes that are dates. It would be handy if we could specify that a particular attribute is a date and then have it become a flatpickr instance.
Comment 1 Katrin Fischer 2023-03-18 09:24:19 UTC
*** Bug 6339 has been marked as a duplicate of this bug. ***
Comment 2 Katrin Fischer 2023-03-18 11:00:18 UTC
Created attachment 148400 [details] [review]
Bug 32610: Add borrower_attribute_types.is_date to the database

* Change to kohastructure.sql for new installations
* Atomic database update to add the column for updating
  installations
Comment 3 Katrin Fischer 2023-03-18 11:00:21 UTC
Created attachment 148401 [details] [review]
Bug 32610: [DO NOT PUSH] DBIC Update
Comment 4 Katrin Fischer 2023-03-18 11:00:24 UTC
Created attachment 148402 [details] [review]
Bug 32610: Add date option to extended patron attributes administration page

With this page it will be possible to configure patron attributes
to be a date.

To test:
* Go to administration > patron attribute types
* Add a new patron attribute of type date
  * Dates cannot be repeatable or linked to an AV category, so:
  * Verify, if you check repeatable, date is disabled
  * Verify, if you select an AV category, date disabled
  * Verify, if you check date, AV category and repeatable are disabled
* Save the new patron attribute
* Edit the patron attribute
  * Verify all settings have been kept/stored correctly
Comment 5 Katrin Fischer 2023-03-18 11:00:27 UTC
Created attachment 148403 [details] [review]
Bug 32610: Add date extended patron attributes to patron module

This makes the necessary changes in the patron module of
the staff interface, so the new patron attribute appers and
behaves correctly when editing a patron record.

To test:
* You will need to test different configuration options for
  extended patron attributes (PA) in combination with the date option:
  * PA is a date and not mandatory
    * Patron form should have the calendar widget to let you set the date.
  * PA is a date and mandatory
    * Patron form shoudl have calendar widget and check that the date is
      set for allowing you to save the record.
  * PA is a date and unique
    * For this set the date in one patron record and try to
      set the same date in another. You should not be able to save.
  * PA displays in brief patron information
    * Make sure the date displays on the left formatted correctly
  * When the date PAs are saved, they should display nicely formatted
    on the details tab.
Comment 6 Katrin Fischer 2023-03-18 11:00:30 UTC
Created attachment 148404 [details] [review]
Bug 32610: Add date extended patron attributes to the OPAC

This makes sure that the attributes are handled correctly
when displayed and edited in the OPAC during address changes
or self registration.

To test:
  * You will need to test different configuration options for
    extended patron attributes (PA) in combination with the date option:
    * PA displays in OPAC, but is not editable
      * The date will show nicely formatted on the personal details tab.
    * PA displays and is editable in the OPAC
      * The date can be edited using the calendar widget
    * PA displays, is editabe and mandatory
      * The date is marked as required and you can't save without
        it being set.
  * Test the form behaves correctly when requesting changes for an
    existing patron account and when self registering.
Comment 7 Katrin Fischer 2023-03-18 11:00:34 UTC
Created attachment 148405 [details] [review]
Bug 32610: Add date extended patron attribute handling to overdues report

This makes sure that the overdues report manages filters for
extended patron attributes of the type date correctly.

To test:
* Make sure you have at least one PA marked as 'searchable'
* Make sure your patron has at east one checked out item
* Go to circulation > overdues
* If you have no overdue items, check "Show any items currently checked out:"
* Verify the list of checkouts displays
* Verify the PA filter option displays with the calendar widget
* Limit to the date in your patron's record - list remains
* Limit to any other date - list empties
Comment 8 Philip Orr 2023-03-28 14:00:44 UTC
Created attachment 148825 [details] [review]
Bug 32610: Add borrower_attribute_types.is_date to the database

* Change to kohastructure.sql for new installations
* Atomic database update to add the column for updating
  installations

Signed-off-by: Philip Orr <philip.orr@lmscloud.de>
Comment 9 Philip Orr 2023-03-28 14:00:46 UTC
Created attachment 148826 [details] [review]
Bug 32610: [DO NOT PUSH] DBIC Update

Signed-off-by: Philip Orr <philip.orr@lmscloud.de>
Comment 10 Philip Orr 2023-03-28 14:00:50 UTC
Created attachment 148827 [details] [review]
Bug 32610: Add date option to extended patron attributes administration page

With this page it will be possible to configure patron attributes
to be a date.

To test:
* Go to administration > patron attribute types
* Add a new patron attribute of type date
  * Dates cannot be repeatable or linked to an AV category, so:
  * Verify, if you check repeatable, date is disabled
  * Verify, if you select an AV category, date disabled
  * Verify, if you check date, AV category and repeatable are disabled
* Save the new patron attribute
* Edit the patron attribute
  * Verify all settings have been kept/stored correctly

Signed-off-by: Philip Orr <philip.orr@lmscloud.de>
Comment 11 Philip Orr 2023-03-28 14:00:53 UTC
Created attachment 148828 [details] [review]
Bug 32610: Add date extended patron attributes to patron module

This makes the necessary changes in the patron module of
the staff interface, so the new patron attribute appers and
behaves correctly when editing a patron record.

To test:
* You will need to test different configuration options for
  extended patron attributes (PA) in combination with the date option:
  * PA is a date and not mandatory
    * Patron form should have the calendar widget to let you set the date.
  * PA is a date and mandatory
    * Patron form shoudl have calendar widget and check that the date is
      set for allowing you to save the record.
  * PA is a date and unique
    * For this set the date in one patron record and try to
      set the same date in another. You should not be able to save.
  * PA displays in brief patron information
    * Make sure the date displays on the left formatted correctly
  * When the date PAs are saved, they should display nicely formatted
    on the details tab.

Signed-off-by: Philip Orr <philip.orr@lmscloud.de>
Comment 12 Philip Orr 2023-03-28 14:00:55 UTC
Created attachment 148829 [details] [review]
Bug 32610: Add date extended patron attributes to the OPAC

This makes sure that the attributes are handled correctly
when displayed and edited in the OPAC during address changes
or self registration.

To test:
  * You will need to test different configuration options for
    extended patron attributes (PA) in combination with the date option:
    * PA displays in OPAC, but is not editable
      * The date will show nicely formatted on the personal details tab.
    * PA displays and is editable in the OPAC
      * The date can be edited using the calendar widget
    * PA displays, is editabe and mandatory
      * The date is marked as required and you can't save without
        it being set.
  * Test the form behaves correctly when requesting changes for an
    existing patron account and when self registering.

Signed-off-by: Philip Orr <philip.orr@lmscloud.de>
Comment 13 Philip Orr 2023-03-28 14:00:59 UTC
Created attachment 148830 [details] [review]
Bug 32610: Add date extended patron attribute handling to overdues report

This makes sure that the overdues report manages filters for
extended patron attributes of the type date correctly.

To test:
* Make sure you have at least one PA marked as 'searchable'
* Make sure your patron has at east one checked out item
* Go to circulation > overdues
* If you have no overdue items, check "Show any items currently checked out:"
* Verify the list of checkouts displays
* Verify the PA filter option displays with the calendar widget
* Limit to the date in your patron's record - list remains
* Limit to any other date - list empties

Signed-off-by: Philip Orr <philip.orr@lmscloud.de>
Comment 14 Jonathan Druart 2023-04-25 19:18:48 UTC
Why are you adding data-date_to="to" in memberentrygen?

Not blocker but it would have been more flexible (for future enhancements) to have a datatype='date' column instead of is_date.
Comment 15 Jonathan Druart 2023-04-25 19:20:34 UTC
I guess you should adjust the comment here

circ/overdue.pl:my @patron_attr_filter_loop;   # array of [ domid cgivalue ismany isclone ordinal code description repeatable is_date authorised_value_category ]

koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.tt:        <!-- domid cgivalue ismany isclone ordinal code description repeatable authorised_value_category -->
Comment 16 Shi Yao Wang 2023-10-25 18:56:07 UTC
Created attachment 157862 [details] [review]
Bug 32610: Add borrower_attribute_types.is_date to the database

* Change to kohastructure.sql for new installations
* Atomic database update to add the column for updating
  installations

Signed-off-by: Philip Orr <philip.orr@lmscloud.de>
Comment 17 Shi Yao Wang 2023-10-25 18:56:09 UTC
Created attachment 157863 [details] [review]
Bug 32610: [DO NOT PUSH] DBIC Update

Signed-off-by: Philip Orr <philip.orr@lmscloud.de>
Comment 18 Shi Yao Wang 2023-10-25 18:56:12 UTC
Created attachment 157864 [details] [review]
Bug 32610: Add date option to extended patron attributes administration page

With this page it will be possible to configure patron attributes
to be a date.

To test:
* Go to administration > patron attribute types
* Add a new patron attribute of type date
  * Dates cannot be repeatable or linked to an AV category, so:
  * Verify, if you check repeatable, date is disabled
  * Verify, if you select an AV category, date disabled
  * Verify, if you check date, AV category and repeatable are disabled
* Save the new patron attribute
* Edit the patron attribute
  * Verify all settings have been kept/stored correctly

Signed-off-by: Philip Orr <philip.orr@lmscloud.de>
Comment 19 Shi Yao Wang 2023-10-25 18:56:14 UTC
Created attachment 157865 [details] [review]
Bug 32610: Add date extended patron attributes to patron module

This makes the necessary changes in the patron module of
the staff interface, so the new patron attribute appers and
behaves correctly when editing a patron record.

To test:
* You will need to test different configuration options for
  extended patron attributes (PA) in combination with the date option:
  * PA is a date and not mandatory
    * Patron form should have the calendar widget to let you set the date.
  * PA is a date and mandatory
    * Patron form shoudl have calendar widget and check that the date is
      set for allowing you to save the record.
  * PA is a date and unique
    * For this set the date in one patron record and try to
      set the same date in another. You should not be able to save.
  * PA displays in brief patron information
    * Make sure the date displays on the left formatted correctly
  * When the date PAs are saved, they should display nicely formatted
    on the details tab.

Signed-off-by: Philip Orr <philip.orr@lmscloud.de>
Comment 20 Shi Yao Wang 2023-10-25 18:56:17 UTC
Created attachment 157866 [details] [review]
Bug 32610: Add date extended patron attributes to the OPAC

This makes sure that the attributes are handled correctly
when displayed and edited in the OPAC during address changes
or self registration.

To test:
  * You will need to test different configuration options for
    extended patron attributes (PA) in combination with the date option:
    * PA displays in OPAC, but is not editable
      * The date will show nicely formatted on the personal details tab.
    * PA displays and is editable in the OPAC
      * The date can be edited using the calendar widget
    * PA displays, is editabe and mandatory
      * The date is marked as required and you can't save without
        it being set.
  * Test the form behaves correctly when requesting changes for an
    existing patron account and when self registering.

Signed-off-by: Philip Orr <philip.orr@lmscloud.de>
Comment 21 Shi Yao Wang 2023-10-25 18:56:19 UTC
Created attachment 157867 [details] [review]
Bug 32610: Add date extended patron attribute handling to overdues report

This makes sure that the overdues report manages filters for
extended patron attributes of the type date correctly.

To test:
* Make sure you have at least one PA marked as 'searchable'
* Make sure your patron has at east one checked out item
* Go to circulation > overdues
* If you have no overdue items, check "Show any items currently checked out:"
* Verify the list of checkouts displays
* Verify the PA filter option displays with the calendar widget
* Limit to the date in your patron's record - list remains
* Limit to any other date - list empties

Signed-off-by: Philip Orr <philip.orr@lmscloud.de>
Comment 22 Shi Yao Wang 2023-10-25 18:57:18 UTC
rebase
Comment 23 Shi Yao Wang 2023-10-25 19:09:21 UTC
Created attachment 157868 [details] [review]
Bug 32610: Remove data-date_to and tweak comment
Comment 24 Katrin Fischer 2023-10-25 21:13:18 UTC
Thanks a lot Shi Yao!
Comment 25 Shi Yao Wang 2023-11-15 16:58:44 UTC
Created attachment 158994 [details] [review]
Bug 32610: Add borrower_attribute_types.is_date to the database

* Change to kohastructure.sql for new installations
* Atomic database update to add the column for updating
  installations

Signed-off-by: Philip Orr <philip.orr@lmscloud.de>
Comment 26 Shi Yao Wang 2023-11-15 16:58:47 UTC
Created attachment 158995 [details] [review]
Bug 32610: [DO NOT PUSH] DBIC Update

Signed-off-by: Philip Orr <philip.orr@lmscloud.de>
Comment 27 Shi Yao Wang 2023-11-15 16:58:49 UTC
Created attachment 158996 [details] [review]
Bug 32610: Add date option to extended patron attributes administration page

With this page it will be possible to configure patron attributes
to be a date.

To test:
* Go to administration > patron attribute types
* Add a new patron attribute of type date
  * Dates cannot be repeatable or linked to an AV category, so:
  * Verify, if you check repeatable, date is disabled
  * Verify, if you select an AV category, date disabled
  * Verify, if you check date, AV category and repeatable are disabled
* Save the new patron attribute
* Edit the patron attribute
  * Verify all settings have been kept/stored correctly

Signed-off-by: Philip Orr <philip.orr@lmscloud.de>
Comment 28 Shi Yao Wang 2023-11-15 16:58:52 UTC
Created attachment 158997 [details] [review]
Bug 32610: Add date extended patron attributes to patron module

This makes the necessary changes in the patron module of
the staff interface, so the new patron attribute appers and
behaves correctly when editing a patron record.

To test:
* You will need to test different configuration options for
  extended patron attributes (PA) in combination with the date option:
  * PA is a date and not mandatory
    * Patron form should have the calendar widget to let you set the date.
  * PA is a date and mandatory
    * Patron form shoudl have calendar widget and check that the date is
      set for allowing you to save the record.
  * PA is a date and unique
    * For this set the date in one patron record and try to
      set the same date in another. You should not be able to save.
  * PA displays in brief patron information
    * Make sure the date displays on the left formatted correctly
  * When the date PAs are saved, they should display nicely formatted
    on the details tab.

Signed-off-by: Philip Orr <philip.orr@lmscloud.de>
Comment 29 Shi Yao Wang 2023-11-15 16:58:54 UTC
Created attachment 158998 [details] [review]
Bug 32610: Add date extended patron attributes to the OPAC

This makes sure that the attributes are handled correctly
when displayed and edited in the OPAC during address changes
or self registration.

To test:
  * You will need to test different configuration options for
    extended patron attributes (PA) in combination with the date option:
    * PA displays in OPAC, but is not editable
      * The date will show nicely formatted on the personal details tab.
    * PA displays and is editable in the OPAC
      * The date can be edited using the calendar widget
    * PA displays, is editabe and mandatory
      * The date is marked as required and you can't save without
        it being set.
  * Test the form behaves correctly when requesting changes for an
    existing patron account and when self registering.

Signed-off-by: Philip Orr <philip.orr@lmscloud.de>
Comment 30 Shi Yao Wang 2023-11-15 16:58:56 UTC
Created attachment 158999 [details] [review]
Bug 32610: Add date extended patron attribute handling to overdues report

This makes sure that the overdues report manages filters for
extended patron attributes of the type date correctly.

To test:
* Make sure you have at least one PA marked as 'searchable'
* Make sure your patron has at east one checked out item
* Go to circulation > overdues
* If you have no overdue items, check "Show any items currently checked out:"
* Verify the list of checkouts displays
* Verify the PA filter option displays with the calendar widget
* Limit to the date in your patron's record - list remains
* Limit to any other date - list empties

Signed-off-by: Philip Orr <philip.orr@lmscloud.de>
Comment 31 Shi Yao Wang 2023-11-15 16:58:59 UTC
Created attachment 159000 [details] [review]
Bug 32610: Remove data-date_to and tweak comment
Comment 32 Shi Yao Wang 2023-11-15 16:59:10 UTC
rebase
Comment 33 Pedro Amorim 2023-12-22 14:43:02 UTC
Failing QA here:

- Missing tests
- import_borrowers.tt should check if a given patron_attribute that's being added is is_date and validate the data accordingly, else the following bug may occur:

1) Create a patron attribute type of is_date as per the original test plan, named 'date'
2) Import a patron, visit:
/cgi-bin/koha/tools/import_borrowers.pl
3) Click "Download a Starter CSV file with all the columns." and add a cardnumber, categorycode, branchcode and on the patron_attributes column put date:test
4) Import, notice the import is successful, now visit that patron edit page (do a search for the imported cardnumber), e.g. example for patron id 289:
/cgi-bin/koha/members/moremember.pl?borrowernumber=289
5) Notice it blows up with error:
Template process failed: undef error - The given date (teste) does not match the date format (iso) at /kohadevbox/koha/Koha/DateUtils.pm line 205.
 at /kohadevbox/koha/C4/Templates.pm line 127
Comment 34 Pedro Amorim 2023-12-22 14:48:02 UTC
Not a blocker, but why the design decision of restricting a date attribute type to not be able to also be repeatable?

I can't find many good examples of how a repeatable date field would be useful, but I don't understand why we wouldn't allow it either.
Comment 35 Katrin Fischer 2023-12-23 11:31:02 UTC
(In reply to Pedro Amorim from comment #34)
> Not a blocker, but why the design decision of restricting a date attribute
> type to not be able to also be repeatable?
> 
> I can't find many good examples of how a repeatable date field would be
> useful, but I don't understand why we wouldn't allow it either.

Mostly because I wanted to keep it a bit more simple and thought that could still be done later if required. 

I had picked this up to work on in my free time, because it seemed something that people were interested in, but it grew quickly and got more complicated than I had first imagined. 

I think I'd definitely need some help to solve the import issue (good testing btw!) and probably the tests as well.

I am also a bit worried about the batch patron edit - at the time of me writing this patch set I had some trouble testing it because of a blocking bug.
Comment 36 Katrin Fischer 2024-04-01 13:11:41 UTC
I cannot continue here on my own - happy if someone wants to take over or collaborate in some way.