151 lines
6.0 KiB
PHP
151 lines
6.0 KiB
PHP
<?php
|
|
require_once 'db/config.php';
|
|
require_once 'auth.php';
|
|
|
|
// Ensure user is authenticated
|
|
check_login();
|
|
|
|
$pdo = db();
|
|
$message = '';
|
|
|
|
// Handle POST requests to add tests
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
if (isset($_POST['add_lab_test'])) {
|
|
$test_name = trim($_POST['test_name']);
|
|
$cost = trim($_POST['cost']);
|
|
if (!empty($test_name) && is_numeric($cost)) {
|
|
$stmt = $pdo->prepare("INSERT INTO lab_tests (test_name, cost) VALUES (?, ?)");
|
|
$stmt->execute([$test_name, $cost]);
|
|
$message = '<div class="alert alert-success">Lab test added successfully!</div>';
|
|
} else {
|
|
$message = '<div class="alert alert-danger">Invalid input for lab test.</div>';
|
|
}
|
|
}
|
|
|
|
if (isset($_POST['add_imaging_test'])) {
|
|
$test_name = trim($_POST['test_name']);
|
|
$cost = trim($_POST['cost']);
|
|
if (!empty($test_name) && is_numeric($cost)) {
|
|
$stmt = $pdo->prepare("INSERT INTO imaging_tests (test_name, cost) VALUES (?, ?)");
|
|
$stmt->execute([$test_name, $cost]);
|
|
$message = '<div class="alert alert-success">Imaging test added successfully!</div>';
|
|
} else {
|
|
$message = '<div class="alert alert-danger">Invalid input for imaging test.</div>';
|
|
}
|
|
}
|
|
}
|
|
|
|
// Fetch all tests
|
|
$lab_tests = $pdo->query("SELECT * FROM lab_tests ORDER BY test_name ASC")->fetchAll();
|
|
$imaging_tests = $pdo->query("SELECT * FROM imaging_tests ORDER BY test_name ASC")->fetchAll();
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Lab & Imaging Test Configuration</title>
|
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
|
<link rel="stylesheet" href="assets/css/custom.css">
|
|
</head>
|
|
<body>
|
|
|
|
<div class="container mt-5">
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
<h1>Test Configuration</h1>
|
|
<div>
|
|
<a href="reception.php" class="btn btn-outline-secondary">Back to Reception</a>
|
|
<a href="doctor_dashboard.php" class="btn btn-outline-primary">Back to Dashboard</a>
|
|
</div>
|
|
</div>
|
|
|
|
<?php echo $message; ?>
|
|
|
|
<div class="row">
|
|
<!-- Lab Tests Column -->
|
|
<div class="col-md-6">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h3>Lab Tests</h3>
|
|
</div>
|
|
<div class="card-body">
|
|
<form method="POST" action="">
|
|
<div class="form-row">
|
|
<div class="col">
|
|
<input type="text" name="test_name" class="form-control" placeholder="Test Name" required>
|
|
</div>
|
|
<div class="col">
|
|
<input type="number" step="0.01" name="cost" class="form-control" placeholder="Cost" required>
|
|
</div>
|
|
<div class="col-auto">
|
|
<button type="submit" name="add_lab_test" class="btn btn-primary">Add</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
<hr>
|
|
<table class="table table-striped">
|
|
<thead>
|
|
<tr>
|
|
<th>Test Name</th>
|
|
<th>Cost</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($lab_tests as $test): ?>
|
|
<tr>
|
|
<td><?php echo htmlspecialchars($test['test_name']); ?></td>
|
|
<td>$<?php echo htmlspecialchars(number_format($test['cost'], 2)); ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Imaging Tests Column -->
|
|
<div class="col-md-6">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h3>Imaging Tests</h3>
|
|
</div>
|
|
<div class="card-body">
|
|
<form method="POST" action="">
|
|
<div class="form-row">
|
|
<div class="col">
|
|
<input type="text" name="test_name" class="form-control" placeholder="Test Name" required>
|
|
</div>
|
|
<div class="col">
|
|
<input type="number" step="0.01" name="cost" class="form-control" placeholder="Cost" required>
|
|
</div>
|
|
<div class="col-auto">
|
|
<button type="submit" name="add_imaging_test" class="btn btn-success">Add</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
<hr>
|
|
<table class="table table-striped">
|
|
<thead>
|
|
<tr>
|
|
<th>Test Name</th>
|
|
<th>Cost</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($imaging_tests as $test): ?>
|
|
<tr>
|
|
<td><?php echo htmlspecialchars($test['test_name']); ?></td>
|
|
<td>$<?php echo htmlspecialchars(number_format($test['cost'], 2)); ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|