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