much easier to understand listing of credits/payments that get split up, closes:...
[freeside.git] / httemplate / graph / money_time.cgi
1 <!-- mason kludge -->
2 <%
3
4 #my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
5 my ($curmon,$curyear) = (localtime(time))[4,5];
6
7 #find first month
8 my $syear = $cgi->param('syear') || 1899+$curyear;
9 my $smonth = $cgi->param('smonth') || $curmon+1;
10
11 #find last month
12 my $eyear = $cgi->param('eyear') || 1900+$curyear;
13 my $emonth = $cgi->param('emonth') || $curmon+1;
14
15 %>
16
17 <HTML>
18   <HEAD>
19     <TITLE>Sales, Credits and Receipts Summary</TITLE>
20   </HEAD>
21 <BODY BGCOLOR="#e8e8e8">
22 <IMG SRC="money_time-graph.cgi?<%= $cgi->query_string %>" WIDTH="976" HEIGHT="384">
23 <BR>
24
25 <%= table('e8e8e8') %>
26 <%
27
28 my @items = qw( invoiced netsales credits receipts );
29 my %label = (
30   'invoiced' => 'Gross Sales',
31   'netsales' => 'Net Sales',
32   'credits'  => 'Credits',
33   'receipts' => 'Receipts',
34 );
35 my %color = (
36   'invoiced' => '9999ff', #light blue
37   'netsales' => '0000cc', #blue
38   'credits'  => 'cc0000', #red
39   'receipts' => '00cc00', #green
40 );
41
42 my $report = new FS::Report::Table::Monthly (
43   'items' => \@items,
44   'start_month' => $smonth,
45   'start_year'  => $syear,
46   'end_month'   => $emonth,
47   'end_year'    => $eyear,
48 );
49 my $data = $report->data;
50
51
52 my @mon = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
53
54 %>
55
56 <TR><TD></TD>
57 <% foreach my $column ( @{$data->{label}} ) {
58      #$column =~ s/^(\d+)\//$mon[$1-1]<BR>/e;
59      $column =~ s/^(\d+)\//$mon[$1-1]<BR>/;
60      %>
61      <TH><%= $column %></TH>
62 <% } %>
63 </TR>
64
65 <% foreach my $row (@items) { %>
66   <TR><TH><FONT COLOR="#<%= $color{$row} %>"><%= $label{$row} %></FONT></TH>
67   <% foreach my $column ( @{$data->{$row}} ) { %>
68     <TD ALIGN="right" BGCOLOR="#ffffff">
69       <FONT COLOR="#<%= $color{$row} %>">$<%= sprintf("%.2f", $column) %></FONT>
70     </TD>
71   <% } %>
72   </TR>
73 <% } %>
74 </TABLE>
75
76 <BR>
77 <FORM METHOD="POST">
78 <!--
79 <INPUT TYPE="checkbox" NAME="ar">
80   Accounts receivable (invoices - applied credits)<BR>
81 <INPUT TYPE="checkbox" NAME="charged">
82   Just Invoices<BR>
83 <INPUT TYPE="checkbox" NAME="defer">
84   Accounts receivable, with deferred revenue (invoices - applied credits, with charges for annual/semi-annual/quarterly/etc. services deferred over applicable time period) (there has got to be a shorter description for this)<BR>
85 <INPUT TYPE="checkbox" NAME="cash">
86   Cashflow (payments - refunds)<BR>
87 <BR>
88 -->
89 From <SELECT NAME="smonth">
90 <% foreach my $mon ( 1..12 ) { %>
91 <OPTION VALUE="<%= $mon %>"<%= $mon == $smonth ? ' SELECTED' : '' %>><%= $mon[$mon-1] %>
92 <% } %>
93 </SELECT>
94 <SELECT NAME="syear">
95 <% foreach my $y ( 1999 .. 2010 ) { %>
96 <OPTION VALUE="<%= $y %>"<%= $y == $syear ? ' SELECTED' : '' %>><%= $y %>
97 <% } %>
98 </SELECT>
99  to <SELECT NAME="emonth">
100 <% foreach my $mon ( 1..12 ) { %>
101 <OPTION VALUE="<%= $mon %>"<%= $mon == $emonth ? ' SELECTED' : '' %>><%= $mon[$mon-1] %>
102 <% } %>
103 </SELECT>
104 <SELECT NAME="eyear">
105 <% foreach my $y ( 1999 .. 2010 ) { %>
106 <OPTION VALUE="<%= $y %>"<%= $y == $eyear ? ' SELECTED' : '' %>><%= $y %>
107 <% } %>
108 </SELECT>
109
110 <INPUT TYPE="submit" VALUE="Redisplay">
111 </FORM>
112 </BODY>
113 </HTML>