<?php
include 'includes/db.php';
include 'includes/header.php';

$masini = $conn->query("SELECT * FROM cars WHERE status = 'sters' ORDER BY id DESC");
?>

<div class="container mt-4">
  <h2>Coș de Reciclare</h2>
  <table class="table table-bordered table-striped mt-3">
    <thead class="table-dark">
      <tr>
        <th>ID</th>
        <th>Marcă</th>
        <th>Model</th>
        <th>An</th>
        <th>Nr. Înmatriculare</th>
        <th>Acțiuni</th>
      </tr>
    </thead>
    <tbody>
      <?php while($car = $masini->fetch_assoc()): ?>
      <tr>
        <td><?= $car['id'] ?></td>
        <td><?= htmlspecialchars($car['marca']) ?></td>
        <td><?= htmlspecialchars($car['model']) ?></td>
        <td><?= $car['an'] ?></td>
        <td><?= htmlspecialchars($car['nr_inmatriculare']) ?></td>
        <td>
          <a href="restore_car.php?id=<?= $car['id'] ?>" class="btn btn-sm btn-success">Restaurează</a>
          <a href="delete_forever.php?id=<?= $car['id'] ?>" class="btn btn-sm btn-danger" onclick="return confirm('Ștergi definitiv această mașină?')">Ștergere definitivă</a>
        </td>
      </tr>
      <?php endwhile; ?>
    </tbody>
  </table>
</div>
</body>
</html>
