From 7c22b2aebfc6452a9f54d04526d4978082cd4e57 Mon Sep 17 00:00:00 2001 From: Vitor Fernandes Date: Thu, 12 Jul 2018 15:17:38 -0400 Subject: [PATCH] Bug 14493: export_borrowers.pl - Export patron attributes Tweaked Vitor's original patch to accomodate changes to the file. Signed-off-by: Maryse Simard --- misc/export_borrowers.pl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/misc/export_borrowers.pl b/misc/export_borrowers.pl index 4733c3c..5f8e10f 100755 --- a/misc/export_borrowers.pl +++ b/misc/export_borrowers.pl @@ -25,6 +25,7 @@ use Getopt::Long qw(:config no_ignore_case); use Koha::Script; use C4::Context; +use C4::Members::Attributes qw(GetBorrowerAttributes); use Koha::Patrons; binmode STDOUT, ":encoding(UTF-8)"; @@ -42,9 +43,10 @@ $0 [--field=FIELD [--field=FIELD [...]]] [--separator=CHAR] [--show-header] [--w $0 -h -f, --field=FIELD Field to export. It is repeatable and has to match - column names of the borrower table (also as 'description' and 'category_type' - If no field is specified, then all fields will be - exported. + column names of the borrower table (with 'description', + 'category_type', and 'patron_attributes' also being + options). If no field is specified, then all fields + will be exported. -s, --separator=CHAR This character will be used to separate fields. Some characters like | or ; will need to be escaped in the parameter setting, like -s=\\| or -s=\\; @@ -106,6 +108,7 @@ my $category = $patron->category; my $member = $patron->unblessed; $member->{description} = $category->description; $member->{category_type} = $category->category_type; +$member->{'patron_attributes'} = join (",", map { $_->{code}.":".$_->{value} } @{GetBorrowerAttributes($borrowernumber)}); @fields = keys %$member unless (@fields); @@ -132,6 +135,7 @@ while ( my $borrowernumber = $sth->fetchrow_array ) { my $member = $patron->unblessed; $member->{description} = $category->description; $member->{category_type} = $category->category_type; + $member->{'patron_attributes'} = join (",", map { $_->{code}.":".$_->{value} } @{GetBorrowerAttributes($borrowernumber)}); $csv->combine( map { ( defined $member->{$_} and !ref $member->{$_} ) -- 2.7.4