<?php

if($_SESSION["type"] != 1){
	echo "No permission to access"; die();
	}

?>
<div class="row">
    <div class="col-lg-12" style="margin-top:-41px;margin-bottom:-13px;">
        <h1 class="page-header" style="font-size:19px; color:#09F;"><i class="fa fa-user fa-fw"></i>&nbsp;User Management</h1>
    </div>
    <!-- /.col-lg-12 -->
</div>

<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default" style="width:100%;">
            <!-- /.panel-heading -->
            <div class="panel-body">
                <div class="table-responsive">
                    <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                        <thead>
                            <tr>
                                <th style="text-align:center">No</th>
                                <th style="text-align:center">
                                    User Name
                                </th>
                                <th style="text-align:center">
                                    Full Name
                                </th>
                                <th style="text-align:center">
                                    Email
                                </th>
                                <th style="text-align:center">
                                    Register Date
                                </th>
                                <th style="text-align:center">
                                    User Description
                                </th>
                                <th style="text-align:center" width="75">
                                    User Type
                                </th>
                                <th style="text-align:center" width="30">Edit</th>
                                <th style="text-align:center" width="30">Reset</th>
                                <th style="text-align:center" width="30">Delete</th>
                                
                            </tr>
                        </thead>
                        <tbody>
                            <?php
								$user_id=$_SESSION["user_id"];
								mysqli_query($conn,'SET NAMES utf8');
								$sql="select * from tbl_user where user_id !=1";
								$res=mysqli_query($conn,$sql);
								$i=0;
								while($row=mysqli_fetch_array($res)){
										
							?> 
                            <tr>
                                <td style="font-size:12px;" align="center"><?php echo $i+=1; ?></td>
                                <td style="font-size:12px;"><?php echo $row['username']; ?></td>
                                <td style="font-size:12px;"><?php echo $row['full_name'];?></td>
                                <td style="font-size:12px;"><?php echo $row['email'];?></td>
                                <td style="font-size:12px;"><?php echo $row['register_date']; ?></td>
                                <td style="font-size:12px;"><?php echo $row['user_description']; ?></td>
                                <td style="font-size:12px; width:100px"><?php if($row['user_type']==1){echo"Admin User";}else{echo"Normal User";}?></td>
                                          
                                <td align="center"><a href="?page=edituser&user_id=<?php echo $row['user_id'] ?>" title="edit"><div class="fa fa-edit fa-fw"></div></a></td>
                                <td align="center"><a href="?page=resetpassword&user_id=<?php echo $row['user_id'] ?>" title="Reset Password"><div class="fa fa-user-md fa-fw"></div></a></td>
                                <td align="center"><a href="#myModal<?php echo $row['user_id']; ?>" data-toggle="modal" title="delete"><div class="fa fa-trash-o fa-fw"></div></a></td>
                            </tr>
                            <div class="modal small fade" id="myModal<?php echo $row['user_id']; ?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                              <div class="modal-dialog">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                                        <h3 id="myModalLabel">Tollay User Confirmation Delete</h3>
                                    </div>
                                    <div class="modal-body">
                                        <p class="error-text"><i class="fa fa-warning modal-icon"></i>Are you sure you want to delete this User?</p><br/>
                                        <label style="font-size:19px; color:#09F;">User Name : <?php echo $row['username']; ?></label>
                                    </div>
                                    <div class="modal-footer">
                                        <a class="btn btn-danger" href="include/user/delete_user.php<?php echo '?user_id='.$row['user_id'];?>" ><i class="icon-check"></i>&nbsp;Yes</a>
                                        <button class="btn" data-dismiss="modal" aria-hidden="true"><i class="icon-remove"></i> Close</button>
                                    </div>
                                  </div>
                                </div>
                            </div>
                            <?php } ?>
                           
                        </tbody>
                    </table>
                </div>
                <!-- /.table-responsive -->
                
            </div>
            <!-- /.panel-body -->
        </div>
        <!-- /.panel -->
    </div>
    <!-- /.col-lg-12 -->
</div>
<!-- /.row -->