projects
/
freeside.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3d8ef5d
)
agent-virt suspension summary, RT#16534
author
Ivan Kohler
<ivan@freeside.biz>
Thu, 8 Mar 2012 06:37:14 +0000
(22:37 -0800)
committer
Ivan Kohler
<ivan@freeside.biz>
Thu, 8 Mar 2012 06:37:14 +0000
(22:37 -0800)
httemplate/search/cust_pkg_susp.cgi
patch
|
blob
|
history
diff --git
a/httemplate/search/cust_pkg_susp.cgi
b/httemplate/search/cust_pkg_susp.cgi
index
53631a2
..
9ab5992
100644
(file)
--- a/
httemplate/search/cust_pkg_susp.cgi
+++ b/
httemplate/search/cust_pkg_susp.cgi
@@
-21,8
+21,11
@@
</TR>
</TABLE>
<%init>
</TR>
</TABLE>
<%init>
+
+my $curuser = $FS::CurrentUser::CurrentUser;
+
die "access denied"
die "access denied"
- unless $
FS::CurrentUser::CurrentU
ser->access_right('List packages');
+ unless $
curu
ser->access_right('List packages');
my $money_char = FS::Conf->new()->config('money_char') || '$';
my $money_char = FS::Conf->new()->config('money_char') || '$';
@@
-68,18
+71,21
@@
my @pay_cond;
push @pay_cond, "cust_bill_pay._date < $end" if $end;
push @pay_cond, "cust_bill_pay._date > $begin" if $begin;
push @pay_cond, "cust_bill_pay._date < $end" if $end;
push @pay_cond, "cust_bill_pay._date > $begin" if $begin;
-my $pay_cond = '';
-$pay_cond = 'WHERE '.join(' AND ', @pay_cond) if @pay_cond;
+my $extra_sql = '';
+$extra_sql = 'WHERE '. join(' AND ', @pay_cond) if @pay_cond;
+$extra_sql .= ( $extra_sql ? ' AND ' : ' WHERE ' ).
+ $curuser->agentnums_sql( 'table' => 'cust_main' );
my $pkg_payments = {
map { $_->pkgpart => $_->total_pay }
qsearch({
'table' => 'cust_pkg',
'select' => 'pkgpart, sum(cust_bill_pay_pkg.amount) AS total_pay',
my $pkg_payments = {
map { $_->pkgpart => $_->total_pay }
qsearch({
'table' => 'cust_pkg',
'select' => 'pkgpart, sum(cust_bill_pay_pkg.amount) AS total_pay',
- 'addl_from' => 'INNER JOIN cust_bill_pkg USING (pkgnum)
+ 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )
+ INNER JOIN cust_bill_pkg USING (pkgnum)
INNER JOIN cust_bill_pay_pkg USING (billpkgnum)
INNER JOIN cust_bill_pay_pkg USING (billpkgnum)
- INNER JOIN cust_bill_pay USING (billpaynum)',
- 'extra_sql' =>
$pay_cond . ' GROUP BY pkgpart'
,
+ INNER JOIN cust_bill_pay
USING (billpaynum)',
+ 'extra_sql' =>
"$extra_sql GROUP BY pkgpart"
,
}) };
my @head = ('Package', 'Suspended', 'Unsuspended', 'Payments');
}) };
my @head = ('Package', 'Suspended', 'Unsuspended', 'Payments');
@@
-87,7
+93,19
@@
my @rows = ();
my @totals = map {0} @head;
$totals[0] = 'Total';
my @totals = map {0} @head;
$totals[0] = 'Total';
-foreach my $part_pkg (qsearch('part_pkg', {} )) {
+my $pkg_agentnums_sql = $curuser->agentnums_sql(
+ 'null' => 1,
+ 'table' => 'part_pkg',
+ );
+
+my $extra_sql = " WHERE $pkg_agentnums_sql";
+
+foreach my $part_pkg (qsearch({ 'table' => 'part_pkg',
+ 'hashref' => {},
+ 'extra_sql' => $extra_sql,
+ })
+ )
+{
my @row = ();
next if !$part_pkg->freq; # exclude one-time packages
my $pkgpart = $part_pkg->pkgpart;
my @row = ();
next if !$part_pkg->freq; # exclude one-time packages
my $pkgpart = $part_pkg->pkgpart;