<?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'];
}
}
?>
<!DOCTYPE html>
<html>
    <head>
        <title>Class-<?php echo $eclass."-".$section; ?></title>
        <style>
            .w-100{width:100%;}
            html{padding:0px;margin:0px;}
            body{padding:15px;margin:0px;font-size:15px;}
            table{border:2px solid;border-collapse:collapse;}
            
            tr td,tr th{border:1px solid;border-collapse:collapse;}
        </style>
        
        
        <style>
            #student {
                font-family: Arial, Helvetica, sans-serif;
                border-collapse: collapse;
                width: 100%;
            }

            #student td, #student th {
                border: 1px solid #ddd;
                padding: 5px;
            }

            #student td{
                font-size:12px;
                text-align:center;
            }

            #student tr:nth-child(even){background-color: #f2f2f2;}

            #student tr:hover {background-color: #ddd;}

            #student th {
                padding-top: 8px;
                padding-bottom: 8px;
                text-align: center;
                background-color: #EAEDED;
                /*color: white;*/
                font-size:13px;
                
            }
        </style>
    </head>
    <body>
        <div class="">
            <table class="table table-bordered table-striped" id="student">
                <thead>
                    <tr>
                        <th colspan="5">
                            <?php echo $eclass."-".$section.", ".date('d-M-Y',strtotime($date))." Attendance Report"; ?>
                        </th>
                    </tr>
                    <tr>
                        <th>#</th>
                        <th>Name</th>
                        <th>Father Name</th>
                        <th>Mobile Number</th>
                        <th id="anni">Status</th>
                    </tr>    
                </thead>  
                <tbody>
                <?php
                $table='attendence';
                $attendance_data=$this->AttendenceModel->class_attendance_data($date,$eclass,$section);
                $count = 0;
                if($attendance_data){
                    foreach($attendance_data as $data){
                        
                        $sid=$data['sid'];
                        $table1='student';
                        $student_information = $this->AttendenceModel->student_data($sid,$table1);
                        if($student_information){
                            foreach($student_information as $info){
                                if($data['status']=='a'){
                                    $count = $count + 1;

                        ?>
                        <tr>
                        <td><?php echo $count;?></td>
                        <td><?php echo $info['student_name'];?></td>
                        <td><?php echo $info['father_name'];?></td>
                        <td><?php echo $info['contact_no'].",".$info['alternate_no'];?></td>
                        <td><?php if($data['status']=='p'){
                        ?>
                        <span class="btn btn-sm btn-success" style="color:green;">Present</span>
                        <?php
                        }else if($data['status']=='a'){
                        ?>
                        <span class="btn btn-sm btn-danger" style="color:red;">Absent</span>
                        <?php
                        } ?></td>
                        </tr>    
                        <?php
                                }
                        }    
                        }
                        }
                        
                        
                        foreach($attendance_data as $data){
                        
                        $sid=$data['sid'];
                        $table1='student';
                        $student_information = $this->AttendenceModel->student_data($sid,$table1);
                        if($student_information){
                            foreach($student_information as $info){
                                if($data['status']=='p'){
                                    $count = $count + 1;

                        ?>
                        <tr>
                        <td><?php echo $count;?></td>
                        <td><?php echo $info['student_name'];?></td>
                        <td><?php echo $info['father_name'];?></td>
                        <td><?php echo $info['contact_no'].",".$info['alternate_no'];?></td>
                        <td style="color:green;"><?php 
                        if($data['status']=='p'){
                        ?>
                        <span class="btn btn-sm btn-danger">Present</span>
                        <?php
                        } ?>
                        </td>
                        </tr>    
                        <?php
                                }
                        }    
                        }
                        
                        

                        }
                        
                        
                        }
                        else{
                        ?>    
                        <tr><td colspan="5">No data found !!</td></tr>
                        <?php
                        }
                        ?>
                </tbody>
            </table>  
         
        </div>

  
    </body>
</html>    