Bug 30952: Header search - move tabs to the right (and other tweaks)
[koha-ffzg.git] / misc / import_patrons.pl
index f840601..6dc037d 100755 (executable)
@@ -19,8 +19,8 @@
 
 use Modern::Perl;
 
-use Getopt::Long;
-use Pod::Usage;
+use Getopt::Long qw( GetOptions );
+use Pod::Usage qw( pod2usage );
 
 use Koha::Script;
 use Koha::Patrons::Import;
@@ -29,21 +29,27 @@ my $Import = Koha::Patrons::Import->new();
 my $csv_file;
 my $matchpoint;
 my $overwrite_cardnumber;
+my $overwrite_passwords;
+my $welcome_new = 0;
 my %defaults;
 my $ext_preserve = 0;
 my $confirm;
 my $verbose      = 0;
 my $help;
+my @preserve_fields;
 
 GetOptions(
-    'c|confirm'                     => \$confirm,
-    'f|file=s'                      => \$csv_file,
-    'm|matchpoint=s'                => \$matchpoint,
-    'd|default=s'                   => \%defaults,
-    'o|overwrite'                   => \$overwrite_cardnumber,
+    'c|confirm'                      => \$confirm,
+    'f|file=s'                       => \$csv_file,
+    'm|matchpoint=s'                 => \$matchpoint,
+    'd|default=s'                    => \%defaults,
+    'o|overwrite'                    => \$overwrite_cardnumber,
+    'op|overwrite_passwords'         => \$overwrite_passwords,
+    'en|email-new'                   => \$welcome_new,
     'p|preserve-extended-attributes' => \$ext_preserve,
-    'v|verbose+'                    => \$verbose,
-    'h|help|?'                      => \$help,
+    'pf|preserve-field=s'            => \@preserve_fields,
+    'v|verbose+'                     => \$verbose,
+    'h|help|?'                       => \$help,
 ) or pod2usage(2);
 
 pod2usage(1) if $help;
@@ -61,7 +67,11 @@ my $return = $Import->import_patrons(
         defaults                     => \%defaults,
         matchpoint                   => $matchpoint,
         overwrite_cardnumber         => $overwrite_cardnumber,
+        overwrite_passwords          => $overwrite_passwords,
         preserve_extended_attributes => $ext_preserve,
+        preserve_fields              => \@preserve_fields,
+        send_welcome                 => $welcome_new,
+        dry_run                      => !$confirm,
     }
 );
 
@@ -100,7 +110,7 @@ import_patrons.pl - CLI script to import patrons data into Koha
 
 =head1 SYNOPSIS
 
-import_patrons.pl --file /path/to/patrons.csv --matchpoint cardnumber --confirm [--default branchcode=MPL] [--overwrite] [--preserve-extended-attributes] [--verbose]
+import_patrons.pl --file /path/to/patrons.csv --matchpoint cardnumber --confirm [--default branchcode=MPL] [--overwrite] [--preserve_field <column>] [--preserve-extended-attributes] [--verbose]
 
 =head1 OPTIONS
 
@@ -126,6 +136,10 @@ Field on which to match incoming patrons to existing patrons
 
 Set defaults to patron fields, repeatable e.g. --default branchcode=MPL --default categorycode=PT
 
+=item B<-k|--preserve-field>
+
+Prevent specified patron fields for existing patrons from being overwritten
+
 =item B<-o|--overwrite>
 
 Overwrite existing patrons with new data if a match is found
@@ -134,10 +148,20 @@ Overwrite existing patrons with new data if a match is found
 
 Retain extended patron attributes for existing patrons being overwritten
 
+=item B<-en|--email-new>
+
+Send the WELCOME notice email to new users
+
 =item B<-v|--verbose>
 
 Be verbose
 
+Multiple -v options increase the verbosity
+
+2 repetitions or above will report lines in error
+
+3 repetitions or above will report feedback
+
 =back
 
 =cut