<style>
    .form-outer{
        display:inline-block;
        width:100%;
    }
    
    .w-20{
        float:left;
        padding:10px;
        width:20%;
    }
    
    .w-25{
        float:left;
        padding:10px 10px 0px 10px;
        width:20%;
    }
</style>
<?php
$class="";
$status="";
$exam_id="";
$freeze_status="";
if($this->session->userdata("exam_head_filter_class") !=""){
    $class=$this->session->userdata("exam_head_filter_class");    
}
        
if($this->session->userdata("exam_head_filter_status") !=""){
    $status=$this->session->userdata("exam_head_filter_status");    
}
        
if($this->session->userdata("exam_head_filter_exam_id") !=""){
    $exam_id=$this->session->userdata("exam_head_filter_exam_id");    
}
        
if($this->session->userdata("exam_head_filter_freeze_status") !=""){
    $freeze_status=$this->session->userdata("exam_head_filter_freeze_status");
}
?>
<div class="container-fluid mt-3 mb-3 bg-white">
    <div class="row">
        <div class="col-sm-12 pt-3 pb-3">
            <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(); ?>ExamManagement">Exam</a></li>
                <li class="breadcrumb-item">Exam Head Master</li>
            </ul>
            <a href="<?php echo base_url(); ?>ExamManagement/add_exam_head" class="btn btn-outline-warning " target="_blank">Add Exam Head</a>
            
            <form method="post" action="#">
                <div class="form-group w-20">
                    <label>Class</label>
                    <select class="form-control" name="class">
                        <option value="">--- Select Class ---</option>
                        <?php
                        $courses_table="courses";
                        $all_classes=$this->NewFeeModel->get_class_list($courses_table);
                        if($all_classes){
                            foreach($all_classes as $courses){
                        ?>
                        <option value="<?php echo $courses['course']; ?>" <?php if($class == $courses['course']){ echo "selected"; } ?>><?php echo $courses['course']; ?></option>
                        <?php
                            }
                        }
                        ?>
                    </select>
                </div>
                
                <div class="form-group w-20">
                    <label>Status</label>
                    <select class="form-control" name="status" >
                        <option value="">--- Status ---</option>
                        <option value="active" <?php if($status == "active"){ echo "selected"; }?>>Active</option>
                        <option value="inactive" <?php if($status == "inactive"){ echo "selected"; }?>>Inactive</option>
                    </select>
                </div>
                <div class="form-group w-20">
                    <label>Exam Mode</label>
                    <select class="form-control" name="exam_id" >
                        <option value="">--- Exam Mode ---</option>
                        <?php
                        $exams_table="all_exams";
                        $academic_session=$this->session->userdata("acedemic_session");
                        $all_exams=$this->ExamManagementModel->get_exams($academic_session,$exams_table);
                        if($all_exams){
                            foreach($all_exams as $exams){
                        ?>
                        <option value="<?php echo $exams['id']; ?>" <?php if($exam_id == $exams['id']){ echo "selected"; }?>><?php echo $exams['exam_title']; ?></option>
                        <?php
                            }
                        }
                        ?>
                    </select>
                </div>
                    
                <div class="form-group w-20">
                    <label>Freeze</label>
                    <select class="form-control" name="freeze_status" >
                        <option value="">--- Select Freeze Status ---</option>
                        <option value="Yes" <?php if($freeze_status == "Yes"){ echo "selected"; }?>>Yes</option>
                        <option value="No" <?php if($freeze_status == "No"){ echo "selected"; }?>>No</option>
                    </select>
                </div>
                
                <div class="form-group w-20">
                    <label>&nbsp;&nbsp;</label><br>
                    <button class="btn btn-warning" name="search_exam_head_filter" type="submit">Search</button>
                    <button type="submit" name="clear_search_filter" class="btn btn-outline-danger">Clear</button>
                </div>
            </form>
            <div class="table-responsive mt-3">
                <table class="table table-bordered table-striped" id="mytable">
                    <thead>
                        <tr>
                            <th class="sl_no">Sl.No.</th>
                            <th>Exam Head</th>
                            <th>MM</th>
                            <th>Class</th>
                            <th>Order</th>
                            <th>Exam</th>
                            <th>Status</th>
                            <th>Freeze</th>
                            <th>Action</th>
                            <th>Schedule</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $i=0;
                        if($all_exam_heads){
                            foreach($all_exam_heads as $exam_head){
                                $i=$i + 1;
                                $status=$exam_head['status'];
                        ?>
                        
                        
                        <tr>
                            <td><?php echo $i; ?></td>
                            <td><?php echo $exam_head['exam_head']; ?></td>
                            <td><?php echo $exam_head['mm']; ?></td>
                            <td><?php echo $exam_head['class']; ?></td>
                            <td><?php echo $exam_head['head_order']; ?></td>
                            <td><?php echo $exam_head['exam_title']; ?></td>
                            <td>
                                <?php
                                if($status == "active"){
                                ?>
                                <button class="btn btn-sm btn-outline-success">Active</button>
                                <?php
                                }else if($status == "inactive"){
                                ?>
                                <button class="btn btn-sm btn-outline-danger">Inactive</button>
                                <?php
                                }
                                ?>
                            </td>
                            <td><?php echo $exam_head['freeze']; ?></td>
                            <td>
                                <a href="<?php echo base_url(); ?>ExamManagement/update_exam_head/<?php echo $exam_head['id']; ?>" class="btn btn-outline-warning" target="_blank">
                                    <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pencil-square" viewBox="0 0 16 16">
                                        <path d="M15.502 1.94a.5.5 0 0 1 0 .706L14.459 3.69l-2-2L13.502.646a.5.5 0 0 1 .707 0l1.293 1.293zm-1.75 2.456-2-2L4.939 9.21a.5.5 0 0 0-.121.196l-.805 2.414a.25.25 0 0 0 .316.316l2.414-.805a.5.5 0 0 0 .196-.12l6.813-6.814z"/>
                                        <path fill-rule="evenodd" d="M1 13.5A1.5 1.5 0 0 0 2.5 15h11a1.5 1.5 0 0 0 1.5-1.5v-6a.5.5 0 0 0-1 0v6a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5v-11a.5.5 0 0 1 .5-.5H9a.5.5 0 0 0 0-1H2.5A1.5 1.5 0 0 0 1 2.5v11z"/>
                                    </svg>
                                </a>
                            </td>
                            <td>
                                <a href="<?php echo base_url(); ?>ExamManagement/exam_schedule/<?php echo $exam_head['id']; ?>" class="btn btn-outline-danger" target="_blank">View</a>
                            </td>
                        </tr>
                        <?php
                            }
                        }
                        ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>