| Current Path : /home/emeraadmin/public_html/pages/ |
| Current File : /home/emeraadmin/public_html/pages/submit_form.php |
<?php
require_once '../Classes/Database.php';
require_once '../Classes/TaskForm.php';
require_once '../Service/TaskFormService.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Collect form data
$subtask = $_POST['subtask_id'];
$schoolName = $_POST['schoolName'];
$date = $_POST['date'];
$time = $_POST['time'];
$main_areas = isset($_POST['main_areas']) ? implode(', ', $_POST['main_areas']) : '';
$notes = $_POST['notes'];
$clientName = $_POST['clientName'];
$staffName = $_POST['staffName'];
$clientSignature = $_POST['clientSignature'];
$staffSignature = $_POST['staffSignature'];
$latitude = $_POST['latitude'];
$longitude = $_POST['longitude'];
$checklist_json = isset($_POST['checklist_json']) ? $_POST['checklist_json'] : '';
$main_areas = $checklist_json;
// Check if signatures are present
if (empty($clientSignature) || empty($staffSignature)) {
echo "Both signatures are required.";
exit();
}
$now = date('Y-m-d H:i:s');
// Create TaskForm instance with base64 signature data
$taskForm = new TaskForm(null, $subtask, $schoolName, $date, $time, $main_areas, $notes, $clientName, $clientSignature, $staffName, $staffSignature, $now, $latitude, $longitude);
$taskFormService = new TaskFormService();
if ($taskFormService->insertTaskForm($taskForm)) {
echo "Task Form added successfully!";
} else {
echo "Failed to add task form.";
}
}
?>