<?php include("parent/callMe.php"); ?>
<?php  include("sessioncheck.php"); ?>
<?php
$WorkAssignListings = $m->get("eduportal_days_config");

     
$periodCat_id=$_REQUEST['periodCat_id'];
$section=$_REQUEST['section'];
$branchId=$_SESSION['branch'];

$sql = "SELECT * FROM  eduportal_periods_category as Pcat, eduportal_school_periods_details as Pdetails  WHERE Pcat.category_period_id=Pdetails.period_id and Pdetails.period_id='$periodCat_id' and Pcat.branch_id='$branchId' ORDER BY Pdetails.period_details_id ASC";

$WorkAssignListings5 = $m->query($sql);

     ?>


<!DOCTYPE html>
<html lang="en">
  <head>
    
    <title>Class Period Selection | EduPortal</title>
    <?php include('RootMe/css_links.php');?>
   
<style>

.tdStyle{border-bottom:1px solid lightgray;}
.thStyle{background-color:#00AFEF;color:white;}

</style>
  </head>
  <script type="text/javascript">
  	

function getTeachers(id,row){
     // alert(id+row);   
          
            
            if (window.XMLHttpRequest) {

              // code for IE7+, Firefox, Chrome, Opera, Safari

              xmlhttp=new XMLHttpRequest();

            } else { // code for IE6, IE5

              xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

            }

            xmlhttp.onreadystatechange=function() {

              if (xmlhttp.readyState==4 && xmlhttp.status==200) {

                document.getElementById("tech"+row).innerHTML=xmlhttp.responseText;
               // alert(xmlhttp.responseText);

              }

            }

            xmlhttp.open("GET","get_teachers.php?subc="+id,true);

            xmlhttp.send();

          }


  </script>

<script src="js/ajax_functions.js"></script> 


  <body class="nav-md">
    <div class="container body">
      <div class="main_container">
        <div class="col-md-3 left_col">
     
            <?php include('RootMe/sidebar.php');?>

              <?php include('RootMe/header.php');?>
     
        <!-- page content -->
          <div class="right_col" role="main">
          <div class="row" style="background-color: white;">
           
     <h3>View Time Table <span style="font-size: 16px;"> (<?php echo count($WorkAssignListings);?> records) </span></h3>

   

    <form class="form-style-7" action="view_teachers_timetable.php" method="Get">


               <div class="col-md-3 col-xs-12" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Instructor</label>
 

                  <select name="user_id" id="user_id"   data-placeholder="Select" class="chosen-multi-select inputfield form-control"  >
                    <option value="">Select Instructor</option>

                    <?php
                    $m->where("status", 0);
                    $m->where("branch_id", $_SESSION['branch']);
                    $WorkAssignList = $m->get("edu_user_config");
                    foreach($WorkAssignList as $WorkAssignListVal)
                    { ?>

                       <option <?php if($_REQUEST['user_id']==$WorkAssignListVal['user_id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['user_id']; ?>"><?php echo $WorkAssignListVal['user_fname']; ?></option>


                            <?php
                    } ?>

                </select> 
                </div>
              </div>

              <div class="col-md-3 col-xs-12" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Period Catgories</label>
 

                  <select name="periodCat_id" id="periodCat_id"   data-placeholder="Select" class="chosen-multi-select inputfield form-control"  >
                    <option value="">Select</option>

                        <?php
                    $m->where("branch_id", $_SESSION['branch']);
                    $WorkAssignList = $m->get("eduportal_periods_category");
                    foreach($WorkAssignList as $WorkAssignListVal)
                    { ?>

                       <option <?php if($_REQUEST['periodCat_id']==$WorkAssignListVal['category_period_id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['category_period_id']; ?>"><?php echo $WorkAssignListVal['period_title']; ?></option>


                            <?php
                    } ?>

                </select> 
                </div>
              </div>


              <div class="col-md-4 " style="padding:2px;">
    
        
                <div class="form-group ">
                   
                <button id="month"  type="submit" class="btn btn-primary" style="margin-top: 27px;">Search</button>

                
              <?php   if(isset($_REQUEST['user_id'])) { ?>
                <a href="print_teacher_timetable.php?<?php echo session_id().session_id().session_id().session_id().session_id(); ?>&class_id=<?php echo $_REQUEST['class_id'];?>&section=<?php echo $_REQUEST['section'];?>&user_id=<?php echo $_REQUEST['user_id'];?>&periodCat_id=<?php echo $_REQUEST['periodCat_id'];?>" id="subuser"target="_blank" class="btn btn-primary" style="margin-top: 27px;">Print </a>
              <?php } ?>
                </div>
        
              </div>
             
</form>
  <section class="add_sub_agent" id="table_sub_agent">
  <div class="container">

 <div class="" style="margin-top:10px;">
    
      <div class="clearfix"></div>
    </div>
    <br>

     
          
          <?php  if(isset($_SESSION['addsuccess'])){?>


            <div class="alert alert-success" id="msg">
             <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              <strong>Success!</strong> Student record is added successfully...
            </div>


          <?php  unset($_SESSION['addsuccess']); }?>

      

          
          <?php  if(isset($_SESSION['addContact'])){?>


            <div class="alert alert-success" id="msg">
             <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              <strong>Success!</strong> Student record is added successfully...
            </div>


          <?php  unset($_SESSION['addContact']); }
          ?>



<form class="form-style-7" action="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php" method="post"  enctype="multipart/form-data">

<input type="hidden" name="action" value="LectureTime"> 

<input type="hidden" value="<?php echo $_REQUEST['class_id']; ?>" name="class_id" />
<input type="hidden" value="<?php echo $_REQUEST['section']; ?>" name="section" />


<div style="overflow-x:auto;">

<table id="listofstudents" class="table table-striped table-bordered" style="width:100%;background-color: white;">
        <thead>
            <tr>

          
                <th width="">Days</th>

               <?php 
                	
                	foreach ($WorkAssignListings5 as $Data) {
    		 	
    		?>         
    		<input type="hidden" name="period_id" value="<?php echo $Data['period_details_id']; ?>">
    		<input type="hidden" name="period_cat_id" value="<?php echo $Data['period_id']; ?>">
             <th width="" class=" center"> <?php echo $Data['period_details_title']; ?><br><span style="font-size: 11px;"><?php echo $Data['period_start']."-".$Data['period_end']; ?></span> </th>
            
    		<?php } ?>

              
                
                
                
            </tr>
        </thead>
        <tbody>


   
     
     <?php 

     $count=1;
     $number1;
      foreach($WorkAssignListings as $WorkAssignListVal)
      { 
        
    

      ?>
 
        <tr>

        		
                
              <td> <?php echo $WorkAssignListVal['day_name'];?> </td>

			        <?php
					for ($x = 1; $x <= count($WorkAssignListings5); $x++) { 

            $row=$WorkAssignListVal['day_name'].$x;


   

       $day=$WorkAssignListVal['day_id'];
       $detailId=$WorkAssignListings5[$x-1]['period_details_id'];
       $cat_id=$WorkAssignListings5[$x-1]['period_id'];
       $user=$_REQUEST['user_id'];
       $branchIdId=$_SESSION['branch'];
   
       $sqll = "SELECT cls.Class_Name, usr.user_fname, sec.section_name FROM  eduportal_lectures_time as lec, edu_class_config as cls, edu_user_config as usr, edu_adm_section_detail as sec  WHERE cls.class_id=lec.class_id and  usr.user_id=lec.user_id and lec.period_id='$detailId' and usr.user_id='$user' and lec.period_cat_id='$cat_id' and lec.branch_id='$branchIdId' and lec.day_id='$day' and lec.period_cat_id='$periodCat_id' and lec.section_id=sec.section_id";
		// print_r($sqll);
       $lectureData = $m->query($sqll);
      
            ?>

           
					  <td style="text-align: center;">
					  	
					  	<?php echo "<b>".$lectureData[0]['Class_Name']."/".$lectureData[0]['section_name']."</b><br>";

					  			echo $lectureData[0]['user_fname'];
					  	?>


                 <div class="form-group ">
                 
     
                  
                </div>

					  </td>
					<?php } ?>
                 
    



              </tr>


 <?php  }  ?>



           
        </tbody>
        
    </table>

  </div>

<!-- <button type="submit" style="margin: 30px;" class="btn btn-success" name="submit" >Submit </button> -->
    </form>

    <br><br>


  </div>
  <div class="clearfix"></div>
</section>          
    

           
          </div>
        </div>

            </div>
          </div>
        </div>
        <!-- /page content -->
     
  <?php include('RootMe/js_linksscript.php');?>


   

<!-- <script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script> -->
 <!-- jQuery -->
    


     <!-- searchable dropdown -->
    
    <link href="autosearch_select/select2.css" rel="stylesheet">
    <link href="autosearch_select/select2-default.css" rel="stylesheet">
    <script src="autosearch_select/select2.min.js"></script>
    
    <script>
    $(function() {
    $('.chosen-select').select2( { width:'100%', maximumSelectionSize: 1 } );
    $(document).ready(function() {
    $(".chosen-multi-select").select2( { width:'100%', } ); }); }); function slideout(){ setTimeout(function(){
    $(".alert-success").fadeOut("slow", function () { });
    $(".alert-danger").fadeOut("slow", function () { }); }, 4000);}
    </script>


  </body>
</html>
