



<div class="page-title">
  <div>
    <h1><i class="fa fa-calendar"></i> staff</h1>
    <p>View all staff and their </p>
  </div>
  <div>
    <ul class="breadcrumb">
      <li><a href='modules.php'><i class="fa fa-home fa-lg"></i></a></li>
      <li><a href="#">View staff</a></li>
    </ul>
  </div>
</div>
<div class="card">
    <div class="table-scrol">
        <div class='panel panel-primary ch'>
            <div class='panel-heading'>
                <h4 align="center">All staff</h4>
            </div>
            <div class='panel-body'>
                <?php
                    $query = "SELECT * FROM `staff`";
                    $run_query = mysqli_query($connection, $query);
                    
                    if(mysqli_num_rows($run_query) > 0){
                        $i = 0;
                        echo "
                            <div class='table-responsive'>
                                <table class='table table-striped' id='myTable'>
                                    <thead>
                                        <tr>
                                            <th>S/N</th>
                                            <th>USERNAME</th>
                                            <th>NAME</th>
                                            <th>SEX</th>
                                            <th>PHONE</th>
                                            <th>ROLE</th>
                                            <th>STATUS</th>
                                            <th>ACTION</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                        ";
                        while($result = mysqli_fetch_assoc($run_query)){
                            $i++;
                            $staff_id = $result['id'];
                            $username = $result['username'];
                            $name = $result['name'];
                            $sex = $result['sex'];
                            $phone = $result['phone'];
                            $position = $result['role'];
                            $status = $result['status'];
                            
                            echo "
                                <tr>
                                    <td>{$i}</td>
                                    <td>{$username}</td>
                                    <td>{$name}</td>
                                    <td>{$sex}</td>
                                    <td>{$phone}</td>
                                    <td>{$position}</td>
                                    <td class='text-success'><b>{$status}</b></td>
                                    <td>
                                        <form method='POST' action=''>
                                            <input type='hidden' name='staff_hidden_id' value='{$staff_id}' />
                                            <select name='staff_status' class='form-control'>
                                                <option selected>{$status}</option>
                                                <option>Active</option>
                                                <option>Suspend</option>
                                                <option>On Leave</option>
                                            </select>
                                            <input type='submit' name='change_status_btn' id='demoSwal' value='Status' class='btn btn-xs btn-info' />
                                            <input type='submit' name='staff_delete_btn' id='demoSwal' value='Delete' class='btn btn-xs btn-danger' />
                                        </form>
                                    </td>
                                </tr>
                            ";
                        }
                        echo "
                                    </tbody>
                                </table>
                            </div>
                        ";
                    } else {
                        echo "<p class='text-danger'><b>No staff found.</b></p>";
                    }
                ?>
                <!-- DataTable JS init -->
            </div>
        </div>
    </div>
</div>

