summaryrefslogtreecommitdiff
path: root/rt/lib
diff options
context:
space:
mode:
authorChristopher Burger <burgerc@freeside.biz>2017-07-20 09:29:45 -0400
committerChristopher Burger <burgerc@freeside.biz>2017-07-20 09:29:45 -0400
commitdc9d1bf1200065b9c34fd2aca4ebbfc642e22b52 (patch)
tree3d07c2e0b6cf6aa72d96395f25cea5cf92c1ee81 /rt/lib
parentd10a3e73a1c3e46f2c784d2aa4e7b3e621c336e2 (diff)
RT# 38517 - added auto create of customer contact, if requestor is not a contact yet when adding a company to ticket.
Diffstat (limited to 'rt/lib')
-rw-r--r--rt/lib/RT/Interface/Web_Vendor.pm27
1 files changed, 27 insertions, 0 deletions
diff --git a/rt/lib/RT/Interface/Web_Vendor.pm b/rt/lib/RT/Interface/Web_Vendor.pm
index ea3a498..da0b189 100644
--- a/rt/lib/RT/Interface/Web_Vendor.pm
+++ b/rt/lib/RT/Interface/Web_Vendor.pm
@@ -164,6 +164,33 @@ sub ProcessTicketCustomers {
push @results, $msg;
warn "$me: linking requestor to custnum $custnum: $msg\n"
if $Debug > 1;
+
+ ## check if FS contact email exists, if not create it.
+ if ( !qsearchs( {
+ 'table' => 'contact_email',
+ 'hashref' => { 'emailaddress' => $Requestor->{'values'}->{'emailaddress'}, },
+ } ) ) {
+ use FS::contact;
+
+ my $lname = $Requestor->{'values'}->{'realname'} ?
+ (split (/ /, $Requestor->{'values'}->{'realname'}))[-1] :
+ 'Requestor';
+
+ my $fname = $Requestor->{'values'}->{'realname'} ?
+ (split (/ /, $Requestor->{'values'}->{'realname'}))[0] :
+ 'RT';
+
+ my $contact = new FS::contact {
+ 'custnum' => $custnum,
+ 'first' => $fname,
+ 'last' => $lname,
+ 'emailaddress' => $Requestor->{'values'}->{'emailaddress'},
+ 'comment' => 'Auto created from RT requestor',
+ };
+ my $error = $contact->insert;
+ push @results, 'Created Freeside contact for requestor ' . $Requestor->{'values'}->{'emailaddress'}
+ unless $error;
+ }
}
}