--- db2gantt.cgi 2002/12/02 14:35:17 1.25 +++ db2gantt.cgi 2003/06/26 20:36:48 1.28 @@ -10,6 +10,10 @@ my $debug = 0; +# comment out following field if you don't want links to omni reports +# or haven't installed repgen.pl +my $repgen_url="/omni/"; # URL to pages with rptgen.pl + my $width = 600; # width of bar my $height = 15; # height of bar my $use_js = 1; # use JavaScript pop-up @@ -36,7 +40,6 @@ #--- no user servicable parts below this line -my $dbh = DBI->connect("DBI:Pg:dbname=gantt","","") || die $DBI::errstr; my $q=new CGI; my ($from_t,$to_t) = (time()-$int_t,time()); @@ -90,6 +93,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 @@ -230,14 +236,23 @@ print STDERR "bar[$col] len:$l s scale:",($len_t/$width)," size:$size px
alt:$alt\n" if ($debug); - my $html = "url(-relative=>1)."/$col\" width=\"$size\" height=\"$h\""; + my $html; + + my ($html_end, $img_end) = ("",""); + if ($repgen_url && $alt =~ m#(\d\d\d\d)/(\d\d)/(\d\d)-(\d+)#) { + $html .= ""; + $html_end .= ""; + $img_end .= " border=0"; + } + + $html .= "url(-relative=>1)."/$col\" width=\"$size\" height=\"$h\""; if ($use_js && $alt) { $html .= " onmouseover=\"T('$alt')\" onmouseout=\"T()\""; } elsif ($alt) { $html .= " alt=\"$alt\""; } - $html .= ">"; + $html .= "$img_end>$html_end"; return($html); } @@ -251,6 +266,7 @@ "; my $sth = $dbh->prepare($sql) || die "sql: $sql ".$dbh->errstr; +print STDERR "sql: $sql\n" if ($debug); my %spec; # specification hash @@ -286,6 +302,8 @@ $last_var = $v; } } + # fix division by zero + $max_use++ if ($max_use == 0); my $h = $last_var / $max_use * $height; my $c = 255 - int (255 * $last_var / $max_use); print color_bar($len,"$c,$c,$c","$last_var concurrent jobs",1,$h+1) if ($len); @@ -335,7 +353,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}; @@ -428,10 +449,15 @@ # label and usage -$len_t = 50; # disable bar scaling print "
\nColors for statuses and usage (#):\n"; print "\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 ""); @@ -441,4 +467,3 @@ # then display number (wrongly). } print "
status#color
$status",$count{$status}*1,"",bar($count{$status},$status),"
\n

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

"; -