<?php 
$class=$this->session->userdata("subject_master_class");
$exam_type=$this->session->userdata("subject_master_exam_type");
$status=$this->session->userdata("subject_master_status");
$subject_type=$this->session->userdata("subject_master_subject_type");
?>

<style>
    .form-outer{
        display:inline-block;
        width:100%;
    }
    
    .w-20{
        float:left;
        padding:10px;
        width:20%;
    }
</style>
<div class="container-fluid 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">Exam Subjet Master</li>
            </ul>
            <a href="<?php echo base_url(); ?>ExamManagement/add_new_subject" class="btn btn-sm btn-outline-success mb-3">Add New Subject</a>
            
            <div class="form-outer">
                <form method="post" action="#">
                    <div class="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>Exam Type</label>
                        <select class="form-control" name="exam_type" >
                            <option value="">--- Select Exam Type ---</option>
                            <option value="Marks" <?php if($exam_type == "Marks"){ echo "selected"; }?>>Marks</option>
                            <option value="Grade" <?php if($exam_type == "Grade"){ echo "selected"; }?>>Grade</option>
                        </select>
                    </div>
                    
                    <div class="form-group w-20">
                        <label>Subject Type</label>
                        <select class="form-control" name="subject_type" >
                            <option value="">--- Select Subject Type ---</option>
                            <option value="Main Subject" <?php if($subject_type == "Main Subject"){ echo "selected"; }?>>Main Subject</option>
                            <option value="Additional Subject" <?php if($subject_type == "Additional Subject"){ echo "selected"; }?>>Additional Subject</option>
                        </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>&nbsp;&nbsp;</label><br>
                        <button class="btn btn-info" name="search">Search</button>
                    </div>
                    
                </form>
            </div>    
            <div class="table-responsive mt-3">
                <table class="table table-bordered" id="mytable">
                    <thead>
                        <tr>
                            <th class="sl_no">Sl. No.</th>
                            <th>Class</th>
                            <th>Subject</th>
                            <th>Status</th>
                            <th>Order</th>
                            <th>Subject Type</th>
                            <th>Exam Type</th>
                            <th>MM</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $i=0;
                        if($all_subjects){
                            foreach($all_subjects as $subjects){
                                $i=$i + 1;
                                $status=$subjects['status'];
                        ?>
                        <tr>
                            <td><?php echo $i; ?></td>
                            <td><?php echo $subjects['class']; ?></td>
                            <td><?php echo $subjects['subject']; ?></td>
                            <td>
                                <?php 
                                if($status == "active"){
                                ?>
                                <button class="btn btn-outline-success">Active</button>
                                <?php
                                }else if($status == "inactive"){
                                ?>
                                <button class="btn btn-outline-danger">Inactive</button>
                                <?php
                                }
                                ?>
                            </td>
                            <td><?php echo $subjects['subject_order']; ?></td>
                            <td><?php echo $subjects['subject_type']; ?></td>
                            <td><?php echo $subjects['exam_type']; ?></td>
                            <td><?php echo $subjects['MM']; ?></td>
                            <td>
                                <a href="<?php echo base_url(); ?>ExamManagement/update_subject_master/<?php echo $subjects['id']; ?>" class="btn btn-outline-warning">
                                    <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>
                        </tr>
                        <?php
                            }
                        }
                        ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>