--- db2gantt.cgi 2002/11/18 08:09:58 1.24 +++ db2gantt.cgi 2002/12/02 17:14:48 1.26 @@ -36,14 +36,25 @@ #--- no user servicable parts below this line -# time range - -$int_t = m_round($int_t); +my $q=new CGI; my ($from_t,$to_t) = (time()-$int_t,time()); -$to_t = param('to_t') if (param('to_t')); $from_t = param('from_t') if (param('from_t')); +$to_t = param('to_t') if (param('to_t')); + +if (param('f-1')) { + $from_t = $from_t - param('int_f-1') || $int_t; +} elsif (param('f+1')) { + $from_t = $from_t + param('int_f+1') || $int_t; +} elsif (param('t-1')) { + $to_t = $from_t - param('int_t-1') || $int_t; +} elsif (param('t+1')) { + $to_t = $from_t + $int_t; +} + +# time range +$int_t = m_round($int_t); # round to nearest minute sub m_round { @@ -78,6 +89,9 @@ exit; } +# open DBI connection +my $dbh = DBI->connect("DBI:Pg:dbname=gantt","","") || die $DBI::errstr; + print "Content-type: text/html Cache-Control: max-age=60, must-revalidate @@ -98,33 +112,43 @@ '; } -print ""; +print " +
+ + +"; # all vars ending in *_t have utime in them. # my $len_t = $to_t - $from_t; -die "interval must be positive and bigger than 1 sec !" if ($len_t < 1); - -my $dbh = DBI->connect("DBI:Pg:dbname=gantt","","") || die $DBI::errstr; -my $q=new CGI; +die "interval must be positive and bigger than 1 sec !" if (abs($len_t) < 1); sub mknav { my $f = shift @_; # from_t my $t = shift @_; # to_t + my $d = shift @_; # delta my $ch = shift @_; # char - return "url(-relative=>1)."?from_t=${f}&to_t=${t}\">$ch"; + return " + + + "; + #return "url(-relative=>1)."?from_t=${f}&to_t=${t}\">$ch"; } print ""; print "\n"; +print mknav($from_t,$to_t,'t-1','<<') if ($to_t+$int_t > $from_t); +print $to,mknav($from_t,$to_t,'t+1','>>'),"\n"; # draw hour grid sub hour_grid { @@ -229,6 +253,7 @@ "; my $sth = $dbh->prepare($sql) || die "sql: $sql ".$dbh->errstr; +print STDERR "sql: $sql\n" if ($debug); my %spec; # specification hash @@ -313,7 +338,10 @@ # init vars for next line ($fix_s,$fix_d) = (0,0); # init fix vars for bar - html_spec if ($curr_spec ne ""); + if ($curr_spec ne "") { + $curr_spec =~ s/ +/ /g; + html_spec; + } $curr_t = $from_t; # init timeline $curr_spec = $row->{specification}; @@ -406,10 +434,15 @@ # label and usage -$len_t = 50; # disable bar scaling print "
\nColors for statuses and usage (#):\n"; print "
Specification"; -print mknav(($from_t-$int_t),$to_t,'<<'),$from; -print mknav(($from_t+$int_t),$to_t,'>>') if ($from_t+$int_t < $to_t); +print mknav($from_t,$to_t,'f-1','<<'),$from; +print mknav($from_t,$to_t,'f+1','>>') if ($from_t+$int_t < $to_t); print ""; -print mknav($from_t,($to_t-$int_t),'<<') if ($to_t-$int_t > $from_t); -print $to,mknav($from_t,($to_t+$int_t),'>>'),"
\n"; +my $max = 0; +foreach my $status (keys %count) { + $max = $count{$status} if ($count{$status} > $max); +} +$len_t = $max ; # disable bar scaling + foreach my $status (keys %count) { #foreach my $status (keys %cols) { print "\n" if ($status ne ""); @@ -418,5 +451,4 @@ # it will first evaluate bar sub (thus increasing number by one) and # then display number (wrongly). } -print "
status#color
$status",$count{$status}*1,"",bar($count{$status},$status),"
\n

Reload url(-relative=>1),"\">current or see help.

"; - +print "
\n

Reload url(-relative=>1),"\">current or see help.

";