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 #prospect active inactive suspended cancelled
71 if ( grep { $cgi->param('status') eq $_ } FS::cust_main->statuses() ) {
72 my $method = $cgi->param('status'). '_sql';
73 #push @where, $class->$method();
74 push @where, FS::cust_main->$method();
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') || '$';