[freeside-commits] branch master updated. 2371880187dcd6a8dbc55be0ddc70a7436ffbf5f
Christopher Burger
burgerc at 420.am
Mon Jul 24 13:45:52 PDT 2017
The branch, master has been updated
via 2371880187dcd6a8dbc55be0ddc70a7436ffbf5f (commit)
from 994b2be1b9b039d309a9527ac598a16cbb7e80e9 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 2371880187dcd6a8dbc55be0ddc70a7436ffbf5f
Author: Christopher Burger <burgerc at freeside.biz>
Date: Mon Jul 24 16:45:50 2017 -0400
RT# 38517 - Added Lingua::EN::NameParse to parse real name into first and last name.
diff --git a/rt/lib/RT/Interface/Web_Vendor.pm b/rt/lib/RT/Interface/Web_Vendor.pm
index da0b189..909127b 100644
--- a/rt/lib/RT/Interface/Web_Vendor.pm
+++ b/rt/lib/RT/Interface/Web_Vendor.pm
@@ -170,16 +170,25 @@ sub ProcessTicketCustomers {
'table' => 'contact_email',
'hashref' => { 'emailaddress' => $Requestor->{'values'}->{'emailaddress'}, },
} ) ) {
- use FS::contact;
- my $lname = $Requestor->{'values'}->{'realname'} ?
- (split (/ /, $Requestor->{'values'}->{'realname'}))[-1] :
- 'Requestor';
+ ## get first and last name for contact.
+ my ($fname, $lname) = (
+ split (/\@/, substr($Requestor->{'values'}->{'emailaddress'}, 0, index($Requestor->{'values'}->{'emailaddress'}, ".")))
+ );
+
+ use Lingua::EN::NameParse;
+ my $name = Lingua::EN::NameParse->new();
+
+ my $error = $name->parse($Requestor->{'values'}->{'realname'})
+ unless !$Requestor->{'values'}->{'realname'};
- my $fname = $Requestor->{'values'}->{'realname'} ?
- (split (/ /, $Requestor->{'values'}->{'realname'}))[0] :
- 'RT';
+ my %name_comps = $name->components unless !$Requestor->{'values'}->{'realname'} || $error;
+ $fname = $name_comps{given_name_1} || $name_comps{initials_1} unless !$name_comps{given_name_1} && !$name_comps{initials_1};
+ $lname = $name_comps{surname_1} unless !$name_comps{surname_1};
+
+ ## create the contact.
+ use FS::contact;
my $contact = new FS::contact {
'custnum' => $custnum,
'first' => $fname,
-----------------------------------------------------------------------
Summary of changes:
rt/lib/RT/Interface/Web_Vendor.pm | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
More information about the freeside-commits
mailing list