<?php
$sid=$this->uri->segment('3');
$acedemic_session=$this->session->userdata('acedemic_session');
$course_id='';
$student_subjects='student_subjects';

$get_students_course_info=$this->NewExamModel->student_course_info($sid,$acedemic_session);
if($get_students_course_info){
    foreach($get_students_course_info as $course_info){
        $course_id=$course_info['course_id'];
    }
}
$student_name='';
$student_table='student';
$student_profile=$this->NewExamModel->get_item_data($sid,$student_table);
if($student_profile){
    foreach($student_profile as $student){
        $student_name=$student['student_name'];
    }
}


$get_student_subjects=$this->NewExamModel->get_student_subjects($sid,$course_id,$acedemic_session);
?>
<div class="container mt-3 mb-3 pt-3 pb-3 bg-white">
    <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();?>Examination/course_students/<?php echo $course_id;?>">Exam</a></li>
                <li class="breadcrumb-item">Student Subjects</li>
                <li class="breadcrumb-item"><?php echo $student_name; ?></li>
            </ul>
            
            
            <div class="table-responsive">
                
                <table class="table table-bordered">
                    <thead>
                        <tr>
                            <th colspan="4"><a href="<?php echo base_url();?>Examination/add_student_subjects/<?php echo $sid;?>" class="btn btn-sm btn-success">Allot Subjects</a></th>
                        </tr>
                        <tr>
                            <th>#</th>
                            <th>Subject</th>
                            <th>Status</th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $count=0;
                        $subject_table='exam_subjects_'.$acedemic_session.'';
                        $all_subjects=$this->NewExamModel->get_course_active_subjects($course_id,$subject_table);
                        if($all_subjects){
                            foreach($all_subjects as $subjects){
                                $subjectid=$subjects['id'];
                                $student_subjects_data=$this->NewExamModel->student_subject_info($sid,$course_id,$acedemic_session,$subjectid);
                                if($student_subjects_data){
                                    foreach($student_subjects_data as $subjects_data){
                                        $count=$count + 1;
                        ?>
                        <tr>
                            <td><?php echo $count;?></td>
                            <td><?php echo $subjects['subject'];?></td>
                            <td><?php if($subjects['status']==1){echo "<span class='text-success'>Active</span>";}else if($subjects['status']==0){echo "<span class='text-danger'>Inactive</span>";}?></td>
                            <td></td>
                        </tr>
                        <?php
                                    }
                                }
                            }
                        }
                        
                        ?>
                        
                    </tbody>
                </table>
            </div>
            
            
        </div>
    </div>
</div>