<% # use strict; use vars qw( $cgi $p $cust_main_county ); use CGI; use CGI::Carp qw(fatalsToBrowser); use FS::UID qw(cgisuidsetup); use FS::Record qw(qsearch qsearchs); use FS::CGI qw(header menubar popurl table); use FS::cust_main_county; $cgi = new CGI; &cgisuidsetup($cgi); $p = popurl(2); print $cgi->header( '-expires' => 'now' ), header("Tax Rate Listing", menubar( 'Main Menu' => $p, 'Edit tax rates' => $p. "edit/cust_main_county.cgi", )),<expand country to specify a country's tax rates by state.
Click on expand state to specify a state's tax rates by county.

END print &table(), < Country State County Tax END my @regions = sort { $a->country cmp $b->country or $a->state cmp $b->state or $a->county cmp $b->county } qsearch('cust_main_county',{}); my $sup=0; #foreach $cust_main_county ( @regions ) { for ( my $i=0; $i<@regions; $i++ ) { my $cust_main_county = $regions[$i]; my $hashref = $cust_main_county->hashref; print < $hashref->{country} END 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; } 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; } print "", $hashref->{state} ? $hashref->{state} : qq!(ALL) !. qq!expand country!; print qq! collapse state! if $j>1; print ""; } # $sup=$newsup; print ""; if ( $hashref->{county} ) { print $hashref->{county}; } else { print "(ALL)"; if ( $hashref->{state} ) { print qq!!. qq!expand state!; } } print ""; print <$hashref->{tax}% END } print < END %>