5 include('elements/monthly.html',
7 'title' => 'Page title',
9 'labels' => \@labels, # or \%labels (keys are items)
12 'colors' => \@colors, # or \%colors,
15 'graph_labels' => \@graph_labels, # or \%graph_labels,
18 'params' => \@params, # opt,
19 'links' => \@links, # or \%link, #opt
20 'link_fromparam' => 'param_from', #defaults to 'begin'
21 'link_toparam' => 'param_to', #defaults to 'end'
23 #optional, pulled from CGI params if not specified
24 'start_month' => $smonth,
25 'start_year' => $syear,
26 'end_month' => $emonth,
30 'agentnum' => $agentnum,
32 'graph_type' => 'LinesPoints',
35 'sprintf' => '%u', #sprintf format, overrides default %.2f
40 <% include('report.html',
41 'items' => $data->{'items'},
42 'data' => $data->{'data'},
43 'row_labels' => $data->{'item_labels'},
44 'graph_labels' => $opt{'graph_labels'} || $data->{'item_labels'},
45 'col_labels' => [ map { my $m = $_; $m =~ s/^(\d+)\//$mon[$1-1] / ; $m }
47 'axis_labels' => $data->{label},
48 'colors' => $data->{colors},
50 'bottom_link' => \@bottom_link,
51 map { $_, $opt{$_} } (qw(title
62 my $conf = new FS::Conf;
63 my $money_char = $opt{'disable_money'} ? '' : $conf->config('money_char');
65 my $fromparam = $opt{'link_fromparam'} || 'begin';
66 my $toparam = $opt{'link_toparam'} || 'end';
68 my @items = @{ $opt{'items'} };
70 foreach my $other (qw( labels graph_labels colors links )) {
71 if ( ref($opt{$other}) eq 'HASH' ) {
72 $opt{$other} = [ map $opt{$other}{$_}, @items ];
76 my @mon = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
79 $opt{'start_month'} ||= $cgi->param('start_month'); # || $curmon+1;
80 $opt{'start_year'} ||= $cgi->param('start_year'); # || 1899+$curyear;
83 $opt{'end_month'} ||= $cgi->param('end_month'); # || $curmon+1;
84 $opt{'end_year'} ||= $cgi->param('end_year'); # || 1900+$curyear;
86 my $report = new FS::Report::Table::Monthly (
89 'params' => $opt{'params'},
90 'item_labels' => ( $cgi->param('_type') =~ /^(png)$/
91 ? $opt{'graph_labels'}
94 'colors' => $opt{'colors'},
95 'links' => $opt{'links'},
97 'start_month' => $opt{'start_month'},
98 'start_year' => $opt{'start_year'},
99 'end_month' => $opt{'end_month'},
100 'end_year' => $opt{'end_year'},
102 'agentnum' => $opt{'agentnum'},
103 'remove_empty' => $opt{'remove_empty'},
104 'doublemonths' => $opt{'doublemonths'},
106 my $data = $report->data;
109 foreach my $link (@{ $data->{'links'} }) {
110 my @speriod = @{$data->{'speriod'}};
111 my @eperiod = @{$data->{'eperiod'}};
112 my ($begin, $end) = ($fromparam, $toparam);
116 $begin = $link->{'fromparam'};
117 $end = $link->{'toparam'};
118 @new = ( $link->{'link'} );
121 push @new, "$begin=". shift(@speriod).";$end=".shift(@eperiod);
123 if(! $opt{'nototal'}) {
124 push @new, "$begin=". $data->{'speriod'}[0] . ";$end=". $data->{'eperiod'}[-1];
130 if($opt{'bottom_link'}) {
131 my @speriod = (@{$data->{'speriod'}}, $data->{'speriod'}[0]);
132 my @eperiod = (@{$data->{'eperiod'}}, $data->{'eperiod'}[-1]);
134 push @bottom_link, $opt{'bottom_link'};
136 push @bottom_link, "$fromparam=". shift(@speriod). ";$toparam=". shift(@eperiod);