<?php 
     
 require_once "labClass.php";
  
 $con = new labClass();
  
 $chkp= $con->getUsersRecord(); 
    $cc=0;
     
 if ($chkp->rowCount()>0) {

  $chp=$chkp->fetchAll();
  ?>
  <div class="container-fluid " id="co">
  <small><h6>STAFF'S PROFILE REPORT</h6></small> 
  <table class="table table-bordered table-striped">
  <thead class="bg-secondary">
   <th>  
        <small><h6>EMP ID/NAME</h6></small>
        </th>
        <th>
        <small><h6>PHONE NO</h6></small>
        </th>
         <th>
        <small><h6>EMAIL</h6></small>
        </th>
        <th>
         <small><h6>DEPARTMENT</h6></small>
      </th>
       <th>
        <small><h6>PASSWORD</h6></small>
     </th>
       <th>
        <small><h6>BLOCK/UNBLOCK</h6></small>
     </th>
   </thead>
<tbody>
   
  <?php

 foreach ($chp as $key => $p) {
 $cc++;
  ?>
 <tr>
     <td colspan="6">
       <sup id="rdn<?php echo $cc;?>" class="text-danger" ></sup>
     </td>
   </tr>

 <tr>
      
  <td>
    <small><?php echo $p['userid'].". ". $p['fname']." ". $p['mname']." ".$p['lname'];?></small>
        
        <input type="hidden" name="email<?php echo $cc;?>" id="email<?php echo $cc;?>" value="<?php echo $p['email'];?>"/> 
        
         <input type="hidden" name="eid<?php echo $cc;?>" id="eid<?php echo $cc;?>" value="<?php echo $p['userid'];?>"/>
  
  </td>
 
  <td>
        <small> <?php echo $p['phoneno'];?></small>
  </td> 
  <td>
        <small> <?php echo $p['email'];?></small>
  </td>
   
 
   <td class="col"> <small>
    <?php echo $p['department'];?></small>
  </td>
  <td><small> 
   <input type="text" name="pwd<?php echo $cc;?>" id="pwd<?php echo $cc;?>" value="<?php echo $p['pwd'];?>"/> </small>
  </td>
  <td>
      
          <input type="submit" name="add<?php echo $cc;?>" id="add<?php echo $cc;?>" value="Un/Block/" id="submit" onclick="var email=$('#email<?php echo $cc;?>').val(); var eid=$('#eid<?php echo $cc;?>').val(); var pwd=$('#pwd<?php echo $cc;?>').val();   if(email!=''&& eid!='' && pwd!='') { 

            $.post('blockusPro.php',{email:email,eid:eid,pwd:pwd},function(data){$('#rdn<?php echo $cc;?>').html(data).show();});
           
        } else{document.getElementById('rdn<?php echo $cc;?>').innerHTML='Valide item detail required!..';}" />
  </td>
</tr>

  <?php
}
?>
</tbody> 
 </table>
</div><div>
   <button type="submit" class="btn btn-primary" value="Print" style="width:10%; height:30px;" onclick="printPageArea();">Print </button>
</div>
 
<?php
}
?>

<script type="text/javascript">
  function printPageArea(){
    var printContent = document.getElementById('co').innerHTML;
    var originalContent = document.body.innerHTML;
    document.body.innerHTML = printContent;
    window.print();
    document.body.innerHTML = originalContent;
}

</script>