diff options
author | Ivan Kohler <ivan@freeside.biz> | 2014-04-13 02:20:15 -0700 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2014-04-13 02:20:15 -0700 |
commit | cebcd8658ba5f45fc21d59769d591b1418a3fdd2 (patch) | |
tree | 9167012572752c89c1654abfba6909dc47178f40 /rt/share | |
parent | afb12da321c052f3628f628e429b59f8ab6453a8 (diff) |
installers (calendaring), RT#16584
Diffstat (limited to 'rt/share')
-rw-r--r-- | rt/share/html/Elements/CalendarDaySchedule | 73 | ||||
-rw-r--r-- | rt/share/html/Elements/CalendarSlotSchedule | 50 | ||||
-rw-r--r-- | rt/share/html/Schedule/UserBar | 21 | ||||
-rw-r--r-- | rt/share/html/Search/Calendar.html | 18 |
4 files changed, 107 insertions, 55 deletions
diff --git a/rt/share/html/Elements/CalendarDaySchedule b/rt/share/html/Elements/CalendarDaySchedule index 0f9f909..f378674 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 3af90ff..fb5b7c1 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> diff --git a/rt/share/html/Schedule/UserBar b/rt/share/html/Schedule/UserBar index 5e834a0..2345fe8 100644 --- a/rt/share/html/Schedule/UserBar +++ b/rt/share/html/Schedule/UserBar @@ -1,6 +1,7 @@ <%perl> use GD; +use RTx::Schedule qw( UserDaySchedule ); my $im = new GD::Image($width, $height) or die; @@ -10,11 +11,21 @@ my $black = $im->colorAllocate(0,0,0); # Put a black frame around the picture $im->rectangle(0,0,$width-1,$height-1,$black); +my %schedule = UserDaySchedule( CurrentUser => $session{CurrentUser}, + username => $Username, + 'date' => $Date, + ); + #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 +#block out / show / color code existing appointments +foreach my $id ( keys %{ $schedule{'scheduled'} } ) { + + my( $starts, $due, $col, $t ) = @{ $schedule{'scheduled'}->{$id} }; + my $color = $im->colorAllocate( unpack 'C*', pack 'H*', $col ); + $im->filledRectangle( int(($starts-$stime)/10), 1, int(($due-$stime)/10)-1, $height-2, $color ); + +} $r->content_type('image/png'); $m->clear_buffer; @@ -33,7 +44,7 @@ $stime = 480 unless $stime =~ /^\d+$/; #8am my $etime = RT->Config->Get('CalendarWeeklyEndMin'); $etime = 1080 unless $etime =~ /^\d+$/; #6pm -my $width = ( $etime - $stime ) / 10; -my $height = 12; +my $width = int( ( $etime - $stime ) / 10 ); +my $height = 12; #Elements/CalendarDaySchedule </%once> diff --git a/rt/share/html/Search/Calendar.html b/rt/share/html/Search/Calendar.html index a6df9fc..d86a5b5 100644 --- a/rt/share/html/Search/Calendar.html +++ b/rt/share/html/Search/Calendar.html @@ -205,7 +205,7 @@ $slots => $default_slots % my($m, $h) = ($Ticket->$meth->Localtime('user'))[1,2]; % my $tod = $h*60 + $m; % -% RTx::Calendar::LocalDate($Ticket->$meth->Unix) eq $date->strftime('%F') #today +% LocalDate($Ticket->$meth->Unix) eq $date->strftime('%F') #today % && $tod >= $row && $tod < ($row+$timestep); #and in timeslot % } keys %DateTypes; % next unless keys %dt; @@ -265,9 +265,10 @@ $slots => $default_slots % if ( defined($Display) && $Display =~ /^(\w+)$/ ) { % % my $el = "/Elements/CalendarDay$1"; - <& $el, Tickets => $Tickets{$date->strftime("%F")}, - Date => $date, - DateTypes => \%DateTypes, + <& $el, CurrentUser => $session{CurrentUser}, + Tickets => $Tickets{$date->strftime("%F")}, + Date => $date, + DateTypes => \%DateTypes, @DisplayArgs, &> % @@ -397,7 +398,8 @@ while ( $wt < $etime ) { push @week_rows, $wt; $wt+=$timestep } </%ONCE> <%INIT> -use RTx::Calendar qw(FirstDay LastDay LastDayOfWeek); +use RTx::Calendar qw( FirstDay LastDay LastDayOfWeek DatesClauses LocalDate + SearchDefaultCalendar FindTickets ); $Embed =~ /^[\w\.]*$/ or die 'xss'; @@ -468,7 +470,7 @@ my $TempQuery = "( Status = 'new' OR Status = 'open' OR Status = 'stalled') AND ( Owner = '" . $session{CurrentUser}->Id ."' OR Owner = 'Nobody' ) AND ( Type = 'reminder' OR 'Type' = 'ticket' )"; -if ( my $Search = RTx::Calendar::SearchDefaultCalendar($session{CurrentUser}) ) { +if ( my $Search = SearchDefaultCalendar($session{CurrentUser}) ) { $TempFormat = $Search->SubValue('Format'); $TempQuery = $Search->SubValue('Query'); } @@ -483,11 +485,11 @@ my @Dates = grep { $TempFormat =~ m/__${_}(Relative)?__/ } @DateTypes; # used to display or not a date in Element/CalendarEvent my %DateTypes = map { $_ => 1 } @Dates; -$TempQuery .= RTx::Calendar::DatesClauses(\@Dates, $start->strftime("%F"), $end->strftime("%F")); +$TempQuery .= DatesClauses(\@Dates, $start->strftime("%F"), $end->strftime("%F")); # print STDERR ("-" x 30), "\n", $TempQuery, "\n"; -my %Tickets = RTx::Calendar::FindTickets($session{'CurrentUser'}, $TempQuery, \@Dates, $start->strftime("%F"), $end->strftime("%F")); +my %Tickets = FindTickets($session{'CurrentUser'}, $TempQuery, \@Dates, $start->strftime("%F"), $end->strftime("%F")); </%INIT> <%def td_week_expand> |