Compare commits

...

18 Commits

Author SHA1 Message Date
rodude123 0d2d660202 Merge pull request 'Final commit of the coursework with the pdfs' (#8) from final into master
Reviewed-on: #8
2022-12-18 16:29:58 +00:00
rodude123 8cd1f3cfda Final commit of the coursework with the pdfs
Signed-off-by: rodude123 <rodude123@gmail.com>
2022-12-18 16:28:10 +00:00
rodude123 2fd2f4806d Merge pull request 'Added in the ability to create new reports' (#7) from reports into master
Reviewed-on: #7
2022-12-16 13:21:38 +00:00
rodude123 108cf7586d Added in the ability to create new reports
Signed-off-by: rodude123 <rodude123@gmail.com>
2022-12-16 13:21:10 +00:00
rodude123 17704a52a0 Merge pull request 'Created the log functionality' (#6) from view-log into master
Reviewed-on: #6
2022-12-16 12:20:28 +00:00
rodude123 95b11f3496 Created the log functionality
Signed-off-by: rodude123 <rodude123@gmail.com>
2022-12-16 12:19:38 +00:00
rodude123 3728701d77 Merge pull request 'add-admin' (#5) from add-admin into master
Reviewed-on: #5
2022-12-15 23:26:54 +00:00
rodude123 a6d2a0c17b Created the ability to add fines
Signed-off-by: rodude123 <rodude123@gmail.com>
2022-12-15 23:25:00 +00:00
rodude123 1f94dcb709 Created the separation of admin and regular user. Added the ability for a regular user to be added in
Signed-off-by: rodude123 <rodude123@gmail.com>
2022-12-15 14:50:58 +00:00
rodude123 5a71f98a9a Merge pull request 'Added in ability to add new vehicle with new owner or existing owner' (#4) from add-new-vehicle into master
Reviewed-on: #4
2022-12-09 04:53:11 +00:00
rodude123 996fee5ad2 Added in ability to add new vehicle with new owner or existing owner
Signed-off-by: rodude123 <rodude123@gmail.com>
2022-12-09 04:51:56 +00:00
rodude123 0235886d60 Merge pull request 'Added in ability to change password and fisxed some other smaller issues' (#3) from change-password into master
Reviewed-on: #3
2022-12-03 12:58:58 +00:00
rodude123 d54d7b37ea Added in ability to change password and fisxed some other smaller issues
Signed-off-by: rodude123 <rodude123@gmail.com>
2022-12-03 12:57:42 +00:00
rodude123 a4b05540d2 Merge pull request 'search' (#2) from search into master
Reviewed-on: #2
2022-11-29 15:54:09 +00:00
rodude123 7eefeaf7ad Finished of the ability to search for a name or plate number. Results shown as a table. Any empty's shown as N/A 2022-11-29 15:48:18 +00:00
rodude123 f03023a000 Created rest of the pages and isLoggedIn.php to check if the user is logged in to make changes to the system 2022-11-24 10:26:37 +00:00
rodude123 e809e9e7e0 Merge pull request 'Created login for the default usernames and passwords' (#1) from login into master
Reviewed-on: #1
2022-11-24 10:24:35 +00:00
rodude123 ee33162dd4 Created login for the default usernames and passwords 2022-11-24 09:15:38 +00:00
48 changed files with 2646 additions and 169 deletions
+2
View File
@@ -2,6 +2,8 @@
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
.idea/
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
@@ -0,0 +1,53 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Add Fines</title>
<link rel="stylesheet" href="css/nav.css">
</head>
<body>
<nav>
<ul>
<li><a href="search.html" class="btn">Search</a></li>
<li><a href="addVehicle.html" class="btn">Add new vehicle</a></li>
<li><a href="reports.html" class="btn">Reports</a></li>
<li class="admin"><a href="newUser.html" class="btn">Create new user</a></li>
<li class="admin"><a href="addFine.html" class="btn active">Add Fines</a></li>
<li class="admin"><a href="viewLog.html" class="btn">View log</a></li>
<li><a href="changePassword.html" class="btn">Change password</a></li>
<li><a id="logout" class="btn">Logout</a></li>
</ul>
</nav>
<main>
<header id="title">
<h1></h1>
</header>
<form method="POST" id="addFineForm">
<div class="formControl">
<label for="amount">Amount in £</label>
<input type="number" name="amount" id="amount" required>
</div>
<div class="formControl">
<label for="points">Points</label>
<input type="number" name="points" id="points" required>
</div>
<div class="formControl"><label for="incident">Incident</label>
<div class="selectDiv">
<select id="incident" name="incident" required>
</select>
</div>
</div>
<input type="submit" value="Add Fines" class="btn btnPrimary" style="margin-top: 1em;">
</form>
</main>
<script src="js/checkUser.js"></script>
<script src="js/addFine.js"></script>
</body>
</html>
@@ -0,0 +1,35 @@
<?php
session_start();
require_once 'config.php';
header('Content-Type: application/json');
if (isset($_SESSION["username"]) && isset($_SESSION["admin"]))
{
$conn = dbConn();
$amount = $_POST["amount"];
$points = $_POST["points"];
$incident = $_POST["incident"];
$stmt = $conn->prepare("INSERT INTO Fines (Fine_amount, Fine_points, Incident_ID) VALUES (:amount, :points, :incident)");
$stmt->bindParam(":amount", $amount);
$stmt->bindParam(":points", $points);
$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"]))
{
echo json_encode(array("message" => "not logged in as admin"));
}
else
{
echo json_encode(array("message" => "Not logged in "));
}
{
}
@@ -0,0 +1,80 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Add New Vehicle</title>
<link rel="stylesheet" href="css/newVehicle.css">
</head>
<body>
<nav>
<ul>
<li><a href="search.html" class="btn">Search</a></li>
<li><a href="addVehicle.html" class="btn active">Add new vehicle</a></li>
<li><a href="reports.html" class="btn">Reports</a></li>
<li class="admin"><a href="newUser.html" class="btn">Create new user</a></li>
<li class="admin"><a href="addFine.html" class="btn">Add Fines</a></li>
<li class="admin"><a href="viewLog.html" class="btn">View log</a></li>
<li><a href="changePassword.html" class="btn">Change password</a></li>
<li><a id="logout" class="btn">Logout</a></li>
</ul>
</nav>
<main>
<header id="title">
<h1></h1>
</header>
<form action="" id="vehicleForm">
<div class="formGroup">
<div class="formSpace">
<div class="formControl">
<label for="type">Type</label>
<input type="text" name="type" id="type" required>
</div>
<div class="formControl">
<label for="colour">Colour</label>
<input type="text" name="colour" id="colour" required>
</div>
<div class="formControl">
<label for="plateNum">Plate Number</label>
<input type="text" name="plateNum" id="plateNum" required>
</div>
<div class="formControl">
<label for="owner">Owner</label>
<div class="selectDiv">
<select name="owner" id="owner" required>
</select>
</div>
</div>
<input type="submit" value="Add new vehicle" class="btn btnPrimary">
</div>
<div class="formSpace" id="addOwner">
<div class="formControl">
<label for="name">Name</label>
<input type="text" name="name" id="name" >
</div>
<div class="formControl">
<label for="address">Address</label>
<input type="text" name="address" id="address">
</div>
<div class="formControl">
<label for="licence">Licence number</label>
<input type="text" name="licence" id="licence" maxlength="16" max="16">
</div>
</div>
</div>
</form>
</main>
<script src="js/checkUser.js"></script>
<script src="js/newVehicle.js"></script>
</body>
</html>
@@ -0,0 +1,46 @@
<?php
session_start();
require_once 'config.php';
header('Content-Type: application/json');
if (isset($_SESSION["username"]))
{
$conn = dbConn();
$stmt = $conn->prepare("INSERT INTO Vehicle (Vehicle_type, Vehicle_colour, Vehicle_licence) VALUES (:type, :colour, :plateNum)");
$stmt->bindParam(":type", $_POST["type"]);
$stmt->bindParam(":colour", $_POST["colour"]);
$stmt->bindParam(":plateNum", $_POST["plateNum"]);
$stmt->execute();
$vehicleID = $conn->lastInsertId();
if (isset($_POST["name"]) && isset($_POST["address"]) && isset($_POST["licence"]))
{
$stmtPeople = $conn->prepare("INSERT INTO People (People_name, People_address, People_licence) VALUES (:name, :address, :licence)");
$stmtPeople->bindParam(":name", $_POST["name"]);
$stmtPeople->bindParam(":address", $_POST["address"]);
$stmtPeople->bindParam(":licence", $_POST["licence"]);
$stmtPeople->execute();
$peopleID = $conn->lastInsertId();
$stmtOwner = $conn->prepare("INSERT INTO Ownership (Vehicle_ID, People_ID) VALUES (:vehicleID, :peopleID)");
$stmtOwner->bindParam(":vehicleID", $vehicleID);
$stmtOwner->bindParam(":peopleID", $peopleID);
$stmtOwner->execute();
echo json_encode(array("message" => "Vehicle and new owner added successfully"));
}
else
{
$stmt = $conn->prepare("INSERT INTO Ownership (Vehicle_ID, People_ID) VALUES (:vehicleID, :peopleID)");
$stmt->bindParam(":vehicleID", $vehicleID);
$stmt->bindParam(":peopleID", $_POST["peopleID"]);
$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
{
echo json_encode(array("message" => "Not logged in"));
}
@@ -0,0 +1,45 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Change Password</title>
<link rel="stylesheet" href="css/nav.css">
</head>
<body>
<nav>
<ul>
<li><a href="search.html" class="btn">Search</a></li>
<li><a href="addVehicle.html" class="btn">Add new vehicle</a></li>
<li><a href="reports.html" class="btn">Reports</a></li>
<li class="admin"><a href="newUser.html" class="btn">Create new user</a></li>
<li class="admin"><a href="addFine.html" class="btn">Add Fines</a></li>
<li class="admin"><a href="viewLog.html" class="btn">View log</a></li>
<li><a href="changePassword.html" class="btn active">Change password</a></li>
<li><a id="logout" class="btn">Logout</a></li>
</ul>
</nav>
<main>
<header id="title">
<h1></h1>
</header>
<form method="POST" id="changePass">
<div class="formControl">
<label for="pass">Password</label>
<input type="password" name="pass" id="pass">
</div>
<div class="formControl">
<label for="rePass">Retype Password</label>
<input type="password" name="rePass" id="rePass">
</div>
<input type="submit" value="Change Password" class="btn btnPrimary">
</form>
</main>
<script src="js/checkUser.js"></script>
<script src="js/changePassword.js"></script>
</body>
</html>
@@ -0,0 +1,30 @@
<?php
session_start();
require_once 'config.php';
header('Content-Type: application/json');
if (isset($_SESSION["username"]))
{
$pass = $_POST["password"];
$conn = dbConn();
$stmt = $conn->prepare("UPDATE Users SET Users_password = :pass WHERE Users_username = :username");
$stmt->bindParam(":pass", $pass);
$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
{
echo json_encode(array("message" => "Error updating password"));
}
}
else
{
echo json_encode(array("message" => "Not logged in"));
}
@@ -0,0 +1,20 @@
<?php
/**
* Create database connection
* @return PDO|string - Database connection or error message
*/
function dbConn()
{
$host = "mysql.cs.nott.ac.uk";
$dbName = "psxrp11_dbcw";
$username = "psxrp11_dbcw";
$password = "B4nking£ma1lC!tys";
try
{
return new PDO("mysql:host=$host;dbname=$dbName", $username, $password);
}
catch (PDOException $e)
{
return "Connection failed: " . $e->getMessage();
}
}
@@ -1,169 +0,0 @@
/* Database for use with DIS-COMP4039 Coursework 2
*
* Please note you do not have to use this. If you find
* it easier to use a database of your own design then
* you are free to do so.
*
* If you do use this database, use it as a starting point only.
* You will not be able to complete the coursework without
* modifying it to some extent.
*/
DROP TABLE IF EXISTS Fines;
CREATE TABLE Fines (
Fine_ID int(11) NOT NULL,
Fine_Amount int(11) NOT NULL,
Fine_Points int(11) NOT NULL,
Incident_ID int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO Fines (Fine_ID, Fine_Amount, Fine_Points, Incident_ID) VALUES
(1, 2000, 6, 3),
(2, 50, 0, 2),
(3, 500, 3, 4);
DROP TABLE IF EXISTS Incident;
CREATE TABLE Incident (
Incident_ID int(11) NOT NULL,
Vehicle_ID int(11) DEFAULT NULL,
People_ID int(11) DEFAULT NULL,
Incident_Date date NOT NULL,
Incident_Report varchar(500) NOT NULL,
Offence_ID int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO Incident (Incident_ID, Vehicle_ID, People_ID, Incident_Date, Incident_Report, Offence_ID) VALUES
(1, 15, 4, '2017-12-01', '40mph in a 30 limit', 1),
(2, 20, 8, '2017-11-01', 'Double parked', 4),
(3, 13, 4, '2017-09-17', '110mph on motorway', 1),
(4, 14, 2, '2017-08-22', 'Failure to stop at a red light - travelling 25mph', 8),
(5, 13, 4, '2017-10-17', 'Not wearing a seatbelt on the M1', 3);
DROP TABLE IF EXISTS Offence;
CREATE TABLE Offence (
Offence_ID int(11) NOT NULL,
Offence_description varchar(50) NOT NULL,
Offence_maxFine int(11) NOT NULL,
Offence_maxPoints int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO Offence (Offence_ID, Offence_description, Offence_maxFine, Offence_maxPoints) VALUES
(1, 'Speeding', 1000, 3),
(2, 'Speeding on a motorway', 2500, 6),
(3, 'Seat belt offence', 500, 0),
(4, 'Illegal parking', 500, 0),
(5, 'Drink driving', 10000, 11),
(6, 'Driving without a licence', 10000, 0),
(7, 'Driving without a licence', 10000, 0),
(8, 'Traffic light offences', 1000, 3),
(9, 'Cycling on pavement', 500, 0),
(10, 'Failure to have control of vehicle', 1000, 3),
(11, 'Dangerous driving', 1000, 11),
(12, 'Careless driving', 5000, 6),
(13, 'Dangerous cycling', 2500, 0);
DROP TABLE IF EXISTS Ownership;
CREATE TABLE Ownership (
People_ID int(11) NOT NULL,
Vehicle_ID int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO Ownership (People_ID, Vehicle_ID) VALUES
(3, 12),
(8, 20),
(4, 15),
(4, 13),
(1, 16),
(2, 14),
(5, 17),
(6, 18),
(7, 21);
DROP TABLE IF EXISTS People;
CREATE TABLE People (
People_ID int(11) NOT NULL,
People_name varchar(50) NOT NULL,
People_address varchar(50) DEFAULT NULL,
People_licence varchar(16) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO People (People_ID, People_name, People_address, People_licence) VALUES
(1, 'James Smith', '23 Barnsdale Road, Leicester', 'SMITH92LDOFJJ829'),
(2, 'Jennifer Allen', '46 Bramcote Drive, Nottingham', 'ALLEN88K23KLR9B3'),
(3, 'John Myers', '323 Derby Road, Nottingham', 'MYERS99JDW8REWL3'),
(4, 'James Smith', '26 Devonshire Avenue, Nottingham', 'SMITHR004JFS20TR'),
(5, 'Terry Brown', '7 Clarke Rd, Nottingham', 'BROWND3PJJ39DLFG'),
(6, 'Mary Adams', '38 Thurman St, Nottingham', 'ADAMSH9O3JRHH107'),
(7, 'Neil Becker', '6 Fairfax Close, Nottingham', 'BECKE88UPR840F9R'),
(8, 'Angela Smith', '30 Avenue Road, Grantham', 'SMITH222LE9FJ5DS'),
(9, 'Xene Medora', '22 House Drive, West Bridgford', 'MEDORH914ANBB223');
DROP TABLE IF EXISTS Vehicle;
CREATE TABLE Vehicle (
Vehicle_ID int(11) NOT NULL,
Vehicle_type varchar(20) NOT NULL,
Vehicle_colour varchar(20) NOT NULL,
Vehicle_licence varchar(7) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO Vehicle (Vehicle_ID, Vehicle_type, Vehicle_colour, Vehicle_licence) VALUES
(12, 'Ford Fiesta', 'Blue', 'LB15AJL'),
(13, 'Ferrari 458', 'Red', 'MY64PRE'),
(14, 'Vauxhall Astra', 'Silver', 'FD65WPQ'),
(15, 'Honda Civic', 'Green', 'FJ17AUG'),
(16, 'Toyota Prius', 'Silver', 'FP16KKE'),
(17, 'Ford Mondeo', 'Black', 'FP66KLM'),
(18, 'Ford Focus', 'White', 'DJ14SLE'),
(20, 'Nissan Pulsar', 'Red', 'NY64KWD'),
(21, 'Renault Scenic', 'Silver', 'BC16OEA'),
(22, 'Hyundai i30', 'Grey', 'AD223NG');
ALTER TABLE Fines
ADD PRIMARY KEY (Fine_ID),
ADD KEY Incident_ID (Incident_ID);
ALTER TABLE Incident
ADD PRIMARY KEY (Incident_ID),
ADD KEY fk_incident_vehicle (Vehicle_ID),
ADD KEY fk_incident_people (People_ID),
ADD KEY fk_incident_offence (Offence_ID);
ALTER TABLE Offence
ADD PRIMARY KEY (Offence_ID);
ALTER TABLE Ownership
ADD KEY fk_people (People_ID),
ADD KEY fk_vehicle (Vehicle_ID);
ALTER TABLE People
ADD PRIMARY KEY (People_ID);
ALTER TABLE Vehicle
ADD PRIMARY KEY (Vehicle_ID);
ALTER TABLE Fines
MODIFY Fine_ID int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
ALTER TABLE Incident
MODIFY Incident_ID int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
ALTER TABLE Offence
MODIFY Offence_ID int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;
ALTER TABLE People
MODIFY People_ID int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;
ALTER TABLE Vehicle
MODIFY Vehicle_ID int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=24;
ALTER TABLE Fines
ADD CONSTRAINT fk_fines FOREIGN KEY (Incident_ID) REFERENCES Incident (Incident_ID);
ALTER TABLE Incident
ADD CONSTRAINT fk_incident_offence FOREIGN KEY (Offence_ID) REFERENCES Offence (Offence_ID),
ADD CONSTRAINT fk_incident_people FOREIGN KEY (People_ID) REFERENCES People (People_ID),
ADD CONSTRAINT fk_incident_vehicle FOREIGN KEY (Vehicle_ID) REFERENCES Vehicle (Vehicle_ID);
ALTER TABLE Ownership
ADD CONSTRAINT fk_person FOREIGN KEY (People_ID) REFERENCES People (People_ID),
ADD CONSTRAINT fk_vehicle FOREIGN KEY (Vehicle_ID) REFERENCES Vehicle (Vehicle_ID);
@@ -0,0 +1,41 @@
@import "template.css";
body, html {
height: 100%;
}
main {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100%;
width: 100%;
background-image: linear-gradient(to top left, var(--primary), var(--hover));
}
div.login {
background-color: #FFFFFF;
padding: 2em 5em;
-webkit-border-radius: 1em;
-moz-border-radius: 1em;
border-radius: 1em;
box-shadow: 0 6px 0 var(--mutedBlack);
}
form.loginForm {
width: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
gap: 1em;
}
div.formControl {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
gap: 0.5em;
}
@@ -0,0 +1,43 @@
@import "template.css";
nav {
background-color: var(--primary);
}
nav ul {
list-style-type: none;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
margin: 0;
padding: 1.5em 1em;
}
nav ul li {
padding: 0 1em;
}
nav ul li a {
color: #FFFFFF;
text-decoration: none;
}
nav ul li a.active, nav ul li a:hover {
padding: 1.5em 1.75em;
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
}
nav ul li a:hover {
background: var(--mutedBlack);
}
nav ul li a.active {
background-color: var(--hover);
}
nav ul li.admin {
display: none;
}
@@ -0,0 +1,52 @@
@import "nav.css";
main .formGroup {
width: 30%;
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: flex-start;
flex-wrap: wrap;
gap: 2em;
}
main form {
width: 100%;
align-items: center;
flex: 1;
}
main form .formControl .selectDiv {
width: 100%;
}
.formSpace {
width: 100%;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: flex-start;
gap: 1em;
flex: 1;
}
#addOwner {
visibility: hidden;
opacity: 0;
-webkit-transition: visibility 0s linear 300ms, opacity 300ms;
-moz-transition: visibility 0s linear 300ms, opacity 300ms;
-ms-transition: visibility 0s linear 300ms, opacity 300ms;
-o-transition: visibility 0s linear 300ms, opacity 300ms;
transition: visibility 0s linear 300ms, opacity 300ms;
}
#addOwner.shown {
visibility: visible;
opacity: 1;
-webkit-transition: visibility 0s linear 0s, opacity 300ms;
-moz-transition: visibility 0s linear 0s, opacity 300ms;
-ms-transition: visibility 0s linear 0s, opacity 300ms;
-o-transition: visibility 0s linear 0s, opacity 300ms;
transition: visibility 0s linear 0s, opacity 300ms;
}
@@ -0,0 +1,349 @@
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
/* Document
========================================================================== */
/**
* 1. Correct the line height in all browsers.
* 2. Prevent adjustments of font size after orientation changes in iOS.
*/
html {
line-height: 1.15; /* 1 */
-webkit-text-size-adjust: 100%; /* 2 */
}
/* Sections
========================================================================== */
/**
* Remove the margin in all browsers.
*/
body {
margin: 0;
}
/**
* Render the `main` element consistently in IE.
*/
main {
display: block;
}
/**
* Correct the font size and margin on `h1` elements within `section` and
* `article` contexts in Chrome, Firefox, and Safari.
*/
h1 {
font-size: 2em;
margin: 0.67em 0;
}
/* Grouping content
========================================================================== */
/**
* 1. Add the correct box sizing in Firefox.
* 2. Show the overflow in Edge and IE.
*/
hr {
box-sizing: content-box; /* 1 */
height: 0; /* 1 */
overflow: visible; /* 2 */
}
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
pre {
font-family: monospace, monospace; /* 1 */
font-size: 1em; /* 2 */
}
/* Text-level semantics
========================================================================== */
/**
* Remove the gray background on active links in IE 10.
*/
a {
background-color: transparent;
}
/**
* 1. Remove the bottom border in Chrome 57-
* 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
*/
abbr[title] {
border-bottom: none; /* 1 */
text-decoration: underline; /* 2 */
text-decoration: underline dotted; /* 2 */
}
/**
* Add the correct font weight in Chrome, Edge, and Safari.
*/
b,
strong {
font-weight: bolder;
}
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
code,
kbd,
samp {
font-family: monospace, monospace; /* 1 */
font-size: 1em; /* 2 */
}
/**
* Add the correct font size in all browsers.
*/
small {
font-size: 80%;
}
/**
* Prevent `sub` and `sup` elements from affecting the line height in
* all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
/* Embedded content
========================================================================== */
/**
* Remove the border on images inside links in IE 10.
*/
img {
border-style: none;
}
/* Forms
========================================================================== */
/**
* 1. Change the font styles in all browsers.
* 2. Remove the margin in Firefox and Safari.
*/
button,
input,
optgroup,
select,
textarea {
font-family: inherit; /* 1 */
font-size: 100%; /* 1 */
line-height: 1.15; /* 1 */
margin: 0; /* 2 */
}
/**
* Show the overflow in IE.
* 1. Show the overflow in Edge.
*/
button,
input { /* 1 */
overflow: visible;
}
/**
* Remove the inheritance of text transform in Edge, Firefox, and IE.
* 1. Remove the inheritance of text transform in Firefox.
*/
button,
select { /* 1 */
text-transform: none;
}
/**
* Correct the inability to style clickable types in iOS and Safari.
*/
button,
[type="button"],
[type="reset"],
[type="submit"] {
-webkit-appearance: button;
}
/**
* Remove the inner border and padding in Firefox.
*/
button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
border-style: none;
padding: 0;
}
/**
* Restore the focus styles unset by the previous rule.
*/
button:-moz-focusring,
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring {
outline: 1px dotted ButtonText;
}
/**
* Correct the padding in Firefox.
*/
fieldset {
padding: 0.35em 0.75em 0.625em;
}
/**
* 1. Correct the text wrapping in Edge and IE.
* 2. Correct the color inheritance from `fieldset` elements in IE.
* 3. Remove the padding so developers are not caught out when they zero out
* `fieldset` elements in all browsers.
*/
legend {
box-sizing: border-box; /* 1 */
color: inherit; /* 2 */
display: table; /* 1 */
max-width: 100%; /* 1 */
padding: 0; /* 3 */
white-space: normal; /* 1 */
}
/**
* Add the correct vertical alignment in Chrome, Firefox, and Opera.
*/
progress {
vertical-align: baseline;
}
/**
* Remove the default vertical scrollbar in IE 10+.
*/
textarea {
overflow: auto;
}
/**
* 1. Add the correct box sizing in IE 10.
* 2. Remove the padding in IE 10.
*/
[type="checkbox"],
[type="radio"] {
box-sizing: border-box; /* 1 */
padding: 0; /* 2 */
}
/**
* Correct the cursor style of increment and decrement buttons in Chrome.
*/
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
height: auto;
}
/**
* 1. Correct the odd appearance in Chrome and Safari.
* 2. Correct the outline style in Safari.
*/
[type="search"] {
-webkit-appearance: textfield; /* 1 */
outline-offset: -2px; /* 2 */
}
/**
* Remove the inner padding in Chrome and Safari on macOS.
*/
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
/**
* 1. Correct the inability to style clickable types in iOS and Safari.
* 2. Change font properties to `inherit` in Safari.
*/
::-webkit-file-upload-button {
-webkit-appearance: button; /* 1 */
font: inherit; /* 2 */
}
/* Interactive
========================================================================== */
/*
* Add the correct display in Edge, IE 10+, and Firefox.
*/
details {
display: block;
}
/*
* Add the correct display in all browsers.
*/
summary {
display: list-item;
}
/* Misc
========================================================================== */
/**
* Add the correct display in IE 10+.
*/
template {
display: none;
}
/**
* Add the correct display in IE 10.
*/
[hidden] {
display: none;
}
@@ -0,0 +1,56 @@
@import "nav.css";
main .formGroup {
width: 40%;
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: flex-start;
flex-wrap: wrap;
gap: 2em;
}
main form {
width: 100%;
align-items: center;
flex: 1;
}
main form .formControl .selectDiv {
width: 100%;
}
.formSpace {
width: 100%;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: flex-start;
gap: 1em;
flex: 1;
}
#addOwner, #addVehicle {
visibility: hidden;
opacity: 0;
-webkit-transition: visibility 0s linear 300ms, opacity 300ms;
-moz-transition: visibility 0s linear 300ms, opacity 300ms;
-ms-transition: visibility 0s linear 300ms, opacity 300ms;
-o-transition: visibility 0s linear 300ms, opacity 300ms;
transition: visibility 0s linear 300ms, opacity 300ms;
}
#addOwner.shown, #addVehicle.shown {
visibility: visible;
opacity: 1;
-webkit-transition: visibility 0s linear 0s, opacity 300ms;
-moz-transition: visibility 0s linear 0s, opacity 300ms;
-ms-transition: visibility 0s linear 0s, opacity 300ms;
-o-transition: visibility 0s linear 0s, opacity 300ms;
transition: visibility 0s linear 0s, opacity 300ms;
}
.content {
margin-top: 3em;
}
@@ -0,0 +1,52 @@
@import "nav.css";
div.searchContainer {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
}
main form {
width: 100%;
flex-direction: row;
align-items: center;
}
main#search form input:not([type="submit"]) {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
width: auto;
}
main#search form button {
border-top-right-radius: 0.5em;
border-bottom-right-radius: 0.5em;
width: 20%;
height: 3em;
background-color: var(--primary);
border: none;
outline: none;
color: #FFFFFF;
cursor: pointer;
}
div.searchBtnContainer {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
div.searchBtnContainer:hover input {
border: 4px solid var(--hover);
}
main#search div.searchBtnContainer:hover button {
background-color: var(--hover);
}
.content {
margin-top: 3em;
}
@@ -0,0 +1,249 @@
@import url('https://fonts.googleapis.com/css2?family=Fira+Sans:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,600;1,700;1,800;1,900&family=Yeseva+One&display=swap');
@import "normalize.css";
:root {
--primary: hsla(220, 60%, 50%, 1);
--hover: hsl(240, 50%, 22%);
--secondary: hsl(210, 100%, 95%, 1);
--accent: hsla(15, 99%, 57%, 1);
--light: hsla(90, 8%, 85%, 1);
--mutedBlack: hsla(0, 0%, 0%, 0.25);
}
* {
box-sizing: border-box;
}
html, body {
padding: 0;
margin: 0;
}
body {
font-size: 1em;
font-weight: 400;
font-family: "Fira Sans", sans-serif;
}
h1, h2 {
font-weight: 400;
font-family: "Yeseva One", cursive;
}
.btn {
outline: none;
border: none;
padding: 0.875em 1.75em;
cursor: pointer;
-webkit-border-radius: 1em;
-moz-border-radius: 1em;
border-radius: 1em;
}
.btnPrimary {
background-color: var(--primary);
color: #FFFFFF;
}
.btnPrimary:hover {
background-color: var(--hover);
}
div.formControl {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
gap: 0.5em;
width: 100%;
}
input:not([type="submit"]), form .formControl textarea {
width: 100%;
border: 4px solid var(--primary);
background: 0 0;
outline: 0;
-webkit-border-radius: 1em;
-moz-border-radius: 1em;
border-radius: .5em;
padding: 0 .5em;
height: 3em;
}
input:not([type="submit"]):hover, form .formControl textarea:hover {
border: 4px solid var(--hover);
}
.checkContainer {
display: block;
position: relative;
margin-bottom: 0.75em;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.checkContainer input[type="checkbox"] {
position: absolute;
opacity: 0;
cursor: pointer;
height: 0;
width: 0;
}
.checkmark {
position: absolute;
top: 1.25em;
left: 0;
height: 1.5em;
width: 1.5em;
background-color: #eee;
}
.checkContainer:hover input ~ .checkmark {
background-color: #ccc;
}
.checkContainer input:checked ~ .checkmark {
background-color: var(--primary);
}
.checkContainer:hover input:checked ~ .checkmark {
background-color: var(--hover);
}
.checkmark:after {
content: "";
position: absolute;
display: none;
}
.checkContainer input:checked ~ .checkmark:after {
display: block;
}
.checkContainer .checkmark:after {
left: 9px;
top: 5px;
width: 0.35em;
height: 0.6em;
border: solid white;
border-width: 0 3px 3px 0;
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
.selectDiv {
position: relative;
min-width: 300px;
cursor: pointer;
}
.selectDiv:before {
content: '';
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg);
right: -5px;
top: 13px;
padding: 0 0 2px;
position: absolute;
width: 46px;
background-color: var(--primary);
height: 30px;
border-top-right-radius: 0.5em;
border-top-left-radius: 0.5em;
}
.selectDiv:after {
content: '<>';
font: 18px "Consolas", monospace;
color: #FFFFFF;
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg);
right: 6px;
top: 18px;
padding: 0 0 2px;
position: absolute;
}
.selectDiv select {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
cursor: pointer;
display: block;
outline: none;
width: 100%;
height: 3em;
margin: 6px 0;
padding: 0 24px;
background-color: #ffffff;
background-image: none;
border: 4px solid var(--primary);
-webkit-border-radius: 0.5em;
-moz-border-radius: 0.5em;
border-radius: 0.5em;
word-break: normal;
}
.selectDiv:hover select, .selectDiv select:hover {
border: 4px solid var(--hover);
}
.selectDiv:hover:before {
background-color: var(--hover);
}
table {
border-collapse: collapse;
}
table td, table th {
border: 1px solid #DDDDDD;
padding: 0.5em;
min-width: 7.5em;
}
table tr:nth-child(even) {
background-color: var(--secondary);
}
table tr:hover {
background-color: #ddd;
}
table th {
padding: 0.75em 0;
text-align: left;
background-color: var(--primary);
color: #FFFFFF;
}
main {
padding-top: 2.5em;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
main form {
width: 15%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
gap: 1em;
}
main #title {
align-self: flex-start;
margin-left: 1em;
}
@@ -0,0 +1,304 @@
-- MariaDB dump 10.19 Distrib 10.9.4-MariaDB, for Linux (x86_64)
--
-- Host: mysql.cs.nott.ac.uk Database: psxrp11_dbcw
-- ------------------------------------------------------
-- Server version 5.5.60-MariaDB
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `Fines`
--
DROP TABLE IF EXISTS `Fines`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Fines` (
`Fine_ID` int(11) NOT NULL AUTO_INCREMENT,
`Fine_Amount` int(11) NOT NULL,
`Fine_Points` int(11) NOT NULL,
`Incident_ID` int(11) NOT NULL,
PRIMARY KEY (`Fine_ID`),
KEY `Incident_ID` (`Incident_ID`),
CONSTRAINT `fk_fines` FOREIGN KEY (`Incident_ID`) REFERENCES `Incident` (`Incident_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `Fines`
--
LOCK TABLES `Fines` WRITE;
/*!40000 ALTER TABLE `Fines` DISABLE KEYS */;
INSERT INTO `Fines` (`Fine_ID`, `Fine_Amount`, `Fine_Points`, `Incident_ID`) VALUES (1,2000,6,3),
(2,50,0,2),
(3,500,3,4),
(5,50,2,3);
/*!40000 ALTER TABLE `Fines` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `Incident`
--
DROP TABLE IF EXISTS `Incident`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Incident` (
`Incident_ID` int(11) NOT NULL AUTO_INCREMENT,
`Vehicle_ID` int(11) DEFAULT NULL,
`People_ID` int(11) DEFAULT NULL,
`Incident_Date` date NOT NULL,
`Incident_Report` varchar(500) NOT NULL,
`Offence_ID` int(11) DEFAULT NULL,
PRIMARY KEY (`Incident_ID`),
KEY `fk_incident_vehicle` (`Vehicle_ID`),
KEY `fk_incident_people` (`People_ID`),
KEY `fk_incident_offence` (`Offence_ID`),
CONSTRAINT `fk_incident_offence` FOREIGN KEY (`Offence_ID`) REFERENCES `Offence` (`Offence_ID`),
CONSTRAINT `fk_incident_people` FOREIGN KEY (`People_ID`) REFERENCES `People` (`People_ID`),
CONSTRAINT `fk_incident_vehicle` FOREIGN KEY (`Vehicle_ID`) REFERENCES `Vehicle` (`Vehicle_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `Incident`
--
LOCK TABLES `Incident` WRITE;
/*!40000 ALTER TABLE `Incident` DISABLE KEYS */;
INSERT INTO `Incident` (`Incident_ID`, `Vehicle_ID`, `People_ID`, `Incident_Date`, `Incident_Report`, `Offence_ID`) VALUES (1,12,4,'2017-12-01','40mph in a 30 limit',1),
(2,20,8,'2017-11-01','Double parked',4),
(3,13,4,'2017-09-17','110mph on motorway',1),
(4,14,2,'2017-08-22','Failure to stop at a red light - travelling 25mph',8),
(5,13,4,'2017-10-17','Not wearing a seatbelt on the M1',3);
/*!40000 ALTER TABLE `Incident` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `Logs`
--
DROP TABLE IF EXISTS `Logs`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Logs` (
`Logs_ID` int(11) NOT NULL AUTO_INCREMENT,
`Logs_type` varchar(100) DEFAULT NULL,
`Users_username` varchar(100) DEFAULT NULL,
`Logs_date` datetime DEFAULT NULL,
PRIMARY KEY (`Logs_ID`),
KEY `fk_logs_users` (`Users_username`),
CONSTRAINT `fk_logs_users` FOREIGN KEY (`Users_username`) REFERENCES `Users` (`Users_username`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `Logs`
--
LOCK TABLES `Logs` WRITE;
/*!40000 ALTER TABLE `Logs` DISABLE KEYS */;
INSERT INTO `Logs` (`Logs_ID`, `Logs_type`, `Users_username`, `Logs_date`) VALUES (9,'Add Report','daniels','2022-12-16 13:14:34'),
(10,'Add Report','daniels','2022-12-16 13:15:33'),
(11,'Add Report','daniels','2022-12-16 13:19:58');
/*!40000 ALTER TABLE `Logs` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `Offence`
--
DROP TABLE IF EXISTS `Offence`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Offence` (
`Offence_ID` int(11) NOT NULL AUTO_INCREMENT,
`Offence_description` varchar(50) NOT NULL,
`Offence_maxFine` int(11) NOT NULL,
`Offence_maxPoints` int(11) NOT NULL,
PRIMARY KEY (`Offence_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `Offence`
--
LOCK TABLES `Offence` WRITE;
/*!40000 ALTER TABLE `Offence` DISABLE KEYS */;
INSERT INTO `Offence` (`Offence_ID`, `Offence_description`, `Offence_maxFine`, `Offence_maxPoints`) VALUES (1,'Speeding',1000,3),
(2,'Speeding on a motorway',2500,6),
(3,'Seat belt offence',500,0),
(4,'Illegal parking',500,0),
(5,'Drink driving',10000,11),
(6,'Driving without a licence',10000,0),
(7,'Driving without a licence',10000,0),
(8,'Traffic light offences',1000,3),
(9,'Cycling on pavement',500,0),
(10,'Failure to have control of vehicle',1000,3),
(11,'Dangerous driving',1000,11),
(12,'Careless driving',5000,6),
(13,'Dangerous cycling',2500,0);
/*!40000 ALTER TABLE `Offence` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `Ownership`
--
DROP TABLE IF EXISTS `Ownership`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Ownership` (
`People_ID` int(11) NOT NULL,
`Vehicle_ID` int(11) NOT NULL,
KEY `fk_people` (`People_ID`),
KEY `fk_vehicle` (`Vehicle_ID`),
CONSTRAINT `fk_person` FOREIGN KEY (`People_ID`) REFERENCES `People` (`People_ID`),
CONSTRAINT `fk_vehicle` FOREIGN KEY (`Vehicle_ID`) REFERENCES `Vehicle` (`Vehicle_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `Ownership`
--
LOCK TABLES `Ownership` WRITE;
/*!40000 ALTER TABLE `Ownership` DISABLE KEYS */;
INSERT INTO `Ownership` (`People_ID`, `Vehicle_ID`) VALUES (3,12),
(8,20),
(4,15),
(4,13),
(1,16),
(2,14),
(5,17),
(6,18),
(7,21),
(1,27),
(1,32),
(1,12),
(1,12),
(1,12);
/*!40000 ALTER TABLE `Ownership` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `People`
--
DROP TABLE IF EXISTS `People`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `People` (
`People_ID` int(11) NOT NULL AUTO_INCREMENT,
`People_name` varchar(50) NOT NULL,
`People_address` varchar(50) DEFAULT NULL,
`People_licence` varchar(16) DEFAULT NULL,
PRIMARY KEY (`People_ID`),
UNIQUE KEY `People_pk` (`People_licence`)
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `People`
--
LOCK TABLES `People` WRITE;
/*!40000 ALTER TABLE `People` DISABLE KEYS */;
INSERT INTO `People` (`People_ID`, `People_name`, `People_address`, `People_licence`) VALUES (1,'James Smith','23 Barnsdale Road, Leicester','SMITH92LDOFJJ829'),
(2,'Jennifer Allen','46 Bramcote Drive, Nottingham','ALLEN88K23KLR9B3'),
(3,'John Myers','323 Derby Road, Nottingham','MYERS99JDW8REWL3'),
(4,'James Smith','26 Devonshire Avenue, Nottingham','SMITHR004JFS20TR'),
(5,'Terry Brown','7 Clarke Rd, Nottingham','BROWND3PJJ39DLFG'),
(6,'Mary Adams','38 Thurman St, Nottingham','ADAMSH9O3JRHH107'),
(7,'Neil Becker','6 Fairfax Close, Nottingham','BECKE88UPR840F9R'),
(8,'Angela Smith','30 Avenue Road, Grantham','SMITH222LE9FJ5DS'),
(9,'Xene Medora','22 House Drive, West Bridgford','MEDORH914ANBB223'),
(17,'Rohit Pai','123, midleton road, London','PAI99909048RA9YX');
/*!40000 ALTER TABLE `People` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `Users`
--
DROP TABLE IF EXISTS `Users`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Users` (
`Users_username` varchar(100) NOT NULL,
`Users_password` varchar(100) DEFAULT NULL,
`Users_admin` tinyint(4) DEFAULT '0',
PRIMARY KEY (`Users_username`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `Users`
--
LOCK TABLES `Users` WRITE;
/*!40000 ALTER TABLE `Users` DISABLE KEYS */;
INSERT INTO `Users` (`Users_username`, `Users_password`, `Users_admin`) VALUES ('daniels','copper99',1),
('mcnulty','plod123',0),
('moreland','fuzz42',0);
/*!40000 ALTER TABLE `Users` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `Vehicle`
--
DROP TABLE IF EXISTS `Vehicle`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Vehicle` (
`Vehicle_ID` int(11) NOT NULL AUTO_INCREMENT,
`Vehicle_type` varchar(20) NOT NULL,
`Vehicle_colour` varchar(20) NOT NULL,
`Vehicle_licence` varchar(7) DEFAULT NULL,
PRIMARY KEY (`Vehicle_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `Vehicle`
--
LOCK TABLES `Vehicle` WRITE;
/*!40000 ALTER TABLE `Vehicle` DISABLE KEYS */;
INSERT INTO `Vehicle` (`Vehicle_ID`, `Vehicle_type`, `Vehicle_colour`, `Vehicle_licence`) VALUES (12,'Ford Fiesta','Blue','LB15AJL'),
(13,'Ferrari 458','Red','MY64PRE'),
(14,'Vauxhall Astra','Silver','FD65WPQ'),
(15,'Honda Civic','Green','FJ17AUG'),
(16,'Toyota Prius','Silver','FP16KKE'),
(17,'Ford Mondeo','Black','FP66KLM'),
(18,'Ford Focus','White','DJ14SLE'),
(20,'Nissan Pulsar','Red','NY64KWD'),
(21,'Renault Scenic','Silver','BC16OEA'),
(22,'Hyundai i30','Grey','AD223NG'),
(27,'sdfsdf','sdff','3545fgg'),
(32,'Ford Focus','Red','EA22HNT');
/*!40000 ALTER TABLE `Vehicle` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2022-12-16 13:25:56
@@ -0,0 +1,21 @@
<?php
session_start();
require_once 'config.php';
header('Content-Type: application/json');
if (isset($_SESSION["username"]) && isset($_SESSION["admin"]))
{
$conn = dbConn();
$stmt = $conn->prepare("SELECT * FROM Incident");
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode(array("message" => "ok", "incidents" => $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 "));
}
@@ -0,0 +1,17 @@
<?php
session_start();
require_once 'config.php';
header('Content-Type: application/json');
if (isset($_SESSION["username"]))
{
$conn = dbConn();
$stmt = $conn->prepare("SELECT Offence_ID, Offence_description, Offence_maxFine FROM Offence");
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode(array("message" => "ok", "offences" => $result));
}
else
{
echo json_encode(array("message" => "Not logged in "));
}
@@ -0,0 +1,17 @@
<?php
session_start();
require_once 'config.php';
header('Content-Type: application/json');
if (isset($_SESSION["username"]))
{
$conn = dbConn();
$stmt = $conn->prepare("SELECT People_ID, People_name, People_licence FROM People");
$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 "));
}
@@ -0,0 +1,17 @@
<?php
session_start();
require_once 'config.php';
header('Content-Type: application/json');
if (isset($_SESSION["username"]))
{
$conn = dbConn();
$stmt = $conn->prepare("SELECT Vehicle_type, People_name, Incident_Date, Incident_Report, Offence_description FROM Incident INNER JOIN People P on Incident.People_ID = P.People_ID INNER JOIN Vehicle V on Incident.Vehicle_ID = V.Vehicle_ID INNER JOIN Offence O on Incident.Offence_ID = O.Offence_ID;");
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode(array("message" => "ok", "data" => $result));
}
else
{
echo json_encode(array("message" => "Not logged in "));
}
@@ -0,0 +1,17 @@
<?php
session_start();
require_once 'config.php';
header('Content-Type: application/json');
if (isset($_SESSION["username"]))
{
$conn = dbConn();
$stmt = $conn->prepare("SELECT Vehicle_ID, Vehicle_type, Vehicle_licence FROM Vehicle");
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode(array("message" => "ok", "vehicles" => $result));
}
else
{
echo json_encode(array("message" => "Not logged in "));
}
@@ -0,0 +1,33 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Login</title>
<link rel="stylesheet" href="css/login.css">
</head>
<body>
<main>
<div class="login">
<h1>Login To Traffic Reporter</h1>
<form method="POST" class="loginForm" id="login">
<div class="formControl">
<label for="username">Username</label>
<input type="text" name="username" id="username" required>
</div>
<div class="formControl">
<label for="password">Password</label>
<input type="password" name="password" id="password" required>
</div>
<input type="submit" value="Login" class="btn btnPrimary">
</form>
</div>
</main>
<script src="js/login.js"></script>
</body>
</html>
@@ -0,0 +1,11 @@
<?php
session_start();
header('Content-Type: application/json');
if ($_SESSION["admin"])
{
echo json_encode(array("message" => "ok", "admin" => $_SESSION["admin"]));
}
else
{
echo json_encode(array("message" => "not logged in as admin"));
}
@@ -0,0 +1,11 @@
<?php
session_start();
header('Content-Type: application/json');
if (isset($_SESSION["username"]))
{
echo json_encode(array("message" => "ok", "username" => $_SESSION["username"], "admin" => $_SESSION["admin"]));
}
else
{
echo json_encode(array("message" => "not logged in"));
}
@@ -0,0 +1,41 @@
document.addEventListener("DOMContentLoaded", () =>
{
fetch("getIncidents.php").then(res => res.json().then(json =>
{
if(json.message === "ok")
{
let body = "";
for (const incident of json.incidents)
{
body += `<option value="${incident.Incident_ID}">${incident.Incident_Report}${incident.Incident_Date}</option>`;
}
document.querySelector("#incident").innerHTML = body;
}
}));
});
document.querySelector("#addFineForm").addEventListener("submit", e =>
{
e.preventDefault();
let formData = new FormData();
formData.append("amount", document.querySelector("#amount").value);
formData.append("points", document.querySelector("#points").value);
formData.append("incident", document.querySelector("#incident").value)
fetch("addFine.php", {
method: "POST",
body: formData
}).then(res => res.json().then(json => {
if(json.message === "ok")
{
alert("Fine added successfully");
}
else
{
alert("Error adding fine");
}
}));
});
@@ -0,0 +1,30 @@
// Change Password stuff
document.querySelector("#changePass").addEventListener("submit", e =>
{
e.preventDefault();
let formData = new FormData();
if (document.querySelector("#pass").value !== document.querySelector("#rePass").value)
{
alert("Passwords do not match");
}
else
{
formData.append("password", document.querySelector("#rePass").value);
fetch("changePassword.php", {
method: "POST",
body: formData
}).then(res => res.json().then(json =>
{
if (json.message === "ok")
{
alert("Password changed successfully");
}
else
{
alert(json.message);
}
}));
}
});
@@ -0,0 +1,35 @@
document.addEventListener("DOMContentLoaded", () =>
{
fetch("isLoggedIn.php").then(res => res.json().then(json =>
{
if (json.message !== "ok")
{
window.location.href = "./";
}
else
{
document.querySelector("#title h1").innerText = "Logged in as: " + json.username;
let adminLinks = document.querySelectorAll(".admin");
for (let adminLink of adminLinks)
{
if (json.admin === true)
{
adminLink.style.display = "block";
}
}
}
}));
});
document.querySelector("#logout").addEventListener("click", e =>
{
e.preventDefault();
fetch("logout.php").then(res => res.json().then(json =>
{
if (json.message === "ok")
{
window.location.href = "./";
}
}));
});
@@ -0,0 +1,35 @@
// Login stuff
document.addEventListener("DOMContentLoaded", () =>
{
fetch("isLoggedIn.php").then(res => res.json().then(json =>
{
if (json.message === "ok")
{
window.location.href = "./search.html";
}
}));
});
document.querySelector("#login").addEventListener("submit", e =>
{
e.preventDefault();
let formData = new FormData();
formData.append("username", document.querySelector("#username").value);
formData.append("password", document.querySelector("#password").value);
fetch("login.php", {
method: "POST",
body: formData
}).then(res => res.json().then(json =>
{
if (json.message === "ok")
{
window.location.href = "search.html";
}
else
{
alert(json.message);
}
}));
});
@@ -0,0 +1,51 @@
// create new a user stuff
document.addEventListener("DOMContentLoaded", () =>
{
fetch("isAdmin.php").then(res => res.json().then(json =>
{
if (json.message !== "ok")
{
window.location.href = "./search.html";
}
}));
});
document.querySelector("#createUser").addEventListener("submit", e =>
{
e.preventDefault();
let username = document.querySelector("#username").value;
let password = document.querySelector("#pass").value;
let rePass = document.querySelector("#rePass").value;
let admin = document.querySelector("#isAdmin").checked;
if (password === "" || rePass === "" || username === "")
{
alert("Please fill in all fields");
}
else if (password !== rePass)
{
alert("Passwords do not match");
}
else
{
let data = new FormData();
data.append("username", username);
data.append("password", password);
data.append("admin", admin);
fetch("newUser.php", {
method: "POST",
body: data
}).then(res => res.json().then(json =>
{
if (json.message === "ok")
{
alert("User created");
}
else
{
alert("Error creating user");
}
}));
}
});
@@ -0,0 +1,67 @@
document.addEventListener("DOMContentLoaded", () =>
{
fetch("getOwners.php").then(res => res.json().then(json =>
{
if(json.message === "ok")
{
let body = "";
for (const owner of json.owners)
{
body += `<option value="${owner.People_ID}">${owner.People_name} - ${owner.People_licence}</option>`;
}
body += `<option value="new">New Owner</option>`;
document.querySelector("#owner").innerHTML = body;
}
}));
});
document.querySelector("#owner").addEventListener("change", e =>
{
let inputs = document.querySelectorAll("#addOwner input");
if (e.target.value === "new")
{
document.querySelector("#addOwner").classList.add("shown");
for (const input of inputs)
{
input.setAttribute("required", "");
}
}
else
{
document.querySelector("#addOwner").classList.remove("shown");
for (const input of inputs)
{
input.removeAttribute("required");
}
}
});
document.querySelector("#vehicleForm").addEventListener("submit", e =>
{
e.preventDefault();
let formData = new FormData();
formData.append("type", document.querySelector("#type").value);
formData.append("colour", document.querySelector("#colour").value);
formData.append("plateNum", document.querySelector("#plateNum").value);
if (document.querySelector("#owner").value === "new")
{
formData.append("name", document.querySelector("#name").value);
formData.append("address", document.querySelector("#address").value);
formData.append("licence", document.querySelector("#licence").value);
}
else
{
formData.append("peopleID", document.querySelector("#owner").value);
}
fetch("addVehicle.php", {
method: "POST",
body: formData
}).then(res => res.json().then(json =>
{
alert(json.message);
}));
});
@@ -0,0 +1,165 @@
document.addEventListener("DOMContentLoaded", () =>
{
fetch("getOwners.php").then(res => res.json().then(json =>
{
if(json.message === "ok")
{
let body = "";
for (const owner of json.owners)
{
body += `<option value="${owner.People_ID}">${owner.People_name} - ${owner.People_licence}</option>`;
}
body += `<option value="new">New Owner</option>`;
document.querySelector("#owner").innerHTML = body;
}
}));
fetch("getVehicles.php").then(res => res.json().then(json =>
{
if (json.message === "ok")
{
let body = "";
for (const owner of json.vehicles)
{
body += `<option value="${owner.Vehicle_ID}">${owner.Vehicle_type} - ${owner.Vehicle_licence}</option>`;
}
body += `<option value="new">New Vehicle</option>`;
document.querySelector("#vehicle").innerHTML = body;
}
}));
fetch("getOffences.php").then(res => res.json().then(json =>
{
if (json.message === "ok")
{
let body = "";
for (const owner of json.offences)
{
body += `<option value="${owner.Offence_ID}">${owner.Offence_description} - ${owner.Offence_maxFine}</option>`;
}
body += `<option value="new">New Vehicle</option>`;
document.querySelector("#offence").innerHTML = body;
}
}));
fetch("getReports.php").then(res => res.json().then(json =>
{
if (json.message === "ok")
{
document.querySelector("#reportsResults thead tr").innerHTML = "";
document.querySelector("#reportsResults tbody").innerHTML = "";
for (const key of Object.keys(json.data[0]))
{
let header = key.substring(key.indexOf("_") + 1)
header = header.charAt(0).toUpperCase() + header.slice(1);
document.querySelector("#reportsResults thead tr").innerHTML += `<th>${header}</th>`;
}
let body = "";
for (const row of json.data)
{
body += "<tr>";
for (const key of Object.keys(row))
{
body += `<td>${(row[key] === "null" || row[key] === null) ? "N/A" : row[key]}</td>`;
}
body += "</tr>";
}
document.querySelector("#reportsResults tbody").innerHTML = body;
}
}));
});
document.querySelector("#owner").addEventListener("change", e =>
{
let inputs = document.querySelectorAll("#addOwner input");
if (e.target.value === "new")
{
document.querySelector("#addOwner").classList.add("shown");
for (const input of inputs)
{
input.setAttribute("required", "");
}
}
else
{
document.querySelector("#addOwner").classList.remove("shown");
for (const input of inputs)
{
input.removeAttribute("required");
}
}
});
document.querySelector("#vehicle").addEventListener("change", e =>
{
let inputs = document.querySelectorAll("#addVehicle input");
if (e.target.value === "new")
{
document.querySelector("#addVehicle").classList.add("shown");
for (const input of inputs)
{
input.setAttribute("required", "");
}
}
else
{
document.querySelector("#addVehicle").classList.remove("shown");
for (const input of inputs)
{
input.removeAttribute("required");
}
}
});
document.querySelector("#reports").addEventListener("click", e =>
{
e.preventDefault();
let formData = new FormData();
formData.append("incidentReport", document.querySelector("#incidentReport").value);
formData.append("incidentDate", document.querySelector("#incidentDate").value);
if (document.querySelector("#owner").value === "new")
{
formData.append("name", document.querySelector("#name").value);
formData.append("address", document.querySelector("#address").value);
formData.append("licence", document.querySelector("#licence").value);
}
else
{
formData.append("peopleID", document.querySelector("#owner").value);
}
if (document.querySelector("#vehicle").value === "new")
{
formData.append("type", document.querySelector("#type").value);
formData.append("colour", document.querySelector("#colour").value);
formData.append("plateNumber", document.querySelector("#plateNum").value);
}
else
{
formData.append("vehicleID", document.querySelector("#vehicle").value);
}
formData.append("offenceID", document.querySelector("#offence").value);
fetch("newReport.php",{
method: "POST",
body: formData
}).then(res => res.json().then(json =>
{
if (json.message === "ok")
{
window.location.reload();
}
else
{
alert("Error adding report");
}
}));
});
@@ -0,0 +1,59 @@
//Search stuff
document.querySelector("#searchType").addEventListener("change", e =>
{
if (e.target.value === "pn")
{
document.querySelector("#searchField").placeholder = "Find vehicle";
}
else
{
document.querySelector("#searchField").placeholder = "Find owner";
}
});
document.querySelector("#searchForm").addEventListener("submit", e =>
{
e.preventDefault();
let formData = new FormData();
formData.append("searchType", document.querySelector("#searchType").value);
formData.append("searchField", document.querySelector("#searchField").value);
fetch("search.php", {
method: "POST",
body: formData
}).then(res => res.json().then(json =>
{
if (json.message === "ok")
{
document.querySelector("#searchResults thead tr").innerHTML = "";
document.querySelector("#searchResults tbody").innerHTML = "";
for (const key of Object.keys(json.data[0]))
{
let header = key.substring(key.indexOf("_") + 1)
header = header.charAt(0).toUpperCase() + header.slice(1);
document.querySelector("#searchResults thead tr").innerHTML += `<th>${header}</th>`;
}
let body = "";
for (const row of json.data)
{
body += "<tr>";
for (const key of Object.keys(row))
{
body += `<td>${(row[key] === "null" || row[key] === null) ? "N/A" : row[key]}</td>`;
}
body += "</tr>";
}
document.querySelector("#searchResults tbody").innerHTML = body;
}
else
{
alert("No search results found");
}
}));
});
@@ -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 += `<th>${header}</th>`;
}
let body = "";
for (const row of json.logs)
{
body += "<tr>";
for (const key of Object.keys(row))
{
body += `<td>${row[key]}</td>`;
}
body += "</tr>";
}
document.querySelector("#logTable tbody").innerHTML = body;
}
}));
});
@@ -0,0 +1,25 @@
<?php
session_start();
require_once 'config.php';
header('Content-Type: application/json');
$username = $_POST["username"];
$password = $_POST["password"];
$conn = dbConn();
$stmt = $conn->prepare("SELECT * FROM Users WHERE Users_username = :username AND Users_password = :password");
$stmt->bindParam(":username", $username);
$stmt->bindParam(":password", $password);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
if (count($result) > 0)
{
$_SESSION["username"] = $username;
$_SESSION["admin"] = $result[0]["Users_admin"] === "1";
echo json_encode(array("message" => "ok"));
}
else
{
echo json_encode(array("message" => "Username or password is incorrect"));
}
@@ -0,0 +1,4 @@
<?php
session_start();
session_destroy();
echo json_encode(array("message" => "ok"));
@@ -0,0 +1,57 @@
<?php
session_start();
require_once 'config.php';
header('Content-Type: application/json');
if (isset($_SESSION["username"]))
{
$conn = dbConn();
$incidentReport = $_POST["incidentReport"];
$incidentDate = $_POST["incidentDate"];
$peopleID = $_POST["peopleID"];
$vehicleID = $_POST["vehicleID"];
$offenceID = $_POST["offenceID"];
if (isset($_POST["type"]) && isset($_POST["colour"]) && isset($_POST["plateNum"]))
{
$stmt = $conn->prepare("INSERT INTO Vehicle (Vehicle_type, Vehicle_colour, Vehicle_licence) VALUES (:type, :colour, :plateNum)");
$stmt->bindParam(":type", $_POST["type"]);
$stmt->bindParam(":colour", $_POST["colour"]);
$stmt->bindParam(":plateNum", $_POST["plateNum"]);
$stmt->execute();
$vehicleID = $conn->lastInsertId();
}
if (isset($_POST["name"]) && isset($_POST["address"]) && isset($_POST["licence"]))
{
$stmtPeople = $conn->prepare("INSERT INTO People (People_name, People_address, People_licence) VALUES (:name, :address, :licence)");
$stmtPeople->bindParam(":name", $_POST["name"]);
$stmtPeople->bindParam(":address", $_POST["address"]);
$stmtPeople->bindParam(":licence", $_POST["licence"]);
$stmtPeople->execute();
$peopleID = $conn->lastInsertId();
}
$stmtOwner = $conn->prepare("INSERT INTO Ownership (Vehicle_ID, People_ID) VALUES (:vehicleID, :peopleID)");
$stmtOwner->bindParam(":vehicleID", $vehicleID);
$stmtOwner->bindParam(":peopleID", $peopleID);
$stmtOwner->execute();
$stmt = $conn->prepare("INSERT INTO Incident (Incident_report, Incident_date, People_ID, Vehicle_ID, Offence_ID) VALUES (:incidentReport, :incidentDate, :peopleID, :vehicleID, :offenceID)");
$stmt->bindParam(":incidentReport", $incidentReport);
$stmt->bindParam(":incidentDate", $incidentDate);
$stmt->bindParam(":peopleID", $peopleID);
$stmt->bindParam(":vehicleID", $vehicleID);
$stmt->bindParam(":offenceID", $offenceID);
$stmt->execute();
$logSQL = "INSERT INTO Logs (Logs_type, Users_username, Logs_date) VALUES ('Add Report', :username, NOW())";
$logStmt = $conn->prepare($logSQL);
$logStmt->bindParam(":username", $_SESSION["username"]);
$logStmt->execute();
echo json_encode(array("message" => "ok"));
}
else
{
echo json_encode(array("message" => "Not logged in"));
}
@@ -0,0 +1,57 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Create New User</title>
<link rel="stylesheet" href="css/nav.css">
</head>
<body>
<nav>
<ul>
<li><a href="search.html" class="btn">Search</a></li>
<li><a href="addVehicle.html" class="btn">Add new vehicle</a></li>
<li><a href="reports.html" class="btn">Reports</a></li>
<li class="admin"><a href="newUser.html" class="btn active">Create new user</a></li>
<li class="admin"><a href="addFine.html" class="btn">Add Fines</a></li>
<li class="admin"><a href="viewLog.html" class="btn">View log</a></li>
<li><a href="changePassword.html" class="btn">Change password</a></li>
<li><a id="logout" class="btn">Logout</a></li>
</ul>
</nav>
<main>
<header id="title">
<h1></h1>
</header>
<form method="POST" id="createUser">
<div class="formControl">
<label for="username">Username</label>
<input type="text" name="username" id="username">
</div>
<div class="formControl">
<label for="pass">Password</label>
<input type="password" name="pass" id="pass">
</div>
<div class="formControl">
<label for="rePass">Retype Password</label>
<input type="password" name="rePass" id="rePass">
</div>
<div class="formControl">
<label for="isAdmin" class="checkContainer">Is Admin
<input type="checkbox" name="isAdmin" id="isAdmin">
<span class="checkmark"></span>
</label>
</div>
<input type="submit" value="Create New User" class="btn btnPrimary" style="margin-top: 1em;">
</form>
</main>
<script src="js/checkUser.js"></script>
<script src="js/newUser.js"></script>
</body>
</html>
@@ -0,0 +1,36 @@
<?php
session_start();
require_once 'config.php';
header('Content-Type: application/json');
if (isset($_SESSION["username"]) && isset($_SESSION["admin"]))
{
$username = $_POST["username"];
$password = $_POST["password"];
$admin = $_POST["admin"];
$conn = dbConn();
$stmt = $conn->prepare("INSERT INTO Users (Users_username, Users_password, Users_admin) VALUES (:username, :password, :admin)");
$stmt->bindParam(":username", $username);
$stmt->bindParam(":password", $password);
$isAdmin = $admin ? 1 : 0;
$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"]))
{
echo json_encode(array("message" => "not logged in as admin"));
}
else
{
echo json_encode(array("message" => "Not logged in "));
}
@@ -0,0 +1,123 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Reports</title>
<link rel="stylesheet" href="css/reports.css">
</head>
<body>
<nav>
<ul>
<li><a href="search.html" class="btn">Search</a></li>
<li><a href="addVehicle.html" class="btn">Add new vehicle</a></li>
<li><a href="reports.html" class="btn active">Reports</a></li>
<li class="admin"><a href="newUser.html" class="btn">Create new user</a></li>
<li class="admin"><a href="addFine.html" class="btn">Add Fines</a></li>
<li class="admin"><a href="viewLog.html" class="btn">View log</a></li>
<li><a href="changePassword.html" class="btn">Change password</a></li>
<li><a id="logout" class="btn">Logout</a></li>
</ul>
</nav>
<main>
<header id="title">
<h1></h1>
</header>
<form>
<div class="formGroup">
<div class="formSpace">
<div class="formControl">
<label for="type">Incident Report</label>
<input type="text" name="type" id="incidentReport" required>
</div>
<div class="formControl">
<label for="colour">Incident Date</label>
<input type="date" name="colour" id="incidentDate" required>
</div>
<div class="formControl">
<label for="owner">Owner</label>
<div class="selectDiv">
<select name="owner" id="owner" required>
</select>
</div>
</div>
<div class="formControl">
<label for="vehicle">Vehicle</label>
<div class="selectDiv">
<select name="owner" id="vehicle" required>
</select>
</div>
</div>
<div class="formControl">
<label for="offence">Offence</label>
<div class="selectDiv">
<select name="owner" id="offence" required>
</select>
</div>
</div>
<input type="submit" id="reports" value="Add new report" class="btn btnPrimary">
</div>
<div class="formSpace" id="addOwner">
<div class="formControl">
<label for="name">Name</label>
<input type="text" name="name" id="name">
</div>
<div class="formControl">
<label for="address">Address</label>
<input type="text" name="address" id="address">
</div>
<div class="formControl">
<label for="licence">Licence number</label>
<input type="text" name="licence" id="licence" maxlength="16" max="16">
</div>
</div>
<div class="formSpace" id="addVehicle">
<div class="formControl">
<label for="type">Type</label>
<input type="text" name="type" id="type" required>
</div>
<div class="formControl">
<label for="colour">Colour</label>
<input type="text" name="colour" id="colour" required>
</div>
<div class="formControl">
<label for="plateNum">Plate Number</label>
<input type="text" name="plateNum" id="plateNum" required>
</div>
</div>
</div>
</form>
<div class="content">
<table id="reportsResults">
<thead>
<tr>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</main>
<script src="js/checkUser.js"></script>
<script src="js/reports.js"></script>
</body>
</html>
@@ -0,0 +1,58 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Search</title>
<link rel="stylesheet" href="css/search.css">
<script src="https://kit.fontawesome.com/ed3c25598e.js" crossorigin="anonymous"></script>
</head>
<body>
<nav>
<ul>
<li><a href="search.html" class="btn active">Search</a></li>
<li><a href="addVehicle.html" class="btn">Add new vehicle</a></li>
<li><a href="reports.html" class="btn">Reports</a></li>
<li class="admin"><a href="newUser.html" class="btn">Create new user</a></li>
<li class="admin"><a href="addFine.html" class="btn">Add Fines</a></li>
<li class="admin"><a href="viewLog.html" class="btn">View log</a></li>
<li><a href="changePassword.html" class="btn">Change password</a></li>
<li><a id="logout" class="btn">Logout</a></li>
</ul>
</nav>
<main id="search">
<header id="title">
<h1></h1>
</header>
<div class="searchContainer">
<form method="POST" id="searchForm">
<div class="selectDiv">
<select name="searchType" id="searchType">
<option value="dln">Name/Driving licence number</option>
<option value="pn">Plate Number</option>
</select>
</div>
<div class="searchBtnContainer">
<input type="text" id="searchField" name="searchField" placeholder="Find owner" required>
<button type="submit"><i class="fa-solid fa-magnifying-glass"></i></button>
</div>
</form>
</div>
<div class="content">
<table id="searchResults">
<thead>
<tr>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</main>
<script src="js/checkUser.js"></script>
<script src="js/search.js"></script>
</body>
</html>
@@ -0,0 +1,49 @@
<?php
session_start();
require_once 'config.php';
header('Content-Type: application/json');
if (isset($_SESSION["username"]))
{
$searchType = $_POST["searchType"];
$searchField = $_POST["searchField"];
$conn = dbConn();
if ($searchType === "dln")
{
$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);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
if (count($result) > 0)
{
echo json_encode(array("message" => "ok", "data" => $result));
}
else
{
echo json_encode(array("message" => "No results found"));
}
}
else
{
echo json_encode(array("message" => "Not logged in"));
}
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>View Log</title>
<link rel="stylesheet" href="css/nav.css">
</head>
<body>
<nav>
<ul>
<li><a href="search.html" class="btn">Search</a></li>
<li><a href="addVehicle.html" class="btn">Add new vehicle</a></li>
<li><a href="reports.html" class="btn">Reports</a></li>
<li class="admin"><a href="newUser.html" class="btn">Create new user</a></li>
<li class="admin"><a href="addFine.html" class="btn">Add Fines</a></li>
<li class="admin"><a href="viewLog.html" class="btn active">View log</a></li>
<li><a href="changePassword.html" class="btn">Change password</a></li>
<li><a id="logout" class="btn">Logout</a></li>
</ul>
</nav>
<main id="search">
<header id="title">
<h1></h1>
</header>
<div class="content">
<table id="logTable">
<thead>
<tr>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</main>
<script src="js/checkUser.js"></script>
<script src="js/viewLog.js"></script>
</body>
</html>
@@ -0,0 +1,21 @@
<?php
session_start();
require_once 'config.php';
header('Content-Type: application/json');
if (isset($_SESSION["username"]) && isset($_SESSION["admin"]))
{
$conn = dbConn();
$stmt = $conn->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 "));
}
@@ -0,0 +1,53 @@
username: psxrp11
student id: 20450011
url: http://mersey.cs.nott.ac.uk/~psxrp11/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/
List of Files
└── DIS-COMP4039-CW2-psxrp11-20450011
├── psxrp11-20450011_cover.txt
└── psxrp11-20450011_InstallationFiles
├── addFine.html
├── addFine.php
├── addVehicle.html
├── addVehicle.php
├── changePassword.html
├── changePassword.php
├── config.php
├── css
│   ├── login.css
│   ├── nav.css
│   ├── newVehicle.css
│   ├── normalize.css
│   ├── reports.css
│   ├── search.css
│   └── template.css
├── final.sql
├── getIncidents.php
├── getOffences.php
├── getOwners.php
├── getVehicles.php
├── index.html
├── isAdmin.php
├── isLoggedIn.php
├── js
│   ├── addFine.js
│   ├── changePassword.js
│   ├── checkUser.js
│   ├── login.js
│   ├── newUser.js
│   ├── newVehicle.js
│   ├── reports.js
│   ├── search.js
│   └── viewLog.js
├── login.php
├── logout.php
├── newReport.php
├── newUser.html
├── newUser.php
├── reports.html
├── search.html
├── search.php
├── viewLog.html
└── viewLog.php
4 directories, 42 files