From: Mark Wells Date: Thu, 20 Dec 2012 19:50:46 +0000 (-0800) Subject: improve display of ticket service links, #17067 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=452da5c4005c7dccc504db38578b9af2227d6e15 improve display of ticket service links, #17067 --- diff --git a/FS/FS/UI/Web/small_custview.pm b/FS/FS/UI/Web/small_custview.pm index e4b5421a2..ae0a4211b 100644 --- a/FS/FS/UI/Web/small_custview.pm +++ b/FS/FS/UI/Web/small_custview.pm @@ -29,7 +29,7 @@ sub small_custview { : qsearchs('cust_main', { 'custnum' => $arg } ) or die "unknown custnum $arg"; - my $html = '
'; + my $html = '
'; $html = qq!View ' if $url; diff --git a/rt/lib/RT/URI/freeside/Internal.pm b/rt/lib/RT/URI/freeside/Internal.pm index b5e56ee1f..61b256ef9 100644 --- a/rt/lib/RT/URI/freeside/Internal.pm +++ b/rt/lib/RT/URI/freeside/Internal.pm @@ -161,12 +161,12 @@ sub _FreesideURILabelLong { } elsif ( $table eq 'cust_svc' ) { my $string = ''; - my $cust = $self->CustomerResolver; - if ( $cust ) { - $string = $cust->AsStringLong; - } - $string .= '' . - $self->AsString . ''; + # we now do this within the UI + #my $cust = $self->CustomerResolver; + #if ( $cust ) { + # $string = $cust->AsStringLong; + #} + $string .= $self->AsString; return $string; } else { @@ -177,6 +177,16 @@ sub _FreesideURILabelLong { } +sub AsString { + my $self = shift; + if ( $self->{'fstable'} eq 'cust_svc' ) { + return '' . + $self->_FreesideURILabel . ''; + } else { + $self->SUPER::AsString; + } +} + sub CustomerResolver { my $self = shift; if ( $self->{fstable} eq 'cust_main' ) { diff --git a/rt/share/html/Ticket/Elements/AddCustomers b/rt/share/html/Ticket/Elements/AddCustomers index 13fb2f010..0ae4f9eaa 100644 --- a/rt/share/html/Ticket/Elements/AddCustomers +++ b/rt/share/html/Ticket/Elements/AddCustomers @@ -21,6 +21,8 @@ > + + <& .small_custview, $customer &> @@ -30,6 +32,8 @@ > + + <& .small_custview, $service &> <& .small_svcview, $service &> diff --git a/rt/share/html/Ticket/Elements/Customers b/rt/share/html/Ticket/Elements/Customers new file mode 100644 index 000000000..d90ef1c44 --- /dev/null +++ b/rt/share/html/Ticket/Elements/Customers @@ -0,0 +1,62 @@ +%# Copyright (c) 2004 Ivan Kohler +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +<%doc> +Provides resolver objects (RT::URI::freeside) for customer/service links +to a specified ticket. + +Do this: +%hash = $m->comp('Customers', Ticket => $ticket); + +%hash contains four elements: +- "custnums", an arrayref of customer numbers that are linked to the ticket, + in order. +- "cust_main", a hashref of custnum => customer object, for each custnum. +- "cust_linked", a hashref of custnum => boolean flag. If the flag is true, + then the customer is _explicitly_ linked (i.e. there is a + 'freeside://freeside/cust_main/' record in the Links table). Otherwise, + the customer link is implied by a service link but doesn't exist in its + own right. +- "cust_svc", a hashref of custnum => an arrayref of service objects that + are linked to the ticket and belong to that customer. + +<%init> +my @custnums; +my %cust_main; +my %cust_svc; +my %cust_linked; +my $customers = $Ticket->Customers; +# ensure each customer is displayed only once +while (my $link = $customers->Next) { + my $uri = $link->Target; + if ( $uri =~ /cust_main\/(\d+)/ ) { + $cust_main{$1} = $link->TargetURI->Resolver; + $cust_linked{$1} = 1; + } elsif ( $uri =~ /cust_svc\/(\d+)/ ) { + my $svc = $link->TargetURI->Resolver; + my $cust = $svc->CustomerResolver; + my $custnum = $cust->{fspkey}; + $cust_main{$custnum} ||= $cust; + $cust_svc{$custnum} ||= []; + push @{$cust_svc{$custnum}}, $svc; + } +} +@custnums = sort { $a <=> $b } keys %cust_main; +return ( + 'custnums' => \@custnums, + 'cust_main' => \%cust_main, + 'cust_svc' => \%cust_svc, + 'cust_linked' => \%cust_linked, +); + +<%ARGS> +$Ticket => undef + diff --git a/rt/share/html/Ticket/Elements/EditCustomers b/rt/share/html/Ticket/Elements/EditCustomers index 96207f4cc..e8aa69edc 100644 --- a/rt/share/html/Ticket/Elements/EditCustomers +++ b/rt/share/html/Ticket/Elements/EditCustomers @@ -15,22 +15,36 @@

<&|/l&>Current Customers

+% my %data = $m->comp('Customers', Ticket => $Ticket); +% if ( @{ $data{custnums} } ) { + - + +% foreach my $custnum ( @{ $data{custnums} } ) { +% foreach my $resolver +% ( $data{cust_main}{$custnum}, @{ $data{cust_svc}{$custnum} } ) +% { + +% } +% }
<&|/l&>(Check box to disassociate)<&|/l&>(Check box to disassociate)
-% foreach my $link ( @{ $Ticket->Customers->ItemsArrayRef } ) { - - -%# <& ShowLink, URI => $link->TargetURI &>
- <% $link->TargetURI->Resolver->AsStringLong |n %> -

-% } +% if ( $resolver->URI !~ /cust_main/ or $data{cust_linked}{$custnum} ) { +% # don't show a checkbox for implicit cust_main links + +% } +
+ <% $resolver->AsStringLong |n %>
+% } @@ -38,15 +52,15 @@

<&|/l&>New Customer Links

- + %# rowspan - + <&|/l&>Find customer

cust #, name, company or phone - + <&|/l&>Find service
diff --git a/rt/share/html/Ticket/Elements/ShowCustomers b/rt/share/html/Ticket/Elements/ShowCustomers index add562440..175822f52 100644 --- a/rt/share/html/Ticket/Elements/ShowCustomers +++ b/rt/share/html/Ticket/Elements/ShowCustomers @@ -9,20 +9,29 @@ %# WITHOUT ANY WARRANTY; without even the implied warranty of %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU %# General Public License for more details. +<%init> +my %data = $m->comp('Customers', Ticket => $Ticket); + + -% my @cust = map { $_->TargetURI->Resolver } -% @{ $Ticket->Customers->ItemsArrayRef }; -% -% foreach my $custResolver ( @cust ) { +% foreach my $custnum (@{ $data{custnums} }) { +% my $cust = $data{cust_main}{$custnum}; % } -% unless ( @cust ) { +% unless ( @{ $data{custnums} } ) {
- <% $custResolver->AsStringLong |n %> -%# includes service label and view/svc_ link for cust_svc links + <% $cust->AsStringLong |n %> +% foreach my $svc ( @{ $data{cust_svc}{$custnum} || [] } ) { + <% $svc->AsString |n %> +
+% }
(none)