<style>
    body{background:#EAEDED;}
    a:hover{text-decoration:none; color:black;}
</style>
<div class="container-fluid 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>
    
	        <!--<a href="<?php base_url();?>add_courses" class="btn btn-primary mt-3 mb-3">Add Courses</a>-->
	        <div class="table-responsive">
                <table class="table table-bordered table-striped" id="mytable">

                    <thead>
                        <tr>
                            <th>Count</th>
                            <th>Course Name</th>
                            <th>View Student</th>
                            <th>View Pdf</th>
                            <th>Export Excel</th>
                            <th>Promote</th>
                            <th>Barcode</th>
                            <th>APR TO MARCH FEE PAID</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(); ?>School/course_students/<?php echo $course_id;?>" class="btn btn-sm btn-success" target="_blank">View(<?php echo $course_student_count;?>)</a>
                        </td>
                    <?php  ?>

                    <td><a href="<?php echo base_url(); ?>School/pdf/<?php echo $course_id;?>" class="btn btn-sm btn-info" target="_blank">View</a></td>
                    <td><a href="<?php echo base_url(); ?>Export/course_students/<?php echo $course_id;?>" class="btn btn-sm btn-info" target="_blank">Export</a></td>
                    <td>
                        <a href="<?php echo base_url();?>Promotion/course_students/<?php echo $course_id; ?>" class="btn btn-sm btn-success" target="_blank">Promote</a>
                    <!--<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();?>Barcodelist/course_wise_codes/<?php echo $data['id'];?>" target="_blank" class="btn btn-sm btn-info">View</a>&nbsp;<a href="<?php echo base_url();?>Barcodelist/download_barcodes/<?php echo $data['id'];?>" target="_blank" class="btn btn-sm btn-info"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-file-arrow-down-fill" viewBox="0 0 16 16"><path d="M12 0H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2zM8 5a.5.5 0 0 1 .5.5v3.793l1.146-1.147a.5.5 0 0 1 .708.708l-2 2a.5.5 0 0 1-.708 0l-2-2a.5.5 0 1 1 .708-.708L7.5 9.293V5.5A.5.5 0 0 1 8 5z"/></svg></a></td>
                    <td>
                        <a href="<?php echo base_url(); ?>Fee/defaulter_new_data/<?php echo $data['id']; ?>" target="_blank" class="btn btn-sm btn-success">View</a>
                    </td>
                    </tr>
            <?php
                }
            }
            ?>
            <tr>
                <th>Total</th>
                <th></th>
                <th><?php echo $total;?></th>
                <th></th>
                <th></th>
            </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>
</div>