<?php 
$emp_id=$this->uri->segment('3');
$emp_name='';
$staff_table='school_staff';
$emp_data=$this->WelcomeModel->get_item_data($emp_id,$staff_table);
if($emp_data){
foreach($emp_data as $emp_info){
$emp_name=$emp_info['name'];
}    
}
?>

<div class="container mt-3 mb-3 bg-white">
    <div class="row">
        <div class="col-sm-12 pt-3 pb-3">
            <ul class="breadcrumb" >
                <li class="breadcrumb-item"><a href="<?php echo base_url();?>Welcome/">Home</a></li>
                <li class="breadcrumb-item">User location</li>
                <li class="breadcrumb-item"><?php echo $emp_name;?></li>
            </ul>
        </div>

        <?php
        $table='staff_attendence';
        $date=date('Y-m-d');
        $eid=$this->uri->segment('3');
        $get_user_data=$this->UserModel->get_user_markin_location_data($table,$eid,$date);
        if($get_user_data){
            foreach($get_user_data as $data){
                $latitude=$data['latitude'];
                $longitude=$data['longitude'];
                $markout_latd=$data['markout_latd'];
                $markout_lotd=$data['markout_lotd'];
                $markin_time=$data['markInTime'];
                $markout_time=$data['markOutTime'];
              
        ?>

        <div class="col-sm-6 pt-3 pb-3">
            <p class="text-danger">Mark In: <?php echo date('h-i-sa',strtotime($markin_time));?></p>
            <iframe width="100%" height="300" src="https://maps.google.com/maps?q=<?php echo $latitude; ?>,<?php echo $longitude; ?>&output=embed"></iframe>

        </div>
        <div class="col-sm-6 pt-3 pb-3">
            <p>Mark Out : <?php echo date('h-i-sa',strtotime($markout_time));?></p>
            <iframe width="100%" height="300" src="https://maps.google.com/maps?q=<?php echo $markout_latd; ?>,<?php echo $markout_lotd; ?>&output=embed" ></iframe>    
        </div>

    
        <?php 
            }  
        }else{
        ?>
        <div class="col-sm-12 p-3">
            <div class="alert alert-danger">No Mark In found.</div>  
        </div>
        <?php
        }

        $get_checkin_data=$this->UserModel->day_checkins($date,$eid);
        if($get_checkin_data){
            $count = 0;    
            foreach($get_checkin_data as $chekin_data){
                $count = $count + 1;    
        ?>
        <div class="col-sm-12 pt-3 pb-3">
            <h5 style="text-transform:uppercase;" class="bg-warning text-white p-2"><?php echo $chekin_data['place']; echo ":"; echo date('h-i-sa',strtotime($chekin_data['checkin_time'])); echo "&nbsp;- "; echo date('h-i-sa',strtotime($chekin_data['checkout_time'])); ?></h5>
        </div>
        <div class="col-sm-6 pt-3 pb-3">
            <p>Check In : <?php echo date('h-i-sa',strtotime($chekin_data['checkin_time']));?></p>    
            <iframe width="100%" height="300" src="https://maps.google.com/maps?q=<?php echo $chekin_data['latd']; ?>,<?php echo $chekin_data['lotd']; ?>&output=embed" ></iframe>      
        </div>
        <div class="col-sm-6 pt-3 pb-3">
            <p>Check Out : <?php echo date('h-i-sa',strtotime($chekin_data['checkout_time']));?></p>
            <iframe width="100%" height="300" src="https://maps.google.com/maps?q=<?php echo $chekin_data['checkout_latd']; ?>,<?php echo $chekin_data['checkout_lotd']; ?>&output=embed"></iframe>      
        </div>

        <?php
            }    

        }else{
        ?>
        <div class="col-sm-12 p-3">
            <div class="alert alert-danger">No Check In found.</div>  
        </div>
        <?php
        }
        ?>

    </div>    
</div>