From: Mark Wells Date: Wed, 29 Feb 2012 00:17:59 +0000 (-0800) Subject: directions to customer address, #16585 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=d5cdad7fae9c5e45701a7e83abeb903d31b7983f directions to customer address, #16585 --- 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, + &> +% } + <% mt('earth') |h %> <%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); +} 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 @@ <% $latitude %>  <% mt('Longitude') |h %> <% $longitude %> - <& /elements/coord-links.html, $latitude, $longitude, $name &> + <& /elements/coord-links.html, @_ &> <%init> -my ($latitude, $longitude, $name) = @_; +my ($latitude, $longitude, $name, $agentnum) = @_; 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, &> % } 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, + } +&> + +
+
+ +<%def .head> +% my $lat = $cgi->param('lat'); +% my $lon = $cgi->param('lon'); + + + + + + + + +<%shared> +my ($lat, $lon, $name, $origin); + +<%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"; + + 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 %> +
-<%init> - -my $name = js_string( scalar($cgi->param('name')) ); +<%def .head> + -my $point = [ map scalar($cgi->param($_)), qw( longitude latitude ) ]; + - - -##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); -'; +'; - - - #my $div = '
'; - my $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 .= " + +<%shared> +my ($lat, $lon, $name); + +<%init> - - "; +$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"; 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 {