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 FS::UI::Web::join_cust_main('cust_bill', 'cust_pkg');
88 LEFT JOIN cust_pkg USING ( pkgnum )
89 LEFT JOIN part_pkg USING ( pkgpart )
93 JOIN cust_bill_pkg USING ( billpkgnum )
102 unless $FS::CurrentUser::CurrentUser->access_right('View customer tax exemptions');
104 my @where = ( "exempt_monthly = 'Y'" );
106 my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
107 if ( $beginning || $ending ) {
108 push @where, "_date >= $beginning",
113 if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
114 push @where, "cust_main.agentnum = $1";
117 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
118 push @where, "cust_main.custnum = $1";
121 if ( $cgi->param('country' ) ) {
123 my $county = dbh->quote( $cgi->param('county') );
124 my $state = dbh->quote( $cgi->param('state') );
125 my $country = dbh->quote( $cgi->param('country') );
126 push @where, "( county = $county OR $county = '' )",
127 "( state = $state OR $state = '' )",
128 " country = $country";
129 push @where, 'taxclass = '. dbh->quote( $cgi->param('taxclass') )
130 if $cgi->param('taxclass');
134 if ( $cgi->param('taxnum') ) {
136 my @taxnums = grep /^\d+$/, map { split(',', $_) } $cgi->param('taxnum');
137 if ( $cgi->param('taxnum') =~ /^([\d,]+)$/) {
138 push @where, "cust_tax_exempt_pkg.taxnum IN ($1)";
143 if ( $cgi->param('classnum') =~ /^(\d+)$/ ) {
144 push @where, "COALESCE(part_pkg.classnum,0) = $1";
147 my $where = scalar(@where) ? 'WHERE '.join(' AND ', @where) : '';
149 my $count_query = "SELECT COUNT(*), SUM(amount)".
150 " FROM cust_tax_exempt_pkg $join $where";
153 'table' => 'cust_tax_exempt_pkg',
154 'addl_from' => $join,
156 'select' => join(', ',
157 'cust_tax_exempt_pkg.*',
162 FS::UI::Web::cust_sql_fields(),
164 'extra_sql' => $where,
167 my $ilink = [ "${p}view/cust_bill.cgi?", 'invnum' ];
168 my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ];
170 my $conf = new FS::Conf;
171 my $money_char = $conf->config('money_char') || '$';