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


$session;

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

      $session=$_REQUEST['session'];
      
    }else {
      
      $session=$_SESSION['current_session'];
    }

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

     
       $branch=$_SESSION['branch'];
       $classID=$_REQUEST['class_id'];
       $sectionID=$_REQUEST['section'];

       $sql = "SELECT student_id, first_name, last_name, ref_no, cell_no, status, branch_id, class_id, candidate_roll_no, section_id, session_id FROM  edu_student_details  WHERE branch_id='$branch' and status='0' and session_id='$session' and class_id='$classID' and section_id='$sectionID' ";

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

      
      }
 
     ?>


<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Mark Attendance | EduPortal</title>
    <!-- Bootstrap -->
    <link href="../vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="../vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <!-- bootstrap-daterangepicker -->
    <link href="../vendors/bootstrap-daterangepicker/daterangepicker.css" rel="stylesheet">

    <!-- Custom Theme Style -->
    <link href="../build/css/custom.min.css" rel="stylesheet">
    <link href="<?php echo DOMAIN;?>Production/css/style1.css" rel="stylesheet">
   
<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 type="text/javascript">

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

 

}

function change_status(id,status){


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

      }

    }

    xmlhttp.open("GET","parent/change_status.php?status="+status+"&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">


      <a href="<?php echo $_SESSION['dashboard'];?>">Dashboard </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp; 

     <a href="mark_attendanceReport_list.php">Attendance Reports </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp; 
          
     Edit Attendance

          <br><br>

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


      <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 to mark attendance !!!
                  </div>



              </div>


<?php 

   }
?>  

          
          <?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['upsuccess'])){?>


            <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 updated successfully...
            </div>


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



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

<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="UpdateAttendance">
  <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 $_GET['date']; ?>" />


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



        <div class="col-md-9">

          
           <div id="check_std_msg" style="display:none;" class="alert alert-danger alert-dismissible">
                    <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
                     <strong>Warning !</strong> Please select class to save attendance !!!
            </div>
    
          <?php  if(isset($_SESSION['error_msg'])){?>

           <div id="error"  class="alert alert-danger alert-dismissible">
                    <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
                     <strong>Warning !</strong> You have already saved the attendance of this class !!!
            </div>

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

        </div>

       

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

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

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

              <br><br>
         <?php    }?>

        </div>


    <table id="listofstudents" data-page-length='100' class="table table-striped table-bordered" style="width:100%">
          
          <thead>
            <tr>
                <th width="15%">Student Name</th>
                <th width="10%"> Father Name </th>
                <th width="8%">Roll#</th>
                <th width="10%" style="text-align:center;"> Class </th>
                <th width="8%" style="text-align:center;"> Date </th>
                 <th width="28%">Attendance</th>
            </tr>
        </thead>
        <tbody>


   
     
     <?php /*$WorkAssignList = $m->query("select * from edu_student_details where status='0' order by student_id desc");*/

      foreach($WorkAssignListings as $WorkAssignListVal)
      { 

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



       $date=$_REQUEST['date'];
       $stdID=$WorkAssignListVal['student_id'];

       $qr1="SELECT attendance FROM eduportal_attendance_detail WHERE branch_Id='$branch' and student_id='$stdID' and status='1' and date='$date'";
  
       $attendance=$m->query($qr1);
     
        
      ?>

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

        if($_SESSION['branch']!=25){
         echo  $WorkAssignListVal['candidate_roll_no']; 
       }else {
         echo  $WorkAssignListVal['ref_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($_REQUEST['date'])) ;?> </td>

                  <td>

                  <div style="float:left;">
                    
                    <label class="btn_style">Present
                      <input <?php if($attendance[0]['attendance']=="P"){echo 'checked="checked"';} ?> type="radio"  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 <?php if($attendance[0]['attendance']=="A"){echo 'checked="checked"';} ?> 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 <?php if($attendance[0]['attendance']=="L"){echo 'checked="checked"';} ?> 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 <?php if($attendance[0]['attendance']=="LA"){echo 'checked="checked"';} ?> type="radio" name="<?php echo $WorkAssignListVal['student_id'];?>" value="LA" />
                      <span class="checkmark"></span>
                    </label>

                  </div>

                  <div style="float:left;margin-left:2%">
                    
                    <label class="btn_style">Short Leave
                      <input <?php if($attendance[0]['attendance']=="SL"){echo 'checked="checked"';} ?> type="radio" name="<?php echo $WorkAssignListVal['student_id'];?>" value="SL" />
                      <span class="checkmark"></span>
                    </label>

                  </div>

        
        
        



                <script>
                function confirmation(id) {
                    var txt;
                    var r = confirm("Are you sure you want to delete this record ?");
                    if (r == true) {
                        delete_student(id);
                    } else {
                        return false;
                    }
                    
                }
                </script>



                  </td>
              </tr>





              <?php
      } ?>



           
            
           
        </tbody>
        
    </table>

</form>
</div>

    <br><br>


  </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>
    <script>
        $(document).ready(function() {
        $('#listofstudents').DataTable();
        } 
        );
    </script>


  
  </body>
</html>
