From c27ba125ea244daba34c02afaf1293fb8c3c2e40 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Wed, 3 Jan 2018 11:53:59 +0100 Subject: [PATCH] Bug 19909: Show attributes in patron search results Add a new column (hidden by default) in the results table which displays all attributes associated to the corresponding patron. Test plan: 1. Enable ExtendedPatronAttributes 2. Create some patron attribute types, with and without an associated authorised value category 3. Choose an existing patron and set a value for each attribute 4. Go to patron search and do a search that will return your patron (and some others to avoid the redirection) 5. Show column 'Extended attributes' by clicking on 'Column visibility' button 6. Note that all attributes are displayed correctly 7. prove t/db_dependent/Koha/Patron/Attributes.t 8. Disable syspref ExtendedPatronAttributes and verify that the column is not displayed Signed-off-by: Cab Vinton --- C4/Utils/DataTables/Members.pm | 4 ++++ admin/columns_settings.yml | 3 +++ .../intranet-tmpl/prog/en/modules/members/member.tt | 10 ++++++++++ .../prog/en/modules/members/tables/members_results.tt | 4 ++++ 4 files changed, 21 insertions(+) diff --git a/C4/Utils/DataTables/Members.pm b/C4/Utils/DataTables/Members.pm index 29efd0bd3c..6fd151999b 100644 --- a/C4/Utils/DataTables/Members.pm +++ b/C4/Utils/DataTables/Members.pm @@ -4,6 +4,7 @@ use Modern::Perl; use C4::Context; use C4::Utils::DataTables; use Koha::DateUtils; +use Koha::Patron::Attributes; sub search { my ( $params ) = @_; @@ -213,6 +214,9 @@ sub search { my $balance = $patron_object->account->balance; # FIXME Should be formatted from the template $patron->{fines} = sprintf("%.2f", $balance); + if (C4::Context->preference('ExtendedPatronAttributes')) { + $patron->{attributes} = Koha::Patron::Attributes->search({ borrowernumber => $patron_object->borrowernumber }); + } if( $patron->{dateexpiry} ) { # FIXME We should not format the date here, do it in template-side instead diff --git a/admin/columns_settings.yml b/admin/columns_settings.yml index 323c431d6e..7e9c795580 100644 --- a/admin/columns_settings.yml +++ b/admin/columns_settings.yml @@ -705,6 +705,9 @@ modules: columnname: od_checkouts - columnname: fines + - + columnname: extended_attributes + is_hidden: 1 - columnname: circ_notes - diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt index 209932b7a6..e8c94bd6c6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt @@ -103,6 +103,9 @@ Expires on OD/Checkouts Fines + [% IF Koha.Preference('ExtendedPatronAttributes') %] + Extended attributes + [% END %] Circ note   @@ -369,6 +372,10 @@ [%# Remove the first column if we do not display the checkbox %] columns_settings.splice(0, 1); [% END %] + [% UNLESS Koha.Preference('ExtendedPatronAttributes') %] + const extendedAttributesColumnIndex = columns_settings.findIndex(column => column.columnname === 'extended_attributes'); + columns_settings.splice(extendedAttributesColumnIndex, 1); + [% END %] dtMemberResults = KohaTable("memberresultst", { 'bServerSide': true, 'sAjaxSource': "/cgi-bin/koha/svc/members/search", @@ -438,6 +445,9 @@ { 'mDataProp': 'dt_dateexpiry' }, { 'mDataProp': 'dt_od_checkouts', 'bSortable': false }, { 'mDataProp': 'dt_fines', 'bSortable': false }, + [% IF Koha.Preference('ExtendedPatronAttributes') %] + { 'mDataProp': 'dt_extended_attributes', 'bSortable': false }, + [% END %] { 'mDataProp': 'dt_borrowernotes' }, { 'mDataProp': 'dt_action', 'bSortable': false, 'sClass': 'actions' } ], diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/members_results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/members_results.tt index ae6364dedf..f8868ff00c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/members_results.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/members_results.tt @@ -3,6 +3,7 @@ [% USE AuthorisedValues %] [% USE KohaDates %] [% USE Price %] +[% USE Koha %] { "sEcho": [% sEcho | html %], "iTotalRecords": [% iTotalRecords | html %], @@ -30,6 +31,9 @@ "[% IF data.overdues %][% data.overdues | html %][% ELSE %][% data.overdues | html %][% END %] / [% data.issues | html %]", "dt_fines": "[% IF data.fines < 0 %][% data.fines | $Price %][% ELSIF data.fines > 0 %][% data.fines | $Price %][% ELSE %][% data.fines | $Price %][% END %]", + [% IF Koha.Preference('ExtendedPatronAttributes') %] + "dt_extended_attributes": "", + [% END %] "dt_borrowernotes": "[% data.borrowernotes | html_line_break | collapse | $To %]", "dt_action": -- 2.20.1