X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Felements%2Fcoord-links.html;h=a755791ae4994216e9cb390f04d0e4689632dd26;hp=81af8120b5dd75739e0f94270785d242231cdcd0;hb=e1acfb2921b35fe097015208e8072a2675d01d69;hpb=28b2b233e588f03a9d7966f29db918ace9382d26 diff --git a/httemplate/elements/coord-links.html b/httemplate/elements/coord-links.html index 81af8120b..a755791ae 100644 --- a/httemplate/elements/coord-links.html +++ b/httemplate/elements/coord-links.html @@ -1,9 +1,11 @@ <& /elements/init_overlib.html &> +% if ( $apikey ) { + <& /elements/popup_link.html, 'action' => $p. 'view/map.html?'. $query, 'label' => mt('map'), - 'actionlabel' => $name, + 'actionlabel' => $js_name, 'width' => 763, 'height' => 575, #'color' @@ -13,26 +15,47 @@ <& /elements/popup_link.html, 'action' => $p. "view/directions.html?origin=$origin;". $query, 'label' => mt('directions'), - 'actionlabel' => $name, + 'actionlabel' => $js_name, 'width' => 763, 'height' => 575, &> % } +% } # end if $apikey + <% mt('earth') |h %> <%init> -my ($latitude, $longitude, $name, $agentnum) = @_; +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 $origin; +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 -if ( $agentnum =~ /^\d+$/ ) { - $origin = FS::Conf->new->config('company_address', $agentnum); - $origin = uri_escape($origin); -} +my @origin = $opt{company_address} + ? @{ $opt{company_address} } + : $conf->config('company_address', $agentnum); +my $origin = uri_escape(join(',', @origin)); +