1 <& elements/search.html,
2 'title' => 'Tax exemptions',
3 'name' => 'tax exemptions',
5 'count_query' => $count_query,
6 'count_addl' => [ $money_char. '%.2f total', ],
14 FS::UI::Web::cust_header(),
18 sub { $_[0]->month. '/'. $_[0]->year; },
19 sub { $money_char. $_[0]->amount; },
22 $_[0]->billpkgnum. ': '.
25 : $_[0]->get('itemdesc')
29 ? $money_char. $_[0]->setup. ' setup'
32 ( $_[0]->setup > 0 && $_[0]->recur > 0
37 ? $money_char. $_[0]->recur. ' recur'
44 sub { time2str('%b %d %Y', shift->_date ) },
46 \&FS::UI::Web::cust_fields,
57 ( map { $_ ne 'Cust. Status' ? $clink : '' }
58 FS::UI::Web::cust_header()
61 'align' => 'rrrlrc'.FS::UI::Web::cust_aligns(), # 'rlrrrc',
69 FS::UI::Web::cust_colors(),
78 FS::UI::Web::cust_styles(),
84 JOIN cust_bill USING ( invnum )
85 LEFT JOIN cust_main USING ( custnum )
89 LEFT JOIN cust_pkg USING ( pkgnum )
90 LEFT JOIN part_pkg USING ( pkgpart )
94 JOIN cust_bill_pkg USING ( billpkgnum )
103 unless $FS::CurrentUser::CurrentUser->access_right('View customer tax exemptions');
107 my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
108 if ( $beginning || $ending ) {
109 push @where, "_date >= $beginning",
114 if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
115 push @where, "cust_main.agentnum = $1";
118 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
119 push @where, "cust_main.custnum = $1";
122 if ( $cgi->param('out') ) {
126 SELECT COUNT(*) FROM cust_main_county AS county_out
127 WHERE ( county_out.county = cust_main.county
128 OR ( county_out.county IS NULL AND cust_main.county = '' )
129 OR ( county_out.county = '' AND cust_main.county IS NULL)
130 OR ( county_out.county IS NULL AND cust_main.county IS NULL)
132 AND ( county_out.state = cust_main.state
133 OR ( county_out.state IS NULL AND cust_main.state = '' )
134 OR ( county_out.state = '' AND cust_main.state IS NULL )
135 OR ( county_out.state IS NULL AND cust_main.state IS NULL )
137 AND county_out.country = cust_main.country
138 AND county_out.tax > 0
142 } elsif ( $cgi->param('country' ) ) {
144 my $county = dbh->quote( $cgi->param('county') );
145 my $state = dbh->quote( $cgi->param('state') );
146 my $country = dbh->quote( $cgi->param('country') );
147 push @where, "( county = $county OR $county = '' )",
148 "( state = $state OR $state = '' )",
149 " country = $country";
150 push @where, 'taxclass = '. dbh->quote( $cgi->param('taxclass') )
151 if $cgi->param('taxclass');
155 my $where = scalar(@where) ? 'WHERE '.join(' AND ', @where) : '';
157 my $count_query = "SELECT COUNT(*), SUM(amount)".
158 " FROM cust_tax_exempt_pkg $join $where";
161 'table' => 'cust_tax_exempt_pkg',
162 'addl_from' => $join,
164 'select' => join(', ',
165 'cust_tax_exempt_pkg.*',
170 FS::UI::Web::cust_sql_fields(),
172 'extra_sql' => $where,
175 my $ilink = [ "${p}view/cust_bill.cgi?", 'invnum' ];
176 my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ];
178 my $conf = new FS::Conf;
179 my $money_char = $conf->config('money_char') || '$';