diff options
author | Christopher Burger <burgerc@freeside.biz> | 2019-05-22 12:58:05 -0400 |
---|---|---|
committer | Christopher Burger <burgerc@freeside.biz> | 2019-05-22 12:58:05 -0400 |
commit | a98de57aee063b3ff737c283336f83b2e50e14a8 (patch) | |
tree | ffeec186cc5b5798401ce9f51d5011084a76bb0c /httemplate | |
parent | 7bfdea32633df161273631bcdc6b33b93867f5b2 (diff) |
RT 77532 - added contact phone numbers to advanced customer report
Diffstat (limited to 'httemplate')
-rw-r--r-- | httemplate/elements/select-cust-fields.html | 10 | ||||
-rw-r--r-- | httemplate/elements/tr-select-cust-fields.html | 9 | ||||
-rw-r--r-- | httemplate/search/contact.html | 18 | ||||
-rw-r--r-- | httemplate/search/elements/options_cust_contacts.html | 17 |
4 files changed, 29 insertions, 25 deletions
diff --git a/httemplate/elements/select-cust-fields.html b/httemplate/elements/select-cust-fields.html index 5e3063877..7396808b1 100644 --- a/httemplate/elements/select-cust-fields.html +++ b/httemplate/elements/select-cust-fields.html @@ -1,8 +1,14 @@ <%init> my( $cust_fields, %opt ) = @_; - use FS::ConfDefaults; - $opt{'avail_fields'} ||= [ FS::ConfDefaults->cust_fields_avail() ]; + my @fields = FS::ConfDefaults->cust_fields_avail(); + my $contact_phone_list; + foreach my $phone_type ( qsearch({table=>'phone_type', order_by=>'weight'}) ) { + $contact_phone_list .= " | Contact ".$phone_type->typename." phone(s)"; + } + @fields = map {s/\| Contact phone\(s\)/$contact_phone_list/g; $_; } @fields; + + $opt{'avail_fields'} ||= [ @fields ]; tie my %hash, 'Tie::IxHash', @{ $opt{'avail_fields'} }; </%init> diff --git a/httemplate/elements/tr-select-cust-fields.html b/httemplate/elements/tr-select-cust-fields.html index dd8513316..62b8144e3 100644 --- a/httemplate/elements/tr-select-cust-fields.html +++ b/httemplate/elements/tr-select-cust-fields.html @@ -6,6 +6,13 @@ my( $cust_fields, %opt ) = @_; -$opt{'avail_fields'} ||= [ FS::ConfDefaults->cust_fields_avail() ]; +my @fields = FS::ConfDefaults->cust_fields_avail(); +my $contact_phone_list; +foreach my $phone_type ( qsearch({table=>'phone_type', order_by=>'weight'}) ) { + $contact_phone_list .= " | Contact ".$phone_type->typename." phone(s)"; +} +@fields = map {s/\| Contact phone\(s\)/$contact_phone_list/g; $_; } @fields; + +$opt{'avail_fields'} ||= [ @fields ]; </%init> diff --git a/httemplate/search/contact.html b/httemplate/search/contact.html index 24cb237c3..0f2b283b5 100644 --- a/httemplate/search/contact.html +++ b/httemplate/search/contact.html @@ -38,7 +38,6 @@ my $classnum_null = grep{ $_ eq 0 } $cgi->param('classnum'); # Catch destination values from dest multi-checkbox, default to message # irrelevant to prospect contacts my @dest = grep{ /^(message|invoice)$/ } $cgi->param('dest'); -@dest = ('message') unless @dest; # Cache the contact_class table my %classname = @@ -125,7 +124,7 @@ if (@classnum || $classnum_null) { if (@dest && $link eq 'cust_main') { my @stm; push @stm, "cust_contact.${_}_dest IS NOT NULL" for @dest; - $extra_sql .= "\nAND (".join(' OR ',@stm).') '; + $extra_sql .= "\nAND (".join(' AND ',@stm).') '; } if ($DEBUG) { @@ -141,20 +140,23 @@ if ($DEBUG) { # Prepare to display phone numbers # adds 3 additional queries per table record :-( -my %phonetype = (qw/1 Work 2 Home 3 Mobile 4 Fax/); -my %phoneid = (qw/Work 1 Home 2 Mobile 3 Fax 4/); my $get_phone_sub = sub { my $type = shift; return sub { my $rec = shift; my @p = qsearch('contact_phone', { contactnum => $rec->contact_contactnum, - phonetypenum => $phoneid{$type} + phonetypenum => $type, }); - @p ? (join ', ',map{$_->phonenum} @p) : undef; + @p ? (join ', ',map{$_->phonenum_pretty} @p) : undef; }; }; +my @phones; +foreach my $phone_type ( qsearch({table=>'phone_type', order_by=>'weight'}) ) { + push @phones, { label => $phone_type->typename.' Phone', field => $get_phone_sub->($phone_type->phonetypenum), }; +} + # Cache contact types my %classname = map {$_->classnum => $_->classname} @@ -166,9 +168,7 @@ my @report = ( { label => 'Last', field => 'contact_last' }, { label => 'Title', field => 'contact_title' }, { label => 'E-Mail', field => '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') }, + @phones, { label => 'Type', field => sub { my $rec = shift; diff --git a/httemplate/search/elements/options_cust_contacts.html b/httemplate/search/elements/options_cust_contacts.html index cfbf834b0..8a6b76913 100644 --- a/httemplate/search/elements/options_cust_contacts.html +++ b/httemplate/search/elements/options_cust_contacts.html @@ -12,21 +12,12 @@ <TH ALIGN="right" VALIGN="center"><% mt('Email') |h %></TH> <TD><INPUT TYPE="text" NAME="<%$field_prefix%>email" SIZE=54></TD> </TR> - - <TR> - <TH ALIGN="right" VALIGN="center"><% mt('Home Phone') |h %></TH> - <TD><INPUT TYPE="text" NAME="<%$field_prefix%>homephone" SIZE=54></TD> - </TR> - - <TR> - <TH ALIGN="right" VALIGN="center"><% mt('Work Phone') |h %></TH> - <TD><INPUT TYPE="text" NAME="<%$field_prefix%>workphone" SIZE=54></TD> - </TR> - +% foreach my $phone_type ( qsearch({table=>'phone_type', order_by=>'weight'}) ) { <TR> - <TH ALIGN="right" VALIGN="center"><% mt('Mobile Phone') |h %></TH> - <TD><INPUT TYPE="text" NAME="<%$field_prefix%>mobilephone" SIZE=54></TD> + <TH ALIGN="right" VALIGN="center"><% $phone_type->typename. ' Phone' |h %></TH> + <TD><INPUT TYPE="text" NAME="<% $field_prefix %>phonetypenum<% $phone_type->phonetypenum %>" SIZE=54></TD> </TR> +% } <%init> |