<?php
$acedemic_session=$this->session->userdata('acedemic_session');
$course_id=$this->uri->segment('3');
$course_table='courses';
$course='';
$subject_stream='';
$get_course_info=$this->WelcomeModel->get_item_data($course_id,$course_table);
if($get_course_info){
    foreach($get_course_info as $info){
        $course=$info['course'];
        $subject_stream=$info['subject_stream'];
    }
}
?>

<div class="container bg-white mt-3 mb-3 pt-3 pb-3">
    <div class="row">
        <div class="col-sm-12">
            <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();?>School/courses">Courses</a></li>
                <li class="breadcrumb-item"><?php echo $course; echo " "; echo $subject_stream;?></li>
            </ul>
            <div class="table-responsive">
                <table class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            
                            <th colspan="3">Acedemic Session : <?php echo $this->session->userdata('ac_year');?></th>
                            <th colspan="3">Class: <?php echo $course; echo " "; echo $subject_stream;?></th>
                        </tr>
                        <tr>
                            <th>#</th>
                            <th>Sch. No.</th>
                            <th>Name</th>
                            <th>Father Name</th>
                            <th>D.O.B.</th>
                            <th>Barcode</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $count=0;
                        $student_table='student';
                        $get_all_students=$this->WelcomeModel->get_active_data_in_alp_order($student_table);
                        if($get_all_students){
                            foreach($get_all_students as $students){
                                $sid=$students['id'];
                                $check_student_in_acedemic_session=$this->WelcomeModel->get_student_in_acedemic_session($sid,$acedemic_session);
                                if($check_student_in_acedemic_session){
                                    foreach($check_student_in_acedemic_session as $ac_exist){
                                        
                                        if($ac_exist['course_id'] == $course_id){
                                            $count = $count + 1;
                                     ?>
                        <tr>
                            <td><?php echo $count;?></td>
                            <td><?php echo $students['sch_no'];?></td>
                            <td><?php echo $students['student_name'];?></td>
                            <td><?php echo $students['father_name'];?></td>
                            <td><?php if($students['dob']){ echo date('d-m-Y',strtotime($students['dob']));}?></td>
                            <td><a href="<?php echo base_url()."barcode/".$students['barcode']; ?>" target="_blank"><img src="<?php echo base_url()."barcode/".$students['barcode']; ?>"></a></td>
                        </tr>                            
                                                                 
                                     
                        <?php
                                        }
                                    }
                                }
                                
                            }
                        }
                        ?>
                        
                        

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