use Modern::Perl;
-use C4::Auth;
-use C4::Output;
+use C4::Auth qw( get_template_and_user );
+use C4::Output qw( output_and_exit output_html_with_http_headers );
use C4::Templates;
use Koha::Patrons;
-use Koha::DateUtils;
+use Koha::DateUtils qw( dt_from_string );
use Koha::Token;
use Koha::Libraries;
use Koha::Patron::Categories;
use Koha::Patron::Attribute::Types;
-use Koha::List::Patron;
+use Koha::List::Patron qw( AddPatronList AddPatronsToList );
use Koha::Patrons::Import;
my $Import = Koha::Patrons::Import->new();
use CGI qw ( -utf8 );
-my ( @errors, @feedback );
my $extended = C4::Context->preference('ExtendedPatronAttributes');
my @columnkeys = map { $_ ne 'borrowernumber' ? $_ : () } Koha::Patrons->columns();
push( @columnkeys, 'patron_attributes' ) if $extended;
-push( @columnkeys, qw( relationship guarantor_id guarantor_firstname guarantor_surname ) );
+push( @columnkeys, qw( guarantor_relationship guarantor_id ) );
my $input = CGI->new();
-#push @feedback, {feedback=>1, name=>'backend', value=>$csv->backend, backend=>$csv->backend}; #XXX
-
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "tools/import_borrowers.tt",
query => $input,
type => "intranet",
- authnotrequired => 0,
flagsrequired => { tools => 'import_patrons' },
- debug => 1,
}
);
# get the patron categories and pass them to the template
-my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
+my @patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']});
$template->param( categories => \@patron_categories );
my $columns = C4::Templates::GetColumnDefs( $input )->{borrowers};
$columns = [ grep { $_->{field} ne 'borrowernumber' ? $_ : () } @$columns ];
exit 0;
}
+my @preserve_fields = $input->param('preserve_existing');
+
my $uploadborrowers = $input->param('uploadborrowers');
my $matchpoint = $input->param('matchpoint');
if ($matchpoint) {
my $handle = $input->upload('uploadborrowers');
my %defaults = $input->Vars;
-
+ my $overwrite_passwords = defined $input->param('overwrite_passwords') ? 1 : 0;
my $return = $Import->import_patrons(
{
file => $handle,
defaults => \%defaults,
matchpoint => $matchpoint,
- overwrite_cardnumber => $input->param('overwrite_cardnumber'),
- overwrite_passwords => $input->param('overwrite_passwords'),
- preserve_extended_attributes => $input->param('ext_preserve') || 0,
+ overwrite_cardnumber => scalar $input->param( 'overwrite_cardnumber' ),
+ overwrite_passwords => $overwrite_passwords,
+ preserve_extended_attributes => scalar $input->param( 'ext_preserve' ) || 0,
+ preserve_fields => \@preserve_fields,
}
);