2 $Month => (localtime)[4]
3 $Year => (localtime)[5] + 1900
12 <& /Elements/Header, Title => $title &>
13 <& /Ticket/Elements/Tabs,
14 current_tab => "Search/Calendar.html?$QueryString",
16 <&| /Widgets/TitleBox,
17 title => loc('Calendar for ') . $rtdate->GetMonth($Month) . " $Year" ,
18 title_class=> 'inverse',
24 % my ($PMonth, $PYear) = ($Month - 1, $Year);
29 <a href="<%$RT::WebPath%>/Search/Calendar.html?Month=<%$PMonth%>&Year=<%$PYear%>&<%$QueryString%>">«<%$rtdate->GetMonth($PMonth)%></a>
32 <font size="+1"><% $rtdate->GetMonth($Month). " $Year" %></font>
35 % my ($NMonth, $NYear) = ($Month + 1, $Year);
40 <a href="<%$RT::WebPath%>/Search/Calendar.html?Month=<%$NMonth%>&Year=<%$NYear%>&<%$QueryString%>"><%$rtdate->GetMonth($NMonth)%>»</a>
45 <table class="rtxcalendar">
49 % for ( @{$week{$weekstart}} ) {
50 <th width="14%"><%$rtdate->GetWeekday($_)%></th>
57 % while ($date <= $end) {
59 % my $offmonth = $date->month != ($Month + 1);
60 % my $is_today = (DateTime->compare($today, $date) == 0);
61 % my $is_yesterday = (DateTime->compare($yesterday, $date) == 0);
62 % my $is_aweekago = (DateTime->compare($aweekago, $date) == 0);
64 <td class="<% $offmonth ? 'offmonth'
66 : $is_yesterday ? 'yesterday'
67 : $is_aweekago ? 'aweekago'
71 <div class="<% $is_today ? 'todays'
72 : $offmonth ? 'offmonth'
77 % for my $t ( @{ $Tickets{$date->strftime("%F")} } ) {
79 <& /Elements/CalendarEvent, Object => $t, Date => $date, DateTypes => \%DateTypes &>
81 <% ($sp>0) ? '<BR>'x$sp : '' |n %>
85 % $date = $set->next($date);
86 % if ( $date->day_of_week == $startday_of_week ) {
98 <a href="<%$RT::WebPath%>/Search/Calendar.html?Month=<%$PMonth%>&Year=<%$PYear%>&<%$QueryString%>">«<%$rtdate->GetMonth($PMonth)%></a>
101 <td valign="top" align="center">
102 <form action="<%$RT::WebPath%>/Search/Calendar.html?<%$QueryString%>" method="post">
104 <select name="Month">
106 <option value="<%$_%>" <% $_ == $Month ? 'selected' : ''%> ><%$rtdate->GetMonth($_)%></option>
109 % my $year = (localtime)[5] + 1900;
111 % for ( ($year-5) .. ($year+5)) {
112 <option value="<%$_%>" <% $_ == $Year ? 'selected' : ''%>><%$_%></option>
116 %# <& /Elements/Submit&>
117 <input type="submit" value="<% loc('Submit') %>" class="button" />
123 <a href="<%$RT::WebPath%>/Search/Calendar.html?Month=<%$NMonth%>&Year=<%$NYear%>&<%$QueryString%>"><%$rtdate->GetMonth($NMonth)%>»</a>
131 <td valign="top" rowspan=9>
133 <a href="<%$RT::WebPath%>/Prefs/Calendar.html">Calendar Preferences and Help</a>
136 % foreach my $legend (keys %legend) {
139 <img src="<%$RT::WebImagesURL%>/<%$legend%>.png" />
143 % foreach ( @{$legend{$legend}} ) {
144 <% $more++ ? ', ' : '' %>
158 'created' => ['Created'],
160 'resolved' => ['Resolved'],
161 'updated' => ['Last Updated'],
162 'created_due' => ['Created','Due'],
163 'reminder' => ['Reminders'],
164 'started' => ['Started'],
165 'starts_due' => ['Starts','Due'],
170 use RTx::Calendar qw(FirstDay LastDay);
172 my $title = loc("Calendar");
174 my @DateTypes = qw/Created Starts Started Due LastUpdated Resolved/;
176 my $rtdate = RT::Date->new($session{'CurrentUser'});
178 my $weekstart = 'Sunday'; #RT::SiteConfig? user pref?
180 'Saturday' => [6,0..5],
182 'Monday' => [1..6,0],
184 my $startday_of_week = ${$week{$weekstart}}[0] || 7;
185 my $endday_of_week = ${$week{$weekstart}}[-1] || 7;
187 my $today = DateTime->today;
188 my $yesterday = $today->clone->subtract( days=>1 );
189 my $aweekago = $today->clone->subtract( days=>7 );
190 my $date = FirstDay($Year, $Month + 1, $startday_of_week );
191 my $end = LastDay ($Year, $Month + 1, $endday_of_week );
193 # use this to loop over days until $end
194 my $set = DateTime::Set->from_recurrence(
195 next => sub { $_[0]->truncate( to => 'day' )->add( days => 1 ) }
200 '/Elements/QueryString',
209 $QueryString ||= 'NewQuery=1';
211 # Default Query and Format
212 my $TempFormat = "__Starts__ __Due__";
213 my $TempQuery = "( Status = 'new' OR Status = 'open' OR Status = 'stalled')
214 AND ( Owner = '" . $session{CurrentUser}->Id ."' OR Owner = 'Nobody' )
215 AND ( Type = 'reminder' OR 'Type' = 'ticket' )";
217 if ( my $Search = RTx::Calendar::SearchDefaultCalendar($session{CurrentUser}) ) {
218 $TempFormat = $Search->SubValue('Format');
219 $TempQuery = $Search->SubValue('Query');
222 # we overide them if needed
223 $TempQuery = $Query if $Query;
224 $TempFormat = $Format if $Format;
226 # we search all date types in Format string
227 my @Dates = grep { $TempFormat =~ m/__${_}(Relative)?__/ } @DateTypes;
229 # used to display or not a date in Element/CalendarEvent
230 my %DateTypes = map { $_ => 1 } @Dates;
232 $TempQuery .= RTx::Calendar::DatesClauses(\@Dates, $date->strftime("%F"), $end->strftime("%F"));
234 # print STDERR ("-" x 30), "\n", $TempQuery, "\n";
236 my %Tickets = RTx::Calendar::FindTickets($session{'CurrentUser'}, $TempQuery, \@Dates, $date->strftime("%F"), $end->strftime("%F"));