RT 77532 - added contact phone numbers to advanced customer report
[freeside.git] / FS / FS / cust_main.pm
index 03300a0..2a3a753 100644 (file)
@@ -3682,6 +3682,31 @@ sub contact_list_email {
   values %emails;
 }
 
+=item contact_list_name_phones
+
+Returns a list of contact phone numbers.
+{ phonetypenum => '1', phonenum => 'xxxxxxxxxx', first => 'firstname', last => 'lastname', countrycode => '1' }
+=cut
+ sub contact_list_name_phones {
+   my $self = shift;
+   my $phone_type = shift;
+   warn "$me contact_list_phones" if $DEBUG;
+   return () if !$self->custnum; # not yet inserted
+   return map { $_ }
+     qsearch({
+         table     => 'contact',
+         select    => 'phonetypenum, phonenum, first, last, countrycode',
+         addl_from => ' JOIN contact_phone USING (contactnum)',
+         hashref   => { 'custnum' => $self->custnum, 'phonetypenum' => $phone_type, },
+         order_by  => 'ORDER BY contactnum DESC',
+         extra_sql => '',
+     });
+ }
+
 =item referral_custnum_cust_main
 
 Returns the customer who referred this customer (or the empty string, if