Will things ever be the same again?
[freeside.git] / httemplate / browse / cust_main_county.cgi
1 <% include('/elements/header.html', "Tax Rate Listing", menubar(
2   'Edit tax rates' => $p. "edit/cust_main_county.cgi",
3 )) %>
4
5     Click on <u>expand country</u> to specify a country's tax rates by state.
6     <BR>Click on <u>expand state</u> to specify a state's tax rates by county.
7 %
8 %my $conf = new FS::Conf;
9 %my $enable_taxclasses = $conf->exists('enable_taxclasses');
10 %
11 %if ( $enable_taxclasses ) { 
12
13
14   <BR>Click on <u>expand taxclasses</u> to specify tax classes
15 % } 
16
17
18 <BR><BR>
19 <% table() %>
20
21   <TR>
22     <TH><FONT SIZE=-1>Country</FONT></TH>
23     <TH><FONT SIZE=-1>State</FONT></TH>
24     <TH>County</TH>
25     <TH>Taxclass<BR><FONT SIZE=-1>(per-package classification)</FONT></TH>
26     <TH>Tax name<BR><FONT SIZE=-1>(printed on invoices)</FONT></TH>
27     <TH><FONT SIZE=-1>Tax</FONT></TH>
28     <TH><FONT SIZE=-1>Exemption</TH>
29   </TR>
30 %
31 %my @regions = sort {    $a->country  cmp $b->country
32 %                     or $a->state    cmp $b->state
33 %                     or $a->county   cmp $b->county
34 %                     or $a->taxclass cmp $b->taxclass
35 %                   } qsearch('cust_main_county',{});
36 %
37 %my $sup=0;
38 %#foreach $cust_main_county ( @regions ) {
39 %for ( my $i=0; $i<@regions; $i++ ) { 
40 %  my $cust_main_county = $regions[$i];
41 %  my $hashref = $cust_main_county->hashref;
42 %
43 %  
44
45       <TR>
46         <TD BGCOLOR="#ffffff"><% $hashref->{country} %></TD>
47 %
48 %
49 %  my $j;
50 %  if ( $sup ) {
51 %    $sup--;
52 %  } else {
53 %
54 %    #lookahead
55 %    for ( $j=1; $i+$j<@regions; $j++ ) {
56 %      last if $hashref->{country} ne $regions[$i+$j]->country
57 %           || $hashref->{state} ne $regions[$i+$j]->state
58 %           || $hashref->{tax} != $regions[$i+$j]->tax
59 %           || $hashref->{exempt_amount} != $regions[$i+$j]->exempt_amount
60 %           || $hashref->{setuptax} ne $regions[$i+$j]->setuptax
61 %           || $hashref->{recurtax} ne $regions[$i+$j]->recurtax;
62 %    }
63 %
64 %    my $newsup=0;
65 %    if ( $j>1 && $i+$j+1 < @regions
66 %         && ( $hashref->{state} ne $regions[$i+$j+1]->state 
67 %              || $hashref->{country} ne $regions[$i+$j+1]->country
68 %              )
69 %         && ( ! $i
70 %              || $hashref->{state} ne $regions[$i-1]->state 
71 %              || $hashref->{country} ne $regions[$i-1]->country
72 %              )
73 %       ) {
74 %       $sup = $j-1;
75 %    } else {
76 %      $j = 1;
77 %    }
78 %
79 %    
80
81
82     <TD ROWSPAN=<% $j %><%
83       $hashref->{state}
84         ? ' BGCOLOR="#ffffff">'. $hashref->{state}
85         : qq! BGCOLOR="#cccccc">(ALL) <FONT SIZE=-1>!.
86           qq!<A HREF="${p}edit/cust_main_county-expand.cgi?!. $hashref->{taxnum}.
87           qq!">expand country</A></FONT>!
88       %>
89 % if ( $j>1 ) { 
90
91         <FONT SIZE=-1><A HREF="<% $p %>edit/process/cust_main_county-collapse.cgi?<% $hashref->{taxnum} %>">collapse state</A></FONT>
92 % } 
93
94
95     </TD>
96 % } 
97 % #  $sup=$newsup; 
98
99
100     <TD
101 % if ( $hashref->{county} ) {
102 %            
103  BGCOLOR="#ffffff"><% $hashref->{county} %>
104 % } else {
105 %            
106  BGCOLOR="#cccccc">(ALL)
107 % if ( $hashref->{state} ) { 
108
109                  <FONT SIZE=-1><A HREF="<% $p %>edit/cust_main_county-expand.cgi?<% $hashref->{taxnum} %>">expand state</A></FONT>
110 % } 
111 % } 
112
113     </TD>
114
115     <TD
116 % if ( $hashref->{taxclass} ) {
117 %            
118  BGCOLOR="#ffffff"><% $hashref->{taxclass} %>
119 % } else {
120 %            
121  BGCOLOR="#cccccc">(ALL)
122 % if ( $enable_taxclasses ) { 
123
124                  <FONT SIZE=-1><A HREF="<% $p %>edit/cust_main_county-expand.cgi?taxclass<% $hashref->{taxnum} %>">expand taxclasses</A></FONT>
125 % } 
126 % } 
127
128     </TD>
129
130     <TD
131 % if ( $hashref->{taxname} ) {
132 %            
133  BGCOLOR="#ffffff"><% $hashref->{taxname} %>
134 % } else {
135 %            
136  BGCOLOR="#cccccc">Tax
137 % } 
138
139     </TD>
140
141     <TD BGCOLOR="#ffffff"><% $hashref->{tax} %>%</TD>
142
143     <TD BGCOLOR="#ffffff">
144 % if ( $hashref->{exempt_amount} > 0 ) { 
145
146         $<% sprintf("%.2f", $hashref->{exempt_amount} ) %>&nbsp;per&nbsp;month<BR>
147 % } 
148 % if ( $hashref->{setuptax} =~ /^Y$/i ) { 
149
150         Setup&nbsp;fee<BR>
151 % } 
152 % if ( $hashref->{recurtax} =~ /^Y$/i ) { 
153
154         Recurring&nbsp;fee<BR>
155 % } 
156
157
158     </TD>
159
160   </TR>
161 % } 
162
163
164 </TABLE>
165
166 <% include('/elements/footer.html') %>