<?php
require('top.inc.php');
isAdmin();
if(isset($_GET['type']) && $_GET['type']!=''){
	$type=get_safe_value($con,$_GET['type']);
	if($type=='status'){
		$operation=get_safe_value($con,$_GET['operation']);
		$id=get_safe_value($con,$_GET['id_member']);
		if($operation=='active'){
			$status='1';
		}else{
			$status='0';
		}
		$update_status_sql="update tbl_member set status='$status' where id_member='$id'";
		mysqli_query($con,$update_status_sql);
	}
	
	if($type=='delete'){
		$id=get_safe_value($con,$_GET['id']);
		$delete_sql="delete from tbl_member where id_member='$id'";
		mysqli_query($con,$delete_sql);
	}
}

$sql="select * from tbl_member order by id_member desc";
$res=mysqli_query($con,$sql);
?>
<div class="content pb-0">
	<div class="orders">
	   <div class="row">
		  <div class="col-xl-12">
			 <div class="card">
				<div class="card-body">
				   <h4 class="box-title">TAMBAH SALDO MEMBER</h4>
				</div>
				<div class="card-body">
				   <div class="form-group">
					<label for="categories" class=" form-control-label">CARI MEMBER :</label>
					<input type="text" id="myInput" class="form-control" style="max-width:250px;" onkeyup="myFunction()" placeholder="Search...">
				   </div>
				</div>
				<div class="card-body--">
				   <div class="table-stats order-table ov-h">
					  <table class="table " id="myTable">
						 <thead>
							<tr>
							   <th width="10%">USERNAME</th>
							   <th width="10%">SALDO</th>
							   <th width="10%"></th>
							</tr>
						 </thead>
						 <tbody>
							<?php 
							$i=1;
							while($row=mysqli_fetch_assoc($res)){?>
							<tr>
							   <td><?php echo $row['username']?></td>
							   <td><?php echo $row['saldo']?></td>
							  
							   <td>
								<?php
								echo "<span class='badge badge-edit'><a href='saldoaksi.php?id_member=".$row['id_member']."'>INJECT</a></span>&nbsp;";
								?>
							   </td>
							</tr>
							<?php } ?>
						 </tbody>
					  </table>
				   </div>
				</div>
			 </div>
		  </div>
	   </div>
	</div>
</div>
<script>
function myFunction() {
  // Declare variables
  var input, filter, table, tr, td, i, txtValue;
  input = document.getElementById("myInput");
  filter = input.value.toUpperCase();
  table = document.getElementById("myTable");
  tr = table.getElementsByTagName("tr");

  // Loop through all table rows, and hide those who don't match the search query
  for (i = 0; i < tr.length; i++) {
    td = tr[i].getElementsByTagName("td")[0];
    if (td) {
      txtValue = td.textContent || td.innerText;
      if (txtValue.toUpperCase().indexOf(filter) > -1) {
        tr[i].style.display = "";
      } else {
        tr[i].style.display = "none";
      }
    }
  }
}
</script>
<?php
require('footer.inc.php');
?>