diff options
Diffstat (limited to 'httemplate/graph')
-rw-r--r-- | httemplate/graph/cust_bill_pkg.cgi | 41 | ||||
-rw-r--r-- | httemplate/graph/elements/monthly.html | 25 | ||||
-rw-r--r-- | httemplate/graph/elements/report.html | 24 | ||||
-rw-r--r-- | httemplate/graph/report_cust_bill_pkg.html | 24 |
4 files changed, 97 insertions, 17 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..275e5e6ff 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'); @@ -89,6 +90,11 @@ $opt{'start_year'} ||= $cgi->param('start_year'); # || 1899+$curyear; $opt{'end_month'} ||= $cgi->param('end_month'); # || $curmon+1; $opt{'end_year'} ||= $cgi->param('end_year'); # || 1900+$curyear; +#find end of projection +$opt{'project_month'} ||= $cgi->param('project_month') || 0; +$opt{'project_year'} ||= $cgi->param('project_year') || 0; +# setting these to zero prevents projection on reports that don't support it + if ( $opt{'daily'} ) { # daily granularity $opt{'start_day'} ||= $cgi->param('start_day'); $opt{'end_day'} ||= $cgi->param('end_day'); @@ -110,20 +116,39 @@ my %reportopts = ( 'end_day' => $opt{'end_day'}, 'end_month' => $opt{'end_month'}, 'end_year' => $opt{'end_year'}, + 'project_day' => $opt{'project_day'}, + 'project_month' => $opt{'project_month'}, + 'project_year' => $opt{'project_year'}, 'agentnum' => $opt{'agentnum'}, 'remove_empty' => $opt{'remove_empty'}, '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'}; + +if ( $data->{'error'} ) { + die $data->{'error'}; # could be smarter +} + 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/elements/report.html b/httemplate/graph/elements/report.html index 2be511aec..3773fbf1d 100644 --- a/httemplate/graph/elements/report.html +++ b/httemplate/graph/elements/report.html @@ -155,28 +155,28 @@ any delimiter and linked from the elements in @data. % ); % % http_header('Content-Type' => 'image/png' ); +% http_header('Cache-Control' => 'no-cache' ); % % $chart->_set_colors(); % <% $chart->scalar_png([ $opt{'axis_labels'}, @data ]) %> % % } else { +% # image and download links should use the cached data +% # just directly reference this component +% my $myself = $p.'graph/elements/report.html?session='.$session; % <% include('/elements/header.html', $opt{'title'} ) %> % unless ( $opt{'graph_type'} eq 'none' ) { -% $cgi->param('_type', 'png'); -<IMG SRC="<% $cgi->self_url %>" WIDTH="976" HEIGHT="384"> +<IMG SRC="<% "$myself;_type=png" %>" WIDTH="976" HEIGHT="384"> % } <P ALIGN="right"> % unless ( $opt{'disable_download'} ) { -% $cgi->param('_type', "xls" ); Download full results<BR> - as <A HREF="<% $cgi->self_url %>">Excel spreadsheet</A><BR> -% $cgi->param('_type', 'csv'); - as <A HREF="<% $cgi->self_url %>">CSV file</A></P> -% $cgi->param('_type', "html" ); + as <A HREF="<% "$myself;_type=xls" %>">Excel spreadsheet</A><BR> + as <A HREF="<% "$myself;_type=csv" %>">CSV file</A></P> % } % </P> @@ -271,6 +271,16 @@ any delimiter and linked from the elements in @data. <%init> my(%opt) = @_; +my $session; +# load from cache if possible, to avoid recalculating +if ( $cgi->param('session') =~ /^(\d+)$/ ) { + $session = $1; + %opt = %{ $m->cache->get($session) }; +} +else { + $session = sprintf("%10d%6d", time, int(rand(1000000))); + $m->cache->set($session, \%opt, '1h'); +} my $sprintf = $opt{'sprintf'} || '%.2f'; diff --git a/httemplate/graph/report_cust_bill_pkg.html b/httemplate/graph/report_cust_bill_pkg.html index 348746514..f2c486cf4 100644 --- a/httemplate/graph/report_cust_bill_pkg.html +++ b/httemplate/graph/report_cust_bill_pkg.html @@ -6,6 +6,13 @@ <% include('/elements/tr-select-from_to.html' ) %> +<TR> + <TD ALIGN="right">Project to:</TD> + <TD><& /elements/select-month_year.html, + prefix => 'project', + show_month_abbr => 1 &></TD> +</TR> + <% include('/elements/tr-select-agent.html', 'label' => 'For agent: ', 'disable_empty' => 0, @@ -28,19 +35,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> |