summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2012-02-28 16:17:59 -0800
committerMark Wells <mark@freeside.biz>2012-02-28 16:17:59 -0800
commitd5cdad7fae9c5e45701a7e83abeb903d31b7983f (patch)
tree24b8a0915a5c7e613a5f117db24c6b5320bef2b4
parent2bfe8d56f1dbf342cb5fac8187953cdb08b9d4cd (diff)
directions to customer address, #16585
-rw-r--r--httemplate/elements/coord-links.html18
-rw-r--r--httemplate/elements/tr-coords.html4
-rw-r--r--httemplate/view/cust_main/contacts.html1
-rw-r--r--httemplate/view/cust_main/packages/location.html3
-rw-r--r--httemplate/view/directions.html101
-rw-r--r--httemplate/view/map.html149
-rw-r--r--httemplate/view/svc_broadband.cgi14
7 files changed, 183 insertions, 107 deletions
diff --git a/httemplate/elements/coord-links.html b/httemplate/elements/coord-links.html
index 907e5f04a..6b91a26e8 100644
--- a/httemplate/elements/coord-links.html
+++ b/httemplate/elements/coord-links.html
@@ -9,14 +9,30 @@
#'color'
&>
+% if ( $origin ) {
+ <& /elements/popup_link.html,
+ 'action' => $p. "view/directions.html?origin=$origin;". $query,
+ 'label' => mt('dir'),
+ 'actionlabel' => $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).
';lat='. $latitude.
';lon='. $longitude;
+my $origin;
+#for directions link
+if ( $agentnum =~ /^\d+$/ ) {
+ $origin = FS::Conf->new->config('company_address', $agentnum);
+ $origin = uri_escape($origin);
+}
</%init>
diff --git a/httemplate/elements/tr-coords.html b/httemplate/elements/tr-coords.html
index 5539f565e..3248dc2de 100644
--- a/httemplate/elements/tr-coords.html
+++ b/httemplate/elements/tr-coords.html
@@ -4,11 +4,11 @@
<FONT STYLE="background-color: #ffffff; border: 1px solid #ffffff"><% $latitude %></FONT>
&nbsp;<% mt('Longitude') |h %>
<FONT STYLE="background-color: #ffffff; border: 1px solid #ffffff"><% $longitude %></FONT>
- <& /elements/coord-links.html, $latitude, $longitude, $name &>
+ <& /elements/coord-links.html, @_ &>
</TD>
</TR>
<%init>
-my ($latitude, $longitude, $name) = @_;
+my ($latitude, $longitude, $name, $agentnum) = @_;
</%init>
diff --git a/httemplate/view/cust_main/contacts.html b/httemplate/view/cust_main/contacts.html
index 3d4043aff..68e3b17ad 100644
--- a/httemplate/view/cust_main/contacts.html
+++ b/httemplate/view/cust_main/contacts.html
@@ -70,6 +70,7 @@
<& /elements/tr-coords.html, $cust_main->get($pre.'latitude'),
$cust_main->get($pre.'longitude'),
$cust_main->name_short,
+ $cust_main->agentnum,
&>
% }
diff --git a/httemplate/view/cust_main/packages/location.html b/httemplate/view/cust_main/packages/location.html
index 1bfca00f2..34e3a64c3 100644
--- a/httemplate/view/cust_main/packages/location.html
+++ b/httemplate/view/cust_main/packages/location.html
@@ -18,7 +18,8 @@
<& /elements/coord-links.html,
$loc->latitude,
$loc->longitude,
- $opt{'cust_main'}->name_short. ': '. $opt{'part_pkg'}->pkg
+ $opt{'cust_main'}->name_short. ': '. $opt{'part_pkg'}->pkg,
+ $opt{'cust_main'}->agentnum,
&>
</FONT>
% }
diff --git a/httemplate/view/directions.html b/httemplate/view/directions.html
new file mode 100644
index 000000000..599d049c2
--- /dev/null
+++ b/httemplate/view/directions.html
@@ -0,0 +1,101 @@
+%# the actual page
+<& /elements/header-popup.html, {
+ title => '',#$name,
+ head => include('.head'),
+ etc => 'onload="initialize()"',
+ nobr => 1,
+ }
+&>
+
+<div id="directions_panel"></div>
+<div id="map_canvas"></div>
+
+<%def .head>
+% my $lat = $cgi->param('lat');
+% my $lon = $cgi->param('lon');
+<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
+
+<style type="text/css">
+html { height: 100% }
+
+body { height: 100%; margin: 0px; padding: 0px }
+
+#map_canvas {
+ height: 100%;
+ margin-right: 320px;
+}
+
+#directions_panel {
+ height: 100%;
+ float: right;
+ width: 310px;
+ overflow: auto;
+ font-size: 80%;
+}
+
+@media print {
+ #map_canvas { height: 500px; margin: 0; }
+ #directions_panel { float: none; width: auto; }
+}
+</style>
+
+<script type="text/javascript"
+src="https://maps.google.com/maps/api/js?v=3.4&sensor=false">
+</script>
+
+<script type="text/javascript">
+var lengthLine=0;
+var map;
+
+function show_route() {
+ var panel = document.getElementById('directions_panel');
+ var directionsService = new google.maps.DirectionsService;
+ var directionsDisplay = new google.maps.DirectionsRenderer;
+ directionsDisplay.setMap(map);
+ directionsDisplay.setPanel(panel);
+
+ var directionsRequest = {
+ origin: <%$origin |js_string%>,
+ destination: <% $lat %>+","+<% $lon %>,
+ travelMode: google.maps.TravelMode.DRIVING
+ };
+
+ directionsService.route(directionsRequest, function(result, status) {
+ if ( status == google.maps.DirectionsStatus.OK ) {
+ directionsDisplay.setDirections(result);
+ }
+ });
+}
+
+function initialize() {
+ var myOptions = {
+ zoom: 14,
+ rotateControl: true,
+ mapTypeId: google.maps.MapTypeId.ROADMAP
+ };
+
+ map = new google.maps.Map(
+ document.getElementById("map_canvas"),
+ myOptions
+ );
+ map.setOptions( {rotateControl : true });
+
+ show_route();
+}
+</script>
+</%def>
+<%shared>
+my ($lat, $lon, $name, $origin);
+</%shared>
+<%init>
+
+$name = $cgi->param('name');
+
+$lat = $cgi->param('lat');
+$lon = $cgi->param('lon');
+$lat =~ /^-?\d+(\.\d+)?$/ or die "bad latitude: $lat";
+$lon =~ /^-?\d+(\.\d+)?$/ or die "bad longitude: $lat";
+
+$origin = $cgi->param('origin') or die "no origin specified";
+
+</%init>
diff --git a/httemplate/view/map.html b/httemplate/view/map.html
index 1725fd852..3122de6a0 100644
--- a/httemplate/view/map.html
+++ b/httemplate/view/map.html
@@ -1,120 +1,69 @@
+%# the actual page
<& /elements/header-popup.html, {
title => '',#$name,
- head => $head,
- etc => 'onload="html_googlemaps_initialize()"',
+ head => include('.head'),
+ etc => 'onload="initialize()"',
nobr => 1,
}
&>
-<% $map_div %>
+<div id="map_canvas"></div>
-<%init>
-
-my $name = js_string( scalar($cgi->param('name')) );
+<%def .head>
+<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
-my $point = [ map scalar($cgi->param($_)), qw( longitude latitude ) ];
+<style type="text/css">
+html { height: 100% }
-my( $head, $map_div ) = onload_render(
- $name,
- map scalar($cgi->param($_)), qw( lat lon )
-);
-
-#false laziness w/Mason.pm
-sub js_string {
- my $string = shift;
- $string =~ s/(['\\])/\\$1/g;
- $string =~ s/\r/\\r/g;
- $string =~ s/\n/\\n/g;
- $string = "'". $string. "'";
- return $string;
-}
+body { height: 100%; margin: 0px; padding: 0px }
-#subroutines below derived from HTML::GoogleMapsV3, but without using
-#Geo::Coder::Google or GPS::Point
-sub onload_render
-{
-## my $self = shift;
- my( $name, $latitude, $longitude ) = @_;
+#map_canvas { height: 100%; }
- #map_canvas { height: 100% }
-
- my $header='
- <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
- <style type="text/css">
- html { height: 100% }
- body { height: 100%; margin: 0px; padding: 0px }
- #map_canvas { height: 100% }
- </style>
- <script type="text/javascript" src="https://maps.google.com/maps/api/js?libraries=panoramio,geometry&v=3.4&sensor=false">
- </script>
- <script type="text/javascript">
- var lengthLine=0;
- function html_googlemaps_initialize() {
- var latlng = new google.maps.LatLng(' .$latitude . ',' . $longitude . ');
- var myOptions = {
- zoom: 14,
- center: latlng,
- rotateControl: true,
- mapTypeId: google.maps.MapTypeId.ROADMAP
- };
-
- map = new google.maps.Map(document.getElementById("map_canvas"),
- myOptions);
-
- map.setOptions( {rotateControl : true });
-
+@media print { #map_canvas { height: 500px; margin: 0; } }
+</style>
- ';
+<script type="text/javascript"
+src="https://maps.google.com/maps/api/js?v=3.4&sensor=false">
+</script>
-##our own hacked in code for displaying a marker at the center
-$header .= '
-var markerOptions = {
- map: map,
- position: latlng,
- title: '. $name. '
-};
-var marker = new google.maps.Marker(markerOptions);
-';
+<script type="text/javascript">
+var lengthLine=0;
+var map;
-## if( defined $self->{polyline} ) {
-## foreach my $polyline ( keys %{$self->{polyline}} ) {
-## $header .= $self->{polyline}->{$polyline} . "\n";
-## }
-## }
-
- $header .= '}
- </script>';
-
-
- #my $div = '<div id="map_canvas" style="width:80%; height:75%"></div>';
- my $div = '<div id="map_canvas" style="width:100%; height:100%"></div>';
+function initialize() {
+ var latlng = new google.maps.LatLng(<%$lat%>, <%$lon%>);
+ var myOptions = {
+ center: latlng,
+ zoom: 14,
+ rotateControl: true,
+ mapTypeId: google.maps.MapTypeId.ROADMAP
+ };
+ map = new google.maps.Map(
+ document.getElementById("map_canvas"),
+ myOptions
+ );
+ map.setOptions( {rotateControl : true });
- $header .= "<SCRIPT>
-
- panoramioLayer = new google.maps.panoramio.PanoramioLayer();
-
- function panoramioOn(){
- panoramioLayer.setMap(map);
- }
- function panoramioOff() {
- panoramioLayer.setMap(null);
- }
-
- function panoramioToggle() {
- if( panoramioLayer.getMap() == null ) {
- panoramioOn();
- } else {
- panoramioOff();
- }
- }
-
+ var markerOptions = {
+ map: map,
+ position: latlng,
+ title: <%$name |js_string%>
+ };
+ var marker = new google.maps.Marker(markerOptions);
+}
+</script>
+</%def>
+<%shared>
+my ($lat, $lon, $name);
+</%shared>
+<%init>
-
- </SCRIPT>";
+$name = $cgi->param('name');
- return ($header,$div)
-
-}
+$lat = $cgi->param('lat');
+$lon = $cgi->param('lon');
+$lat =~ /^-?\d+(\.\d+)?$/ or die "bad latitude: $lat";
+$lon =~ /^-?\d+(\.\d+)?$/ or die "bad longitude: $lat";
</%init>
diff --git a/httemplate/view/svc_broadband.cgi b/httemplate/view/svc_broadband.cgi
index 05ae632bd..961374e7d 100644
--- a/httemplate/view/svc_broadband.cgi
+++ b/httemplate/view/svc_broadband.cgi
@@ -89,14 +89,22 @@ sub coordinates {
return '' unless $s->latitude && $s->longitude;
my $d = $s->description;
+ my $agentnum;
unless ($d) {
- my $cust_pkg = $s->cust_svc->cust_pkg;
- $d = $cust_pkg->cust_main->name_short if $cust_pkg;
+ if ( my $cust_pkg = $s->cust_svc->cust_pkg ) {
+ $d = $cust_pkg->cust_main->name_short;
+ $agentnum = $cust_pkg->cust_main->agentnum;
+ }
}
#'Latitude: '. $s->latitude. ', Longitude: '. $s->longitude. ' '.
$s->latitude. ', '. $s->longitude. ' '.
- include('/elements/coord-links.html', $s->latitude, $s->longitude, $d);
+ include('/elements/coord-links.html',
+ $s->latitude,
+ $s->longitude,
+ $d,
+ $agentnum
+ );
}
sub svc_callback {