Merge branch 'master' of git.freeside.biz:/home/git/freeside
[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 <% $location{address1} %> <% $location{address2} %><BR>
10 <% $location{city} %>, <% $location{state} %> <% $location{zip} %><BR>
11 <BR>
12 % my $querystring = "census_year=$year&latitude=".$cache->get('latitude').'&longitude='.$cache->get('longitude');
13 <A HREF="http://maps.ffiec.gov/FFIECMapper/TGMapSrv.aspx?<% $querystring %>"
14    TARGET="_blank">Map service module location</A><BR>
15 % $querystring = "census_year=$year&zip_code=".$cache->get('zip');
16 <A HREF="http://maps.ffiec.gov/FFIECMapper/TGMapSrv.aspx?<% $querystring %>"
17    TARGET="_blank">Map zip code center</A><BR>
18 <BR>
19 <TABLE>
20   <TR>
21     <TH style="width:50%">Entered census tract</TH>
22     <TH style="width:50%">Calculated census tract</TH>
23   </TR>
24   <TR>
25     <TD><% $old_tract %></TD>
26 % if ( $error ) {
27     <TD><FONT COLOR="#ff0000"><% $error %></FONT></TD>
28 % } else {
29     <TD><% $new_tract %></TD>
30 % }
31   </TR>
32   <TR>
33     <TD ALIGN="center">
34       <BUTTON TYPE="button"
35               onclick="set_censustract('<% $old_tract %>', '<% $year %>', '<% $pre %>')">
36       <IMG SRC="<%$p%>images/error.png" ALT=""> Use entered census tract
37       </BUTTON>
38     </TD>
39 %   if ( !$error ) {
40     <TD ALIGN="center">
41       <BUTTON TYPE="button"
42               onclick="set_censustract('<% $new_tract %>', '<% $year %>', '<% $pre %>')">
43       <IMG SRC="<%$p%>images/tick.png" ALT=""> Use calculated census tract
44       </BUTTON>
45     </TD>
46   </TR>
47   <TR>
48     <TD COLSPAN=2 ALIGN="center">
49       <BUTTON TYPE="button" onclick="submit_abort()">
50       <IMG SRC="<%$p%>images/cross.png" ALT=""> Cancel submission
51       </BUTTON>
52     </TD>
53   </TR>
54 %   } else { # don't show a button to use the calculated value
55     <TD COLSPAN=1 ALIGN="center">
56       <BUTTON TYPE="button" onclick="submit_abort()">
57       <IMG SRC="<%$p%>images/cross.png" ALT=""> Cancel submission
58       </BUTTON>
59     </TD>
60   </TR>
61 %   }
62 </TABLE></CENTER>
63 <%init>
64
65 local $SIG{__DIE__}; #disable Mason error trap
66
67 my $DEBUG = 0;
68
69 my $conf = new FS::Conf;
70
71 warn $cgi->param('q') if $DEBUG;
72
73 my $q = decode_json($cgi->param('q'))
74   or die "bad argument '".$cgi->param('q')."'";
75
76 my $pre = $q->{prefix} || '';
77 my %location = (
78   map { $_ => $q->{$pre.$_} }
79     qw( company address1 address2 city state zip country latitude longitude )
80 );
81
82 my $old_tract = $q->{$pre.'censustract'};
83 my $cache = eval { FS::GeocodeCache->new(%location) };
84 $cache->set_censustract;
85 my $year = FS::Conf->new->config('census_year');
86 my $new_tract = $cache->get('censustract');
87 my $error = $cache->get('censustract_error');
88
89 warn Dumper($cache) if $DEBUG;
90
91 </%init>