3 #my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
4 my ($curmon,$curyear) = (localtime(time))[4,5];
7 my $syear = $cgi->param('syear') || 1899+$curyear;
8 my $smonth = $cgi->param('smonth') || $curmon+1;
11 my $eyear = $cgi->param('eyear') || 1900+$curyear;
12 my $emonth = $cgi->param('emonth') || $curmon+1;
13 #if ( $emonth++>12 ) { $emonth-=12; $eyear++; }
17 if ( $cgi->param('agentnum') =~ /^(\d*)$/ ) {
24 my @items = qw( invoiced netsales credits payments receipts );
25 if ( $cgi->param('12mo') == 1 ) {
26 @items = map $_.'_12mo', @items;
30 'invoiced' => 'Gross Sales (invoiced)',
31 'netsales' => 'Net Sales (invoiced - applied credits)',
32 'credits' => 'Credits',
33 'payments' => 'Gross Receipts (payments)',
34 'receipts' => 'Net Receipts/Cashflow (payments - refunds)',
36 $label{$_.'_12mo'} = $label{$_}. " (previous 12 months)"
40 'invoiced' => [ 153, 153, 255 ], #light blue
41 'netsales' => [ 0, 0, 204 ], #blue
42 'credits' => [ 204, 0, 0 ], #red
43 'payments' => [ 153, 204, 153 ], #light green
44 'receipts' => [ 0, 204, 0 ], #green
46 $color{$_.'_12mo'} = $color{$_}
49 my $report = new FS::Report::Table::Monthly (
51 'start_month' => $smonth,
52 'start_year' => $syear,
53 'end_month' => $emonth,
55 'agentnum' => $agentnum,
57 my %data = %{$report->data};
59 #my $chart = Chart::LinesPoints->new(1024,480);
60 #my $chart = Chart::LinesPoints->new(768,480);
61 my $chart = Chart::LinesPoints->new(976,384);
67 'colors' => { ( map { 'dataset'.$d++ => $color{$_} } @items ),
68 #'grey_background' => [ 211, 211, 211 ],
69 'grey_background' => 'white',
70 'background' => [ 0xe8, 0xe8, 0xe8 ], #grey
72 #'grey_background' => 'false',
73 'legend_labels' => [ map { $label{$_} } @items ],
78 my @data = map { $data{$_} } ( 'label', @items );
80 http_header('Content-Type' => 'image/png' );
82 $chart->_set_colors();
84 %><%= $chart->scalar_png(\@data) %>