Lines 22-27
use Text::CSV;
Link Here
|
22 |
|
22 |
|
23 |
use C4::Members; |
23 |
use C4::Members; |
24 |
use C4::Branch; |
24 |
use C4::Branch; |
|
|
25 |
use Koha::DateUtils; |
25 |
|
26 |
|
26 |
sub import_patrons { |
27 |
sub import_patrons { |
27 |
my ($params) = @_; |
28 |
my ($params) = @_; |
Lines 71-81
sub import_patrons {
Link Here
|
71 |
} |
72 |
} |
72 |
|
73 |
|
73 |
push @feedback, { feedback => 1, name => 'headerrow', value => join( ', ', @csvcolumns ) }; |
74 |
push @feedback, { feedback => 1, name => 'headerrow', value => join( ', ', @csvcolumns ) }; |
74 |
my $today_iso = C4::Dates->new()->output('iso'); |
75 |
my $today_iso = output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } ); |
75 |
my @criticals = qw(surname branchcode categorycode); # there probably should be others |
76 |
my @criticals = qw(surname branchcode categorycode); # there probably should be others |
76 |
my @bad_dates; # I've had a few. |
77 |
my @bad_dates; # I've had a few. |
77 |
my $date_re = C4::Dates->new->regexp('syspref'); |
|
|
78 |
my $iso_re = C4::Dates->new->regexp('iso'); |
79 |
LINE: while ( my $borrowerline = <$handle> ) { |
78 |
LINE: while ( my $borrowerline = <$handle> ) { |
80 |
my %borrower; |
79 |
my %borrower; |
81 |
my @missing_criticals; |
80 |
my @missing_criticals; |
Lines 168-180
sub import_patrons {
Link Here
|
168 |
# Popular spreadsheet applications make it difficult to force date outputs to be zero-padded, but we require it. |
167 |
# Popular spreadsheet applications make it difficult to force date outputs to be zero-padded, but we require it. |
169 |
foreach (qw(dateofbirth dateenrolled dateexpiry)) { |
168 |
foreach (qw(dateofbirth dateenrolled dateexpiry)) { |
170 |
my $tempdate = $borrower{$_} or next; |
169 |
my $tempdate = $borrower{$_} or next; |
171 |
if ( $tempdate =~ /$date_re/ ) { |
170 |
$tempdate = eval { output_pref( { dt => dt_from_string( $tempdate ), dateonly => 1, dateformat => 'iso' } ); }; |
172 |
$borrower{$_} = format_date_in_iso($tempdate); |
171 |
if ($tempdate) { |
173 |
} |
|
|
174 |
elsif ( $tempdate =~ /$iso_re/ ) { |
175 |
$borrower{$_} = $tempdate; |
172 |
$borrower{$_} = $tempdate; |
176 |
} |
173 |
} else { |
177 |
else { |
|
|
178 |
$borrower{$_} = ''; |
174 |
$borrower{$_} = ''; |
179 |
push @missing_criticals, { key => $_, line => $., lineraw => $borrowerline, bad_date => 1 }; |
175 |
push @missing_criticals, { key => $_, line => $., lineraw => $borrowerline, bad_date => 1 }; |
180 |
} |
176 |
} |
Lines 212-217
sub import_patrons {
Link Here
|
212 |
$invalid++; |
208 |
$invalid++; |
213 |
next; |
209 |
next; |
214 |
} |
210 |
} |
|
|
211 |
|
212 |
# generate a proper login if none provided |
213 |
if ( $borrower{userid} eq '' || !Check_Userid( $borrower{userid} ) ) { |
214 |
push @errors, { duplicate_userid => 1, userid => $borrower{userid} }; |
215 |
$invalid++; |
216 |
next LINE; |
217 |
} |
215 |
|
218 |
|
216 |
if ($borrowernumber) { |
219 |
if ($borrowernumber) { |
217 |
|
220 |
|
Lines 280-286
sub import_patrons {
Link Here
|
280 |
$patron_attributes = extended_attributes_merge( $old_attributes, $patron_attributes ); |
283 |
$patron_attributes = extended_attributes_merge( $old_attributes, $patron_attributes ); |
281 |
} |
284 |
} |
282 |
push @errors, { unknown_error => 1 } |
285 |
push @errors, { unknown_error => 1 } |
283 |
unless SetBorrowerAttributes( $borrower{'borrowernumber'}, $patron_attributes ); |
286 |
unless SetBorrowerAttributes( $borrower{'borrowernumber'}, $patron_attributes, 'no_branch_limit' ); |
284 |
} |
287 |
} |
285 |
$overwritten++; |
288 |
$overwritten++; |
286 |
push( |
289 |
push( |
287 |
- |
|
|