<?php $host = gethostbyaddr($_SERVER["REMOTE_ADDR"]); ?>    
<div class="container">
    <div class="row">
        <div class="col-sm-12 text-center">
            <p id="demo"></p>
            <div>
                <div class="spinner-grow text-primary" role="status">
                    <span class="sr-only">Loading...</span>
                </div>
                <div class="spinner-grow text-secondary" role="status">
                    <span class="sr-only">Loading...</span>
                </div>
                <div class="spinner-grow text-success" role="status">
                    <span class="sr-only">Loading...</span>
                </div>
                <div class="spinner-grow text-danger" role="status">
                    <span class="sr-only">Loading...</span>
                </div>
                <div class="spinner-grow text-warning" role="status">
                    <span class="sr-only">Loading...</span>
                </div>
                <div class="spinner-grow text-info" role="status">
                    <span class="sr-only">Loading...</span>
                </div>
                <div class="spinner-grow text-light" role="status">
                    <span class="sr-only">Loading...</span>
                </div>
                <div class="spinner-grow text-dark" role="status">
                    <span class="sr-only">Loading...</span>
                </div>    
            </div>
        </div>    
    </div>
</div>
<script>

$(document).ready(function(){
    if (navigator.geolocation) {
        var x = document.getElementById("demo");        
        navigator.geolocation.getCurrentPosition(showPosition);
    }else{ 
        alert("Geolocation is not supported by this browser.");
    }


    function showPosition(position){
        var latd;
        var lotd;
        var table = 'staff_attendence';
        latd=position.coords.latitude;
        lotd=position.coords.longitude;
        var ip='<?php echo $host; ?>';
        $.ajax({
            url: '<?php echo base_url(); ?>Staff/start_day',
            type: 'POST',
            data: {ip:ip,latd:latd,lotd:lotd,table:table},
            success: function(data){
                window.location.assign("<?php echo base_url();?>Welcome/attendance");
            }
        });
    }
});
</script>