2 title => loc("Calendar"),
3 title_href => "Search/Calendar.html" &>
5 <table class="rtxcalendar">
8 % my $date = $begin->clone;
9 % while ( $date <= $end ) {
10 <th width="14%"><%$rtdate->GetWeekday($date->day_of_week % 7)%></th>
11 % $date = $set->next($date);
17 % $date = $begin->clone;
18 % while ($date <= $end) {
20 <p class="date"><%$date->day%></p>
21 % for my $t (@{ $Tickets{$date->strftime("%F")} }) {
22 <& /Elements/CalendarEvent, Object => $t, Date => $date, DateTypes => \%DateTypes &>
25 % $date = $set->next($date);
37 my $title = loc("Calendar");
39 my $rtdate = RT::Date->new($session{'CurrentUser'});
41 my @DateTypes = qw/Created Starts Started Due LastUpdated Resolved/;
43 my $today = DateTime->today;
45 # this line is used to debug MyCalendar
46 # $today = DateTime->new(year => 2007, month => 4, day => 11);
48 my $begin = $today->clone->subtract( days => 3);
49 my $end = $today->clone->add( days => 3);
51 # use this to loop over days until $end
52 my $set = DateTime::Set->from_recurrence(
53 next => sub { $_[0]->truncate( to => 'day' )->add( days => 1 ) }
56 my $Query = "( Status = 'new' OR Status = 'open' OR Status = 'stalled')
57 AND ( Owner = '" . $session{CurrentUser}->Id ."' OR Owner = 'Nobody' )
58 AND ( Type = 'reminder' OR 'Type' = 'ticket' )";
59 my $Format = "__Starts__ __Due__";
61 if ( my $Search = RTx::Calendar::SearchDefaultCalendar($session{CurrentUser}) ) {
62 $Format = $Search->SubValue('Format');
63 $Query = $Search->SubValue('Query');
66 # we search all date types in Format string
67 my @Dates = grep { $Format =~ m/__${_}(Relative)?__/ } @DateTypes;
69 # used to display or not a date in Element/CalendarEvent
70 my %DateTypes = map { $_ => 1 } @Dates;
72 $Query .= RTx::Calendar::DatesClauses(\@Dates, $begin->strftime("%F"), $end->strftime("%F"));
74 # print STDERR $Query, "\n";
76 my %Tickets = RTx::Calendar::FindTickets($session{'CurrentUser'}, $Query, \@Dates);