use Getopt::Long qw(:config no_ignore_case);
use C4::Context;
-use C4::Members;
+use Koha::Patrons;
binmode STDOUT, ":encoding(UTF-8)";
$0 -h
-f, --field=FIELD Field to export. It is repeatable and has to match
- keys returned by the GetMemberDetails function.
+ column names of the borrower table (also as 'description' and 'category_type'
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=\\;
- If no separator is specifield, a comma will be used.
+ If no separator is specified, the delimiter pref
+ will be used (or a comma, if the pref is empty)
-H, --show-header Print field names on first row
-w, --where=CONDITION Condition to filter borrowers to export
(SQL where clause).
- CONDITION must be enclosed by double quotes and
- if needed, where value by single quotes.
- example : --where "surname='De Lattre'"
+ CONDITION must be enclosed by double quotes
+ You can use single quotes around a field value
+ within the condition like:
+ --where "surname='De Lattre'"
-h, --help Show this help
USAGE
my $csv = Text::CSV->new( { sep_char => $separator, binary => 1 } );
-# If the user did not specify any field to export, we assume he wants them all
+# If the user did not specify any field to export, we assume they want them all
# We retrieve the first borrower informations to get field names
my ($borrowernumber) = $sth->fetchrow_array or die "No borrower to export";
-my $member = GetMemberDetails($borrowernumber);
+my $patron = Koha::Patrons->find( $borrowernumber ); # FIXME Now is_expired is no longer available
+ # We will have to use Koha::Patron and allow method calls
+my $category = $patron->category;
+my $member = $patron->unblessed;
+$member->{description} = $category->description;
+$member->{category_type} = $category->category_type;
+
@fields = keys %$member unless (@fields);
if ($show_header) {
print $csv->string . "\n";
while ( my $borrowernumber = $sth->fetchrow_array ) {
- $member = GetMemberDetails($borrowernumber);
+ my $patron = Koha::Patrons->find( $borrowernumber );
+ my $category = $patron->category;
+ my $member = $patron->unblessed;
+ $member->{description} = $category->description;
+ $member->{category_type} = $category->category_type;
$csv->combine(
map {
( defined $member->{$_} and !ref $member->{$_} )