summaryrefslogtreecommitdiff
path: root/rt/lib
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2014-04-13 02:20:15 -0700
committerIvan Kohler <ivan@freeside.biz>2014-04-13 02:20:15 -0700
commitcebcd8658ba5f45fc21d59769d591b1418a3fdd2 (patch)
tree9167012572752c89c1654abfba6909dc47178f40 /rt/lib
parentafb12da321c052f3628f628e429b59f8ab6453a8 (diff)
installers (calendaring), RT#16584
Diffstat (limited to 'rt/lib')
-rw-r--r--rt/lib/RTx/Calendar.pm9
-rw-r--r--rt/lib/RTx/Schedule.pm117
2 files changed, 122 insertions, 4 deletions
diff --git a/rt/lib/RTx/Calendar.pm b/rt/lib/RTx/Calendar.pm
index 88cfecd..7ddf186 100644
--- a/rt/lib/RTx/Calendar.pm
+++ b/rt/lib/RTx/Calendar.pm
@@ -10,7 +10,8 @@ our $VERSION = "0.17";
RT->AddStyleSheets('calendar.css')
if RT->can('AddStyleSheets');
-our @EXPORT_OK = qw( FirstDay LastDay LastDayOfWeek );
+our @EXPORT_OK = qw( FirstDay LastDay LastDayOfWeek DatesClauses LocalDate
+ SearchDefaultCalendar FindTickets );
sub FirstDay {
my ($year, $month, $matchday) = @_;
@@ -43,10 +44,10 @@ sub LastDayOfWeek {
next => sub { $_[0]->truncate( to => 'day' )->add( days => 1 ) }
);
- my $day = DateTime->new( year => $year, month => $month, day => $day );
+ my $dt = DateTime->new( year => $year, month => $month, day => $day );
- $day = $set->next($day) while $day->day_of_week != $matchday;
- $day;
+ $dt = $set->next($dt) while $dt->day_of_week != $matchday;
+ $dt;
}
diff --git a/rt/lib/RTx/Schedule.pm b/rt/lib/RTx/Schedule.pm
new file mode 100644
index 0000000..4c6e1f9
--- /dev/null
+++ b/rt/lib/RTx/Schedule.pm
@@ -0,0 +1,117 @@
+package RTx::Schedule;
+use base qw( Exporter );
+
+use strict;
+use RTx::Calendar qw( FindTickets LocalDate );
+
+our $VERSION = '0.01';
+
+our @EXPORT_OK = qw( UserDaySchedule );
+
+#ala Calendar.html
+# Default Query and Format
+our $DefaultFormat = "__Starts__ __Due__";
+our $DefaultQuery = "( Status = 'new' OR Status = 'open' OR Status = 'stalled')
+ AND ( Type = 'reminder' OR 'Type' = 'ticket' )";
+
+sub UserDaySchedule {
+ my %arg = @_;
+ my $username = $arg{username};
+ my $date = $arg{date};
+
+ my $Tickets;
+ if ( $arg{Tickets} ) {
+ $Tickets = $arg{Tickets};
+ } else {
+
+ my $Query = $DefaultQuery;
+
+# # 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;
+
+ my @Dates = qw( Starts Due );
+
+# # used to display or not a date in Element/CalendarEvent
+# my %DateTypes = map { $_ => 1 } @Dates;
+#
+# $TempQuery .= DatesClauses(\@Dates, $start->strftime("%F"), $end->strftime("%F"));
+
+ my %t = FindTickets( $arg{CurrentUser}, $Query, \@Dates, $date x2 );
+
+ $Tickets = $t{ $date };
+ }
+
+ #XXX block out unavailable times
+ #alas. abstractions break, freeside-specific stuff to get availability
+ # move availability to RT side? make it all callback/pluggable?
+
+ return (
+
+ #avail/unavailable times
+ 'avail' => {
+ },
+
+ #block out / show / color code existing appointments
+ 'scheduled' => {
+ map {
+ #$_->Id => [ $_->StartsObj, $t->DueObj ];
+
+ my($sm, $sh) = ($_->StartsObj->Localtime('user'))[1,2];
+ my $starts = $sh*60 + $sm;
+
+ my($dm, $dh) = ($_->DueObj->Localtime('user'))[1,2];
+ my $due = $dh*60 + $dm;
+
+ #XXX color code existing appointments by... city? proximity? etc.
+ my $col = '99ff99'; #green
+
+ $_->Id => [ $starts, $due, $col, $_ ];
+ }
+ grep {
+ LocalDate($_->StartsObj->Unix) eq $date
+ and $_->OwnerObj->Name eq $username
+ }
+ @$Tickets
+ },
+
+ );
+
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+RTx::Schedule - Scheduling extension for Request Tracker
+
+=head1 DESCRIPTION
+
+This RT extension adds scheduling functionality to Request Tracker.
+
+=head1 CONFIGURATION
+
+CalendarWeeklyStartMin (default 480, 8am)
+
+CalendarWeeklyEndMin (default 1080, 6pm)
+
+CalendarWeeklySizeMin (default 30)
+
+CalendarWeeklySlots (unused now?)
+
+=head1 AUTHOR
+
+Ivan Kohler
+
+=head1 COPYRIGHT
+
+Copyright 2014 Freeside Internet Services, Inc.
+
+This program is free software; you can redistribute it and/or
+modify it under the same terms as Request Tracker itself.
+