3 my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
6 JOIN cust_bill USING ( invnum )
7 LEFT JOIN cust_main USING ( custnum )
11 LEFT JOIN cust_pkg USING ( pkgnum )
12 LEFT JOIN part_pkg USING ( pkgpart )
16 JOIN cust_bill_pkg USING ( billpkgnum )
22 WHERE _date >= $beginning AND _date <= $ending
26 if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
27 $where .= " AND agentnum = $1 ";
30 if ( $cgi->param('out') ) {
34 SELECT COUNT(*) FROM cust_main_county AS county_out
35 WHERE ( county_out.county = cust_main.county
36 OR ( county_out.county IS NULL AND cust_main.county = '' )
37 OR ( county_out.county = '' AND cust_main.county IS NULL)
38 OR ( county_out.county IS NULL AND cust_main.county IS NULL)
40 AND ( county_out.state = cust_main.state
41 OR ( county_out.state IS NULL AND cust_main.state = '' )
42 OR ( county_out.state = '' AND cust_main.state IS NULL )
43 OR ( county_out.state IS NULL AND cust_main.state IS NULL )
45 AND county_out.country = cust_main.country
46 AND county_out.tax > 0
50 } elsif ( $cgi->param('country' ) ) {
52 my $county = dbh->quote( $cgi->param('county') );
53 my $state = dbh->quote( $cgi->param('state') );
54 my $country = dbh->quote( $cgi->param('country') );
56 AND ( county = $county OR $county = '' )
57 AND ( state = $state OR $state = '' )
58 AND country = $country
60 $where .= ' AND taxclass = '. dbh->quote( $cgi->param('taxclass') )
61 if $cgi->param('taxclass');
65 my $count_query = "SELECT COUNT(*), SUM(amount)".
66 " FROM cust_tax_exempt_pkg $join $where";
69 'table' => 'cust_tax_exempt_pkg',
72 'select' => join(', ',
73 'cust_tax_exempt_pkg.*',
78 FS::UI::Web::cust_sql_fields(),
80 'extra_sql' => $where,
83 my $ilink = [ "${p}view/cust_bill.cgi?", 'invnum' ];
84 my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ];
86 my $conf = new FS::Conf;
87 my $money_char = $conf->config('money_char') || '$';
89 %><%= include( 'elements/search.html',
90 'title' => 'Tax exemptions',
91 'name' => 'tax exemptions',
93 'count_query' => $count_query,
94 'count_addl' => [ $money_char. '%.2f total', ],
106 FS::UI::Web::cust_header(),
110 sub { $_[0]->month. '/'. $_[0]->year; },
113 #sub { $_[0]->pkgnum > 0
114 # ? $_[0]->get('pkg')
115 # : $_[0]->get('itemdesc')
117 ##strikethrough or "N/A ($amount)" or something these when
118 ## they're not applicable to pkg_tax search
119 #sub { sprintf($money_char.'%.2f', shift->setup ) },
120 #sub { sprintf($money_char.'%.2f', shift->recur ) },
122 #sub { time2str('%b %d %Y', shift->_date ) },
124 \&FS::UI::Web::cust_fields,
138 ( map { $clink } FS::UI::Web::cust_header() ),
140 'align' => 'rrr', # 'rlrrrc',