<?php
  /**** this section displays users details*****/
  session_start();
  include_once('../../config/config.php');
  $user_id=$_SESSION['user_id'];

  //select statement
  $statement="select * from system_users where user_id !=
  '$user_id'";

  try{
    $sql=$db->query($statement);
    if($sql){
      
  ?>

 <table id="order-listing" class="table table-striped table-bordered table-sm">
                    <thead>
                      <tr>
                        <th>#</th>
                        <th>Name</th>  
                        <th>Email Address</th>
                        <th>Account Type</th>
                        <th>Action</th> 
                      </tr>
                    </thead>
<?php
    echo"<tbody>";
    $i=0;
    while ($row=$sql->fetch()) {
      $i++;
      echo "
      <tr>
        <td>".$i."</td>
        <td>".$row['first_name']." ".$row['last_name']."</td>
       <td>".$row['email_address']."</td>
       <td>".$row['user_type']."</td>
       <td>"; ?>
       <div class="btn-toolbar mb-2 mb-md-0">
              <div class="btn-group mr-2">
                <button class="btn btn-sm btn-outline-primary" id="new_user"><i class="fa fa-edit"></i> Edit</button>
                <button class="btn btn-sm btn-outline-danger btn_delete" name="delete_btn" data-id3="<?php echo $row["user_id"]; ?>" ><i class="icon icon-trash"></i> Delete</button>
              </div>
            </div>
           
      <?php echo" </td>
      </tr>"  
      ;
    }
    echo"</tbody>";

  }
  else{
    echo"<tr><td colspan='6'>There are no system users users</td></tr>";
  }
?>
</table>

  <?php
  }
  catch(PDOException $e){
    $e->getMessage();
  }  
?>



 <script>
    (function($) {
      'use strict';
      $(function() {
        $('#order-listing').DataTable({
          "aLengthMenu": [
          [5, 10, 15, -1],
          [5, 10, 15, "All"]
          ],
          "iDisplayLength": 10
        });
      });
    })(jQuery);
  </script>
  
