t-shirts: control by type when we send.

Allow for controlled sending of t-shirts by type.
This commit is contained in:
Bradley M. Kuhn 2017-08-01 10:17:19 -07:00
parent 434f2de875
commit 96c04d988e
2 changed files with 15 additions and 6 deletions

View file

@ -11,8 +11,8 @@ use Supporters;
my $LEDGER_CMD = "/usr/local/bin/ledger"; my $LEDGER_CMD = "/usr/local/bin/ledger";
if (@ARGV != 4 and @ARGV != 5) { if (@ARGV != 5 and @ARGV != 6) {
print STDERR "usage: $0 <SUPPORTERS_SQLITE_DB_FILE> <WHO> <HOW> <SUPPORTER_CHECKLIST_TEX_FILE> <VERBOSITY_LEVEL>\n"; print STDERR "usage: $0 <SUPPORTERS_SQLITE_DB_FILE> <T_SHIRT_TYPE> <WHO> <HOW> <SUPPORTER_CHECKLIST_TEX_FILE> <VERBOSITY_LEVEL>\n";
exit 1; exit 1;
} }
@ -46,7 +46,7 @@ foreach my $id (sort keys %idsSent) {
my $sizesSent; my $sizesSent;
my $foundRequestCount = 0; my $foundRequestCount = 0;
foreach my $type (@requestTypes) { foreach my $type (@requestTypes) {
next unless ($type =~ /shirt/); next unless ($type =~ /shirt/ and $type =~ /$T_SHIRT_TYPE/);
my $request = $sp->getRequest({ donorId => $id, requestType => $type, my $request = $sp->getRequest({ donorId => $id, requestType => $type,
ignoreHeldRequests => 1, ignoreFulfilledRequests => 1 }); ignoreHeldRequests => 1, ignoreFulfilledRequests => 1 });
if (defined $request and defined $request->{requestId} and defined $request->{requestType}) { if (defined $request and defined $request->{requestId} and defined $request->{requestType}) {

View file

@ -13,12 +13,12 @@ use Supporters;
my $LEDGER_CMD = "/usr/local/bin/ledger"; my $LEDGER_CMD = "/usr/local/bin/ledger";
if (@ARGV < 8) { if (@ARGV < 9) {
print STDERR "usage: $0 <SUPPORTERS_SQLITE_DB_FILE> <GIVING_LIMIT> <SIZE_COUNTS> <OUTPUT_DIRECTORY > <MONTHLY_SEARCH_REGEX> <ANNUAL_SEARCH_REGEX> <VERBOSE> <LEDGER_CMD_LINE>\n"; print STDERR "usage: $0 <SUPPORTERS_SQLITE_DB_FILE> <GIVING_LIMIT> <T-SHIRT-STYLE> <SIZE_COUNTS> <OUTPUT_DIRECTORY > <MONTHLY_SEARCH_REGEX> <ANNUAL_SEARCH_REGEX> <VERBOSE> <LEDGER_CMD_LINE>\n";
exit 1; exit 1;
} }
my($SUPPORTERS_SQLITE_DB_FILE, $GIVING_LIMIT, $SIZE_COUNTS, $OUTPUT_DIRECTORY, $MONTHLY_SEARCH_REGEX, $ANNUAL_SEARCH_REGEX, $VERBOSE, @LEDGER_CMD_LINE) = @ARGV; my($SUPPORTERS_SQLITE_DB_FILE, $GIVING_LIMIT, $T_SHIRT_STYLE, $SIZE_COUNTS, $OUTPUT_DIRECTORY, $MONTHLY_SEARCH_REGEX, $ANNUAL_SEARCH_REGEX, $VERBOSE, @LEDGER_CMD_LINE) = @ARGV;
$VERBOSE = 0 if not defined $VERBOSE; $VERBOSE = 0 if not defined $VERBOSE;
open(SIZE_COUNTS, "<", $SIZE_COUNTS); open(SIZE_COUNTS, "<", $SIZE_COUNTS);
@ -78,6 +78,15 @@ sub sortFunction($$) {
return ($lastGaveDate0 cmp $lastGaveDate1); return ($lastGaveDate0 cmp $lastGaveDate1);
} }
} }
my @typeList;
if ($T_SHIRT_STYLE == 0) {
@typeList = qw/t-shirt-0 t-shirt-extra-0/;
} elsif ($T_SHIRT_STYLE == 1) {
@typeList = qw/t-shirt-1 t-shirt-extra-1/;
} else {
die "Unknown t-shirt style given: $T_SHIRT_STYLE";
}
foreach my $id (sort { sortFunction($a, $b); } @supporterIds) { foreach my $id (sort { sortFunction($a, $b); } @supporterIds) {
my $sizeNeeded; my $sizeNeeded;
foreach my $type (qw/t-shirt-0 t-shirt-1/) { foreach my $type (qw/t-shirt-0 t-shirt-1/) {