70 lines
2.8 KiB
PHP
70 lines
2.8 KiB
PHP
<?php
|
|
require_once 'includes/admin_header.php';
|
|
require_once 'db/config.php';
|
|
|
|
// Fetch tour packages from the database
|
|
try {
|
|
$pdo = db();
|
|
$stmt = $pdo->query('SELECT * FROM tour_packages ORDER BY name ASC');
|
|
$tours = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
} catch (PDOException $e) {
|
|
$error_message = "Database error: " . $e->getMessage();
|
|
$tours = [];
|
|
}
|
|
|
|
require_once 'includes/admin_sidebar.php';
|
|
?>
|
|
|
|
<h1 class="h2">Manage Tour Packages</h1>
|
|
<p>Add, edit, or remove tour packages.</p>
|
|
|
|
<div class="card">
|
|
<div class="card-header d-flex justify-content-between align-items-center">
|
|
<h5 class="mb-0">Tour Package List</h5>
|
|
<a href="admin_add_tour.php" class="btn btn-primary"><i class="bi bi-plus-circle me-2"></i>Add Tour Package</a>
|
|
</div>
|
|
<div class="card-body">
|
|
<?php if (isset($error_message)): ?>
|
|
<div class="alert alert-danger">
|
|
<?php echo htmlspecialchars($error_message); ?>
|
|
</div>
|
|
<?php elseif (empty($tours)): ?>
|
|
<div class="alert alert-info">
|
|
No tour packages found. <a href="admin_add_tour.php">Add one now</a>.
|
|
</div>
|
|
<?php else: ?>
|
|
<div class="table-responsive">
|
|
<table class="table table-striped table-hover">
|
|
<thead>
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>Destination</th>
|
|
<th>Duration (days)</th>
|
|
<th>Price</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($tours as $tour): ?>
|
|
<tr>
|
|
<td><?php echo htmlspecialchars($tour['name']); ?></td>
|
|
<td><?php echo htmlspecialchars($tour['destination']); ?></td>
|
|
<td><?php echo htmlspecialchars($tour['duration_days']); ?></td>
|
|
<td>Rp <?php echo number_format($tour['price'], 0, ',', '.'); ?></td>
|
|
<td>
|
|
<a href="admin_edit_tour.php?id=<?php echo $tour['id']; ?>" class="btn btn-sm btn-outline-primary"><i class="bi bi-pencil-square"></i></a>
|
|
<a href="admin_delete_tour.php?id=<?php echo $tour['id']; ?>" class="btn btn-sm btn-outline-danger" onclick="return confirm('Are you sure you want to delete this tour package?');"><i class="bi bi-trash"></i></a>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
require_once 'includes/admin_footer.php';
|
|
?>
|