<?php
include "zklibrary.php";
$zk = new ZKLibrary('182.176.184.236', 4371);
$res=$zk->connect();
//var_dump($res); die();
  $zk->disableDevice();
 //var_dump($res);die();
 

$users = $zk->getuser();
//var_dump($users); die();
?>

<input id="myInput" type="text" placeholder="Search..">

<table width="100%" border="1" cellspacing="0" cellpadding="0" style="border-collapse:collapse;">
<thead>
  <tr>
   
    <td>UID</td>
    <td>Name</td>
    <td>roles</td>
    <td>time  </td>
    <td>Student Names </td>
    <td>class Names </td>
    <td>section Names </td>
    <td>branch </td>
   
  </tr>    
</thead>

<tbody id="myTable" >
<?php
$no = 0;
foreach($users as $key=>$user)
{      
   $id = $user[0];
  
    $result = $this->db->query("
    SELECT student.*,class.*,section.*,student.id as stid 
    FROM student JOIN promotion ON promotion.student_id=student.id 
    JOIN class ON promotion.class_id=class.class_id 
    JOIN section ON promotion.section_id=section.section_id
    WHERE  student.status='0' 
    AND promotion.is_active='1' 
    and class.is_delete=0 
    and section.is_delete=0
    and student.id=$id
    
    ")->row();
        // var_dump($result);
?>

  <tr>
    <td><?php echo $user[0];?></td>
    <td><?php echo $user[1];?></td>
    <td><?php echo $user[2];?></td>
    <td><?php echo $user[3];?></td>
    <td><?php echo  $result->student_name;?></td>
    <td><?php echo  $result->class_name?></td>
    <td><?php echo  $result->section_name;?></td>
    <td><?php   if($result->branch==1)
    {
    echo "Morning Shift";
    }
    if($result->branch==2)
    {
    echo "Evening Shift";
    
    }
    else
    {
        echo "";
        
        
    }
    
    
    ?></td>
  </tr>

<?php
}
?>

</tbody>
</table>
<?php

$zk->enableDevice();
$zk->disconnect();

?>




<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("#myInput").on("keyup", function() {
    var value = $(this).val().toLowerCase();
    $("#myTable tr").filter(function() {
      $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
    });
  });
});
</script>

