summaryrefslogtreecommitdiff
path: root/httemplate/elements/coord-links.html
blob: db04dad97787c47dd4d2c4b685416f9e4bc22911 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<& /elements/init_overlib.html &>

<& /elements/popup_link.html,
     'action'      => $p. 'view/map.html?'. $query,
     'label'       => mt('map'),
     'actionlabel' => $js_name,
     'width'       => 763,
     'height'      => 575,
     #'color'
&>

% if ( $origin ) {
  <& /elements/popup_link.html,
      'action'      => $p. "view/directions.html?origin=$origin;". $query,
      'label'       => mt('directions'),
      'actionlabel' => $js_name,
      'width'       => 763,
      'height'      => 575,
  &>
% }

<A HREF="<%$p%>view/kml.cgi?<% $query %>"><% mt('earth') |h %></A>

<%init>

my %opt = ();
my ($latitude, $longitude, $name, $agentnum);
if ( ref($_[0]) ) {
  %opt = %{ $_[0] };
  $latitude  = $opt{latitude};
  $longitude = $opt{longitude};
  $name      = $opt{name};
  $agentnum  = $opt{agentnum};
} else {
  ($latitude, $longitude, $name, $agentnum) = @_;
}

my $query = 'name='. uri_escape_utf8($name).
            ';lat='. $latitude.
            ';lon='. $longitude;

my $js_name = $name;
$js_name =~ s/[<>"']/ /g;
$m->interp->apply_escapes($js_name, 'js_string');
$js_name =~ s/^'//;
$js_name =~ s/'$//;

my $conf = new FS::Conf;
my $apikey = $conf->config('google_maps_api_key');

#for directions link
my @origin = $opt{company_address}
               ? @{ $opt{company_address} }
               : ( $conf->config('company_physical_address', $agentnum) 
                   ? $conf->config('company_physical_address', $agentnum)
                   : $conf->config('company_address', $agentnum) );
my $origin = uri_escape(join(',', @origin));

</%init>