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 355-360
if ( $uploadborrowers && length($uploadborrowers) > 0 ) {
Link Here
|
355 |
|
370 |
|
356 |
$imported++; |
371 |
$imported++; |
357 |
$template->param('lastimported'=>$borrower{'surname'}.' / '.$borrowernumber); |
372 |
$template->param('lastimported'=>$borrower{'surname'}.' / '.$borrowernumber); |
|
|
373 |
push @imported_borrowers, $borrowernumber; #for patronlist |
358 |
} else { |
374 |
} else { |
359 |
$invalid++; |
375 |
$invalid++; |
360 |
push @errors, {unknown_error => 1}; |
376 |
push @errors, {unknown_error => 1}; |
Lines 362-367
if ( $uploadborrowers && length($uploadborrowers) > 0 ) {
Link Here
|
362 |
} |
378 |
} |
363 |
} |
379 |
} |
364 |
} |
380 |
} |
|
|
381 |
|
382 |
if ( $imported && $createpatronlist ) { |
383 |
my $patronlist = AddPatronList({ name => $patronlistname }); |
384 |
AddPatronsToList({ list => $patronlist, borrowernumbers => \@imported_borrowers }); |
385 |
$template->param('patronlistname' => $patronlistname); |
386 |
} |
387 |
|
365 |
(@errors ) and $template->param( ERRORS=>\@errors ); |
388 |
(@errors ) and $template->param( ERRORS=>\@errors ); |
366 |
(@feedback) and $template->param(FEEDBACK=>\@feedback); |
389 |
(@feedback) and $template->param(FEEDBACK=>\@feedback); |
367 |
$template->param( |
390 |
$template->param( |
368 |
- |
|
|