1 <& elements/search.html,
2 'title' => 'Legacy tax exemptions',
3 'name' => 'legacy tax exemptions',
5 'count_query' => $count_query,
6 'count_addl' => [ $money_char. '%.2f total', ],
12 FS::UI::Web::cust_header(),
16 sub { $_[0]->month. '/'. $_[0]->year; },
17 sub { my $h = $_[0]->h_search('insert');
18 $h ? time2str('%L/%d/%Y', $h->history_date ) : ''
20 sub { $money_char. $_[0]->amount; },
22 \&FS::UI::Web::cust_fields,
30 ( map { $_ ne 'Cust. Status' ? $clink : '' }
31 FS::UI::Web::cust_header()
34 'align' => 'rrrr'.FS::UI::Web::cust_aligns(),
40 FS::UI::Web::cust_colors(),
47 FS::UI::Web::cust_styles(),
53 my $join_cust = FS::UI::Web::join_cust_main('cust_tax_exempt');
56 unless $FS::CurrentUser::CurrentUser->access_right('View customer tax exemptions');
60 #my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
61 #if ( $beginning || $ending ) {
62 # push @where, "_date >= $beginning",
66 if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
67 push @where, "agentnum = $1";
70 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
71 push @where, "cust_main.custnum = $1";
74 #prospect active inactive suspended cancelled
75 if ( grep { $cgi->param('status') eq $_ } FS::cust_main->statuses() ) {
76 my $method = $cgi->param('status'). '_sql';
77 #push @where, $class->$method();
78 push @where, FS::cust_main->$method();
81 if ( $cgi->param('out') ) {
85 SELECT COUNT(*) FROM cust_main_county AS county_out
86 WHERE ( county_out.county = cust_main.county
87 OR ( county_out.county IS NULL AND cust_main.county = '' )
88 OR ( county_out.county = '' AND cust_main.county IS NULL)
89 OR ( county_out.county IS NULL AND cust_main.county IS NULL)
91 AND ( county_out.state = cust_main.state
92 OR ( county_out.state IS NULL AND cust_main.state = '' )
93 OR ( county_out.state = '' AND cust_main.state IS NULL )
94 OR ( county_out.state IS NULL AND cust_main.state IS NULL )
96 AND county_out.country = cust_main.country
97 AND county_out.tax > 0
101 } elsif ( $cgi->param('country' ) ) {
103 my $county = dbh->quote( $cgi->param('county') );
104 my $state = dbh->quote( $cgi->param('state') );
105 my $country = dbh->quote( $cgi->param('country') );
106 push @where, "( county = $county OR $county = '' )",
107 "( state = $state OR $state = '' )",
108 " country = $country";
109 push @where, 'taxclass = '. dbh->quote( $cgi->param('taxclass') )
110 if $cgi->param('taxclass');
114 my $where = scalar(@where) ? 'WHERE '.join(' AND ', @where) : '';
116 my $count_query = "SELECT COUNT(*), SUM(amount)".
117 " FROM cust_tax_exempt $join_cust $where";
120 'table' => 'cust_tax_exempt',
121 'addl_from' => $join_cust,
123 'select' => join(', ',
126 FS::UI::Web::cust_sql_fields(),
128 'extra_sql' => $where,
131 my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ];
133 my $conf = new FS::Conf;
134 my $money_char = $conf->config('money_char') || '$';