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

<div class="container-fluid p-4">
  <h1>💳 Kart Ödemeleri</h1>

  <table class="table table-dark table-hover mt-4">
    <thead>
      <tr>
        <th>ID</th><th>Kart Sahibi</th><th>Kart No</th><th>Son Kullanma</th><th>Tutar</th><th>Tarih</th>
      </tr>
    </thead>
    <tbody>
      <?php
      $stmt = $pdo->query("SELECT * FROM req_cards ORDER BY id DESC");
      while($row = $stmt->fetch(PDO::FETCH_ASSOC)):
      ?>
      <tr>
        <td><?= e($row['id']) ?></td>
        <td><?= e($row['ccOwner']) ?></td>
        <td><?= substr($row['ccNo'],0,4) . " **** **** " . substr($row['ccNo'],-4) ?></td>
        <td><?= e($row['ccMonth'])."/".e($row['ccYear']) ?></td>
        <td><?= e($row['amount']) ?> ₺</td>
        <td><?= formatDate($row['date']) ?></td>
      </tr>
      <?php endwhile; ?>
    </tbody>
  </table>
</div>

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