From 1c59bba12621e154765a8255534e94a041dfd200 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Tue, 17 Apr 2012 15:52:14 -0700 Subject: link tickets to services, #17067 --- httemplate/elements/form-create_ticket.html | 38 +++++++ httemplate/elements/table-tickets.html | 159 ++++++++++++++++++++++++++ httemplate/view/cust_main/tickets.html | 166 +--------------------------- httemplate/view/elements/svc_Common.html | 4 + httemplate/view/svc_acct.cgi | 4 + httemplate/view/svc_domain.cgi | 4 + httemplate/view/svc_external.cgi | 5 + httemplate/view/svc_forward.cgi | 4 + httemplate/view/svc_www.cgi | 4 + 9 files changed, 224 insertions(+), 164 deletions(-) create mode 100644 httemplate/elements/form-create_ticket.html create mode 100644 httemplate/elements/table-tickets.html (limited to 'httemplate') diff --git a/httemplate/elements/form-create_ticket.html b/httemplate/elements/form-create_ticket.html new file mode 100644 index 000000000..362e82397 --- /dev/null +++ b/httemplate/elements/form-create_ticket.html @@ -0,0 +1,38 @@ +
+ +Tickets +<% mt('Create new ticket') |h %> + <% mt('in queue') |h %> +%# fetch list of queues in which the user can create tickets +% my %queues = FS::TicketSystem->queues('', 'CreateTicket'); +% if( $conf->exists('ticket_system-force_default_queueid') ) { +<% $queues{$new_param{'Queue'}} %> + +% } +% else { + + +% } +
+<%init> +my %opt = @_; +my $conf = new FS::Conf; +my $object = $opt{'object'}; # must be a cust_main, cust_svc, or svc_... +my ($new_base, %new_param) = FS::TicketSystem->href_params_new_ticket($object); +my $new_link = FS::TicketSystem->href_new_ticket($object); + diff --git a/httemplate/elements/table-tickets.html b/httemplate/elements/table-tickets.html new file mode 100644 index 000000000..6d1a45a0d --- /dev/null +++ b/httemplate/elements/table-tickets.html @@ -0,0 +1,159 @@ +<& /elements/form-create_ticket.html, object => $object &> + | +View +<% mt($openlabel) |h %> | +<% mt('resolved') |h %> +
+ +<& /elements/table-grid.html &> +% my $bgcolor1 = '#eeeeee'; +% my $bgcolor2 = '#ffffff'; +% my $bgcolor = ''; + + + <% mt('#') |h %> + <% mt('Subject') |h %> + <% mt('Status') |h %> + <% mt('Queue') |h %> + <% mt('Owner') |h %> + <% mt('Due') |h %> + <% mt('Estimated Time') |h %> + <% mt('Priority') |h %> +% if ( $ss_priority ) { + <% mt('Customer Priority') |h %> +% } +% if ( $object->isa('FS::cust_main') ) { + <% mt('Service') |h %> +% } + + +% foreach my $ticket ( @tickets ) { +% my $href = FS::TicketSystem->href_ticket($ticket->{id}); +% if ( $bgcolor eq $bgcolor1 ) { +% $bgcolor = $bgcolor2; +% } else { +% $bgcolor = $bgcolor1; +% } + + + + + ><% $ticket->{id} %> + + + + ><% $ticket->{subject} %> + + + + <% $ticket->{status} %> + + + + <% $ticket->{queue} %> + + + + <% $ticket->{owner} %> + + + + <% $date_formatter->($ticket->{due}) %> + + + + <% $ticket->{timeestimated} %> + + + + <% $ticket->{content} + ? $ticket->{content}.' ('.$ticket->{priority}.')' + : $ticket->{priority} + %> + + +% if ( $ss_priority ) { + + <% $ticket->{"CF.{$ss_priority}"} %> + +% } +% if ( $object->isa('FS::cust_main') ) { + +% foreach (@{ $ticket->{svcnums} }) { +% my $cust_svc = FS::cust_svc->by_key($_) or next; + <% FS::UI::Web::svc_label_link($m, $cust_svc->part_svc, $cust_svc) %> +
+% } +
+% } + + + +% } + + + +<%init> +use Date::Parse qw(str2time); +use Date::Format qw(time2str); + +my %opt = @_; +my $conf = new FS::Conf; + +my $object = $opt{'object'}; +$object = $object->cust_svc if $object->isa('FS::svc_Common'); +my( @tickets ) = $object->tickets; + +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') ) { + $thing = 'service'; + $open_link = FS::TicketSystem->href_service_tickets($object->svcnum); + + $res_link = FS::TicketSystem->href_service_tickets( + $object->svcnum, + { 'statuses' => [ 'resolved' ] } + ); +} + +my $ss_priority = FS::TicketSystem->selfservice_priority; +if ( $ss_priority ) { + my $dir = $conf->exists('ticket_system-priority_reverse') ? -1 : 1; + use sort 'stable'; + # sort in the following way: + @tickets = sort { + # within a severity level... + ( $a->{'content'} eq $b->{'content'} ) ? ( + # no-priority tickets sort last + ( + ($a->{'_selfservice_priority'} eq '') <=> + ($b->{'_selfservice_priority'} eq '') + ) || + # otherwise obey ticket_system-priority_reverse + ( $dir * + ($b->{'_selfservice_priority'} <=> $a->{'_selfservice_priority'}) + ) + ) : 0; # but don't rearrange between severity levels + } @tickets; +} + +my $format = $conf->config('date_format') || '%Y-%m-%d'; + +my $date_formatter = sub { + my $time = str2time($_[0], 'GMT'); + # exclude times within 24 hours of zero + ($time > 86400) ? time2str($format, $time) : ''; +}; + + diff --git a/httemplate/view/cust_main/tickets.html b/httemplate/view/cust_main/tickets.html index 194e90742..f076fcc92 100644 --- a/httemplate/view/cust_main/tickets.html +++ b/httemplate/view/cust_main/tickets.html @@ -1,164 +1,2 @@ -
- -Tickets -<% mt('Create new ticket') |h %> - <% mt('in queue') |h %> -%# fetch list of queues in which the user can create tickets -% my %queues = FS::TicketSystem->queues('', 'CreateTicket'); -% if( $conf->exists('ticket_system-force_default_queueid') ) { -<% $queues{$new_param{'Queue'}} %> - -% } -% else { - - -% } -
- | -View -<% mt($openlabel) |h %> | -<% mt('resolved') |h %> -
- -<& /elements/table-grid.html &> -% my $bgcolor1 = '#eeeeee'; -% my $bgcolor2 = '#ffffff'; -% my $bgcolor = ''; - - - <% mt('#') |h %> - <% mt('Subject') |h %> - <% mt('Status') |h %> - <% mt('Queue') |h %> - <% mt('Owner') |h %> - <% mt('Due') |h %> - <% mt('Estimated Time') |h %> - <% mt('Priority') |h %> -% if ( $ss_priority ) { - <% mt('Customer Priority') |h %> -% } - - -% foreach my $ticket ( @tickets ) { -% my $href = FS::TicketSystem->href_ticket($ticket->{id}); -% if ( $bgcolor eq $bgcolor1 ) { -% $bgcolor = $bgcolor2; -% } else { -% $bgcolor = $bgcolor1; -% } - - - - - ><% $ticket->{id} %> - - - - ><% $ticket->{subject} %> - - - - <% $ticket->{status} %> - - - - <% $ticket->{queue} %> - - - - <% $ticket->{owner} %> - - - - <% $date_formatter->($ticket->{due}) %> - - - - <% $ticket->{timeestimated} %> - - - - <% $ticket->{content} - ? $ticket->{content}.' ('.$ticket->{priority}.')' - : $ticket->{priority} - %> - - -% if ( $ss_priority ) { - - <% $ticket->{"CF.{$ss_priority}"} %> - -% } - - - -% } - - - -<%init> -use Date::Format 'time2str'; -use Date::Parse 'str2time'; - -my( $conf ) = new FS::Conf; -my( $cust_main ) = @_; -my( @tickets ) = $cust_main->tickets; - -my $open_link = FS::TicketSystem->href_customer_tickets($cust_main->custnum); -my $openlabel = join('/', FS::TicketSystem->statuses ); - -my $res_link = FS::TicketSystem->href_customer_tickets( - $cust_main->custnum, - { 'statuses' => [ 'resolved' ] } - ); - -my( $new_base, %new_param ) = - FS::TicketSystem->href_params_new_ticket( $cust_main ); - -my $new_link = FS::TicketSystem->href_new_ticket( $cust_main ); - -my $ss_priority = FS::TicketSystem->selfservice_priority; -if ( $ss_priority ) { - my $dir = $conf->exists('ticket_system-priority_reverse') ? -1 : 1; - use sort 'stable'; - # sort in the following way: - @tickets = sort { - # within a severity level... - ( $a->{'content'} eq $b->{'content'} ) ? ( - # no-priority tickets sort last - ( - ($a->{'_selfservice_priority'} eq '') <=> - ($b->{'_selfservice_priority'} eq '') - ) || - # otherwise obey ticket_system-priority_reverse - ( $dir * - ($b->{'_selfservice_priority'} <=> $a->{'_selfservice_priority'}) - ) - ) : 0; # but don't rearrange between severity levels - } @tickets; -} - -my $format = $conf->config('date_format') || '%Y-%m-%d'; - -my $date_formatter = sub { - my $time = str2time($_[0], 'GMT'); - # exclude times within 24 hours of zero - ($time > 86400) ? time2str($format, $time) : ''; -}; - - +% my $cust_main = shift; +<& /elements/table-tickets.html, object => $cust_main &> diff --git a/httemplate/view/elements/svc_Common.html b/httemplate/view/elements/svc_Common.html index 3130c73a0..04d2b2962 100644 --- a/httemplate/view/elements/svc_Common.html +++ b/httemplate/view/elements/svc_Common.html @@ -114,6 +114,10 @@ function areyousure(href) { % } +% if ( $conf->config('ticket_system') ) { +<& /elements/table-tickets.html, object => $cust_svc &> +% } + <% joblisting({'svcnum'=>$svcnum}, 1) %> <% include('/elements/footer.html') %> diff --git a/httemplate/view/svc_acct.cgi b/httemplate/view/svc_acct.cgi index 441e4945d..de97a0796 100755 --- a/httemplate/view/svc_acct.cgi +++ b/httemplate/view/svc_acct.cgi @@ -75,6 +75,10 @@ <& elements/svc_export_settings.html, $svc_acct &> +% if ( $conf->config('ticket_system') ) { +<& /elements/table-tickets.html, object => $cust_svc &> +% } + <% joblisting({'svcnum'=>$svcnum}, 1) %> <& /elements/footer.html &> diff --git a/httemplate/view/svc_domain.cgi b/httemplate/view/svc_domain.cgi index 3938a3406..fcccd74b4 100755 --- a/httemplate/view/svc_domain.cgi +++ b/httemplate/view/svc_domain.cgi @@ -36,6 +36,10 @@ <% include('elements/svc_export_settings.html', $svc_domain) %> +% if ( $conf->config('ticket_system') ) { +<& /elements/table-tickets.html, object => $cust_svc &> +% } + <% joblisting({'svcnum'=>$svcnum}, 1) %> <% include('/elements/footer.html') %> diff --git a/httemplate/view/svc_external.cgi b/httemplate/view/svc_external.cgi index 77679d81c..72e553598 100644 --- a/httemplate/view/svc_external.cgi +++ b/httemplate/view/svc_external.cgi @@ -23,6 +23,11 @@ + +% if ( $conf->config('ticket_system') ) { +<& /elements/table-tickets.html, object => $cust_svc &> +% } +
<% joblisting({'svcnum'=>$svcnum}, 1) %> <% include('/elements/footer.html') %> diff --git a/httemplate/view/svc_forward.cgi b/httemplate/view/svc_forward.cgi index 15b5ae56f..2cb78ebd5 100755 --- a/httemplate/view/svc_forward.cgi +++ b/httemplate/view/svc_forward.cgi @@ -53,6 +53,10 @@ <% include('elements/svc_export_settings.html', $svc_forward) %> +% if ( $conf->config('ticket_system') ) { +<& /elements/table-tickets.html, object => $cust_svc &> +% } + <% joblisting({'svcnum'=>$svcnum}, 1) %> <% include('/elements/footer.html') %> diff --git a/httemplate/view/svc_www.cgi b/httemplate/view/svc_www.cgi index 935d139e9..fbb02a00f 100644 --- a/httemplate/view/svc_www.cgi +++ b/httemplate/view/svc_www.cgi @@ -49,6 +49,10 @@
+% if ( $conf->config('ticket_system') ) { +<& /elements/table-tickets.html, object => $cust_svc &> +% } + <% joblisting({'svcnum'=>$svcnum}, 1) %> <% include('/elements/footer.html') %> -- cgit v1.2.1