46 lines
1.6 KiB
PHP
46 lines
1.6 KiB
PHP
<?php
|
|
require_once 'session.php';
|
|
check_admin();
|
|
require_once 'db/config.php';
|
|
|
|
$db = db();
|
|
$properties = $db->query("SELECT * FROM properties ORDER BY name ASC")->fetchAll();
|
|
|
|
include 'templates/header.php';
|
|
?>
|
|
|
|
<div class="container mt-4">
|
|
<h2>Manage Properties</h2>
|
|
|
|
<a href="add_property.php" class="btn btn-primary mb-3">Add New Property</a>
|
|
|
|
<table class="table table-bordered">
|
|
<thead>
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>Address</th>
|
|
<th>Rent Amount</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($properties as $property): ?>
|
|
<tr>
|
|
<td><?php echo htmlspecialchars($property['name']); ?></td>
|
|
<td><?php echo htmlspecialchars($property['address']); ?></td>
|
|
<td>$<?php echo htmlspecialchars($property['rent_amount']); ?></td>
|
|
<td>
|
|
<a href="edit_property.php?id=<?php echo $property['id']; ?>" class="btn btn-sm btn-secondary">Edit</a>
|
|
<form action="delete_property.php" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to delete this property?');">
|
|
<input type="hidden" name="id" value="<?php echo $property['id']; ?>">
|
|
<button type="submit" class="btn btn-sm btn-danger">Delete</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<?php include 'templates/footer.php'; ?>
|