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

  
      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']);
        
      }

       $m->where("status", '0');
       $m->where("branch_id", $_SESSION['branch']);



      $WorkAssignListings = $m->get("edu_student_details");
      }


  $date1;
  if($_REQUEST['date']!=NULL){
    $date1=$_REQUEST['date'];
  }else {
    
    $date1=date("Y-m-d");
  }


     ?>


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

<style>
/* The container */
.btn_style {
    display: block;
    position: relative;
    padding-left: 35px;
    margin-bottom: 12px;
    cursor: pointer;
    font-size: 12px;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Hide the browser's default radio button */
.btn_style input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

/* Create a custom radio button */
.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 20px;
    width: 20px;
    background-color: #eee;
    border-radius: 50%;
}

/* On mouse-over, add a grey background color */
.btn_style:hover input ~ .checkmark {
    background-color: #ccc;
}

/* When the radio button is checked, add a blue background */
.btn_style input:checked ~ .checkmark {
    background-color: #2196F3;
}

/* Create the indicator (the dot/circle - hidden when not checked) */
.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

/* Show the indicator (dot/circle) when checked */
.btn_style input:checked ~ .checkmark:after {
    display: block;
}

/* Style the indicator (dot/circle) */
.btn_style .checkmark:after {
  top: 6px;
  left: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: white;
}
</style>


  </head>
  
<script>

var chk_status;  





  </script>

<script type="text/javascript">

function show_message(){
  
  $("#msg").slideDown('slow').delay(4000).slideUp('slow');
  $("#error").slideDown('slow').delay(5000).slideUp('slow');

}

</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="" >
      <h3 style="float: left;">Students Mark Attendance <small>(<?php echo count($WorkAssignListings);?> Students Records)</small> </h3>     
    <section class="add_sub_agent" id="table_sub_agent">
  <div class="container">

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


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

          <input type="hidden" value="<?php echo session_id().session_id().session_id().session_id().session_id(); ?>" name="session" />


<div class="pull-right">   

 
  <a onClick="$('#advanceSearch').toggle('blind')" class="btn btn-primary" style="margin-top: 5px;">Advance Search</a>


</div>



          </span><div class="clearfix"></div> </div>
          <div class="panel-body" style="padding: 0px;">
          
            <div class="col-md-12" id="advanceSearch" style="display:none;">
             <div class="col-md-3" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Class</label>
 <script>
      

        
                        


                  </script>
                  <select name="class_id" class="form-control" onChange="getsec(this.value)"  >
                    <option value="">All</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-3" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Section</label>
                    <select name="section" id="txt_section" class="form-control" >
                      
                   <?php
                              if($_REQUEST['section']!='')
                              { 

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

                              $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-3" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Session</label>
                    <select name="session" class="form-control" >

                              
                        <?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-3" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Date</label>
                  
                  <input class="form-control" type="date" name="date"  id="date"  value="<?php echo $date1;?>" required>
                </div>
              </div>



              <div class="col-md-3 pull-right" style="padding:2px;">
                <div class="form-group ">
                   <input type="hidden" name="addaccountAdmin" value="1">
                <button type="submit" class="btn btn-primary" style="margin-top: 24px;float: right;">Search</button>
                </div>
              </div>

             
            </div>
            <div class="clearfix"></div>
          </div>
        </div>
      </form>
      <div class="clearfix"></div>
    </div>
    <br>

        


          
<?php 

 if(!isset($_REQUEST['class_id'])){

?>
          <div class="col-md-12">

                  <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 class and month from advance search to mark attendance !!!
                  </div>
            </div>
<?php 

   }
?>  



<div style="">
      

<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="MarkAttendance">
  <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="session"  name="session" value="<?php echo $_GET['session']; ?>" />
  <input type="hidden" id="date"  name="date" value="<?php echo $date1; ?>" />



 <?php    if($_REQUEST['class_id']!=NULL){?>

  <input type="submit" name="submit" class="pull-right btn btn-primary"  value="Save Attendance" style="margin-top: 5px;"  />
  
   <?php    }?>

       
    <table id="listofstudents" data-page-length='100' class="table table-striped table-bordered dataTable no-footer" style="width:100%;background-color: white;">
          
          <thead>
            <tr>
                <th width="5%">S.No</th>
                <th width="10%">Student Name</th>
                <th width="10%">Father Name </th>
                <th width="10%">Roll#</th>
                <th width="10%" style="text-align:center;"> Class </th>
                <th width="8%" style="text-align:center;"> Date </th>
                 <th width="25%">Attendance</th>
            </tr>
        </thead>
        <tbody>


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

 
      ?>

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

               <input name="attendance[]" id="attendance[]" type="hidden" value="<?php echo $WorkAssignListVal['student_id'];?>">



               <?php echo $WorkAssignListVal['first_name'];?>

             </td>

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

                  <td>
                   <?php echo  $WorkAssignListVal['candidate_roll_no'];?> 
                  </td>
                  <td style="text-align:center;"> 

                    <?php echo getClassName($m,$WorkAssignListVal['class_id']);?> -  <?php echo getSectionName($m,$WorkAssignListVal['section_id']);?> 
                  </td>
                  
                  <td style="text-align:center;"> <?php echo date("d-M-Y",strtotime($_GET['date']));?> </td>

                  <td>

                  <div style="float:left;">
                    
                    <label class="btn_style">Present
                      <input type="radio" checked="checked" name="<?php echo $WorkAssignListVal['student_id'];?>" value="P" />
                      <span class="checkmark"></span>
                    </label>

                  </div>

                  <div style="float:left;margin-left:2%">
                    
                    <label class="btn_style">Absent
                      <input type="radio" name="<?php echo $WorkAssignListVal['student_id'];?>" value="A" />
                      <span class="checkmark"></span>
                    </label>

                  </div>

                  <div style="float:left;margin-left:2%">
                    
                    <label class="btn_style">Leave
                      <input type="radio" name="<?php echo $WorkAssignListVal['student_id'];?>" value="L" />
                      <span class="checkmark"></span>
                    </label>

                  </div>

                  <div style="float:left;margin-left:2%">
                    
                    <label class="btn_style">Late
                      <input type="radio" name="<?php echo $WorkAssignListVal['student_id'];?>" value="LA" />
                      <span class="checkmark"></span>
                    </label>

                  </div>


                  </td>
              </tr>





              <?php
      } ?>



           
            
           
        </tbody>
        
    </table>

</form>
</div>

    <br><br>


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

           
          </div>
        </div>

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

<!-- Links for Datatable-->
<link href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css" rel="stylesheet" type="text/css" />   
<script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
 <script>
        
  $(document).ready(function() {
    $('#listofstudents').DataTable({
      "pageLength": 1000
    });
    } 
  );

</script>
     
  </body>
</html>
