[freeside-commits] branch FREESIDE_2_3_BRANCH updated. 5e26eb34ecbc90724b4d2894f20049d01f90f013
Ivan
ivan at 420.am
Tue Jul 3 02:26:31 PDT 2012
The branch, FREESIDE_2_3_BRANCH has been updated
via 5e26eb34ecbc90724b4d2894f20049d01f90f013 (commit)
from e6c63380905a96364738715cfb59e408f17fb775 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 5e26eb34ecbc90724b4d2894f20049d01f90f013
Author: Ivan Kohler <ivan at freeside.biz>
Date: Tue Jul 3 02:26:30 2012 -0700
add advertising source to sales report, RT#18349
diff --git a/FS/FS/Report/Table.pm b/FS/FS/Report/Table.pm
index b0e911f..e1aec05 100644
--- a/FS/FS/Report/Table.pm
+++ b/FS/FS/Report/Table.pm
@@ -416,6 +416,8 @@ sub cust_bill_pkg_setup {
$self->in_time_period_and_agent($speriod, $eperiod, $agentnum),
);
+ push @where, 'cust_main.refnum = '. $opt{'refnum'} if $opt{'refnum'};
+
my $total_sql = "SELECT COALESCE(SUM(cust_bill_pkg.setup),0)
FROM cust_bill_pkg
$cust_bill_pkg_join
@@ -436,6 +438,8 @@ sub cust_bill_pkg_recur {
$self->with_classnum($opt{'classnum'}, $opt{'use_override'}),
);
+ push @where, 'cust_main.refnum = '. $opt{'refnum'} if $opt{'refnum'};
+
# subtract all usage from the line item regardless of date
my $item_usage;
if ( $opt{'project'} ) {
@@ -489,6 +493,8 @@ sub cust_bill_pkg_detail {
my @where = ( "cust_bill_pkg.pkgnum != 0" );
+ push @where, 'cust_main.refnum = '. $opt{'refnum'} if $opt{'refnum'};
+
$agentnum ||= $opt{'agentnum'};
push @where,
diff --git a/httemplate/graph/cust_bill_pkg.cgi b/httemplate/graph/cust_bill_pkg.cgi
index af4d045..e7a3bd2 100644
--- a/httemplate/graph/cust_bill_pkg.cgi
+++ b/httemplate/graph/cust_bill_pkg.cgi
@@ -49,6 +49,21 @@ elsif ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
die "agentnum $agentnum not found!" unless $sel_agent;
}
my $title = $sel_agent ? $sel_agent->agent.' ' : '';
+
+my( $refnum, $sel_part_referral, $all_part_referral ) = ('', '', '');
+if ( $cgi->param('refnum') eq 'all' ) {
+ $refnum = 0;
+ $all_part_referral = 'ALL';
+}
+elsif ( $cgi->param('refnum') =~ /^(\d+)$/ ) {
+ $refnum = $1;
+ $bottom_link .= "refnum=$refnum;";
+ $sel_part_referral = qsearchs('part_referral', { 'refnum' => $refnum } );
+ die "part_referral $refnum not found!" unless $sel_part_referral;
+}
+$title .= $sel_part_referral->referral.' '
+ if $sel_part_referral;
+
$title .= 'Sales Report (Gross)';
$title .= ', average per customer package' if $average_per_cust_pkg;
@@ -130,42 +145,49 @@ foreach my $agent ( $all_agent || $sel_agent || qsearch('agent', { 'disabled' =>
### fixup the color handling for package classes...
### and usage
- my $n = 0;
-
- foreach my $pkg_class ( @pkg_class ) {
- foreach my $component ( @components ) {
-
- push @items, 'cust_bill_pkg';
-
- push @labels,
- ( $all_agent || $sel_agent ? '' : $agent->agent.' ' ).
- ( $classnum eq '0'
- ? ( ref($pkg_class) ? $pkg_class->classname : $pkg_class )
- : ''
- ).
- ' '.$charge_labels{$component};
-
- my $row_classnum = ref($pkg_class) ? $pkg_class->classnum : 0;
- my $row_agentnum = $all_agent || $agent->agentnum;
- push @params, [ ($all_class ? () : ('classnum' => $row_classnum) ),
- ($all_agent ? () : ('agentnum' => $row_agentnum) ),
- 'use_override' => $use_override,
- 'charges' => $component,
- 'average_per_cust_pkg' => $average_per_cust_pkg,
- 'distribute' => $distribute,
- ];
-
- push @links, "$link;".($all_agent ? '' : "agentnum=$row_agentnum;").
- ($all_class ? '' : "classnum=$row_classnum;").
- "distribute=$distribute;".
- "use_override=$use_override;charges=$component;";
-
- @recur_colors = ($col_scheme->colors)[0,4,8,1,5,9]
- unless @recur_colors;
- @onetime_colors = ($col_scheme->colors)[2,6,10,3,7,11]
- unless @onetime_colors;
- push @colors, shift @recur_colors;
+ foreach my $part_referral ( $all_part_referral || $sel_part_referral || qsearch('part_referral', { 'disabled' => '' } ) ) {
+
+ foreach my $pkg_class ( @pkg_class ) {
+ foreach my $component ( @components ) {
+
+ push @items, 'cust_bill_pkg';
+
+ push @labels,
+ ( $all_agent || $sel_agent ? '' : $agent->agent.' ' ).
+ ( $all_part_referral || $sel_part_referral ? '' : $part_referral->referral.' ' ).
+ ( $classnum eq '0'
+ ? ( ref($pkg_class) ? $pkg_class->classname : $pkg_class )
+ : ''
+ ).
+ ' '.$charge_labels{$component};
+
+ my $row_classnum = ref($pkg_class) ? $pkg_class->classnum : 0;
+ my $row_agentnum = $all_agent || $agent->agentnum;
+ my $row_refnum = $all_part_referral || $part_referral->refnum;
+ push @params, [ ($all_class ? () : ('classnum' => $row_classnum) ),
+ ($all_agent ? () : ('agentnum' => $row_agentnum) ),
+ ($all_part_referral ? () : ('refnum' => $row_refnum) ),
+ 'use_override' => $use_override,
+ 'charges' => $component,
+ 'average_per_cust_pkg' => $average_per_cust_pkg,
+ 'distribute' => $distribute,
+ ];
+
+ push @links, "$link;".
+ ($all_agent ? '' : "agentnum=$row_agentnum;").
+ ($all_part_referral ? '' : "refnum=$row_refnum;").
+ ($all_class ? '' : "classnum=$row_classnum;").
+ "distribute=$distribute;".
+ "use_override=$use_override;charges=$component;";
+
+ @recur_colors = ($col_scheme->colors)[0,4,8,1,5,9]
+ unless @recur_colors;
+ @onetime_colors = ($col_scheme->colors)[2,6,10,3,7,11]
+ unless @onetime_colors;
+ push @colors, shift @recur_colors;
+
+ }
}
}
diff --git a/httemplate/graph/report_cust_bill_pkg.html b/httemplate/graph/report_cust_bill_pkg.html
index 07d4421..4cedcef 100644
--- a/httemplate/graph/report_cust_bill_pkg.html
+++ b/httemplate/graph/report_cust_bill_pkg.html
@@ -12,7 +12,15 @@
</TR>
<% include('/elements/tr-select-agent.html',
- 'label' => 'For agent: ',
+ 'label' => 'Agent ',
+ 'disable_empty' => 0,
+ 'pre_options' => [ 'all' => 'all (aggregate)' ],
+ 'empty_label' => 'all (breakdown)',
+ )
+%>
+
+<% include('/elements/tr-select-part_referral.html',
+ 'label' => 'Advertising source ',
'disable_empty' => 0,
'pre_options' => [ 'all' => 'all (aggregate)' ],
'empty_label' => 'all (breakdown)',
diff --git a/httemplate/search/cust_bill_pkg.cgi b/httemplate/search/cust_bill_pkg.cgi
index f9dd4a2..1a46b00 100644
--- a/httemplate/search/cust_bill_pkg.cgi
+++ b/httemplate/search/cust_bill_pkg.cgi
@@ -171,6 +171,10 @@ if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
push @where, "cust_main.agentnum = $1";
}
+if ( $cgi->param('refnum') =~ /^(\d+)$/ ) {
+ push @where, "cust_main.refnum = $1";
+}
+
#classnum
# not specified: all classes
# 0: empty class
-----------------------------------------------------------------------
Summary of changes:
FS/FS/Report/Table.pm | 6 ++
httemplate/graph/cust_bill_pkg.cgi | 92 +++++++++++++++++-----------
httemplate/graph/report_cust_bill_pkg.html | 10 +++-
httemplate/search/cust_bill_pkg.cgi | 4 +
4 files changed, 76 insertions(+), 36 deletions(-)
More information about the freeside-commits
mailing list