[freeside-commits] branch master updated. 7cfd11c02730df0bd27f03b8da765666af0a0edc

Ivan ivan at 420.am
Sun Apr 13 13:23:38 PDT 2014


The branch, master has been updated
       via  7cfd11c02730df0bd27f03b8da765666af0a0edc (commit)
      from  778b8c70120cce490e8c6ddb534f1302200e0ad6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 7cfd11c02730df0bd27f03b8da765666af0a0edc
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sun Apr 13 13:23:37 2014 -0700

    installers (calendaring), RT#16584

diff --git a/rt/lib/RTx/Schedule.pm b/rt/lib/RTx/Schedule.pm
index 4c6e1f9..c143277 100644
--- a/rt/lib/RTx/Schedule.pm
+++ b/rt/lib/RTx/Schedule.pm
@@ -3,6 +3,9 @@ use base qw( Exporter );
 
 use strict;
 use RTx::Calendar qw( FindTickets LocalDate );
+use FS::Record qw( qsearch qsearchs );
+use FS::access_user;
+use FS::sched_avail;
 
 our $VERSION = '0.01';
 
@@ -45,15 +48,38 @@ sub UserDaySchedule {
     $Tickets = $t{ $date };
   }
 
-  #XXX block out unavailable times
+  #block out unavailable times
   #alas.  abstractions break, freeside-specific stuff to get availability
   # move availability to RT side?  make it all callback/pluggable?
 
+  use Date::Parse qw( str2time );
+  #my $wday = (localtime(str2time($date)))[6];
+
+  my $access_user = qsearchs('access_user', { 'username'=>$username })#disabled?
+    or die "unknown user $username";
+
+  my @sched_item = $access_user->sched_item #disabled?
+    or die "$username not an installer";
+  my $sched_item = $sched_item[0];
+
+  my @sched_avail = qsearch('sched_avail', {
+                               itemnum       => $sched_item->itemnum,
+                               override_date => 99, #XXX override date via $date
+                           });
+  @sched_avail    = qsearch('sched_avail', {
+                               itemnum       => $sched_item->itemnum,
+                               wday          => (localtime(str2time($date)))[6],
+                               override_date => '',
+                           })
+    unless @sched_avail;
+
   return (
 
     #avail/unavailable times
-    'avail'     => {
-    },
+    'avail'     => [
+                     map [ $_->stime, $_->etime ],
+                       @sched_avail
+                   ],
 
     #block out / show / color code existing appointments
     'scheduled' => {
@@ -63,11 +89,17 @@ sub UserDaySchedule {
             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;
+            my $due;
+            if ( LocalDate($_->DueObj->Unix) eq $date ) { #same day, use it
+              my($dm, $dh) = ($_->DueObj->Localtime('user'))[1,2];
+              $due = $dh*60 + $dm;
+            } else {
+              $due = 1439;#not today, we don't handle multi-day appointments, so
+            }
+            
 
             #XXX color code existing appointments by... city?  proximity?  etc.
-            my $col = '99ff99'; #green
+            my $col = '99ff99'; #green for now
 
             $_->Id => [ $starts, $due, $col, $_ ];
           }
diff --git a/rt/share/html/Elements/CalendarDaySchedule b/rt/share/html/Elements/CalendarDaySchedule
index f378674..a8cda65 100644
--- a/rt/share/html/Elements/CalendarDaySchedule
+++ b/rt/share/html/Elements/CalendarDaySchedule
@@ -1,10 +1,14 @@
 <%args>
 $Date        => undef
+$today       => undef
 $Tickets     => undef
 $DateTypes   => undef
 @username    => ()
 $CurrentUser => undef
 </%args>
+%if ( DateTime->compare( $Date, $today ) == -1 ) {#flag to show the past anyway?
+% #the past already happened...
+%} else {
 % foreach my $username ( @username ) {
 %   my $mapname = "$username-$date";
 %   my $img = "$RT::WebPath/Schedule/UserBar?Username=$username;Date=$date";
@@ -19,10 +23,8 @@ $CurrentUser => undef
 
 %   my %schedule = UserDaySchedule( CurrentUser => $CurrentUser,
 %                                   username    => $username,
-%                                   'date'      => $Date->strftime('%F'),
+%                                   'date'      => $date, #$Date->strftime('%F'),
 %                                 );
-
-%   #XXX block out unavailable times
 %
 %   #block out / show / color code existing appointments
 %   foreach my $id ( keys %{ $schedule{'scheduled'} } ) {
@@ -30,19 +32,47 @@ $CurrentUser => undef
 %     my $s = int(($starts-$stime)/10);
 %     my $e = int(($due-$stime)/10)-1;
       <AREA
-         onmouseover = "overlib('<%$id%>: XX miles away<BR>more info', BGCOLOR, '#000000', FGCOLOR, '#<%$col%>')"
+         onmouseover = "overlib('<%$id%>: XX miles away<BR>more info', WRAP, BGCOLOR, '#000000', FGCOLOR, '#<%$col%>')"
+         onmouseout  = "nd(); return true;"
+         shape       = "rect"
+         coords      = "<%$s%>,0,<%$e%>,<%$height%>"
+%#         href        = "test_href"
+%#         alt         =
+%#         title       =
+      >
+%   }
+%
+%   #white out available times
+%   foreach my $avail ( @{ $schedule{'avail'} } ) {
+%     my( $start, $end ) = @$avail;
+%     
+%     my $s = $start >= $stime ? int(($start-$stime)/10) : 0;
+%     my $e = int(($end-$stime)/10)-1;
+      <AREA
+         onmouseover = "overlib('Available', WRAP, BGCOLOR, '#000000', FGCOLOR, '#FFFFFF')"
          onmouseout  = "nd(); return true;"
          shape       = "rect"
-         coords      = "<%$s%>,0,<%$e%>,<%$height-1%>"
+         coords      = "<%$s%>,0,<%$e%>,<%$height%>"
+%# XXX link to book - if the appointment we want can fit
 %#         href        = "test_href"
 %#         alt         =
 %#         title       =
       >
 %   }
 
+      <AREA 
+         onmouseover = "overlib('Not available', WRAP, BGCOLOR, '#000000', FGCOLOR, '#666666', TEXTCOLOR, '#FFFFFF' )"
+         onmouseout  = "nd(); return true;"
+         shape       = "default"
+%#         href        = "test_href"
+%#         alt         =
+%#         title       =
+      >
+
     </MAP>
 
 % }
+%}
 <%once>
 
 my $stime    = RT->Config->Get('CalendarWeeklyStartMin');
@@ -58,6 +88,7 @@ my $height = 12; #Schedule/UserBar
 
 use RTx::Schedule qw( UserDaySchedule );
 
-my( $date, $time ) = split('T', $Date);
+#my( $date, $time ) = split('T', $Date);
+my $date = $Date->strftime('%F');
 
 </%init>
diff --git a/rt/share/html/Elements/CalendarSlotSchedule b/rt/share/html/Elements/CalendarSlotSchedule
index fb5b7c1..8a0c617 100644
--- a/rt/share/html/Elements/CalendarSlotSchedule
+++ b/rt/share/html/Elements/CalendarSlotSchedule
@@ -14,33 +14,37 @@
 %                                   Tickets  => \@Tickets,
 %                                 );
 %
-%   my $bgcolor = 'ffffff';
+%   my $bgcolor = '666666;border-color:#555555';
 %   my $content = '';
 %
-%   #XXX block out unavailable times
+%   #white out available times
+%   foreach my $avail ( @{ $schedule{'avail'} } ) {
+%     my( $start, $end ) = @$avail;
+%     next if $start >= ($tod_row+$timestep) || $end <= $tod_row;
+%     $bgcolor = 'FFFFFF';
+%   }
 %
 %   #block out / show / color code existing appointments
-%       foreach my $id ( keys %{ $schedule{'scheduled'} } ) {
+%   foreach my $id ( keys %{ $schedule{'scheduled'} } ) {
 %
-%         my( $starts, $due, $col, $t ) = @{ $schedule{'scheduled'}->{$id} };
+%     my( $starts, $due, $col, $t ) = @{ $schedule{'scheduled'}->{$id} };
 %
-%         next if $starts >= ($tod_row+$timestep) || $due < $tod_row;
+%     next if $starts >= ($tod_row+$timestep) || $due < $tod_row;
 %
-%         if ( $starts >= $tod_row ) {
-%           $bgcolor = $col;
-%           $content .= ($content?', ':''). $id; #XXX more
-%         } else {
-%           $bgcolor = $col;
-%         }
-%       }
+%     if ( $starts >= $tod_row ) {
+%       $bgcolor = $col;
+%       $content .= ($content?', ':''). $id; #XXX more
+%     } else {
+%       $bgcolor = $col;
+%     }
+%   }
 
-    <td style="background:#<%$bgcolor%>" class="weekly
+    <td style="background:#<%$bgcolor%>" class="weekly"
 %#               <%   $is_today     ? 'today'
 %#                  : $is_yesterday ? 'yesterday'
 %#                  : $is_aweekago  ? 'aweekago'
 %#                  : ''
-%#               %>
-                   "
+%#               %>"
     ><% $content %></td>
 % }
 <%ONCE>
diff --git a/rt/share/html/NoAuth/css/calendar.css b/rt/share/html/NoAuth/css/calendar.css
index 96241e7..75541f2 100644
--- a/rt/share/html/NoAuth/css/calendar.css
+++ b/rt/share/html/NoAuth/css/calendar.css
@@ -25,6 +25,12 @@ color:#505050;
   width:100%;
 }
 
+.pastoffmonthcalendardate {
+  text-align: right;
+  background-color: #e0e0e0;
+  width:100%;
+}
+
 .todayscalendardate {
   text-align: right;
   background-color: #fc6; /*#fad163*/
@@ -74,6 +80,16 @@ table.rtxcalendar td.offmonth {
     color: #aaa;
 }
 
+table.rtxcalendar td.past {
+    background: #e8e8e8;
+    color: #aaa;
+}
+
+table.rtxcalendar td.pastoffmonth {
+    background: #e0e0e0;
+    color: #aaa;
+}
+
 table.rtxcalendar td.today {
     background: #ffe; /*#fed;*/
     border: 1px solid #fc6;
diff --git a/rt/share/html/Schedule/UserBar b/rt/share/html/Schedule/UserBar
index 2345fe8..321107d 100644
--- a/rt/share/html/Schedule/UserBar
+++ b/rt/share/html/Schedule/UserBar
@@ -6,17 +6,29 @@ use RTx::Schedule qw( UserDaySchedule );
 my $im = new GD::Image($width, $height) or die;
 
 my $white = $im->colorAllocate(255,255,255);
-my $black = $im->colorAllocate(0,0,0); 
 
-# Put a black frame around the picture
+my $black = $im->colorAllocate(0,0,0); 
 $im->rectangle(0,0,$width-1,$height-1,$black);
 
+my $darkgray = $im->colorAllocate(102, 102, 102);
+$im->filledRectangle(0, 1, $width-1, $height-2, $darkgray);
+
 my %schedule = UserDaySchedule( CurrentUser => $session{CurrentUser},
                                 username    => $Username,
                                 'date'      => $Date,
                               );
 
-#XXX block out unavailable times
+#white out available times
+foreach my $avail ( @{ $schedule{'avail'} } ) {
+  my( $start, $end ) = @$avail;
+  
+  $im->filledRectangle( $start >= $stime ? int(($start-$stime)/10) : 0,
+                        1,
+                        int(($end-$stime)/10)-1,
+                        $height-2,
+                        $white,
+                      );
+}
 
 #block out / show / color code existing appointments
 foreach my $id ( keys %{ $schedule{'scheduled'} } ) {
diff --git a/rt/share/html/Search/Calendar.html b/rt/share/html/Search/Calendar.html
index d86a5b5..55b2b5a 100644
--- a/rt/share/html/Search/Calendar.html
+++ b/rt/share/html/Search/Calendar.html
@@ -16,6 +16,7 @@ $Embed       => undef
 $Display     => undef
 @DisplayArgs => ()
 $slots       => $default_slots
+$DimPast     => 0
 </%ARGS>
 
 % my $title;
@@ -247,18 +248,19 @@ $slots       => $default_slots
 %     my $is_today     = (DateTime->compare($today,     $date) == 0);
 %     my $is_yesterday = (DateTime->compare($yesterday, $date) == 0);
 %     my $is_aweekago  = (DateTime->compare($aweekago,  $date) == 0);
+%
+%     my $past = $DimPast && DateTime->compare($today,  $date) == 1;
 
       <td
-          class="<%   $offmonth     ? 'offmonth'
-                    : $is_today     ? 'today'
-                    : $is_yesterday ? 'yesterday'
-                    : $is_aweekago  ? 'aweekago'
+          class="<% $past ? 'past' : '' %><% $offmonth ? 'offmonth' : '' %><%
+                      $is_today     ? ' today'
+                    : $is_yesterday ? ' yesterday'
+                    : $is_aweekago  ? ' aweekago'
                     : ''
                  %>"
       >
         <div class="<%   $is_today ? 'todays'
-                       : $offmonth ? 'offmonth'
-                       : ''
+                       : ( $past ? 'past' : ''). ($offmonth ? 'offmonth' : '' )
                     %>calendardate"
         ><% $date->day %></div>
 
@@ -268,6 +270,7 @@ $slots       => $default_slots
           <& $el, CurrentUser => $session{CurrentUser},
                   Tickets     => $Tickets{$date->strftime("%F")},
                   Date        => $date,
+                  today       => $today,
                   DateTypes   => \%DateTypes,
                   @DisplayArgs,
           &>
diff --git a/rt/share/html/Search/Schedule.html b/rt/share/html/Search/Schedule.html
index 9ba41c7..14956b2 100644
--- a/rt/share/html/Search/Schedule.html
+++ b/rt/share/html/Search/Schedule.html
@@ -12,6 +12,7 @@
                     #XXX and we have the magic custom field
      slots       => scalar( @{ $ARGS{username} } ),
      Embed       => 'Schedule.html',
+     DimPast     => 1,
      Display     => 'Schedule',
      DisplayArgs => [ username => $ARGS{username} ],
 &>

-----------------------------------------------------------------------

Summary of changes:
 rt/lib/RTx/Schedule.pm                      |   44 +++++++++++++++++++++++----
 rt/share/html/Elements/CalendarDaySchedule  |   43 ++++++++++++++++++++++----
 rt/share/html/Elements/CalendarSlotSchedule |   34 +++++++++++---------
 rt/share/html/NoAuth/css/calendar.css       |   16 ++++++++++
 rt/share/html/Schedule/UserBar              |   18 +++++++++--
 rt/share/html/Search/Calendar.html          |   15 +++++----
 rt/share/html/Search/Schedule.html          |    1 +
 7 files changed, 135 insertions(+), 36 deletions(-)




More information about the freeside-commits mailing list