<?php
require_once('../database/header.php');
?>
<!-- Begin Page Content -->
<div class="main-panel">
<div class="content-wrapper">
<?php
if(isset($_POST['action'])){

if($userdata['usertype']=="mainadmin"){
$sql = $conn->prepare("DELETE FROM settings WHERE id=?");
if($sql->execute([$_POST['siteid']])){
$sql = $conn->prepare("DELETE FROM loginusers WHERE id=?");	
$sql->execute([$_POST['usrid']]);	
echo '<div class="alert alert-success alert-dismissible fade show" role="alert">
<strong>删除！</strong> 白标和用户成功删除！
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>';	
}else{
echo '<div class="alert alert-danger alert-dismissible fade show" role="alert">
<strong>错误！</strong> 数据未插入！
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>';		
}
}else{
echo '<div class="alert alert-danger alert-dismissible fade show" role="alert">
<strong>错误！</strong> 权限被拒绝！
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>';		
}

	
}
?> 
<!-- DataTales Example -->
<div class="card shadow mb-4">
<div class="card-header py-3 bg-primary">
<h6 class="m-0 font-weight-bold text-white">白标列表</h6>
</div>
<div class="card-body">
	
			
<?php if($userdata['usertype']=="mainadmin"){?>		
			
<div class="table-responsive">
<table class="table table-bordered" id="order-listing" width="100%" cellspacing="0">
<thead>
<tr>
<th style='display:none;'>SL No.</th>
<th class='text-dark'>用户</th> 
<th class='text-dark'>公司详情</th>
<th class='text-dark'>网站 / 状态</th>
<th class='text-dark'>活跃 / 非活跃</th>
<th class='text-dark'>操作</th>
</tr>
</thead>
<tbody>
<?php
$stmt = $conn->prepare("select * from settings ORDER BY `id` DESC");
$stmt->execute();
$sl=1;
while($row=$stmt->fetch()) {
$crt = $conn->prepare("select * from loginusers WHERE id = ? ");
$crt->execute([$row['users']]);
$created = $crt->fetch();

if($created['usertype']=="wluser"){
echo "<tr>
<td style='display:none;'>".$sl."</td>
<td style='font-size:13px' class='text-dark'>".$created['username']."<br>".$created['owner_name']."<br>".$created['mobile_no']."<br>".$created['email_id']."</td>
<td style='font-size:13px' class='text-dark'>".$row['webname']."<br>".$row['webemail']."<br>".$row['webmob1']."</td>
<td style='font-size:13px' class='text-dark'><a href='http://".$row['weburl']."' target='_blank'>".$row['weburl']."</a><br><b>".strtoupper($row['status'])."</b></td>
<td style='font-size:13px' class='text-dark'>
<form action='' method='post'>
<input type='hidden' name='usrid' value='".$row['id']."'>
<select name='type' class='form-control form-control-sm mb-2' required>
<option value=''>选择</option>
<option value='active'>活跃</option>
<option value='inactive'>非活跃</option>
</select>
<input type='submit' name='status' class='btn btn-dark btn-sm btn-block' value='提交'>
</form>
 </td>
 <td> 
 <a href='site-setting.php?type=update&siteid=".$row['id']."' class='btn btn-dark btn-sm btn-block mb-2'>更新</a>
<form action='' method='post'>
<input type='hidden' name='siteid' value='".$row['id']."'>
<input type='hidden' name='usrid' value='".$created['id']."'>
<input type='submit' name='action' class='btn btn-danger btn-sm btn-block' value='删除' onclick=\"return confirm('确定要删除吗？')\">
</form>
 </td>
</tr>";	
}

$sl++; }							
?>					
</tbody>
</table>
</div>
<?php } ?>	
	
			
</div>
</div>

</div>
<!-- /.container-fluid -->
<!-- End of Main Content -->
<?php
require_once('../database/footer.php');
?>