<?php
$subject_id=$this->uri->segment('3');
$acedemic_session=$this->session->userdata('acedemic_session');
$subjects_table='exam_subjects_'.$acedemic_session.'';
$get_subject_info=$this->NewExamModel->get_item_data($subject_id,$subjects_table);
if($get_subject_info){
    foreach($get_subject_info as $subject_info){
        $course_id=$subject_info['course_id'];
        $class="";
        $courses_table="courses";
        $get_course_data=$this->NewExamModel->get_item_data($course_id,$courses_table);
        if($get_course_data){
            foreach($get_course_data as $course_data){
                $class=$course_data['course'];
            }
        }
?>

<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">Exam</li>
                <li class="breadcrumb-item">Update Subject Information</li>
            </ul>
            
            <div>
                <form method="post" action="#">
                    <?php 
                    if($success){
                    ?>
                    <div class="alert alert-success"><?php echo $success;?></div>
                    <?php
                    }
                    if($error){
                    ?>
                    <div class="alert alert-danger"><?php echo $error;?></div>
                    <?php
                    }
                    ?>
                    <div class="form-group">
                        <label>Subject</label>
                        <input type="hidden" name="subject_id" value="<?php echo $subject_id;?>">
                        <input type="text" name="subject" class="form-control" value="<?php echo $subject_info['subject'];?>">
                    </div>
                    
                    <div class="form-group">
                        <label>Subject Order</label>
                        <input type="text" name="subject_order" class="form-control" value="<?php echo $subject_info['subject_order'];?>">
                    </div>
                    
                    
                    <div class="form-group">
                        <label>MM</label>
                        <input type="text" name="MM" class="form-control" value="<?php echo $subject_info['MM'];?>">
                    </div>
                    
                    <div class="form-group">
                        <label>Exam Type</label>
                        <select class="form-control" name="exam_type">
                            <option value="Marks" <?php if($subject_info['exam_type'] =='Marks'){echo "selected";}?>>Marks</option>
                            <option value="Grade" <?php if($subject_info['exam_type'] =='Grade'){echo "selected";}?>>Grade</option>
                        </select>
                        
                    </div>
                    
                    
                    <div class="form-group">
                        <label>Subject Type</label>
                        <!--<input type="text" name="subject_type" class="form-control" value="">-->
                        <select class="form-control" name="subject_type">
                            <option value="Main Subject" <?php if($subject_info['subject_type'] == 'Main Subject'){echo "selected";}?>>Main Subject</option>
                            <option value="Additional Subject" <?php if($subject_info['subject_type'] == 'Additional Subject'){echo "selected";}?>>Additional Subject</option>
                        </select>
                    </div>
                    
                    
                    <div class="form-group">
                        <label>Class</label>
                        <input type="text" name="class" value="<?php echo $class?>" class="form-control" readonly>
                    </div>
                    <div class="form-group">
                        <label>Hic Subject</label>
                        <select class="form-control" name="hic_subject_id">
                            
                        
                        <?php
                        $table="exam_subjects_3_new";
                        $get_class_subjects=$this->NewExamModel->get_class_subjects($class,$table);
                        if($get_class_subjects){
                            foreach($get_class_subjects as $class_subjects){
                        ?>
                        <option value="<?php echo $class_subjects['id']; ?>" <?php if($subject_info['subject'] == $class_subjects['subject']){ echo "selected"; } ?>><?php echo $class_subjects['subject']; ?></option>
                        <?php
                            }
                        }
                        ?>
                        </select>
                    </div>
                    
                    <div class="form-group">
                        <button type="submit" class="btn btn-sm btn-success" name="update_subject_info">Update Subject</button>
                    </div>
                    
                </form>
            </div>
        </div>
    </div>
</div>

<?php
    }
}
?>