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

$m->where("user_id", $_SESSION['user_id']);
$m->where ("branch_id", $_SESSION['branch']);
$m->where("page_id", $_REQUEST['page']);
$access = $m->get("users_privilege_detail");

$date;
  if ($_REQUEST['date']) {

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

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

       if($_REQUEST['attendance']=="All"){        
        
      } else {

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

      }

       $m->where("status", '1');
       $m->orderBy("class_id", "asc");
       $m->where("branch_id", $_SESSION['branch']);
       $m->where("date", $_REQUEST['date']);
      
      $param = array('attendance','student_id','class_id','section_id');
       $WorkAssignListings = $m->get("eduportal_attendance_detail",null,$param);



       /*$branch=$_SESSION['branch'];
       $att=$_REQUEST['attendance'];
       $sql = "SELECT student_id, attendance, status, class_id, section_id, date, branch_Id, session_id FROM  eduportal_attendance_detail  WHERE branch_id='$branch' and status='1' and attendance='$att' and date='$date' ";
print_r($sql);*/
//print_r($WorkAssignListings);
  }
else {

       $m->where("status", '1');
       $m->where("attendance", 'A');
       $m->orderBy("class_id", "asc");
       $m->where("date", date("Y-m-d"));
       $m->where("branch_id", $_SESSION['branch']);
        $param = array('attendance');
       $WorkAssignListings = $m->get("eduportal_attendance_detail",null,$param);
  }
     ?>


<!DOCTYPE html>
<html lang="en">
  <head>
    
    <title>Select Edit Attendance | EduPortal</title>
   <?php include('RootMe/css_links.php');?>
   <style type="text/css">
    
    tr th{padding:1%;color:black;}

   </style>
  

  </head>

  <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;">
           
              <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; 
          
     Day Attendance Summary

          <br><br>

  <section class="">
  <div class="container">
  <div class="inner_banner_bg">
        
    <div class="clearfix"></div>
    </div>
  </div>
</section>
<br>
<section class="add_sub_agent" id="table_sub_agent">
  <div class="container">
   <div class="box_visa_form">
    <div class="table-responsive" style="min-height:320px;padding:3%;">



          
<form class="" action="select_edit_attendance.php" enctype="multipart/form-data" method="get">
<input type="hidden" name="page" value="<?php echo $_REQUEST['page']; ?>">
              <div class="col-md-3 col-xs-9">
                <div class="form-group ">
                  <label class="required">Attendance Date</label>
                  <input class="form-control" type="date" name="date"  id="date"   value="<?php echo $date;?>" required>
                </div>
              </div>

              <div class="col-md-2 col-xs-9" >
                <div class="form-group ">
                    <label class="required">Attendance</label>
                    <select class="form-control" id="attendance" name="attendance"> 
                      <option <?php if ($_REQUEST['attendance']=="All"){echo "Selected";}?> value="All"> All </option>
                      <option <?php if ($_REQUEST['attendance']=="P"){echo "Selected";}?> value="P"> Present </option>
                      <option <?php if ($_REQUEST['attendance']=="A"){echo "Selected";}?> value="A"> Absent </option>
                      <option <?php if ($_REQUEST['attendance']=="L"){echo "Selected";}?> value="L"> Leave </option>
                      <option <?php if ($_REQUEST['attendance']=="LA"){echo "Selected";}?> value="LA"> Late </option>
                      <option <?php if ($_REQUEST['attendance']=="SL"){echo "Selected";}?> value="SL"> Short Leave </option>
                    </select>
                      
                 </div>
               </div>               

              <div class="col-md-1" style="padding:2px;">
                <div class="form-group ">
                  
                <button type="submit" class="btn btn-primary" style="margin-top: 20px;">Search</button>
                </div>
              </div>

              <a href="mark_attendanceReport_list.php?<?php echo session_id().session_id().session_id().session_id().session_id(); ?>" class="btn btn-info" style="margin-top: 22px;"> Attendance Reports</a>

              <a href="view_attendance.php?<?php echo session_id().session_id().session_id().session_id().session_id(); ?>" id="subuser"target="_blank" class="btn btn-success" style="margin-top: 22px;">View Class Wise Attendance </a>

              <?php if (isset($_REQUEST['attendance'])) { ?>                
             
              <a href="print_attendance_history.php?<?php echo session_id().session_id().session_id().session_id().session_id(); ?>&date=<?php echo $_GET['date'];?>&attendance=<?php echo $_GET['attendance'];?>" id="subuser"target="_blank" class="btn btn-success" style="margin-top: 22px;">Print Report </a>

            <?php  } ?>

</form>
          

              


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

<br>


     <table id="listofstudents" data-page-length='100' class="table table-striped table-bordered datatable" style="width:100%">
          
          <thead>
            <tr>
                <th width="2%">S.No</th>
                <th width="12%">Student Name</th>
                <th width="10%"> Father Name </th>
                <th width="10%"> Cell No </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="10%">Attendance</th>
                 <th width="6%">Action</th>
            </tr>
        </thead>
        <tbody>


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

        $stdID=$WorkAssignListVal['student_id'];
        $branch=$_SESSION['branch'];
        $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 student_id='$stdID' ";
       
        $student = $m->query($sql);
      ?>

        <tr>
                
                  <td style="text-align:center;">

                     <?php echo $count; $count++;?>

                   </td>


                  <td>
              <a target="_blank" style="text-decoration: none;" 
  href="print_students_attendance_history.php?student=<?php echo $student[0]['student_id'];?>" >
                     
                     <?php echo $student[0]['first_name'];?>

                   </a>

                   </td>

                  <td>  <?php echo $student[0]['last_name'];?> </td>
                  <td>  <?php echo $student[0]['cell_no'];?> </td>

                  <td> <?php 


                if($_SESSION['branch']!=25){
                 echo  $student[0]['candidate_roll_no']; 
               }else {
                 echo  $student[0]['ref_no']; 
               }


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

                  <td style="text-align:center;<?php if($WorkAssignListVal['attendance']=="L"){echo "background-color:gray;color:white;";} if($WorkAssignListVal['attendance']=="A"){echo "background-color:#E26867;color:white;";}?>;" >

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

                  <td>
                    <?php if ($access[0]['edit_access']!=NULL) { ?>

                    <a data-toggle="modal" data-target="#EditStdAttendance<?php echo $WorkAssignListVal['student_id'];?>" style="padding: 0px 5px; font-size:14px;" href="#" class="btn btn-success">
                 <i class="fa fa-pencil" aria-hidden="true">&nbsp;&nbsp;Edit</i>
                 </a>
               <?php } ?>
                  </td>
              </tr>


 <!-- Student Edit Attendance Popup start -->


      <div id="EditStdAttendance<?php echo $WorkAssignListVal['student_id'];?>" class="modal fade" role="dialog">
        <div class="modal-dialog">

          <!-- Modal content-->
          <div class="modal-content">
            <div class="modal-header" style="border-bottom:none;">
              <button type="button" class="close" data-dismiss="modal">&times;</button>
              <h4 class="modal-title" style="text-align:center;"> Attendance OF (<?php echo $student[0]['first_name']." - ".$student[0]['last_name']; ?>)  </h4>
            </div>

            <div class="modal-body">

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

           <input type="hidden" name="action" value="EditStdAttendance"> 
           <input type="hidden" id="date"  name="date" value="<?php echo $date; ?>" />
           <input type="hidden" id="date"  name="session" value="<?php echo $sessionID; ?>" />
           <input type="hidden" id="date"  name="stdId" value="<?php echo $WorkAssignListVal['student_id']; ?>" />
           <input type="hidden" name="page" value="<?php echo $_REQUEST['page'] ;?>">
         
<br>
                 <div class="col-md-12" >
                <div class="form-group ">
                    <label class="required">Attendance</label>
                    <select class="form-control" id="attendance" name="attendance"> 
                      <option <?php if ($_REQUEST['attendance']=="All"){echo "Selected";}?> value="All"> All </option>
                      <option <?php if ($_REQUEST['attendance']=="P"){echo "Selected";}?> value="P"> Present </option>
                      <option <?php if ($_REQUEST['attendance']=="A"){echo "Selected";}?> value="A"> Absent </option>
                      <option <?php if ($_REQUEST['attendance']=="L"){echo "Selected";}?> value="L"> Leave </option>
                      <option <?php if ($_REQUEST['attendance']=="LA"){echo "Selected";}?> value="LA"> Late </option>
                      <option <?php if ($_REQUEST['attendance']=="SL"){echo "Selected";}?> value="SL"> Short Leave </option>
                    </select>
                      
                 </div>
               </div> 
 



            <div class="modal-footer">

            <button type="submit" style="margin: 30px;" class="btn btn-primary" name="submit" >Submit </button>             


            </div>

                 </form>

          </div>

          </div>

        </div>
      </div>

      <!-- Student Edit Attendance popup ending -->


              <?php
      } ?>



           
            
           
        </tbody>
        
    </table>
   

</div>


    </div>

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

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

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


</script>

  </body>
</html>
