<%args> $Month => (localtime)[4] $Year => (localtime)[5] + 1900 $Query => undef $Format => undef $Order => undef $OrderBy => undef $RowsPerPage => undef <& /Elements/Header, Title => $title &> <& /Ticket/Elements/Tabs, current_tab => "Search/Calendar.html$QueryString", Title => $title &> <&| /Widgets/TitleBox, title => loc('Calendar for ') . $rtdate->GetMonth($Month) . " $Year" , title_class=> 'inverse', color => "#993333" &> % my @options; % push @options, "Query=$Query" % if $Query; % my $options = "&" . join("&", @options) if @options;
% my ($PMonth, $PYear) = ($Month - 1, $Year); % if ($PMonth < 0) { % $PYear--; % $PMonth = 11; % } «<%$rtdate->GetMonth($PMonth)%> Calendar Preferences % my ($NMonth, $NYear) = ($Month + 1, $Year); % if ($NMonth > 11) { % $NYear++; % $NMonth = 0; % } <%$rtdate->GetMonth($NMonth)%>»
% for (1 .. 6, 0) { % } % while ($date <= $end) { % if ( $date->day_of_week == 1) { % } % $date = $set->next($date); % if ( $date->day_of_week == 1) { % } % }
<%$rtdate->GetWeekday($_)%>
<% $date->week_number %>

<%$date->day%>

% for my $t (@{ $Tickets{$date->strftime("%F")} }) { <& /Elements/CalendarEvent, Object => $t, Date => $date &> % }
«<%$rtdate->GetMonth($PMonth)%> <%$rtdate->GetMonth($NMonth)%>»
% my $year = (localtime)[5] + 1900; <& /Elements/Submit&>
% # : <&|/l&>Created
: <&|/l&>Due
% # : <&|/l&>Created, <&|/l&>Due
: <&|/l&>Reminders
<%INIT> use RTx::Calendar; my $title = loc("Calendar"); 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); # 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; $QueryString = '?' . $m->comp( '/Elements/QueryString', Query => $Query, Format => $Format, Order => $Order, OrderBy => $OrderBy, Rows => $RowsPerPage ) if ($Query); my $Tickets = RT::Tickets->new($session{'CurrentUser'}); if ($Query) { $Tickets->FromSQL($Query) # How can I add limit date to FromSQL ? # $Tickets->LimitDue(OPERATOR => ">=", VALUE => $date->strftime("%F") ); # $Tickets->LimitDue(OPERATOR => "<=", VALUE => $end->strftime("%F") ); } else { $Tickets->LimitStatus( VALUE => 'open' ); $Tickets->LimitStatus ( VALUE => 'new'); $Tickets->LimitStatus ( VALUE => 'stalled'); $Tickets->LimitOwner(VALUE => $session{CurrentUser}->Id); $Tickets->LimitOwner(VALUE => "Nobody"); $Tickets->LimitType(VALUE => 'reminder'); $Tickets->LimitType(VALUE => 'ticket'); # Is it a good idea ? Should be way faster $Tickets->LimitDue(OPERATOR => ">=", VALUE => $date->strftime("%F") ); } my %Tickets; while ( my $Ticket = $Tickets->Next()) { # if reminder, check it's refering to a ticket push @{ $Tickets{ RTx::Calendar::LocalDate($Ticket->DueObj->Unix) } }, $Ticket unless $Ticket->Type eq 'reminder' and not $Ticket->RefersTo->First; }