#28004 Adjustments to directions link on customer view page
[freeside.git] / httemplate / elements / coord-links.html
index 907e5f0..4c263c6 100644 (file)
@@ -3,20 +3,44 @@
 <& /elements/popup_link.html,
      'action'      => $p. 'view/map.html?'. $query,
      'label'       => mt('map'),
-     'actionlabel' => $name,
+     '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 ($latitude, $longitude, $name) = @_;
+my ($latitude, $longitude, $name, $agentnum) = @_;
 
-my $query = 'name='. uri_escape($name).
+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 @origin;
+my $origin;
+#for directions link
+if ( $agentnum =~ /^\d+$/ ) {
+  @origin = FS::Conf->new->config('company_address', $agentnum);
+  $origin = join (/,/,@origin);
+  $origin = uri_escape($origin);
+}
 </%init>