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 = ( zip => $zip5,
8 % map { $_ => $location->$_ }
9 % qw ( city state geocode )
11 % map { $value{$_} = $location{$_} } qw ( city state )
12 % if $location{country} eq 'CA';
14 % my $value = encode_entities(objToJson({ %value })
17 % $content .= $location->$_. ' ' x ( $max{$_} - length($location->$_) )
18 % foreach qw( city county state );
19 % $content .= $location->cityflag eq 'I' ? 'Y' : 'N' ;
21 % if (!$have_selected && lc($location->city) eq lc($location{city})) {
22 % $selected = 'SELECTED';
24 <OPTION VALUE="<% $value %>" STYLE="<% $style %>" <% $selected %>><% $content %>
29 <TD> <BUTTON TYPE="button" onClick="set_geocode(document.getElementById('geocodes'));"><IMG SRC="<%$p%>images/tick.png" ALT=""> Set location </BUTTON></TD>
30 <TD><BUTTON TYPE="button" onClick="document.CustomerForm.submitButton.disabled=false; parent.cClick();"><IMG SRC="<%$p%>images/cross.png" ALT=""> Cancel submission </BUTTON></TD>
38 my $conf = new FS::Conf;
39 my $have_selected = 0;
43 ($location{data_vendor}) = $cgi->param('data_vendor') =~ /^([-\w]+)$/;
44 ($location{city}) = $cgi->param('city') =~ /^([\w ]+)$/;
45 ($location{state}) = $cgi->param('state') =~ /^(\w+)$/;
46 ($location{zip}) = $cgi->param('zip') =~ /^([-\w ]+)$/;
47 ($location{country}) = $cgi->param('country') =~ /^([\w ]+)$/;
49 my($zip5, $zip4) = split('-', $location{zip});
52 my $hashref = { 'data_vendor' => $location{data_vendor} };
53 $hashref->{zip} = $location{country} eq 'CA' ? substr($zip5,0,1) : $zip5,
55 my @keys = keys(%$hashref);
56 my @cust_tax_location = ();
57 until ( @cust_tax_location ) {
58 @cust_tax_location = qsearch({ table => 'cust_tax_location',
60 order_by => 'LIMIT 50',
62 last unless scalar(@keys);
63 delete $hashref->{ shift @keys };
66 my %max = ( city => 4, county => 6, state => 5);
67 foreach my $location (@cust_tax_location) {
68 foreach ( qw( city county state ) ) {
69 my $length = length($location->$_);
70 $max{$_} = ($length > $max{$_}) ? $length : $max{$_};
73 foreach ( qw( city county state ) ) {
74 $max{$_} = $location{$_} if $location{$_} > $max{$_};
78 my $header = ' ';
79 $header .= $_. ' ' x ( $max{lc($_)} - length($_) )
80 foreach qw( City County State );
81 $header .= "In city?";
83 my $style = "font-family:monospace;";