 <?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){
        $sch_table="time_table";
        $time_table_data=$this->TimeTableModel->get_item_data($sch_id,$sch_table);
        if($time_table_data){
            foreach($time_table_data as $time_data){
                $y1=$time_data['y1'];
                $y2=$time_data['y2'];
?>


<!DOCTYPE html>
<html>
    <head>
        <title>Time Table</title>
        <style>
            /*<link rel="preconnect" href="https://fonts.googleapis.com">*/
            /*<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>*/
            /*<link href="https://fonts.googleapis.com/css2?family=Exo+2:ital,wght@0,500;1,400&display=swap" rel="stylesheet"> */
            
            
            <link rel="preconnect" href="https://fonts.googleapis.com">
            <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
            <link href="https://fonts.googleapis.com/css2?family=Inconsolata:wght@200;300;400;500;600;700&display=swap" rel="stylesheet">
            
            .w-100{width:100%;}
            .w-50-1{width:50%;float:left;height:100%;border-right:1px dotted red;}
            .w-50-2{width:50%;float:left;height:100%;}
            .w-2{width:0%;float:left;}
            img{height:60px;width:auto;}
            html{padding:0px;margin:0px;}
            body{padding:20px;margin:0px;font-size:13px;
            /*font-family: 'Exo 2', sans-serif !important;*/
                font-family: 'Inconsolata', monospace; 
            }
            table{
                border-collapse:collapse;
            }
            tr th{
                border:1px solid;
                border-collapse:collapse;
            }
            tr td{
                border:1px solid;
                border-collapse:collapse;
                text-align:center;
                font-size:12px;
            }
        </style>
    </head>
    <body>
        
        <div style="height:auto;width:100%;float:left;padding:0px;border:1px solid;">
 
            <div style="width:100%;text-align:center;margin:0px;padding:0px;height:60px;display:block; border-bottom:1px solid;">
                <div style="width:20%;text-align:right;float:left;">
                    <img src="<?php echo school_logo_full; ?>" style="width:auto;margin-top:0px;padding-top:10px;height:40px;">
                </div>
                <div style="width:80%;display:inline-block;text-align:center;float:right;height:60px;vertical-align:middle;align-items:center;justify-content:center;">
                    <h1 style="padding:20px;margin-top:auto;margin-bottom:auto;font-size:22px !important;font-weight:900 !important;text-transform:uppercase;letter-spacing:2px;">
                            <?php echo school_full_name; ?><br>
                    </h1>
                    <!--<h2 style="font-size:14px;margin:0px; padding :0px;font-weight:500;letter-spacing:2px;">Awas Vikas, Hanspuram Naubasta, Kanpur</h2>-->
                    <!--<h2 style="padding:0px;margin:0px;font-size:14px !important;font-weight:500 !important;letter-spacing:2px;"><?php echo school_affiliation;?></h2>-->
                    <!--<h2 style="padding:0px;margin:0px;font-size:18px !important;font-weight:700 !important;letter-spacing:2px;">School Code - UP-230</h2>-->
                    
                    <!--<p style="padding:0px;margin:0px;font-size:13px;font-weight:500;"><?php echo school_address;?></p>-->
                    <!--<p style="padding:0px;margin:0px;font-size:13px;font-weight:500;letter-spacing:2px;">Session : <b><?php echo $y1; ?></b> to <b><?php echo $y2; ?></b></p>-->
                </div>   
            </div>
            
            
                        <p class="main-heading" style="padding:0px 5px 0px 5px;margin:0px;">Name : <b><?php echo $staff_data['salutation']." ".$staff_data['name']; ?></b></p>
                        <div class="" style="padding:5px;">
                            <table class="table table-bordered" style="width:100%;border:1px solid;">
                                <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>        
    </body>
</html>


<?php
            }
        }

    }
}
?>
    
    