<?php 
$course_id=$this->uri->segment('4');
$exam_id=$this->uri->segment('3');
$exam_table='all_exams';
$courses_table='courses';
$get_exam_info=$this->NewExamModel->get_item_data($exam_id,$exam_table);
$get_course_info=$this->NewExamModel->get_item_data($course_id,$courses_table);
$exam_title='';
$acedemic_session=$this->session->userdata('acedemic_session');
$exam_head_table="exam_heads_".$acedemic_session."";
$exam_type='';
if($get_exam_info){
    foreach($get_exam_info as $exam_info){
        $exam_title=$exam_info['exam_title'];
        $exam_type=$exam_info['exam_type'];
    }
}

$get_exam_heads=$this->NewExamModel->get_exam_head_for_session_for_exam($exam_type,$course_id,$acedemic_session,$exam_head_table);
?>

<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">Exam</a></li>
                <li class="breadcrumb-item"><a href="<?php echo base_url();?>Examination/schedule/<?php echo $exam_id?>"><?php echo $exam_title;?></a></li>
                <?php
                if($get_course_info){
                    foreach($get_course_info as $course_info){
                ?>
                <li class="breadcrumb-item"><?php echo $course_info['course']; echo " "; echo $course_info['subject_stream'];?></li>
                <?php
                    }
                }
                ?>
            </ul>
            
            <div class="table-responsive">
                <table class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <th>Subject</th>
                            <?php
                            if($get_exam_heads){
                                foreach($get_exam_heads as $exam_heads){
                            ?>
                            <th><?php echo $exam_heads['exam_head'];?></th>
                            <?php
                                }
                            }
                            ?>           
                        </tr>
                        <?php
                        $sub_count=0;
                            $subject_table='exam_subjects_'.$acedemic_session.'';
                            $all_active_subjects=$this->NewExamModel->get_course_active_subjects($course_id,$subject_table);
                            if($all_active_subjects){
                                foreach($all_active_subjects as $subjects){
                             
                                
                        ?>
                        <tr>
                            <th><?php echo $subjects['subject'];?></th>
                            <?php
                            
                            if($get_exam_heads){
                                foreach($get_exam_heads as $exam_heads){
                            ?>
                            <td><?php echo $exam_heads['exam_head'];?></td>
                            <?php
                                }
                            }
                                   
                                }
                            }
                            ?>           
                        </tr>
                    </thead>
                </table>
            </div>
            
        </div>
    </div>
</div>