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>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Katrin Fischer 2023-03-18 10:13:09 +00:00 committed by Katrin Fischer
parent ff306da736
commit e22e0e09dd
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834
4 changed files with 25 additions and 5 deletions

View file

@ -115,7 +115,12 @@
[% IF ( extendedattribute.type.display_checkout ) %] [%# FIXME We should filter in the line above %]
[% IF ( extendedattribute.attribute.defined ) %]
<li class="patronattribute">
<span class="patronattributelabel">[% extendedattribute.type.description | html %]</span>: [% extendedattribute.description | html %]
<span class="patronattributelabel">[% extendedattribute.type.description | html %]</span>:
[% IF extendedattribute.type.is_date %]
[% extendedattribute.description | $KohaDates %]
[% ELSE %]
[% extendedattribute.description | html %]
[% END %]
</li>
[% END %]
[% END %]

View file

@ -1657,13 +1657,23 @@ legend.collapsed i.fa.fa-caret-down::before {
</select>
[% ELSE %]
[% IF patron_attribute.mandatory %]
<textarea rows="2" cols="30" id="[% patron_attribute.form_id | html %]" name="[% patron_attribute.form_id | html %]" required="required">[% patron_attribute.value | html %]</textarea>
[% IF patron_attribute.is_date %]
<input type="text" id="[% patron_attribute.form_id | html %]" name="[% patron_attribute.form_id | html %]" maxlength="10" size="10" value="[% patron_attribute.value | html %]" required="required" class="flatpickr" data-date_to="to" />
[% ELSE %]
<textarea rows="2" cols="30" id="[% patron_attribute.form_id | html %]" name="[% patron_attribute.form_id | html %]" required="required">[% patron_attribute.value | html %]</textarea>
[% END %]
[% ELSE %]
<textarea rows="2" cols="30" id="[% patron_attribute.form_id | html %]" name="[% patron_attribute.form_id | html %]">[% patron_attribute.value | html %]</textarea>
[% IF patron_attribute.is_date %]
<input type="text" id="[% patron_attribute.form_id | html %]" name="[% patron_attribute.form_id | html %]" maxlength="10" size="10" value="[% patron_attribute.value | html %]" class="flatpickr" data-date_to="to" />
[% ELSE %]
<textarea rows="2" cols="30" id="[% patron_attribute.form_id | html %]" name="[% patron_attribute.form_id | html %]">[% patron_attribute.value | html %]</textarea>
[% END %]
[% END %]
[% END # /IF ( patron_attribute.use_dropdown ) %]
<input type="hidden" id="[% patron_attribute.form_id | html %]_code" name="[% patron_attribute.form_id | html %]_code" value="[% patron_attribute.code | html %]" />
<a href="#" class="clear_attribute"><i class="fa fa-fw fa-trash-can"></i> Clear</a>
[% IF ( !patron_attribute.is_date ) %]
<a href="#" class="clear_attribute"><i class="fa fa-fw fa-trash-can"></i> Clear</a>
[% END %]
[% IF ( patron_attribute.repeatable ) %]
<a href="#" class="clone_attribute"><i class="fa fa-fw fa-plus"></i> New</a>
[% END %]

View file

@ -335,7 +335,11 @@
[% FOREACH item IN attribute.items %]
<li data-pa_code="[% item.type.code | replace('[^a-zA-Z0-9_-]', '') %]">
<span class="label">[% item.type.description | html %]: </span>
[% item.description | html_line_break %]
[% IF item.type.is_date %]
[% item.description | $KohaDates %]
[% ELSE %]
[% item.description | html_line_break %]
[% END %]
</li>
[% END %]
</ol>

View file

@ -880,6 +880,7 @@ sub patron_attributes_form {
category => $attr_type->authorised_value_category(),
category_code => $attr_type->category_code(),
mandatory => $attr_type->mandatory(),
is_date => $attr_type->is_date(),
};
if (exists $attr_hash{$attr_type->code()}) {
foreach my $attr (@{ $attr_hash{$attr_type->code()} }) {