summaryrefslogtreecommitdiff
path: root/rt/share/html/Schedule/UserBar
blob: 2345fe8217d82d25faaca56927d42e4f0dcbb213 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<%perl>

use GD;
use RTx::Schedule qw( UserDaySchedule );

my $im = new GD::Image($width, $height) or die;

my $white = $im->colorAllocate(255,255,255);
my $black = $im->colorAllocate(0,0,0); 

# Put a black frame around the picture
$im->rectangle(0,0,$width-1,$height-1,$black);

my %schedule = UserDaySchedule( CurrentUser => $session{CurrentUser},
                                username    => $Username,
                                'date'      => $Date,
                              );

#XXX block out unavailable times

#block out / show / color code existing appointments
foreach my $id ( keys %{ $schedule{'scheduled'} } ) {

  my( $starts, $due, $col, $t ) = @{ $schedule{'scheduled'}->{$id} };
  my $color = $im->colorAllocate( unpack 'C*', pack 'H*', $col );
  $im->filledRectangle( int(($starts-$stime)/10), 1, int(($due-$stime)/10)-1, $height-2, $color );

}

$r->content_type('image/png');
$m->clear_buffer;
$m->out($im->png);
$m->abort;

</%perl>
<%args>
$Username => undef
$Date     => undef
</%args>
<%once>

my $stime    = RT->Config->Get('CalendarWeeklyStartMin');
$stime = 480 unless $stime =~ /^\d+$/; #8am
my $etime    = RT->Config->Get('CalendarWeeklyEndMin');
$etime = 1080 unless $etime =~ /^\d+$/; #6pm

my $width = int( ( $etime - $stime ) / 10 );
my $height = 12; #Elements/CalendarDaySchedule

</%once>