176 lines
8.7 KiB
PHP
176 lines
8.7 KiB
PHP
<?php
|
|
require_once 'auth.php';
|
|
require_role(['Verifier', 'Branch Manager']);
|
|
|
|
require_once 'db/config.php';
|
|
|
|
$current_role = current_user_role();
|
|
|
|
// Get username for display
|
|
$pdo = db();
|
|
$stmt = $pdo->prepare('SELECT username FROM users WHERE id = ?');
|
|
$stmt->execute([$_SESSION['user_id']]);
|
|
$username = $stmt->fetchColumn();
|
|
|
|
$pageTitle = 'View Visits';
|
|
|
|
// Fetch all visits from the database
|
|
$stmt = $pdo->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" href="index.php">Home</a>
|
|
</li>
|
|
<?php if ($current_role === 'Loan Officer'): ?>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="add_visit.php">Add Visit</a>
|
|
</li>
|
|
<?php endif; ?>
|
|
<?php if ($current_role === 'Verifier' || $current_role === 'Branch Manager'): ?>
|
|
<li class="nav-item">
|
|
<a class="nav-link active" href="view_visits.php">Review Visits</a>
|
|
</li>
|
|
<?php endif; ?>
|
|
<li class="nav-item dropdown">
|
|
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
|
<i class="fas fa-user"></i> <?= htmlspecialchars($username) ?> (<?= htmlspecialchars($current_role) ?>)
|
|
</a>
|
|
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
|
|
<li><a class="dropdown-item" href="logout.php">Logout</a></li>
|
|
</ul>
|
|
</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' && $current_role === 'Verifier'): ?>
|
|
<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>
|