5 % # 'title' => 'Page title',
6 % # 'items' => \@items,
7 % # 'params' => \@params, # opt,
8 % # 'labels' => \@labels, # or \%labels (keys are items)
9 % # 'graph_labels' => \@graph_labels, # or \%graph_labels,
10 % # 'colors' => \@colors, # or \%colors,
11 % # 'links => \@links, # or \%link, #opt
12 % # 'start_month' => $smonth,
13 % # 'start_year' => $syear,
14 % # 'end_month' => $emonth,
15 % # 'end_year' => $eyear,
16 % # 'agentnum' => $agentnum, #opt
17 % # 'nototal' => 1, #opt,
18 % # 'graph_type' => 'LinesPoints', #opt
19 % # 'remove_empty' => 1, #opt,
20 % # 'bottom_total' => 1, #opt,
23 % my @items = @{ $opt{'items'} };
25 % foreach my $other (qw( labels graph_labels colors links )) {
26 % #foreach my $other (qw( labels graph_labels colors )) {
27 % if ( ref($opt{$other}) eq 'HASH' ) {
28 % $opt{$other} = [ map $opt{$other}{$_}, @items ];
32 % my $report = new FS::Report::Table::Monthly (
34 % #'items' => $opt{'items'},
36 % 'params' => $opt{'params'},
37 % 'item_labels' => ( $cgi->param('_type') =~ /^(png)$/
38 % ? $opt{'graph_labels'}
41 % 'colors' => $opt{'colors'},
42 % 'links' => $opt{'links'},
44 % 'start_month' => $opt{'start_month'},
45 % 'start_year' => $opt{'start_year'},
46 % 'end_month' => $opt{'end_month'},
47 % 'end_year' => $opt{'end_year'},
49 % 'agentnum' => $opt{'agentnum'},
50 % 'remove_empty' => $opt{'remove_empty'},
52 % my $data = $report->data;
54 % if ( $cgi->param('_type') =~ /^(png)$/ ) {
56 % #my $chart = Chart::LinesPoints->new(1024,480);
57 % #my $chart = Chart::LinesPoints->new(768,480);
59 % my $graph_type = 'LinesPoints';
60 % if ( $opt{'graph_type'} =~ /^(LinesPoints|Mountain)$/ ) {
63 % my $class = "Chart::$graph_type";
65 % my $chart = $class->new(976,384);
70 % 'legend' => 'bottom',
72 % map { my $color = $_;
74 % [ map hex($_), unpack 'a2a2a2', $color ]
76 % #@{ $opt{'colors'} }
77 % @{ $data->{'colors'} }
79 % #'grey_background' => [ 211, 211, 211 ],
80 % 'grey_background' => 'white',
81 % 'background' => [ 0xe8, 0xe8, 0xe8 ], #grey
83 % #'grey_background' => 'false',
84 % 'legend_labels' => $data->{'item_labels'},
89 % #my @data = map { $data->{$_} } ( 'label', @items );
90 % my @data = @{ $data->{data} };
91 % unshift @data, $data->{'label'};
93 % http_header('Content-Type' => 'image/png' );
95 % $chart->_set_colors();
98 <% $chart->scalar_png(\@data) %>
103 % my @mon = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
106 <% include('/elements/header.html', $opt{'title'} ) %>
107 % $cgi->param('_type', 'png');
109 <IMG SRC="<% $cgi->self_url %>" WIDTH="976" HEIGHT="384">
112 <% table('e8e8e8') %>
117 % foreach my $column ( @{$data->{label}} ) {
118 % #$column =~ s/^(\d+)\//$mon[$1-1]<BR>/e;
119 % $column =~ s/^(\d+)\//$mon[$1-1]<BR>/;
122 <TH><% $column %></TH>
124 % unless ( $opt{'nototal'} ) {
131 % my @bottom_total = ();
132 % foreach my $row ( @{ $data->{'items'} } ) {
134 % #my $color = shift( @{ $opt{'colors'} } );
135 % my $color = shift( @{ $data->{'colors'} } );
136 % my $link = shift( @{ $data->{'links'} } );
137 % $link = $link ? qq(<A HREF="$link) : '';
143 <TH><FONT COLOR="#<% $color %>"><% shift( @{ $data->{'item_labels'} } ) %></FONT></TH>
144 % #my $link = exists($opt{'links'}{$row})
145 % # ? qq(<A HREF="$opt{'links'}{$row})
147 % my @speriod = @{$data->{speriod}};
148 % my @eperiod = @{$data->{eperiod}};
152 % foreach my $column ( @{ shift( @{$data->{data}} ) } ) { # ( @{$data->{$row}} ) {
156 <TD ALIGN="right" BGCOLOR="#ffffff">
157 <% $link ? $link. 'begin='. shift(@speriod). ';end='. shift(@eperiod). '">' : '' %><FONT COLOR="#<% $color %>">$<% sprintf("%.2f", $column) %></FONT><% $link ? '</A>' : '' %>
161 % $bottom_total[$col++] += $column;
164 % unless ( $opt{'nototal'} ) {
167 <TD ALIGN="right" BGCOLOR="#f5f6be">
168 <% $link ? $link. 'begin='. ${$data->{speriod}}[0]. ';end='. ${$data->{eperiod}}[-1]. '">' : '' %><FONT COLOR="#<% $color %>">$<% sprintf("%.2f", $total) %></FONT><% $link ? '</A>' : '' %>
170 % $bottom_total[$col++] += $total;
176 % if ( $opt{'bottom_total'} ) {
177 % my @speriod = ( @{$data->{speriod}}, ${$data->{speriod}}[0] );
178 % my @eperiod = ( @{$data->{eperiod}}, ${$data->{eperiod}}[-1] );
184 % foreach my $total ( @bottom_total ) {
187 <TD ALIGN="right" BGCOLOR="#f5f6be">
188 <% $opt{'bottom_link'}
189 ? '<A HREF="'. $opt{'bottom_link'}.
190 'begin='. shift(@speriod).
191 ';end='. shift(@eperiod). '">'
193 %>$<% sprintf("%.2f", $total) %><% $opt{'bottom_link'} ? '</A>' : '' %>
205 <% include('/elements/footer.html') %>