Mark preferred addresses & better formatting.

Note that I haven't implemented getPreferredPostalAddress() yet so it's
commented out here for now.
This commit is contained in:
Bradley M. Kuhn 2016-03-11 11:23:30 -08:00
parent b1abebb32b
commit 3a6edee83f

View file

@ -32,17 +32,31 @@ if ($CRITERION ne 'id') {
} }
my @requestTypes = $sp->getRequestType(); my @requestTypes = $sp->getRequestType();
foreach my $id (@supporterIds) { foreach my $id (@supporterIds) {
$found = 1;
my $preferredEmail = $sp->getPreferredEmailAddress($id);
my $preferredPostal = undef; # $sp->getPreferredPostalAddress($id);
print "Found: $id, ", $sp->getLedgerEntityId($id), "\n"; print "Found: $id, ", $sp->getLedgerEntityId($id), "\n";
my(%addr) = $sp->getEmailAddresses($id); my(%addr) = $sp->getEmailAddresses($id);
print " Email Addresses: ", join(", ", keys %addr), "\n"; 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;
}
my(%postalAddresses) = $sp->getPostalAddresses($id); my(%postalAddresses) = $sp->getPostalAddresses($id);
print " Postal Addresses:\n"; if (scalar keys %postalAddresses <= 0) {
foreach my $address (keys %postalAddresses) { print "\n NO POSTAL ADDRESSES.\n";
foreach my $addrLine (split("\n", $address)) { } else {
print " $addrLine\n"; 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";
}
} }
} }
$found = 1;
foreach my $requestType (@requestTypes) { foreach my $requestType (@requestTypes) {
my $req = $sp->getRequest({ donorId => $id, requestType => $requestType}); my $req = $sp->getRequest({ donorId => $id, requestType => $requestType});
if (defined $req) { if (defined $req) {