<style>
    body{background:#EAEDED;}
    a:hover{text-decoration:none; color:black;}
</style>
<div class="container mt-3 bg-white">
    <div class="row">
        <div class="col-sm-12 p-3">
    
            <ul class="breadcrumb">
                <li class="breadcrumb-item"><?php echo $this->session->userdata('ac_year'); ?></li>    
                <li class="breadcrumb-item"><a href="<?php echo base_url(); ?>Welcome">Home</a></li>
                <li class="breadcrumb-item">Courses</a></li>
            </ul>
	        <div class="table-responsive">
                <table class="table table-bordered table-striped" id="">

                    <thead>
                        <tr>
                            <th>Count</th>
                            <th>Course Name</th>
                            <th>View Student</th>
                        </tr>
                    </thead>
                <tbody>
                <?php
                    $table='courses';
                    $total=0;
                    $get_courses_data=$this->WelcomeModel->get_data($table);
                    $count=0;
                    $acedemic_session=$this->session->userdata('acedemic_session');
    
                    if($get_courses_data){
                        foreach($get_courses_data as $data){
                            $count= $count + 1;
                            $course_student_count=0;
                ?>
                    <tr>
                    <td><?php echo $count; ?></td>
                    <td><?php echo htmlspecialchars_decode($data['course']); if($data['subject_stream'] !=''){echo " - "; echo $data['subject_stream'];} ?></td>
                <?php
                    $course=$data['course'];
                    $course_id=$data['id'];
                    $get_all_course_students=$this->WelcomeModel->get_course_students_by_ac_session_by_course_id($acedemic_session,$course_id);
                    if($get_all_course_students){
                        foreach($get_all_course_students as $course_students){
                            $student_table='student';
                            $sid=$course_students['sid'];
                            $get_item_data=$this->WelcomeModel->get_item_data($sid,$student_table);
                            if($get_item_data){
                                foreach($get_item_data as $student_info){
                                    if($student_info['status']==1){
                                        $course_student_count=$course_student_count + 1;
                                    }
                                }
                            }
                            
                        }
                    }  
                    
                    $total=$total + $course_student_count;
                    ?>
                    <td>
                        <a href="<?php echo base_url(); ?>Settings/course_students/<?php echo $course_id;?>" class="btn btn-primary">View(<?php echo $course_student_count;?>)</a>
                        </td>
                    <?php  ?>

                    
                    <!--<td>
                    <a href="<?php echo base_url();?>Developer/promote_course_all_students/<?php echo $data['course'];?>" class="btn btn-sm btn-info">Promote All</a></td>-->
                    <!--<td>-->
                    <!--    <a href="<?php echo base_url();?>Developer/update_course_id/<?php echo $data['id'];?>">Update Course Id</a>-->
                    <!--</td>-->
                    
                    <!--<td><a href="<?php echo base_url();?>"></a></td>-->
                    </tr>
            <?php
                }
            }
            ?>
            <tr>
                <th>Total</th>
                <th></th>
                <th><?php echo $total;?></th>
            </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>
</div>