<?php include 'includes/header.php'; ?>
<?php include 'includes/sidebar.php'; ?>
<?php require 'includes/db_connect.php'; ?>

<?php
$id = $_GET['id'];
$sql = "SELECT houses.*, streets.street_name 
        FROM houses 
        JOIN streets ON houses.street_id = streets.id
        WHERE houses.id=$id";

$result = $conn->query($sql);
$house = $result->fetch_assoc();

if (!$house) {
    echo "<div class='alert alert-danger'>House not found.</div>";
    exit;
}
?>

<h3 class="text-orange fw-bold">House Details</h3>

<div class="card shadow mt-4">
    <div class="card-body">

        <h4 class="text-orange"><?= $house['house_number'] ?> - <?= $house['street_name'] ?></h4>

        <p><strong>Occupant:</strong> <?= $house['occupant_name'] ?></p>

        <p><strong>Status:</strong>  
            <span class="badge bg-<?= $house['status']=='verified'?'success':'warning' ?>">
                <?= $house['status'] ?>
            </span>
        </p>

        <p><strong>Coordinates:</strong> <?= $house['latitude'] ?> , <?= $house['longitude'] ?></p>

        <p><strong>Description:</strong><br><?= nl2br($house['description']) ?></p>

        <p><strong>Date Added:</strong> <?= $house['created_at'] ?></p>

        <a href="edit_house.php?id=<?= $house['id'] ?>" class="btn btn-warning text-white">Edit</a>
        <a href="house_numbering.php" class="btn btn-secondary">Back</a>

    </div>
</div>

<?php include 'includes/footer.php'; ?>
