Add ticket number as an option.
This commit is contained in:
parent
f6b0ac1903
commit
fe4aa69763
1 changed files with 16 additions and 3 deletions
|
@ -12,15 +12,15 @@ use DBI;
|
||||||
use Encode qw(encode decode);
|
use Encode qw(encode decode);
|
||||||
use Supporters;
|
use Supporters;
|
||||||
|
|
||||||
my($VERBOSE, $supporterId, $requestType, $requestConfig, $SUPPORTERS_SQLITE_DB_FILE) = (0, undef, undef, undef,
|
my($VERBOSE, $supporterId, $requestType, $ticketNumber, $requestConfig, $SUPPORTERS_SQLITE_DB_FILE) = (0, undef, undef, undef, undef,
|
||||||
catfile($ENV{CONSERVANCY_REPOSITORY},
|
catfile($ENV{CONSERVANCY_REPOSITORY},
|
||||||
'Financial', 'Ledger', 'supporters.db'));
|
'Financial', 'Ledger', 'supporters.db'));
|
||||||
GetOptions("verbose=i" => \$VERBOSE, "supporterDB=s" => \$SUPPORTERS_SQLITE_DB_FILE,
|
GetOptions("verbose=i" => \$VERBOSE, "supporterDB=s" => \$SUPPORTERS_SQLITE_DB_FILE, 'ticketNumber=i' => \$ticketNumber,
|
||||||
'supporterId=i' => \$supporterId, 'requestType=s' => \$requestType, 'requestConfig=s' => \$requestConfig, );
|
'supporterId=i' => \$supporterId, 'requestType=s' => \$requestType, 'requestConfig=s' => \$requestConfig, );
|
||||||
|
|
||||||
|
|
||||||
sub UsageAndExit($) {
|
sub UsageAndExit($) {
|
||||||
print STDERR "usage: $0 [ --supporterId=i --requestyType=STR --requestConfig=STR --supportersDB=PATH_TO_SUPPORTERS_SQLITE_DB_FILE --verbose=N ]\n";
|
print STDERR "usage: $0 [ --supporterId=i --requestyType=STR --requestConfig=STR --supportersDB=PATH_TO_SUPPORTERS_SQLITE_DB_FILE --ticketNumber=NNN --verbose=N ]\n";
|
||||||
print STDERR "\n $_[0]\n";
|
print STDERR "\n $_[0]\n";
|
||||||
exit 2;
|
exit 2;
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ if (defined $supporterId) {
|
||||||
print "Supporter Id: ";
|
print "Supporter Id: ";
|
||||||
my $supporterId = <STDIN>;
|
my $supporterId = <STDIN>;
|
||||||
chomp $supporterId;
|
chomp $supporterId;
|
||||||
|
UsageAndExit("$supporterId is not a valid supporter id") unless $sp->_verifyId($supporterId);
|
||||||
}
|
}
|
||||||
|
|
||||||
my @requestTypes = $sp->getRequestType();
|
my @requestTypes = $sp->getRequestType();
|
||||||
|
@ -86,4 +87,16 @@ if ($requestType) {
|
||||||
$requestParamaters = { donorId => $supporterId, requestType => $requestType };
|
$requestParamaters = { donorId => $supporterId, requestType => $requestType };
|
||||||
}
|
}
|
||||||
$sp->addRequest($requestParamaters);
|
$sp->addRequest($requestParamaters);
|
||||||
|
|
||||||
|
if (defined $ticketNumber) {
|
||||||
|
$sp->_beginWork;
|
||||||
|
$sp->dbh->do("UPDATE donor SET rt_ticket = " . $sp->dbh->quote($ticketNumber, 'SQL_INTEGER') .
|
||||||
|
" WHERE id = " . $sp->dbh->quote($supporterId, 'SQL_INTEGER'));
|
||||||
|
$sp->_commit;
|
||||||
|
my $name = $sp->getLedgerEntityId($supporterId);
|
||||||
|
system("rt", "edit", $ticketNumber, "set", "subject=$supporterId, $name");
|
||||||
|
system("rt", "comment", $ticketNumber, "-m", "Set $supporterId to $requestConfig for $requestType in supporters db");
|
||||||
|
system("rt", "edit", $ticketNumber, 'set', 'status=resolved');
|
||||||
|
print "rt:$ticketNumber — Supporter $supporterId, $name — unsubscribe\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue