-my @header = ( 'First', 'Last', 'Title', );
-my @fields = ( 'first', 'last', 'title', );
-my @links = ( '', '', '' );
+my $email_sub = sub {
+ my $contact = shift;
+ my @contact_email = $contact->contact_email;
+ join(', ', map $_->emailaddress, @contact_email);
+};
+
+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', 'Type' );
+my @fields = ( 'first', 'last', 'title', $email_sub, $contact_classname_sub );
+my @links = ( '', '', '', '', '', );