<?php
// session_start();
include 'head.php';
include 'header.php';
?>
<body class="skin-default fixed-layout">
<div id="main-wrapper">
<?php
include 'sidebar.php';
// Fetch rental applications
$sql = $conn->query("SELECT * FROM rental_applications ORDER BY created_at DESC");
?>
<div class="page-wrapper">
<section>
<div class="">
<?php
include 'nav1.php';
?>
<div class="container-fluid">
<div class="card">
<div class="card-header">
<h4>Manage Rental Applications</h4>
<?php echo isset($_SESSION['mgs'])?$_SESSION['mgs']:""?>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered table-striped">
<thead class="table-dark">
<tr>
<th>#</th>
<th>Full Name</th>
<th>Date of Birth</th>
<th>Phone</th>
<th>Pets</th>
<th>Income Amount</th>
<th>Roommate</th>
<th>Housing Voucher</th>
<th>Application Date</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
if($sql->num_rows > 0){
$num = 1;
while($row = $sql->fetch_assoc()){
?>
<tr>
<td><?php echo $num++; ?></td>
<td><?php echo htmlspecialchars($row['full_name']); ?></td>
<td><?php echo !empty($row['dob']) ? date("j M Y", strtotime($row['dob'])) : "N/A"; ?></td>
<td><?php echo htmlspecialchars($row['phone']); ?></td>
<td>
<?php
echo ($row['pets'] == "yes") ? "Yes - " . htmlspecialchars($row['pet_info']) : "No";
?>
</td>
<td><?php echo htmlspecialchars($row['income_amount']); ?></td>
<td><?php echo ucfirst($row['has_roommate']); ?></td>
<td>
<?php
echo ($row['housing_voucher'] == "yes")
? htmlspecialchars($row['voucher_type']) . " ($" . htmlspecialchars($row['voucher_amount']) . ")"
: "No";
?>
</td>
<td><?php echo date("j M Y", strtotime($row['created_at'])); ?></td>
<td>
<a href="application_details.php?id=<?php echo $row['id']; ?>" class="btn btn-info btn-sm">Details</a>
<a href="delete_application.php?id=<?php echo $row['id']; ?>" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure you want to delete this application?');">Delete</a>
</td>
</tr>
<?php
}
} else {
echo "<tr><td colspan='10' class='text-center'>No applications found.</td></tr>";
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
</div>
<?php include 'footer.php'; ?>
</body>
</html>
Back to Directory