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;
|
2016-03-11 17:55:11 +00:00
|
|
|
my(@supporterIds);
|
|
|
|
if ($CRITERION ne 'id') {
|
|
|
|
@supporterIds = $sp->findDonor({$CRITERION => $SEARCH_PARAMETER });
|
|
|
|
} else {
|
|
|
|
push(@supporterIds, $SEARCH_PARAMETER);
|
|
|
|
}
|
2016-03-11 19:05:05 +00:00
|
|
|
my @requestTypes = $sp->getRequestType();
|
2016-01-25 00:18:29 +00:00
|
|
|
foreach my $id (@supporterIds) {
|
2016-03-11 19:23:30 +00:00
|
|
|
$found = 1;
|
|
|
|
my $preferredEmail = $sp->getPreferredEmailAddress($id);
|
2016-03-11 20:29:20 +00:00
|
|
|
my $preferredPostal = $sp->getPreferredPostalAddress($id);
|
2016-01-25 00:18:29 +00:00
|
|
|
print "Found: $id, ", $sp->getLedgerEntityId($id), "\n";
|
2016-03-11 20:11:58 +00:00
|
|
|
print " Public Ack: ";
|
|
|
|
if (not defined $sp->getPublicAck($id)) {
|
|
|
|
print " unknown\n";
|
|
|
|
} elsif ($sp->getPublicAck($id)) {
|
|
|
|
print " yes\n";
|
|
|
|
} else {
|
|
|
|
print " no\n";
|
|
|
|
}
|
2016-03-11 17:55:11 +00:00
|
|
|
my(%addr) = $sp->getEmailAddresses($id);
|
2016-03-11 19:23:30 +00:00
|
|
|
print " Email Addresses: ";
|
|
|
|
my $cnt = 0;
|
|
|
|
foreach my $email (keys %addr) {
|
|
|
|
$cnt++;
|
|
|
|
print $email;
|
|
|
|
print "(preferred)" if (defined $preferredEmail) and $email eq $preferredEmail;
|
|
|
|
print ", " unless $cnt == scalar keys %addr;
|
|
|
|
}
|
2016-03-11 17:55:11 +00:00
|
|
|
my(%postalAddresses) = $sp->getPostalAddresses($id);
|
2016-03-11 19:23:30 +00:00
|
|
|
if (scalar keys %postalAddresses <= 0) {
|
|
|
|
print "\n NO POSTAL ADDRESSES.\n";
|
|
|
|
} else {
|
|
|
|
print "\n Postal Addresses:\n";
|
|
|
|
foreach my $address (keys %postalAddresses) {
|
|
|
|
print " PREFERRED\n" if (defined $preferredPostal) and $address eq $preferredPostal;
|
|
|
|
foreach my $addrLine (split("\n", $address)) {
|
|
|
|
print " $addrLine\n";
|
|
|
|
}
|
2016-03-11 19:10:39 +00:00
|
|
|
}
|
|
|
|
}
|
2016-03-11 19:05:05 +00:00
|
|
|
foreach my $requestType (@requestTypes) {
|
|
|
|
my $req = $sp->getRequest({ donorId => $id, requestType => $requestType});
|
|
|
|
if (defined $req) {
|
|
|
|
print " Request $req->{requestType}";
|
|
|
|
print "($req->{requestConfiguration})" if defined $req->{requestConfiguration};
|
|
|
|
print " made on $req->{requestDate}";
|
|
|
|
if (not defined $req->{fulfillDate}) {
|
|
|
|
print "\n";
|
|
|
|
} else {
|
|
|
|
print "...\n fulfilled on $req->{fulfillDate}";
|
|
|
|
print "...\n notes: $req->{notes}" if defined $req->{notes};
|
|
|
|
print "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-01-25 00:18:29 +00:00
|
|
|
}
|
|
|
|
print "No entries found\n" unless $found;
|
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# Local variables:
|
|
|
|
# compile-command: "perl -c send-mass-email.plx"
|
|
|
|
# End:
|
|
|
|
|