From: ivan Date: Mon, 24 Mar 2008 03:08:00 +0000 (+0000) Subject: woo! final part of #1160! yup, auto-associating tickets with customers now. whew! X-Git-Tag: root_of_webpay_support~809 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=6ad0603afe8119536b21f65f06c3ff13f243170f woo! final part of #1160! yup, auto-associating tickets with customers now. whew! --- diff --git a/rt/html/Elements/EditCustomers b/rt/html/Elements/EditCustomers index 57eb9059d..68efb5f40 100644 --- a/rt/html/Elements/EditCustomers +++ b/rt/html/Elements/EditCustomers @@ -21,12 +21,7 @@ -% #while (my $link = $Object->MemberOf->Next) { -% foreach my $link ( -% grep { $_->TargetURI->Resolver->{'fstable'} eq 'cust_main' } -% grep { $_->TargetURI->Scheme eq 'freeside' } -% @{ $Object->_Links('Base')->ItemsArrayRef } -% ) { +% foreach my $link ( @{ $Object->Customers->ItemsArrayRef } ) { %# <& ShowLink, URI => $link->TargetURI &>
diff --git a/rt/html/Ticket/Elements/EditCustomers b/rt/html/Ticket/Elements/EditCustomers index c5a6f708c..0ba6e447b 100644 --- a/rt/html/Ticket/Elements/EditCustomers +++ b/rt/html/Ticket/Elements/EditCustomers @@ -1,4 +1,5 @@ %# Copyright (c) 2004 Ivan Kohler +%# Copyright (c) 2008 Freeside Internet Services, Inc. %# %# 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 @@ -20,12 +21,7 @@ -% #while (my $link = $Ticket->MemberOf->Next) { -% foreach my $link ( -% grep { $_->TargetURI->Resolver->{'fstable'} eq 'cust_main' } -% grep { $_->TargetURI->Scheme eq 'freeside' } -% @{ $Ticket->_Links('Base')->ItemsArrayRef } -% ) { +% foreach my $link ( @{ $Ticket->Customers->ItemsArrayRef } ) { %# <& ShowLink, URI => $link->TargetURI &>
diff --git a/rt/html/Ticket/Elements/ShowCustomers b/rt/html/Ticket/Elements/ShowCustomers index 612727ede..3acf92dd4 100644 --- a/rt/html/Ticket/Elements/ShowCustomers +++ b/rt/html/Ticket/Elements/ShowCustomers @@ -11,17 +11,15 @@ %# General Public License for more details. % my $cust = 0; -% foreach my $customerURI ( -% grep { $_->Resolver->{'fstable'} eq 'cust_main' } -% grep { $_->Scheme eq 'freeside' } -% map { $_->TargetURI } -% @{ $Ticket->_Links('Base')->ItemsArrayRef } -% ) { +% foreach my $custResolver ( map { $_->TargetURI->Resolver } +% @{ $Ticket->Customers->ItemsArrayRef } +% ) +% { % $cust++; % my $cust_main = ''; % } diff --git a/rt/lib/RT/Record.pm b/rt/lib/RT/Record.pm index f7100c5f2..b32ef5553 100755 --- a/rt/lib/RT/Record.pm +++ b/rt/lib/RT/Record.pm @@ -74,6 +74,7 @@ our @ISA; use base qw(RT::Base); use RT::Date; +use RT::I18N; use RT::User; use RT::Attributes; use DBIx::SearchBuilder::Record::Cachable; @@ -862,6 +863,7 @@ sub _DecodeLOB { elsif ( $ContentEncoding && $ContentEncoding ne 'none' ) { return ( $self->loc( "Unknown ContentEncoding [_1]", $ContentEncoding ) ); } + if ( RT::I18N::IsTextualContentType($ContentType) ) { $Content = Encode::decode_utf8($Content) unless Encode::is_utf8($Content); } diff --git a/rt/lib/RT/Ticket_Overlay.pm b/rt/lib/RT/Ticket_Overlay.pm index b4e3259f1..1916bc463 100644 --- a/rt/lib/RT/Ticket_Overlay.pm +++ b/rt/lib/RT/Ticket_Overlay.pm @@ -716,6 +716,43 @@ sub Create { # }}} + # {{{ Deal with auto-customer association + + #unless we already have (a) customer(s)... + unless ( $self->Customers->Count ) { + + #find any requestors with customer targets + + my %cust_target = (); + + my @Requestors = + grep { $_->Customers->Count } + @{ $self->Requestors->UserMembersObj->ItemsArrayRef }; + + foreach my $Requestor ( @Requestors ) { + foreach my $cust_link ( @{ $Requestor->Customers->ItemsArrayRef } ) { + $cust_target{ $cust_link->Target } = 1; + } + } + + #and then auto-associate this ticket with those customers + + foreach my $cust_target ( keys %cust_target ) { + + my @link = ( 'Type' => 'MemberOf', + #'Target' => "freeside://freeside/cust_main/$custnum", + 'Target' => $cust_target, + ); + + my( $val, $msg ) = $self->AddLink(@link); + push @non_fatal_errors, $msg; + + } + + } + + # }}} + # {{{ Add all the custom fields foreach my $arg ( keys %args ) {
- <% $customerURI->Resolver->AsStringLong |n %> + <% $custResolver->AsStringLong |n %>