<?php 
$tid=$this->uri->segment("3");
$sch_id=$this->uri->segment("4");
$staff_table="school_staff";
$get_staff_data=$this->TimeTableModel->get_item_data($tid,$staff_table);
if($get_staff_data){
    foreach($get_staff_data as $staff_data){
?>


<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(); ?>TimeTableManagement">Time Table</a>
                </li>
                
                <li class="breadcrumb-item">
                    <a href="<?php echo base_url(); ?>TimeTableManagement/all_teachers/<?php echo $sch_id; ?>">All Teacher</a>
                </li>
                
                <li class="breadcrumb-item"><?php echo $staff_data['salutation']." ".$staff_data['name']; ?></li>
            </ul>
            <!--<p class="main-heading"><?php echo $staff_data['salutation']." ".$staff_data['name']; ?></p>-->
            <div class="table-responsive">
                <table class="table table-bordered">
                    <thead>
                        
                        <tr>
                            <th>Day</th>
                            <?php 
                            $p_count=0;
                            $periods_table="time_table_periods";
                            $all_periods=$this->TimeTableModel->get_schedule_periods($sch_id,$periods_table);
                            if($all_periods){
                            foreach($all_periods as $periods){
                                $p_count=$p_count + 1;
                            ?>
                            <th class="text-center">
                                <?php echo $periods['period']; ?>
                                <br>
                                <?php echo "(".date('h:i:sa',strtotime($periods['start_time']))."<br>".date('h:i:sa',strtotime($periods['end_time'])).")"?>
                            </th>
                            <?php
                                }
                            }
                            ?>
                            
                        </tr>
                        
                    </thead>
                    <tbody>
                        <?php
                        $acedemic_session=$this->session->userdata('acedemic_session');
                        ?>
                        <tr>
                            <th>Mon</th>
                            
                            <?php
                            if($all_periods){
                                foreach($all_periods as $periods){
                                    echo "<td class='text-center'>";
                                    $period=$periods['id'];
                                    $week_day_1="MON";
                                    $get_teacher_day_schedule=$this->TimeTableModel->get_teacher_day_schedule_comb($tid,$sch_id,$week_day_1,$period);
                                    if($get_teacher_day_schedule){
                                        foreach($get_teacher_day_schedule as $sch_data){
                                            
                                            echo $sch_data['class']."-".$sch_data['section']."<br>";
                                            echo $sch_data['subject'];
                                        }
                                    }
                            echo "</td>";
                                }
                            }
                            ?>
                        </tr>
                        <tr>
                            <th>Tue</th>
                            <?php
                            if($all_periods){
                                foreach($all_periods as $periods){
                                    echo "<td class='text-center'>";
                                    $period=$periods['id'];
                                    $week_day_1="TUE";
                                    $get_teacher_day_schedule=$this->TimeTableModel->get_teacher_day_schedule_comb($tid,$sch_id,$week_day_1,$period);
                                    if($get_teacher_day_schedule){
                                        foreach($get_teacher_day_schedule as $sch_data){
                                            
                                            echo $sch_data['class']."-".$sch_data['section']."<br>";
                                            echo $sch_data['subject'];
                                        }
                                    }
                            echo "</td>";
                                }
                            }
                            ?>
                        </tr>
                        <tr>
                            <th>Wed</th>
                            <?php
                            if($all_periods){
                                foreach($all_periods as $periods){
                                    echo "<td class='text-center'>";
                                    $period=$periods['id'];
                                    $week_day_1="WED";
                                    $get_teacher_day_schedule=$this->TimeTableModel->get_teacher_day_schedule_comb($tid,$sch_id,$week_day_1,$period);
                                    if($get_teacher_day_schedule){
                                        foreach($get_teacher_day_schedule as $sch_data){
                                            
                                            echo $sch_data['class']."-".$sch_data['section']."<br>";
                                            echo $sch_data['subject'];
                                        }
                                    }
                            echo "</td>";
                                }
                            }
                            ?>
                        </tr>
                        <tr>
                            <th>Thu</th>
                            <?php
                            if($all_periods){
                                foreach($all_periods as $periods){
                                    echo "<td class='text-center'>";
                                    $period=$periods['id'];
                                    $week_day_1="THU";
                                    $get_teacher_day_schedule=$this->TimeTableModel->get_teacher_day_schedule_comb($tid,$sch_id,$week_day_1,$period);
                                    if($get_teacher_day_schedule){
                                        foreach($get_teacher_day_schedule as $sch_data){
                                            
                                            echo $sch_data['class']."-".$sch_data['section']."<br>";
                                            echo $sch_data['subject'];
                                        }
                                    }
                            echo "</td>";
                                }
                            }
                            ?>
                        </tr>
                        <tr>
                            <th>Fri</th>
                            <?php
                            if($all_periods){
                                foreach($all_periods as $periods){
                                    echo "<td class='text-center'>";
                                    $period=$periods['id'];
                                    $week_day_1="FRI";
                                    $get_teacher_day_schedule=$this->TimeTableModel->get_teacher_day_schedule_comb($tid,$sch_id,$week_day_1,$period);
                                    if($get_teacher_day_schedule){
                                        foreach($get_teacher_day_schedule as $sch_data){
                                            
                                            echo $sch_data['class']."-".$sch_data['section']."<br>";
                                            echo $sch_data['subject'];
                                        }
                                    }
                            echo "</td>";
                                }
                            }
                            ?>
                        </tr>
                        <tr>
                            <th>Sat</th>
                            <?php
                            if($all_periods){
                                foreach($all_periods as $periods){
                                    echo "<td class='text-center'>";
                                    $period=$periods['id'];
                                    $week_day_1="SAT";
                                    $get_teacher_day_schedule=$this->TimeTableModel->get_teacher_day_schedule_comb($tid,$sch_id,$week_day_1,$period);
                                    if($get_teacher_day_schedule){
                                        foreach($get_teacher_day_schedule as $sch_data){
                                            
                                            echo $sch_data['class']."-".$sch_data['section']."<br>";
                                            echo $sch_data['subject'];
                                        }
                                    }
                            echo "</td>";
                                }
                            }
                            ?>
                        </tr>
                        
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

<?php
    }
}
?>