1 <FORM NAME="choosegeocodeform">
2 <CENTER><BR><B>Choose tax location</B><BR><BR>
3 <P STYLE="<% $style %>"><% $header %></P>
5 <SELECT NAME='geocodes' ID='geocodes' STYLE="<% $style %>">
6 % foreach my $location (@cust_tax_location) {
7 % my %value = ( map { $_ => $location->$_ }
8 % qw ( zip city state geocode )
10 % map { $value{$_} = $location{$_} } qw ( city state )
11 % if $location{country} eq 'CA';
13 % my $value = encode_entities(encode_json({ %value })
16 % $content .= $location->$_. ' ' x ( $max{$_} - length($location->$_) )
17 % foreach qw( city county state );
18 % $content .= $location->cityflag eq 'I' ? 'Y' : 'N' ;
20 % if ($geocode && $location->geocode eq $geocode) {
21 % $selected = 'SELECTED';
23 <OPTION VALUE="<% $value %>" STYLE="<% $style %>" <% $selected %>><% $content %>
28 <TD> <BUTTON TYPE="button" onClick="set_geocode(document.getElementById('geocodes'));"><IMG SRC="<%$p%>images/tick.png" ALT=""> Set location </BUTTON></TD>
29 <TD><BUTTON TYPE="button" onClick="document.<% $formname %>.submitButton.disabled=false; parent.cClick();"><IMG SRC="<%$p%>images/cross.png" ALT=""> Cancel submission </BUTTON></TD>
37 my $conf = new FS::Conf;
38 my $tax_engine = FS::TaxEngine->new;
41 ($location{data_vendor}) = $conf->config('tax_data_vendor');
42 ($location{city}) = $cgi->param('city') =~ /^([\w ]+)$/;
43 ($location{state}) = $cgi->param('state') =~ /^(\w+)$/;
44 ($location{zip}) = $cgi->param('zip') =~ /^([-\w ]+)$/;
45 ($location{country}) = $cgi->param('country') =~ /^([\w ]+)$/;
47 my($geocode) = $cgi->param('geocode') =~ /^([\w]+)$/;
49 my($formname) = $cgi->param('formname') =~ /^([\w]*)$/;
50 $formname ||= 'CustomerForm';
52 my @cust_tax_location = $tax_engine->cust_tax_locations(\%location);
54 my %max = ( city => 4, county => 6, state => 5);
55 foreach my $location (@cust_tax_location) {
56 foreach ( qw( city county state ) ) {
57 my $length = length($location->$_);
58 $max{$_} = ($length > $max{$_}) ? $length : $max{$_};
61 foreach ( qw( city county state ) ) {
62 $max{$_} = $location{$_} if $location{$_} > $max{$_};
66 my $header = ' ';
67 $header .= $_. ' ' x ( $max{lc($_)} - length($_) )
68 foreach qw( City County State );
69 $header .= "In city?";
71 my $style = "font-family:monospace;";