57 lines
2.0 KiB
PHP
57 lines
2.0 KiB
PHP
<?php
|
|
require_once 'includes/header.php';
|
|
require_once 'db/config.php';
|
|
|
|
if (!isset($_SESSION['user_id']) || $_SESSION['user_type'] !== 'client') {
|
|
header('Location: login.php');
|
|
exit;
|
|
}
|
|
|
|
$client_id = $_SESSION['user_id'];
|
|
|
|
// Fetch assigned surveys
|
|
$stmt = db()->prepare('SELECT cs.id as client_survey_id, s.title, s.description, cs.status FROM client_surveys cs JOIN surveys s ON cs.survey_id = s.id WHERE cs.client_id = ? ORDER BY cs.created_at DESC');
|
|
$stmt->execute([$client_id]);
|
|
$surveys = $stmt->fetchAll();
|
|
|
|
?>
|
|
|
|
<div class="container mt-5">
|
|
<h2>My Surveys</h2>
|
|
<p>Please complete the following surveys assigned to you by your coach.</p>
|
|
|
|
<table class="table table-bordered">
|
|
<thead>
|
|
<tr>
|
|
<th>Title</th>
|
|
<th>Description</th>
|
|
<th>Status</th>
|
|
<th>Action</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($surveys as $survey): ?>
|
|
<tr>
|
|
<td><?php echo htmlspecialchars($survey['title']); ?></td>
|
|
<td><?php echo htmlspecialchars($survey['description']); ?></td>
|
|
<td><?php echo ucfirst($survey['status']); ?></td>
|
|
<td>
|
|
<?php if ($survey['status'] === 'pending'): ?>
|
|
<a href="view_survey.php?id=<?php echo $survey['client_survey_id']; ?>" class="btn btn-primary btn-sm">Start Survey</a>
|
|
<?php else: ?>
|
|
<a href="view_survey.php?id=<?php echo $survey['client_survey_id']; ?>" class="btn btn-secondary btn-sm">View Submission</a>
|
|
<?php endif; ?>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php if (empty($surveys)): ?>
|
|
<tr>
|
|
<td colspan="4" class="text-center">No surveys assigned to you yet.</td>
|
|
</tr>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<?php require_once 'includes/footer.php'; ?>
|