https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30657

--- Comment #54 from Martin Renvoize (ashimema) 
<[email protected]> ---
Created attachment 209026
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=209026&action=edit
Bug 30657: Make patron attributes available via Template Toolkit in notices

Add Koha::Patron->extended_attribute_values, which returns a hashref of
the patron's extended attribute values keyed by attribute type code.
Repeatable types map to an arrayref (empty when there are no values),
non-repeatable types to the single value (undef when unset).

This makes the attributes easy to reach from notices:

  [% borrower.extended_attribute_values.UNCLE %]

  [% FOREACH nick IN borrower.extended_attribute_values.NICKNAMES %]
    [% nick | html %]
  [% END %]

Earlier revisions of this patch added an accessor per attribute code
(borrower.UNCLE), generated through AUTOLOAD. As noted in QA, that
could collide with existing or future Koha::Patron methods and columns,
and made every missing method call query the attribute types. Keeping
the attributes under a single, explicitly named accessor avoids both, and
needs no dynamic method generation.

To test:
1. Run the unit tests inside KTD:
     ktd --shell --run 'prove t/db_dependent/Koha/Patron.t'
2. In Administration > Patron attribute types, create two types:
   - UNCLE, not repeatable
   - NICKNAMES, repeatable
3. Edit a patron and set UNCLE to BOB and two values for NICKNAMES,
   e.g. Al and Alex.
4. In Tools > Notices & slips, edit the HOLD_SLIP (or any slip that
   receives the patron as `borrower`) and add to its content:
     [% IF borrower.extended_attribute_values.UNCLE == 'BOB' %]Bob is your
uncle[% END %]
     [% FOREACH nick IN borrower.extended_attribute_values.NICKNAMES %]
       Nickname: [% nick | html %]
     [% END %]
5. Place a hold for that patron and print the hold slip (or use the
   notice preview where available) and confirm the output shows
   "Bob is your uncle" and both nicknames.
6. Confirm that an attribute type that has no value for the patron
   renders as empty and does not cause an error.
7. Sign off

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to