summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorivan <ivan>2002-12-16 10:47:38 +0000
committerivan <ivan>2002-12-16 10:47:38 +0000
commit7b636e0d0a90e05e37ebe778bde29709f3323813 (patch)
treece056634f5382ec0d9af98b509046692f8d6be6c /httemplate
parentedbcab06936c79a4f8d4edc0d0222139fa8c312c (diff)
working date range selector that defaults to the past year!
Diffstat (limited to 'httemplate')
-rwxr-xr-xhttemplate/graph/money_time-graph.cgi12
-rw-r--r--httemplate/graph/money_time.cgi26
2 files changed, 29 insertions, 9 deletions
diff --git a/httemplate/graph/money_time-graph.cgi b/httemplate/graph/money_time-graph.cgi
index ca8f6e8..944019a 100755
--- a/httemplate/graph/money_time-graph.cgi
+++ b/httemplate/graph/money_time-graph.cgi
@@ -1,12 +1,16 @@
<%
+#my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
+my ($curmon,$curyear) = (localtime(time))[4,5];
+
#find first month
-my $syear = 2001;
-my $smonth = 8;
+my $syear = $cgi->param('syear') || 1899+$curyear;
+my $smonth = $cgi->param('smonth') || $curmon+1;
#find last month
-my $eyear = 2002;
-my $emonth = 12;
+my $eyear = $cgi->param('eyear') || 1900+$curyear;
+my $emonth = $cgi->param('emonth') || $curmon+1;
+if ( $emonth++>12 ) { $emonth-=12; $eyear++; }
my @labels;
my %data;
diff --git a/httemplate/graph/money_time.cgi b/httemplate/graph/money_time.cgi
index d6c3543..e24157c 100644
--- a/httemplate/graph/money_time.cgi
+++ b/httemplate/graph/money_time.cgi
@@ -1,9 +1,25 @@
+<!-- mason kludge %>
+<%
+
+#my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
+my ($curmon,$curyear) = (localtime(time))[4,5];
+
+#find first month
+my $syear = $cgi->param('syear') || 1899+$curyear;
+my $smonth = $cgi->param('smonth') || $curmon+1;
+
+#find last month
+my $eyear = $cgi->param('eyear') || 1900+$curyear;
+my $emonth = $cgi->param('emonth') || $curmon+1;
+
+%>
+
<HTML>
<HEAD>
<TITLE>Graphing monetary values over time</TITLE>
</HEAD>
<BODY BGCOLOR="#e8e8e8">
-<IMG SRC="money_time-graph.cgi" WIDTH="768" HEIGHT="480">
+<IMG SRC="money_time-graph.cgi?<%= $cgi->query_string %>" WIDTH="768" HEIGHT="480">
<BR>
<FORM METHOD="POST">
<INPUT TYPE="checkbox" NAME="ar">
@@ -18,22 +34,22 @@
From <SELECT NAME="smonth">
<% my @m = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
foreach my $m ( 1..12 ) { %>
-<OPTION VALUE="<%= $m %>"><%= $m[$m-1] %>
+<OPTION VALUE="<%= $m %>"<%= $m == $smonth ? ' SELECTED' : '' %>><%= $m[$m-1] %>
<% } %>
</SELECT>
<SELECT NAME="syear">
<% foreach my $y ( 1999 .. 2010 ) { %>
-<OPTION VALUE="<%= $y %>"><%= $y %>
+<OPTION VALUE="<%= $y %>"<%= $y == $syear ? ' SELECTED' : '' %>><%= $y %>
<% } %>
</SELECT>
to <SELECT NAME="emonth">
<% foreach my $m ( 1..12 ) { %>
-<OPTION VALUE="<%= $m %>"><%= $m[$m-1] %>
+<OPTION VALUE="<%= $m %>"<%= $m == $emonth ? ' SELECTED' : '' %>><%= $m[$m-1] %>
<% } %>
</SELECT>
<SELECT NAME="eyear">
<% foreach my $y ( 1999 .. 2010 ) { %>
-<OPTION VALUE="<%= $y %>"><%= $y %>
+<OPTION VALUE="<%= $y %>"<%= $y == $eyear ? ' SELECTED' : '' %>><%= $y %>
<% } %>
</SELECT>