From 203aa3dbe95397f85b02e5c626cae1419ca6c9c9 Mon Sep 17 00:00:00 2001 From: Christopher Burger Date: Mon, 18 Sep 2017 13:25:39 -0400 Subject: [PATCH] RT# 77532 - Updated customer contact reports to display contact phone numers Conflicts: httemplate/search/contact.html --- httemplate/search/contact.html | 59 ++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/httemplate/search/contact.html b/httemplate/search/contact.html index 1ddfabb8b..1f7385866 100644 --- a/httemplate/search/contact.html +++ b/httemplate/search/contact.html @@ -44,30 +44,45 @@ my $dbh = dbh; my $DEBUG = 0; -my $format_phone_sub = sub { - - my $pn = $_[0] || return ''; - $pn =~ s/\D//g; - my @pn = split //, $pn; - - return sprintf( - '(%s) %s-%s', - join( '', @pn[0..2] ), - join( '', @pn[3..5] ), - join( '', @pn[6..9] ) - ) if @pn == 10; - - return sprintf( - '+%s (%s) %s-%s', - $pn[0], - join( '', @pn[1..3] ), - join( '', @pn[4..6] ), - join( '', @pn[7..10] ) - ) if @pn == 11 && $pn[0] == 1; - - encode_entities $_[0]; +my $work_phone_sub = sub { + my $contact = shift; + #can't because contactnum is in the wrong field + my @contact_workphone = qsearch('contact_phone', { 'contactnum' => $contact->contact_contactnum, 'phonetypenum' => '1' } ); + join(', ', map $_->phonenum, @contact_workphone); }; +my $mobile_phone_sub = sub { + my $contact = shift; + #can't because contactnum is in the wrong field + my @contact_mobilephone = qsearch('contact_phone', { 'contactnum' => $contact->contact_contactnum, 'phonetypenum' => '3' } ); + join(', ', map $_->phonenum, @contact_mobilephone); +}; + +my $home_phone_sub = sub { + my $contact = shift; + #can't because contactnum is in the wrong field + my @contact_homephone = qsearch('contact_phone', { 'contactnum' => $contact->contact_contactnum, 'phonetypenum' => '2' } ); + join(', ', map $_->phonenum, @contact_homephone); +}; + +my $link; #for closure in this sub, we'll define it later +my $contact_classname_sub = sub { + my $contact = shift; + my %hash = ( 'contactnum' => $contact->contact_contactnum ); + my $X_contact; + if ( $link eq 'cust_main' ) { + $X_contact = qsearchs('cust_contact', { %hash, 'custnum' => $contact->custnum } ); + } elsif ( $link eq 'prospect_main' ) { + $X_contact = qsearchs('prospect_contact', { %hash, 'prospectnum' => $contact->prospectnum } ); + } else { + die 'guru meditation #5555'; + } + $X_contact->contact_classname; +}; + +my @header = ( 'First', 'Last', 'Title', 'Email', 'Work Phone', 'Mobile Phone', 'Home Phone', 'Type' ); +my @fields = ( 'first', 'last', 'title', $email_sub, $work_phone_sub, $mobile_phone_sub, $home_phone_sub, $contact_classname_sub ); +my @links = ( '', '', '', '', '', '', '', '', ); my @report = ( -- 2.11.0