diff options
Diffstat (limited to 'httemplate/misc')
| -rwxr-xr-x | httemplate/misc/change_pkg.cgi | 1 | ||||
| -rw-r--r-- | httemplate/misc/confirm-address_standardize.html | 122 | ||||
| -rw-r--r-- | httemplate/misc/order_pkg.html | 1 | ||||
| -rw-r--r-- | httemplate/misc/xmlhttp-address_standardize.html | 38 | ||||
| -rw-r--r-- | httemplate/misc/xmlhttp-cust_main-address_standardize.html | 93 |
5 files changed, 162 insertions, 93 deletions
diff --git a/httemplate/misc/change_pkg.cgi b/httemplate/misc/change_pkg.cgi index 2ab9329a1..7b08f7b10 100755 --- a/httemplate/misc/change_pkg.cgi +++ b/httemplate/misc/change_pkg.cgi @@ -34,6 +34,7 @@ 'form' => "OrderPkgForm", 'onlyship' => 1, 'no_company' => 1, + 'no_census' => 1, 'callback' => 'document.OrderPkgForm.submit();', &> diff --git a/httemplate/misc/confirm-address_standardize.html b/httemplate/misc/confirm-address_standardize.html new file mode 100644 index 000000000..1f94dd917 --- /dev/null +++ b/httemplate/misc/confirm-address_standardize.html @@ -0,0 +1,122 @@ +<STYLE type="text/css"> +th { line-height: 150% } +</STYLE> +<CENTER><BR><B> +% if ( $new{error} or $new{ship_error} ) { +Address standardization error +% } +% else { +Confirm address standardization +% } + +</B><BR><BR> +<TABLE WIDTH="100%"> +% for my $pre ('', 'ship_') { +% next if !$pre and $old{onlyship}; +% my $name = $pre eq 'ship_' ? 'service' : 'billing'; +% if ( $new{$pre.'addr_clean'} ) { + <TR> + <TH>Entered <%$name%> address</TH> + <TH>Standardized <%$name%> address</TH> + </TR> + <TR> +% if ( $old{$pre.'company'} ) { + <TR> + <TD><% $old{$pre.'company'} %></TD> + <TD><% $new{$pre.'company'} %></TD> + </TR> +% } + <TR> + <TD><% $old{$pre.'address1'} %></TD> + <TD><% $new{$pre.'address1'} %></TD> + </TR> + <TR> + <TD><% $old{$pre.'address2'} %></TD> + <TD><% $new{$pre.'address2'} %></TD> + </TR> + <TR> + <TD><% $old{$pre.'city'} %>, <% $old{$pre.'state'} %> <% $old{$pre.'zip'} %></TD> + <TD><% $new{$pre.'city'} %>, <% $new{$pre.'state'} %> <% $new{$pre.'zip'} %></TD> + </TR> + +% } # if addr_clean +% elsif ( $new{$pre.'error'} ) { + <TR> + <TH>Entered <%$name%> address</TH> + </TR> +% if ( $old{$pre.'company'} ) { + <TR> + <TD><% $old{$pre.'company'} %></TD> + </TR> +% } + <TR> + <TD><% $old{$pre.'address1'} %></TD> + <TD><FONT COLOR="#ff0000"><B><% $new{$pre.'error'} %></B></FONT></TD> + </TR> + <TR> + <TD><% $old{$pre.'address2'} %></TD> + </TR> + <TR> + <TD><% $old{$pre.'city'} %>, <% $old{$pre.'state'} %> <% $old{$pre.'zip'} %></TD> + </TR> +% } #if error +% } # for $pre + +% if ( $old{'ship_censustract'} or $new{'ship_censustract'} ) { + <TR> + <TH>Entered census tract</TH> + <TH>Calculated census tract</TH> + </TR> + <TR> + <TD><% $old{'ship_censustract'} %></TD> + <TD> +% if ( $new{'ship_census_error'} ) { + <FONT COLOR="#ff0000"><% $new{'ship_census_error'} %></FONT> +% } else { + <% $new{'ship_censustract'} %> +% } + </TD> + </TR> +% } #if censustract + +% if ( $new{error} or $new{ship_error} ) { + <TR> + <TD ALIGN="center"> + <BUTTON TYPE="button" STYLE="width:205px" onclick="post_standardization();"> + <IMG SRC="<%$p%>images/error.png" ALT=""> Use entered <%$addresses%> + </BUTTON></TD> + <TD ALIGN="center"> + <BUTTON TYPE="button" STYLE="width:205px" onclick="submit_abort();"> + <IMG SRC="<%$p%>images/cross.png" ALT=""> Cancel submission + </BUTTON></TD> + </TR> +% } +% else { + <TR> + <TD ALIGN="center"> + <BUTTON TYPE="button" STYLE="width:205px" onclick="post_standardization();"> + <IMG SRC="<%$p%>images/error.png" ALT=""> Use entered <%$addresses%> + </BUTTON></TD> + <TD ALIGN="center"> + <BUTTON TYPE="button" STYLE="width:205px" onclick="replace_address();"> + <IMG SRC="<%$p%>images/tick.png" ALT=""> Use standardized <%$addresses%> + </BUTTON></TD> + </TR> + <TR ALIGN="center"><TD COLSPAN=2> + <BUTTON TYPE="button" STYLE="width:205px" onclick="submit_abort();"> + <IMG SRC="<%$p%>images/cross.png" ALT=""> Cancel submission + </BUTTON> + </TD></TR> +</TABLE> +% } # !error +<%init> + +# slightly weird interface... +my $q = decode_json($cgi->param('q')); +warn Dumper($q); +my %old = %{ $q->{old} }; +my %new = %{ $q->{new} }; + +my $addresses = $old{onlyship} ? 'address' : 'addresses'; + +</%init> diff --git a/httemplate/misc/order_pkg.html b/httemplate/misc/order_pkg.html index 2332f2028..66717b5bf 100644 --- a/httemplate/misc/order_pkg.html +++ b/httemplate/misc/order_pkg.html @@ -114,6 +114,7 @@ 'form' => "OrderPkgForm", 'onlyship' => 1, 'no_company' => 1, + 'no_census' => 1, 'callback' => 'document.OrderPkgForm.submit();', &> diff --git a/httemplate/misc/xmlhttp-address_standardize.html b/httemplate/misc/xmlhttp-address_standardize.html new file mode 100644 index 000000000..f305a2410 --- /dev/null +++ b/httemplate/misc/xmlhttp-address_standardize.html @@ -0,0 +1,38 @@ +<% encode_json($return) %> +<%init> + +local $SIG{__DIE__}; #disable Mason error trap + +my $DEBUG = 0; + +my $conf = new FS::Conf; + +my $sub = $cgi->param('sub'); + +warn $cgi->param('arg') if $DEBUG; + +my %old = %{ decode_json($cgi->param('arg')) } + or die "bad argument '".$cgi->param('arg')."'"; + +my %new; + +foreach my $pre ( '', 'ship_' ) { + next unless ($pre || !$old{onlyship}); + + my $location = { + map { $_ => $old{$pre.$_} } + qw( company address1 address2 city state zip country ) + }; + + my $cache = eval { FS::geocode_cache->standardize($location) }; + $cache->set_censustract if $pre; + $cache->set_coord; + + foreach ( keys(%$cache) ) { + $new{$pre.$_} = $cache->get($_); + } +} + +my $return = { old => \%old, new => \%new }; +warn "result:\n".encode_json($return) if $DEBUG; +</%init> diff --git a/httemplate/misc/xmlhttp-cust_main-address_standardize.html b/httemplate/misc/xmlhttp-cust_main-address_standardize.html deleted file mode 100644 index d0627cd59..000000000 --- a/httemplate/misc/xmlhttp-cust_main-address_standardize.html +++ /dev/null @@ -1,93 +0,0 @@ -<% objToJson($return) %> -<%init> - -my $DEBUG = 0; - -my $conf = new FS::Conf; - -my $sub = $cgi->param('sub'); - -my $return = {}; - -if ( $sub eq 'address_standardize' ) { - - my %arg = $cgi->param('arg'); - $return = \%arg; - warn join('', map "$_: $arg{$_}\n", keys %arg ) - if $DEBUG; - - my $userid = $conf->config('usps_webtools-userid'); - my $password = $conf->config('usps_webtools-password'); - - if ( length($userid) && length($password) ) { - - my $verifier = Business::US::USPS::WebTools::AddressStandardization->new( { - UserID => $userid, #$ENV{USPS_WEBTOOLS_USERID}, - Password => $password, #$ENV{USPS_WEBTOOLS_PASSWORD}, - #Testing => 1, - } ); - - foreach my $pre ( '', 'ship_' ) { - next unless ($pre || !$arg{onlyship}); - - my($zip5, $zip4) = split('-',$arg{$pre.'zip'}); - - my %usps_args = ( - FirmName => $arg{$pre.'company'}, - Address2 => $arg{$pre.'address1'}, - Address1 => $arg{$pre.'address2'}, - City => $arg{$pre.'city'}, - State => $arg{$pre.'state'}, - Zip5 => $zip5, - Zip4 => $zip4, - ); - warn join('', map "$_: $usps_args{$_}\n", keys %usps_args ) - if $DEBUG; - - my $hash = $verifier->verify_address( %usps_args ); - - warn $verifier->response - if $DEBUG; - - unless ( $verifier->is_error ) { - - my $zip = $hash->{Zip5}; - $zip .= '-'. $hash->{Zip4} if $hash->{Zip4} =~ /\d/; - - $return = { - %$return, - "new_$pre".'company' => $hash->{FirmName}, - "new_$pre".'address1' => $hash->{Address2}, - "new_$pre".'address2' => $hash->{Address1}, - "new_$pre".'city' => $hash->{City}, - "new_$pre".'state' => $hash->{State}, - "new_$pre".'zip' => $zip, - }; - - my @fields = (qw( company address1 address2 city state zip )); #hmm - - my $changed = - scalar( grep { $return->{$pre.$_} ne $return->{"new_$pre$_"} } - @fields - ) - ? 1 : 0; - - $return->{$pre.'address_standardized'} = $changed; - - } else { - - $return->{$pre.'error'} = "USPS WebTools error: ". - $verifier->{error}{description}; - - - } - - } - - } - - $return; - -} - -</%init> |
