diff --git a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/addFine.html b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/addFine.html
index a4a17d8..24ce610 100644
--- a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/addFine.html
+++ b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/addFine.html
@@ -10,7 +10,7 @@
- Search
- Add new vehicle
- - Create new report
+ - Reports
- Create new user
- Add Fines
- View log
diff --git a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/addFine.php b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/addFine.php
index 3fc0cc8..209c15c 100644
--- a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/addFine.php
+++ b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/addFine.php
@@ -16,6 +16,11 @@ if (isset($_SESSION["username"]) && isset($_SESSION["admin"]))
$stmt->bindParam(":incident", $incident);
$stmt->execute();
+ $logSQL = "INSERT INTO Logs (Logs_type, Users_username, Logs_date) VALUES ('Added a fine', :username, NOW())";
+ $logStmt = $conn->prepare($logSQL);
+ $logStmt->bindParam(":username", $_SESSION["username"]);
+ $logStmt->execute();
+
echo json_encode(array("message" => "ok"));
}
else if (isset($_SESSION["username"]) && !isset($_SESSION["admin"]))
diff --git a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/addVehicle.html b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/addVehicle.html
index 2c96e28..9520bdf 100644
--- a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/addVehicle.html
+++ b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/addVehicle.html
@@ -10,7 +10,7 @@
- Search
- Add new vehicle
- - Create new report
+ - Reports
- Create new user
- Add Fines
- View log
diff --git a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/addVehicle.php b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/addVehicle.php
index 3114169..eab9598 100644
--- a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/addVehicle.php
+++ b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/addVehicle.php
@@ -34,6 +34,11 @@ if (isset($_SESSION["username"]))
$stmt->execute();
echo json_encode(array("message" => "Vehicle added successfully and assigned to existing owner"));
}
+
+ $logSQL = "INSERT INTO Logs (Logs_type, Users_username, Logs_date) VALUES ('Add vehicle', :username, NOW())";
+ $logStmt = $conn->prepare($logSQL);
+ $logStmt->bindParam(":username", $_SESSION["username"]);
+ $logStmt->execute();
}
else
{
diff --git a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/changePassword.html b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/changePassword.html
index 9007bc3..b03252a 100644
--- a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/changePassword.html
+++ b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/changePassword.html
@@ -10,7 +10,7 @@
- Search
- Add new vehicle
- - Create new report
+ - Reports
- Create new user
- Add Fines
- View log
diff --git a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/changePassword.php b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/changePassword.php
index bc41a76..fdd9757 100644
--- a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/changePassword.php
+++ b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/changePassword.php
@@ -12,7 +12,12 @@ if (isset($_SESSION["username"]))
$stmt->bindParam(":username", $_SESSION["username"]);
if ($stmt->execute())
{
+
+ $logSQL = "INSERT INTO Logs (Logs_type, Users_username, Logs_date) VALUES ('Change password', :username, NOW())";
+ $logStmt = $conn->prepare($logSQL);
+ $logStmt->bindParam(":username", $_SESSION["username"]);
echo json_encode(array("message" => "ok"));
+ $logStmt->execute();
}
else
{
diff --git a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/getOwners.php b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/getOwners.php
index 9c2f8f7..51789ec 100644
--- a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/getOwners.php
+++ b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/getOwners.php
@@ -10,4 +10,8 @@ if (isset($_SESSION["username"]))
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode(array("message" => "ok", "owners" => $result));
+}
+else
+{
+ echo json_encode(array("message" => "Not logged in "));
}
\ No newline at end of file
diff --git a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/js/viewLog.js b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/js/viewLog.js
new file mode 100644
index 0000000..7e1c1e0
--- /dev/null
+++ b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/js/viewLog.js
@@ -0,0 +1,37 @@
+
+document.addEventListener("DOMContentLoaded", () =>
+{
+ fetch("isAdmin.php").then(res => res.json().then(json =>
+ {
+ if (json.message !== "ok")
+ {
+ window.location.href = "./search.html";
+ }
+ }));
+
+ fetch("viewLog.php").then(res => res.json().then(json =>
+ {
+ if (json.message === "ok")
+ {
+ for (const key of Object.keys(json.logs[0]))
+ {
+ let header = key.substring(key.indexOf("_") + 1)
+ header = header.charAt(0).toUpperCase() + header.slice(1);
+ document.querySelector("#logTable thead tr").innerHTML += `${header} | `;
+ }
+
+ let body = "";
+ for (const row of json.logs)
+ {
+ body += "";
+ for (const key of Object.keys(row))
+ {
+ body += `${row[key]} | `;
+ }
+ body += "
";
+ }
+
+ document.querySelector("#logTable tbody").innerHTML = body;
+ }
+ }));
+});
\ No newline at end of file
diff --git a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/newUser.html b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/newUser.html
index c52a6c5..e79c01d 100644
--- a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/newUser.html
+++ b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/newUser.html
@@ -10,7 +10,7 @@
- Search
- Add new vehicle
- - Create new report
+ - Reports
- Create new user
- Add Fines
- View log
diff --git a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/newUser.php b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/newUser.php
index 3bff2b8..cf5c274 100644
--- a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/newUser.php
+++ b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/newUser.php
@@ -17,6 +17,13 @@ if (isset($_SESSION["username"]) && isset($_SESSION["admin"]))
$stmt->bindParam(":admin", $isAdmin);
$stmt->execute();
+ $logSQL = "INSERT INTO Logs (Logs_type, Users_username, Logs_date) VALUES (:type, :username, NOW())";
+ $logStmt = $conn->prepare($logSQL);
+ $type = !$admin ? "Add user" : "Add admin";
+ $logStmt->bindParam(":type", $type);
+ $logStmt->bindParam(":username", $_SESSION["username"]);
+ $logStmt->execute();
+
echo json_encode(array("message" => "ok", "admin" => $admin));
}
else if (isset($_SESSION["username"]) && !isset($_SESSION["admin"]))
diff --git a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/search.html b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/search.html
index bb19098..97d6093 100644
--- a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/search.html
+++ b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/search.html
@@ -11,7 +11,7 @@
- Search
- Add new vehicle
- - Create new report
+ - Reports
- Create new user
- Add Fines
- View log
diff --git a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/search.php b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/search.php
index df7c65e..f28c44f 100644
--- a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/search.php
+++ b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/search.php
@@ -13,10 +13,20 @@ if (isset($_SESSION["username"]))
$stmt = $conn->prepare("SELECT People_name, People_address, People_licence FROM People WHERE People_name LIKE :name OR People_licence = :searchField");
$name = "%" . $searchField . "%";
$stmt->bindParam(":name", $name);
+
+ $logSQL = "INSERT INTO Logs (Logs_type, Users_username, Logs_date) VALUES ('Search by driving licence number', :username, NOW())";
+ $logStmt = $conn->prepare($logSQL);
+ $logStmt->bindParam(":username", $_SESSION["username"]);
+ $logStmt->execute();
+
}
else
{
$stmt = $conn->prepare("SELECT P.People_name, Vehicle_type, Vehicle_colour, Vehicle_licence FROM Vehicle LEFT JOIN Ownership O on Vehicle.Vehicle_ID = O.Vehicle_ID LEFT JOIN People P on O.People_ID = P.People_ID WHERE Vehicle_licence = :searchField");
+
+ $logSQL = "INSERT INTO Logs (Logs_type, Users_username, Logs_date) VALUES ('Search by plate number', :username, NOW())";
+ $logStmt = $conn->prepare($logSQL);
+ $logStmt->bindParam(":username", $_SESSION["username"]);
}
$stmt->bindParam(":searchField", $searchField);
@@ -36,4 +46,4 @@ if (isset($_SESSION["username"]))
else
{
echo json_encode(array("message" => "Not logged in"));
-}
\ No newline at end of file
+}
diff --git a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/viewLog.html b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/viewLog.html
index 566549b..163c414 100644
--- a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/viewLog.html
+++ b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/viewLog.html
@@ -2,9 +2,41 @@
- Title
+ View Log
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/viewLog.php b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/viewLog.php
new file mode 100644
index 0000000..b414b56
--- /dev/null
+++ b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/viewLog.php
@@ -0,0 +1,21 @@
+prepare("SELECT Logs_type, Users_username, Logs_date FROM Logs");
+ $stmt->execute();
+ $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
+ echo json_encode(array("message" => "ok", "logs" => $result));
+}
+else if (isset($_SESSION["username"]) && !isset($_SESSION["admin"]))
+{
+ echo json_encode(array("message" => "not logged in as admin"));
+}
+else
+{
+ echo json_encode(array("message" => "Not logged in "));
+}
\ No newline at end of file