<?php
session_start();
if($_SESSION["username"]=="")
{
 	echo "You are not Logged in Please <a href='index.html'>Sign in </a> First ";
}
else
{

include 'dbc.php';
date_default_timezone_set("Asia/Karachi");
$today=date("Y-m-d");
$month = date("m",strtotime($today));
		$year = date("Y",strtotime($today));
		 $month_name = date("F", mktime(0, 0, 0, $month, 10));
		 $my=$month_name . " " . $year;
$userid=$_SESSION["userid"];
$id=$_REQUEST["id"];
$sql1="Select * from teacher";
$result1 = $conn->query($sql1);
$sql2="Select * from addclass";
$result2 = $conn->query($sql2);
$sql3="Select * from tt_days";
$result3 = $conn->query($sql3);
$sql4="Select * from tt_periods";
$result4 = $conn->query($sql4);
$sql5="Select * from tt_subject";
$result5 = $conn->query($sql5);

?>
<!doctype html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang=""> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8" lang=""> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9" lang=""> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js" lang="en">
<!--<![endif]-->

<head>
   <?php include("includes/header.php") ?>
</head>

<body>


    <!-- Left Panel -->

    <?php include("includes/menu.php") ?><!-- /#left-panel -->

    <!-- Left Panel -->

    <!-- Right Panel -->

    <div id="right-panel" class="right-panel">

        <!-- Header-->
        <header id="header" class="header">

             <?php include("includes/headermenu.php") ?>

        </header><!-- /header -->
        <!-- Header-->

        <div class="breadcrumbs">
            <div class="col-sm-6">
                <div class="page-header float-left">
                    <div class="page-title">
                        <h1><? echo "" . $_SESSION["userid"]; ?></h1>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="page-header float-right">
                    <div class="page-title">
                        <ol class="breadcrumb text-right">
                            <li class="active"><? echo "" . $_SESSION["username"]; ?></li>
                        </ol>
                    </div>
                </div>
            </div>
        </div>

        <div class="content mt-3">

           


          <div class="col-lg-12">
                        <div class="card">
                            <div class="card-header"><strong>Genrate Time Table</strong><small> Form</small></div>
                            <div class="card-body card-block">
							<form action="Time_Table_Save.php" method="post" enctype="multipart/form-data" class="form-group">
							           
                                                                    <div class="col-12 col-md-3">
																	<div class="form-group"><label for="cname" class=" form-control-label">Select Teacher</label
                                                                        ><select name="teacher" id="teacher" class="form-control">
                                                                             <?php
  while($user_data1=$result1->fetch_assoc())
  {
  ?>
              <option value="<? echo $user_data1['tech_name']; ?>"><? echo $user_data1["tech_name"]; ?></option>
              <?php
  }
  ?>         
                                                                        </select>
                                                                    </div>
																	</div>
                                                              <div class="col-12 col-md-3">
																	<div class="form-group"><label for="cname" class=" form-control-label">Select Class</label
                                                                        ><select name="class_name" id="class_name" class="form-control">
                                                                             <?php
  while($user_data2=$result2->fetch_assoc())
  {
  ?>
              <option value="<? echo $user_data2['cname']; ?>"><? echo $user_data2["cname"]; ?></option>
              <?php
  }
  ?>         
                                                                        </select>
                                                                    </div>
																	</div>
																	
																	<div class="col-12 col-md-3">
																	<div class="form-group"><label for="cname" class=" form-control-label">Select Days</label
                                                                        ><select name="tdays" id="tdays" class="form-control">
                                                                             <?php
  while($user_data3=$result3->fetch_assoc())
  {
  ?>
              <option value="<? echo $user_data3['tname']; ?>"><? echo $user_data3["tname"]; ?></option>
              <?php
  }
  ?>         
                                                                        </select>
                                                                    </div>
																	</div>
							
								
								<div class="col-12 col-md-3">
																	<div class="form-group"><label for="cname" class=" form-control-label">Select Timeslot/ Periods</label
                                                                        ><select name="tpriods" id="tpriods" class="form-control">
                                                                             <?php
  while($user_data4=$result4->fetch_assoc())
  {
  ?>
              <option value="<? echo $user_data4['tname']; ?>"><? echo $user_data4["tname"]; ?></option>
              <?php
  }
  ?>         
                                                                        </select>
                                                                    </div>
																	</div>
																	<div class="col-12 col-md-3">
																	<div class="form-group"><label for="cname" class=" form-control-label">Select Subject</label
                                                                        ><select name="tsubject" id="tsubject" class="form-control">
                                                                             <?php
  while($user_data5=$result5->fetch_assoc())
  {
  ?>
              <option value="<? echo $user_data5['tname']; ?>"><? echo $user_data5["tname"]; ?></option>
              <?php
  }
  ?>         
                                                                        </select>
                                                                    </div>
																	</div>
							
							
									
									
								
				
													
                                                    </div>
													<div class="card-footer">
                                                        <button type="submit" class="btn btn-primary btn-sm">
                                                            <i class="fa fa-dot-circle-o"></i> Genrate Timetable
                                                        </button>
                                                        
                                                    </div>
													
													</form>
                                                </div>
                                            </div>

            <div class="col-md-14">
                        <div class="card">
                            <div class="card-header">
                                <strong class="card-title">Edit</strong>
                            </div>
                            <div class="card-body">
							<?php

include 'dbc.php';


$userid=$_SESSION["userid"];
$sql = "SELECT * FROM timetable";
$result=$conn->query($sql);
?>
                                <table id="bootstrap-data-table-export" class="table table-striped table-bordered">
                                    <thead>
									<?php
                                       echo "<tr>";
echo "<th > Teacher </th>";
echo "<th > Class </th>";
echo "<th > Days </th>";
echo "<th > Timeslot </th>";
echo "<th > Subject </th>";


echo "</tr>";
?>
                                    </thead>
									
                                    <tbody>
									<?php
                                       while($row = $result->fetch_assoc())
 
  {
   $id = $row['id'];	
   echo "<tr>";
echo "<td>" .$row['tname'] . "</td>";
echo "<td>" .$row['cname'] . "</td>";
echo "<td>" .$row['dname'] . "</td>";
echo "<td>" .$row['pname'] . "</td>";
echo "<td>" .$row['sname'] . "</td>";
 

		 ?>
		 
		  
		 <?php
		
		  echo"<th> <a href ='Del_Timetable.php?id=$id'>"?><button type="button" class="btn btn-primary">  Del </button><?php "</a>";
		
		 
		  
	
  echo "</tr>";


  }
  ?>
                                       
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>


        </div> <!-- .content -->
    </div><!-- /#right-panel -->

    <!-- Right Panel -->

   <?php include("includes/footermenu.php") ?>

</body>

</html>
<?php
}
?>