36852-vm/synthesis_plan.php
Flatlogic Bot 7dcb29de25 basic 1
2025-12-12 23:16:50 +00:00

166 lines
11 KiB
PHP

<?php
require_once 'db/config.php';
// Get plan_id from URL
$plan_id = isset($_GET['plan_id']) ? (int)$_GET['plan_id'] : 0;
// Fetch synthesis plan details
$stmt = db()->prepare("SELECT * FROM Candidate_Synthesis_Plan WHERE plan_id = ?");
$stmt->execute([$plan_id]);
$plan = $stmt->fetch(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>Candidate Synthesis Plan Details</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
<div class="container mt-5">
<h2>Candidate Synthesis Plan Details</h2>
<?php if ($plan): ?>
<table class="table table-bordered">
<tbody>
<tr>
<th>Plan ID</th>
<td><?php echo htmlspecialchars($plan['plan_id']); ?></td>
</tr>
<tr>
<th>Candidate ID</th>
<td><?php echo htmlspecialchars($plan['candidate_id']); ?></td>
</tr>
<tr>
<th>Conditions Document</th>
<td><a href="<?php echo htmlspecialchars($plan['conditions_doc_link']); ?>" target="_blank">View Document</a></td>
</tr>
</tbody>
</table>
<?php else: ?>
<div class="alert alert-warning">Synthesis plan not found.</div>
<?php endif; ?>
<a href="candidate.php?id=<?php echo htmlspecialchars($plan['candidate_id']); ?>" class="btn btn-primary">Back to Candidate</a>
<div class="card mt-4">
<div class="card-header">
<h5>Well Plates</h5>
</div>
<div class="card-body">
<?php
$stmt_well_plate = db()->prepare("SELECT wp.*, l.name as laboratory_name FROM Well_Plate wp JOIN Laboratory l ON wp.lab_id = l.lab_id WHERE wp.plan_id = ?");
$stmt_well_plate->execute([$plan_id]);
$well_plates = $stmt_well_plate->fetchAll(PDO::FETCH_ASSOC);
?>
<?php if ($well_plates): ?>
<table class="table table-bordered">
<thead>
<tr>
<th>Well Plate ID</th>
<th>Laboratory Name</th>
<th>Incubation Start</th>
<th>Incubation End</th>
<th>Temperature</th>
<th>Incubator ID</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php foreach ($well_plates as $well_plate): ?>
<tr>
<td><?php echo htmlspecialchars($well_plate['well_plate_id']); ?></td>
<td><?php echo htmlspecialchars($well_plate['laboratory_name']); ?></td>
<td><?php echo htmlspecialchars($well_plate['incubation_start']); ?></td>
<td><?php echo htmlspecialchars($well_plate['incubation_end']); ?></td>
<td><?php echo htmlspecialchars($well_plate['Temperature']); ?></td>
<td><?php echo htmlspecialchars($well_plate['incubator_id']); ?></td>
<td><?php echo htmlspecialchars($well_plate['status']); ?></td>
</tr>
<tr>
<td colspan="7">
<?php
$stmt_sample_well = db()->prepare("SELECT * FROM Sample_Well WHERE well_plate_id = ?");
$stmt_sample_well->execute([$well_plate['well_plate_id']]);
$sample_wells = $stmt_sample_well->fetchAll(PDO::FETCH_ASSOC);
?>
<?php if ($sample_wells): ?>
<h6>Sample Wells</h6>
<table class="table table-sm table-bordered">
<thead>
<tr>
<th>Sample ID</th>
<th>Picture</th>
<th>Solutions</th>
<th>Solvents</th>
<th>Catalysts</th>
<th>Solids</th>
</tr>
</thead>
<tbody>
<?php foreach ($sample_wells as $sample_well): ?>
<tr>
<td><?php echo htmlspecialchars($sample_well['sample_id']); ?></td>
<td><img src="<?php echo htmlspecialchars($sample_well['picture_url']); ?>" alt="Sample Well" style="max-width: 100px;"></td>
<td>
<?php
$stmt_solutions = db()->prepare("SELECT ws.*, s.name FROM Well_Solution ws JOIN Preprep_vial s ON ws.vial_id = s.vial_id WHERE ws.sample_id = ?");
$stmt_solutions->execute([$sample_well['sample_id']]);
$solutions = $stmt_solutions->fetchAll(PDO::FETCH_ASSOC);
foreach ($solutions as $solution) {
echo htmlspecialchars($solution['name']) . ' (' . htmlspecialchars($solution['amount']) . ' ' . htmlspecialchars($solution['units']) . ')<br>';
}
?>
</td>
<td>
<?php
$stmt_solvents = db()->prepare("SELECT ws.*, s.name FROM Well_Solvents ws JOIN Solvent s ON ws.solvent_id = s.solvent_id WHERE ws.sample_id = ?");
$stmt_solvents->execute([$sample_well['sample_id']]);
$solvents = $stmt_solvents->fetchAll(PDO::FETCH_ASSOC);
foreach ($solvents as $solvent) {
echo htmlspecialchars($solvent['name']) . ' (' . htmlspecialchars($solvent['amount']) . ' ' . htmlspecialchars($solvent['units']) . ')<br>';
}
?>
</td>
<td>
<?php
$stmt_catalysts = db()->prepare("SELECT wc.*, c.name FROM Well_Catalysts wc JOIN Catalyst c ON wc.catalyst_id = c.catalyst_id WHERE wc.sample_id = ?");
$stmt_catalysts->execute([$sample_well['sample_id']]);
$catalysts = $stmt_catalysts->fetchAll(PDO::FETCH_ASSOC);
foreach ($catalysts as $catalyst) {
echo htmlspecialchars($catalyst['name']) . ' (' . htmlspecialchars($catalyst['amount']) . ' ' . htmlspecialchars($catalyst['units']) . ')<br>';
}
?>
</td>
<td>
<?php
$stmt_solids = db()->prepare("SELECT ws.*, s.name FROM Well_Solids ws JOIN Solid s ON ws.solid_id = s.solid_id WHERE ws.sample_id = ?");
$stmt_solids->execute([$sample_well['sample_id']]);
$solids = $stmt_solids->fetchAll(PDO::FETCH_ASSOC);
foreach ($solids as $solid) {
echo htmlspecialchars($solid['name']) . ' (' . htmlspecialchars($solid['amount']) . ' ' . htmlspecialchars($solid['units']) . ')<br>';
}
?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<div class="alert alert-info">No sample wells found for this well plate.</div>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<div class="alert alert-info">No well plates found for this synthesis plan.</div>
<?php endif; ?>
</div>
</div>
</div>
</body>
</html>