RT# 82949 - changes section name from fees to pricing, better opiton
[freeside.git] / httemplate / misc / confirm-censustract.html
1 % if ( !$error and !$new_tract ) {
2 %   # then set_censustract returned nothing
3 %   # because it's not relevant for this address
4 %   # so output nothing (forces confirm_censustract() to continue)
5 % $m->clear_buffer;
6 % $m->abort;
7 % }
8 <CENTER><BR><B>
9 % if ( $error ) {
10 Census tract error
11 % }
12 % else {
13 Confirm census tract
14 % }
15 </B><BR>
16 <% $location{address1} |h %> <% $location{address2} |h %><BR>
17 <% $location{city} |h %>, <% $location{state} |h %> <% $location{zip} |h %><BR>
18 <BR>
19 % my $querystring = "census_year=$year&address=$location{address1}, $location{address2}, $location{city}, $location{state}";
20 <A HREF="<%$p%>misc/openmap.html?<% $querystring %>"
21    TARGET="_blank">Map service module location</A><BR>
22 % $querystring = "census_year=$year&pre=$pre&zip_code=" . $cache->get('zip');
23 <A HREF="<%$p%>misc/openmap.html?<% $querystring %>"
24    TARGET="_blank">Map zip code center</A><BR>
25 <BR>
26 <input type="hidden" id="new_tract" name="new_tract" value="<%$new_tract%>">
27 <TABLE>
28   <TR>
29     <TH style="width:50%">Entered census tract</TH>
30     <TH style="width:50%">Calculated census tract</TH>
31   </TR>
32   <TR>
33     <TD><% $old_tract %></TD>
34 % if ( $error ) {
35     <TD><div id='newcensustract'><FONT COLOR="#ff0000"><% $error %></FONT></div></TD>
36 % } else {
37     <TD><div id='newcensustract'><% $new_tract %></div></TD>
38 % }
39   </TR>
40   <TR>
41     <TD ALIGN="center">
42       <BUTTON TYPE="button"
43               onclick="set_censustract('<% $old_tract %>', '<% $year %>', '<% $pre %>')">
44       <IMG SRC="<%$p%>images/error.png" ALT=""> Use entered census tract
45       </BUTTON>
46     </TD>
47     <TD ALIGN="center">
48      <div id="setnewtractdiv"
49 % if ( $error ) { ## do not display this block if error finding track.
50       style="display:none"
51 % }
52      >
53       <BUTTON TYPE="button" id="setnewtract"
54               onclick="set_censustract(getElementById('new_tract').value, '<% $year %>', '<% $pre %>')">
55       <IMG SRC="<%$p%>images/tick.png" ALT=""> Use calculated census tract
56       </BUTTON>
57      </div>
58      <div id='cancelsubmissiontop'
59 % if ( !$error ) { ## do not display this block if there is no error finding a track.
60       style="display:none"
61 % }
62      >
63       <BUTTON TYPE="button" onclick="submit_abort()">
64         <IMG SRC="<%$p%>images/cross.png" ALT=""> Cancel submission
65       </BUTTON>
66      </div>
67     </TD>
68   </TR>
69   <TR>
70     <TD COLSPAN=2 ALIGN="center">
71      <div id='cancelsubmissionbottom'
72 % if ( $error ) { ## do not display this block if error finding track.
73       style="display:none"
74 % }
75      >
76       <BUTTON TYPE="button" onclick="submit_abort()">
77         <IMG SRC="<%$p%>images/cross.png" ALT=""> Cancel submission
78       </BUTTON>
79      </div>
80     </TD>
81   </TR>
82 </TABLE></CENTER>
83
84 <%init>
85
86 local $SIG{__DIE__}; #disable Mason error trap
87
88 my $DEBUG = 0;
89
90 my $conf = new FS::Conf;
91
92 warn $cgi->param('q') if $DEBUG;
93
94 my $q = decode_json($cgi->param('q'))
95   or die "bad argument '".$cgi->param('q')."'";
96
97 my $pre = $q->{prefix} || '';
98 my %location = (
99   map { $_ => $q->{$pre.$_} }
100     qw( company address1 address2 city state zip country latitude longitude )
101 );
102
103 my $old_tract = $q->{$pre.'censustract'};
104 my $cache = eval { FS::GeocodeCache->new(%location) };
105 $cache->set_censustract;
106 my $year = FS::Conf->new->config('census_year');
107 my $new_tract = $cache->get('censustract');
108 my $error = $cache->get('censustract_error');
109
110 warn Dumper($cache) if $DEBUG;
111
112 </%init>