diff options
Diffstat (limited to 'httemplate')
-rw-r--r-- | httemplate/graph/cust_bill_pkg.cgi | 41 | ||||
-rw-r--r-- | httemplate/graph/elements/monthly.html | 13 | ||||
-rw-r--r-- | httemplate/graph/report_cust_bill_pkg.html | 17 | ||||
-rw-r--r-- | httemplate/search/cust_bill_pkg.cgi | 12 |
4 files changed, 71 insertions, 12 deletions
diff --git a/httemplate/graph/cust_bill_pkg.cgi b/httemplate/graph/cust_bill_pkg.cgi index 03e29b901..af4d045fe 100644 --- a/httemplate/graph/cust_bill_pkg.cgi +++ b/httemplate/graph/cust_bill_pkg.cgi @@ -22,9 +22,19 @@ die "access denied" my $link = "${p}search/cust_bill_pkg.cgi?nottax=1"; my $bottom_link = "$link;"; +my $use_usage = $cgi->param('use_usage') || 0; +my $use_setup = $cgi->param('use_setup') || 0; my $use_override = $cgi->param('use_override') ? 1 : 0; -my $use_usage = $cgi->param('use_usage') ? 1 : 0; my $average_per_cust_pkg = $cgi->param('average_per_cust_pkg') ? 1 : 0; +my $distribute = $cgi->param('distribute') ? 1 : 0; + +my %charge_labels = ( + 'SR' => 'setup + recurring', + 'RU' => 'recurring', + 'S' => 'setup', + 'R' => 'recurring', + 'U' => 'usage', +); #XXX or virtual my( $agentnum, $sel_agent, $all_agent ) = ('', '', ''); @@ -94,6 +104,21 @@ my @labels = (); my @colors = (); my @links = (); +my @components = ( 'SRU' ); +# split/omit components as appropriate +if ( $use_setup == 1 ) { + @components = ( 'S', 'RU' ); +} +elsif ( $use_setup == 2 ) { + @components = ( 'RU' ); +} +if ( $use_usage == 1 ) { + $components[-1] =~ s/U//; push @components, 'U'; +} +elsif ( $use_usage == 2 ) { + $components[-1] =~ s/U//; +} + foreach my $agent ( $all_agent || $sel_agent || qsearch('agent', { 'disabled' => '' } ) ) { my $col_scheme = Color::Scheme->new @@ -108,7 +133,7 @@ foreach my $agent ( $all_agent || $sel_agent || qsearch('agent', { 'disabled' => my $n = 0; foreach my $pkg_class ( @pkg_class ) { - foreach my $component ( $use_usage ? ('recurring', 'usage') : ('') ) { + foreach my $component ( @components ) { push @items, 'cust_bill_pkg'; @@ -118,20 +143,22 @@ foreach my $agent ( $all_agent || $sel_agent || qsearch('agent', { 'disabled' => ? ( ref($pkg_class) ? $pkg_class->classname : $pkg_class ) : '' ). - " $component"; + ' '.$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, - 'use_usage' => $component, + '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;"). - "use_override=$use_override;use_usage=$component;"; + "distribute=$distribute;". + "use_override=$use_override;charges=$component;"; @recur_colors = ($col_scheme->colors)[0,4,8,1,5,9] unless @recur_colors; @@ -147,5 +174,7 @@ foreach my $agent ( $all_agent || $sel_agent || qsearch('agent', { 'disabled' => } #use Data::Dumper; - +if ( $cgi->param('debug') == 1 ) { + $FS::Report::Table::DEBUG = 1; +} </%init> diff --git a/httemplate/graph/elements/monthly.html b/httemplate/graph/elements/monthly.html index a451ea8ff..99db31ecf 100644 --- a/httemplate/graph/elements/monthly.html +++ b/httemplate/graph/elements/monthly.html @@ -64,6 +64,7 @@ Example: <%init> my(%opt) = @_; +$opt{'debug'} ||= $cgi->param('debug'); my $conf = new FS::Conf; my $money_char = $opt{'disable_money'} ? '' : $conf->config('money_char'); @@ -115,15 +116,27 @@ my %reportopts = ( 'doublemonths' => $opt{'doublemonths'}, ); +warn Dumper({ 'REPORTOPTS' => \%reportopts }) if $opt{'debug'}; + my $report; $report = new FS::Report::Table::Daily(%reportopts) if $opt{'daily'}; $report = new FS::Report::Table::Monthly(%reportopts) unless $opt{'daily'}; my $data = $report->data; +warn Dumper({'DATA' => $data}) if $opt{'debug'}; + my $col_labels = [ map { my $m = $_; $m =~ s/^(\d+)\//$mon[$1-1] / ; $m } @{$data->{label}} ]; $col_labels = $data->{label} if $opt{'daily'}; +if ( $opt{'remove_empty'} ) { + # need to filter out series labels for collapsed rows + $opt{'graph_labels'} = [ + map { $opt{'graph_labels'}[$_] } + @{ $data->{indices} } + ]; +} + my @links; foreach my $link (@{ $data->{'links'} }) { my @speriod = @{$data->{'speriod'}}; diff --git a/httemplate/graph/report_cust_bill_pkg.html b/httemplate/graph/report_cust_bill_pkg.html index 348746514..af61dda82 100644 --- a/httemplate/graph/report_cust_bill_pkg.html +++ b/httemplate/graph/report_cust_bill_pkg.html @@ -28,19 +28,28 @@ </TR> --> +% foreach ( qw(Setup Usage) ) { +<& /elements/tr-select.html, + 'label' => "$_ fees", + 'field' => 'use_'.lc($_), + 'options' => [ 0, 1, 2 ], + 'labels' => { 0 => 'Combine', 1 => 'Separate', 2 => 'Do not show' }, +&> +% } + <TR> <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="use_override" VALUE="1"></TD> <TD>Separate sub-packages from parents</TD> </TR> <TR> - <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="use_usage" VALUE="1"></TD> - <TD>Separate rated usage from recurring fees</TD> + <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="average_per_cust_pkg" VALUE="1"></TD> + <TD>Average per customer package</TD> </TR> <TR> - <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="average_per_cust_pkg" VALUE="1"></TD> - <TD>Average per customer package</TD> + <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="distribute" VALUE="1"></TD> + <TD>Distribute recurring fees over billing period</TD> </TR> </TABLE> diff --git a/httemplate/search/cust_bill_pkg.cgi b/httemplate/search/cust_bill_pkg.cgi index 13fb9f836..94860d3f2 100644 --- a/httemplate/search/cust_bill_pkg.cgi +++ b/httemplate/search/cust_bill_pkg.cgi @@ -145,8 +145,16 @@ my $agentnums_sql = my @where = ( $agentnums_sql ); my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); -push @where, "_date >= $beginning", - "_date <= $ending"; + +if ( $cgi->param('distribute') == 1 ) { + push @where, "sdate <= $ending", + "edate > $beginning", + ; +} +else { + push @where, "_date >= $beginning", + "_date <= $ending"; +} if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { push @where, "cust_main.agentnum = $1"; |