1 <% include( 'elements/browse.html',
2 'title' => "Tax classes $title",
3 'name_singular' => 'tax class',
4 'menubar' => \@menubar,
5 'html_init' => $html_init,
7 'table' => 'tax_class',
10 'order_by' => 'ORDER BY taxclass',
12 'count_query' => $count_query,
17 'link_onclicks' => \@link_onclicks,
18 'disable_maxselect' => 1,
24 my $conf = new FS::Conf;
30 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
37 my $onclick = 'return true;';
40 if ( $cgi->param('magic') eq 'omit' ) {
41 $cgi->param('omit') =~ /^([,\d]+)$/;
43 $title .= " unselected";
44 push @where, map { "taxclassnum != $_" } grep {$_} split( /,/, $omit );
45 $onclick = sub{ 'parent.doSelect('. shift->taxclassnum. '); return false;' }
50 if ( $cgi->param('datavendor') =~ /^([\w]+)$/ ) {
52 $title .= " for data vendor $1";
53 push @where, 'data_vendor = '. dbh->quote($data_vendor);
55 $cgi->delete('data_vendor');
58 if ( $cgi->param('magic') eq 'select')
60 $cgi->param('selected') =~ /^([,\d]*)$/;
63 my @clauses = map { "taxclassnum = $_" } grep {$_} split( /,/, $selected );
64 @where = scalar(@clauses) ? '( '. join(' OR ', @clauses) .')' : '1=0';
65 $onclick = sub{ 'parent.doUnselect('. shift->taxclassnum. '); return false;' } ;
67 $cgi->delete('selected');
71 push @menubar, 'View all tax classes' => $p.'browse/tax_class.html';
74 $cgi->param('dummy', 1);
76 #restore this so pagination works
77 $cgi->param('omit', $omit ) if $omit;
78 $cgi->param('selected', $selected ) if $selected;
79 $cgi->param('data_vendor', $data_vendor ) if $data_vendor;
81 my $where = scalar(@where) ? 'WHERE '. join( ' AND ', @where ) : '';
82 my $count_query = 'SELECT COUNT(*) FROM tax_class '. $where;
84 my $link = [ 'javascript:void(0);', sub{ ''; } ];
86 my @header = ( '', '', '' );
87 my @links = ( $link, $link, $link );
88 my @link_onclicks = ( $onclick, $onclick, $onclick );
90 my @fields = ( 'data_vendor', 'taxclass', 'description' );