5 # 'title' => 'Page title',
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);
74 [ map hex($_), unpack 'a2a2a2', $color ]
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();
97 %><%= $chart->scalar_png(\@data) %><%
101 my @mon = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
103 %><%= include('/elements/header.html', $opt{'title'} ) %>
105 <% $cgi->param('_type', 'png'); %>
106 <IMG SRC="<%= $cgi->self_url %>" WIDTH="976" HEIGHT="384">
109 <%= table('e8e8e8') %>
115 <% foreach my $column ( @{$data->{label}} ) {
116 #$column =~ s/^(\d+)\//$mon[$1-1]<BR>/e;
117 $column =~ s/^(\d+)\//$mon[$1-1]<BR>/;
119 <TH><%= $column %></TH>
122 <% unless ( $opt{'nototal'} ) { %>
128 <% my @bottom_total = ();
129 foreach my $row ( @{ $data->{'items'} } ) {
131 #my $color = shift( @{ $opt{'colors'} } );
132 my $color = shift( @{ $data->{'colors'} } );
133 my $link = shift( @{ $data->{'links'} } );
134 $link = $link ? qq(<A HREF="$link) : '';
139 <TH><FONT COLOR="#<%= $color %>"><%= shift( @{ $data->{'item_labels'} } ) %></FONT></TH>
141 <% #my $link = exists($opt{'links'}{$row})
142 # ? qq(<A HREF="$opt{'links'}{$row})
144 my @speriod = @{$data->{speriod}};
145 my @eperiod = @{$data->{eperiod}};
149 foreach my $column ( @{ shift( @{$data->{data}} ) } ) { # ( @{$data->{$row}} ) {
152 <TD ALIGN="right" BGCOLOR="#ffffff">
153 <%= $link ? $link. 'begin='. shift(@speriod). ';end='. shift(@eperiod). '">' : '' %><FONT COLOR="#<%= $color %>">$<%= sprintf("%.2f", $column) %></FONT><%= $link ? '</A>' : '' %>
157 $bottom_total[$col++] += $column;
162 <% unless ( $opt{'nototal'} ) { %>
164 <TD ALIGN="right" BGCOLOR="#f5f6be">
165 <%= $link ? $link. 'begin='. ${$data->{speriod}}[0]. ';end='. ${$data->{eperiod}}[-1]. '">' : '' %><FONT COLOR="#<%= $color %>">$<%= sprintf("%.2f", $total) %></FONT><%= $link ? '</A>' : '' %>
168 <% $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 ) { %>
186 <TD ALIGN="right" BGCOLOR="#f5f6be">
187 <%= $opt{'bottom_link'}
188 ? '<A HREF="'. $opt{'bottom_link'}.
189 'begin='. shift(@speriod).
190 ';end='. shift(@eperiod). '">'
192 %>$<%= sprintf("%.2f", $total) %><%= $opt{'bottom_link'} ? '</A>' : '' %>
204 <%= include('/elements/footer.html') %>