From ab9be1d2bfedf205eab7a9d399ef22ee14117f53 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 19 May 2010 02:32:01 +0000 Subject: add RTx::Calendar 0.07 --- rt/share/html/Search/Calendar.html | 185 +++++++++++++++++++++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100644 rt/share/html/Search/Calendar.html (limited to 'rt/share/html/Search/Calendar.html') diff --git a/rt/share/html/Search/Calendar.html b/rt/share/html/Search/Calendar.html new file mode 100644 index 000000000..e711b861c --- /dev/null +++ b/rt/share/html/Search/Calendar.html @@ -0,0 +1,185 @@ +<%args> +$Month => (localtime)[4] +$Year => (localtime)[5] + 1900 +$Query => undef +$Format => undef +$Order => undef +$OrderBy => undef +$RowsPerPage => undef +$NewQuery => 0 + + +<& /Elements/Header, Title => $title &> +<& /Ticket/Elements/Tabs, + current_tab => "Search/Calendar.html?$QueryString", + Title => $title &> +<&| /Widgets/TitleBox, + title => loc('Calendar for ') . $rtdate->GetMonth($Month) . " $Year" , + title_class=> 'inverse', + color => "#993333" &> + + + + + + + +
+% my ($PMonth, $PYear) = ($Month - 1, $Year); +% if ($PMonth < 0) { +% $PYear--; +% $PMonth = 11; +% } +«<%$rtdate->GetMonth($PMonth)%> + +Calendar Preferences and Help + +% my ($NMonth, $NYear) = ($Month + 1, $Year); +% if ($NMonth > 11) { +% $NYear++; +% $NMonth = 0; +% } +<%$rtdate->GetMonth($NMonth)%>» +
+ + + + + +% for (1 .. 6, 0) { + +% } + + + + +% while ($date <= $end) { +% if ( $date->day_of_week == 1) { + +% } + +% $date = $set->next($date); +% if ( $date->day_of_week == 1) { + +% } +% } + + +
<%$rtdate->GetWeekday($_)%>
<% $date->week_number %> +

<%$date->day%>

+% for my $t ( @{ $Tickets{$date->strftime("%F")} } ) { +<& /Elements/CalendarEvent, Object => $t, Date => $date, DateTypes => \%DateTypes &> +% } +
+ + + + + + +
+«<%$rtdate->GetMonth($PMonth)%> + +<%$rtdate->GetMonth($NMonth)%>» +
+ + + + + + +
+
+ + +% my $year = (localtime)[5] + 1900; + + +<& /Elements/Submit&> +
+
+ : <&|/l&>Created
+ : <&|/l&>Due
+ : <&|/l&>Resolved
+ : <&|/l&>Last Updated
+ : <&|/l&>Created, <&|/l&>Due
+ : <&|/l&>Reminders
+ : <&|/l&>Starts
+ : <&|/l&>Started
+ : <&|/l&>Starts, <&|/l&>Due
+ + +
+ + + + +<%INIT> +use RTx::Calendar; + +my $title = loc("Calendar"); + +my @DateTypes = qw/Created Starts Started Due LastUpdated Resolved/; + +my $rtdate = RT::Date->new($session{'CurrentUser'}); + +my $today = DateTime->today; +my $date = RTx::Calendar::FirstMonday($Year, $Month + 1); +my $end = RTx::Calendar::LastSunday($Year, $Month + 1); + +# use this to loop over days until $end +my $set = DateTime::Set->from_recurrence( + next => sub { $_[0]->truncate( to => 'day' )->add( days => 1 ) } +); + +my $QueryString = + $m->comp( + '/Elements/QueryString', + Query => $Query, + Format => $Format, + Order => $Order, + OrderBy => $OrderBy, + Rows => $RowsPerPage + ) + if ($Query); + +$QueryString ||= 'NewQuery=1'; + +# Default Query and Format +my $TempFormat = "__Starts__ __Due__"; +my $TempQuery = "( Status = 'new' OR Status = 'open' OR Status = 'stalled') + AND ( Owner = '" . $session{CurrentUser}->Id ."' OR Owner = 'Nobody' ) + AND ( Type = 'reminder' OR 'Type' = 'ticket' )"; + +if ( my $Search = RTx::Calendar::SearchDefaultCalendar($session{CurrentUser}) ) { + $TempFormat = $Search->SubValue('Format'); + $TempQuery = $Search->SubValue('Query'); +} + +# we overide them if needed +$TempQuery = $Query if $Query; +$TempFormat = $Format if $Format; + +# we search all date types in Format string +my @Dates = grep { $TempFormat =~ m/__${_}(Relative)?__/ } @DateTypes; + +# used to display or not a date in Element/CalendarEvent +my %DateTypes = map { $_ => 1 } @Dates; + +$TempQuery .= RTx::Calendar::DatesClauses(\@Dates, $date->strftime("%F"), $end->strftime("%F")); + +# print STDERR ("-" x 30), "\n", $TempQuery, "\n"; + +my %Tickets = RTx::Calendar::FindTickets($session{'CurrentUser'}, $TempQuery, \@Dates, $date->strftime("%F"), $end->strftime("%F")); + + -- cgit v1.2.1