2 $Month => (localtime)[4]
3 $Year => (localtime)[5] + 1900
12 <& /Elements/Header, Title => $title &>
15 <&| /Widgets/TitleBox,
16 title => loc('Calendar for ') . $rtdate->GetMonth($Month) . " $Year" ,
17 title_class=> 'inverse',
23 % my ($PMonth, $PYear) = ($Month - 1, $Year);
28 <a href="<%$RT::WebPath%>/Search/Calendar.html?Month=<%$PMonth%>&Year=<%$PYear%>&<%$QueryString%>">«<%$rtdate->GetMonth($PMonth)%></a>
31 <font size="+1"><% $rtdate->GetMonth($Month). " $Year" %></font>
34 % my ($NMonth, $NYear) = ($Month + 1, $Year);
39 <a href="<%$RT::WebPath%>/Search/Calendar.html?Month=<%$NMonth%>&Year=<%$NYear%>&<%$QueryString%>"><%$rtdate->GetMonth($NMonth)%>»</a>
44 <table class="rtxcalendar">
48 % for ( @{$week{$weekstart}} ) {
49 <th width="14%"><%$rtdate->GetWeekday($_)%></th>
56 % while ($date <= $end) {
58 % my $offmonth = $date->month != ($Month + 1);
59 % my $is_today = (DateTime->compare($today, $date) == 0);
60 % my $is_yesterday = (DateTime->compare($yesterday, $date) == 0);
61 % my $is_aweekago = (DateTime->compare($aweekago, $date) == 0);
63 <td class="<% $offmonth ? 'offmonth'
65 : $is_yesterday ? 'yesterday'
66 : $is_aweekago ? 'aweekago'
70 <div class="<% $is_today ? 'todays'
71 : $offmonth ? 'offmonth'
76 % for my $t ( @{ $Tickets{$date->strftime("%F")} } ) {
78 <& /Elements/CalendarEvent, Object => $t, Date => $date, DateTypes => \%DateTypes &>
80 <% ($sp>0) ? '<BR>'x$sp : '' |n %>
84 % $date = $set->next($date);
85 % if ( $date->day_of_week == $startday_of_week ) {
97 <a href="<%$RT::WebPath%>/Search/Calendar.html?Month=<%$PMonth%>&Year=<%$PYear%>&<%$QueryString%>">«<%$rtdate->GetMonth($PMonth)%></a>
100 <td valign="top" align="center">
101 <form action="<%$RT::WebPath%>/Search/Calendar.html?<%$QueryString%>" method="post">
103 <select name="Month">
105 <option value="<%$_%>" <% $_ == $Month ? 'selected' : ''%> ><%$rtdate->GetMonth($_)%></option>
108 % my $year = (localtime)[5] + 1900;
110 % for ( ($year-5) .. ($year+5)) {
111 <option value="<%$_%>" <% $_ == $Year ? 'selected' : ''%>><%$_%></option>
115 %# <& /Elements/Submit&>
116 <input type="submit" value="<% loc('Submit') %>" class="button" />
122 <a href="<%$RT::WebPath%>/Search/Calendar.html?Month=<%$NMonth%>&Year=<%$NYear%>&<%$QueryString%>"><%$rtdate->GetMonth($NMonth)%>»</a>
130 <td valign="top" rowspan=9>
132 <a href="<%$RT::WebPath%>/Prefs/Calendar.html">Calendar Preferences and Help</a>
135 % foreach my $legend (keys %legend) {
138 <img src="<%$RT::WebImagesURL%>/<%$legend%>.png" />
142 % foreach ( @{$legend{$legend}} ) {
143 <% $more++ ? ', ' : '' %>
157 'created' => ['Created'],
159 'resolved' => ['Resolved'],
160 'updated' => ['Last Updated'],
161 'created_due' => ['Created','Due'],
162 'reminder' => ['Reminders'],
163 'started' => ['Started'],
164 'starts_due' => ['Starts','Due'],
169 use RTx::Calendar qw(FirstDay LastDay);
171 my $title = loc("Calendar");
173 my @DateTypes = qw/Created Starts Started Due LastUpdated Resolved/;
175 my $rtdate = RT::Date->new($session{'CurrentUser'});
177 my $weekstart = 'Sunday'; #RT::SiteConfig? user pref?
179 'Saturday' => [6,0..5],
181 'Monday' => [1..6,0],
183 my $startday_of_week = ${$week{$weekstart}}[0] || 7;
184 my $endday_of_week = ${$week{$weekstart}}[-1] || 7;
186 my $today = DateTime->today;
187 my $yesterday = $today->clone->subtract( days=>1 );
188 my $aweekago = $today->clone->subtract( days=>7 );
189 my $date = FirstDay($Year, $Month + 1, $startday_of_week );
190 my $end = LastDay ($Year, $Month + 1, $endday_of_week );
192 # use this to loop over days until $end
193 my $set = DateTime::Set->from_recurrence(
194 next => sub { $_[0]->truncate( to => 'day' )->add( days => 1 ) }
199 '/Elements/QueryString',
208 $QueryString ||= 'NewQuery=1';
210 # Default Query and Format
211 my $TempFormat = "__Starts__ __Due__";
212 my $TempQuery = "( Status = 'new' OR Status = 'open' OR Status = 'stalled')
213 AND ( Owner = '" . $session{CurrentUser}->Id ."' OR Owner = 'Nobody' )
214 AND ( Type = 'reminder' OR 'Type' = 'ticket' )";
216 if ( my $Search = RTx::Calendar::SearchDefaultCalendar($session{CurrentUser}) ) {
217 $TempFormat = $Search->SubValue('Format');
218 $TempQuery = $Search->SubValue('Query');
221 # we overide them if needed
222 $TempQuery = $Query if $Query;
223 $TempFormat = $Format if $Format;
225 # we search all date types in Format string
226 my @Dates = grep { $TempFormat =~ m/__${_}(Relative)?__/ } @DateTypes;
228 # used to display or not a date in Element/CalendarEvent
229 my %DateTypes = map { $_ => 1 } @Dates;
231 $TempQuery .= RTx::Calendar::DatesClauses(\@Dates, $date->strftime("%F"), $end->strftime("%F"));
233 # print STDERR ("-" x 30), "\n", $TempQuery, "\n";
235 my %Tickets = RTx::Calendar::FindTickets($session{'CurrentUser'}, $TempQuery, \@Dates, $date->strftime("%F"), $end->strftime("%F"));