<?php
$exam_id=$this->uri->segment('3');
?>

<style>
    h1{text-align:center;font-size:22px;font-weight:700;}
    h2{text-align:center;font-size:16px;font-weight:550;}
</style>
<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">Home</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">Exam Dates</li>
            </ul>
            <a href="<?php echo base_url();?>Examination/add_new_exam_date/<?php echo $exam_id; ?>" class="btn btn-sm btn-info">Add New Exam Date</a>
            
            <?php
            $exam_table='all_exams';
            $get_exam_info=$this->NewExamModel->get_item_data($exam_id,$exam_table);
            if($get_exam_info){
                foreach($get_exam_info as $exam_info){
            ?>
            <h1> <?php echo $exam_info['exam_title'];?></h1>
            
                <?php
                $acedemic_session_table='academic_session_details';
                $acedemic_session=$exam_info['acedemic_session'];
                $get_acedemic_session_info=$this->NewExamModel->get_item_data($acedemic_session,$acedemic_session_table);
                if($get_acedemic_session_info){
                    foreach($get_acedemic_session_info as $acedemic_session_info){
                ?>
            <h2><?php echo $acedemic_session_info['year_long'];?></h2>
                <?php
                    }
                }
                ?>
                
            <?php
                }
            }
            ?>
            
            <div class="table-responsive">
                <table class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>Exam Date</th>
                            <th>Status</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $count=0;
                        $exam_dates_table='exam_date';
                        $get_exam_dates=$this->NewExamModel->exam_data($exam_id,$exam_dates_table);
                        if($get_exam_dates){
                            foreach($get_exam_dates as $exam_dates){
                                $count=$count + 1;
                        ?>
                        <tr>
                            <td><?php echo $count;?></td>
                            <td><?php echo date('d-M-Y',strtotime($exam_dates['exam_date']));?></td>
                            <td>
                                <?php
                                if($exam_dates['status'] == 1){
                                ?>
                                <button class="btn btn-sm btn-success status-btn" db_id="<?php echo $exam_dates['status'];?>">Active</button>
                                <?php
                                }else{
                                ?>
                                <button class="btn btn-sm btn-danger status-btn" db_id="<?php echo $exam_dates['status'];?>">Inactive</button>
                                <?php
                                }
                                ?>
                                
                            </td>
                            <td><a href="#" class="btn btn-sm btn-danger">
                                <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash2-fill" viewBox="0 0 16 16">
                                    <path d="M2.037 3.225A.703.703 0 0 1 2 3c0-1.105 2.686-2 6-2s6 .895 6 2a.702.702 0 0 1-.037.225l-1.684 10.104A2 2 0 0 1 10.305 15H5.694a2 2 0 0 1-1.973-1.671L2.037 3.225zm9.89-.69C10.966 2.214 9.578 2 8 2c-1.58 0-2.968.215-3.926.534-.477.16-.795.327-.975.466.18.14.498.307.975.466C5.032 3.786 6.42 4 8 4s2.967-.215 3.926-.534c.477-.16.795-.327.975-.466-.18-.14-.498-.307-.975-.466z"/>
                                </svg>
                            </a></td>
                        </tr>
                        <?php
                            }
                        }
                        
                        ?>
                        
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>