This commit was generated by cvs2svn to compensate for changes in r10640,
[freeside.git] / httemplate / search / cust_main.html
1 <% include( 'elements/search.html',
2                   'title'       => 'Customer Search Results', 
3                   'menubar'     => $menubar,
4                   'name'        => 'customers',
5                   'query'       => $sql_query,
6                   'count_query' => $count_query,
7                   'header'      => [ FS::UI::Web::cust_header(
8                                        $cgi->param('cust_fields')
9                                      ),
10                                      @extra_headers,
11                                    ],
12                   'fields'      => [
13                     \&FS::UI::Web::cust_fields,
14                     @extra_fields,
15                   ],
16                   'color'       => [ FS::UI::Web::cust_colors(),
17                                      map '', @extra_fields
18                                    ],
19                   'style'       => [ FS::UI::Web::cust_styles(),
20                                      map '', @extra_fields
21                                    ],
22                   'align'       => [ FS::UI::Web::cust_aligns(),
23                                      map '', @extra_fields
24                                    ],
25                   'links'       => [ ( map { $_ ne 'Cust. Status' ? $link : '' }
26                                            FS::UI::Web::cust_header(
27                                                       $cgi->param('cust_fields')
28                                                                    )
29                                      ),
30                                      map '', @extra_fields
31                                    ],
32               )
33 %>
34 <%init>
35
36 die "access denied"
37   unless ( $FS::CurrentUser::CurrentUser->access_right('List customers') &&
38            $FS::CurrentUser::CurrentUser->access_right('List packages')
39          );
40
41 my %search_hash = ();
42
43 #$search_hash{'query'} = $cgi->keywords;
44
45 #scalars
46 my @scalars = qw (
47   agentnum status address paydate_year paydate_month invoice_terms
48   no_censustract with_geocode custbatch usernum
49   cancelled_pkgs
50   cust_fields flattened_pkgs
51 );
52
53 for my $param ( @scalars ) {
54   $search_hash{$param} = scalar( $cgi->param($param) )
55     if $cgi->param($param);
56 }
57
58 #lists
59 for my $param (qw( classnum payby tagnum )) {
60   $search_hash{$param} = [ $cgi->param($param) ];
61 }
62
63 ###
64 # parse dates
65 ###
66
67 foreach my $field (qw( signupdate )) {
68
69   my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, $field);
70
71   next if $beginning == 0 && $ending == 4294967295 && !defined($cgi->param('signuphour'));
72        #or $disable{$cgi->param('status')}->{$field};
73
74   $search_hash{$field} = [ $beginning, $ending, $cgi->param('signuphour') ];
75
76 }
77
78 ##
79 # amounts
80 ##
81
82 $search_hash{'current_balance'} =
83   [ FS::UI::Web::parse_lt_gt($cgi, 'current_balance') ];
84
85 ###
86 # etc
87 ###
88
89 my $sql_query = FS::cust_main::Search->search(\%search_hash);
90 my $count_query   = delete($sql_query->{'count_query'});
91 my @extra_headers = @{ delete($sql_query->{'extra_headers'}) };
92 my @extra_fields  = @{ delete($sql_query->{'extra_fields'})  };
93
94 my $link = [ "${p}view/cust_main.cgi?", 'custnum' ];
95
96 ###
97 # email links
98 ###
99
100 my $menubar = [];
101
102 if ( $FS::CurrentUser::CurrentUser->access_right('Bulk send customer notices') ) {
103
104   my $uri = new URI;
105   $uri->query_form( \%search_hash );
106   my $query = $uri->query;
107
108   push @$menubar, 'Email a notice to these customers' =>
109                     "${p}misc/email-customers.html?table=cust_main&$query",
110
111 }
112
113 </%init>