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


$modules_id=$_REQUEST['modules_id'];
$user_id=$_REQUEST['user_id'];
$branchId=$_SESSION['branch'];

if (isset($_REQUEST['user_id'])) {

  $query="SELECT * FROM eduportal_users_auditlog_detail where branch_id='$branchId' and module_id='$modules_id' and user_id='$user_id'  order by id_useraudit desc limit 0,7000 ";
  
} else {

$query="SELECT * FROM eduportal_users_auditlog_detail where branch_id='$branchId' order by id_useraudit desc limit 0,1500 ";
}
//echo $query;
$WorkAssignListings = $m->query($query);

 
     ?>


<!DOCTYPE html>
<html lang="en">
  <head>
    
    <title>User Audit Report | EduPortal</title>
    <?php include('RootMe/css_links.php');?>
   
  </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();

          }

</script>

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

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

 <div class="" style="margin-top:10px;">
      <form  action="user_audit_report.php" enctype="multipart/form-data" method="get">
        <div class="panel panel-default">
          <div class="panel-heading"><?php echo count($WorkAssignListings);?> Records <span style="float:right;margin-top: -7px;">

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

          </span><div class="clearfix"></div> </div>
          <div class="panel-body">
          
            <div class="col-md-12" id="" >


                

             <div class="col-md-3 col-xs-12" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Modules</label>
                  
                  <select name="modules_id" id="modules_id"  data-placeholder="Select" class="chosen-multi-select inputfield form-control" >
                    <option value="">Select Module</option>

                    <?php
                   
                    $m->orderBy("modules_id","asc");                    
                    $WorkAssignList = $m->get("eduportal_modules_detail");
                    foreach($WorkAssignList as $WorkAssignListVal)
                    { ?>

                       <option <?php if($_REQUEST['modules_id']==$WorkAssignListVal['modules_id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['modules_id']; ?>"><?php echo $WorkAssignListVal['modules_name']; ?></option>

                            <?php
                    } ?>

                </select> 

                  
                </div>
              </div> 

             <div class="col-md-3 col-xs-12" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Users</label>
 

                  <select style="height:40px;" name="user_id" id="user_id" class="chosen-multi-select form-control"  required>

                              <option value="">Select User</option>
                        
                        <?php
                        $m->where("status", '0');
                        $m->where("branch_id", $_SESSION['branch']);
                        $Users = $m->get("edu_user_config");
                        foreach($Users as $User)
                        { ?>

                           <option <?php if($_REQUEST['user_id']==$User['user_id']){echo 'selected';}?> value="<?php echo $User['user_id']; ?>"><?php echo $User['user_fname']; ?></option>


                                <?php
                        } ?>

                    </select> 
                </div>
              </div>
              

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

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

     

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

    <h3>Audit Reports</h3>
    <table id="listofstudents" data-page-length='100' class="table table-striped table-bordered center" style="width:100%">
          
          <thead>
            <tr>
                <th width="3%">S.No</th>
                <th width="17%">Action</th>
                <th width="50%">Details</th>
                <th width="8%">Date/Time</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['action'];?></td>
                  <td><?php echo $WorkAssignListVal['details'];?></td>
                  <td><?php echo date("d-M-Y",strtotime($WorkAssignListVal['date']))." / ".$WorkAssignListVal['time'];?></td>
                
                </tr>

              <?php
      } ?>

        </tbody>
        
    </table>

</div>



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

           
          </div>
        </div>

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


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