- <% $hashref->{country} %> |
-%
-%
-% my $j;
-% if ( $sup ) {
-% $sup--;
-% } else {
-%
-% #lookahead
-% for ( $j=1; $i+$j<@regions; $j++ ) {
-% last if $hashref->{country} ne $regions[$i+$j]->country
-% || $hashref->{state} ne $regions[$i+$j]->state
-% || $hashref->{tax} != $regions[$i+$j]->tax
-% || $hashref->{exempt_amount} != $regions[$i+$j]->exempt_amount
-% || $hashref->{setuptax} ne $regions[$i+$j]->setuptax
-% || $hashref->{recurtax} ne $regions[$i+$j]->recurtax;
-% }
-%
-% my $newsup=0;
-% if ( $j>1 && $i+$j+1 < @regions
-% && ( $hashref->{state} ne $regions[$i+$j+1]->state
-% || $hashref->{country} ne $regions[$i+$j+1]->country
-% )
-% && ( ! $i
-% || $hashref->{state} ne $regions[$i-1]->state
-% || $hashref->{country} ne $regions[$i-1]->country
-% )
-% ) {
-% $sup = $j-1;
-% } else {
-% $j = 1;
-% }
-%
-%
-
-
- <%
- $hashref->{state}
- ? ' BGCOLOR="#ffffff">'. $hashref->{state}
- : qq! BGCOLOR="#cccccc">(ALL) !.
- qq!expand country!
- %>
-% if ( $j>1 ) {
-
- collapse state
-% }
-
-
- |
-% }
-% # $sup=$newsup;
-
+Add new tax to selected
+
+END
+
+my $hashref = {};
+my $count_query = 'SELECT COUNT(*) FROM cust_main_county';
+if ( $country ) {
+ $hashref->{'country'} = $country;
+ $count_query .= ' WHERE country = '. dbh->quote($country);
+}
+if ( $state ) {
+ $hashref->{'state'} = $state;
+ $count_query .= ' AND state = '. dbh->quote($state);
+}
+if ( $county ) {
+ if ( $county eq '__NONE__' ) {
+ $hashref->{'county'} = '';
+ $count_query .= " AND ( county = '' OR county IS NULL ) ";
+ } else {
+ $hashref->{'county'} = $county;
+ $count_query .= ' AND county = '. dbh->quote($county);
+ }
+}
+if ( $taxclass ) {
+ $hashref->{'taxclass'} = $taxclass;
+ $count_query .= ( $count_query =~ /WHERE/i ? ' AND ' : ' WHERE ' ).
+ ' taxclass = '. dbh->quote($taxclass);
+}
+
+
+$cell_style = '';
+
+my @header = ( 'Country', 'State/Province', 'County',);
+my @header2 = ( '', '', '', );
+my @links = ( '', '', '', );
+my @link_onclicks = ( '', '', '', );
+my $align = 'lll';
+
+my @fields = (
+ sub { my $country = shift->country;
+ code2country($country). " ($country)";
+ },
+ sub { state_label($_[0]->state, $_[0]->country).
+ ( $_[0]->state
+ ? ''
+ : ' '. expand_link( desc => 'Add States',
+ row => $_[0],
+ label => 'add states',
+ )
+ )
+ },
+ sub { $_[0]->county || '(all) '.
+ expand_link( desc => 'Add Counties',
+ row => $_[0],
+ label => 'add counties',
+ )
+ },
+);
+
+my @color = (
+ '000000',
+ sub { shift->state ? '000000' : '999999' },
+ sub { shift->county ? '000000' : '999999' },
+);
+
+if ( $conf->exists('enable_taxclasses') ) {
+ push @header, qq!Tax class (add new)!;
+ push @header2, '(per-package classification)';
+ push @fields, sub { $_[0]->taxclass || '(all) '.
+ separate_taxclasses_link($_[0], 'Separate Taxclasses').
+ 'separate taxclasses'
+ };
+ push @color, sub { shift->taxclass ? '000000' : '999999' };
+ push @links, '';
+ push @link_onclicks, '';
+ $align .= 'l';
+}
+
+push @header,
+ '', #checkbox column
+ 'Tax name',
+ 'Rate', #'Tax',
+ 'Exemptions',
+ ;
+
+push @header2,
+ '',
+ '(printed on invoices)',
+ '',
+ '',
+ ;
+
+my $newregion = 1;
+my $cb_oldrow = '';
+my $cb_sub = sub {
+ my $cust_main_county = shift;
+
+ if ( $cb_oldrow ) {
+ if ( $cb_oldrow->country ne $cust_main_county->country
+ || $cb_oldrow->state ne $cust_main_county->state
+ || $cb_oldrow->county ne $cust_main_county->county
+ || $cb_oldrow->taxclass ne $cust_main_county->taxclass )
+ {
+ $newregion = 1;
+ } else {
+ $newregion = 0;
+ }
+
+ } else {
+ $newregion = 1;
+ }
+ $cb_oldrow = $cust_main_county;
+
+ if ( $newregion ) {
+ my $taxnum = $cust_main_county->taxnum;
+ qq!!;
+ } else {
+ '';
+ }
+};
+
+push @fields,
+ $cb_sub,
+ sub { shift->taxname || 'Tax' },
+ sub { shift->tax. '% (edit)' },
+ $exempt_sub,
+;
+
+push @color,
+ '000000',
+ sub { shift->taxname ? '000000' : '666666' },
+ sub { shift->tax ? '000000' : '666666' },
+ '000000',
+;
+
+$align .= 'clrl';
+
+my @cell_style = map $cell_style_sub, (1..scalar(@header));
+
+push @links, '', '', $edit_link, '';
+push @link_onclicks, '', '', $edit_onclick, '';
- {county} ) {
-%
- BGCOLOR="#ffffff"><% $hashref->{county} %>
-% } else {
-%
- BGCOLOR="#cccccc">(ALL)
-% if ( $hashref->{state} ) {
-
- expand state
-% }
-% }
-
- |
-
- {taxclass} ) {
-%
- BGCOLOR="#ffffff"><% $hashref->{taxclass} %>
-% } else {
-%
- BGCOLOR="#cccccc">(ALL)
-% if ( $enable_taxclasses ) {
-
- expand taxclasses
-% }
-% }
-
- |
-
- {taxname} ) {
-%
- BGCOLOR="#ffffff"><% $hashref->{taxname} %>
-% } else {
-%
- BGCOLOR="#cccccc">Tax
-% }
-
- |
-
- <% $hashref->{tax} %>% |
-
-
-% if ( $hashref->{exempt_amount} > 0 ) {
-
- $<% sprintf("%.2f", $hashref->{exempt_amount} ) %> per month
-% }
-% if ( $hashref->{setuptax} =~ /^Y$/i ) {
-
- Setup fee
-% }
-% if ( $hashref->{recurtax} =~ /^Y$/i ) {
-
- Recurring fee
-% }
-
-
- |
-
-
-% }
-
-
-
-
-<% include('/elements/footer.html') %>
-<%init>
-die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
%init>