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

ini_set('max_execution_time', '300'); //300 seconds = 5 minutes
ini_set('max_execution_time', '0'); // for infinite time of execution 

      if($_REQUEST['class_id']!=NULL){
     
       $m->where("class_id", $_REQUEST['class_id']);  
            
   
      if($_REQUEST['session']!=NULL){

        $m->where("session_id", $_REQUEST['session']);
        
      }

      if($_REQUEST['section']!=NULL){

        $m->where("section_id", $_REQUEST['section']);
        
      }
           
      if($_REQUEST['rollno']!=NULL){

        $m->where("candidate_roll_no", $_REQUEST['rollno']);
        
      }


         if($_REQUEST['orderBy']=='RollNoWise'){
       
       $m->where("status", '0');
       $m->where("branch_id", $_SESSION['branch']);
       $m->orderBy("candidate_roll_no","asc");  
       $WorkAssignListings = $m->get("edu_student_details");
       
       } else {

       $m->where("status", '0');
       $m->where("branch_id", $_SESSION['branch']);
       $m->orderBy("first_name","asc");
       $WorkAssignListings = $m->get("edu_student_details");

      }

      }
 
     ?>

<script type="text/javascript">
         function getsecall(id){

    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("txt_section").innerHTML=xmlhttp.responseText;
        // alert(xmlhttp.responseText);

      }

    }

    xmlhttp.open("GET","get_section_all.php?class_id="+id,true);

    xmlhttp.send();




  }
     </script>

<!DOCTYPE html>
<html lang="en">
  <head>
    
    <title>Add MarkSheet | EduPortal</title>
    <?php include('RootMe/css_links.php');?>
   
  </head>
  <script type="text/javascript">
  
function getterm(id){
//alert(id);
            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("term_id").innerHTML=xmlhttp.responseText;
               //  alert(xmlhttp.responseText);

              }

            }

            xmlhttp.open("GET","get_term.php?session_id="+id,true);

            xmlhttp.send();

          }

</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="" style="background-color: white;">
           
<section class="add_sub_agent" id="table_sub_agent">
  <div class="container">

 <div class="" style="margin-top:10px;">
      <form  action="syllabus_management.php" enctype="multipart/form-data" method="get">
        <div class="">
          
          <div class="panel-body">
          
            <div class="col-md-12" id="" style="">

            <div class="col-md-2" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Session</label>
                    <select name="session" id="session" class="form-control" onChange="getterm(this.value)" >

                              <option value="">Select Session</option>
                        

                        <?php
 
 
 
                      $match;
                      if(!isset($_REQUEST['session'])){
                        $match=$_SESSION['current_session'];
                      }else { $match=$_REQUEST['session']; }
                     
   
                        $WorkAssignList = $m->get("edu_session_config");
                        foreach($WorkAssignList as $WorkAssignListVal)
                        { ?>

                           <option <?php if($match==$WorkAssignListVal['session_id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['session_id']; ?>"><?php echo $WorkAssignListVal['session_year']; ?></option>


                                <?php
                        } ?>

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

             <div class="col-md-2" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Term</label>

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

                    <?php
                    $m->where("session_id", $_SESSION['current_session']);
                    $m->where("branch_id", $_SESSION['branch']);
                    $m->orderBy("term_title","asc");
                    
                    $WorkAssignList = $m->get("eduportal_exam_terms");
                    foreach($WorkAssignList as $WorkAssignListVal)
                    { ?>

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


                            <?php
                    } ?>

                </select> 

                  
                </div>
              </div> 
                         
              


             <div class="col-md-2" 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="getsecall(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" 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']=="All"){echo "Selected";} ?> value="All">All</option>
                                <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-2" style="padding:2px;" >
                <div class="form-group ">
                   <input type="hidden" name="addaccountAdmin" value="1">
                <button type="submit" class="btn btn-primary" style="margin-top: 28px;">Search</button>
                </div>
          </div>

            
            </div>
            <div class="clearfix"></div>
          </div>
        </div>
      </form>
      <div class="clearfix"></div>
    </div>
    <br>
  
          
          <?php  if(isset($_SESSION['marksheet_error'])){?>


            <div class="alert alert-danger" id="msg">
             <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              <strong>Warning!</strong> You have already saved this Syllaubs...
            </div>


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

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


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


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

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

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


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

  <input type="hidden" id="class_id"  name="class_id" value="<?php echo $_GET['class_id']; ?>" />
  <input type="hidden" id="section_id"  name="section_id" value="<?php echo $_GET['section']; ?>" />
  <input type="hidden" id="term_id"  name="term_id" value="<?php echo $_GET['term_id']; ?>" />
  <input type="hidden" id="session"  name="session" value="<?php echo $_GET['session']; ?>" />
  
<script>


function student_check(){
       
     var hello=document.getElementById("class_id").value;
     var hello1=document.getElementById("section_id").value;


         if(hello=="" || hello==null || hello1==null || hello1==null ){
          

          // $("#check_std_msg").slideDown('slow').delay(4000).slideUp('slow');
          document.getElementById("check_std_msg").style.display = "block";
          $("#check_std_msg").slideDown('slow').delay(5000).slideUp('slow');

        return false;
         }
    
        else {
          document.getElementById("check_std_msg").style.display = "none";
          return true;
         }
    
}

</script>



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

        <div class="col-md-12" style="margin-bottom:1%;">

              <input type="submit" name="submit" class="pull-right btn btn-primary"  value="Save&Update Syllabus" />


        </div>

 
    <table data-page-length='100' class="table table-striped table-bordered" style="width:100%">
          
          <thead>
            <tr>
            
            <th width="" style="text-align: center;font-size: 22px;font-weight: bold;">Subjects & Syllabus</th> 
                
              
  
            </tr>
        </thead>
        <tbody>

         <?php 
              
          // printing all the relevant subjects of each class
                   
              $m->where("branch_id", $_SESSION['branch']);
              $m->where("session_id", $_REQUEST['session']);
              $m->where("class_id", $_REQUEST['class_id']);
              $m->where("section_id", $_REQUEST['section']);          

              $teacher_sbj = $m->get("eduportal_class_subjects");

              foreach($teacher_sbj as $teacher_sb) {

                      
                $m->where("subject_id", $teacher_sb['subject_id']);
                $subjects = $m->get("eduportal_subject_config");


                $m->where ("session_id", $_REQUEST['session']);
                $m->where ("branch_id", $_SESSION['branch']);
                $m->where("class_id", $_REQUEST['class_id']);
                $m->where ("term_id", $_REQUEST['term_id']);
                $m->where("section_id", $_REQUEST['section']); 
                $m->where ("subjects_id", $teacher_sb['subject_id']);      

                $Syllabus =  $m->get ('eduportal_syllabus_management');

                 ?>
            <input type="hidden" name="subjects[]"  value="<?php echo $teacher_sb['subject_id'];?>"  />
            <tr>
             <td width="" class=" center"> <?php echo $subjects[0]['subject']; ?><br>

              <textarea class="form-control"  id="syllabus" name="syllabus<?php echo $teacher_sb['subject_id'];?>" > <?php echo $Syllabus[0]['syllabus'];?>
                
              </textarea>

             </td> 
            </tr> 
             
         <?php  }  ?> 
 
     </tbody>
        
    </table>
 
<?php } else {?>
<br>
  <div  style="display:block;" class="alert alert-danger alert-dismissible">
      <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
       <strong>Warning !</strong> Please select Term/Class and serarch to creat Syllabus  !!!
  </div>
  <?php }?>
</form>
</div>
    <br><br>


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

            </div>
          </div>
        </div>
        <!-- /page content -->
  
  <!-- jQuery -->
    <script src="js/ajax_functions.js"></script>  
    
  <?php include('RootMe/js_linksscript.php');?>


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