1 <% include( '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 { $money_char. $_[0]->amount; },
19 sub { time2str('%b %d %Y', shift->_date ) },
21 \&FS::UI::Web::cust_fields,
30 ( map { $_ ne 'Cust. Status' ? $clink : '' }
31 FS::UI::Web::cust_header()
34 'align' => 'rrrlrc'.FS::UI::Web::cust_aligns(), # 'rlrrrc',
40 FS::UI::Web::cust_colors(),
47 FS::UI::Web::cust_styles(),
54 LEFT JOIN cust_main USING ( custnum )
58 unless $FS::CurrentUser::CurrentUser->access_right('View customer tax exemptions');
62 my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
63 if ( $beginning || $ending ) {
64 push @where, "_date >= $beginning",
69 if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
70 push @where, "agentnum = $1";
73 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
74 push @where, "cust_main.custnum = $1";
77 if ( $cgi->param('out') ) {
81 SELECT COUNT(*) FROM cust_main_county AS county_out
82 WHERE ( county_out.county = cust_main.county
83 OR ( county_out.county IS NULL AND cust_main.county = '' )
84 OR ( county_out.county = '' AND cust_main.county IS NULL)
85 OR ( county_out.county IS NULL AND cust_main.county IS NULL)
87 AND ( county_out.state = cust_main.state
88 OR ( county_out.state IS NULL AND cust_main.state = '' )
89 OR ( county_out.state = '' AND cust_main.state IS NULL )
90 OR ( county_out.state IS NULL AND cust_main.state IS NULL )
92 AND county_out.country = cust_main.country
93 AND county_out.tax > 0
97 } elsif ( $cgi->param('country' ) ) {
99 my $county = dbh->quote( $cgi->param('county') );
100 my $state = dbh->quote( $cgi->param('state') );
101 my $country = dbh->quote( $cgi->param('country') );
102 push @where, "( county = $county OR $county = '' )",
103 "( state = $state OR $state = '' )",
104 " country = $country";
105 push @where, 'taxclass = '. dbh->quote( $cgi->param('taxclass') )
106 if $cgi->param('taxclass');
110 my $where = scalar(@where) ? 'WHERE '.join(' AND ', @where) : '';
112 my $count_query = "SELECT COUNT(*), SUM(amount)".
113 " FROM cust_tax_exempt $join_cust $where";
116 'table' => 'cust_tax_exempt',
117 'addl_from' => $join_cust,
119 'select' => join(', ',
122 FS::UI::Web::cust_sql_fields(),
124 'extra_sql' => $where,
127 my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ];
129 my $conf = new FS::Conf;
130 my $money_char = $conf->config('money_char') || '$';