<?php
session_start();

include_once '../config.php';

require_once '../database1.php';
require_once "../check_admin.php";

class userObj extends database
{
    public function getAllUsers()
    { 
		$sql = ' SELECT u.*, g.name AS group_name FROM ichat_users u INNER JOIN ichat_groups g ON u.prvlg_group=g.id ';
		return $this->callQuery($sql);
	}

	
}

$msg='';
if(isset($_GET['message']))
{
	$msg=$_GET['message'];
}

$obj = new userObj();
$users = $obj->getAllUsers();
include '../header.php';
?>
            <!-- MAIN CONTENT-->
            <div class="main-content">
                <div class="section__content section__content--p30">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="overview-wrap">
                                    <h2 class="title-1">All Users</h2>
                                      <a class="btn btn-success pull-right" href="add">Add User</a>
                                </div>
								
                            </div>
                        </div>
                        
                        <div class="row m-t-25 m-row col-sm-12">
							<div class="col-lg-12">
                                                         
                                <div class="table--no-card m-b-30 top-margin pull-left col-sm-12">
                                   
                                    <div class="table-responsive" style="width:100%">
                                    <table class="table table-striped table-hover dt-responsive ACP_table" style="width:100%">
                                        <thead>
                                            <tr>
                                            	<th>
                                            		Role
                                            	</th>
												<th>Username</th>	
                                               	<th>Email</th>
												<th>Mobile</th>
												<th>Address</th>
												<th>Name</th>
												
												
												<th data-priority="1">Actions</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                           <?php
                                           $count = 0;
											foreach($users AS $user)
											{
												
											?>
												<tr class="action-container">
													<td data-order="<?php echo $count++ ?>"><?php echo htmlspecialchars($user['group_name']);?></td>
												
													<td><?php echo htmlspecialchars($user['username']);?></td>
													<td><?php echo htmlspecialchars($user['email']);?></td>
													<td><?php echo htmlspecialchars($user['mobile']);?></td>
													<td><?php echo htmlspecialchars($user['address']) ?></td>
													<td><?php echo htmlspecialchars($user['name']) ?></td>
													
													<td> <a id="edit" href="edit?id=<?php  echo htmlspecialchars($user['id']); ?>" class="btn btn-success"><i class="fa fa-edit"></i></a></td>
												</tr>
											<?php
											}
											?>
                                           
                                        </tbody>
                                    </table>
									</div>
                                </div>
                            </div>
                            
                          
                        </div>
                        
                       <script>
						$(document).ready(function(){
							$('.active').removeClass('active');
							$('#store_menu_ul').show();
							$('#user-menu').addClass('active');
						}); 

					</script>               

  <?php
  include '../footer.php';
  ?>