1 <& elements/search.html,
2 'title' => emt('Customer Search Results'),
4 'name' => emt('customers'),
6 'count_query' => $count_query,
7 'header' => [ FS::UI::Web::cust_header(
8 $cgi->param('cust_fields')
13 \&FS::UI::Web::cust_fields,
17 FS::UI::Web::cust_sort_fields(),
20 'color' => [ FS::UI::Web::cust_colors(),
23 'style' => [ FS::UI::Web::cust_styles(),
26 'align' => [ FS::UI::Web::cust_aligns(),
29 'links' => [ ( map { $_ ne 'Cust. Status' ? $link : '' }
30 FS::UI::Web::cust_header(
31 $cgi->param('cust_fields')
34 map { $_ eq 'num_referrals'
44 unless $FS::CurrentUser::CurrentUser->access_right('Advanced customer search');
48 #$search_hash{'query'} = $cgi->keywords;
52 agentnum salesnum status
53 address city county state zip country location_history
55 no_censustract with_geocode with_email tax no_tax POST no_POST
58 cust_fields flattened_pkgs
62 with_referrals referral_status
65 for my $param ( @scalars ) {
66 $search_hash{$param} = scalar( $cgi->param($param) )
67 if length($cgi->param($param));
71 for my $param (qw( classnum refnum pkg_classnum )) {
72 $search_hash{$param} = [ $cgi->param($param) ];
75 my $params = $cgi->Vars;
78 $search_hash{'contacts'} = {
79 map { $_ => $cgi->param($_), }
80 grep { /^(contacts_*)/ && $cgi->param($_) }
85 $search_hash{'tagnum'} = [
86 map { /^tagnum(\d+)/ && $1 }
87 grep { /^tagnum(\d+)/ && $cgi->param($_) }
95 foreach my $field (qw( signupdate birthdate spouse_birthdate anniversary_date )) {
97 my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, $field);
99 next if $beginning == 0 && $ending == 4294967295 && ( $field ne 'signupdate' || !defined($cgi->param('signuphour')) );
100 #or $disable{$cgi->param('status')}->{$field};
102 unless ( $field eq 'signupdate' ) {
107 my @ary = ( $beginning, $ending );
108 push @ary, scalar($cgi->param('signuphour')) if $field eq 'signupdate';
110 $search_hash{$field} = \@ary;
118 $search_hash{'current_balance'} =
119 [ FS::UI::Web::parse_lt_gt($cgi, 'current_balance') ];
125 my $sql_query = FS::cust_main::Search->search(\%search_hash);
126 my $count_query = delete($sql_query->{'count_query'});
127 my @extra_headers = @{ delete($sql_query->{'extra_headers'}) };
128 my @extra_fields = @{ delete($sql_query->{'extra_fields'}) };
129 my @extra_sort_fields = @{ delete($sql_query->{'extra_sort_fields'}) };
131 my $link = [ "${p}view/cust_main.cgi?", 'custnum' ];
133 my $referral_link = [ "${p}search/cust_main.cgi?referral_custnum=", 'custnum' ];
141 if ( $FS::CurrentUser::CurrentUser->access_right('Bulk send customer notices') ) {
143 # URI::query_from does not support hashref
144 # results in: ...&contacts=HASH(0x55e16cb81da8)&...
145 my %query_hash = %search_hash;
146 delete $query_hash{contacts}
147 if exists $query_hash{contacts} && ref $query_hash{contacts};
150 $uri->query_form( \%query_hash );
151 my $query = $uri->query;
153 push @$menubar, emt('Email a notice to these customers') =>
154 "${p}misc/email-customers.html?table=cust_main&$query",