/[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.9 by dpavlin, Fri Sep 13 14:34:02 2002 UTC revision 1.11 by dpavlin, Fri Sep 13 18:35:50 2002 UTC
# Line 5  use DBI; Line 5  use DBI;
5  use Data::Dumper;  use Data::Dumper;
6  use Date::Parse;  use Date::Parse;
7  use CGI qw/:standard/;  use CGI qw/:standard/;
8    use CGI::Carp qw(fatalsToBrowser);
9  use POSIX qw(strftime);  use POSIX qw(strftime);
10    
11  my $debug = 0;  my $debug = 0;
# Line 119  print "</td><td align=right>"; Line 120  print "</td><td align=right>";
120  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-$int_t),'<small>&lt;&lt;</small>') if ($to_t-$int_t > $from_t);
121  print $to,mknav($from_t,($to_t+$int_t),'<small>&gt;&gt;</small>'),"</td></tr>\n";  print $to,mknav($from_t,($to_t+$int_t),'<small>&gt;&gt;</small>'),"</td></tr>\n";
122    
123    # draw hour grid
124    sub hour_grid {
125            print "<tr><td align=right><small>hour grid</small></td><td colspan=2>";
126            my @c = ("255,255,128","255,192,128");
127            my $hr=strftime("%H",localtime ($from_t));
128            print color_bar(3600 - $from_t % 3600,$c[0],sprintf("%02d",$hr++ % 24));
129            for (my $i=1; $i<int(($to_t-$from_t)/3600); $i++) {
130                    print color_bar(3600,$c[1],sprintf("%02d",$hr++ % 24));
131                    push @c, shift @c;
132            }
133            print color_bar($from_t % 3600,$c[1],sprintf("%02d",$hr % 24));
134            print "</td></tr>\n";
135    }
136    
137    hour_grid();
138    
139  my $fix_d = 0;  # used to fix graph len  my $fix_d = 0;  # used to fix graph len
140    
141  sub bar {  sub bar {
142          my $l = shift @_;       # lenght of event utime          my $l = shift @_;
143          my $status = shift @_ || undef; # what to draw          my $status = shift @_;
144            my $alt = shift @_;
145    
146            my $col;
147    
148            if ($status) {
149                    if ($cols{$status}) {
150                            $col .= $cols{$status};
151                    } else {
152                            $col .= "0,0,0";        # unknown status, black
153                    }
154                    $count{$status}++;
155            } else {
156    #               $col .= '240,240,240';
157                    $col .= '220,220,220';
158            }
159            return color_bar($l,$col,$alt);
160    }
161    
162    sub color_bar {
163            my $l = shift @_;                       # lenght of event utime
164            my $col = shift @_ || '240,240,240';    # default color (filler)
165          my $alt = shift @_ || undef;          my $alt = shift @_ || undef;
166    
167          my $size = int($l / ($len_t / $width));          my $size = int($l / ($len_t / $width));
# Line 138  sub bar { Line 176  sub bar {
176                  print STDERR "fix_d: $fix_d\n" if ($debug);                  print STDERR "fix_d: $fix_d\n" if ($debug);
177          }          }
178    
179          print STDERR "bar[$status] 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);
180    
181          my $html = "<img src=\"".$q->url(-relative=>1)."?pic=";          my $html = "<img src=\"".$q->url(-relative=>1)."?pic=$col\" width=\"$size\" height=\"$height\"";
   
         if ($status) {  
                 if ($cols{$status}) {  
                         $html .= $cols{$status};  
                 } else {  
                         $html .= "0,0,0";       # unknown status, black  
                 }  
                 $count{$status}++;  
         } else {  
 #               $html .= '240,240,240';  
                 $html .= '220,220,220';  
         }  
182    
         $html .= "\" width=\"$size\" height=\"$height\"";  
183          if ($use_js && $alt) {          if ($use_js && $alt) {
184                  $html .= " onmouseover=\"T('$alt')\" onmouseout=\"T()\"";                  $html .= " onmouseover=\"T('$alt')\" onmouseout=\"T()\"";
185          } elsif ($alt) {          } elsif ($alt) {
# Line 255  if ($curr_t < $to_t ) { Line 280  if ($curr_t < $to_t ) {
280  undef $sth;  undef $sth;
281  $dbh->disconnect;  $dbh->disconnect;
282    
283  print "</td></tr>\n</table>";  print "</td></tr>\n";
284    hour_grid();
285    print "</table>";
286    
287    
288  # label and usage  # label and usage

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.11

  ViewVC Help
Powered by ViewVC 1.1.26