supporters/scripts/find-supporter.plx

49 lines
1.3 KiB
Text
Raw Normal View History

2016-01-25 00:18:29 +00:00
#!/usr/bin/perl
use strict;
use warnings;
use autodie qw(open close);
use DBI;
use Encode qw(encode decode);
use Supporters;
if (@ARGV < 2) {
print STDERR "usage: $0 <SUPPORTERS_SQLITE_DB_FILE> <CRITERION> <SEARCH_PARAMETER> <VERBOSE>\n";
exit 1;
}
my($SUPPORTERS_SQLITE_DB_FILE, $CRITERION, $SEARCH_PARAMETER, $VERBOSE) = @ARGV;
$VERBOSE = 0 if not defined $VERBOSE;
my $dbh = DBI->connect("dbi:SQLite:dbname=$SUPPORTERS_SQLITE_DB_FILE", "", "",
{ RaiseError => 1, sqlite_unicode => 1 })
or die $DBI::errstr;
my $sp = new Supporters($dbh, ['none']);
my $found = 0;
my(@supporterIds);
if ($CRITERION ne 'id') {
@supporterIds = $sp->findDonor({$CRITERION => $SEARCH_PARAMETER });
} else {
push(@supporterIds, $SEARCH_PARAMETER);
}
2016-01-25 00:18:29 +00:00
foreach my $id (@supporterIds) {
print "Found: $id, ", $sp->getLedgerEntityId($id), "\n";
my(%addr) = $sp->getEmailAddresses($id);
print " Email Addresses: ", join(", ", keys %addr), "\n";
my(%postalAddresses) = $sp->getPostalAddresses($id);
print " Postal Addresses: ", join("\n\n", keys %postalAddresses), "\n";
2016-01-25 00:18:29 +00:00
$found = 1;
}
print "No entries found\n" unless $found;
###############################################################################
#
# Local variables:
# compile-command: "perl -c send-mass-email.plx"
# End: