diff --git a/api/create_election.php b/api/create_election.php
index 61e59bc..b463627 100644
--- a/api/create_election.php
+++ b/api/create_election.php
@@ -24,7 +24,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
audit_log('Created election', 'elections', $id);
- header("Location: ../view_election.php?id=$id&success=1");
+ $redirect = $_POST['redirect'] ?? "../view_election.php?id=$id&success=1";
+ header("Location: $redirect");
exit;
} catch (Exception $e) {
die("Error: " . $e->getMessage());
diff --git a/api/manage_election_action.php b/api/manage_election_action.php
new file mode 100644
index 0000000..0227cd2
--- /dev/null
+++ b/api/manage_election_action.php
@@ -0,0 +1,46 @@
+prepare($sql);
+ $stmt->execute($params);
+
+ audit_log("Election Managed: Status=$status, EndTime=$end_time", 'elections', $id);
+
+ header("Location: ../dashboard.php?success=Election updated successfully");
+ exit;
+ } catch (Exception $e) {
+ die($e->getMessage());
+ }
+}
diff --git a/api/update_election_status.php b/api/update_election_status.php
index 9697604..53f5cf9 100644
--- a/api/update_election_status.php
+++ b/api/update_election_status.php
@@ -18,9 +18,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$stmt->execute([$status, $id]);
audit_log("Updated election status to $status", 'elections', $id);
-
- header("Location: ../view_election.php?id=$id&success=1");
+
+ $redirect = $_POST['redirect'] ?? "../view_election.php?id=$id&success=1";
+ header("Location: $redirect");
exit;
+
} catch (Exception $e) {
die($e->getMessage());
}
diff --git a/dashboard.php b/dashboard.php
index b352062..80057c2 100644
--- a/dashboard.php
+++ b/dashboard.php
@@ -3,11 +3,18 @@ require_once 'auth_helper.php';
require_login();
$user = get_user();
-$pdo = db();
-$electionId = get_active_election_id();
-$election = get_active_election();
+ $pdo = db();
+ $electionId = get_active_election_id();
+ $election = get_active_election();
+
+ // For Election Management Section
+ $allElections = [];
+ if (in_array($user['role'], ['Admin', 'Adviser', 'Officer'])) {
+ $allElections = $pdo->query("SELECT * FROM elections WHERE archived = FALSE ORDER BY created_at DESC")->fetchAll();
+ }
+
+ // Statistics (Filtered by Election)
-// Statistics (Filtered by Election)
$totalVoters = $pdo->prepare("SELECT COUNT(*) FROM election_assignments WHERE election_id = ? AND role_in_election = 'Voter'");
$totalVoters->execute([$electionId]);
$totalVoters = $totalVoters->fetchColumn();
@@ -64,6 +71,81 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Online Election System
+
@@ -74,6 +156,16 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Online Election System
+
+
+ = htmlspecialchars($_GET['success']) ?>
+
+
+
+
+ = htmlspecialchars($_GET['error']) ?>
+
+
+
+
+
+
+
+
+
+ | Election Title |
+ Status |
+ Current End Time |
+ Actions |
+
+
+
+
+
+ | = htmlspecialchars($e['title']) ?> |
+
+
+ = htmlspecialchars($e['status']) ?>
+
+ |
+
+ = date('M d, H:i', strtotime($e['end_date_and_time'])) ?>
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+
+
+
@@ -243,5 +402,109 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Online Election System
updateSectionChart(trackFilter.value);
}
+
+
+
+
+
+
+
+