installers (calendaring), RT#16584
[freeside.git] / rt / share / html / Elements / CalendarDaySchedule
1 <%args>
2 $Date        => undef
3 $today       => undef
4 $Tickets     => undef
5 $DateTypes   => undef
6 @username    => ()
7 $CurrentUser => undef
8 </%args>
9 %if ( DateTime->compare( $Date, $today ) == -1 ) {#flag to show the past anyway?
10 % #the past already happened...
11 %} else {
12 % foreach my $username ( @username ) {
13 %   my $mapname = "$username-$date";
14 %   my $img = "$RT::WebPath/Schedule/UserBar?Username=$username;Date=$date";
15     <span class="calendarright"
16     ><% $username %><img src    = "<%$img|n%>"
17                          useMap = "#<%$mapname%>"
18                          height = <%$height%>
19                          width  = <%$width%>
20     ></span><br>
21
22     <MAP name="<%$mapname%>">
23
24 %   my %schedule = UserDaySchedule( CurrentUser => $CurrentUser,
25 %                                   username    => $username,
26 %                                   'date'      => $date, #$Date->strftime('%F'),
27 %                                 );
28 %
29 %   #block out / show / color code existing appointments
30 %   foreach my $id ( keys %{ $schedule{'scheduled'} } ) {
31 %     my( $starts, $due, $col, $t ) = @{ $schedule{'scheduled'}->{$id} };
32 %     my $s = int(($starts-$stime)/10);
33 %     my $e = int(($due-$stime)/10)-1;
34       <AREA
35          onmouseover = "overlib('<%$id%>: <% FS::sched_avail::pretty_time($starts). '-'. FS::sched_avail::pretty_time($due) %><BR>XX miles away<BR>more info', WRAP, BGCOLOR, '#000000', FGCOLOR, '#<%$col%>')"
36          onmouseout  = "nd(); return true;"
37          shape       = "rect"
38          coords      = "<%$s%>,0,<%$e%>,<%$height%>"
39 %#         href        = "test_href"
40 %#         alt         =
41 %#         title       =
42       >
43 %   }
44 %
45 %   #white out available times
46 %   foreach my $avail ( @{ $schedule{'avail'} } ) {
47 %     my( $start, $end ) = @$avail;
48 %     
49 %     my $s = $start >= $stime ? int(($start-$stime)/10) : 0;
50 %     my $e = int(($end-$stime)/10)-1;
51       <AREA
52          onmouseover = "overlib('Available', WRAP, BGCOLOR, '#000000', FGCOLOR, '#FFFFFF')"
53          onmouseout  = "nd(); return true;"
54          shape       = "rect"
55          coords      = "<%$s%>,0,<%$e%>,<%$height%>"
56 %# XXX link to book - if the appointment we want can fit
57 %#         href        = "test_href"
58 %#         alt         =
59 %#         title       =
60       >
61 %   }
62
63       <AREA 
64          onmouseover = "overlib('Not available', WRAP, BGCOLOR, '#000000', FGCOLOR, '#666666', TEXTCOLOR, '#FFFFFF' )"
65          onmouseout  = "nd(); return true;"
66          shape       = "default"
67 %#         href        = "test_href"
68 %#         alt         =
69 %#         title       =
70       >
71
72     </MAP>
73
74 % }
75 %}
76 <%once>
77
78 my $stime    = RT->Config->Get('CalendarWeeklyStartMin');
79 $stime = 480 unless $stime =~ /^\d+$/; #8am
80 my $etime    = RT->Config->Get('CalendarWeeklyEndMin');
81 $etime = 1080 unless $etime =~ /^\d+$/; #6pm
82
83 my $width = int( ( $etime - $stime ) / 10 );
84 my $height = 12; #Schedule/UserBar
85
86 </%once>
87 <%init>
88
89 use RTx::Schedule qw( UserDaySchedule );
90 use FS::sched_avail; #just for pretty_time
91
92 #my( $date, $time ) = split('T', $Date);
93 my $date = $Date->strftime('%F');
94
95 </%init>