View | Details | Raw Unified | Return to bug 14493
Collapse All | Expand All

(-)a/misc/export_borrowers.pl (-4 / +7 lines)
Lines 24-29 use Text::CSV; Link Here
24
use Getopt::Long qw(:config no_ignore_case);
24
use Getopt::Long qw(:config no_ignore_case);
25
25
26
use C4::Context;
26
use C4::Context;
27
use C4::Members::Attributes qw(GetBorrowerAttributes);
27
use Koha::Patrons;
28
use Koha::Patrons;
28
29
29
binmode STDOUT, ":encoding(UTF-8)";
30
binmode STDOUT, ":encoding(UTF-8)";
Lines 41-49 $0 [--field=FIELD [--field=FIELD [...]]] [--separator=CHAR] [--show-header] [--w Link Here
41
$0 -h
42
$0 -h
42
43
43
    -f, --field=FIELD       Field to export. It is repeatable and has to match
44
    -f, --field=FIELD       Field to export. It is repeatable and has to match
44
                            column names of the borrower table (also as 'description' and 'category_type'
45
                            column names of the borrower table (with 'description',
45
                            If no field is specified, then all fields will be
46
                            'category_type', and 'patron_attributes' also being
46
                            exported.
47
                            options). If no field is specified, then all fields
48
                            will be exported.
47
    -s, --separator=CHAR    This character will be used to separate fields.
49
    -s, --separator=CHAR    This character will be used to separate fields.
48
                            Some characters like | or ; will need to be escaped
50
                            Some characters like | or ; will need to be escaped
49
                            in the parameter setting, like -s=\\| or -s=\\;
51
                            in the parameter setting, like -s=\\| or -s=\\;
Lines 105-110 my $category = $patron->category; Link Here
105
my $member = $patron->unblessed;
107
my $member = $patron->unblessed;
106
$member->{description} = $category->description;
108
$member->{description} = $category->description;
107
$member->{category_type} = $category->category_type;
109
$member->{category_type} = $category->category_type;
110
$member->{'patron_attributes'} = join (",", map { $_->{code}.":".$_->{value} } @{GetBorrowerAttributes($borrowernumber)});
108
111
109
@fields = keys %$member unless (@fields);
112
@fields = keys %$member unless (@fields);
110
113
Lines 131-136 while ( my $borrowernumber = $sth->fetchrow_array ) { Link Here
131
    my $member = $patron->unblessed;
134
    my $member = $patron->unblessed;
132
    $member->{description} = $category->description;
135
    $member->{description} = $category->description;
133
    $member->{category_type} = $category->category_type;
136
    $member->{category_type} = $category->category_type;
137
    $member->{'patron_attributes'} = join (",", map { $_->{code}.":".$_->{value} } @{GetBorrowerAttributes($borrowernumber)});
134
    $csv->combine(
138
    $csv->combine(
135
        map {
139
        map {
136
            ( defined $member->{$_} and !ref $member->{$_} )
140
            ( defined $member->{$_} and !ref $member->{$_} )
137
- 

Return to bug 14493