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,
16 'color' => [ FS::UI::Web::cust_colors(),
19 'style' => [ FS::UI::Web::cust_styles(),
22 'align' => [ FS::UI::Web::cust_aligns(),
25 'links' => [ ( map { $_ ne 'Cust. Status' ? $link : '' }
26 FS::UI::Web::cust_header(
27 $cgi->param('cust_fields')
30 map { $_ eq 'num_referrals'
40 unless $FS::CurrentUser::CurrentUser->access_right('Advanced customer search');
44 #$search_hash{'query'} = $cgi->keywords;
48 agentnum salesnum status
49 address city county state zip country location_history
51 no_censustract with_geocode with_email tax no_tax POST no_POST
54 cust_fields flattened_pkgs
58 with_referrals referral_status
61 for my $param ( @scalars ) {
62 $search_hash{$param} = scalar( $cgi->param($param) )
63 if length($cgi->param($param));
67 for my $param (qw( classnum refnum pkg_classnum )) {
68 $search_hash{$param} = [ $cgi->param($param) ];
72 $search_hash{'contacts'} = {
73 map { $_ => $cgi->param($_), } grep { /^(contacts_*)/ && $cgi->param($_) } keys $cgi->Vars
77 my $params = $cgi->Vars;
78 $search_hash{'tagnum'} = [
79 map { /^tagnum(\d+)/ && $1 }
80 grep { /^tagnum(\d+)/ && $cgi->param($_) } keys %$params
87 foreach my $field (qw( signupdate birthdate spouse_birthdate anniversary_date )) {
89 my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, $field);
91 next if $beginning == 0 && $ending == 4294967295 && ( $field ne 'signupdate' || !defined($cgi->param('signuphour')) );
92 #or $disable{$cgi->param('status')}->{$field};
94 unless ( $field eq 'signupdate' ) {
99 my @ary = ( $beginning, $ending );
100 push @ary, scalar($cgi->param('signuphour')) if $field eq 'signupdate';
102 $search_hash{$field} = \@ary;
110 $search_hash{'current_balance'} =
111 [ FS::UI::Web::parse_lt_gt($cgi, 'current_balance') ];
117 my $sql_query = FS::cust_main::Search->search(\%search_hash);
118 my $count_query = delete($sql_query->{'count_query'});
119 my @extra_headers = @{ delete($sql_query->{'extra_headers'}) };
120 my @extra_fields = @{ delete($sql_query->{'extra_fields'}) };
122 my $link = [ "${p}view/cust_main.cgi?", 'custnum' ];
124 my $referral_link = [ "${p}search/cust_main.cgi?referral_custnum=", 'custnum' ];
132 if ( $FS::CurrentUser::CurrentUser->access_right('Bulk send customer notices') ) {
135 $uri->query_form( \%search_hash );
136 my $query = $uri->query;
138 push @$menubar, emt('Email a notice to these customers') =>
139 "${p}misc/email-customers.html?table=cust_main&$query",