enable census tract lookup and manual entry in package order/change and location...
[freeside.git] / httemplate / misc / confirm-censustract.html
1 <CENTER><BR><B>
2 % if ( $error ) {
3 Census tract error
4 % }
5 % else {
6 Confirm census tract
7 % }
8 </B><BR>
9 % my $querystring = "census_year=$year&latitude=".$cache->get('latitude').'&longitude='.$cache->get('longitude');
10 <A HREF="http://maps.ffiec.gov/FFIECMapper/TGMapSrv.aspx?<% $querystring %>"
11    TARGET="_blank">Map service module location</A><BR>
12 % $querystring = "census_year=$year&zip_code=".$cache->get('zip');
13 <A HREF="http://maps.ffiec.gov/FFIECMapper/TGMapSrv.aspx?<% $querystring %>"
14    TARGET="_blank">Map zip code center</A><BR>
15 <BR>
16 <TABLE>
17   <TR>
18     <TH style="width:50%">Entered census tract</TH>
19     <TH style="width:50%">Calculated census tract</TH>
20   </TR>
21   <TR>
22     <TD><% $old_tract %></TD>
23 % if ( $error ) {
24     <TD><FONT COLOR="#ff0000"><% $error %></FONT></TD>
25 % } else {
26     <TD><% $new_tract %></TD>
27 % }
28   </TR>
29   <TR>
30     <TD ALIGN="center">
31       <BUTTON TYPE="button"
32               onclick="set_censustract('<% $old_tract %>', '<% $year %>')">
33       <IMG SRC="<%$p%>images/error.png" ALT=""> Use entered census tract
34       </BUTTON>
35     </TD>
36     <TD ALIGN="center">
37       <BUTTON TYPE="button"
38               onclick="set_censustract('<% $new_tract %>', '<% $year %>')">
39       <IMG SRC="<%$p%>images/tick.png" ALT=""> Use calculated census tract
40       </BUTTON>
41     </TD>
42   </TR>
43   <TR>
44     <TD COLSPAN=2 ALIGN="center">
45       <BUTTON TYPE="button" onclick="submit_abort()">
46       <IMG SRC="<%$p%>images/cross.png" ALT=""> Cancel submission
47       </BUTTON>
48     </TD>
49   </TR>
50 </TABLE></CENTER>
51 <%init>
52
53 local $SIG{__DIE__}; #disable Mason error trap
54
55 my $DEBUG = 0;
56
57 my $conf = new FS::Conf;
58
59 warn $cgi->param('q') if $DEBUG;
60
61 my $q = decode_json($cgi->param('q'))
62   or die "bad argument '".$cgi->param('q')."'";
63
64 my $pre = '';
65 if ($q->{billship}) {
66   # this still isn't quite correct
67   $pre = $q->{'same'} ? 'bill_' : 'ship_';
68 }
69 my %location = (
70   map { $_ => $q->{$pre.$_} }
71     qw( company address1 address2 city state zip country latitude longitude )
72 );
73
74 my $old_tract = $q->{$pre.'censustract'};
75 my $cache = eval { FS::GeocodeCache->new(%location) };
76 $cache->set_censustract;
77 my $year = FS::Conf->new->config('census_year');
78 my $new_tract = $cache->get('censustract');
79 my $error = $cache->get('censustract_error');
80
81 warn Dumper($cache) if $DEBUG;
82
83 </%init>