From 3a6edee83fe1679e0a5631c74869375bbcbae998 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Fri, 11 Mar 2016 11:23:30 -0800 Subject: [PATCH] Mark preferred addresses & better formatting. Note that I haven't implemented getPreferredPostalAddress() yet so it's commented out here for now. --- scripts/find-supporter.plx | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/scripts/find-supporter.plx b/scripts/find-supporter.plx index 029f38e..95774d0 100755 --- a/scripts/find-supporter.plx +++ b/scripts/find-supporter.plx @@ -32,17 +32,31 @@ if ($CRITERION ne 'id') { } my @requestTypes = $sp->getRequestType(); foreach my $id (@supporterIds) { + $found = 1; + my $preferredEmail = $sp->getPreferredEmailAddress($id); + my $preferredPostal = undef; # $sp->getPreferredPostalAddress($id); print "Found: $id, ", $sp->getLedgerEntityId($id), "\n"; 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); - print " Postal Addresses:\n"; - foreach my $address (keys %postalAddresses) { - foreach my $addrLine (split("\n", $address)) { - print " $addrLine\n"; + 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"; + } } } - $found = 1; foreach my $requestType (@requestTypes) { my $req = $sp->getRequest({ donorId => $id, requestType => $requestType}); if (defined $req) {