2 $Month => (localtime)[4]
3 $Year => (localtime)[5] + 1900
17 <& /Elements/Header, Title => $title &>
22 % if ( $date->month == $end->month ) {
23 % $title = $rtdate->GetMonth( $date->month -1 ). ' '.
24 % $date->day. '-'. $end->day. ', '. $date->year;
25 % } elsif ( $date->year == $end->year ) {
27 % $rtdate->GetMonth( $date->month -1 ). ' '. $date->day. ' - '.
28 % $rtdate->GetMonth( $end->month -1 ). ' '. $end->day. ', '. $end->year;
31 % $rtdate->GetMonth( $date->month -1 ). ' '.$date->day. ', '. $date->year.
33 % $rtdate->GetMonth( $end->month -1 ). ' '.$end->day. ', '. $end->year;
36 % $title = $rtdate->GetMonth($Month) . " $Year"
38 <&| /Widgets/TitleBox,
39 title => loc('Calendar for '). $title,
40 title_class=> 'inverse',
43 % my($PMonth, $PYear, $NMonth, $NYear);
44 % unless ( $WeekDay ) {
49 % ($PMonth, $PYear) = ($Month - 1, $Year);
54 <a href="<%$RT::WebPath%>/Search/Calendar.html?Month=<%$PMonth%>&Year=<%$PYear%>&<%$QueryString%>">«<%$rtdate->GetMonth($PMonth)%></a>
57 <font size="+1"><% $rtdate->GetMonth($Month). " $Year" %></font>
60 % ($NMonth, $NYear) = ($Month + 1, $Year);
65 <a href="<%$RT::WebPath%>/Search/Calendar.html?Month=<%$NMonth%>&Year=<%$NYear%>&<%$QueryString%>"><%$rtdate->GetMonth($NMonth)%>»</a>
71 <table class="rtxcalendar">
75 <td class="controls"></td>
76 % for ( @{$week{$weekstart}} ) {
77 <th width="14%"><%$rtdate->GetWeekday($_)%></th>
85 <& td_week_collapse, date=>$date, Month=>$OrigMonth, Year=>$OrigYear, QueryString=>$QueryString &>
87 <& td_week_expand, date=>$date, Month=>$Month, Year=>$Year, QueryString=>$QueryString &>
89 % while ($date <= $end) {
91 % my $offmonth = !$WeekDay && $date->month != ($Month + 1);
92 % my $is_today = (DateTime->compare($today, $date) == 0);
93 % my $is_yesterday = (DateTime->compare($yesterday, $date) == 0);
94 % my $is_aweekago = (DateTime->compare($aweekago, $date) == 0);
96 <td class="<% $offmonth ? 'offmonth'
98 : $is_yesterday ? 'yesterday'
99 : $is_aweekago ? 'aweekago'
103 <div class="<% $is_today ? 'todays'
104 : $offmonth ? 'offmonth'
107 ><% ( $WeekDay ? $rtdate->GetMonth($date->month-1). ' ' : '' ).
112 % for my $t ( @{ $Tickets{$date->strftime("%F")} } ) {
114 <& /Elements/CalendarEvent, Object => $t, Date => $date, DateTypes => \%DateTypes &>
116 <% ($sp>0) ? '<BR>'x$sp : '' |n %>
120 % $date = $set->next($date);
121 % if ( $date->day_of_week == $startday_of_week ) {
123 % if ( $date <= $end ) {
126 <& td_week_collapse, date=>$date, Month=>$OrigMonth, Year=>$OrigYear, QueryString=>$QueryString &>
128 <& td_week_expand, date=>$date, Month=>$Month, Year=>$Year, QueryString=>$QueryString &>
137 % unless ( $WeekDay ) {
142 <a href="<%$RT::WebPath%>/Search/Calendar.html?Month=<%$PMonth%>&Year=<%$PYear%>&<%$QueryString%>">«<%$rtdate->GetMonth($PMonth)%></a>
145 <td valign="top" align="center">
146 <form action="<%$RT::WebPath%>/Search/Calendar.html?<%$QueryString%>" method="post">
148 <select name="Month">
150 <option value="<%$_%>" <% $_ == $Month ? 'selected' : ''%> ><%$rtdate->GetMonth($_)%></option>
154 % my $year = (localtime)[5] + 1900;
156 % for ( ($year-5) .. ($year+5)) {
157 <option value="<%$_%>" <% $_ == $Year ? 'selected' : ''%>><%$_%></option>
161 %# <& /Elements/Submit&>
162 <input type="submit" value="<% loc('Submit') %>" class="button" />
168 <a href="<%$RT::WebPath%>/Search/Calendar.html?Month=<%$NMonth%>&Year=<%$NYear%>&<%$QueryString%>"><%$rtdate->GetMonth($NMonth)%>»</a>
175 % #XXX an option to turn off "Calendar Preferences and Help" for embedded
176 % # (and weekly?) use
180 <td valign="top" rowspan=9>
182 <a href="<%$RT::WebPath%>/Prefs/Calendar.html">Calendar Preferences and Help</a>
185 % foreach my $legend (keys %legend) {
188 <img src="<%$RT::WebImagesURL%>/<%$legend%>.png" />
192 % foreach ( @{$legend{$legend}} ) {
193 <% $more++ ? ', ' : '' %>
207 'created' => ['Created'],
209 'resolved' => ['Resolved'],
210 'updated' => ['Last Updated'],
211 'created_due' => ['Created','Due'],
212 'reminder' => ['Reminders'],
213 'started' => ['Started'],
214 'starts_due' => ['Starts','Due'],
219 use RTx::Calendar qw(FirstDay LastDay LastDayOfWeek);
221 my $title = loc("Calendar");
223 my @DateTypes = qw/Created Starts Started Due LastUpdated Resolved/;
225 my $rtdate = RT::Date->new($session{'CurrentUser'});
227 my $weekstart = 'Sunday'; #RT::SiteConfig? user pref?
229 'Saturday' => [6,0..5],
231 'Monday' => [1..6,0],
233 my $startday_of_week = ${$week{$weekstart}}[0] || 7;
234 my $endday_of_week = ${$week{$weekstart}}[-1] || 7;
236 my $today = DateTime->today;
237 my $yesterday = $today->clone->subtract( days=>1 );
238 my $aweekago = $today->clone->subtract( days=>7 );
242 $date = DateTime->new( year=>$WeekYear, month=>$WeekMonth+1, day=>$WeekDay );
243 $end = LastDayOfWeek( $WeekYear, $WeekMonth+1, $WeekDay, $endday_of_week );
245 $date = FirstDay($Year, $Month + 1, $startday_of_week );
246 $end = LastDay ($Year, $Month + 1, $endday_of_week );
249 # use this to loop over days until $end
250 my $set = DateTime::Set->from_recurrence(
251 next => sub { $_[0]->truncate( to => 'day' )->add( days => 1 ) }
256 '/Elements/QueryString',
265 $QueryString ||= 'NewQuery=1';
267 # Default Query and Format
268 my $TempFormat = "__Starts__ __Due__";
269 my $TempQuery = "( Status = 'new' OR Status = 'open' OR Status = 'stalled')
270 AND ( Owner = '" . $session{CurrentUser}->Id ."' OR Owner = 'Nobody' )
271 AND ( Type = 'reminder' OR 'Type' = 'ticket' )";
273 if ( my $Search = RTx::Calendar::SearchDefaultCalendar($session{CurrentUser}) ) {
274 $TempFormat = $Search->SubValue('Format');
275 $TempQuery = $Search->SubValue('Query');
278 # we overide them if needed
279 $TempQuery = $Query if $Query;
280 $TempFormat = $Format if $Format;
282 # we search all date types in Format string
283 my @Dates = grep { $TempFormat =~ m/__${_}(Relative)?__/ } @DateTypes;
285 # used to display or not a date in Element/CalendarEvent
286 my %DateTypes = map { $_ => 1 } @Dates;
288 $TempQuery .= RTx::Calendar::DatesClauses(\@Dates, $date->strftime("%F"), $end->strftime("%F"));
290 # print STDERR ("-" x 30), "\n", $TempQuery, "\n";
292 my %Tickets = RTx::Calendar::FindTickets($session{'CurrentUser'}, $TempQuery, \@Dates, $date->strftime("%F"), $end->strftime("%F"));
295 <%def td_week_expand>
300 $QueryString => undef
302 <td class="controls">
303 <a href="<%$RT::WebPath%>/Search/Calendar.html?WeekDay=<% $date->day %>&WeekMonth=<% $date->month -1 %>&WeekYear=<% $date->year %>&OrigMonth=<% $Month %>&OrigYear=<% $Year %>&<%$QueryString%>"><img src="<%$RT::WebPath%>/NoAuth/images/week-expand.gif"></a>
307 <%def td_week_collapse>
312 $QueryString => undef
314 <td class="controls">
315 <a href="<%$RT::WebPath%>/Search/Calendar.html?Month=<% $Month %>&Year=<% $Year %>&<%$QueryString%>"><img src="<%$RT::WebPath%>/NoAuth/images/week-collapse.gif"></a>