get rid of header foo in individual templates
[freeside.git] / httemplate / browse / cust_main_county.cgi
1 <%
2 #<!-- $Id: cust_main_county.cgi,v 1.5 2001-10-30 14:54:07 ivan Exp $ -->
3
4 use strict;
5 use vars qw( $cgi $p $cust_main_county );
6 use CGI;
7 use CGI::Carp qw(fatalsToBrowser);
8 use FS::UID qw(cgisuidsetup);
9 use FS::Record qw(qsearch qsearchs);
10 use FS::CGI qw(header menubar popurl table);
11 use FS::cust_main_county;
12
13 $cgi = new CGI;
14
15 &cgisuidsetup($cgi);
16
17 $p = popurl(2);
18
19 print header("Tax Rate Listing", menubar(
20   'Main Menu' => $p,
21   'Edit tax rates' => $p. "edit/cust_main_county.cgi",
22 )),<<END;
23     Click on <u>expand country</u> to specify a country's tax rates by state.
24     <BR>Click on <u>expand state</u> to specify a state's tax rates by county.
25     <BR><BR>
26 END
27 print &table(), <<END;
28       <TR>
29         <TH><FONT SIZE=-1>Country</FONT></TH>
30         <TH><FONT SIZE=-1>State</FONT></TH>
31         <TH>County</TH>
32         <TH><FONT SIZE=-1>Tax</FONT></TH>
33       </TR>
34 END
35
36 my @regions = sort {    $a->country cmp $b->country
37                      or $a->state   cmp $b->state
38                      or $a->county  cmp $b->county
39                    } qsearch('cust_main_county',{});
40
41 my $sup=0;
42 #foreach $cust_main_county ( @regions ) {
43 for ( my $i=0; $i<@regions; $i++ ) { 
44   my $cust_main_county = $regions[$i];
45   my $hashref = $cust_main_county->hashref;
46   print <<END;
47       <TR>
48         <TD>$hashref->{country}</TD>
49 END
50
51   my $j;
52   if ( $sup ) {
53     $sup--;
54   } else {
55
56     #lookahead
57     for ( $j=1; $i+$j<@regions; $j++ ) {
58       last if $hashref->{country} ne $regions[$i+$j]->country
59            || $hashref->{state} ne $regions[$i+$j]->state
60            || $hashref->{tax} != $regions[$i+$j]->tax;
61     }
62
63     my $newsup=0;
64     if ( $j>1 && $i+$j+1 < @regions
65          && ( $hashref->{state} ne $regions[$i+$j+1]->state 
66               || $hashref->{country} ne $regions[$i+$j+1]->country
67               )
68          && ( ! $i
69               || $hashref->{state} ne $regions[$i-1]->state 
70               || $hashref->{country} ne $regions[$i-1]->country
71               )
72        ) {
73        $sup = $j-1;
74     } else {
75       $j = 1;
76     }
77
78     print "<TD ROWSPAN=$j>", $hashref->{state}
79         ? $hashref->{state}
80         : qq!(ALL) <FONT SIZE=-1>!.
81           qq!<A HREF="${p}edit/cust_main_county-expand.cgi?!. $hashref->{taxnum}.
82           qq!">expand country</A></FONT>!;
83
84     print qq! <FONT SIZE=-1><A HREF="${p}edit/process/cust_main_county-collapse.cgi?!. $hashref->{taxnum}. qq!">collapse state</A></FONT>! if $j>1;
85
86     print "</TD>";
87   }
88
89 #  $sup=$newsup;
90
91   print "<TD>";
92   if ( $hashref->{county} ) {
93     print $hashref->{county};
94   } else {
95     print "(ALL)";
96     if ( $hashref->{state} ) {
97       print qq!<FONT SIZE=-1>!.
98           qq!<A HREF="${p}edit/cust_main_county-expand.cgi?!. $hashref->{taxnum}.
99           qq!">expand state</A></FONT>!;
100     }
101   }
102   print "</TD>";
103
104   print <<END;
105         <TD>$hashref->{tax}%</TD>
106       </TR>
107 END
108
109 }
110
111 print <<END;
112     </TABLE>
113     </CENTER>
114   </BODY>
115 </HTML>
116 END
117
118 %>