<?php
ob_start();
session_start();

require_once 'includes.php';

require_once("conn.php");

require_once("config.php");

require_once 'dbconfig4.php';

if(isset($_SESSION['admin_user_id'])){

	$user_qury=mysqli_query($conn,"SELECT * FROM ormsusers WHERE user_id='$_SESSION[admin_user_id]'");

	$user_resalt=mysqli_fetch_array($user_qury);

	$customer = $user_resalt['user_id'];
	
	$adminbalance = number_format((float)$user_resalt['balance'],2);

	if($user_resalt['image']==""){

		$image_path="images/empty.jpg";

	}

	else{

		$image_path="../dashboard/images/admin/".$user_resalt['image'];

	}

}


?>
<!DOCTYPE html>
<html lang="en">

<head>
	
	<meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Admin | Mobile Recharge and Billing System | ORMS | Dashbaord</title>
    <?php
	require_once 'headercss.php';
	?>

</head>

<body>

        <!--**********************************
        Main wrapper start
    ***********************************-->
    <div id="main-wrapper">
	
<?php
require_once 'header.php';
?>

        <!--**********************************
            Sidebar start
        ***********************************-->
        <div class="deznav">
            <div class="deznav-scroll">
<?php

require_once 'sidebarmenu.php';

?>
            </div>
        </div>
        <!--**********************************
            Sidebar end
        ***********************************-->
		
        <!--**********************************
            Content body start
        ***********************************-->
        <div class="content-body">
            <!-- row -->
            <div class="container-fluid">
				<div class="row">
				<div class="col-xl-12 col-xxl-12 col-sm-12">
				<div class="alert alert-danger bg-danger text-white" role="alert">
				<strong>Alert!</strong> ඔබගේ ගිනුම තහවුරු කිරීම අසම්පුර්නයි.<a href="identity_verify.php" class="btn btn-success float-right" style="padding: 0px 3px;">සම්පුර්න කරන්න</a>
				</div>
				</div>
				</div>    
                <div class="row page-titles mx-0">
                    <div class="col-sm-6 p-md-0">
                        <div class="welcome-text">
                            <h4>All Admin</h4>
                        </div>
                    </div>
                    <div class="col-sm-6 p-md-0 justify-content-sm-end mt-2 mt-sm-0 d-flex">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item"><a href="home.php">Home</a></li>
                            <li class="breadcrumb-item active"><a href="javascript:void(0);">Admin</a></li>
                            <li class="breadcrumb-item active"><a href="javascript:void(0);">All Admin</a></li>
                        </ol>
                    </div>
                </div>
				
				<div class="row">
					<div class="col-lg-12">
						<div class="row tab-content">
							<div id="list-view" class="tab-pane fade active show col-lg-12">
								<div class="card">
									<div class="card-header">
										<h4 class="card-title">All Admin </h4>
										<a href="add_admin.php" class="btn btn-square btn-secondary">+ Add Admin</a>
									</div>
									<div class="card-body">
										<div class="table-responsive">
											<table id="example3" class="table table-bordered">
												<thead>
													<tr>
														<th>ID</th>
														<th>Profile Photo</th>
														<th>Full Name</th>
														<th>Username</th>
														<th>Email</th>
														<th>Role</th>
														<th>Package</th>
														<th>Balance</th>
														<th>Menu List</th>
														<th>Option</th>
														<th>Action</th>
													</tr>
												</thead>
												<tbody>
												<?php

								$stmt = $DB_con->prepare("SELECT * FROM ormsusers WHERE admintype !='False' ORDER BY user_id");

								$stmt->execute();

								if($stmt->rowCount() > 0)

								{

								while($row=$stmt->fetch(PDO::FETCH_ASSOC))

								{

								extract($row);

								?>
													<tr>
														<td><?php echo $row['user_id']; ?></td>
														<td><?php if($row['image']==""){$pro_img="images/empty.jpg";}else{$pro_img="images/admin/".$row['image'];} ?><img src="<?php echo $pro_img; ?>" class="pro_pick"></td>
														<td><a href="javascript:void(0);"><strong><?php echo $row['fullname']; ?></strong></a></td>
														<td><a href="javascript:void(0);"><strong><?php echo $row['user_name']; ?></strong></a></td>
														<td><a href="javascript:void(0);"><strong><?php echo $row['user_email']; ?></strong></a></td>
														<td><a href="javascript:void(0);"><strong><?php echo $row['admintype']; ?></strong></a></td>
														<td><a href="javascript:void(0);"><strong><?php

								$id = $row['package']; 

								$query = $DB_con->prepare('SELECT name FROM pkgs WHERE pid='.$id);

								$query->execute();

								$result = $query->fetch();

								echo $result['name'];

								?></strong></a></td>
													
														<td><a href="javascript:void(0);"><strong><?php echo $row['balance']; ?></strong></a></td>
														<td><p><strong>Admin - <span class="badge badge-pill badge-secondary"><?php echo $row['admin']; ?></span><strong><p>
														<p>Pay Desk - <span class="badge badge-pill badge-secondary"><?php echo $row['paydesk']; ?></span><strong><p>
														<p>Category - <span class="badge badge-pill badge-secondary"><?php echo $row['category']; ?></span><strong><p>
														<p>Providers - <span class="badge badge-pill badge-secondary"><?php echo $row['providers']; ?></span><strong><p>
														<p>Services - <span class="badge badge-pill badge-secondary"><?php echo $row['services']; ?></span><strong><p>
														<p>Reload - <span class="badge badge-pill badge-secondary"><?php echo $row['reload']; ?></span><strong><p>
														<p>Data Card - <span class="badge badge-pill badge-secondary"><?php echo $row['datacard']; ?></span></strong></p>
														<p>Customers - <span class="badge badge-pill badge-secondary"><?php echo $row['customers']; ?></span><strong><p>
														<p>Reports - <span class="badge badge-pill badge-secondary"><?php echo $row['reports']; ?></span><strong><p>
														</td>
														<td>
														<?php 
						
														if($row['status'] == "0"){

														echo '<a class="badge badge-warning">Deactive</a>';

													    }else if($row['status'] == "1"){

														echo '<a class="badge badge-success">Active</a>';

														}
						
														?>
														</td>
														<td>
															<a href="edit_admin.php?adid=<?php echo $row["user_id"]; ?>" class="btn btn-sm btn-primary"><i class="la la-pencil"></i></a>
															<a href="delete_admin.php?adid=<?php echo $row["user_id"]; ?>" class="btn btn-sm btn-danger"><i class="la la-trash-o"></i></a>
														</td>												
													</tr>
								<?php 
								} 
								}
								?>
												</tbody>
											</table>
										</div>
									</div>
                                </div>
                            </div>
						</div>
					</div>
				</div>
				
            </div>
        </div>
        <!--**********************************
            Content body end
        ***********************************-->


        <?php
		require_once 'footer.php';
		?>

		<!--**********************************
           Support ticket button start
        ***********************************-->

        <!--**********************************
           Support ticket button end
        ***********************************-->


    </div>
    <!--**********************************
        Main wrapper end
    ***********************************-->

    <?php
	require_once 'footerjs.php';
	?>
    
	
</body>
</html>