X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Fshare%2Fhtml%2FSearch%2FCalendar.html;h=a693bd64594ee2428cd187cc036574fc9300083c;hb=9931b2eeff85811118d0b495dd4e460bc939b744;hp=e711b861cc213e4d7d6e9254bb20fa2f6479fcdf;hpb=ab9be1d2bfedf205eab7a9d399ef22ee14117f53;p=freeside.git diff --git a/rt/share/html/Search/Calendar.html b/rt/share/html/Search/Calendar.html index e711b861c..a693bd645 100644 --- a/rt/share/html/Search/Calendar.html +++ b/rt/share/html/Search/Calendar.html @@ -7,125 +7,308 @@ $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)%> - -Calendar Preferences and Help - -% 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 (1 .. 6, 0) { + +% for ( @{$week{$weekstart}} ) { % } + -% while ($date <= $end) { -% if ( $date->day_of_week == 1) { - -% } - -% $date = $set->next($date); -% if ( $date->day_of_week == 1) { - + +% 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 $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 { + +% while ($date <= $end) { +% +% my $offmonth = !$WeekDay && $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); + + + +% $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 &> +% } +% } + +% } #while ($date <= $end) + % } -
><%$rtdate->GetWeekday($_)%>
<% $date->week_number %> -

<%$date->day%>

-% for my $t ( @{ $Tickets{$date->strftime("%F")} } ) { -<& /Elements/CalendarEvent, Object => $t, Date => $date, DateTypes => \%DateTypes &> -% } -
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 %>
+ +% my $sp = 3; +% for my $t ( @{ $Tickets{$date->strftime("%F")} } ) { +% $sp--; + <& /Elements/CalendarEvent, Object => $t, Date => $date, DateTypes => \%DateTypes &> +% } + <% ($sp>0) ? '
'x$sp : '' |n %> + +
- - - - - -
-«<%$rtdate->GetMonth($PMonth)%> - -<%$rtdate->GetMonth($NMonth)%>» -
+% unless ( $WeekDay ) { + + + -
+ «<%$rtdate->GetMonth($PMonth)%> +
- - + + + +
-
+
+ + + + +% my $year = (localtime)[5] + 1900; + + +%# <& /Elements/Submit&> + + + + + <%$rtdate->GetMonth($NMonth)%>» +
- -% my $year = (localtime)[5] + 1900; - -<& /Elements/Submit&> - +% #XXX an option to turn off "Calendar Preferences and Help" for embedded +% # (and weekly?) use + + + + - + + + +% } -
+
+ Calendar Preferences and Help
- : <&|/l&>Created
- : <&|/l&>Due
- : <&|/l&>Resolved
- : <&|/l&>Last Updated
- : <&|/l&>Created, <&|/l&>Due
- : <&|/l&>Reminders
- : <&|/l&>Starts
- : <&|/l&>Started
- : <&|/l&>Starts, <&|/l&>Due
+% foreach my $legend (keys %legend) { +
+ + +% my $more = 0; +% foreach ( @{$legend{$legend}} ) { + <% $more++ ? ', ' : '' %> + <&|/l&><% $_ %> +% } +
- +<%ONCE> + +my %legend = ( + 'created' => ['Created'], + 'due' => ['Due'], + 'resolved' => ['Resolved'], + 'updated' => ['Last Updated'], + 'created_due' => ['Created','Due'], + 'reminder' => ['Reminders'], + 'started' => ['Started'], + '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; +use RTx::Calendar qw(FirstDay LastDay LastDayOfWeek); my $title = loc("Calendar"); @@ -133,16 +316,42 @@ my @DateTypes = qw/Created Starts Started Due LastUpdated Resolved/; my $rtdate = RT::Date->new($session{'CurrentUser'}); -my $today = DateTime->today; -my $date = RTx::Calendar::FirstMonday($Year, $Month + 1); -my $end = RTx::Calendar::LastSunday($Year, $Month + 1); +my $time_zone = $session{'CurrentUser'}->UserObj->Timezone + || RT->Config->Get('Timezone'); + +my $weekstart = 'Sunday'; #RT::SiteConfig? user pref? +my %week = ( + 'Saturday' => [6,0..5], + 'Sunday' => [0..6], + 'Monday' => [1..6,0], +); +my $startday_of_week = ${$week{$weekstart}}[0] || 7; +my $endday_of_week = ${$week{$weekstart}}[-1] || 7; + +my $today = DateTime->today( time_zone=>$time_zone ); +my $yesterday = $today->clone->subtract( days=>1 ); +my $aweekago = $today->clone->subtract( days=>7 ); + +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, @@ -159,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'); @@ -183,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; + <% pretty_time($min) |n %> +<%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); + +} + +