+# Cache contact types
+my %classname =
+ map {$_->classnum => $_->classname}
+ qsearch(contact_class => {disabled => ''});
+
+# And now for something completly different:
+my @report = (
+ { label => 'First', field => sub { shift->contact_first }},
+ { label => 'Last', field => sub { shift->contact_last }},
+ { label => 'Title', field => sub { shift->contact_title }},
+ { label => 'E-Mail', field => sub { shift->contact_email_emailaddress }},
+ { label => 'Work Phone', field => $get_phone_sub->('Work') },
+ { label => 'Mobile Phone', field => $get_phone_sub->('Mobile') },
+ { label => 'Home Phone', field => $get_phone_sub->('Home') },
+ { label => 'Type',
+ field => sub {
+ my $rec = shift;
+ if ($rec->cust_contact_custnum) {
+ return $rec->cust_contact_classnum
+ ? $classname{$rec->cust_contact_classnum}
+ : undef;
+ } else {
+ return $rec->prospect_contact_classnum
+ ? $classname{$rec->prospect_contact_classnum}
+ : undef;
+ }
+ }},
+ { label => 'Send Invoices',
+ field => sub {
+ my $rec = shift;
+ return 'N/A' if $rec->prospect_contact_prospectnum;
+ $rec->cust_contact_invoice_dest ? 'Y' : 'N';
+ }},
+ { label => 'Send Messages',
+ field => sub {
+ my $rec = shift;
+ return 'N/A' if $rec->prospect_contact_prospectnum;
+ $rec->cust_contact_message_dest ? 'Y' : 'N';
+ }},
+ { label => 'Customer',
+ link => sub {
+ my $rec = shift;
+ $rec->prospect_contact_prospectnum
+ ? ["${p}view/prospect_main.html?", 'prospect_contact_prospectnum' ]
+ : ["${p}view/cust_main.cgi?", 'cust_contact_custnum' ];
+ },
+ field => sub {
+ my $rec = shift;
+ if ($rec->prospect_contact_prospectnum) {
+ return $rec->contact_company
+ || $rec->contact_last.' '.$rec->contact_first;
+ }
+ $rec->cust_main_company || $rec->cust_main_last.' '.$rec->cust_main_first;
+ }},
+ { label => 'Self-service',
+ field => sub {
+ my $rec = shift;
+ return 'N/A' if $rec->prospect_contact_prospectnum;
+ $rec->cust_contact_selfservice_access ? 'Y' : 'N';
+ }},
+ { label => 'Comment',
+ field => sub {
+ my $rec = shift;
+ $rec->prospect_contact_prospectnum
+ ? $rec->prospect_contact_comment
+ : $rec->cust_contact_comment;
+ }},
+);
+
+my (@header, @fields, @links);
+for my $col (@report) {
+ push @header, emt($col->{label});
+ push @fields, $col->{field};
+ push @links, ($col->{link} || "");
+}