71873: GlobalVision - directions
[freeside.git] / httemplate / elements / coord-links.html
1 <& /elements/init_overlib.html &>
2
3 % if ( $apikey ) {
4
5 <& /elements/popup_link.html,
6      'action'      => $p. 'view/map.html?'. $query,
7      'label'       => mt('map'),
8      'actionlabel' => $js_name,
9      'width'       => 763,
10      'height'      => 575,
11      #'color'
12 &>
13
14 % if ( $origin ) {
15   <& /elements/popup_link.html,
16       'action'      => $p. "view/directions.html?origin=$origin;". $query,
17       'label'       => mt('directions'),
18       'actionlabel' => $js_name,
19       'width'       => 763,
20       'height'      => 575,
21   &>
22 % }
23
24 % } # end if $apikey
25
26 <A HREF="<%$p%>view/kml.cgi?<% $query %>"><% mt('earth') |h %></A>
27
28 <%init>
29
30 my %opt = ();
31 my ($latitude, $longitude, $name, $agentnum);
32 if ( ref($_[0]) ) {
33   %opt = %{ $_[0] };
34   $latitude  = $opt{latitude};
35   $longitude = $opt{longitude};
36   $name      = $opt{name};
37   $agentnum  = $opt{agentnum};
38 } else {
39   ($latitude, $longitude, $name, $agentnum) = @_;
40 }
41
42 my $query = 'name='. uri_escape_utf8($name).
43             ';lat='. $latitude.
44             ';lon='. $longitude;
45
46 my $js_name = $name;
47 $js_name =~ s/[<>"']/ /g;
48 $m->interp->apply_escapes($js_name, 'js_string');
49 $js_name =~ s/^'//;
50 $js_name =~ s/'$//;
51
52 my $conf = new FS::Conf;
53 my $apikey = $conf->config('google_maps_api_key');
54
55 #for directions link
56 my @origin = $opt{company_address}
57                ? @{ $opt{company_address} }
58                : $conf->config('company_address', $agentnum);
59 my $origin = uri_escape(join(',', @origin));
60
61 </%init>