2016-12-09 21:44:08 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
2022-06-21 17:15:00 +00:00
|
|
|
use utf8;
|
2016-12-09 21:44:08 +00:00
|
|
|
|
|
|
|
use DBI;
|
|
|
|
use Encode qw(encode decode);
|
|
|
|
use Supporters;
|
|
|
|
|
2022-06-21 17:15:00 +00:00
|
|
|
binmode STDOUT, ":utf8";
|
|
|
|
binmode STDIN, ":utf8";
|
|
|
|
|
2016-12-09 21:44:08 +00:00
|
|
|
if (@ARGV != 1 and @ARGV !=2) {
|
|
|
|
print STDERR "usage: $0 <SUPPORTERS_SQLITE_DB_FILE> <VERBOSITY_LEVEL>\n";
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
my($SUPPORTERS_SQLITE_DB_FILE, $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" ]);
|
|
|
|
|
|
|
|
print "Supporter Id: ";
|
|
|
|
my $supporterId = <STDIN>;
|
|
|
|
chomp $supporterId;
|
|
|
|
|
|
|
|
my @requestTypes = $sp->getRequestType();
|
|
|
|
my %requestTypes;
|
|
|
|
@requestTypes{@requestTypes} = @requestTypes;
|
|
|
|
my $requestType = "";
|
|
|
|
while (not defined $requestTypes{$requestType}) {
|
|
|
|
print "Request Type (", join(", ", @requestTypes), "): ";
|
|
|
|
$requestType = <STDIN>;
|
|
|
|
chomp $requestType;
|
|
|
|
}
|
|
|
|
print "Why fulfillment failed: ";
|
|
|
|
my $why = <STDIN>;
|
|
|
|
chomp $why;
|
2022-06-21 17:14:49 +00:00
|
|
|
print "Who?: ";
|
|
|
|
my $who = <STDIN>;
|
|
|
|
chomp $who;
|
2016-12-09 21:44:08 +00:00
|
|
|
|
2022-06-21 17:14:49 +00:00
|
|
|
my $id = $sp->fulfillFailure({donorId => $supporterId, requestType => $requestType, why => $why, who => $who});
|
2016-12-09 21:44:08 +00:00
|
|
|
|
|
|
|
die "requestType $requestType not found for $supporterId, or the request was not already fulfilled yet anyway." unless defined $id;
|
|
|
|
|
|
|
|
print "Fulfill failure recorded. Hold Id is $id\n";
|