<?php include("parent/callMe.php"); ?>
<?php  include("sessioncheck.php"); ?>
<?php
 
/*$sql = "SELECT * FROM  edu_student_details  WHERE branch_id='$branch' and status='0'";*/

$sql = "SELECT std.student_id,std.class_id,std.section_id,std.first_name,std.last_name,std.candidate_roll_no,std.cell_no,std.session_id,std.image FROM edu_student_details as std WHERE std.status='0' and std.branch_id=".$_SESSION['branch']. " ";

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

    if($_REQUEST['class_id']=="All"){
      $sql;
    } else {
    $sql .= " AND std.class_id = '" .$_REQUEST['class_id']. "' ";

    }

    if($_REQUEST['section']=="All"){
      $sql;
    } else {
    $sql .= " AND std.section_id =" . $_REQUEST['section']. " ";

    }
  
 // echo $sql;

  $WorkAssignListings = $m->query($sql);
}

$termID=$_REQUEST['term_id'];
$branchId=$_SESSION['branch'];
 $clssec="SELECT * FROM eduportal_datesheet_config as confg, eduportal_datesheet_details as detail WHERE confg.term_id='$termID' and confg.datesheet_id=detail.datesheet_ids and confg.branch_id='$branchId' ORDER BY detail.Dsheet_detail_id ASC";

//print_r($clssec);

 $classSection = $m->query($clssec);
     
$class_id=$_REQUEST['class_id'];
$section=$_REQUEST['section'];
$detailid=$classSection[0]['Dsheet_detail_id'];

$sql = "SELECT * FROM  eduportal_datesheet_subject_day WHERE detail_sheet_id='$detailid' and branch_id='$branchId' ORDER BY id ASC";
//print_r($sql);
$WorkAssignListings5 = $m->query($sql);


$sessionIDs;
 
  if($_GET["session"]!=NULL ){

      $sessionIDs= $_GET["session"];
    }
    else{
      $sessionIDs= $_SESSION['current_session'];
    }

 ?>


<!DOCTYPE html>
<html lang="en">
  <head>
    
    <title>View Date Sheet | 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 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();

          }


   function getsec(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();




  }



function checkboxes_print(){
  
var chk_arr =  document.getElementsByName("numbers[]");
var class_id =  document.getElementById("class_id").value;
var section =  document.getElementById("txt_section").value;
var session =  document.getElementById("session").value;
var term_id =  document.getElementById("term_id").value;
var month =  document.getElementById("month").value;
var fee =  document.getElementById("fee").value;
var syllabus =  document.getElementById("syllabus").value;

//alert(chk_arr);

var chklength = chk_arr.length;             
var ids;
var count=0;
  for(k=0;k< chklength;k++)
  {
      
      if(chk_arr[k].checked){
         var vl=chk_arr[k].value.split(",");
         ids=ids+","+vl[0];
        count++;  
    }
  } 
 //alert(ids);
if(count>0){
  window.location="print_rollnumber_slip_withoutFee.php?students="+ids+"&class_id="+class_id+"&section="+section+"&session="+session+"&term_id="+term_id+"&month="+month+"&fee="+fee+"&syllabus="+syllabus;
} else {
  
  alert("Please choose any students from checkboxes...");

}
  
}




function checkboxes_printLandscape(){
  
var chk_arr =  document.getElementsByName("numbers[]");
var class_id =  document.getElementById("class_id").value;
var section =  document.getElementById("txt_section").value;
var session =  document.getElementById("session").value;
var term_id =  document.getElementById("term_id").value;
var month =  document.getElementById("month").value;
var fee =  document.getElementById("fee").value;
var syllabus =  document.getElementById("syllabus").value;

//alert(chk_arr);

var chklength = chk_arr.length;             
var ids;
var count=0;
  for(k=0;k< chklength;k++)
  {
      
      if(chk_arr[k].checked){
         var vl=chk_arr[k].value.split(",");
         ids=ids+","+vl[0];
        count++;  
    }
  } 
 //alert(ids);
if(count>0){
  window.location="print_rollnumber_slip_landscap.php?students="+ids+"&class_id="+class_id+"&section="+section+"&session="+session+"&term_id="+term_id+"&month="+month+"&fee="+fee+"&syllabus="+syllabus;
} else {
  
  alert("Please choose any students from checkboxes...");

}
  
}



function HideDate(str){
  
  if(str=="1" || str=="0"){
    
    document.getElementById("month").style.display="block";
    document.getElementById("col3").style.display="block";
   
  }
  else {
    
    document.getElementById("month").style.display="none";
    document.getElementById("col3").style.display="none";
   
   
  }
}

  </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 Date Sheet </h3>

   

    <form class="form-style-7" action="rollnumber_slips_withoutFee.php">

  <!--   <input type="hidden" name="action" value="rollNumberSlips"> -->
              
   <div class="col-md-2 col-xs-12" 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 col-xs-12" 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" required >
                    <option value="">Select Term</option>

                    <?php
                    $m->where("session_id", $sessionIDs);
                    $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 col-xs-12" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Class</label>
 
                  <select name="class_id" id="class_id" class="form-control" onChange="getsec(this.value)" required >
                    <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"   >
                      <option value="All">All</option>
                   <?php
                              if(isset($_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-2 col-xs-12" style="padding: 8px;">

                       <div class="form-group ">

                          <label class="required">Fee Status</label>
                              <select name="fee" id="fee" onChange="HideDate(this.value);" class="form-control"  >

                                <option value='All'>All</option>
                          
                                <option <?php if($_GET['fee']=="1"){echo 'selected';}?> value='1'>PAID</option>
                                <option <?php if($_GET['fee']=="0"){echo 'selected';}?> value='0'>UNPAID</option>
                          

                                  
                              </select>
                            </div>


                    </div>


                    <div class="col-md-2 col-xs-12" style="padding: 8px;">
                       <div class="form-group ">
                          <label class="required">Display Syllabus</label>
                              <select name="syllabus" id="syllabus" class="form-control">
                                
                                <option <?php if($_GET['syllabus']=="Yes"){echo 'selected';}?> value='Yes'>Yes</option>

                                <option <?php if($_GET['syllabus']=="No"){echo 'selected';}?> value='No'>No</option>   

                              </select>

                            </div>
                    </div>


                       <div class="col-md-2 col-xs-12" style="padding:8px;<?php if(isset($_REQUEST['month']) && $_REQUEST['fee']=='1' || $_REQUEST['fee']=='0') { echo 'display:block;';}else {echo 'display:none;';} ?>"  id="col3">

                       <div class="form-group ">

                          <label class="required">Challan Month</label>
                              <select name="month" id="month" class="form-control">

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

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

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


                                          <?php
                                  } ?>

                              </select>
                            </div>


                    </div>


             


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

 <a class="btn btn-warning" style="float: right;" href="#" onClick="checkboxes_print();" >
    Print RollNo Slips
  </a>

  <a class="btn btn-warning" style="float: right;" href="#" onClick="checkboxes_printLandscape();" >
    Print RollNo Slips Landscape
  </a>

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

              
                <th width="5%">S.No</th>
                <th width="17%">Student</th>
                <th width="5%">Roll#</th>              
                <th width="10%"> Cell </th>
                <th width="20%"> Class </th>
              

                <th width="5%">

              <label class="container1"><input  type="checkbox" id="checkAll"/><span style="margin-top: -20%;border: 1px solid gray;" class="checkmark" ></span></label>
              
               </th>
                
            </tr>
        </thead>
        <tbody>


   
     
     <?php 
$count=1;
      foreach($WorkAssignListings as $WorkAssignListVal)
      { 

        /*$m->where("class_id", $WorkAssignListVal['class_id']);
        $class=$m->get("edu_class_config");

        $m->where("section_id", $WorkAssignListVal['section_id']);
        $section=$m->get("edu_adm_section_detail");*/

        $m->where("session_id", $WorkAssignListVal['session_id']);
        $sessionIDs=$m->get("edu_session_config");
        
      ?>

        <tr>

          <td style="text-align:center; padding: 2px;"><?php echo $count++;?></td>        

                  <td style="padding: 2px;" > 

<!-- making a link   -->

<a style="padding: 0px 5px; font-size:14px;"  href="student_profile.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']; ?>&session=<?php echo $_REQUEST['session']; ?>&student=<?php echo $WorkAssignListVal['student_id']; ?>" style="cursor:pointer;">


                 <!--  <?php if($WorkAssignListVal['image']!=NULL){?>

                    <img style="border-radius:50%;height:30px;width:30px;" src="<?php echo DOMAIN.AgentDirectory;?>/students_pics/<?php echo $WorkAssignListVal['image'];?>"  />
                  <?php }else {?>

                    <img style="border-radius:50%;height:30px;with:30px;" src="images/student.png" />

                  <?php }?> -->
                  
                    <?php echo $WorkAssignListVal['first_name'];?>
                </a>
                                   
                                   
                </td>
                  <td style="padding: 2px; text-align: center;"> <?php echo $WorkAssignListVal['candidate_roll_no']; ?> </td>
                 
                  <td style="text-align:center; padding: 2px;"> <?php echo $WorkAssignListVal['cell_no'];?> </td>
                  <td style="text-align:center; padding: 2px;">
                   <?php echo getClassName($m,$WorkAssignListVal['class_id']);?> / <?php echo getSectionName($m,$WorkAssignListVal['section_id']);?> </td>
                  
              

    

  

    

<td style="padding: 2px;">
      <label class="container1">
  <input type="checkbox"  name="numbers[]" value="<?php echo $WorkAssignListVal['student_id'].",".$WorkAssignListVal['cell_no'];?>"><span style="border: 1px solid gray;" class="checkmark"></span>
      </label>

</td>  </tr> <?php   } ?>
 
        </tbody>
        
    </table>



    


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

      <!-- Links for Datatable-->

<script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
 <script>
        
  $(document).ready(function() {
    $('#listofstudents').DataTable({
      "pageLength": 100
    });
    } 
  );

  $("#checkAll").change(function () {

      $("input:checkbox").prop('checked', $(this).prop("checked"));
  });


</script>

  </body>
</html>
