Add bing maps support for job orders. #221
This commit is contained in:
parent
4a608b50b9
commit
6c8ad89d6e
4 changed files with 244 additions and 112 deletions
|
|
@ -32,6 +32,7 @@ use App\Service\MapTools;
|
|||
use App\Service\HubCounter;
|
||||
use App\Service\MQTTClient;
|
||||
use App\Service\APNSClient;
|
||||
use App\Service\MapManagerInterface;
|
||||
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\DBAL\Connection;
|
||||
|
|
@ -206,7 +207,7 @@ class JobOrderController extends Controller
|
|||
/**
|
||||
* @Menu(selected="jo_in")
|
||||
*/
|
||||
public function incomingForm()
|
||||
public function incomingForm(MapManagerInterface $map_manager)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('jo_in.list', null, 'No access.');
|
||||
|
||||
|
|
@ -214,6 +215,7 @@ class JobOrderController extends Controller
|
|||
$params['mode'] = 'create';
|
||||
$params['submit_url'] = $this->generateUrl('jo_in_submit');
|
||||
$params['return_url'] = $this->generateUrl('jo_in');
|
||||
$params['map_manager'] = $map_manager->getMapManager();
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
|
|
@ -227,7 +229,7 @@ class JobOrderController extends Controller
|
|||
/**
|
||||
* @Menu(selected="jo_in")
|
||||
*/
|
||||
public function openEditForm($id)
|
||||
public function openEditForm($id, MapManagerInterface $map_manager)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('jo_open.edit', null, 'No access.');
|
||||
|
||||
|
|
@ -240,6 +242,7 @@ class JobOrderController extends Controller
|
|||
$params['return_url'] = $this->generateUrl('jo_open');
|
||||
$params['cvid'] = $jo->getCustomerVehicle()->getID();
|
||||
$params['vid'] = $jo->getCustomerVehicle()->getVehicle()->getID();
|
||||
$params['map_manager'] = $map_manager->getMapManager();
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
|
|
@ -390,7 +393,7 @@ class JobOrderController extends Controller
|
|||
/**
|
||||
* @Menu(selected="jo_in")
|
||||
*/
|
||||
public function incomingVehicleForm($cvid)
|
||||
public function incomingVehicleForm($cvid, MapManagerInterface $map_manager)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('jo_in.list', null, 'No access.');
|
||||
|
||||
|
|
@ -398,6 +401,7 @@ class JobOrderController extends Controller
|
|||
$params['submit_url'] = $this->generateUrl('jo_in_submit');
|
||||
$params['return_url'] = $this->generateUrl('jo_in');
|
||||
$params['cvid'] = $cvid;
|
||||
$params['map_manager'] = $map_manager->getMapManager();
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
|
|
@ -858,7 +862,7 @@ class JobOrderController extends Controller
|
|||
/**
|
||||
* @Menu(selected="jo_proc")
|
||||
*/
|
||||
public function processingForm(MapTools $map_tools, $id)
|
||||
public function processingForm(MapTools $map_tools, $id, MapManagerInterface $map_manager)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('jo_proc.list', null, 'No access.');
|
||||
|
||||
|
|
@ -974,6 +978,7 @@ class JobOrderController extends Controller
|
|||
$params['obj'] = $obj;
|
||||
$params['submit_url'] = $this->generateUrl('jo_proc_submit', ['id' => $obj->getID()]);
|
||||
$params['return_url'] = $this->generateUrl('jo_proc');
|
||||
$params['map_manager'] = $map_manager->getMapManager();
|
||||
|
||||
// response
|
||||
return $this->render('job-order/form.html.twig', $params);
|
||||
|
|
@ -1121,7 +1126,7 @@ class JobOrderController extends Controller
|
|||
/**
|
||||
* @Menu(selected="jo_assign")
|
||||
*/
|
||||
public function assigningForm(MapTools $map_tools, $id)
|
||||
public function assigningForm(MapTools $map_tools, $id, MapManagerInterface $map_manager)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('jo_assign.list', null, 'No access.');
|
||||
|
||||
|
|
@ -1195,6 +1200,7 @@ class JobOrderController extends Controller
|
|||
$params['status_cancelled'] = JOStatus::CANCELLED;
|
||||
$params['submit_url'] = $this->generateUrl('jo_assign_submit', ['id' => $obj->getID()]);
|
||||
$params['return_url'] = $this->generateUrl('jo_assign');
|
||||
$params['map_manager'] = $map_manager->getMapManager();
|
||||
|
||||
// response
|
||||
return $this->render('job-order/form.html.twig', $params);
|
||||
|
|
@ -1309,7 +1315,7 @@ class JobOrderController extends Controller
|
|||
/**
|
||||
* @Menu(selected="jo_fulfill")
|
||||
*/
|
||||
public function fulfillmentForm(MapTools $map_tools, $id)
|
||||
public function fulfillmentForm(MapTools $map_tools, $id, MapManagerInterface $map_manager)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('jo_fulfill.list', null, 'No access.');
|
||||
|
||||
|
|
@ -1346,6 +1352,7 @@ class JobOrderController extends Controller
|
|||
$params['status_cancelled'] = JOStatus::CANCELLED;
|
||||
$params['submit_url'] = $this->generateUrl('jo_fulfill_submit', ['id' => $obj->getID()]);
|
||||
$params['return_url'] = $this->generateUrl('jo_fulfill');
|
||||
$params['map_manager'] = $map_manager->getMapManager();
|
||||
|
||||
// response
|
||||
return $this->render('job-order/form.html.twig', $params);
|
||||
|
|
@ -1528,7 +1535,7 @@ class JobOrderController extends Controller
|
|||
/**
|
||||
* @Menu(selected="jo_open")
|
||||
*/
|
||||
public function openHubForm(MapTools $map_tools, $id)
|
||||
public function openHubForm(MapTools $map_tools, $id, MapManagerInterface $map_manager)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('jo_open.list', null, 'No access.');
|
||||
|
||||
|
|
@ -1606,6 +1613,7 @@ class JobOrderController extends Controller
|
|||
$params['obj'] = $obj;
|
||||
$params['submit_url'] = $this->generateUrl('jo_open_hub_submit', ['id' => $obj->getID()]);
|
||||
$params['return_url'] = $this->generateUrl('jo_open');
|
||||
$params['map_manager'] = $map_manager->getMapManager();
|
||||
|
||||
// response
|
||||
return $this->render('job-order/form.html.twig', $params);
|
||||
|
|
@ -1718,7 +1726,7 @@ class JobOrderController extends Controller
|
|||
/**
|
||||
* @Menu(selected="jo_open")
|
||||
*/
|
||||
public function openRiderForm($id)
|
||||
public function openRiderForm($id, MapManagerInterface $map_manager)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('jo_open.list', null, 'No access.');
|
||||
|
||||
|
|
@ -1750,6 +1758,7 @@ class JobOrderController extends Controller
|
|||
$params['status_cancelled'] = JOStatus::CANCELLED;
|
||||
$params['submit_url'] = $this->generateUrl('jo_open_rider_submit', ['id' => $obj->getID()]);
|
||||
$params['return_url'] = $this->generateUrl('jo_open');
|
||||
$params['map_manager'] = $map_manager->getMapManager();
|
||||
|
||||
// response
|
||||
return $this->render('job-order/form.html.twig', $params);
|
||||
|
|
@ -1862,7 +1871,7 @@ class JobOrderController extends Controller
|
|||
/**
|
||||
* @Menu(selected="jo_all")
|
||||
*/
|
||||
public function allForm($id)
|
||||
public function allForm($id, MapManagerInterface $map_manager)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('jo_all.list', null, 'No access.');
|
||||
|
||||
|
|
@ -1884,6 +1893,7 @@ class JobOrderController extends Controller
|
|||
$params['status_cancelled'] = JOStatus::CANCELLED;
|
||||
$params['return_url'] = $this->generateUrl('jo_all');
|
||||
$params['submit_url'] = '';
|
||||
$params['map_manager'] = $map_manager->getMapManager();
|
||||
|
||||
// timeline stuff (descending by time)
|
||||
$params['timeline'] = [
|
||||
|
|
|
|||
120
templates/job-order/bingmaps.js.twig
Normal file
120
templates/job-order/bingmaps.js.twig
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
<script type='text/javascript' src='http://www.bing.com/api/maps/mapcontrol?callback=GetMap&key={{ bingmaps_api_key|raw }}' async defer></script>
|
||||
<script>
|
||||
|
||||
$(function() {
|
||||
var form_in_process = false;
|
||||
var pin;
|
||||
|
||||
function selectPoint(e) {
|
||||
if (e.targetType == "map") {
|
||||
var point = new Microsoft.Maps.Point(e.getX(), e.getY());
|
||||
var locTemp = e.target.tryPixelToLocation(point);
|
||||
var location = new Microsoft.Maps.Location(locTemp.latitude,
|
||||
locTemp.longitude)
|
||||
|
||||
map.entities.remove(pin);
|
||||
|
||||
pin = new Microsoft.Maps.Pushpin(location, {
|
||||
draggable: false,
|
||||
icon: '/assets/images/icon-destination.png'
|
||||
});
|
||||
|
||||
map.entities.push(pin);
|
||||
map.setCenter(location);
|
||||
|
||||
// set value in hidden input
|
||||
$('#map_lat').val(locTemp.latitude);
|
||||
$('#map_lng').val(locTemp.longitude);
|
||||
}
|
||||
|
||||
map.setCenter(lat, lng);
|
||||
map.addMarker({
|
||||
lat: lat,
|
||||
lng: lng,
|
||||
icon: '/assets/images/icon-destination.png'
|
||||
});
|
||||
|
||||
// set value in hidden input
|
||||
$('#map_lat').val(lat);
|
||||
$('#map_lng').val(lng);
|
||||
}
|
||||
|
||||
var map = new Microsoft.Maps.Map('#m_gmap', {
|
||||
center: new Microsoft.Maps.Location(14.6091, 121.0223),
|
||||
}
|
||||
Microsoft.Maps.Events.addHandler(map, 'click', selectPoint);
|
||||
|
||||
|
||||
{
|
||||
div: '#m_gmap',
|
||||
lat: 14.6091,
|
||||
lng: 121.0223,
|
||||
click: function(e) {
|
||||
// handle click in map
|
||||
selectPoint(map, e.latLng);
|
||||
e.stop();
|
||||
}
|
||||
});
|
||||
var handleAction = function() {
|
||||
var text = $.trim($('#m_gmap_address').val());
|
||||
GMaps.geocode({
|
||||
address: text,
|
||||
callback: function(results, status) {
|
||||
map.removeMarkers();
|
||||
if (status == 'OK') {
|
||||
selectPoint(map, results[0].geometry.location);
|
||||
}
|
||||
},
|
||||
region: 'ph'
|
||||
});
|
||||
}
|
||||
|
||||
$('#m_gmap_btn').click(function(e) {
|
||||
e.preventDefault();
|
||||
handleAction();
|
||||
});
|
||||
|
||||
$("#m_gmap_address").keypress(function(e) {
|
||||
var keycode = (e.keyCode ? e.keyCode : e.which);
|
||||
if (keycode == '13') {
|
||||
e.preventDefault();
|
||||
handleAction();
|
||||
}
|
||||
});
|
||||
|
||||
{% if ftags.set_map_coordinate %}
|
||||
// check if we need to set map
|
||||
var latlng = new google.maps.LatLng({{ obj.getCoordinates.getLatitude }}, {{ obj.getCoordinates.getLongitude }});
|
||||
selectPoint(map, latlng);
|
||||
|
||||
// remove placeholder text
|
||||
$("[data-vehicle-field='1']").prop('placeholder', '');
|
||||
{% endif %}
|
||||
|
||||
{% if mode in ['update-processing', 'update-reassign-hub'] %}
|
||||
// display hub map
|
||||
var hmap = new GMaps({
|
||||
div: '#hub_map',
|
||||
lat: {{ obj.getCoordinates.getLatitude }},
|
||||
lng: {{ obj.getCoordinates.getLongitude }}
|
||||
});
|
||||
|
||||
hmap.addMarker({
|
||||
lat: {{ obj.getCoordinates.getLatitude }},
|
||||
lng: {{ obj.getCoordinates.getLongitude }},
|
||||
icon: '/assets/images/icon-destination.png',
|
||||
title: "Destination",
|
||||
content: "Destination"
|
||||
});
|
||||
|
||||
{% for hub in hubs %}
|
||||
hmap.addMarker({
|
||||
lat: {{ hub.hub.getCoordinates.getLatitude }},
|
||||
lng: {{ hub.hub.getCoordinates.getLongitude }},
|
||||
title: "{{ hub.hub.getName }}",
|
||||
content: "{{ hub.hub.getName }}",
|
||||
icon: '/assets/images/icon-outlet.png'
|
||||
});
|
||||
{% endfor %}
|
||||
|
||||
{% endif %}
|
||||
|
|
@ -893,109 +893,11 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<!-- <script src="//maps.google.com/maps/api/js?key={{ gmaps_api_key }}" type="text/javascript"></script> -->
|
||||
<script src="//maps.googleapis.com/maps/api/js?key={{ gmaps_api_key }}" type="text/javascript"></script>
|
||||
<script src="/assets/vendors/custom/gmaps/gmaps.js" type="text/javascript"></script>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
var form_in_process = false;
|
||||
|
||||
// BEGIN google maps stuff
|
||||
function selectPoint(map, latlng) {
|
||||
var lat = latlng.lat();
|
||||
var lng = latlng.lng();
|
||||
|
||||
// show it in map
|
||||
map.removeMarkers();
|
||||
map.setCenter(lat, lng);
|
||||
map.addMarker({
|
||||
lat: lat,
|
||||
lng: lng,
|
||||
icon: '/assets/images/icon-destination.png'
|
||||
});
|
||||
|
||||
// set value in hidden input
|
||||
$('#map_lat').val(lat);
|
||||
$('#map_lng').val(lng);
|
||||
}
|
||||
|
||||
var map = new GMaps({
|
||||
div: '#m_gmap',
|
||||
lat: 14.6091,
|
||||
lng: 121.0223,
|
||||
click: function(e) {
|
||||
// handle click in map
|
||||
selectPoint(map, e.latLng);
|
||||
e.stop();
|
||||
}
|
||||
});
|
||||
var handleAction = function() {
|
||||
var text = $.trim($('#m_gmap_address').val());
|
||||
GMaps.geocode({
|
||||
address: text,
|
||||
callback: function(results, status) {
|
||||
map.removeMarkers();
|
||||
if (status == 'OK') {
|
||||
selectPoint(map, results[0].geometry.location);
|
||||
}
|
||||
},
|
||||
region: 'ph'
|
||||
});
|
||||
}
|
||||
|
||||
$('#m_gmap_btn').click(function(e) {
|
||||
e.preventDefault();
|
||||
handleAction();
|
||||
});
|
||||
|
||||
$("#m_gmap_address").keypress(function(e) {
|
||||
var keycode = (e.keyCode ? e.keyCode : e.which);
|
||||
if (keycode == '13') {
|
||||
e.preventDefault();
|
||||
handleAction();
|
||||
}
|
||||
});
|
||||
|
||||
{% if ftags.set_map_coordinate %}
|
||||
// check if we need to set map
|
||||
var latlng = new google.maps.LatLng({{ obj.getCoordinates.getLatitude }}, {{ obj.getCoordinates.getLongitude }});
|
||||
selectPoint(map, latlng);
|
||||
|
||||
// remove placeholder text
|
||||
$("[data-vehicle-field='1']").prop('placeholder', '');
|
||||
{% endif %}
|
||||
|
||||
{% if mode in ['update-processing', 'update-reassign-hub'] %}
|
||||
// display hub map
|
||||
var hmap = new GMaps({
|
||||
div: '#hub_map',
|
||||
lat: {{ obj.getCoordinates.getLatitude }},
|
||||
lng: {{ obj.getCoordinates.getLongitude }}
|
||||
});
|
||||
|
||||
hmap.addMarker({
|
||||
lat: {{ obj.getCoordinates.getLatitude }},
|
||||
lng: {{ obj.getCoordinates.getLongitude }},
|
||||
icon: '/assets/images/icon-destination.png',
|
||||
title: "Destination",
|
||||
content: "Destination"
|
||||
});
|
||||
|
||||
{% for hub in hubs %}
|
||||
hmap.addMarker({
|
||||
lat: {{ hub.hub.getCoordinates.getLatitude }},
|
||||
lng: {{ hub.hub.getCoordinates.getLongitude }},
|
||||
title: "{{ hub.hub.getName }}",
|
||||
content: "{{ hub.hub.getName }}",
|
||||
icon: '/assets/images/icon-outlet.png'
|
||||
});
|
||||
{% endfor %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
|
||||
// END google maps stuff
|
||||
{% if map_manager == 'bing' %}
|
||||
{{ include ('job-order/bingmaps.js.twig')}}
|
||||
{% else %}
|
||||
{{ include ('job-order/googlemaps.js.twig')}}
|
||||
{% endif %}
|
||||
|
||||
$("#row-form").submit(function(e) {
|
||||
if (form_in_process) {
|
||||
|
|
|
|||
100
templates/job-order/googlemaps.js.twig
Normal file
100
templates/job-order/googlemaps.js.twig
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
<script src="//maps.google.com/maps/api/js?key={{ gmaps_api_key|raw }}" type="text/javascript"></script>
|
||||
<script src="/assets/vendors/custom/gmaps/gmaps.js" type="text/javascript"></script>
|
||||
|
||||
<script>
|
||||
|
||||
$(function() {
|
||||
var form_in_process = false;
|
||||
|
||||
// BEGIN google maps stuff
|
||||
function selectPoint(map, latlng) {
|
||||
var lat = latlng.lat();
|
||||
var lng = latlng.lng();
|
||||
|
||||
// show it in map
|
||||
map.removeMarkers();
|
||||
map.setCenter(lat, lng);
|
||||
map.addMarker({
|
||||
lat: lat,
|
||||
lng: lng,
|
||||
icon: '/assets/images/icon-destination.png'
|
||||
});
|
||||
|
||||
// set value in hidden input
|
||||
$('#map_lat').val(lat);
|
||||
$('#map_lng').val(lng);
|
||||
}
|
||||
|
||||
var map = new GMaps({
|
||||
div: '#m_gmap',
|
||||
lat: 14.6091,
|
||||
lng: 121.0223,
|
||||
click: function(e) {
|
||||
// handle click in map
|
||||
selectPoint(map, e.latLng);
|
||||
e.stop();
|
||||
}
|
||||
});
|
||||
var handleAction = function() {
|
||||
var text = $.trim($('#m_gmap_address').val());
|
||||
GMaps.geocode({
|
||||
address: text,
|
||||
callback: function(results, status) {
|
||||
map.removeMarkers();
|
||||
if (status == 'OK') {
|
||||
selectPoint(map, results[0].geometry.location);
|
||||
}
|
||||
},
|
||||
region: 'ph'
|
||||
});
|
||||
}
|
||||
|
||||
$('#m_gmap_btn').click(function(e) {
|
||||
e.preventDefault();
|
||||
handleAction();
|
||||
});
|
||||
|
||||
$("#m_gmap_address").keypress(function(e) {
|
||||
var keycode = (e.keyCode ? e.keyCode : e.which);
|
||||
if (keycode == '13') {
|
||||
e.preventDefault();
|
||||
handleAction();
|
||||
}
|
||||
});
|
||||
|
||||
{% if ftags.set_map_coordinate %}
|
||||
// check if we need to set map
|
||||
var latlng = new google.maps.LatLng({{ obj.getCoordinates.getLatitude }}, {{ obj.getCoordinates.getLongitude }});
|
||||
selectPoint(map, latlng);
|
||||
|
||||
// remove placeholder text
|
||||
$("[data-vehicle-field='1']").prop('placeholder', '');
|
||||
{% endif %}
|
||||
|
||||
{% if mode in ['update-processing', 'update-reassign-hub'] %}
|
||||
// display hub map
|
||||
var hmap = new GMaps({
|
||||
div: '#hub_map',
|
||||
lat: {{ obj.getCoordinates.getLatitude }},
|
||||
lng: {{ obj.getCoordinates.getLongitude }}
|
||||
});
|
||||
|
||||
hmap.addMarker({
|
||||
lat: {{ obj.getCoordinates.getLatitude }},
|
||||
lng: {{ obj.getCoordinates.getLongitude }},
|
||||
icon: '/assets/images/icon-destination.png',
|
||||
title: "Destination",
|
||||
content: "Destination"
|
||||
});
|
||||
|
||||
{% for hub in hubs %}
|
||||
hmap.addMarker({
|
||||
lat: {{ hub.hub.getCoordinates.getLatitude }},
|
||||
lng: {{ hub.hub.getCoordinates.getLongitude }},
|
||||
title: "{{ hub.hub.getName }}",
|
||||
content: "{{ hub.hub.getName }}",
|
||||
icon: '/assets/images/icon-outlet.png'
|
||||
});
|
||||
{% endfor %}
|
||||
|
||||
{% endif %}
|
||||
Loading…
Reference in a new issue