From 7cd35e039f0339dc115e386c07174957d9a4ee06 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Mon, 14 Apr 2014 01:18:05 -0700 Subject: [PATCH] installers (appointments customer view), RT#16584 --- 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 diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm index 4d9cff99e..ecbaa643f 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 3dfe003a3..3ca3d264f 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 &> +% } +

+ +% } + % if ( $view eq 'jumbo' ) { #XXX enable me && $curuser->access_right('View customer packages') { <% mt('Packages') |h %>
@@ -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 000000000..9bec7b9ae --- /dev/null +++ b/httemplate/view/cust_main/appointments.html @@ -0,0 +1,124 @@ +%# <& /elements/form-create_ticket.html, object => $object &> +Appointments + +% 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 +Make appointment +% } + +%# | +%# View +%# <% mt($openlabel) |h %> | +%# <% mt('resolved') |h %> +
+ +<& /elements/table-grid.html &> +% my $bgcolor1 = '#eeeeee'; +% my $bgcolor2 = '#ffffff'; +% my $bgcolor = ''; + + + <% mt('Type') |h %> + <% mt('Date') |h %> + <% mt('Status') |h %> + <% mt('Owner') |h %> + + +% 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; + + + + + ><% 'custom field magic type' %> + + + + ><% $starts_pretty %> + + + + <% $ticket->{status} %> + + + + <% $ticket->{owner} %> + + + + +% } + + + +<%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) : ''; +#}; + + -- 2.11.0