36 |
|
|
37 |
#--- no user servicable parts below this line |
#--- no user servicable parts below this line |
38 |
|
|
39 |
# time range |
my $dbh = DBI->connect("DBI:Pg:dbname=gantt","","") || die $DBI::errstr; |
40 |
|
my $q=new CGI; |
|
$int_t = m_round($int_t); |
|
41 |
|
|
42 |
my ($from_t,$to_t) = (time()-$int_t,time()); |
my ($from_t,$to_t) = (time()-$int_t,time()); |
43 |
|
|
|
$to_t = param('to_t') if (param('to_t')); |
|
44 |
$from_t = param('from_t') if (param('from_t')); |
$from_t = param('from_t') if (param('from_t')); |
45 |
|
$to_t = param('to_t') if (param('to_t')); |
46 |
|
|
47 |
|
if (param('f-1')) { |
48 |
|
$from_t = $from_t - param('int_f-1') || $int_t; |
49 |
|
} elsif (param('f+1')) { |
50 |
|
$from_t = $from_t + param('int_f+1') || $int_t; |
51 |
|
} elsif (param('t-1')) { |
52 |
|
$to_t = $from_t - param('int_t-1') || $int_t; |
53 |
|
} elsif (param('t+1')) { |
54 |
|
$to_t = $from_t + $int_t; |
55 |
|
} |
56 |
|
|
57 |
|
# time range |
58 |
|
$int_t = m_round($int_t); |
59 |
|
|
60 |
# round to nearest minute |
# round to nearest minute |
61 |
sub m_round { |
sub m_round { |
82 |
$im->transparent($back); |
$im->transparent($back); |
83 |
my $col = path_info(); $col =~ s,/,,g; |
my $col = path_info(); $col =~ s,/,,g; |
84 |
my ($r,$g,$b) = split(/,/,$col); |
my ($r,$g,$b) = split(/,/,$col); |
85 |
my $col = $im->colorAllocate($r,$g,$b); |
$col = $im->colorAllocate($r,$g,$b); |
86 |
$im->fill(0,0,$col); |
$im->fill(0,0,$col); |
87 |
print "Content-Length: ",length($im->png),"\n\n"; |
print "Content-Length: ",length($im->png),"\n\n"; |
88 |
binmode STDOUT; |
binmode STDOUT; |
110 |
</script> |
</script> |
111 |
'; |
'; |
112 |
} |
} |
113 |
print "</head><body>"; |
print "</head><body> |
114 |
|
<form action=".$q->url(-relative=>1)." method=get> |
115 |
|
<input type=hidden name=from_t value=$from_t> |
116 |
|
<input type=hidden name=to_t value=$to_t> |
117 |
|
"; |
118 |
|
|
119 |
# all vars ending in *_t have utime in them. |
# all vars ending in *_t have utime in them. |
120 |
# |
# |
121 |
my $len_t = $to_t - $from_t; |
my $len_t = $to_t - $from_t; |
122 |
|
|
123 |
die "interval must be positive and bigger than 1 sec !" if ($len_t < 1); |
die "interval must be positive and bigger than 1 sec !" if (abs($len_t) < 1); |
|
|
|
|
my $dbh = DBI->connect("DBI:Pg:dbname=gantt","","") || die $DBI::errstr; |
|
|
my $q=new CGI; |
|
124 |
|
|
125 |
|
|
126 |
sub mknav { |
sub mknav { |
127 |
my $f = shift @_; # from_t |
my $f = shift @_; # from_t |
128 |
my $t = shift @_; # to_t |
my $t = shift @_; # to_t |
129 |
|
my $d = shift @_; # delta |
130 |
my $ch = shift @_; # char |
my $ch = shift @_; # char |
131 |
|
|
132 |
return "<a href=\"".$q->url(-relative=>1)."?from_t=${f}&to_t=${t}\">$ch</a>"; |
return " |
133 |
|
<select name=int_${d}> |
134 |
|
<option value=".(12*60*60).">12h</option> |
135 |
|
<option value=".(24*60*60).">day</option> |
136 |
|
<option value=".(7*24*60*60).">week</option> |
137 |
|
</select> |
138 |
|
<input type=submit name=$d value=\"$ch\"> |
139 |
|
"; |
140 |
|
#return "<a href=\"".$q->url(-relative=>1)."?from_t=${f}&to_t=${t}\">$ch</a>"; |
141 |
} |
} |
142 |
|
|
143 |
print "<table cellspacing=0 cellpadding=0>"; |
print "<table cellspacing=0 cellpadding=0>"; |
144 |
print "<tr bgcolor=#e0e0e0><td>Specification</td><td align=left>"; |
print "<tr bgcolor=#e0e0e0><td>Specification</td><td align=left>"; |
145 |
print mknav(($from_t-$int_t),$to_t,'<small><<</small>'),$from; |
print mknav($from_t,$to_t,'f-1','<<'),$from; |
146 |
print mknav(($from_t+$int_t),$to_t,'<small>>></small>') if ($from_t+$int_t < $to_t); |
print mknav($from_t,$to_t,'f+1','>>') if ($from_t+$int_t < $to_t); |
147 |
print "</td><td align=right>"; |
print "</td><td align=right>"; |
148 |
print mknav($from_t,($to_t-$int_t),'<small><<</small>') if ($to_t-$int_t > $from_t); |
print mknav($from_t,$to_t,'t-1','<<') if ($to_t+$int_t > $from_t); |
149 |
print $to,mknav($from_t,($to_t+$int_t),'<small>>></small>'),"</td></tr>\n"; |
print $to,mknav($from_t,$to_t,'t+1','>>'),"</td></tr>\n"; |
150 |
|
|
151 |
# draw hour grid |
# draw hour grid |
152 |
sub hour_grid { |
sub hour_grid { |
254 |
|
|
255 |
my %spec; # specification hash |
my %spec; # specification hash |
256 |
|
|
257 |
my $curr_spec; |
my $curr_spec = ""; |
258 |
my $curr_t = $from_t; |
my $curr_t = $from_t; |
259 |
|
|
260 |
$sth->execute() || die "sql: $sql ".$dbh->errstr; |
$sth->execute() || die "sql: $sql ".$dbh->errstr; |
440 |
# it will first evaluate bar sub (thus increasing number by one) and |
# it will first evaluate bar sub (thus increasing number by one) and |
441 |
# then display number (wrongly). |
# then display number (wrongly). |
442 |
} |
} |
443 |
print "</table>\n<p>Reload <a href=\"",$q->url(-relative=>1),"\">current</a> or see <a href=\"db2gantt_help.html\">help</a>.</p></body></html>"; |
print "</table></form>\n<p>Reload <a href=\"",$q->url(-relative=>1),"\">current</a> or see <a href=\"db2gantt_help.html\">help</a>.</p></body></html>"; |
444 |
|
|