<?php include("parent/callMe.php"); ?>
<?php  include("sessioncheck.php"); ?>
<?php

 $pageName=basename($_SERVER['PHP_SELF']);

    
     $m->where("page_name", $pageName);
     $video = $m->get("eduportal_modules_pages_detail");


if(isset($_REQUEST['id'])){


  $data = array('status' => "1");

      $m->where("contact_id", $_REQUEST['id']);
    $result =  $m->update ('eduportal_contacts', $data);
   
     
      header("location:contacts.php?".session_id().session_id().session_id());


 }
      

 
      
       $WorkAssignListings = $m->get("eduportal_days_config");

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

$sql = "SELECT * FROM  eduportal_class_periods as classP, eduportal_school_periods_details as Pdetails  WHERE classP.class_id='$class_id' and classP.section_id='$section' and classP.period_id=Pdetails.period_id and classP.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">
             
            <?php //include('RootMe/sidebar.php');?>

              <?php //include('RootMe/header.php');?>
     
        <!-- page content -->
          <div class="" role="main" style="margin-left: 25px;margin-right: 25px;">

            <a href="<?php echo $_SESSION['dashboard'];?>">Dashboard </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp; 
            Create Time Table 
          <br><br>
          
          <div class="row" style="background-color: white;">
           
     <h3>Create Time Table <span style="font-size: 16px;"> (<?php echo count($WorkAssignListings);?> records) </span></h3>


     <?php if ($video[0]['video_url']!=NULL) { ?>
  
  <a href="watch_video.php?videourl=<?php echo $video[0]['video_url'];?>" target="_blank" class="btn btn-success" style="padding: 10px 10px; font-size:14px;color:white;float: right;"><i class="fa fa-play"></i>&nbsp;&nbsp;Watch Demo</a>

<?php } ?>



   

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

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

                  <select name="class_id" id="class_id"  name="term_id"   data-placeholder="Select" class="chosen-multi-select inputfield form-control" onChange="getsec(this.value)"  >
                    <option value="">Select Class</option>

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

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


                            <?php
                    } ?>

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


                <div class="col-md-2 col-xs-12" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Section</label>
                    <select name="section" id="txt_section" class="form-control" onChange="getSubjects(this.value)">
                      
                   <?php
                              if($_REQUEST['section']!='')
                              { 

                              $m->where("class_id", $_REQUEST['class_id']);    

                              $secondLevel = $m->get("edu_adm_section_detail");
                              
                              foreach($secondLevel as $secondLevel_val)
                              {
                              
                               ?>
                                <option <?php if($_REQUEST['section']==$secondLevel_val['section_id']){echo "selected";} ?> value="<?php echo $secondLevel_val['section_id']; ?>"><?php echo trim(utf8_encode_all($secondLevel_val['section_name'])); ?></option>

                              <?php }   ?>
                                
                          <?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['cat_id'])) { ?>
                <a href="print_contacts.php?<?php echo session_id().session_id().session_id().session_id().session_id(); ?>&cat_id=<?php echo $_REQUEST['cat_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">

<?php if (!isset($_REQUEST['Edit'])) {?>

  <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" />

<?php } else { ?> 
<input type="hidden" name="action" value="EditLectureTime"> 

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

<?php } ?>
<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)
      { 
        
    
     $days_id=$WorkAssignListVal['day_id'];
      

      ?>
 
        <tr>

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

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

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

 if (isset($_REQUEST['Edit'])) { 

       $day=$WorkAssignListVal['day_id'];
       $detailId=$WorkAssignListings5[$x-1]['period_details_id'];
       $cat_id=$WorkAssignListings5[$x-1]['period_id'];
       $branchIdId=$_SESSION['branch'];

       
       $sqll = "SELECT * FROM  eduportal_lectures_time as lec, eduportal_subject_config as sub, edu_user_config as usr  WHERE sub.subject_id=lec.subject_id and usr.user_id=lec.user_id and lec.class_id='$class_id' and lec.section_id='$section' and lec.period_id='$detailId' and lec.period_cat_id='$cat_id' and lec.branch_id='$branchIdId' and lec.day_id='$day'";
     //print_r($sqll);
       $lectureData = $m->query($sqll);
//echo $lectureData[0]['subject_id'];
           } ?>

            <input type="hidden" name="day_id1<?php echo $days_id;?><?php echo $x;?>[]" value="<?php echo $WorkAssignListVal['day_id'];?>">
					  <td>
					  	
					  	 <div class="form-group ">
                 
                    <select name="subjects1<?php echo $days_id;?><?php echo $x;?>[]" class="form-control chosen-multi-select" onChange="getTeachers(this.value,'<?php echo $row;?>')" >
                      <option>Subject</option>
                   <?php
                             
                              
                              $section=$_REQUEST['section'];
                              $class=$_REQUEST['class_id'];
                             // $session=$_REQUEST['session'];
  
                              $query="SELECT * FROM eduportal_subject_config as sub, eduportal_class_subjects as cls where cls.subject_id=sub.subject_id and cls.class_id='$class' and cls.section_id='$section'";


                              $secondLevel = $m->query($query);
                              
                              foreach($secondLevel as $secondLevel_val)
                              {
                              
                               ?>

                                <option <?php if($lectureData[0]['subject_id']==$secondLevel_val['subject_id']){echo "selected";} ?> value="<?php echo $secondLevel_val['subject_id']; ?>"><?php echo trim(utf8_encode_all($secondLevel_val['subject'])); ?></option>

                              <?php }  
                              
                                ?>

                    </select>

                  
                </div>


                 <div class="form-group ">
                 
                    <select name="teachers1<?php echo $days_id;?><?php echo $x;?>[]" id="tech<?php echo $WorkAssignListVal['day_name'].$x;?>" class="form-control chosen-multi-select"  >
                      
                      <?php if (isset($_REQUEST['Edit'])) { ?>
                        
                      
                      <option>Teacher</option>
                   <?php
                             
                              
                              
  
                              $query="SELECT * FROM edu_user_config where branch_id='$branchId' and status='0'";


                              $secondLevel = $m->query($query);
                              
                              foreach($secondLevel as $secondLevel_val)
                              {
                              
                               ?>

                                <option <?php if($lectureData[0]['user_id']==$secondLevel_val['user_id']){echo "selected";} ?> value="<?php echo $secondLevel_val['user_id']; ?>"><?php echo trim(utf8_encode_all($secondLevel_val['user_fname'])); ?></option>

                              <?php }  }
                              
                                ?>
                            

                    </select>

                  
                </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>
        <!-- /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>
