Mission Dashboard
-© AgroDrone Control. All Rights Reserved.
+ + + @@ -99,4 +185,4 @@ - \ No newline at end of file +diff --git a/assets/js/main.js b/assets/js/main.js index a6186fc..ad5cb41 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -1,9 +1,4 @@ - -document.addEventListener('DOMContentLoaded', function() { - const createMissionBtn = document.getElementById('createMissionBtn'); - if (createMissionBtn) { - createMissionBtn.addEventListener('click', function() { - alert('This feature is coming soon!'); - }); - } -}); +document.addEventListener('DOMContentLoaded', function () { + // You can add any interactive scripts here in the future. + // For example, handling view button clicks to show mission details. +}); \ No newline at end of file diff --git a/db/setup.php b/db/setup.php new file mode 100644 index 0000000..6bd2468 --- /dev/null +++ b/db/setup.php @@ -0,0 +1,33 @@ +exec($sql); + echo "Table 'missions' created successfully." . PHP_EOL; + + // Add some initial data for demonstration + $stmt = $pdo->query("SELECT COUNT(*) FROM missions"); + if ($stmt->fetchColumn() == 0) { + $pdo->exec(" + INSERT INTO missions (name, drone, status, mission_date) VALUES + ('Vineyard Survey', 'DJI Agras T30', 'Completed', '2025-09-25'), + ('Pest Control', 'XAG P40', 'In Progress', '2025-09-27'), + ('Crop Dusting', 'DJI Agras T30', 'Scheduled', '2025-09-29'); + "); + echo "Initial data inserted into 'missions' table." . PHP_EOL; + } + +} catch (PDOException $e) { + die("DB ERROR: " . $e->getMessage()); +} diff --git a/index.php b/index.php index b5e5a16..d0ad0cb 100644 --- a/index.php +++ b/index.php @@ -1,3 +1,56 @@ +prepare($sql); + $stmt->execute([ + ':name' => $name, + ':drone' => $drone, + ':status' => $status, + ':mission_date' => $mission_date, + ]); + // Redirect to avoid form resubmission + header("Location: index.php"); + exit; + } catch (PDOException $e) { + // For a real app, you'd log this error + die("Error saving mission: " . $e->getMessage()); + } + } +} + +// Fetch all missions +try { + $pdo = db(); + $stmt = $pdo->query("SELECT id, name, drone, status, DATE_FORMAT(mission_date, '%Y-%m-%d') as mission_date FROM missions ORDER BY mission_date DESC"); + $missions = $stmt->fetchAll(); +} catch (PDOException $e) { + die("Error fetching missions: " . $e->getMessage()); +} + +function getStatusClass($status) { + switch (strtolower($status)) { + case 'completed': + return 'status-completed'; + case 'in progress': + return 'status-in-progress'; + case 'scheduled': + return 'status-pending'; + default: + return 'status-pending'; + } +} +?>
@@ -32,10 +85,10 @@ -© AgroDrone Control. All Rights Reserved.
+ + + @@ -99,4 +185,4 @@ - \ No newline at end of file +