From 96c04d988e583175af767a77515fb543e54c4667 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Tue, 1 Aug 2017 10:17:19 -0700 Subject: [PATCH] t-shirts: control by type when we send. Allow for controlled sending of t-shirts by type. --- scripts/send-t-shirts.plx | 6 +++--- scripts/t-shirt-label-print.plx | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/scripts/send-t-shirts.plx b/scripts/send-t-shirts.plx index 6599eb7..8f9545b 100644 --- a/scripts/send-t-shirts.plx +++ b/scripts/send-t-shirts.plx @@ -11,8 +11,8 @@ use Supporters; my $LEDGER_CMD = "/usr/local/bin/ledger"; -if (@ARGV != 4 and @ARGV != 5) { - print STDERR "usage: $0 \n"; +if (@ARGV != 5 and @ARGV != 6) { + print STDERR "usage: $0 \n"; exit 1; } @@ -46,7 +46,7 @@ foreach my $id (sort keys %idsSent) { my $sizesSent; my $foundRequestCount = 0; 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, ignoreHeldRequests => 1, ignoreFulfilledRequests => 1 }); if (defined $request and defined $request->{requestId} and defined $request->{requestType}) { diff --git a/scripts/t-shirt-label-print.plx b/scripts/t-shirt-label-print.plx index da6fd8c..cb0b772 100644 --- a/scripts/t-shirt-label-print.plx +++ b/scripts/t-shirt-label-print.plx @@ -13,12 +13,12 @@ use Supporters; my $LEDGER_CMD = "/usr/local/bin/ledger"; -if (@ARGV < 8) { - print STDERR "usage: $0 \n"; +if (@ARGV < 9) { + print STDERR "usage: $0 \n"; 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; open(SIZE_COUNTS, "<", $SIZE_COUNTS); @@ -78,6 +78,15 @@ sub sortFunction($$) { 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) { my $sizeNeeded; foreach my $type (qw/t-shirt-0 t-shirt-1/) {