diff options
-rw-r--r-- | FS/FS/UI/Web/small_custview.pm | 2 | ||||
-rw-r--r-- | rt/lib/RT/URI/freeside/Internal.pm | 22 | ||||
-rw-r--r-- | rt/share/html/Ticket/Elements/AddCustomers | 4 | ||||
-rw-r--r-- | rt/share/html/Ticket/Elements/Customers | 62 | ||||
-rw-r--r-- | rt/share/html/Ticket/Elements/EditCustomers | 36 | ||||
-rw-r--r-- | rt/share/html/Ticket/Elements/ShowCustomers | 23 |
6 files changed, 124 insertions, 25 deletions
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 = '<DIV ID="fs_small_custview">'; + my $html = '<DIV ID="fs_small_custview" CLASS="small_custview">'; $html = qq!View <A HREF="$url?! . $cust_main->custnum . '">' 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 .= '<B><A HREF="' . $self->HREF . '">' . - $self->AsString . '</A></B>'; + # 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 '<B><A HREF="' . $self->HREF . '">' . + $self->_FreesideURILabel . '</A></B>'; + } 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 @@ <tr> <td> <input type="checkbox" name="Ticket-AddCustomer-<% $customer->{'custnum'} %>" VALUE="1" <% scalar(@Customers) == 1 ? 'CHECKED' : '' %>> + </td> + <td> <& .small_custview, $customer &> </td> </tr> @@ -30,6 +32,8 @@ <tr> <td> <input type="checkbox" name="Ticket-AddService-<% $service->{'svcnum'} %>" VALUE="1" <% scalar(@Services) == 1 ? 'CHECKED' : '' %>> + </td> + <td> <& .small_custview, $service &> <& .small_svcview, $service &> </td> 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 <ivan-rt@420.am> +%# +%# 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. +</%doc> +<%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, +); +</%init> +<%ARGS> +$Ticket => undef +</%ARGS> 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 @@ <TD VALIGN=TOP WIDTH=50% ROWSPAN=3> <h3><&|/l&>Current Customers</&></h3> +% my %data = $m->comp('Customers', Ticket => $Ticket); +% if ( @{ $data{custnums} } ) { +<style> +.small_custview { + padding-top: 1em; +} +</style> <table> <tr> - <td><i><&|/l&>(Check box to disassociate)</&></i></td> + <td colspan=2><i><&|/l&>(Check box to disassociate)</&></i></td> </tr> +% foreach my $custnum ( @{ $data{custnums} } ) { +% foreach my $resolver +% ( $data{cust_main}{$custnum}, @{ $data{cust_svc}{$custnum} } ) +% { <tr> <td class="value"> -% foreach my $link ( @{ $Ticket->Customers->ItemsArrayRef } ) { - - <INPUT TYPE=CHECKBOX NAME="DeleteLink--<%$link->Type%>-<%$link->Target%>"> -%# <& ShowLink, URI => $link->TargetURI &><br> - <% $link->TargetURI->Resolver->AsStringLong |n %></A> - <BR><BR> -% } +% if ( $resolver->URI !~ /cust_main/ or $data{cust_linked}{$custnum} ) { +% # don't show a checkbox for implicit cust_main links + <input type="checkbox" name="DeleteLink--MemberOf-<% $resolver->URI %>"> +% } + </td> + <td> + <% $resolver->AsStringLong |n %> </td> </tr> +% } +% } </table> +% } </TD> @@ -38,15 +52,15 @@ <h3><&|/l&>New Customer Links</&></h3> </TD> </TR> -<TR VALIGN="top"> +<TR> %# rowspan - <td width=25%> + <td width=25% style="vertical-align:top"> <&|/l&>Find customer</&><br> <input name="CustomerString"> <input type=submit name="OnlySearchForCustomers" value="<&|/l&>Go!</&>"> <br><i>cust #, name, company or phone</i> </td> - <td width=25%> + <td width=25% style="vertical-align:top"> <&|/l&>Find service</&><br> <input name="ServiceString"> <input type=submit name="OnlySearchForServices" value="<&|/l&>Go!</&>"> 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); +</%init> +<style> +.small_custview { + padding-top: 1em; +} +</style> <table> -% my @cust = map { $_->TargetURI->Resolver } -% @{ $Ticket->Customers->ItemsArrayRef }; -% -% foreach my $custResolver ( @cust ) { +% foreach my $custnum (@{ $data{custnums} }) { +% my $cust = $data{cust_main}{$custnum}; <tr> <td class="value"> - <% $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 %> + <br> +% } </td> </tr> % } -% unless ( @cust ) { +% unless ( @{ $data{custnums} } ) { <tr> <td class="labeltop"> <i>(none)<i> |