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', ],
11 FS::UI::Web::cust_header(),
15 sub { $_[0]->month. '/'. $_[0]->year; },
16 sub { $money_char. $_[0]->amount; },
18 \&FS::UI::Web::cust_fields,
25 ( map { $_ ne 'Cust. Status' ? $clink : '' }
26 FS::UI::Web::cust_header()
29 'align' => 'rrr'.FS::UI::Web::cust_aligns(),
34 FS::UI::Web::cust_colors(),
40 FS::UI::Web::cust_styles(),
47 LEFT JOIN cust_main USING ( custnum )
51 unless $FS::CurrentUser::CurrentUser->access_right('View customer tax exemptions');
55 #my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
56 #if ( $beginning || $ending ) {
57 # push @where, "_date >= $beginning",
62 if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
63 push @where, "agentnum = $1";
66 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
67 push @where, "cust_main.custnum = $1";
70 if ( $cgi->param('out') ) {
74 SELECT COUNT(*) FROM cust_main_county AS county_out
75 WHERE ( county_out.county = cust_main.county
76 OR ( county_out.county IS NULL AND cust_main.county = '' )
77 OR ( county_out.county = '' AND cust_main.county IS NULL)
78 OR ( county_out.county IS NULL AND cust_main.county IS NULL)
80 AND ( county_out.state = cust_main.state
81 OR ( county_out.state IS NULL AND cust_main.state = '' )
82 OR ( county_out.state = '' AND cust_main.state IS NULL )
83 OR ( county_out.state IS NULL AND cust_main.state IS NULL )
85 AND county_out.country = cust_main.country
86 AND county_out.tax > 0
90 } elsif ( $cgi->param('country' ) ) {
92 my $county = dbh->quote( $cgi->param('county') );
93 my $state = dbh->quote( $cgi->param('state') );
94 my $country = dbh->quote( $cgi->param('country') );
95 push @where, "( county = $county OR $county = '' )",
96 "( state = $state OR $state = '' )",
97 " country = $country";
98 push @where, 'taxclass = '. dbh->quote( $cgi->param('taxclass') )
99 if $cgi->param('taxclass');
103 my $where = scalar(@where) ? 'WHERE '.join(' AND ', @where) : '';
105 my $count_query = "SELECT COUNT(*), SUM(amount)".
106 " FROM cust_tax_exempt $join_cust $where";
109 'table' => 'cust_tax_exempt',
110 'addl_from' => $join_cust,
112 'select' => join(', ',
115 FS::UI::Web::cust_sql_fields(),
117 'extra_sql' => $where,
120 my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ];
122 my $conf = new FS::Conf;
123 my $money_char = $conf->config('money_char') || '$';