<style>
    h1{
        font-size:26px;
        text-align:center;
    }
    tr th,tr td{
        text-align:center;
    }
    .w_25{
        width:25%;
        float:left;
        padding:10px;
    }
    
    .form-outer{
        display:flex;
    }
    
    .form-outer form{
        width:100%;
    }
</style>

<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(); ?>Examination/all_classes">All Courses</a>
                </li>
                <li class="breadcrumb-item">Add New Exam </li>
            </ul>
            
            <div class="p-3 form-outer">
                <form method="post" action="#">
                    <h1>Add New Exam</h1><hr>
                    
                    <?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 w_25">
                        <label>Exam Title</label>
                        <input type="text" name="exam_title" class="form-control" placeholder="Exam Title">
                    </div>
                    <?php
                    $acedemic_session=$this->session->userdata('acedemic_session');
                    $y1=$this->session->userdata('y1');
                    $y2=$this->session->userdata('y2');
                    ?>
                    
                    <div class="form-group w_25">
                        <label>Acedemic Session</label>
                        <select class="form-control" name="acedemic_session">
                            <option value="<?php echo $acedemic_session; ?>"><?php echo $y1."-".$y2; ?></option>
                        </select>
                        
                        <input type="hidden" name="y1" value="<?php echo $y1; ?>">
                        <input type="hidden" name="y2" value="<?php echo $y2; ?>">
                    </div>
                    
                    <div class="form-group w_25">
                        <label>Status</label>
                        <select class="form-control" name="status" required>
                            <option value="">--- Select Status ---</option>
                            <option value="1">Active</option>
                            <option value="0">Inactive</option>
                        </select>
                    </div>
                    
                    <div class="form-group w_25">
                        <label>&nbsp;&nbsp;</label><br>
                        <button class="btn btn-sm btn-success" type"submit" name="add_new_exam">Submit</button>
                    </div>
                </form>
            </div>
            
            <div class="table-responsive mt-3 mb-3 ">
                <table class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>Exam Title</th>
                            <th>Academic Session</th>
                            <th>Status</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $count=0;
                        $table="exam_list";
                        
                        $get_list_data=$this->NewExamModel->get_exams($acedemic_session,$table);
                        // $table="exam_list";
                        // $get_list_data=$this->NewExamModel->get_data($table);
                        if($get_list_data){
                            foreach($get_list_data as $list_data){
                                $count=$count + 1;
                                $status=$list_data['status'];
                        ?>
                        
                        <tr>
                            <td><?php echo $count; ?></td>
                            <td><?php echo $list_data['exam_title']; ?></td>
                            <td><?php echo $list_data['y1']."-".$list_data['y2']; ?></td>
                            <td>
                                <?php
                                if($status == 1){
                                ?>
                                <button class="btn btn-sm btn-outline-success">Active</button>
                                <?php
                                }else if($status == 0){
                                ?>
                                <button class="btn btn-sm btn-outline-danger">Inactive</button>
                                <?php
                                }
                                ?>
                            </td>
                            <td>
                               
                                <a href="<?php echo base_url().'Examination/update_exam_information/'.$list_data['id']; ?>" class="btn btn-sm btn-outline-warning">Edit</a>
                                
                            </td>
                        </tr>
                        <?php
                            }
                        }
                        ?>
                    </tbody>
                </table>
            </div>
            
            
        </div>
    </div>
</div>