first part of ACL and re-skinning work and some other small stuff
[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 <%
9 my $conf = new FS::Conf;
10 my $enable_taxclasses = $conf->exists('enable_taxclasses');
11
12 if ( $enable_taxclasses ) { %>
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 <%
32 my @regions = sort {    $a->country  cmp $b->country
33                      or $a->state    cmp $b->state
34                      or $a->county   cmp $b->county
35                      or $a->taxclass cmp $b->taxclass
36                    } qsearch('cust_main_county',{});
37
38 my $sup=0;
39 #foreach $cust_main_county ( @regions ) {
40 for ( my $i=0; $i<@regions; $i++ ) { 
41   my $cust_main_county = $regions[$i];
42   my $hashref = $cust_main_county->hashref;
43
44   %>
45       <TR>
46         <TD BGCOLOR="#ffffff"><%= $hashref->{country} %></TD>
47
48   <%
49
50   my $j;
51   if ( $sup ) {
52     $sup--;
53   } else {
54
55     #lookahead
56     for ( $j=1; $i+$j<@regions; $j++ ) {
57       last if $hashref->{country} ne $regions[$i+$j]->country
58            || $hashref->{state} ne $regions[$i+$j]->state
59            || $hashref->{tax} != $regions[$i+$j]->tax
60            || $hashref->{exempt_amount} != $regions[$i+$j]->exempt_amount
61            || $hashref->{setuptax} ne $regions[$i+$j]->setuptax
62            || $hashref->{recurtax} ne $regions[$i+$j]->recurtax;
63     }
64
65     my $newsup=0;
66     if ( $j>1 && $i+$j+1 < @regions
67          && ( $hashref->{state} ne $regions[$i+$j+1]->state 
68               || $hashref->{country} ne $regions[$i+$j+1]->country
69               )
70          && ( ! $i
71               || $hashref->{state} ne $regions[$i-1]->state 
72               || $hashref->{country} ne $regions[$i-1]->country
73               )
74        ) {
75        $sup = $j-1;
76     } else {
77       $j = 1;
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         <FONT SIZE=-1><A HREF="<%= $p %>edit/process/cust_main_county-collapse.cgi?<%= $hashref->{taxnum} %>">collapse state</A></FONT>
91       <% } %>
92
93     </TD>
94   <% } %>
95
96 <% #  $sup=$newsup; %>
97
98     <TD<% if ( $hashref->{county} ) {
99             %> BGCOLOR="#ffffff"><%= $hashref->{county} %>
100        <% } else {
101             %> BGCOLOR="#cccccc">(ALL)
102             <% if ( $hashref->{state} ) { %>
103                  <FONT SIZE=-1><A HREF="<%= $p %>edit/cust_main_county-expand.cgi?<%= $hashref->{taxnum} %>">expand state</A></FONT>
104             <% } %>
105        <% } %>
106     </TD>
107
108     <TD<% if ( $hashref->{taxclass} ) {
109             %> BGCOLOR="#ffffff"><%= $hashref->{taxclass} %>
110        <% } else {
111             %> BGCOLOR="#cccccc">(ALL)
112             <% if ( $enable_taxclasses ) { %>
113                  <FONT SIZE=-1><A HREF="<%= $p %>edit/cust_main_county-expand.cgi?taxclass<%= $hashref->{taxnum} %>">expand taxclasses</A></FONT>
114             <% } %>
115        <% } %>
116     </TD>
117
118     <TD<% if ( $hashref->{taxname} ) {
119             %> BGCOLOR="#ffffff"><%= $hashref->{taxname} %>
120        <% } else {
121             %> BGCOLOR="#cccccc">Tax
122        <% } %>
123     </TD>
124
125     <TD BGCOLOR="#ffffff"><%= $hashref->{tax} %>%</TD>
126
127     <TD BGCOLOR="#ffffff">
128
129       <% if ( $hashref->{exempt_amount} > 0 ) { %>
130         $<%= sprintf("%.2f", $hashref->{exempt_amount} ) %>&nbsp;per&nbsp;month<BR>
131       <% } %>
132
133       <% if ( $hashref->{setuptax} =~ /^Y$/i ) { %>
134         Setup&nbsp;fee<BR>
135       <% } %>
136       
137       <% if ( $hashref->{recurtax} =~ /^Y$/i ) { %>
138         Recurring&nbsp;fee<BR>
139       <% } %>
140
141     </TD>
142
143   </TR>
144
145 <% } %>
146
147 </TABLE>
148
149 <%= include('/elements/footer.html') %>