<?php
/* Smarty version 3.1.34-dev-7, created on 2020-10-30 05:29:35
  from '/home/bscom/public_html/crm/ui/theme/default/crmviewmap.tpl' */

/* @var Smarty_Internal_Template $_smarty_tpl */
if ($_smarty_tpl->_decodeProperties($_smarty_tpl, array (
  'version' => '3.1.34-dev-7',
  'unifunc' => 'content_5f9b343fa341c1_46859432',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    '426cc377b58b329ac321c550db2aa1e4fb85929a' => 
    array (
      0 => '/home/bscom/public_html/crm/ui/theme/default/crmviewmap.tpl',
      1 => 1592525325,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
  ),
),false)) {
function content_5f9b343fa341c1_46859432 (Smarty_Internal_Template $_smarty_tpl) {
$_smarty_tpl->_loadInheritance();
$_smarty_tpl->inheritance->init($_smarty_tpl, false);
?>

<?php 
$_smarty_tpl->inheritance->instanceBlock($_smarty_tpl, 'Block_16014090645f9b343fa224b1_23024467', "style");
?>

<?php 
$_smarty_tpl->inheritance->instanceBlock($_smarty_tpl, 'Block_16464024355f9b343fa25779_57483560', "content");
?>



    

    <?php echo '<script'; ?>
>


    


        function assign_driver(cid, invoiceid){
          var _url = $("#_url").val();


          // alert(invoiceid);

              $.post(_url + 'invoices/assign_driver/', {
                  cid: cid,
                  invoice: invoiceid


              })
                  .done(function (data) {
                      alert(data);

                  });
        }
     

  

 
 //initMap();
                function initMap() {
                 //   var latitude = 1.3521;
                  //var longitude = 103.8198;
                  var latitude = parseFloat(document.getElementById('currentlatitude').value);
                  var longitude = parseFloat(document.getElementById('currentlongitude').value);
                 // alert(longitude);
                  var uluru = {lat: latitude, lng: longitude};

                  var loc = [];
                 /* var locations = [];
                 
                  for(i=0 , j=0 ;i < temp.length; i++, j++){

                    locations[j] = ["aaa", temp[i].c3, temp[i].c4, i];

                  }*/
                  // The map, centered at Uluru
                  var map = new google.maps.Map(
                      document.getElementById('map'), {zoom: 9, center: new google.maps.LatLng(latitude, longitude)});
                  // The marker, positioned at Uluru
                  var marker = new google.maps.Marker({position: uluru, map: map});



                  /*for (i = 0; i < locations.length; i++) {
                        marker = new google.maps.Marker({
                        position: new google.maps.LatLng(locations[i][1], locations[i][2]),
                        map: map
                        });

                        google.maps.event.addListener(marker, 'click', (function(marker, i) {
                        return function() {
                            infowindow.setContent(locations[i][0]);
                            infowindow.open(map, marker);
                        }
                        })(marker, i));
                    }*/
                calcRoute(1.3521, 103.8198, 1.4414267, 103.7532869 );
                }

                var map;
	            var waypoints;

                function calcRoute(endlat, endlon, startlat, startlon) {
                  //alert(endlon);
                      var mapLayer = document.getElementById("map");
                      var centerCoordinates = new google.maps.LatLng(startlat, startlon);
                    var defaultOptions = { center: centerCoordinates, zoom: 9 }
                    map = new google.maps.Map(mapLayer, defaultOptions);

                    var directionsService = new google.maps.DirectionsService;
                    var directionsDisplay = new google.maps.DirectionsRenderer;
                    directionsDisplay.setMap(map);

                       var latitude = parseFloat(document.getElementById('currentlatitude').value);
                  var longitude = parseFloat(document.getElementById('currentlongitude').value);
                 // alert(longitude);
                  var uluru = {lat: latitude, lng: longitude};

                var marker = new google.maps.Marker({position: uluru, map: map});




                  drawPath(directionsService, directionsDisplay,endlat,endlon , startlat, startlon);
                  //return false;
                }
                  function drawPath(directionsService, directionsDisplay,endlat,endlon, startlat, startlon) 
                  {
                    //alert(endlon);
                    directionsService.route({
                    //  origin: new google.maps.LatLng(startlat, startlon), //mobile city
                    origin: new google.maps.LatLng(startlat, startlon), //mobile city
                    destination: new google.maps.LatLng(endlat, endlon),
                    //  destination: new google.maps.LatLng(endlat, endlon),
                    //  waypoints: waypoints,
                      optimizeWaypoints: true,
                      travelMode: 'DRIVING'
                    }, function(response, status) {
                        if (status === 'OK') {

                        directionsDisplay.setDirections(response);
                        } else {
                      //      alert("d");
                        window.alert('Problem in showing direction due to ' + status);
                        }
                    });






                }





 

    <?php echo '</script'; ?>
>
    <?php echo '<script'; ?>
 async defer
    src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDK9Wyy81NpY3wkqekhOF4EBFHt5Tc-Yyw&callback=initMap">
    <?php echo '</script'; ?>
>




<?php }
/* {block "style"} */
class Block_16014090645f9b343fa224b1_23024467 extends Smarty_Internal_Block
{
public $subBlocks = array (
  'style' => 
  array (
    0 => 'Block_16014090645f9b343fa224b1_23024467',
  ),
);
public function callBlock(Smarty_Internal_Template $_smarty_tpl) {
?>

    
    <style>
       /* Set the size of the div element that contains the map */
      #map {
        height: 400px;  /* The height is 400 pixels */
        width: 100%;  /* The width is the width of the web page */
       }

       table, th, td {
  border: 1px solid black;
  border-collapse: collapse;
}
    </style>

<?php
}
}
/* {/block "style"} */
/* {block "content"} */
class Block_16464024355f9b343fa25779_57483560 extends Smarty_Internal_Block
{
public $subBlocks = array (
  'content' => 
  array (
    0 => 'Block_16464024355f9b343fa25779_57483560',
  ),
);
public function callBlock(Smarty_Internal_Template $_smarty_tpl) {
?>

<meta http-equiv="refresh" content="60" />

   
    <div class="row">
        <div class="col-md-12">
        
         <?php if ($_smarty_tpl->tpl_vars['msg']->value == '') {?>
       
            <h3 class="ibilling-page-header">Current Location Of Driver
             <input type="text" id="currentlatitude" readonly value="<?php echo $_smarty_tpl->tpl_vars['location']->value[0]['latitude'];?>
"/>
             <input type="text" id="currentlongitude" readonly value="<?php echo $_smarty_tpl->tpl_vars['location']->value[0]['longitude'];?>
"/>

             </h3>
             <div class="ibox-content">
      <table class="table table-hover" >
<tr>
  <td><label>Delivery Challan </label></td>
  <td><label><?php echo $_smarty_tpl->tpl_vars['deliverychellan']->value[0]['invoicenum'];
echo $_smarty_tpl->tpl_vars['deliverychellan']->value[0]['cn'];?>
</label></td>

</tr>
<tr>
    <td>Customer Name </td>
    <td><?php echo $_smarty_tpl->tpl_vars['customer']->value[0]['account'];?>
</td>

</tr>

<tr>
    <td>Address </td>
    <td><?php echo $_smarty_tpl->tpl_vars['customer']->value[0]['address'];?>
, <?php echo $_smarty_tpl->tpl_vars['customer']->value[0]['zip'];?>
</td>

</tr>
<tr>
    <td>Driver Name </td>
    <td><?php echo $_smarty_tpl->tpl_vars['driver']->value[0]['fullname'];?>
</td>

</tr>
</table>


</div>


             
        <?php } else { ?>
            <h3><?php echo $_smarty_tpl->tpl_vars['msg']->value;?>
</h3>
         <?php }?>


  


        </div>
    </div>


    <div class="row">
        <div class="col-md-12">
            <div class="panel">
                <div class="panel-body">


                    <div class="col-sm-8">
                        <div id="map"></div>
                    </div>
                    





                </div>
            </div>
        </div>
    </div>

  

<?php
}
}
/* {/block "content"} */
}
