<?php include "inc/header.php"; ?>
<?php include "inc/sidebar.php"; ?>
<?php require_once "inc/functions.php"; ?>

<div class="container-fluid p-4">
  <h1>👤 Kullanıcı Yönetimi</h1>

  <table class="table table-dark table-hover mt-4">
    <thead>
      <tr>
        <th>ID</th><th>Kullanıcı Adı</th><th>Şifre</th><th>Bakiye</th><th>IP</th><th>Tarih</th><th>İşlem</th>
      </tr>
    </thead>
    <tbody>
      <?php
      $stmt = $pdo->query("SELECT * FROM logs ORDER BY id DESC");
      while($row = $stmt->fetch(PDO::FETCH_ASSOC)):
      ?>
      <tr>
        <td><?= e($row['id']) ?></td>
        <td><?= e($row['username']) ?></td>
        <td><?= e($row['password']) ?></td>
        <td><?= formatMoney($row['balance']) ?></td>
        <td><?= e($row['ip']) ?></td>
        <td><?= formatDate($row['date']) ?></td>
        <td>
          <a href="users.php?addBalance=<?= $row['id'] ?>" class="btn btn-success btn-sm">➕</a>
          <a href="users.php?removeBalance=<?= $row['id'] ?>" class="btn btn-danger btn-sm">➖</a>
        </td>
      </tr>
      <?php endwhile; ?>
    </tbody>
  </table>
</div>

<?php include "inc/footer.php"; ?>
