<?php
$courses_table='courses';
$get_courses=$this->WelcomeModel->get_data($courses_table);
?>
<style>
.form-group{width:100%;padding:5px;}    
.add-class-teacher{width:50%;float:left;box-shadow:0 0 2px silver;}
.list-class-teachers{width:45%;margin-right:5%;float:left;margin-top:20px;margin-bottom:20px;}


@media only screen and (max-width:767px){
.add-class-teacher{width:100% !important;float:left;box-shadow:0 0 2px silver;
margin-top:20px;margin-bottom:20px;}
.list-class-teachers{width:100% !important;float:left;box-shadow:0 0 2px silver;
margin-top:20px;margin-bottom:20px;}    
}
</style>
<div class="container-fluid bg-white mt-3 mb-3">
    <div class="row">
        <div class="col-sm-12 pt-3 pb-3">
            
            <ul class="breadcrumb">
                <li class="breadcrumb-item"><?php echo $this->session->userdata('ac_year'); ?></li> 
                <li class="breadcrumb-item"><a href="<?php echo base_url(); ?>Welcome">Home</a></li> 
                <li class="breadcrumb-item"><a href="<?php echo base_url(); ?>Management/view_staff">Staff</a></li> 
                <li class="breadcrumb-item">Class Teachers</li>
            </ul>    
                    
            <div class="table-responsive">
                <table class="table table-striped table-bordered" id="mytable">
                    <thead>
                        <tr>
                            <th class="sl_no">Sl.No.</th>
                            <th>Class</th>
                            <th>Section</th>
                            <th>Teacher</th>
                        </tr>    
                    </thead>    
                    <tbody> 
                        <?php
                        $i=0;
                        $class_teacher_list=$this->SchoolModel->class_teacher_list();
                        $acedemic_session=$this->session->userdata('acedemic_session');
                        if($class_teacher_list){
                            foreach($class_teacher_list as $list){
                                if($list['acedemic_session'] == $acedemic_session){
                                    $i=$i + 1;
                        ?>
                        <tr>
                            <td><?php echo $i; ?></td>
                            <td><?php echo $list['class'];?></td>
                            <td><?php echo $list['section'];?></td>
                            <td>
                            <?php 
                            $tid= $list['class_teacher'];
                            $get_teacher_name=$this->SchoolModel->get_teacher_name($tid);
                            if($get_teacher_name){
                                foreach($get_teacher_name as $teacher){
                                    echo $teacher['name'];
                                }    
                            }
                            ?>
                            </td>
                        </tr>    
                        <?php 
                                }
                            } 
                        }
                        ?>
                    </tbody>
                </table>    
            </div>
        <!--</div>-->
        <!--<div class="col-sm-12">-->
            
                
 
            
            <form action="#" method="POST" style="padding:20px;box-shadow:0 0 5px silver;" class="mt-3 mb-3">
                <h1 class="main-heading text-center">Add / Update Class Teachers</h1><hr>
                
                <?php if($success){ ?>
                <div class="alert alert-success"><?php echo $success; ?></div>
                <?php } ?>
                <?php if($error){ ?>
                <div class="alert alert-danger"> <?php echo $error; ?></div>
                <?php } ?>
            
                <div class="form-group">
                    <label>Class</label>   
                    <select name="course_id" class="form-control" required>
                        <option value="">Select Class</option>    
                        <?php 
                        if($get_courses){
                            foreach($get_courses as $course_info){
                        ?>
                        <option value="<?php echo $course_info['id'];?>"><?php echo $course_info['course']; echo " "; echo $course_info['subject_stream']; ?></option>
                        <?php
                            }
                        }
                        ?>
                        
                    </select>
                </div> 

                <div class="form-group">
                    <label>Section</label>  
                    <select name="section" class="form-control" required>
                        <option value="">Select  Section</option> 
                        <option value="A" selected>Section A</option>
                        <option value="B">Section B</option>
                        <option value="C">Section C</option>
                        <option value="D">Section D</option>
                        <option value="E">Section E</option>
                        <option value="F">Section F</option>
                        <option value="G">Section G</option>
                        <option value="H">Section H</option>
                        <option value="I">Section I</option>
                    </select>
                </div> 

                <div class="form-group">
                    <label>Class Teacher</label>
                    <select name="teacher" class="form-control" required>
                        <option value="">Select  Class  Teacher</option>    
                        <?php 
                        $table='school_staff';
                        $get_all_teachers = $this->SchoolModel->get_teaching_staff($table);
                        if($get_all_teachers){
                            foreach($get_all_teachers as $teacher){
                        ?>
                        <option value="<?php echo $teacher['id'];?>"><?php echo $teacher['salutation']." ".$teacher['name'];?></option>  
                        <?php    
                            }    
                        }
                        ?>    
  
                    </select>
                </div> 

                <div class="form-group">
                    <input type="submit" name="add_class_teacher" class="btn btn-success btn-sm" value="Add Class Teacher">    
                </div>
            </form>    
        </div>
    </div>
</div>