diff options
author | ivan <ivan> | 2008-04-01 08:43:33 +0000 |
---|---|---|
committer | ivan <ivan> | 2008-04-01 08:43:33 +0000 |
commit | 4d3c77fe23ae72abb72e4cb9f8e77a84b2375e6a (patch) | |
tree | 109f3e3e9feb6f39f1261eb8a9949c453bd883c1 /rt | |
parent | 2f673cd6e61a8c67c4ef89d11cae3e96a7fac306 (diff) |
last bit of magic for RT ticket customer auto-association: look for requestor email addresses in cust_main_invoice and svc_acct, closes; RT#1160
Diffstat (limited to 'rt')
-rw-r--r-- | rt/lib/RT/Ticket_Overlay.pm | 25 | ||||
-rw-r--r-- | rt/lib/RT/URI/freeside/Internal.pm | 6 |
2 files changed, 31 insertions, 0 deletions
diff --git a/rt/lib/RT/Ticket_Overlay.pm b/rt/lib/RT/Ticket_Overlay.pm index 1916bc463..c8b02e7ac 100644 --- a/rt/lib/RT/Ticket_Overlay.pm +++ b/rt/lib/RT/Ticket_Overlay.pm @@ -721,6 +721,31 @@ sub Create { #unless we already have (a) customer(s)... unless ( $self->Customers->Count ) { + #first find any requestors with emails but *without* customer targets + my @NoCust_Requestors = + grep { $_->EmailAddress && ! $_->Customers->Count } + @{ $self->Requestors->UserMembersObj->ItemsArrayRef }; + + for my $Requestor (@NoCust_Requestors) { + + #perhaps the stuff in here should be in a User method?? + my @Customers = + &RT::URI::freeside::email_search( email=>$Requestor->EmailAddress ); + + foreach my $custnum ( map $_->{'custnum'}, @Customers ) { + + ## false laziness w/RT/Interface/Web_Vendor.pm + my @link = ( 'Type' => 'MemberOf', + 'Target' => "freeside://freeside/cust_main/$custnum", + ); + + my( $val, $msg ) = $Requestor->AddLink(@link); + #XXX should do something with $msg# push @non_fatal_errors, $msg; + + } + + } + #find any requestors with customer targets my %cust_target = (); diff --git a/rt/lib/RT/URI/freeside/Internal.pm b/rt/lib/RT/URI/freeside/Internal.pm index 9ca06306d..0bc4c9010 100644 --- a/rt/lib/RT/URI/freeside/Internal.pm +++ b/rt/lib/RT/URI/freeside/Internal.pm @@ -107,6 +107,12 @@ sub smart_search { #Subroutine } +sub email_search { #Subroutine + + return map { { $_->hash } } &FS::cust_main::email_search(@_); + +} + sub small_custview { return &FS::CGI::small_custview(@_); |