X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=rt%2Fshare%2Fhtml%2FSearch%2FCalendar.html;h=db781d81bb2cce99b00a9b6f2ad1044bbe58e637;hb=b7e8cfa78c29c9cc561cafa07dbcd82ff58acb50;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..db781d81b 100644 --- a/rt/share/html/Search/Calendar.html +++ b/rt/share/html/Search/Calendar.html @@ -7,125 +7,197 @@ $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 &> + <&| /Widgets/TitleBox, title => loc('Calendar for ') . $rtdate->GetMonth($Month) . " $Year" , 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}} ) { % } + +% if ( $WeekDay ) { + <& td_week_collapse, date=>$date, Month=>$OrigMonth, Year=>$OrigYear, QueryString=>$QueryString &> +% } else { + <& td_week_expand, date=>$date, Month=>$Month, Year=>$Year, QueryString=>$QueryString &> +% } % while ($date <= $end) { -% if ( $date->day_of_week == 1) { - +% +% 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); + + + +% $date = $set->next($date); +% if ( $date->day_of_week == $startday_of_week ) { + +% if ( $date <= $end ) { + +% if ( $WeekDay ) { + <& td_week_collapse, date=>$date, Month=>$OrigMonth, Year=>$OrigYear, QueryString=>$QueryString &> +% } else { + <& td_week_expand, date=>$date, Month=>$Month, Year=>$Year, QueryString=>$QueryString &> +% } +% } % } - -% $date = $set->next($date); -% if ( $date->day_of_week == 1) { - -% } + % } -
<%$rtdate->GetWeekday($_)%>
<% $date->week_number %> +
<% ( $WeekDay ? $rtdate->GetMonth($date->month). ' ' : '' ). + $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 %> + +
-

<%$date->day%>

-% for my $t ( @{ $Tickets{$date->strftime("%F")} } ) { -<& /Elements/CalendarEvent, Object => $t, Date => $date, DateTypes => \%DateTypes &> -% } -
- - - - - -
-«<%$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'], +); + + <%INIT> -use RTx::Calendar; +use RTx::Calendar qw(FirstDay LastDay LastDayOfWeek); my $title = loc("Calendar"); @@ -133,16 +205,34 @@ my @DateTypes = qw/Created Starts Started Due LastUpdated Resolved/; my $rtdate = RT::Date->new($session{'CurrentUser'}); +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; -my $date = RTx::Calendar::FirstMonday($Year, $Month + 1); -my $end = RTx::Calendar::LastSunday($Year, $Month + 1); +my $yesterday = $today->clone->subtract( days=>1 ); +my $aweekago = $today->clone->subtract( days=>7 ); + +my( $date, $end); +if ( $WeekDay ) { + $date = DateTime->new( year=>$WeekYear, month=>$WeekMonth, day=>$WeekDay ); + $end = LastDayOfWeek( $WeekYear, $WeekMonth, $WeekDay, $endday_of_week ); +} else { + $date = FirstDay($Year, $Month + 1, $startday_of_week ); + $end = LastDay ($Year, $Month + 1, $endday_of_week ); +} # 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 +249,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 +273,26 @@ $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 td_week_collapse> +<%args> + $date => undef + $Month => undef + $Year => undef + $QueryString => undef + + + + +