<?php
$date=date('Y-m-d',strtotime($this->uri->segment('3')));
$class_tid=$this->uri->segment('4');


$eclass=$this->uri->segment('5');
$section=$this->uri->segment('6'); 
// $tid=$this->session->userdata('tid');
$get_teacher_information=$this->AttendenceModel->teacher_info($class_tid);
if($get_teacher_information){
foreach($get_teacher_information as $teacher_information){
// $eclass=$teacher_information['class_teacher'];
// $section=$teacher_information['class_teacher_section'];
}
}
?>
<div class="container-fluid 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"><a href="<?php echo base_url();?>Management/attendance_history">Attendance History</a></li>
                <li class="breadcrumb-item"><?php echo date('d-M-Y',strtotime($date));?></li>
                <li class="breadcrumb-item"><?php echo "Class : "; echo $eclass;echo"-"; echo $section; ?></li>
            </ul>   
            <div class="table-responsive">
                <table class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>Name</th>
                            <th>Father Name</th>
                            <th id="anni">Status</th>
                        </tr>    
                    </thead>  
                    <tbody>
                    <?php
                    // echo $date;
                    //  $eclass=$this->session->userdata('class_teacher');
                    //  $section=$this->session->userdata('class_teacher_section');
                    $table='attendence';
                    $attendance_data=$this->AttendenceModel->class_attendance_data($date,$eclass,$section);
                    $count = 0;
                    if($attendance_data){
                        foreach($attendance_data as $data){
                            $count = $count + 1;
                            $sid=$data['sid'];
                            $table1='student';
                            $student_information = $this->AttendenceModel->student_data($sid,$table1);
                            if($student_information){
                                foreach($student_information as $info){
    

                    ?>
                        <tr>
                            <td><?php echo $count;?></td>
                            <td><?php echo $info['student_name'];?></td>
                            <td><?php echo $info['father_name'];?></td>
                            <td><?php
                                if($data['status']=='p'){
                                ?>
                                <span class="btn btn-sm btn-success">Present</span>
                                <?php
                                }else if($data['status']=='a'){
                                ?>
                                <span class="btn btn-sm btn-danger">Absent</span>
                                <?php
                                }
                                ?>
                            </td>
                        </tr>    
                        <?php
                                }    
                            } 
                        }    
                    }else{
                    ?>
                    <tr><td colspan='4'>No data found !!</td></tr>
                    <?php
                    }
                    ?>
                    </tbody>
                </table>    
            </div>   
    
        </div>
    </div>
</div>