155 lines
7.8 KiB
PHP
155 lines
7.8 KiB
PHP
<?php
|
|
require_once 'db/config.php';
|
|
|
|
$pageTitle = 'View Visits';
|
|
$page = 'view_visits.php';
|
|
|
|
// Fetch all visits from the database
|
|
$pdoconn = db();
|
|
$stmt = $pdoconn->query('SELECT id, client_name, latitude, longitude, visit_time, status FROM visits ORDER BY visit_time DESC');
|
|
$visits = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title><?php echo htmlspecialchars($pageTitle); ?> - Geo-verification App</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" rel="stylesheet">
|
|
<style>
|
|
body {
|
|
background-color: #f8f9fa;
|
|
}
|
|
.navbar {
|
|
box-shadow: 0 2px 4px rgba(0,0,0,.1);
|
|
}
|
|
.card {
|
|
border: none;
|
|
box-shadow: 0 4px 8px rgba(0,0,0,.1);
|
|
}
|
|
.card-header {
|
|
background-color: #0d6efd;
|
|
color: white;
|
|
font-weight: bold;
|
|
}
|
|
.badge-status {
|
|
font-size: 0.9em;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<nav class="navbar navbar-expand-lg navbar-light bg-white mb-4">
|
|
<div class="container-fluid">
|
|
<a class="navbar-brand" href="index.php">
|
|
<i class="fas fa-map-marked-alt text-primary"></i>
|
|
Geo-verification
|
|
</a>
|
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
<div class="collapse navbar-collapse" id="navbarNav">
|
|
<ul class="navbar-nav ms-auto">
|
|
<li class="nav-item">
|
|
<a class="nav-link <?php if ($page === 'index.php') echo 'active'; ?>" href="index.php">Home</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link <?php if ($page === 'add_visit.php') echo 'active'; ?>" href="add_visit.php">Add Visit</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link <?php if ($page === 'view_visits.php') echo 'active'; ?>" href="view_visits.php">Review Visits</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<main class="container mt-5">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<i class="fas fa-list-check"></i>
|
|
Review Client Visits
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<table class="table table-striped table-hover align-middle">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>ID</th>
|
|
<th>Client Name</th>
|
|
<th>Coordinates</th>
|
|
<th>Visit Time</th>
|
|
<th>Status</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (empty($visits)): ?>
|
|
<tr>
|
|
<td colspan="6" class="text-center">No visits recorded yet.</td>
|
|
</tr>
|
|
<?php else: ?>
|
|
<?php foreach ($visits as $visit): ?>
|
|
<tr>
|
|
<td><?php echo htmlspecialchars($visit['id']); ?></td>
|
|
<td><?php echo htmlspecialchars($visit['client_name']); ?></td>
|
|
<td>
|
|
<a href="https://www.google.com/maps?q=<?php echo htmlspecialchars($visit['latitude']); ?>,<?php echo htmlspecialchars($visit['longitude']); ?>" target="_blank">
|
|
<?php echo htmlspecialchars(round($visit['latitude'], 5)) . ', ' . htmlspecialchars(round($visit['longitude'], 5)); ?>
|
|
</a>
|
|
</td>
|
|
<td><?php echo htmlspecialchars($visit['visit_time']); ?></td>
|
|
<td>
|
|
<?php
|
|
$status = htmlspecialchars($visit['status']);
|
|
$badge_class = 'bg-secondary';
|
|
if ($status === 'verified') {
|
|
$badge_class = 'bg-success';
|
|
} elseif ($status === 'rejected') {
|
|
$badge_class = 'bg-danger';
|
|
}
|
|
echo "<span class=\"badge {$badge_class} badge-status p-2\">" . ucfirst($status) . "</span>";
|
|
?>
|
|
</td>
|
|
<td>
|
|
<?php if ($visit['status'] === 'pending'): ?>
|
|
<div class="btn-group" role="group">
|
|
<form action="update_visit_status.php" method="POST" class="d-inline">
|
|
<input type="hidden" name="visit_id" value="<?php echo $visit['id']; ?>">
|
|
<input type="hidden" name="status" value="verified">
|
|
<button type="submit" class="btn btn-sm btn-success">
|
|
<i class="fas fa-check"></i> Verify
|
|
</button>
|
|
</form>
|
|
<form action="update_visit_status.php" method="POST" class="d-inline">
|
|
<input type="hidden" name="visit_id" value="<?php echo $visit['id']; ?>">
|
|
<input type="hidden" name="status" value="rejected">
|
|
<button type="submit" class="btn btn-sm btn-danger">
|
|
<i class="fas fa-times"></i> Reject
|
|
</button>
|
|
</form>
|
|
</div>
|
|
<?php else: ?>
|
|
<span>-</span>
|
|
<?php endif; ?>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<footer class="text-center text-muted py-4 mt-5">
|
|
<p>© <?php echo date("Y"); ?> Geo-verification App. All Rights Reserved.</p>
|
|
</footer>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
</body>
|
|
</html>
|