340 lines
16 KiB
PHP
340 lines
16 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Candidate Details</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.4.0/css/all.min.css" rel="stylesheet">
|
|
<style>
|
|
:root {
|
|
--primary-color: #2a3f54;
|
|
--secondary-color: #73879C;
|
|
--background-color: #F7F7F7;
|
|
--surface-color: #FFFFFF;
|
|
--accent-color: #1ABB9C;
|
|
}
|
|
body {
|
|
display: flex;
|
|
background-color: var(--background-color);
|
|
font-family: "Helvetica Neue", Roboto, Arial, sans-serif;
|
|
}
|
|
.sidebar {
|
|
width: 250px;
|
|
height: 100vh;
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
background-color: var(--primary-color);
|
|
color: #ECF0F1;
|
|
padding-top: 20px;
|
|
}
|
|
.sidebar h3 {
|
|
text-align: center;
|
|
margin-bottom: 30px;
|
|
font-weight: bold;
|
|
}
|
|
.sidebar .nav-link {
|
|
color: #ECF0F1;
|
|
padding: 10px 20px;
|
|
transition: background-color 0.3s;
|
|
}
|
|
.sidebar .nav-link:hover, .sidebar .nav-link.active {
|
|
background-color: var(--accent-color);
|
|
color: var(--surface-color);
|
|
}
|
|
.sidebar .nav-link .fa {
|
|
margin-right: 10px;
|
|
}
|
|
.main-content {
|
|
margin-left: 250px;
|
|
padding: 20px;
|
|
width: calc(100% - 250px);
|
|
}
|
|
.header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 20px;
|
|
}
|
|
.header h1 {
|
|
font-weight: bold;
|
|
color: var(--primary-color);
|
|
}
|
|
.card {
|
|
border: none;
|
|
border-radius: 8px;
|
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
margin-bottom: 20px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div class="sidebar">
|
|
<h3><i class="fa fa-flask"></i> LWM</h3>
|
|
<ul class="nav flex-column">
|
|
<li class="nav-item">
|
|
<hr>
|
|
<a href="index.php" class="nav-link"><i class="fas fa-tachometer-alt"></i> Dashboard</a>
|
|
<a href="users.php" class="nav-link"><i class="fas fa-users"></i> User Management</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="main-content">
|
|
<?php
|
|
require_once 'db/config.php';
|
|
$candidate = null;
|
|
$assessments = [];
|
|
if (isset($_GET['id'])) {
|
|
try {
|
|
$pdo = db();
|
|
// Fetch candidate details
|
|
$stmt = $pdo->prepare("SELECT * FROM Candidate WHERE candidate_id = ?");
|
|
$stmt->execute([$_GET['id']]);
|
|
$candidate = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
// Fetch candidate assessments
|
|
$stmt_assessments = $pdo->prepare("SELECT assessment_id, candidate_id, assessed_by, assess_date, assessment, status FROM Candidate_Assessment WHERE candidate_id = ? ORDER BY assess_date DESC");
|
|
$stmt_assessments->execute([$_GET['id']]);
|
|
$assessments = $stmt_assessments->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
// Fetch candidate synthesis plans
|
|
$stmt_plans = $pdo->prepare("SELECT * FROM Candidate_Synthesis_Plan WHERE candidate_id = ? ORDER BY plan_id DESC");
|
|
$stmt_plans->execute([$_GET['id']]);
|
|
$plans = $stmt_plans->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
} catch (PDOException $e) {
|
|
echo '<div class="alert alert-danger">Database error: ' . $e->getMessage() . '</div>';
|
|
}
|
|
}
|
|
|
|
if ($candidate):
|
|
?>
|
|
<div class="header">
|
|
<h1>Candidate: <?php echo htmlspecialchars($candidate['candidate_id']); ?></h1>
|
|
<a href="project.php?id=<?php echo htmlspecialchars($candidate['project_id']); ?>" class="btn btn-secondary">Back to Project</a>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<h5 class="card-title">Candidate Details</h5>
|
|
<p><strong>Candidate ID:</strong> <?php echo htmlspecialchars($candidate['candidate_id']); ?></p>
|
|
<p><strong>Run ID:</strong> <?php echo htmlspecialchars($candidate['run_id']); ?></p>
|
|
<p><strong>Project ID:</strong> <?php echo htmlspecialchars($candidate['project_id']); ?></p>
|
|
<p><strong>SMILES ID:</strong> <?php echo htmlspecialchars($candidate['smiles_id']); ?></p>
|
|
<p><strong>Estimated Cost:</strong> <?php echo htmlspecialchars($candidate['estimated_cost']); ?></p>
|
|
<p><strong>Generated Time:</strong> <?php echo htmlspecialchars($candidate['generated_time']); ?></p>
|
|
<p><strong>Synthesis Approved:</strong> <?php echo htmlspecialchars($candidate['synthesis_approved']); ?></p>
|
|
<p><strong>Status:</strong> <?php echo htmlspecialchars($candidate['status']); ?></p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="d-flex justify-content-between align-items-center">
|
|
<h5 class="card-title mb-0">Candidate Assessments</h5>
|
|
<a href="create_assessment.php?candidate_id=<?php echo htmlspecialchars($candidate['candidate_id']); ?>" class="btn btn-primary">Create Assessment</a>
|
|
</div>
|
|
<hr>
|
|
<?php if (count($assessments) > 0): ?>
|
|
<div class="table-responsive">
|
|
<table class="table table-hover">
|
|
<thead>
|
|
<tr>
|
|
<th>Assessment ID</th>
|
|
<th>Comments</th>
|
|
<th>Assessor Name</th>
|
|
<th>Date</th>
|
|
<th>Status</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($assessments as $assessment): ?>
|
|
<tr>
|
|
<td><?php echo htmlspecialchars($assessment['assessment_id']); ?></td>
|
|
<td><?php echo htmlspecialchars($assessment['assessment']); ?></td>
|
|
<td><?php echo htmlspecialchars($assessment['assessed_by']); ?></td>
|
|
<td><?php echo htmlspecialchars($assessment['assess_date']); ?></td>
|
|
<td><?php echo htmlspecialchars($assessment['status']); ?></td>
|
|
<td>
|
|
<a href="edit_assessment.php?id=<?php echo $assessment['assessment_id']; ?>" class="btn btn-sm btn-outline-primary">Edit</a>
|
|
</td>
|
|
</tr> <?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<?php else: ?>
|
|
<p>No assessments found for this candidate.</p>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<h5 class="card-title">Candidate Synthesis Plans</h5>
|
|
<hr>
|
|
<?php if (count($plans) > 0): ?>
|
|
<div class="table-responsive">
|
|
<table class="table table-hover">
|
|
<thead>
|
|
<tr>
|
|
<th>Plan ID</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($plans as $plan): ?>
|
|
<tr>
|
|
<td><?php echo htmlspecialchars($plan['plan_id']); ?></td>
|
|
<td>
|
|
<a href="synthesis_plan.php?plan_id=<?php echo $plan['plan_id']; ?>" class="btn btn-sm btn-outline-primary">View</a>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<?php else: ?>
|
|
<p>No synthesis plans found for this candidate.</p>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<h5 class="card-title">Sample Wells</h5>
|
|
<hr>
|
|
<?php
|
|
// Fetch Sample Well data related to the candidate
|
|
$stmt_sample_wells = $pdo->prepare("
|
|
SELECT
|
|
sw.sample_id,
|
|
sw.name,
|
|
wp.Temperature,
|
|
wp.incubation_start,
|
|
wp.incubation_end,
|
|
sol.name as solution_name,
|
|
wsn.amount as solution_amount,
|
|
wsn.units as solution_units,
|
|
sv.name as solvent_name,
|
|
wsv.amount as solvent_amount,
|
|
wsv.units as solvent_units,
|
|
cat.name as catalyst_name,
|
|
wcat.amount as catalyst_amount,
|
|
wcat.units as catalyst_units,
|
|
sld.name as solid_name,
|
|
wsd.amount as solid_amount,
|
|
wsd.units as solid_units,
|
|
pxrd.character_id as pxrd_characterization_id
|
|
FROM
|
|
Candidate c
|
|
JOIN
|
|
Candidate_Synthesis_Plan csp ON c.candidate_id = csp.candidate_id
|
|
JOIN
|
|
Well_Plate wp ON csp.plan_id = wp.plan_id
|
|
JOIN
|
|
Sample_Well sw ON wp.well_plate_id = sw.well_plate_id
|
|
LEFT JOIN
|
|
Well_Solution wsn ON sw.sample_id = wsn.sample_id
|
|
LEFT JOIN
|
|
Preprep_vial sol ON wsn.vial_id = sol.vial_id
|
|
LEFT JOIN
|
|
Well_Solvents wsv ON sw.sample_id = wsv.sample_id
|
|
LEFT JOIN
|
|
Solvent sv ON wsv.solvent_id = sv.solvent_id
|
|
LEFT JOIN
|
|
Well_Catalysts wcat ON sw.sample_id = wcat.sample_id
|
|
LEFT JOIN
|
|
Catalyst cat ON wcat.catalyst_id = cat.catalyst_id
|
|
LEFT JOIN
|
|
Well_Solids wsd ON sw.sample_id = wsd.sample_id
|
|
LEFT JOIN
|
|
Solid sld ON wsd.solid_id = sld.solid_id
|
|
LEFT JOIN
|
|
PXRD_Characterization pxrd ON sw.sample_id = pxrd.sample_id
|
|
WHERE
|
|
c.candidate_id = ?
|
|
");
|
|
$stmt_sample_wells->execute([$_GET['id']]);
|
|
$sample_wells_result = $stmt_sample_wells->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
$sample_wells = [];
|
|
foreach ($sample_wells_result as $row) {
|
|
$sample_wells[$row['sample_id']][] = $row;
|
|
}
|
|
|
|
if ($sample_wells && count($sample_wells) > 0):
|
|
?>
|
|
<div class="table-responsive">
|
|
<table class="table table-hover">
|
|
<thead>
|
|
<tr>
|
|
<th>Sample ID</th>
|
|
<th>Name</th>
|
|
<th>Composition</th>
|
|
<th>Incubation</th>
|
|
<th>PXRD Characterization</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($sample_wells as $sample_id => $rows):
|
|
$first_row = $rows[0];
|
|
$incubation_start = new DateTime($first_row['incubation_start']);
|
|
$incubation_end = new DateTime($first_row['incubation_end']);
|
|
$incubation_duration = $incubation_start->diff($incubation_end);
|
|
?>
|
|
<tr>
|
|
<td><?php echo htmlspecialchars($sample_id); ?></td>
|
|
<td><?php echo htmlspecialchars($first_row['name']); ?></td>
|
|
<td>
|
|
<ul>
|
|
<?php foreach ($rows as $row): ?>
|
|
<?php if ($row['solution_name']): ?>
|
|
<li><strong>Solution:</strong> <?php echo htmlspecialchars($row['solution_name'] . ' (' . $row['solution_amount'] . ' ' . $row['solution_units'] . ')'); ?></li>
|
|
<?php endif; ?>
|
|
<?php if ($row['solvent_name']): ?>
|
|
<li><strong>Solvent:</strong> <?php echo htmlspecialchars($row['solvent_name'] . ' (' . $row['solvent_amount'] . ' ' . $row['solvent_units'] . ')'); ?></li>
|
|
<?php endif; ?>
|
|
<?php if ($row['catalyst_name']): ?>
|
|
<li><strong>Catalyst:</strong> <?php echo htmlspecialchars($row['catalyst_name'] . ' (' . $row['catalyst_amount'] . ' ' . $row['catalyst_units'] . ')'); ?></li>
|
|
<?php endif; ?>
|
|
<?php if ($row['solid_name']): ?>
|
|
<li><strong>Solid:</strong> <?php echo htmlspecialchars($row['solid_name'] . ' (' . $row['solid_amount'] . ' ' . $row['solid_units'] . ')'); ?></li>
|
|
<?php endif; ?>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
</td>
|
|
<td>
|
|
<?php echo htmlspecialchars($first_row['Temperature']); ?>°C for
|
|
<?php echo $incubation_duration->format('%h hours, %i minutes'); ?>
|
|
</td>
|
|
<td>
|
|
<?php if ($first_row['pxrd_characterization_id']): ?>
|
|
<a href="pxrd_characterization.php?id=<?php echo $first_row['pxrd_characterization_id']; ?>" class="btn btn-sm btn-outline-primary">View</a>
|
|
<?php else: ?>
|
|
N/A
|
|
<?php endif; ?>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<?php else: ?>
|
|
<p>No sample wells found for this candidate.</p>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<?php else: ?>
|
|
<div class="alert alert-warning">Candidate not found or ID not provided.</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
</body>
|
|
</html>
|