summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Report/Table.pm37
-rw-r--r--FS/FS/Report/Table/Monthly.pm7
-rw-r--r--FS/FS/cust_bill.pm9
3 files changed, 53 insertions, 0 deletions
diff --git a/FS/FS/Report/Table.pm b/FS/FS/Report/Table.pm
index 696940679..2e202e5d9 100644
--- a/FS/FS/Report/Table.pm
+++ b/FS/FS/Report/Table.pm
@@ -56,6 +56,13 @@ sub signups {
push @where, "refnum = ".$opt{'refnum'};
}
+ if ( $opt{'cust_classnum'} ) {
+ my $classnums = $opt{'cust_classnum'};
+ $classnums = [ $classnums ] if !ref($classnums);
+ @$classnums = grep /^\d+$/, @$classnums;
+ push @where, 'cust_main.classnum in('. join(',',@$classnums) .')';
+ }
+
$self->scalar_sql(
"SELECT COUNT(*) FROM cust_main $join WHERE ".join(' AND ', @where)
);
@@ -439,8 +446,16 @@ sub cust_bill_pkg_setup {
$self->in_time_period_and_agent($speriod, $eperiod, $agentnum),
);
+ # yuck, false laziness
push @where, "cust_main.refnum = ". $opt{'refnum'} if $opt{'refnum'};
+ if ( $opt{'cust_classnum'} ) {
+ my $classnums = $opt{'cust_classnum'};
+ $classnums = [ $classnums ] if !ref($classnums);
+ @$classnums = grep /^\d+$/, @$classnums;
+ push @where, 'cust_main.classnum in('. join(',',@$classnums) .')';
+ }
+
my $total_sql = "SELECT COALESCE(SUM(cust_bill_pkg.setup),0)
FROM cust_bill_pkg
$cust_bill_pkg_join
@@ -463,6 +478,13 @@ sub cust_bill_pkg_recur {
push @where, 'cust_main.refnum = '. $opt{'refnum'} if $opt{'refnum'};
+ if ( $opt{'cust_classnum'} ) {
+ my $classnums = $opt{'cust_classnum'};
+ $classnums = [ $classnums ] if !ref($classnums);
+ @$classnums = grep /^\d+$/, @$classnums;
+ push @where, 'cust_main.classnum in('. join(',',@$classnums) .')';
+ }
+
# subtract all usage from the line item regardless of date
my $item_usage;
if ( $opt{'project'} ) {
@@ -518,6 +540,13 @@ sub cust_bill_pkg_detail {
push @where, 'cust_main.refnum = '. $opt{'refnum'} if $opt{'refnum'};
+ if ( $opt{'cust_classnum'} ) {
+ my $classnums = $opt{'cust_classnum'};
+ $classnums = [ $classnums ] if !ref($classnums);
+ @$classnums = grep /^\d+$/, @$classnums;
+ push @where, 'cust_main.classnum in('. join(',',@$classnums) .')';
+ }
+
$agentnum ||= $opt{'agentnum'};
push @where,
@@ -657,6 +686,14 @@ sub for_opts {
if ( $opt{'refnum'} =~ /^(\d+)$/ ) {
$sql .= " and refnum = $1 ";
}
+ if ( $opt{'cust_classnum'} ) {
+ my $classnums = $opt{'cust_classnum'};
+ $classnums = [ $classnums ] if !ref($classnums);
+ @$classnums = grep /^\d+$/, @$classnums;
+ $sql .= ' and cust_main.classnum in('. join(',',@$classnums) .')'
+ if @$classnums;
+ }
+
$sql;
}
diff --git a/FS/FS/Report/Table/Monthly.pm b/FS/FS/Report/Table/Monthly.pm
index ee4dc5fe8..b8e52ae63 100644
--- a/FS/FS/Report/Table/Monthly.pm
+++ b/FS/FS/Report/Table/Monthly.pm
@@ -25,6 +25,7 @@ FS::Report::Table::Monthly - Tables of report data, indexed monthly
#opt
'agentnum' => 54
'refnum' => 54
+ 'cust_classnum' => [ 1,2,4 ],
'params' => [ [ 'paramsfor', 'item_one' ], [ 'item', 'two' ] ], # ...
'remove_empty' => 1, #collapse empty rows, default 0
'item_labels' => [ ], #useful with remove_empty
@@ -69,6 +70,9 @@ corresponding to this arrayref.
=item refnum: Limit to customers with this advertising source.
+=item cust_classnum: Limit to customers with this classnum; can be an
+arrayref.
+
=item remove_empty: Set this to a true value to hide rows that contain
only zeroes. The C<indices> array in the returned data will list the item
indices that are actually present in the output so that you know what they
@@ -139,6 +143,8 @@ sub data {
my $agentnum = $self->{'agentnum'};
my $refnum = $self->{'refnum'};
+ my $cust_classnum = $self->{'cust_classnum'} || [];
+ $cust_classnum = [ $cust_classnum ] if !ref($cust_classnum);
if ( $projecting ) {
@@ -183,6 +189,7 @@ sub data {
my @param = $self->{'params'} ? @{ $self->{'params'}[$col] }: ();
push @param, 'project', $projecting;
push @param, 'refnum' => $refnum if $refnum;
+ push @param, 'cust_classnum' => $cust_classnum if @$cust_classnum;
if ( $self->{'cross_params'} ) {
my @xdata;
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index e4b2df4e8..e7622d712 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -3429,6 +3429,15 @@ sub search_sql_where {
push @search, "cust_bill.custnum = $1";
}
+ #customer classnum
+ if ( $param->{'cust_classnum'} ) {
+ my $classnums = $param->{'cust_classnum'};
+ $classnums = [ $classnums ] if !ref($classnums);
+ $classnums = [ grep /^\d+$/, @$classnums ];
+ push @search, 'cust_main.classnum in ('.join(',',@$classnums).')'
+ if @$classnums;
+ }
+
#_date
if ( $param->{_date} ) {
my($beginning, $ending) = @{$param->{_date}};