Lines 52-57
use Koha::DateUtils;
Link Here
|
52 |
use Koha::Token; |
52 |
use Koha::Token; |
53 |
use Koha::Libraries; |
53 |
use Koha::Libraries; |
54 |
use Koha::Patron::Categories; |
54 |
use Koha::Patron::Categories; |
|
|
55 |
use Koha::List::Patron; |
55 |
|
56 |
|
56 |
use Text::CSV; |
57 |
use Text::CSV; |
57 |
# Text::CSV::Unicode, even in binary mode, fails to parse lines with these diacriticals: |
58 |
# Text::CSV::Unicode, even in binary mode, fails to parse lines with these diacriticals: |
Lines 105-110
if ($matchpoint) {
Link Here
|
105 |
} |
106 |
} |
106 |
my $overwrite_cardnumber = $input->param('overwrite_cardnumber'); |
107 |
my $overwrite_cardnumber = $input->param('overwrite_cardnumber'); |
107 |
|
108 |
|
|
|
109 |
#create a patronlist |
110 |
my $createpatronlist = $input->param('createpatronlist') || 0; |
111 |
my $dt = dt_from_string(); |
112 |
my $timestamp = $dt->ymd('-').' '.$dt->hms(':'); |
113 |
my $patronlistname = $uploadborrowers . ' (' . $timestamp .')'; |
114 |
|
108 |
$template->param( SCRIPT_NAME => '/cgi-bin/koha/tools/import_borrowers.pl' ); |
115 |
$template->param( SCRIPT_NAME => '/cgi-bin/koha/tools/import_borrowers.pl' ); |
109 |
|
116 |
|
110 |
if ( $uploadborrowers && length($uploadborrowers) > 0 ) { |
117 |
if ( $uploadborrowers && length($uploadborrowers) > 0 ) { |
Lines 114-126
if ( $uploadborrowers && length($uploadborrowers) > 0 ) {
Link Here
|
114 |
token => scalar $input->param('csrf_token'), |
121 |
token => scalar $input->param('csrf_token'), |
115 |
}); |
122 |
}); |
116 |
|
123 |
|
|
|
124 |
#create a patronlist |
125 |
my $createpatronlist = $input->param('createpatronlist'); |
126 |
my $dt = dt_from_string(); |
127 |
my $timestamp = $dt->ymd('-').' '.$dt->hms(':'); |
128 |
my $patronlistname = $uploadborrowers. ' (' . $timestamp .')'; |
129 |
|
117 |
push @feedback, {feedback=>1, name=>'filename', value=>$uploadborrowers, filename=>$uploadborrowers}; |
130 |
push @feedback, {feedback=>1, name=>'filename', value=>$uploadborrowers, filename=>$uploadborrowers}; |
118 |
my $handle = $input->upload('uploadborrowers'); |
131 |
my $handle = $input->upload('uploadborrowers'); |
119 |
my $uploadinfo = $input->uploadInfo($uploadborrowers); |
132 |
my $uploadinfo = $input->uploadInfo($uploadborrowers); |
120 |
foreach (keys %$uploadinfo) { |
133 |
foreach (keys %$uploadinfo) { |
121 |
push @feedback, {feedback=>1, name=>$_, value=>$uploadinfo->{$_}, $_=>$uploadinfo->{$_}}; |
134 |
push @feedback, {feedback=>1, name=>$_, value=>$uploadinfo->{$_}, $_=>$uploadinfo->{$_}}; |
122 |
} |
135 |
} |
|
|
136 |
|
123 |
my $imported = 0; |
137 |
my $imported = 0; |
|
|
138 |
my @imported_borrowers; |
124 |
my $alreadyindb = 0; |
139 |
my $alreadyindb = 0; |
125 |
my $overwritten = 0; |
140 |
my $overwritten = 0; |
126 |
my $invalid = 0; |
141 |
my $invalid = 0; |
Lines 356-361
if ( $uploadborrowers && length($uploadborrowers) > 0 ) {
Link Here
|
356 |
|
371 |
|
357 |
$imported++; |
372 |
$imported++; |
358 |
$template->param('lastimported'=>$borrower{'surname'}.' / '.$borrowernumber); |
373 |
$template->param('lastimported'=>$borrower{'surname'}.' / '.$borrowernumber); |
|
|
374 |
push @imported_borrowers, $borrowernumber; #for patronlist |
359 |
} else { |
375 |
} else { |
360 |
$invalid++; |
376 |
$invalid++; |
361 |
push @errors, {unknown_error => 1}; |
377 |
push @errors, {unknown_error => 1}; |
Lines 363-368
if ( $uploadborrowers && length($uploadborrowers) > 0 ) {
Link Here
|
363 |
} |
379 |
} |
364 |
} |
380 |
} |
365 |
} |
381 |
} |
|
|
382 |
|
383 |
if ( $imported && $createpatronlist ) { |
384 |
my $patronlist = AddPatronList({ name => $patronlistname }); |
385 |
AddPatronsToList({ list => $patronlist, borrowernumbers => \@imported_borrowers }); |
386 |
$template->param('patronlistname' => $patronlistname); |
387 |
} |
388 |
|
366 |
(@errors ) and $template->param( ERRORS=>\@errors ); |
389 |
(@errors ) and $template->param( ERRORS=>\@errors ); |
367 |
(@feedback) and $template->param(FEEDBACK=>\@feedback); |
390 |
(@feedback) and $template->param(FEEDBACK=>\@feedback); |
368 |
$template->param( |
391 |
$template->param( |
369 |
- |
|
|