e94bddfe24b411db27f603f8f6895a0a642f19c0
[freeside.git] / rt / share / html / Elements / CalendarSlotSchedule
1 <%ARGS>
2   @Tickets  => ()
3   $slots    => $default_slots,
4   $sday     => undef,
5   $tod_row  => undef,
6   $timestep => $default_timestep,
7 </%ARGS>
8 <%SHARED>
9 my @slots = ( [], [], [], [], [], [], [] );
10 </%SHARED>
11 % warn $sday;
12 %       #for my $t ( @{ $Tickets{$date->strftime("%F")} } ) {
13 %       for my $t (@Tickets) {
14 %
15 %         #XXX off by 1h on daylight savings boundaries... 2 sundays a year
16 %         my $starts = ($t->StartsObj->Unix - $t->StartsObj->SetToMidnight(Timezone=>'user'))/60;
17 %
18 %         if ( $starts >= $tod_row && $starts < ($tod_row + $timestep) ) {
19 %           #then we're a new entry, find a slot for us
20 %           my $s = 0;
21 %           while ( ref($slots[$sday]->[$s]) ) { $s++ }
22 %           $slots[$sday]->[$s] = [ $t->Id, $t ];
23 %         }
24 %
25 %         #XXX also off by 1h on daylight savings boundaries
26 %         my $due = $t->DueObj->Unix - $t->DueObj->SetToMidnight;
27 %
28 %         if ( $due <= $tod_row && $due > ($tod_row + $timestep ) ) {
29 %           #then find our slot and remove us
30 %           @{ $slots[$sday] } =
31 %             map { (!ref($_) || $_->[0] != $t->Id) ? $_ : '' }
32 %               @{ $slots[$sday] };
33 %         }
34 %
35 %       }
36 %
37 %       pop @{ $slots[$sday] } while @{ $slots[$sday] } && !ref($slots[$sday]->[-1]);
38 %
39 %       #now display:
40 %
41 %       if ( scalar(@{$slots[$sday]}) > $slots ) {
42 %         #overflow situation, eek... could be handled better, how?
43
44           <td colspan=<%$slots%>
45               class="weekly
46 %#                     <%   $is_today     ? 'today'
47 %#                        : $is_yesterday ? 'yesterday'
48 %#                        : $is_aweekago  ? 'aweekago'
49 %#                        : ''
50 %#                     %>
51                          "
52           >MULTIPLE
53           </td>
54
55 %       } else {
56 %
57 %         foreach my $slot ( @{ $slots[$sday] } ) {
58 %           my( $id, $ticket ) = @$slot;
59
60             <td class="weekly
61 %#                       <%   $is_today     ? 'today'
62 %#                          : $is_yesterday ? 'yesterday'
63 %#                          : $is_aweekago  ? 'aweekago'
64 %#                          : ''
65 %#                       %>
66                            "
67             ><% $id %>
68             </td>
69
70 %         }
71 %
72 %         if ( scalar(@{$slots[$sday]}) < $slots ) {
73
74             <td colspan=<% $slots - scalar(@{$slots[$sday]}) %>
75                 class="weekly
76 %#                       <%   $is_today     ? 'today'
77 %#                          : $is_yesterday ? 'yesterday'
78 %#                          : $is_aweekago  ? 'aweekago'
79 %#                          : ''
80 %#                       %>
81                            "
82             >
83             </td>
84 %         }
85 %
86 %       }
87 <%ONCE>
88 my $default_slots = RT->Config->Get('CalendarWeeklySlots') || 5;
89 my $default_timestep = RT->Config->Get('CalendarWeeklySizeMin') || 30; #1/2h
90 </%ONCE>