<style>
    
.dashboard-item{width:100%;}

</style>
<div class="container-fluid mt-3 mb-3 bg-white">
    <div class="row">
        <div class="col-sm-12 pt-3 pb-3">
            <div class="dashboard-item">
    
                <div class="table-responsive">
                    <table class="table table-bordered table-striped" id="mytable" style="width:100%;">
                        <thead>
                            <tr>
                                <td>#</td>
                                <td>Name</td>
                                <td>Desig.</td>
                                <td>Contact No</td>
                                <td>Status</td>
                                <td>Mark-In time</td>
                                <td>Mark-Out time</td>
                                <td>Check-in's</td>
                                <td>View places</td>
                            </tr>    
                        </thead>    
                        <tbody>
   
                        <?php 
                        $table='school_staff';
                        $all_employee=$this->WelcomeModel->get_data($table); 
                        if($all_employee){
                            $count1=0;    
                            foreach($all_employee as $emp){
                                if($emp['user_status'] ==1 && $emp['status'] == 0){
                                    $markintime='';    
                                    $locator_id='';
                                    $count1=$count1 + 1;
                                    $emp_id=$emp['id'];
                                    $markout_status=0;
                                    $markouttime='';
                        ?>
                            <tr> 
                                <td><?php echo $count1; ?></td>
                                <td><?php echo $emp['salutation']; echo " "; echo $emp['name']; ?></td>
                                <td><?php echo $emp['designation'];?></td>
                                <td><?php echo $emp['mobile_number'];?></td>
                                <td><?php 
                                $table1='staff_attendence';
                                $date=date('Y-m-d');
                                $attendance=$this->UserModel->get_attendance($table1,$emp_id,$date);
                                if($attendance){
                                    foreach($attendance as $attendance_data){
                                        $markintime=$attendance_data['markInTime'];
                                        $markout_status=$attendance_data['is_markout'];
                                        $markouttime=$attendance_data['markOutTime'];
                                        $locator_id=$attendance_data['id'];
                                        $attendance_status = $attendance_data['status'];
                                        if($attendance_status == 1){
                                            echo "<span class='text-success font-weight-bolder'>Present</span>";   
                                        }else{
                                            echo "<span class='text-warning'>Pending</span>";    
                                        }
                                    }
                                }else{
                                    echo "<span class='text-danger'>Pending</span>";    
                                }
                                ?>
                                </td>
                                <td><?php echo $markintime; ?></td>

                                <td><?php if($markout_status==1){
                                ?>
                                <?php echo date('h-i-sa',strtotime($markouttime)); ?>
                                <?php
                                }
                                else if($markout_status==0){echo "<span class='text-warning'>Pending</span>";
                                }?></td>

                                <td>
                                <?php
                                $get_checkin_data=$this->UserModel->day_checkins($date,$emp_id);
                                if($get_checkin_data){
                                $count = 0;    
                                foreach($get_checkin_data as $chekin_data){
                                $count = $count + 1;    
                                }    
                                echo $count;
                                }
                                ?>
                                </td>
                                <td><a href="<?php echo base_url();?>Welcome/markin_location/<?php echo $emp_id; ?>" class="btn btn-info">View</a></td>

                            </tr> 
                            <?php
                            }
    
                            }    
                            }

                            ?>

    
   

                        </tbody>
                    </table>    
                </div>    
    
            </div>    
        </div>    
    </div>
</div>

