5b400406295fe0a4200a6e7696fa708d77cb4115
[freeside.git] / rt / share / html / Elements / CalendarSlotSchedule
1 <%ARGS>
2   $Date      => undef
3   @Tickets   => ()
4   $slots     => $default_slots
5   $sday      => undef
6   $tod_row   => undef
7   $timestep  => $default_timestep
8   @username  => ()
9   $LengthMin => $default_timestep
10 </%ARGS>
11 % foreach my $username ( @username ) {
12 %
13 %   my %schedule = UserDaySchedule( username => $username,
14 %                                   'date'   => $Date->strftime('%F'),
15 %                                   Tickets  => \@Tickets,
16 %                                 );
17 %
18 %   my $bgcolor = '666666;border-color:#555555';
19 %   my $content = '';
20 %   my $onmouse = 0;
21 %
22 %   #white out available times
23 %   foreach my $avail ( @{ $schedule{'avail'} } ) {
24 %     my( $start, $end ) = @$avail;
25 %     next if $start >= ($tod_row+$timestep) || $end <= $tod_row;
26 %     $bgcolor = 'FFFFFF';
27 %     $onmouse = 1
28 %       if $LengthMin <= $end - $tod_row  #the slot is long enough
29 %       && ! grep { $_ > $tod_row && $LengthMin > $_ - $tod_row }
30 %              map $_->[0], values %{ $schedule{'scheduled'} };
31 %   }
32 %
33 %   #block out / show / color code existing appointments
34 %   foreach my $id ( keys %{ $schedule{'scheduled'} } ) {
35 %
36 %     my( $starts, $due, $col, $t ) = @{ $schedule{'scheduled'}->{$id} };
37 %
38 %     next if $starts >= ($tod_row+$timestep) || $due < $tod_row;
39 %
40 %     $bgcolor = $col;
41 %     $onmouse = 0;
42 %
43 %     if ( $starts >= $tod_row ) { #first row
44 %       $content .= ($content?', ':''). $id; #XXX more
45 %     }
46 %   }
47
48     <td style="background:#<%$bgcolor%>" class="weekly"
49 %#               <%   $is_today     ? 'today'
50 %#                  : $is_yesterday ? 'yesterday'
51 %#                  : $is_aweekago  ? 'aweekago'
52 %#                  : ''
53 %#               %>"
54 %     if ( $onmouse ) {
55         onmouseover="boxon(this);"
56         onmouseout ="boxoff(this);"
57 %     }
58     ><% $content %></td>
59 % }
60 <%ONCE>
61 my $default_slots = RT->Config->Get('CalendarWeeklySlots') || 5;
62 my $default_timestep = RT->Config->Get('CalendarWeeklySizeMin') || 30; #1/2h
63 </%ONCE>
64 <%INIT>
65
66 use RTx::Schedule qw( UserDaySchedule );
67
68 </%INIT>