1 <% include( 'elements/browse.html',
2 'title' => "Tax Rates $title",
3 'name_singular' => 'tax rate',
4 'menubar' => \@menubar,
5 'html_init' => $html_init,
9 'order_by' => 'ORDER BY geocode, taxclassnum',
11 'count_query' => $count_query,
13 'header2' => \@header2,
17 'cell_style' => \@cell_style,
19 'link_onclicks' => \@link_onclicks,
24 my $conf = new FS::Conf;
25 my $money_char = $conf->config('money_char') || '$';
27 my $exempt_sub = sub {
32 sprintf("$money_char%.2f per month", $tax_rate->exempt_amount )
33 if $tax_rate->exempt_amount > 0;
35 push @exempt, 'Setup fee'
36 if $tax_rate->setuptax =~ /^Y$/i;
38 push @exempt, 'Recurring fee'
39 if $tax_rate->recurtax =~ /^Y$/i;
41 [ map [ {'data'=>$_} ], @exempt ];
46 my $cell_style_sub = sub {
48 if ( $oldrow ne $row ) {
50 if ( $oldrow->country ne $row->country ) {
51 $cell_style = 'border-top:1px solid #000000';
52 } elsif ( $oldrow->state ne $row->state ) {
53 $cell_style = 'border-top:1px solid #cccccc'; #default?
54 } elsif ( $oldrow->state eq $row->state ) {
55 #$cell_style = 'border-top:dashed 1px dark gray';
56 $cell_style = 'border-top:1px dashed #cccccc';
64 my $select_link = [ 'javascript:void(0);', sub { ''; } ];
66 my $select_onclick = sub {
68 my $taxnum = $row->taxnum;
69 my $color = '#333399';
70 qq!overlib( OLiframeContent('${p}edit/tax_rate.html?$taxnum', 540, 420, 'edit_tax_rate_popup' ), CAPTION, 'Edit tax rate', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK, BGCOLOR, '$color', CGCOLOR, '$color' ); return false;!;
73 my $separate_taxclasses_link = sub {
75 my $taxnum = $row->taxnum;
76 my $url = "${p}edit/process/tax_rate-expand.cgi?taxclassnum=1;taxnum=$taxnum";
78 qq!<FONT SIZE="-1"><A HREF="$url">!;
85 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
90 "Click on <u>geocodes</u> to specify rates for a new area.";
91 $html_init .= "<BR>Click on <u>separate taxclasses</u> to specify taxes per taxclass.";
92 $html_init .= '<BR><BR>';
95 <SCRIPT TYPE="text/javascript" SRC="${fsurl}elements/overlibmws.js"></SCRIPT>
96 <SCRIPT TYPE="text/javascript" SRC="${fsurl}elements/overlibmws_iframe.js"></SCRIPT>
97 <SCRIPT TYPE="text/javascript" SRC="${fsurl}elements/overlibmws_draggable.js"></SCRIPT>
98 <SCRIPT TYPE="text/javascript" SRC="${fsurl}elements/iframecontentmws.js"></SCRIPT>
102 my $select_word = 'edit';
105 if ( $cgi->param('geocode') =~ /^(\w+)$/ ) {
109 $cgi->delete('geocode');
111 $title = " for $title" if $title;
113 my $taxclassnum = '';
114 if ( $cgi->param('taxclassnum') =~ /^(\d+)$/ ) {
116 my $tax_class = qsearchs('tax_class', {'taxclassnum' => $taxclassnum});
118 $title .= " for ". $tax_class->taxclass.
119 " (". $tax_class->description. ") tax class";
124 $cgi->delete('taxclassnum');
126 if ( $geocode || $taxclassnum ) {
127 push @menubar, 'View all tax rates' => $p.'browse/tax_rate.cgi';
130 $cgi->param('dummy', 1);
132 #restore this so pagination works
133 $cgi->param('geocode', $geocode) if $geocode;
134 $cgi->param('taxclassnum', $taxclassnum ) if $taxclassnum;
137 my $count_query = 'SELECT COUNT(*) FROM tax_rate';
139 $hashref->{'geocode'} = $geocode;
140 $count_query .= ' WHERE geocode = '. dbh->quote($geocode);
142 if ( $taxclassnum ) {
143 $hashref->{'taxclassnum'} = $taxclassnum;
144 $count_query .= ( $count_query =~ /WHERE/i ? ' AND ' : ' WHERE ' ).
145 ' taxclassnum = '. dbh->quote($taxclassnum);
151 my @header = ( 'Location Code', );
152 my @header2 = ( '', );
154 my @link_onclicks = ( '', );
165 push @header, qq!Tax class (<A HREF="${p}edit/tax_class.html">add new</A>)!;
166 push @header2, '(per-tax classification)';
167 push @fields, sub { $_[0]->taxclass_description || '(all) '.
168 &{$separate_taxclasses_link}($_[0], 'Separate Taxclasses').
169 'separate taxclasses</A></FONT>'
171 push @color, sub { shift->taxclass ? '000000' : '999999' };
173 push @link_onclicks, '';
176 push @header, 'Tax name',
181 push @header2, '(printed on invoices)',
187 sub { shift->taxname || 'Tax' },
188 sub { shift->tax. '% <FONT SIZE="-1">('. $select_word. ')</FONT>' },
193 sub { shift->taxname ? '000000' : '666666' },
194 sub { shift->tax ? '000000' : '666666' },
200 my @cell_style = map $cell_style_sub, (1..scalar(@header));
202 push @links, '', $select_link, '';
203 push @link_onclicks, '', $select_onclick, '';