/[omni_gantt]/db2gantt.cgi
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /db2gantt.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.25 by dpavlin, Mon Dec 2 14:35:17 2002 UTC revision 1.28 by dpavlin, Thu Jun 26 20:36:48 2003 UTC
# Line 10  use POSIX qw(strftime); Line 10  use POSIX qw(strftime);
10    
11  my $debug = 0;  my $debug = 0;
12    
13    # comment out following field if you don't want links to omni reports
14    # or haven't installed repgen.pl
15    my $repgen_url="/omni/"; # URL to pages with rptgen.pl
16    
17  my $width = 600;        # width of bar  my $width = 600;        # width of bar
18  my $height = 15;        # height of bar  my $height = 15;        # height of bar
19  my $use_js = 1;         # use JavaScript pop-up  my $use_js = 1;         # use JavaScript pop-up
# Line 36  my $min_l = 3;                 # min length of bar seg Line 40  my $min_l = 3;                 # min length of bar seg
40    
41  #--- no user servicable parts below this line  #--- no user servicable parts below this line
42    
 my $dbh = DBI->connect("DBI:Pg:dbname=gantt","","") || die $DBI::errstr;  
43  my $q=new CGI;  my $q=new CGI;
44    
45  my ($from_t,$to_t) = (time()-$int_t,time());  my ($from_t,$to_t) = (time()-$int_t,time());
# Line 90  if (path_info()) { Line 93  if (path_info()) {
93          exit;          exit;
94  }  }
95    
96    # open DBI connection
97    my $dbh = DBI->connect("DBI:Pg:dbname=gantt","","") || die $DBI::errstr;
98    
99  print "Content-type: text/html  print "Content-type: text/html
100  Cache-Control: max-age=60, must-revalidate  Cache-Control: max-age=60, must-revalidate
101    
# Line 230  sub color_bar { Line 236  sub color_bar {
236    
237          print STDERR "bar[$col] len:$l s scale:",($len_t/$width)," size:$size px<br> alt:$alt\n" if ($debug);          print STDERR "bar[$col] len:$l s scale:",($len_t/$width)," size:$size px<br> alt:$alt\n" if ($debug);
238    
239          my $html = "<img src=\"".$q->url(-relative=>1)."/$col\" width=\"$size\" height=\"$h\"";          my $html;
240    
241            my ($html_end, $img_end) = ("","");
242            if ($repgen_url && $alt =~ m#(\d\d\d\d)/(\d\d)/(\d\d)-(\d+)#) {
243                    $html .= "<a href=\"$repgen_url/$1-$2-$3-$4.html\">";
244                    $html_end .= "</a>";
245                    $img_end .= " border=0";
246            }
247    
248            $html .= "<img src=\"".$q->url(-relative=>1)."/$col\" width=\"$size\" height=\"$h\"";
249    
250          if ($use_js && $alt) {          if ($use_js && $alt) {
251                  $html .= " onmouseover=\"T('$alt')\" onmouseout=\"T()\"";                  $html .= " onmouseover=\"T('$alt')\" onmouseout=\"T()\"";
252          } elsif ($alt) {          } elsif ($alt) {
253                  $html .= " alt=\"$alt\"";                  $html .= " alt=\"$alt\"";
254          }          }
255          $html .= ">";          $html .= "$img_end>$html_end";
256    
257          return($html);          return($html);
258  }  }
# Line 251  my $sql = "select start,finish,specifica Line 266  my $sql = "select start,finish,specifica
266          ";          ";
267    
268  my $sth = $dbh->prepare($sql) || die "sql: $sql ".$dbh->errstr;  my $sth = $dbh->prepare($sql) || die "sql: $sql ".$dbh->errstr;
269    print STDERR "sql: $sql\n" if ($debug);
270    
271  my %spec;       # specification hash  my %spec;       # specification hash
272    
# Line 286  sub sum_bar { Line 302  sub sum_bar {
302                          $last_var = $v;                          $last_var = $v;
303                  }                  }
304          }          }
305            # fix division by zero
306            $max_use++ if ($max_use == 0);
307          my $h = $last_var / $max_use * $height;          my $h = $last_var / $max_use * $height;
308          my $c = 255 - int (255 * $last_var / $max_use);          my $c = 255 - int (255 * $last_var / $max_use);
309          print color_bar($len,"$c,$c,$c","$last_var concurrent jobs",1,$h+1) if ($len);          print color_bar($len,"$c,$c,$c","$last_var concurrent jobs",1,$h+1) if ($len);
# Line 335  while(my $row = $sth->fetchrow_hashref) Line 353  while(my $row = $sth->fetchrow_hashref)
353                  # init vars for next line                  # init vars for next line
354                  ($fix_s,$fix_d) = (0,0); # init fix vars for bar                  ($fix_s,$fix_d) = (0,0); # init fix vars for bar
355    
356                  html_spec if ($curr_spec ne "");                  if ($curr_spec ne "") {
357                            $curr_spec =~ s/ +/&nbsp;/g;
358                            html_spec;
359                    }
360    
361                  $curr_t = $from_t;      # init timeline                  $curr_t = $from_t;      # init timeline
362                  $curr_spec = $row->{specification};                  $curr_spec = $row->{specification};
# Line 428  print "</table>"; Line 449  print "</table>";
449    
450    
451  # label and usage  # label and usage
 $len_t = 50; # disable bar scaling  
452    
453  print "<hr>\nColors for statuses and usage (#):\n";  print "<hr>\nColors for statuses and usage (#):\n";
454  print "<table border=0><tr bgcolor=#e0e0e0><th>status</th><th>#</th><th>color</th></tr>\n";  print "<table border=0><tr bgcolor=#e0e0e0><th>status</th><th>#</th><th>color</th></tr>\n";
455    my $max = 0;
456    foreach my $status (keys %count) {
457            $max = $count{$status} if ($count{$status} > $max);
458    }
459    $len_t = $max ; # disable bar scaling
460    
461  foreach my $status (keys %count) {  foreach my $status (keys %count) {
462  #foreach my $status (keys %cols) {  #foreach my $status (keys %cols) {
463          print "<tr bgcolor=#e0e0e0><td><small>$status</small></td><td><small>",$count{$status}*1,"</small></td><td>",bar($count{$status},$status),"</td></tr>\n" if ($status ne "");          print "<tr bgcolor=#e0e0e0><td><small>$status</small></td><td><small>",$count{$status}*1,"</small></td><td>",bar($count{$status},$status),"</td></tr>\n" if ($status ne "");
# Line 441  foreach my $status (keys %count) { Line 467  foreach my $status (keys %count) {
467          # then display number (wrongly).          # then display number (wrongly).
468  }  }
469  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>";  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>";
   

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.28

  ViewVC Help
Powered by ViewVC 1.1.26