summaryrefslogtreecommitdiff
path: root/rt/share/html/Elements
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2014-04-13 02:20:15 -0700
committerIvan Kohler <ivan@freeside.biz>2014-04-13 02:20:15 -0700
commitcebcd8658ba5f45fc21d59769d591b1418a3fdd2 (patch)
tree9167012572752c89c1654abfba6909dc47178f40 /rt/share/html/Elements
parentafb12da321c052f3628f628e429b59f8ab6453a8 (diff)
installers (calendaring), RT#16584
Diffstat (limited to 'rt/share/html/Elements')
-rw-r--r--rt/share/html/Elements/CalendarDaySchedule73
-rw-r--r--rt/share/html/Elements/CalendarSlotSchedule50
2 files changed, 81 insertions, 42 deletions
diff --git a/rt/share/html/Elements/CalendarDaySchedule b/rt/share/html/Elements/CalendarDaySchedule
index 0f9f9092e..f378674ff 100644
--- a/rt/share/html/Elements/CalendarDaySchedule
+++ b/rt/share/html/Elements/CalendarDaySchedule
@@ -1,32 +1,63 @@
<%args>
-$Date => undef
-$Tickets => undef
-$DateTypes => undef
-@username => ()
+$Date => undef
+$Tickets => undef
+$DateTypes => undef
+@username => ()
+$CurrentUser => undef
</%args>
% foreach my $username ( @username ) {
% my $mapname = "$username-$date";
-<span class="calendarright"><% $username %><img src="<%$RT::WebPath%>/Schedule/UserBar?Username=<%$username%>;Date=<%$date%>" useMap="#<%$mapname%>"><span><br>
-<MAP name="<%$mapname%>">
-%# false laziness w/Schedule/UserBar
-%#XXX block out unavailable times
-%#alas. abstractions break, freeside-specific stuff to get availability
-%# move availability to RT side? make it all callback/pluggable?
-%
-%#XXX block out / show / color code existing appointments
+% my $img = "$RT::WebPath/Schedule/UserBar?Username=$username;Date=$date";
+ <span class="calendarright"
+ ><% $username %><img src = "<%$img|n%>"
+ useMap = "#<%$mapname%>"
+ height = <%$height%>
+ width = <%$width%>
+ ></span><br>
+
+ <MAP name="<%$mapname%>">
+
+% my %schedule = UserDaySchedule( CurrentUser => $CurrentUser,
+% username => $username,
+% 'date' => $Date->strftime('%F'),
+% );
+
+% #XXX block out unavailable times
%
-<AREA onmouseover="overlib('XX miles away<BR>more info')"
- onmouseout="nd(); return true;"
- shape = "rect"
- coords="0,0,59,11"
- href="test_href"
-%# alt=
-%# title=
->
-</MAP>
+% #block out / show / color code existing appointments
+% foreach my $id ( keys %{ $schedule{'scheduled'} } ) {
+% my( $starts, $due, $col, $t ) = @{ $schedule{'scheduled'}->{$id} };
+% my $s = int(($starts-$stime)/10);
+% my $e = int(($due-$stime)/10)-1;
+ <AREA
+ onmouseover = "overlib('<%$id%>: XX miles away<BR>more info', BGCOLOR, '#000000', FGCOLOR, '#<%$col%>')"
+ onmouseout = "nd(); return true;"
+ shape = "rect"
+ coords = "<%$s%>,0,<%$e%>,<%$height-1%>"
+%# href = "test_href"
+%# alt =
+%# title =
+ >
+% }
+
+ </MAP>
+
% }
+<%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; #Schedule/UserBar
+
+</%once>
<%init>
+use RTx::Schedule qw( UserDaySchedule );
+
my( $date, $time ) = split('T', $Date);
</%init>
diff --git a/rt/share/html/Elements/CalendarSlotSchedule b/rt/share/html/Elements/CalendarSlotSchedule
index 3af90ff3e..fb5b7c1ab 100644
--- a/rt/share/html/Elements/CalendarSlotSchedule
+++ b/rt/share/html/Elements/CalendarSlotSchedule
@@ -8,39 +8,47 @@
@username => ()
</%ARGS>
% foreach my $username ( @username ) {
-
- <td class="weekly
-%# <% $is_today ? 'today'
-%# : $is_yesterday ? 'yesterday'
-%# : $is_aweekago ? 'aweekago'
-%# : ''
-%# %>
- "
- >
-% for my $t (@Tickets) {
-% next unless $t->OwnerObj->Name eq $username;
%
-% next unless RTx::Calendar::LocalDate($t->StartsObj->Unix)
-% eq $Date->strftime('%F'); #today
+% my %schedule = UserDaySchedule( username => $username,
+% 'date' => $Date->strftime('%F'),
+% Tickets => \@Tickets,
+% );
+%
+% my $bgcolor = 'ffffff';
+% my $content = '';
+%
+% #XXX block out unavailable times
%
-% my($sm, $sh) = ($t->StartsObj->Localtime('user'))[1,2];
-% my $starts = $sh*60 + $sm;
+% #block out / show / color code existing appointments
+% foreach my $id ( keys %{ $schedule{'scheduled'} } ) {
%
-% my($dm, $dh) = ($t->DueObj->Localtime('user'))[1,2];
-% my $due = $dh*60 + $dm;
+% my( $starts, $due, $col, $t ) = @{ $schedule{'scheduled'}->{$id} };
%
% next if $starts >= ($tod_row+$timestep) || $due < $tod_row;
%
-% warn $starts. ' = '. ($tod_row+$timestep);
% if ( $starts >= $tod_row ) {
- <% $t->Id %>
+% $bgcolor = $col;
+% $content .= ($content?', ':''). $id; #XXX more
% } else {
- cont<% $t->Id %>...
+% $bgcolor = $col;
% }
% }
- </td>
+
+ <td style="background:#<%$bgcolor%>" class="weekly
+%# <% $is_today ? 'today'
+%# : $is_yesterday ? 'yesterday'
+%# : $is_aweekago ? 'aweekago'
+%# : ''
+%# %>
+ "
+ ><% $content %></td>
% }
<%ONCE>
my $default_slots = RT->Config->Get('CalendarWeeklySlots') || 5;
my $default_timestep = RT->Config->Get('CalendarWeeklySizeMin') || 30; #1/2h
</%ONCE>
+<%INIT>
+
+use RTx::Schedule qw( UserDaySchedule );
+
+</%INIT>