diff options
Diffstat (limited to 'httemplate/graph')
-rw-r--r-- | httemplate/graph/cust_bill_pkg.cgi | 57 | ||||
-rw-r--r-- | httemplate/graph/elements/monthly.html | 5 | ||||
-rw-r--r-- | httemplate/graph/money_time.cgi | 50 | ||||
-rw-r--r-- | httemplate/graph/money_time_daily.cgi | 31 | ||||
-rw-r--r-- | httemplate/graph/report_cust_bill_pkg.html | 6 | ||||
-rw-r--r-- | httemplate/graph/report_money_time.html | 23 | ||||
-rw-r--r-- | httemplate/graph/report_money_time_daily.html | 12 |
7 files changed, 120 insertions, 64 deletions
diff --git a/httemplate/graph/cust_bill_pkg.cgi b/httemplate/graph/cust_bill_pkg.cgi index ea7fee932..b5486f4af 100644 --- a/httemplate/graph/cust_bill_pkg.cgi +++ b/httemplate/graph/cust_bill_pkg.cgi @@ -27,6 +27,8 @@ my $bottom_link = "$link;"; my $use_usage = $cgi->param('use_usage') || 0; my $use_setup = $cgi->param('use_setup') || 0; +my $use_discount = $cgi->param('use_discount') || 2; + my $use_override = $cgi->param('use_override') ? 1 : 0; my $average_per_cust_pkg = $cgi->param('average_per_cust_pkg') ? 1 : 0; my $distribute = $cgi->param('distribute') ? 1 : 0; @@ -41,11 +43,13 @@ if ( $average_per_cust_pkg ) { } my %charge_labels = ( + 'SRU'=> 'setup + recurring', 'SR' => 'setup + recurring', 'RU' => 'recurring', 'S' => 'setup', 'R' => 'recurring', 'U' => 'usage', + 'D' => 'discount', ); #XXX or virtual @@ -186,6 +190,10 @@ elsif ( $use_usage == 2 ) { $components[-1] =~ s/U//; } +if ( $use_discount == 1 ) { + push @components, 'D'; +} # else leave discounts off entirely; never combine them with setup/recur + # Categorization of line items goes # Agent -> Referral -> Package class -> Component (setup/recur/usage) # If per-agent totals are enabled, they go under the Agent level. @@ -240,21 +248,26 @@ foreach my $agent ( $all_agent || $sel_agent || $FS::CurrentUser::CurrentUser->a 'charges' => $component, ); - # XXX this is very silly. we should cache it server-side and - # just put a cache identifier in the link - my $rowlink = "$link;". - ($all_agent ? '' : "agentnum=$row_agentnum;"). + my $row_link = "$link;". + "charges=$component;". + "distribute=$distribute;"; + + if ( $component eq 'D' ) { + # discounts ignore 'charges' and 'distribute' + $row_link = "${p}search/cust_bill_pkg_discount.html?"; + } + + $row_link .= ($all_agent ? '' : "agentnum=$row_agentnum;"). ($all_part_referral ? '' : "refnum=$row_refnum;"). (join('',map {"cust_classnum=$_;"} @cust_classnums)). - "distribute=$distribute;". - "use_override=$use_override;charges=$component;"; - $rowlink .= "$class_param=$_;" foreach @classnums; + "use_override=$use_override;"; + $row_link .= "$class_param=$_;" foreach @classnums; if ( $all_report_options ) { push @row_params, 'all_report_options', 1; - $rowlink .= 'all_report_options=1'; + $row_link .= 'all_report_options=1'; } push @params, \@row_params; - push @links, $rowlink; + push @links, $row_link; @colorbuf = @agent_colors unless @colorbuf; push @colors, shift @colorbuf; @@ -293,13 +306,22 @@ foreach my $agent ( $all_agent || $sel_agent || $FS::CurrentUser::CurrentUser->a ($all_part_referral ? () : ('refnum' => $row_refnum)), 'charges' => $component, ); + my $row_link = "$link;". - ($all_agent ? '' : "agentnum=$row_agentnum;"). + "charges=$component;". + "distribute=$distribute;"; + + if ( $component eq 'D' ) { + # discounts ignore 'charges' and 'distribute' + $row_link ="${p}search/cust_bill_pkg_discount.html?"; + } + + $row_link .= ($all_agent ? '' : "agentnum=$row_agentnum;"). ($all_part_referral ? '' : "refnum=$row_refnum;"). (join('',map {"cust_classnum=$_;"} @cust_classnums)). "$class_param=$row_classnum;". - "distribute=$distribute;". - "use_override=$use_override;charges=$component;"; + "use_override=$use_override;"; + if ( $class_param eq 'report_optionnum' ) { push @row_params, 'all_report_options' => 1, @@ -366,17 +388,6 @@ foreach my $agent ( $all_agent || $sel_agent || $FS::CurrentUser::CurrentUser->a } -# may be useful at some point... -#if ( $average_per_cust_pkg ) { -# @items = map { ('cust_bill_pkg', 'cust_bill_pkg_count_pkgnum') } @items; -# @labels = map { $_, "Packages" } @labels; -# @params = map { $_, $_ } @params; -# @links = map { $_, $_ } @links; -# @colors = map { $_, $_ } @colors; -# @no_graph = map { $_, 1 } @no_graph; -#} -# - #use Data::Dumper; if ( $cgi->param('debug') == 1 ) { $FS::Report::Table::DEBUG = 1; diff --git a/httemplate/graph/elements/monthly.html b/httemplate/graph/elements/monthly.html index 4b988f166..1a9428115 100644 --- a/httemplate/graph/elements/monthly.html +++ b/httemplate/graph/elements/monthly.html @@ -27,7 +27,7 @@ Example: 'start_year' => $syear, 'end_month' => $emonth, 'end_year' => $eyear, - + '12mo' => 0, #optional, pulled from CGI params if not specified, #only if 'daily' option is given @@ -96,6 +96,8 @@ $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; +$opt{'12mo'} ||= $cgi->param('12mo') ? 1 : 0; + $opt{'projection'} ||= $cgi->param('projection') ? 1 : 0; if ( $opt{'daily'} ) { # daily granularity @@ -119,6 +121,7 @@ my %reportopts = ( 'end_day' => $opt{'end_day'}, 'end_month' => $opt{'end_month'}, 'end_year' => $opt{'end_year'}, + '12mo' => $opt{'12mo'}, 'projection' => $opt{'projection'}, 'agentnum' => $opt{'agentnum'}, 'refnum' => $opt{'refnum'}, diff --git a/httemplate/graph/money_time.cgi b/httemplate/graph/money_time.cgi index 9071fc7b9..aa17eb2f4 100644 --- a/httemplate/graph/money_time.cgi +++ b/httemplate/graph/money_time.cgi @@ -39,33 +39,37 @@ if ( $cgi->param('refnum') =~ /^(\d+)$/ ) { } my $referralname = $part_referral ? $part_referral->referral.' ' : ''; - -my @items = qw( invoiced netsales +# need to clean this up. the false symmetry of "gross" and "net" everything +# makes it aesthetically hard to make this report more useful. +my @items = ($cgi->param('exclude_discount') ? 'invoiced' : 'gross'); +push @items, + qw( discounted netsales credits netcredits payments receipts refunds netrefunds cashflow netcashflow - ); -if ( $cgi->param('12mo') == 1 ) { - @items = map $_.'_12mo', @items; -} + ); my %label = ( - 'invoiced' => 'Gross Sales', - 'netsales' => 'Net Sales', + 'gross' => 'Gross Sales', + 'invoiced' => 'Invoiced Sales', + 'netsales' => 'Net Sales', + 'discounted' => 'Discounts', 'credits' => 'Gross Credits', - 'netcredits' => 'Net Credits', + 'netcredits' => 'Net Credits', 'payments' => 'Gross Receipts', - 'receipts' => 'Net Receipts', + 'receipts' => 'Net Receipts', 'refunds' => 'Gross Refunds', - 'netrefunds' => 'Net Refunds', + 'netrefunds' => 'Net Refunds', 'cashflow' => 'Gross Cashflow', - 'netcashflow' => 'Net Cashflow', + 'netcashflow' => 'Net Cashflow', ); my %graph_suffix = ( - 'invoiced' => ' (invoiced)', + 'gross' => ' (invoiced + discounts)', + 'invoiced' => '', 'netsales' => ' (invoiced - applied credits)', + 'discounted' => '', 'credits' => ' (credited)', 'netcredits' => ' (applied credits)', 'payments' => ' (payments)', @@ -77,13 +81,8 @@ my %graph_suffix = ( ); my %graph_label = map { $_ => $label{$_}.$graph_suffix{$_} } keys %label; -$label{$_.'_12mo'} = $label{$_}. " (prev 12 months)" - foreach keys %label; - -$graph_label{$_.'_12mo'} = $graph_label{$_}. " (prev 12 months)" - foreach keys %graph_label; - my %color = ( + 'gross' => '9999ff', #light blue 'invoiced' => '9999ff', #light blue 'netsales' => '0000cc', #blue 'credits' => 'ff9999', #light red @@ -94,6 +93,7 @@ my %color = ( 'netrefunds' => 'ff9900', #orange 'cashflow' => '99cc33', #light olive 'netcashflow' => '339900', #olive + 'discounted' => 'cc33cc', #purple-ish? ); $color{$_.'_12mo'} = $color{$_} foreach keys %color; @@ -102,7 +102,8 @@ my $ar = "agentnum=$agentnum;refnum=$refnum"; $ar .= ";cust_classnum=$_" foreach @classnums; my %link = ( - 'invoiced' => "${p}search/cust_bill.html?$ar;", + 'gross' => "${p}search/cust_bill.html?$ar;", + 'invoiced' => "${p}search/cust_bill.html?$ar;invoiced=1;", 'netsales' => "${p}search/cust_bill.html?$ar;net=1;", 'credits' => "${p}search/cust_credit.html?$ar;", 'netcredits' => "${p}search/cust_credit_bill.html?$ar;", @@ -110,7 +111,16 @@ my %link = ( 'receipts' => "${p}search/cust_bill_pay.html?$ar;", 'refunds' => "${p}search/cust_refund.html?magic=_date;$ar;", 'netrefunds' => "${p}search/cust_credit_refund.html?$ar;", + 'discounted' => "${p}search/cust_bill_pkg_discount.html?$ar;", ); # XXX link 12mo? +if ( $cgi->param('12mo') ) { + $label{$_} .= " (prev 12 months)" + foreach keys %label; + + $graph_label{$_} .= " (prev 12 months)" + foreach keys %graph_label; +} + </%init> diff --git a/httemplate/graph/money_time_daily.cgi b/httemplate/graph/money_time_daily.cgi index 9b2ca714b..00771d3d6 100644 --- a/httemplate/graph/money_time_daily.cgi +++ b/httemplate/graph/money_time_daily.cgi @@ -8,7 +8,6 @@ 'links' => \%link, 'agentnum' => $agentnum, 'cust_classnum'=> \@classnums, - 'nototal' => scalar($cgi->param('12mo')), 'daily' => 1, 'start_day' => $smday, 'start_month' => $smon+1, @@ -44,19 +43,20 @@ my ($ssec,$smin,$shour,$smday,$smon,$syear,$swday,$syday,$sisdst) my ($esec,$emin,$ehour,$emday,$emon,$eyear,$ewday,$eyday,$eisdst) = localtime($ending); -my @items = qw( invoiced netsales +my @items = ($cgi->param('exclude_discount') ? 'invoiced' : 'gross'); +push @items, + qw( discounted netsales credits netcredits payments receipts refunds netrefunds cashflow netcashflow ); -if ( $cgi->param('12mo') == 1 ) { - @items = map $_.'_12mo', @items; -} my %label = ( - 'invoiced' => 'Gross Sales', + 'gross' => 'Gross Sales', + 'invoiced' => 'Invoiced Sales', 'netsales' => 'Net Sales', + 'discounted' => 'Discounts', 'credits' => 'Gross Credits', 'netcredits' => 'Net Credits', 'payments' => 'Gross Receipts', @@ -68,8 +68,10 @@ my %label = ( ); my %graph_suffix = ( - 'invoiced' => ' (invoiced)', + 'gross' => ' (invoiced + discounts)', + 'invoiced' => '', 'netsales' => ' (invoiced - applied credits)', + 'discounted' => '', 'credits' => ' (credited)', 'netcredits' => ' (applied credits)', 'payments' => ' (payments)', @@ -81,13 +83,8 @@ my %graph_suffix = ( ); my %graph_label = map { $_ => $label{$_}.$graph_suffix{$_} } keys %label; -$label{$_.'_12mo'} = $label{$_}. " (prev 12 months)" - foreach keys %label; - -$graph_label{$_.'_12mo'} = $graph_label{$_}. " (prev 12 months)" - foreach keys %graph_label; - my %color = ( + 'gross' => '9999ff', #light blue 'invoiced' => '9999ff', #light blue 'netsales' => '0000cc', #blue 'credits' => 'ff9999', #light red @@ -98,12 +95,12 @@ my %color = ( 'netrefunds' => 'ff9900', #orange 'cashflow' => '99cc33', #light olive 'netcashflow' => '339900', #olive + 'discounted' => 'cc33cc', #purple-ish? ); -$color{$_.'_12mo'} = $color{$_} - foreach keys %color; my %link = ( - 'invoiced' => "${p}search/cust_bill.html?agentnum=$agentnum;", + 'gross' => "${p}search/cust_bill.html?agentnum=$agentnum;", + 'invoiced' => "${p}search/cust_bill.html?agentnum=$agentnum;invoiced=1;", 'netsales' => "${p}search/cust_bill.html?agentnum=$agentnum;net=1;", 'credits' => "${p}search/cust_credit.html?agentnum=$agentnum;", 'netcredits' => "${p}search/cust_credit_bill.html?agentnum=$agentnum;", @@ -111,7 +108,7 @@ my %link = ( 'receipts' => "${p}search/cust_bill_pay.html?agentnum=$agentnum;", 'refunds' => "${p}search/cust_refund.html?magic=_date;agentnum=$agentnum;", 'netrefunds' => "${p}search/cust_credit_refund.html?agentnum=$agentnum;", + 'discounted' => "${p}search/cust_bill_pkg_discount.html?agentnum=$agentnum;", ); -# XXX link 12mo? </%init> diff --git a/httemplate/graph/report_cust_bill_pkg.html b/httemplate/graph/report_cust_bill_pkg.html index 76d3a6ca3..1db86e393 100644 --- a/httemplate/graph/report_cust_bill_pkg.html +++ b/httemplate/graph/report_cust_bill_pkg.html @@ -190,6 +190,12 @@ window.onload = class_mode_changed; 'onchange'=> 'enable_agent_totals', &> % } +<& /elements/tr-select.html, + 'label' => 'Discounts', + 'field' => 'use_discount', + 'options' => [ 1, 2 ], + 'labels' => { 1 => 'Separate', 2 => 'Do not show' }, +&> <TR> <TD ALIGN="right">Colors</TD> diff --git a/httemplate/graph/report_money_time.html b/httemplate/graph/report_money_time.html index 315d31bc5..aaaf01b19 100644 --- a/httemplate/graph/report_money_time.html +++ b/httemplate/graph/report_money_time.html @@ -36,9 +36,26 @@ ) %> -<TR> - <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="12mo" VALUE="1"></TD> - <TD>Show 12 month totals instead of monthly values</TD> +<tr> + <td /> + <td> + <& /elements/checkbox.html, + field => '12mo', + value => 1, + &> + <% emt('Show 12 month totals instead of monthly values') %> + </td> +</tr> +<tr> + <td /> + <td> + <& /elements/checkbox.html, + field => 'exclude_discount', + value => 1, + curr_value => 0, + &> + <% emt('Exclude discounts from total sales') %> + </td> </TR> </TABLE> diff --git a/httemplate/graph/report_money_time_daily.html b/httemplate/graph/report_money_time_daily.html index e80f5862c..ca3d915f1 100644 --- a/httemplate/graph/report_money_time_daily.html +++ b/httemplate/graph/report_money_time_daily.html @@ -21,6 +21,18 @@ 'multiple' => 1, &> +<tr> + <td /> + <td> + <& /elements/checkbox.html, + field => 'exclude_discount', + value => 1, + curr_value => 0, + &> + <% emt('Exclude discounts from total sales') %> + </td> +</TR> + </TABLE> <BR><INPUT TYPE="submit" VALUE="Display"> |