123 lines
5.4 KiB
PHP
123 lines
5.4 KiB
PHP
<?php
|
|
require_once 'db/config.php';
|
|
|
|
// Ensure user is logged in
|
|
if (!isset($_SESSION['farmer_id'])) {
|
|
header("Location: login.php");
|
|
exit();
|
|
}
|
|
|
|
$farmer_id = $_SESSION['farmer_id'];
|
|
$pdo = db();
|
|
|
|
// Fetch farmer's details
|
|
$stmt = $pdo->prepare("SELECT * FROM farmers WHERE id = ?");
|
|
$stmt->execute([$farmer_id]);
|
|
$farmer = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
// Fetch applied schemes
|
|
$stmt = $pdo->prepare("
|
|
SELECT s.id, s.name, s.description, a.application_date, a.status
|
|
FROM applications a
|
|
JOIN schemes s ON a.scheme_id = s.id
|
|
WHERE a.farmer_id = ?
|
|
ORDER BY a.application_date DESC
|
|
");
|
|
$stmt->execute([$farmer_id]);
|
|
$applied_schemes = $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>Dashboard - Smart Farmer</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
|
<link rel="stylesheet" href="assets/css/custom.css">
|
|
</head>
|
|
<body>
|
|
|
|
<?php include 'partials/navbar.php'; ?>
|
|
|
|
<header class="bg-success text-white text-center py-5">
|
|
<div class="container">
|
|
<h1 class="display-5">Welcome, <?php echo htmlspecialchars($farmer['full_name']); ?>!</h1>
|
|
<p class="lead">This is your personal dashboard. Manage your applications and profile here.</p>
|
|
</div>
|
|
</header>
|
|
|
|
<main class="container my-5">
|
|
<div class="row">
|
|
<!-- Farmer Profile Section -->
|
|
<div class="col-md-4">
|
|
<div class="card shadow-sm mb-4">
|
|
<div class="card-header bg-light d-flex justify-content-between align-items-center">
|
|
<h4><i class="bi bi-person-circle me-2"></i>My Profile</h4>
|
|
<a href="edit_profile.php" class="btn btn-sm btn-outline-primary">
|
|
<i class="bi bi-pencil-square me-1"></i>Edit
|
|
</a>
|
|
</div>
|
|
<div class="card-body">
|
|
<p><strong>Name:</strong> <?php echo htmlspecialchars($farmer['full_name']); ?></p>
|
|
<p><strong>Email:</strong> <?php echo htmlspecialchars($farmer['email']); ?></p>
|
|
<p><strong>Phone:</strong> <?php echo htmlspecialchars($farmer['phone'] ?? 'N/A'); ?></p>
|
|
<p><strong>District:</strong> <?php echo htmlspecialchars($farmer['district'] ?? 'N/A'); ?></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Applied Schemes Section -->
|
|
<div class="col-md-8">
|
|
<div class="card shadow-sm">
|
|
<div class="card-header bg-light">
|
|
<h4><i class="bi bi-journal-check me-2"></i>My Applications</h4>
|
|
</div>
|
|
<div class="card-body">
|
|
<?php if (empty($applied_schemes)): ?>
|
|
<div class="alert alert-info">
|
|
You have not applied for any schemes yet.
|
|
<a href="index.php#schemes" class="alert-link">Explore schemes</a> and apply now.
|
|
</div>
|
|
<?php else: ?>
|
|
<div class="list-group">
|
|
<?php foreach ($applied_schemes as $scheme): ?>
|
|
<a href="scheme.php?id=<?php echo $scheme['id']; ?>" class="list-group-item list-group-item-action">
|
|
<div class="d-flex w-100 justify-content-between">
|
|
<h5 class="mb-1"><?php echo htmlspecialchars($scheme['name']); ?></h5>
|
|
<small class="text-muted">Applied on: <?php echo date('d M Y', strtotime($scheme['application_date'])); ?></small>
|
|
</div>
|
|
<p class="mb-1"><?php echo htmlspecialchars(substr($scheme['description'], 0, 100)); ?>...</p>
|
|
<div class="mt-2">
|
|
<strong>Status:</strong>
|
|
<span class="badge
|
|
<?php
|
|
switch ($scheme['status']) {
|
|
case 'Approved': echo 'bg-success'; break;
|
|
case 'Rejected': echo 'bg-danger'; break;
|
|
default: echo 'bg-warning text-dark'; break;
|
|
}
|
|
?>">
|
|
<?php echo htmlspecialchars($scheme['status']); ?>
|
|
</span>
|
|
</div>
|
|
</a>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<footer class="footer mt-auto py-3 bg-light">
|
|
<div class="container text-center">
|
|
<span class="text-muted">© <?php echo date("Y"); ?> Smart Farmer Support System. All Rights Reserved.</span>
|
|
</div>
|
|
</footer>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
</body>
|
|
</html>
|