No worker ID specified.';
require_once 'footer.php';
exit;
}
$worker_id = $_GET['id'] ?? $_POST['id'];
try {
$db = db();
$stmt = $db->prepare("SELECT * FROM support_workers WHERE id = :id");
$stmt->bindParam(':id', $worker_id, PDO::PARAM_INT);
$stmt->execute();
$worker = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$worker) {
throw new Exception("Support worker not found.");
}
} catch (Exception $e) {
$error = "Error: " . $e->getMessage();
echo "
$error
";
require_once 'footer.php';
exit;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
try {
$db = db();
if (empty($_POST['full_name']) || empty($_POST['id'])) {
throw new Exception("Full Name and ID are required fields.");
}
$sql = "UPDATE support_workers SET
full_name = :full_name,
contact_info = :contact_info,
ndis_worker_screening_number = :ndis_worker_screening_number,
ndis_worker_screening_expiry = :ndis_worker_screening_expiry,
first_aid_expiry = :first_aid_expiry,
qualifications = :qualifications,
hourly_rate = :hourly_rate
WHERE id = :id";
$stmt = $db->prepare($sql);
$worker_id = $_POST['id'];
$stmt->bindParam(':id', $worker_id, PDO::PARAM_INT);
$stmt->bindParam(':full_name', $_POST['full_name']);
$stmt->bindParam(':contact_info', $_POST['contact_info']);
$stmt->bindParam(':ndis_worker_screening_number', $_POST['ndis_worker_screening_number']);
$stmt->bindParam(':ndis_worker_screening_expiry', $_POST['ndis_worker_screening_expiry']);
$stmt->bindParam(':first_aid_expiry', $_POST['first_aid_expiry']);
$stmt->bindParam(':qualifications', $_POST['qualifications']);
$stmt->bindParam(':hourly_rate', $_POST['hourly_rate']);
$stmt->execute();
header("Location: worker_detail.php?id=" . $worker_id . "&message=updated");
exit;
} catch (Exception $e) {
$error = "Error: " . $e->getMessage();
}
}
?>