X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Fshare%2Fhtml%2FSearch%2FCalendar.html;h=a693bd64594ee2428cd187cc036574fc9300083c;hb=9931b2eeff85811118d0b495dd4e460bc939b744;hp=9d2b6f5466b114503b16fc654d464d78571d6896;hpb=fb4ab1073f0d15d660c6cdc4e07afebf68ef3924;p=freeside.git diff --git a/rt/share/html/Search/Calendar.html b/rt/share/html/Search/Calendar.html index 9d2b6f546..a693bd645 100644 --- a/rt/share/html/Search/Calendar.html +++ b/rt/share/html/Search/Calendar.html @@ -7,45 +7,72 @@ $Order => undef $OrderBy => undef $RowsPerPage => undef $NewQuery => 0 +$WeekDay => undef +$WeekMonth => undef +$WeekYear => undef +$OrigMonth => undef +$OrigYear => undef <& /Elements/Header, Title => $title &> -<& /Ticket/Elements/Tabs, - current_tab => "Search/Calendar.html?$QueryString", - Title => $title &> +<& /Elements/Tabs &> + +% my $title; +% if ( $WeekMonth ) { +% if ( $date->month == $end->month ) { +% $title = $rtdate->GetMonth( $date->month -1 ). ' '. +% $date->day. '-'. $end->day. ', '. $date->year; +% } elsif ( $date->year == $end->year ) { +% $title = +% $rtdate->GetMonth( $date->month -1 ). ' '. $date->day. ' - '. +% $rtdate->GetMonth( $end->month -1 ). ' '. $end->day. ', '. $end->year; +% } else { +% $title = +% $rtdate->GetMonth( $date->month -1 ). ' '.$date->day. ', '. $date->year. +% ' - '. +% $rtdate->GetMonth( $end->month -1 ). ' '.$end->day. ', '. $end->year; +% } +% } else { +% $title = $rtdate->GetMonth($Month) . " $Year" +% } <&| /Widgets/TitleBox, - title => loc('Calendar for ') . $rtdate->GetMonth($Month) . " $Year" , + title => loc('Calendar for '). $title, title_class=> 'inverse', color => "#993333" &> - - - + +
-% my ($PMonth, $PYear) = ($Month - 1, $Year); +% my($PMonth, $PYear, $NMonth, $NYear); +% unless ( $WeekDay ) { + + + + - - + + - -
+% ($PMonth, $PYear) = ($Month - 1, $Year); % if ($PMonth < 0) { % $PYear--; % $PMonth = 11; % } -«<%$rtdate->GetMonth($PMonth)%> - - <% $rtdate->GetMonth($Month). " $Year" %> - -% my ($NMonth, $NYear) = ($Month + 1, $Year); + «<%$rtdate->GetMonth($PMonth)%> + + <% $rtdate->GetMonth($Month). " $Year" %> + +% ($NMonth, $NYear) = ($Month + 1, $Year); % if ($NMonth > 11) { % $NYear++; % $NMonth = 0; % } -<%$rtdate->GetMonth($NMonth)%>» -
+ <%$rtdate->GetMonth($NMonth)%>» +
+% } + % for ( @{$week{$weekstart}} ) { % } @@ -54,77 +81,181 @@ $NewQuery => 0 -% while ($date <= $end) { + +% if ( $WeekDay ) { + + +% } else { + <& td_week_expand, date=>$date, Month=>$Month, Year=>$Year, QueryString=>$QueryString &> +% } + +% if ( $WeekDay ) { + + + +% $date = $start; +% while ($date <= $end) { +% +% my $is_today = (DateTime->compare($today, $date) == 0); +% my $is_yesterday = (DateTime->compare($yesterday, $date) == 0); +% my $is_aweekago = (DateTime->compare($aweekago, $date) == 0); + + + +% $date = $set->next($date); +% if ( $date->day_of_week == $startday_of_week ) { + +% if ( $date <= $end ) { #a second week? not going to work for week view yet + + +% } +% } + +% } #while ($date <= $end) + +% foreach my $row ( @week_rows ) { + + <& td_time, $row &> + +% $date = $start; +% while ($date <= $end) { % -% my $offmonth = $date->month != ($Month + 1); -% my $is_today = (DateTime->compare($today, $date) == 0); -% my $is_yesterday = (DateTime->compare($yesterday, $date) == 0); -% my $is_aweekago = (DateTime->compare($aweekago, $date) == 0); +% my $is_today = (DateTime->compare($today, $date) == 0); +% my $is_yesterday = (DateTime->compare($yesterday, $date) == 0); +% my $is_aweekago = (DateTime->compare($aweekago, $date) == 0); + + + +% $date = $set->next($date); +% if ( $date->day_of_week == $startday_of_week ) { + +% if ( $date <= $end ) { #a second week? not going to work for week view yet + + +% } +% } + +% } #while ($date <= $end) +% } #foreach my $row ( @week_rows ) + +% } else { - - +% $date = $set->next($date); +% if ( $date->day_of_week == $startday_of_week ) { + +% if ( $date <= $end ) { + + <& td_week_expand, date=>$date, Month=>$Month, Year=>$Year, QueryString=>$QueryString &> +% } +% } -% $date = $set->next($date); -% if ( $date->day_of_week == $startday_of_week ) { - -% } +% } #while ($date <= $end) % } -
><%$rtdate->GetWeekday($_)%>
valign="middle"> + <& week_collapse, date=>$date, Month=>$OrigMonth, Year=>$OrigYear, QueryString=>$QueryString &> + +
<% $rtdate->GetMonth($date->month-1). ' '. $date->day %>
+ +
valign="middle"> + <& week_collapse, date=>$date, Month=>$OrigMonth, Year=>$OrigYear, QueryString=>$QueryString &> + + +% #XXX display these in a time aware fashion +%#% my $sp = 3; +%#% for my $t ( @{ $Tickets{$date->strftime("%F")} } ) { +%#% $sp--; +%# <& /Elements/CalendarEvent, Object => $t, Date => $date, DateTypes => \%DateTypes &> +%#% } +%# <% ($sp>0) ? '
'x$sp : '' |n %> + +
valign="middle"> + <& week_collapse, date=>$date, Month=>$OrigMonth, Year=>$OrigYear, QueryString=>$QueryString &> + " - > -
+
<%$date->day%>
+ : '' + %>calendardate" + ><% $date->day %>
+ +% my $sp = 3; +% for my $t ( @{ $Tickets{$date->strftime("%F")} } ) { +% $sp--; + <& /Elements/CalendarEvent, Object => $t, Date => $date, DateTypes => \%DateTypes &> +% } + <% ($sp>0) ? '
'x$sp : '' |n %> -% my $sp = 3; -% for my $t ( @{ $Tickets{$date->strftime("%F")} } ) { -% $sp--; - <& /Elements/CalendarEvent, Object => $t, Date => $date, DateTypes => \%DateTypes &> -% } - <% ($sp>0) ? '
'x$sp : '' |n %> +
- - - +% unless ( $WeekDay ) { - + +
-«<%$rtdate->GetMonth($PMonth)%> - -
+ + + - -% my $year = (localtime)[5] + 1900; - + + + - - -
+ «<%$rtdate->GetMonth($PMonth)%> + + + + + +% my $year = (localtime)[5] + 1900; + %# <& /Elements/Submit&> - + - - -<%$rtdate->GetMonth($NMonth)%>» -
+
+ <%$rtdate->GetMonth($NMonth)%>» +
+ +% } +% #XXX an option to turn off "Calendar Preferences and Help" for embedded +% # (and weekly?) use @@ -165,9 +296,19 @@ my %legend = ( 'starts_due' => ['Starts','Due'], ); +my $stime = 480; #8am +my $etime = 1080; #6pm +my $timestep = 30; #1/2h +#my $timestep = 120; #2h +my $rowspan = ($etime-$stime) / $timestep; + +my $wt = $stime; +my @week_rows = (); +while ( $wt < $etime ) { push @week_rows, $wt; $wt+=$timestep } + <%INIT> -use RTx::Calendar qw(FirstDay LastDay); +use RTx::Calendar qw(FirstDay LastDay LastDayOfWeek); my $title = loc("Calendar"); @@ -175,6 +316,9 @@ my @DateTypes = qw/Created Starts Started Due LastUpdated Resolved/; my $rtdate = RT::Date->new($session{'CurrentUser'}); +my $time_zone = $session{'CurrentUser'}->UserObj->Timezone + || RT->Config->Get('Timezone'); + my $weekstart = 'Sunday'; #RT::SiteConfig? user pref? my %week = ( 'Saturday' => [6,0..5], @@ -184,18 +328,30 @@ my %week = ( my $startday_of_week = ${$week{$weekstart}}[0] || 7; my $endday_of_week = ${$week{$weekstart}}[-1] || 7; -my $today = DateTime->today; +my $today = DateTime->today( time_zone=>$time_zone ); my $yesterday = $today->clone->subtract( days=>1 ); my $aweekago = $today->clone->subtract( days=>7 ); -my $date = FirstDay($Year, $Month + 1, $startday_of_week ); -my $end = LastDay ($Year, $Month + 1, $endday_of_week ); + +my( $start, $end ); +if ( $WeekDay ) { + $start = DateTime->new( year => $WeekYear, + month => $WeekMonth+1, + day => $WeekDay, + time_zone => $time_zone, + ); + $end = LastDayOfWeek( $WeekYear, $WeekMonth+1, $WeekDay, $endday_of_week ); +} else { + $start = FirstDay($Year, $Month + 1, $startday_of_week ); + $end = LastDay ($Year, $Month + 1, $endday_of_week ); +} +my $date = $start; # use this to loop over days until $end my $set = DateTime::Set->from_recurrence( next => sub { $_[0]->truncate( to => 'day' )->add( days => 1 ) } ); -my $QueryString = +my $QueryString = $m->comp( '/Elements/QueryString', Query => $Query, @@ -212,7 +368,7 @@ $QueryString ||= 'NewQuery=1'; my $TempFormat = "__Starts__ __Due__"; my $TempQuery = "( Status = 'new' OR Status = 'open' OR Status = 'stalled') AND ( Owner = '" . $session{CurrentUser}->Id ."' OR Owner = 'Nobody' ) - AND ( Type = 'reminder' OR 'Type' = 'ticket' )"; + AND ( Type = 'reminder' OR 'Type' = 'ticket' )"; if ( my $Search = RTx::Calendar::SearchDefaultCalendar($session{CurrentUser}) ) { $TempFormat = $Search->SubValue('Format'); @@ -236,3 +392,48 @@ $TempQuery .= RTx::Calendar::DatesClauses(\@Dates, $date->strftime("%F"), $end-> my %Tickets = RTx::Calendar::FindTickets($session{'CurrentUser'}, $TempQuery, \@Dates, $date->strftime("%F"), $end->strftime("%F")); +<%def td_week_expand> +<%args> + $date => undef + $Month => undef + $Year => undef + $QueryString => undef + + + + +<%def week_collapse> +<%args> + $date => undef + $Month => undef + $Year => undef + $QueryString => undef + + + + +<%def td_time> +% my( $min ) = shift; + +<%init> +sub pretty_time { + my $t = shift; + + return 'Midnight' if $t == 0 || $t == 1440; + return 'Noon' if $t == 720; + + my $h = int( $t / 60 ); + my $m = $t % 60; + + my $ap = 'AM'; + if ( $h == 0 || $h == 24 ) { $h = 12; } + elsif ( $h == 12 ) { $ap = 'PM'; } + elsif ( $h > 12 ) { $ap = 'PM'; $h -= 12; } + + sprintf('%02d:%02d '.$ap, $h, $m); + +} + +
+ + <% pretty_time($min) |n %>