5 # 'title' => 'Page title',
7 # 'params' => \@params, # opt,
8 # 'labels' => \@labels, # or \%labels (keys are items)
9 # 'graph_labels' => \%graph_labels,
10 # 'colors' => \%colors,
11 # 'links => \%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
21 my @items = @{ $opt{'items'} };
23 #foreach my $other (qw( labels graph_labels colors links )) {
24 foreach my $other (qw( labels graph_labels colors )) {
25 if ( ref($opt{$other}) eq 'HASH' ) {
26 $opt{$other} = [ map $opt{$other}{$_}, @items ];
30 my $report = new FS::Report::Table::Monthly (
31 #'items' => $opt{'items'},
33 'params' => $opt{'params'},
34 'start_month' => $opt{'start_month'},
35 'start_year' => $opt{'start_year'},
36 'end_month' => $opt{'end_month'},
37 'end_year' => $opt{'end_year'},
38 'agentnum' => $opt{'agentnum'},
40 my $data = $report->data;
42 if ( $cgi->param('_type') =~ /^(png)$/ ) {
44 #my $chart = Chart::LinesPoints->new(1024,480);
45 #my $chart = Chart::LinesPoints->new(768,480);
47 my $graph_type = 'LinesPoints';
48 if ( $opt{'graph_type'} =~ /^(LinesPoints|Mountain)$/ ) {
51 my $class = "Chart::$graph_type";
53 my $chart = $class->new(976,384);
62 [ map hex($_), unpack 'a2a2a2', $color ]
66 #'grey_background' => [ 211, 211, 211 ],
67 'grey_background' => 'white',
68 'background' => [ 0xe8, 0xe8, 0xe8 ], #grey
70 #'grey_background' => 'false',
71 'legend_labels' => $opt{'graph_labels'},
76 #my @data = map { $data->{$_} } ( 'label', @items );
77 my @data = @{ $data->{data} };
78 unshift @data, $data->{'label'};
80 http_header('Content-Type' => 'image/png' );
82 $chart->_set_colors();
84 %><%= $chart->scalar_png(\@data) %><%
88 my @mon = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
90 %><%= include('/elements/header.html', $opt{'title'} ) %>
92 <% $cgi->param('_type', 'png'); %>
93 <IMG SRC="<%= $cgi->self_url %>" WIDTH="976" HEIGHT="384">
96 <%= table('e8e8e8') %>
102 <% foreach my $column ( @{$data->{label}} ) {
103 #$column =~ s/^(\d+)\//$mon[$1-1]<BR>/e;
104 $column =~ s/^(\d+)\//$mon[$1-1]<BR>/;
106 <TH><%= $column %></TH>
109 <% unless ( $opt{'nototal'} ) { %>
115 <% foreach my $row (@items) {
117 my $color = shift( @{ $opt{'colors'} } );
122 <TH><FONT COLOR="#<%= $color %>"><%= shift( @{ $opt{'labels'} } ) %></FONT></TH>
124 <% my $link = exists($opt{'links'}{$row})
125 ? qq(<A HREF="$opt{'links'}{$row})
127 my @speriod = @{$data->{speriod}};
128 my @eperiod = @{$data->{eperiod}};
131 <% foreach my $column ( @{ shift( @{$data->{data}} ) } ) { # ( @{$data->{$row}} ) {
134 <TD ALIGN="right" BGCOLOR="#ffffff">
135 <%= $link ? $link. 'begin='. shift(@speriod). ';end='. shift(@eperiod). '">' : '' %><FONT COLOR="#<%= $color %>">$<%= sprintf("%.2f", $column) %></FONT><%= $link ? '</A>' : '' %>
137 <% $total += $column; %>
141 <% unless ( $opt{'nototal'} ) { %>
143 <TD ALIGN="right" BGCOLOR="#f5f6be">
144 <%= $link ? $link. 'begin='. @{$data->{speriod}}[0]. ';end='. @{$data->{eperiod}}[-1]. '">' : '' %><FONT COLOR="#<%= $color %>">$<%= sprintf("%.2f", $total) %></FONT><%= $link ? '</A>' : '' %>
155 <%= include('/elements/footer.html') %>