/[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.25 by dpavlin, Mon Dec 2 14:35:17 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 $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 {
# Line 70  if (path_info()) { Line 82  if (path_info()) {
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;
# Line 98  print ' Line 110  print '
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>&lt;&lt;</small>'),$from;  print mknav($from_t,$to_t,'f-1','&lt;&lt;'),$from;
146  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);
147  print "</td><td align=right>";  print "</td><td align=right>";
148  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);
149  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";
150    
151  # draw hour grid  # draw hour grid
152  sub hour_grid {  sub hour_grid {
# Line 232  my $sth = $dbh->prepare($sql) || die "sq Line 254  my $sth = $dbh->prepare($sql) || die "sq
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;
# Line 418  foreach my $status (keys %count) { Line 440  foreach my $status (keys %count) {
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    

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

  ViewVC Help
Powered by ViewVC 1.1.26