
<div class="table-responsive">
<table id="dt-basic-example" class="table table-hover table-striped w-100" style="font-size: 11px;">
    <thead class="bg-primary" style="color: #fff;">
        <tr>
        <th></th>
        <th>Name</th>
        <th>Phone</th>
        <th>Email</th>
        <th>Office</th>
        <th>Appointment</th>
        <th>Username</th>
        <th>Privilege</th>
        <th>Status</th>
        <th>Pwd Reset</th>
        <th></th>
        </tr>
    </thead>
    <tbody>
    <?php

    $aa=0;
    $Sql = $conn->prepare("SELECT * FROM tbl_user_accounts
    INNER JOIN tbl_role ON tbl_role.role_id = tbl_user_accounts.user_role
    INNER JOIN tbl_user_access ON tbl_user_access.last_acc = tbl_user_accounts.user_id
    WHERE tbl_user_accounts.us=1 order by user_id desc");
    $Sql->execute();
    while($Get=$Sql->fetch()){
    $user_id = $Get['user_id'];
    $title_id = $Get['title_id'];
    $role_id = $Get['role_id'];
    $privilege_id = $Get['privilege_id'];
    $aa++;
    $status = $Get['status'];
    $gender = $Get['gender'];
    if($gender == 'M'){
        $g_name = "Male";
    }elseif($gender == 'F'){
        $g_name = "Female";  
    }else{
        $g_name = "Other";   
    }
    ########## RANK ###########
    $rankQue= $conn->prepare("SELECT * FROM tbl_rank where rank_id='".$Get['rank_id']."' ");
    $rankQue->execute();
    $data1=$rankQue->fetch();
    ########## RANK ###########

    ########## APPOINT ###########
    $appoiQue= $db->prepare("SELECT * FROM tbl_title where title_id='".$title_id."' ");
    $appoiQue->execute();
    
    if($appoiQue->rowCount()>0){
    while($data2=$appoiQue->fetch()){
        $tlename=$data2['title_name'];
    }

    }else{
    $tlename="";
    }
    ########## APPOINT ###########

    ########## PRIVILEDGE ###########
    $sttmt1 = $conn->prepare("SELECT * FROM tbl_privilege WHERE  privilege_id= $privilege_id");
    $sttmt1->execute();
    $row2 = $sttmt1->fetch();
    $privilege = $row2['privilege'];
    $priv_ID = $row2['privilege_id'];
    ########## PRIVILEDGE ############
    ?>

    <tr>
    <td><?php  echo $aa."."; ?></td>
    <td><?php echo "<b>".$data1['rank_name']."</b>"." ".$Get['family_name']." ".$Get['first_name'];?></td>
    <td><?php echo $Get['mobile_no'];?></td>
    <td><?php echo $Get['user_email'];?></td>
    <td><?php echo $Get['role_name'];?></td>
    <td><?php echo $tlename;?></td>
    <td><?php echo $Get['username'];?></td>
    <td><?php echo $privilege;?></td>

    <td class="text-center">
        <?php
        if($status==0)
            { 
        ?>
            <a href="gate?b=mgeus&acid=<?php echo $user_id;?>" class="btn btn-danger btn-xs">Inactive</a>
            <?php }elseif($status == 1){?>
            <a href="gate?b=mgeus&did=<?php echo $user_id;?>" class="btn btn-success btn-xs">Active</a>
        <?php }?>
    </td>
    
    <td><a class="text-success" href="#" data-toggle="modal" data-target="#res_<?php echo $Get['user_id']; ?>">
        <span class="custom-badge btn-primary btn-xs">Reset Password</span></a>
    </td>

    <td align="center" style="width:10%;">
        <a href="gate?b=mgeus&usrid=<?php echo $user_id;?>" title="Edit user info."><i class="fa fa-pencil-square-o" style="color: #5a5a5a;"></i> Edit</strong></a>
        |      
        <a href="javascript:void(0)" title="Delete record" data-toggle="modal" data-target="#modalCenterIcon<?php echo $Get['user_id'];?>" style="color: #a61212;"><i class="fa fa fa-trash-o" style="color: #a61212;"></i> Delete</strong></a><br>
    </td>
    
    </tr>
    <?php
    include 'delete-user.php';
    include 'reset_ok.php';
     }
    ?>
</tbody>              
</table>
</div>
