v4 style
[freeside.git] / httemplate / search / cust_payby.html
1 <& elements/search.html,
2                   'title'       => emt('Customer stored payment information results'),
3                   'menubar'     => $menubar,
4                   'name'        => emt('cards or bank accounts'), #??
5                   'query'       => $sql_query,
6                   'count_query' => $count_query,
7                   'header'      => [ @headers,
8                                      FS::UI::Web::cust_header(
9                                        $cgi->param('cust_fields')
10                                      ),
11                                    ],
12                   'fields'      => [
13                     @fields,
14                     \&FS::UI::Web::cust_fields,
15                   ],
16                   'color'       => [ 
17                                      ( map '', @fields ),
18                                      FS::UI::Web::cust_colors(),
19                                    ],
20                   'style'       => [
21                                      ( map '', @fields ),
22                                      FS::UI::Web::cust_styles(),
23                                    ],
24                   'align'       => [ 
25                                      ( map '', @fields ),
26                                      FS::UI::Web::cust_aligns(),
27                                    ],
28                   'links'       => [
29                                      ( map '', @fields ),
30                                      ( map { $_ ne 'Cust. Status' ? $link : '' }
31                                            FS::UI::Web::cust_header(
32                                                       $cgi->param('cust_fields')
33                                                                    )
34                                      ),
35                                    ],
36 &>
37 <%init>
38
39 die "access denied"
40   unless $FS::CurrentUser::CurrentUser->access_right('Advanced customer search');
41
42 my %search_hash = ();
43
44 my @scalars = qw (
45   paydate_year paydate_month
46 );
47
48 for my $param ( @scalars ) {
49   $search_hash{$param} = scalar( $cgi->param($param) )
50     if length($cgi->param($param));
51 }
52
53 #lists
54 for my $param (qw( payby )) {
55   $search_hash{$param} = [ $cgi->param($param) ];
56 }
57
58 ###
59 # etc
60 ###
61
62 my $sql_query = FS::cust_payby->search_sql(\%search_hash);
63 my $count_query   = delete($sql_query->{'count_query'});
64
65 my @headers = ( 'Payment information',
66               );
67
68 my @fields = ( sub { my $cust_payby = shift;
69                      FS::payby->shortname( $cust_payby->payby ). ' '.
70                        $cust_payby->paymask;
71                    }
72              );
73
74 my $link = [ "${p}view/cust_main.cgi?", 'custnum' ];
75
76 ###
77 # email links
78 ###
79
80 my $menubar = [];
81
82 #XXX TODO
83 #if ( $FS::CurrentUser::CurrentUser->access_right('Bulk send customer notices') ) {
84 #
85 #  my $uri = new URI;
86 #  $uri->query_form( \%search_hash );
87 #  my $query = $uri->query;
88 #
89 #  push @$menubar, emt('Email a notice to these customers') =>
90 #                    "${p}misc/email-customers.html?table=cust_main&$query",
91 #
92 #}
93
94 </%init>