[freeside-commits] branch master updated. 7cd35e039f0339dc115e386c07174957d9a4ee06

Ivan ivan at 420.am
Mon Apr 14 01:18:07 PDT 2014


The branch, master has been updated
       via  7cd35e039f0339dc115e386c07174957d9a4ee06 (commit)
      from  61efe651061fbf1ac5fd2952e5ebfc9d827c7b95 (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 7cd35e039f0339dc115e386c07174957d9a4ee06
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Mon Apr 14 01:18:05 2014 -0700

    installers (appointments customer view), RT#16584

diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm
index 4d9cff9..ecbaa64 100644
--- a/FS/FS/AccessRight.pm
+++ b/FS/FS/AccessRight.pm
@@ -151,6 +151,8 @@ tie my %rights, 'Tie::IxHash',
     'Edit customer package comments', #NEW
     'Qualify service', #NEW
     'Waive setup fee', #NEW
+    'View appointments', #NEWNEW
+    'Make appointment',
   ],
   
   ###
diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi
index 3dfe003..3ca3d26 100755
--- a/httemplate/view/cust_main.cgi
+++ b/httemplate/view/cust_main.cgi
@@ -265,6 +265,16 @@ function areyousure(href, message) {
 
 % }
 
+% if ( $view eq 'appointments' || $view eq 'jumbo' ) {
+
+% if ( $conf->config('ticket_system')
+%        && $curuser->access_right('View appointments') ) { 
+  <& cust_main/appointments.html, $cust_main &>
+% } 
+  <BR><BR>
+
+% }
+
 % if ( $view eq 'jumbo' ) { #XXX enable me && $curuser->access_right('View customer packages') { 
 
   <A NAME="cust_pkg"><FONT SIZE="+2"><% mt('Packages') |h %></FONT></A><BR>
@@ -341,12 +351,15 @@ $title = mt("Customer:")." ".$title;
 
 #false laziness w/pref/pref.html and Conf.pm (cust_main-default_view)
 tie my %views, 'Tie::IxHash',
-       emt('Basics')       => 'basics',
-       emt('Notes')        => 'notes', #notes and files?
+       emt('Basics')           => 'basics',
+       emt('Notes')            => 'notes', #notes and files?
 ;
-$views{emt('Tickets')}     =  'tickets'
-                               if $conf->config('ticket_system');
-$views{emt('Packages')}    =  'packages';
+if ( $conf->config('ticket_system') ) {
+  $views{emt('Tickets')}       =  'tickets';
+  $views{emt('Appointments')}  =  'appointments'
+    if $curuser->access_right('View appointments');
+}
+$views{emt('Packages')}        =  'packages';
 $views{emt('Payment History')} =  'payment_history'
                                unless $conf->config('payby-default' eq 'HIDE');
 $views{emt('Change History')}  =  'change_history'
diff --git a/httemplate/view/cust_main/appointments.html b/httemplate/view/cust_main/appointments.html
new file mode 100644
index 0000000..9bec7b9
--- /dev/null
+++ b/httemplate/view/cust_main/appointments.html
@@ -0,0 +1,124 @@
+%# <& /elements/form-create_ticket.html, object => $object &>
+<A NAME="appointments"><FONT CLASS="fsinnerbox-title">Appointments</FONT></A>
+
+% if ( $FS::CurrentUser::CurrentUser->access_right('Make appointment') ) { 
+%# just a link for now,  should probably be FS::TicketSystem->href_schedule
+%# maybe need to add a dropdown for type (install etc.) from a custom field
+%# or maybe change to a popup and get that info there
+% my @sched_item = qsearch('sched_item', { 'disabled' => '', });
+% my @username = map $_->access_user->username, @sched_item;
+% my $query = join('&', map "username=$_", @username).
+%             '&LengthMin=180'. #XXX appointment length
+%             '&custnum='. $cust_main->custnum; #.
+%             #XXX '&pkgnum=$pkgnum";need to be for specific package/location, not just for a customer... default to active(/ordered) package in a pkg_class w/ticketing_queueid, otherwise, a popup?  we're getting complicated like form-creat_ticket.html
+<A HREF="<%$p%>rt/Search/Schedule.html?<% $query %>">Make appointment</A>
+% }
+
+%#  |
+%# View
+%# <A HREF="<% $open_link %>"><% mt($openlabel) |h %></A> |
+%# <A HREF="<% $res_link  %>"><% mt('resolved') |h %></A>
+ <BR>
+
+<& /elements/table-grid.html &>
+% my $bgcolor1 = '#eeeeee';
+%   my $bgcolor2 = '#ffffff';
+%   my $bgcolor = '';
+
+<TR>
+  <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Type') |h %></TH>
+  <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Date') |h %></TH>
+  <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Status') |h %></TH>
+  <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Owner') |h %></TH>
+</TR>
+
+% foreach my $ticket ( @tickets ) {
+%     my $href = FS::TicketSystem->href_ticket($ticket->{id});
+%     if ( $bgcolor eq $bgcolor1 ) {
+%       $bgcolor = $bgcolor2;
+%     } else {
+%       $bgcolor = $bgcolor1;
+%     }
+%
+%     use Date::Parse qw( str2time );
+%     my $starts = str2time( $ticket->{starts} ); #default format here sucks
+%     my $starts_pretty = '';
+%     $starts_pretty = time2str('%a %h %o %Y %l:%M%P', $starts)
+%       if $starts > 86400;
+
+  <TR>
+  
+    <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+      <A HREF=<%$href%>><% 'custom field magic type' %></A>
+    </TD>
+  
+    <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+      <A HREF=<%$href%>><% $starts_pretty %></A>
+    </TD>
+  
+    <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+      <% $ticket->{status} %>
+    </TD>
+  
+    <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+      <% $ticket->{owner} %>
+    </TD>
+
+  </TR>
+
+% } 
+
+</TABLE>
+
+<%init>
+
+my $cust_main = shift;
+my $object = $cust_main;
+
+#total false laziness & just copied from elements/table-tickets.html
+
+my %opt = @_;
+my $conf = new FS::Conf;
+
+return '' unless $conf->config('ticket_system');
+
+#my $object = $opt{'object'};
+#$object = $object->cust_svc if $object->isa('FS::svc_Common');
+my( @tickets )  = $object->tickets; #XXX but actually appointments... filter by presense of the necessary CF?  RT::Appointment instead of RT::Ticket ?
+
+my ($openlabel, $open_link, $res_link, $thing);
+$openlabel = join('/', FS::TicketSystem->statuses );
+
+# not the nicest way to do this--FS::has_tickets_Common?
+#if ( $object->isa('FS::cust_main') ) {
+  $thing  = 'customer';
+  $open_link = FS::TicketSystem->href_customer_tickets($object->custnum);
+
+  $res_link  = FS::TicketSystem->href_customer_tickets(
+                    $object->custnum,
+                    { 'statuses' => [ 'resolved' ] }
+                  );
+#} elsif ( $object->isa('FS::cust_svc') ) {
+#
+#  return '' unless $object->pkgnum;
+#
+#  $thing = 'service';
+#  $open_link = FS::TicketSystem->href_service_tickets($object->svcnum);
+#
+#  $res_link  = FS::TicketSystem->href_service_tickets(
+#                    $object->svcnum,
+#                    { 'statuses' => [ 'resolved' ] }
+#                  );
+#}
+
+#not actually used, appointments are all about what day this week and the time,
+# so formatting them with that in mind
+#my $format = $conf->config('date_format') || '%Y-%m-%d';
+#
+#my $date_formatter = sub {
+#  my $time = parse_datetime($_[0], 'GMT');
+#  # exclude times within 24 hours of zero
+#  ($time > 86400) ? time2str($format, $time) : '';
+#};
+
+</%init>

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

Summary of changes:
 FS/FS/AccessRight.pm                        |    2 +
 httemplate/view/cust_main.cgi               |   23 ++++-
 httemplate/view/cust_main/appointments.html |  124 +++++++++++++++++++++++++++
 3 files changed, 144 insertions(+), 5 deletions(-)
 create mode 100644 httemplate/view/cust_main/appointments.html




More information about the freeside-commits mailing list