<?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");

 $branch=$_SESSION['branch'];
$WorkAssignListings = $m->query("SELECT sec.*, cls.* FROM edu_adm_section_detail as sec LEFT JOIN edu_class_config as cls ON sec.class_id = cls.class_id where cls.class_id!='' and cls.branch_id='$branch' and sec.branch_id='$branch' ORDER BY cls.class_id asc");


$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.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>

  <style type="text/css">
    .center {
  margin-left: auto;
  margin-right: auto;
}
  </style>

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

            <a href="<?php echo $_SESSION['dashboard'];?>">Dashboard </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp; 
                   
              Roll Number Slips
                 
                         <br><br>
                         
          <div class="row" style="background-color: white;">

      <?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 } ?>

<br>
           
     <h3>Class Wise Roll Number Slips </h3>

   

    <form class="form-style-7" action="classwise_rollnumber_slips.php" method="get" enctype="multipart/form-data">

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

  <?php if (isset($_REQUEST['term_id'])) { ?>
 
    <table data-page-length='100' class="table table-striped table-bordered center" style="width:80%">
          
          <thead>
            <tr>
                <th width="3%">S.No</th>
                <th width="17%">Class/Section Name</th>              
                <th width="8%">Genrate Roll Number Slip</th>              
                               
            </tr>
        </thead>
        <tbody>


   
     
     <?php $count=1;

      foreach($WorkAssignListings as $WorkAssignListVal)
      { 

             
      ?>

             <tr>
          <td style="text-align:center;"> <?php echo $count; $count+=1;?> </td>
          <td><?php echo  $WorkAssignListVal['Class_Name']." - ".$WorkAssignListVal['section_name']; ?></td>
         
               <?php
          $m->where("month_id", $_REQUEST['month']);
          $m->where("classs_id", $WorkAssignListVal['class_id']);
          $m->where("session_id", $_REQUEST['session']);
          $m->where("branch_id",$_SESSION['branch']);
          $cls_challan = $m->get("eduportal_monthly_challan");

          if($_REQUEST['fee']=='1') { ?>

                  <td> <a target="_blank" href="rollnumber_slips.php?<?php echo session_id().session_id().session_id();?>&session=<?php echo $_GET['session'];?>&term_id=<?php echo $_GET['term_id'];?>&class_id=<?php echo $WorkAssignListVal['class_id'];?>&section=<?php echo $WorkAssignListVal['section_id'];?>&fee=<?php echo $_GET['fee'];?>&syllabus=<?php echo $_GET['syllabus'];?>&month=<?php echo $_GET['month'];?>" class="btn btn-success">Genrate Roll Number Slip</a> </td>

                 <?php } elseif($_REQUEST['fee']=='0') { ?>

                 <td> <a target="_blank" href="rollnumber_slips.php?<?php echo session_id().session_id().session_id();?>&session=<?php echo $_GET['session'];?>&term_id=<?php echo $_GET['term_id'];?>&class_id=<?php echo $WorkAssignListVal['class_id'];?>&section=<?php echo $WorkAssignListVal['section_id'];?>&fee=<?php echo $_GET['fee'];?>&syllabus=<?php echo $_GET['syllabus'];?>&month=<?php echo $_GET['month'];?>" class="btn btn-success">Genrate Roll Number Slip</a> </td>


            <?php  } else { ?>

            	<td> <a target="_blank" href="rollnumber_slips_withoutFee.php?<?php echo session_id().session_id().session_id();?>&session=<?php echo $_GET['session'];?>&term_id=<?php echo $_GET['term_id'];?>&class_id=<?php echo $WorkAssignListVal['class_id'];?>&section=<?php echo $WorkAssignListVal['section_id'];?>&fee=<?php echo $_GET['fee'];?>&syllabus=<?php echo $_GET['syllabus'];?>&month=<?php echo $_GET['month'];?>" class="btn btn-success">Genrate Roll Number Slip</a> </td>


            <?php } ?>

       

                </tr>

              <?php
      } ?>

        </tbody>
        
    </table>
<?php  } else {?>
<br><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 and serarch to Genrate Roll Number Slip  !!!
  </div>
  <?php }?>
</div>



    


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