show a better message when no results are found
[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 payments receipts );
29 my %label = (
30   'invoiced' => 'Gross Sales',
31   'netsales' => 'Net Sales',
32   'credits'  => 'Credits',
33   'payments' => 'Gross Receipts',
34   'receipts' => 'Net Receipts',
35 );
36 my %color = (
37   'invoiced' => '9999ff', #light blue
38   'netsales' => '0000cc', #blue
39   'credits'  => 'cc0000', #red
40   'payments' => '99cc99', #light green
41   'receipts' => '00cc00', #green
42 );
43 my %link = (
44   'invoiced' => "${p}search/cust_bill.html?",
45   'credits'  => "${p}search/cust_credit.html?",
46   'payments' => "${p}search/cust_pay.cgi?magic=_date;",
47 );
48
49 my $report = new FS::Report::Table::Monthly (
50   'items' => \@items,
51   'start_month' => $smonth,
52   'start_year'  => $syear,
53   'end_month'   => $emonth,
54   'end_year'    => $eyear,
55 );
56 my $data = $report->data;
57
58 my @mon = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
59
60 %>
61
62 <TR><TD></TD>
63 <% foreach my $column ( @{$data->{label}} ) {
64      #$column =~ s/^(\d+)\//$mon[$1-1]<BR>/e;
65      $column =~ s/^(\d+)\//$mon[$1-1]<BR>/;
66      %>
67      <TH><%= $column %></TH>
68 <% } %>
69 </TR>
70
71 <% foreach my $row (@items) { %>
72   <TR><TH><FONT COLOR="#<%= $color{$row} %>"><%= $label{$row} %></FONT></TH>
73   <% my $link = exists($link{$row})
74        ? qq(<A HREF="$link{$row})
75        : '';
76      my @speriod = @{$data->{speriod}};
77      my @eperiod = @{$data->{eperiod}};
78   %>
79   <% foreach my $column ( @{$data->{$row}} ) { %>
80     <TD ALIGN="right" BGCOLOR="#ffffff">
81       <%= $link ? $link. 'begin='. shift(@speriod). ';end='. shift(@eperiod). '">' : '' %><FONT COLOR="#<%= $color{$row} %>">$<%= sprintf("%.2f", $column) %></FONT><%= $link ? '</A>' : '' %>
82     </TD>
83   <% } %>
84   </TR>
85 <% } %>
86 </TABLE>
87
88 <BR>
89 <FORM METHOD="POST">
90 <!--
91 <INPUT TYPE="checkbox" NAME="ar">
92   Accounts receivable (invoices - applied credits)<BR>
93 <INPUT TYPE="checkbox" NAME="charged">
94   Just Invoices<BR>
95 <INPUT TYPE="checkbox" NAME="defer">
96   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>
97 <INPUT TYPE="checkbox" NAME="cash">
98   Cashflow (payments - refunds)<BR>
99 <BR>
100 -->
101 From <SELECT NAME="smonth">
102 <% foreach my $mon ( 1..12 ) { %>
103 <OPTION VALUE="<%= $mon %>"<%= $mon == $smonth ? ' SELECTED' : '' %>><%= $mon[$mon-1] %>
104 <% } %>
105 </SELECT>
106 <SELECT NAME="syear">
107 <% foreach my $y ( 1999 .. 2010 ) { %>
108 <OPTION VALUE="<%= $y %>"<%= $y == $syear ? ' SELECTED' : '' %>><%= $y %>
109 <% } %>
110 </SELECT>
111  to <SELECT NAME="emonth">
112 <% foreach my $mon ( 1..12 ) { %>
113 <OPTION VALUE="<%= $mon %>"<%= $mon == $emonth ? ' SELECTED' : '' %>><%= $mon[$mon-1] %>
114 <% } %>
115 </SELECT>
116 <SELECT NAME="eyear">
117 <% foreach my $y ( 1999 .. 2010 ) { %>
118 <OPTION VALUE="<%= $y %>"<%= $y == $eyear ? ' SELECTED' : '' %>><%= $y %>
119 <% } %>
120 </SELECT>
121
122 <INPUT TYPE="submit" VALUE="Redisplay">
123 </FORM>
124 </BODY>
125 </HTML>