/[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.23 by dpavlin, Mon Sep 23 08:45:36 2002 UTC revision 1.26 by dpavlin, Mon Dec 2 17:14:48 2002 UTC
# Line 36  my $min_l = 3;                 # min length of bar seg Line 36  my $min_l = 3;                 # min length of bar seg
36    
37  #--- no user servicable parts below this line  #--- no user servicable parts below this line
38    
39  # time range  my $q=new CGI;
   
 $int_t = m_round($int_t);  
40    
41  my ($from_t,$to_t) = (time()-$int_t,time());  my ($from_t,$to_t) = (time()-$int_t,time());
42    
 $to_t = param('to_t') if (param('to_t'));  
43  $from_t = param('from_t') if (param('from_t'));  $from_t = param('from_t') if (param('from_t'));
44    $to_t = param('to_t') if (param('to_t'));
45    
46    if (param('f-1')) {
47            $from_t = $from_t - param('int_f-1') || $int_t;
48    } elsif (param('f+1')) {
49            $from_t = $from_t + param('int_f+1') || $int_t;
50    } elsif (param('t-1')) {
51            $to_t = $from_t - param('int_t-1') || $int_t;
52    } elsif (param('t+1')) {
53            $to_t = $from_t + $int_t;
54    }
55    
56    # time range
57    $int_t = m_round($int_t);
58    
59  # round to nearest minute  # round to nearest minute
60  sub m_round {  sub m_round {
# Line 70  if (path_info()) { Line 81  if (path_info()) {
81          $im->transparent($back);          $im->transparent($back);
82          my $col = path_info(); $col =~ s,/,,g;          my $col = path_info(); $col =~ s,/,,g;
83          my ($r,$g,$b) = split(/,/,$col);          my ($r,$g,$b) = split(/,/,$col);
84          my $col = $im->colorAllocate($r,$g,$b);          $col = $im->colorAllocate($r,$g,$b);
85          $im->fill(0,0,$col);          $im->fill(0,0,$col);
86          print "Content-Length: ",length($im->png),"\n\n";          print "Content-Length: ",length($im->png),"\n\n";
87          binmode STDOUT;          binmode STDOUT;
# Line 78  if (path_info()) { Line 89  if (path_info()) {
89          exit;          exit;
90  }  }
91    
92    # open DBI connection
93    my $dbh = DBI->connect("DBI:Pg:dbname=gantt","","") || die $DBI::errstr;
94    
95  print "Content-type: text/html  print "Content-type: text/html
96  Cache-Control: max-age=60, must-revalidate  Cache-Control: max-age=60, must-revalidate
97    
# Line 98  print ' Line 112  print '
112  </script>  </script>
113  ';  ';
114  }  }
115  print "</head><body>";  print "</head><body>
116            <form action=".$q->url(-relative=>1)." method=get>
117            <input type=hidden name=from_t value=$from_t>
118            <input type=hidden name=to_t value=$to_t>
119    ";
120    
121  # all vars ending in *_t have utime in them.  # all vars ending in *_t have utime in them.
122  #  #
123  my $len_t = $to_t - $from_t;  my $len_t = $to_t - $from_t;
124    
125  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;  
126    
127    
128  sub mknav {  sub mknav {
129          my $f = shift @_;       # from_t          my $f = shift @_;       # from_t
130          my $t = shift @_;       # to_t          my $t = shift @_;       # to_t
131            my $d = shift @_;       # delta
132          my $ch = shift @_;      # char          my $ch = shift @_;      # char
133    
134          return "<a href=\"".$q->url(-relative=>1)."?from_t=${f}&to_t=${t}\">$ch</a>";          return "
135            <select name=int_${d}>
136            <option value=".(12*60*60).">12h</option>
137            <option value=".(24*60*60).">day</option>
138            <option value=".(7*24*60*60).">week</option>
139            </select>
140            <input type=submit name=$d value=\"$ch\">
141            ";
142            #return "<a href=\"".$q->url(-relative=>1)."?from_t=${f}&to_t=${t}\">$ch</a>";
143  }  }
144    
145  print "<table cellspacing=0 cellpadding=0>";  print "<table cellspacing=0 cellpadding=0>";
146  print "<tr bgcolor=#e0e0e0><td>Specification</td><td align=left>";  print "<tr bgcolor=#e0e0e0><td>Specification</td><td align=left>";
147  print mknav(($from_t-$int_t),$to_t,'<small>&lt;&lt;</small>'),$from;  print mknav($from_t,$to_t,'f-1','&lt;&lt;'),$from;
148  print mknav(($from_t+$int_t),$to_t,'<small>&gt;&gt;</small>') if ($from_t+$int_t < $to_t);  print mknav($from_t,$to_t,'f+1','&gt;&gt;') if ($from_t+$int_t < $to_t);
149  print "</td><td align=right>";  print "</td><td align=right>";
150  print mknav($from_t,($to_t-$int_t),'<small>&lt;&lt;</small>') if ($to_t-$int_t > $from_t);  print mknav($from_t,$to_t,'t-1','&lt;&lt;') if ($to_t+$int_t > $from_t);
151  print $to,mknav($from_t,($to_t+$int_t),'<small>&gt;&gt;</small>'),"</td></tr>\n";  print $to,mknav($from_t,$to_t,'t+1','&gt;&gt;'),"</td></tr>\n";
152    
153  # draw hour grid  # draw hour grid
154  sub hour_grid {  sub hour_grid {
# Line 229  my $sql = "select start,finish,specifica Line 253  my $sql = "select start,finish,specifica
253          ";          ";
254    
255  my $sth = $dbh->prepare($sql) || die "sql: $sql ".$dbh->errstr;  my $sth = $dbh->prepare($sql) || die "sql: $sql ".$dbh->errstr;
256    print STDERR "sql: $sql\n" if ($debug);
257    
258  my %spec;       # specification hash  my %spec;       # specification hash
259    
260  my $curr_spec;  my $curr_spec = "";
261  my $curr_t = $from_t;  my $curr_t = $from_t;
262    
263  $sth->execute() || die "sql: $sql ".$dbh->errstr;  $sth->execute() || die "sql: $sql ".$dbh->errstr;
# Line 313  while(my $row = $sth->fetchrow_hashref) Line 338  while(my $row = $sth->fetchrow_hashref)
338                  # init vars for next line                  # init vars for next line
339                  ($fix_s,$fix_d) = (0,0); # init fix vars for bar                  ($fix_s,$fix_d) = (0,0); # init fix vars for bar
340    
341                  html_spec if ($curr_spec ne "");                  if ($curr_spec ne "") {
342                            $curr_spec =~ s/ +/&nbsp;/g;
343                            html_spec;
344                    }
345    
346                  $curr_t = $from_t;      # init timeline                  $curr_t = $from_t;      # init timeline
347                  $curr_spec = $row->{specification};                  $curr_spec = $row->{specification};
# Line 406  print "</table>"; Line 434  print "</table>";
434    
435    
436  # label and usage  # label and usage
 $len_t = 50; # disable bar scaling  
437    
438  print "<hr>\nColors for statuses and usage (#):\n";  print "<hr>\nColors for statuses and usage (#):\n";
439  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";
440    my $max = 0;
441    foreach my $status (keys %count) {
442            $max = $count{$status} if ($count{$status} > $max);
443    }
444    $len_t = $max ; # disable bar scaling
445    
446  foreach my $status (keys %count) {  foreach my $status (keys %count) {
447  #foreach my $status (keys %cols) {  #foreach my $status (keys %cols) {
448          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 418  foreach my $status (keys %count) { Line 451  foreach my $status (keys %count) {
451          # it will first evaluate bar sub (thus increasing number by one) and          # it will first evaluate bar sub (thus increasing number by one) and
452          # then display number (wrongly).          # then display number (wrongly).
453  }  }
454  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>";
   

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.26

  ViewVC Help
Powered by ViewVC 1.1.26