add -t flag to bulk void for payment type, RT#73413
[freeside.git] / bin / explain-bill-query
1 #!/usr/bin/perl -w
2
3 use strict;
4 use Getopt::Std;
5 use FS::UID qw(adminsuidsetup dbh);
6 use FS::Cron::bill qw(bill_where);
7
8 my $user = 'fs_daily';
9
10 #&untaint_argv;  #what it sounds like  (eww)
11 use vars qw(%opt);
12 getopts("p:a:d:vl:sy:nmrk", \%opt);
13
14 adminsuidsetup $user;
15
16   #we're at now now (and later).
17   $opt{'time'} = $opt{'d'} ? str2time($opt{'d'}) : $^T;
18   $opt{'time'} += $opt{'y'} * 86400 if $opt{'y'};
19
20   $opt{'invoice_time'} = $opt{'n'} ? $^T : $opt{'time'};
21
22
23 my $sql = 'EXPLAIN SELECT custnum FROM cust_main WHERE '. bill_where(%opt);
24
25 my $sth = dbh->prepare($sql) or die dbh->errstr;
26
27 $sth->execute or die $sth->errstr;
28
29 while ( my $row = $sth->fetchrow_arrayref ) {
30
31   print join(' / ', @$row ). "\n";
32
33 }
34