add customer status to adv. customer report, template customer search for future...
[freeside.git] / httemplate / search / cust_main.html
1 <% include( 'elements/search.html',
2                   'title'       => 'Customer Search Results', 
3                   'name'        => 'customers',
4                   'query'       => $sql_query,
5                   'count_query' => $count_query,
6                   'header'      => [ FS::UI::Web::cust_header(
7                                        $cgi->param('cust_fields')
8                                      ),
9                                      @extra_headers,
10                                    ],
11                   'fields'      => [
12                     \&FS::UI::Web::cust_fields,
13                     @extra_fields,
14                   ],
15                   'color'       => [ FS::UI::Web::cust_colors(),
16                                      map '', @extra_fields
17                                    ],
18                   'style'       => [ FS::UI::Web::cust_styles(),
19                                      map '', @extra_fields
20                                    ],
21                   'align'       => [ FS::UI::Web::cust_aligns(),
22                                      map '', @extra_fields
23                                    ],
24                   'links'       => [ ( map { $_ ne 'Cust. Status' ? $link : '' }
25                                            FS::UI::Web::cust_header(
26                                                       $cgi->param('cust_fields')
27                                                                    )
28                                      ),
29                                      map '', @extra_fields
30                                    ],
31               )
32 %>
33 <%once>
34
35 my $link = [ "${p}view/cust_main.cgi?", 'custnum' ];
36
37 </%once>
38 <%init>
39
40 die "access denied"
41   unless ( $FS::CurrentUser::CurrentUser->access_right('List customers') &&
42            $FS::CurrentUser::CurrentUser->access_right('List packages')
43          );
44
45 my %search_hash = ();
46
47 #$search_hash{'query'} = $cgi->keywords;
48
49 #scalars
50 for my $param (qw( agentnum status cancelled_pkgs cust_fields flattened_pkgs)) {
51   $search_hash{$param} = scalar( $cgi->param($param) )
52     if $cgi->param($param);
53 }
54
55 #lists
56 for my $param (qw( payby )) {
57   $search_hash{$param} = [ $cgi->param($param) ]
58     if $cgi->param($param);
59 }
60
61 ###
62 # parse dates
63 ###
64
65 foreach my $field (qw( signupdate )) {
66
67   my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, $field);
68
69   next if $beginning == 0 && $ending == 4294967295;
70        #or $disable{$cgi->param('status')}->{$field};
71
72   $search_hash{$field} = [ $beginning, $ending ];
73
74 }
75
76 ##
77 # amounts
78 ##
79
80 $search_hash{'current_balance'} =
81   [ FS::UI::Web::parse_lt_gt($cgi, 'current_balance') ];
82
83 ###
84 # etc
85 ###
86
87 my $sql_query = FS::cust_main->search_sql(\%search_hash);
88 my $count_query   = delete($sql_query->{'count_query'});
89 my @extra_headers = @{ delete($sql_query->{'extra_headers'}) };
90 my @extra_fields  = @{ delete($sql_query->{'extra_fields'})  };
91
92 </%init>