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 <a href="<%$RT::WebPath%>/Prefs/Calendar.html">Calendar Preferences and Help</a>
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>
56 % while ($date <= $end) {
57 % if ( $date->day_of_week == $startday_of_week ) {
58 <th><% $date->week_number %></th>
60 <td class="<% $date->month != ($Month + 1) ? 'oddline' : '' %>"
61 style="width:14%;<% DateTime->compare($today, $date) == 0 ? 'background:#f6f7f8;' : '' %>"
63 <p class="date"><%$date->day%></p>
64 % for my $t ( @{ $Tickets{$date->strftime("%F")} } ) {
65 <& /Elements/CalendarEvent, Object => $t, Date => $date, DateTypes => \%DateTypes &>
68 % $date = $set->next($date);
69 % if ( $date->day_of_week == $startday_of_week ) {
80 <a href="<%$RT::WebPath%>/Search/Calendar.html?Month=<%$PMonth%>&Year=<%$PYear%>&<%$QueryString%>">«<%$rtdate->GetMonth($PMonth)%></a>
83 <a href="<%$RT::WebPath%>/Search/Calendar.html?Month=<%$NMonth%>&Year=<%$NYear%>&<%$QueryString%>"><%$rtdate->GetMonth($NMonth)%>»</a>
91 <td valign="top" align="center" width="80%">
92 <form action="<%$RT::WebPath%>/Search/Calendar.html?<%$QueryString%>" method="post">
96 <option value="<%$_%>" <% $_ == $Month ? 'selected' : ''%> ><%$rtdate->GetMonth($_)%></option>
99 % my $year = (localtime)[5] + 1900;
101 % for ( ($year-5) .. ($year+5)) {
102 <option value="<%$_%>" <% $_ == $Year ? 'selected' : ''%>><%$_%></option>
106 <& /Elements/Submit&>
109 <td valign="top" width="50%" align="right">
110 <img src="<%$RT::WebImagesURL%>/created.png" /> : <&|/l&>Created</&><br />
111 <img src="<%$RT::WebImagesURL%>/due.png" /> : <&|/l&>Due</&><br />
112 <img src="<%$RT::WebImagesURL%>/resolved.png" /> : <&|/l&>Resolved</&><br />
113 <img src="<%$RT::WebImagesURL%>/updated.png" /> : <&|/l&>Last Updated</&><br />
114 <img src="<%$RT::WebImagesURL%>/created_due.png" /> : <&|/l&>Created</&>, <&|/l&>Due</&><br />
115 <img src="<%$RT::WebImagesURL%>/reminder.png" /> : <&|/l&>Reminders</&><br />
116 <img src="<%$RT::WebImagesURL%>/starts.png" /> : <&|/l&>Starts</&><br />
117 <img src="<%$RT::WebImagesURL%>/started.png" /> : <&|/l&>Started</&><br />
118 <img src="<%$RT::WebImagesURL%>/starts_due.png" /> : <&|/l&>Starts</&>, <&|/l&>Due</&><br />
128 use RTx::Calendar qw(FirstDay LastDay);
130 my $title = loc("Calendar");
132 my @DateTypes = qw/Created Starts Started Due LastUpdated Resolved/;
134 my $rtdate = RT::Date->new($session{'CurrentUser'});
136 my $weekstart = 'Sunday'; #RT::SiteConfig? user pref?
138 'Saturday' => [6,0..5],
140 'Monday' => [1..6,0],
142 my $startday_of_week = ${$week{$weekstart}}[0] || 7;
143 my $endday_of_week = ${$week{$weekstart}}[-1] || 7;
145 my $today = DateTime->today;
146 my $date = FirstDay($Year, $Month + 1, $startday_of_week );
147 my $end = LastDay ($Year, $Month + 1, $endday_of_week );
149 # use this to loop over days until $end
150 my $set = DateTime::Set->from_recurrence(
151 next => sub { $_[0]->truncate( to => 'day' )->add( days => 1 ) }
156 '/Elements/QueryString',
165 $QueryString ||= 'NewQuery=1';
167 # Default Query and Format
168 my $TempFormat = "__Starts__ __Due__";
169 my $TempQuery = "( Status = 'new' OR Status = 'open' OR Status = 'stalled')
170 AND ( Owner = '" . $session{CurrentUser}->Id ."' OR Owner = 'Nobody' )
171 AND ( Type = 'reminder' OR 'Type' = 'ticket' )";
173 if ( my $Search = RTx::Calendar::SearchDefaultCalendar($session{CurrentUser}) ) {
174 $TempFormat = $Search->SubValue('Format');
175 $TempQuery = $Search->SubValue('Query');
178 # we overide them if needed
179 $TempQuery = $Query if $Query;
180 $TempFormat = $Format if $Format;
182 # we search all date types in Format string
183 my @Dates = grep { $TempFormat =~ m/__${_}(Relative)?__/ } @DateTypes;
185 # used to display or not a date in Element/CalendarEvent
186 my %DateTypes = map { $_ => 1 } @Dates;
188 $TempQuery .= RTx::Calendar::DatesClauses(\@Dates, $date->strftime("%F"), $end->strftime("%F"));
190 # print STDERR ("-" x 30), "\n", $TempQuery, "\n";
192 my %Tickets = RTx::Calendar::FindTickets($session{'CurrentUser'}, $TempQuery, \@Dates, $date->strftime("%F"), $end->strftime("%F"));