<?php 
$exam_paper_schedule_id=$this->uri->segment('3');
$exam_paper_table='exam_schedule';
$get_exam_schedule_paper_info=$this->NewExamModel->get_item_data($exam_paper_schedule_id,$exam_paper_table);
if($get_exam_schedule_paper_info){
    foreach($get_exam_schedule_paper_info as $exam_schedule_paper_info){
        $exam_id=$exam_schedule_paper_info['exam_id'];
        $exam_table='all_exams';
        $get_exam_info=$this->NewExamModel->get_item_data($exam_id,$exam_table);
        
        $course_id=$exam_schedule_paper_info['course_id'];
        $course_table='courses';
        $get_course_info=$this->NewExamModel->get_item_data($course_id,$course_table);
        
        $exam_shift_table='exam_shift';
        $all_exam_shift=$this->NewExamModel->exam_data($exam_id,$exam_shift_table);
        
        $exam_date_table='exam_date';
        $all_exam_date=$this->NewExamModel->exam_data($exam_id,$exam_date_table);
        
        $acedemic_session=$exam_schedule_paper_info['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">Exam</a></li>
                <li class="breadcrumb-item"><a href="<?php echo base_url();?>Examination/schedule/<?php echo $exam_id;?>">Exam Schedule</a></li>
                <li class="breadcrumb-item">Update Exam Schedule</li>
            </ul>
            
            <form method="post" action="#">
                <?php
                if($success){
                ?>
                <div class="alert alert-success"><?php echo $success;?></div>
                <?php 
                }
                if($error){
                ?>
                <div class="alert alert-success"><?php echo $error;?></div>
                <?php 
                }
                ?>
                <input type="hidden" value="<?php echo $exam_paper_schedule_id;?>" name="exam_paper_schedule_id">
                <input type="hidden" name="exam_id" vlaue="<?php echo $exam_id;?>" >
                <input type="hidden" name="acedemic_session" value="<?php echo $acedemic_session?>" >
                <input type="hidden" name="course_id" value="<?php echo $course_id;?>" >
                <div class="form-group">
                    <label>Acedemic Session</label>
                    <input type="text" class="form-control" name="acedemic_session_info" value="<?php echo $exam_schedule_paper_info['acedemic_session_info'];?>" readonly>
                </div>
                <div class="form-group">
                    <label>Exam</label>
                    <?php
                    if($get_exam_info){
                        foreach($get_exam_info as $exam_info){
                    ?>
                    <input type="text" name="exam_title" class="form-control" value="<?php echo $exam_info['exam_title'];?>" placeholder="Exam Title" readonly>
                    <?php
                        }
                    }
                    ?>
                </div>
                
                <div class="form-group">
                    <label>Exam Head</label>
                    <select class="form-control" name="exam_head">
                        <?php
                        $exam_head_table='exam_heads_'.$acedemic_session.'';
                        $all_exam_heads=$this->NewExamModel->get_data($exam_head_table);
                        if($all_exam_heads){
                            foreach($all_exam_heads as $exam_heads){
                        ?>
                        <option value="<?php echo $exam_heads['id'];?>"  <?php if($exam_schedule_paper_info['exam_head'] == $exam_heads['id']){echo "selected";} ?>><?php echo $exam_heads['exam_head'];?></option>
                        <?php
                            }
                        }
                        ?>
                    </select>
                </div>
                
                <div class="form-group">
                    <label>Course</label>
                    <?php
                    if($get_course_info){
                        foreach($get_course_info as $course_info){
                    ?>
                    <input type="text" class="form-control" name="course_info" value="<?php echo $course_info['course']; echo " "; echo $course_info['subject_stream'];?>" readonly>
                    <?php
                        }
                    }
                    ?>
                </div>
                
                <div class="form-group">
                    <label>Course Subjects</label>
                    <select class="form-control" name="subject_id">
                        <?php
                        $subjects_table='exam_subjects_'.$acedemic_session.'';
                        $all_subjects=$this->NewExamModel->get_course_subjects($course_id,$subjects_table);
                        if($all_subjects){
                            foreach($all_subjects as $subjects){
                        ?>
                        <option value="<?php echo $subjects['id'];?>" <?php if($exam_schedule_paper_info['subject_id'] == $subjects['id']){echo "selected";}?>><?php echo $subjects['subject']; ?></option>
                        <?php
                            }
                        }
                        ?>
                    </select>
                </div>
                
                <div class="form-group">
                    <label>Exam Paper</label>
                    <input type="text" value="<?php echo $exam_schedule_paper_info['exam_paper_name'];?>" name="exam_paper_name" class="form-control" >
                </div>
                
                
                
                <div class="form-group">
                    <label>Exam Date</label>
                    <select class="form-control" name="exam_date_id">
                        <?php
                        if($all_exam_date){
                            foreach($all_exam_date as $exam_date_data){
                        ?>
                        <option value="<?php echo $exam_date_data['id'];?>"><?php echo date('d-M-Y',strtotime($exam_date_data['exam_date']));?></option>
                        <?php
                            }
                        }
                        ?>
                    </select>
                    <!--<input type="date" value="<?php echo date('Y-m-d',strtotime($exam_schedule_paper_info['exam_date']))?>" name="exam_date" class="form-control">-->
                
                </div>
                
                <div class="form-group">
                    <label>Exam Shift</label>
                    <select class="form-control" name="exam_shift">
                        <?php
                        if($all_exam_shift){
                            foreach($all_exam_shift as $exam_shift_data){
                        ?>
                        <option value="<?php echo $exam_shift_data['id'];?>"><?php echo $exam_shift_data['start_time']; echo "<b class='text-danger'> to </b>"; echo $exam_shift_data['end_time'];?></option>
                        <?php
                            }
                        }
                        ?>
                    </select>
                </div>
                
                <div class="form-group">
                    <button class="btn btn-sm btn-success" type="submit" name="update_exam_paper_schedule">Udate Schedule</button>
                </div>
                
            </form>
            
        </div>
    </div>
</div>
<?php
    }
}
?>