From cd9b25451e90d428edbf13085266104617c3a378 Mon Sep 17 00:00:00 2001
From: James
Date: Tue, 21 Jan 2025 22:50:05 +0000
Subject: [PATCH 01/86] testing new navbar
---
dashboard/dashboard.php | 6 +++---
server/main_navbar.php | 18 ++++++++++++++++++
2 files changed, 21 insertions(+), 3 deletions(-)
create mode 100644 server/main_navbar.php
diff --git a/dashboard/dashboard.php b/dashboard/dashboard.php
index 69f99ac..fe001e3 100644
--- a/dashboard/dashboard.php
+++ b/dashboard/dashboard.php
@@ -10,6 +10,7 @@
// Include the database connection file
include "../server/db_connect.php";
+include "../server/main_navbar.php";
$time = time();
@@ -112,13 +113,12 @@
Hours Tracking - Dashboard
+ -->
diff --git a/server/main_navbar.php b/server/main_navbar.php
new file mode 100644
index 0000000..7042666
--- /dev/null
+++ b/server/main_navbar.php
@@ -0,0 +1,18 @@
+
\ No newline at end of file
From e43720b1b34550ef9146d5f231a82585ac95218b Mon Sep 17 00:00:00 2001
From: James
Date: Tue, 21 Jan 2025 23:19:34 +0000
Subject: [PATCH 02/86] added: new notes styling
---
assets/style/style.css | 21 ++++++++++++++++++++-
bigtable/bigtable.php | 23 +++++++++++++++++------
bigtable/{notes.php => view_notes.php} | 0
3 files changed, 37 insertions(+), 7 deletions(-)
rename bigtable/{notes.php => view_notes.php} (100%)
diff --git a/assets/style/style.css b/assets/style/style.css
index c62d2b9..748ff28 100644
--- a/assets/style/style.css
+++ b/assets/style/style.css
@@ -538,9 +538,28 @@ select option {
display: flex;
justify-content: center;
align-items: center;
- padding-top: 10px;
}
.centered-form form {
text-align: center; /* Align content inside the form */
+}
+
+.table_button{
+ color: #1d70b8;
+ position: relative;
+ font-family: roboto;
+ font-size: 20px;
+ font-weight: bold;
+ background-color: transparent;
+ border: none;
+ text-decoration: none;
+ cursor: pointer;
+ border-bottom: none;
+ padding-bottom: 3px;
+}
+
+.table_button:hover {
+ text-decoration: none;
+ color: #003078;
+ border-bottom: 2px solid #003078;
}
\ No newline at end of file
diff --git a/bigtable/bigtable.php b/bigtable/bigtable.php
index 7891722..696be3e 100644
--- a/bigtable/bigtable.php
+++ b/bigtable/bigtable.php
@@ -141,21 +141,32 @@ class="search_bar"
echo "" . htmlspecialchars($value, ENT_QUOTES) . " ";
}
echo "
+
-
";
+
+ ";
echo "
- ";
+
+
+
+ View Notes
+
+
+
+
+ ";
echo "";
}
diff --git a/bigtable/notes.php b/bigtable/view_notes.php
similarity index 100%
rename from bigtable/notes.php
rename to bigtable/view_notes.php
From 4050ff04e60e09c50784fd98b320ff88628611ba Mon Sep 17 00:00:00 2001
From: James
Date: Tue, 21 Jan 2025 23:22:42 +0000
Subject: [PATCH 03/86] fixed: table style
---
assets/style/style.css | 4 ++--
bigtable/bigtable.php | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/assets/style/style.css b/assets/style/style.css
index 748ff28..46d6c66 100644
--- a/assets/style/style.css
+++ b/assets/style/style.css
@@ -536,8 +536,8 @@ select option {
.centered-form {
display: flex;
- justify-content: center;
- align-items: center;
+ /* justify-content: center;
+ align-items: center; */
}
.centered-form form {
diff --git a/bigtable/bigtable.php b/bigtable/bigtable.php
index 696be3e..7801a65 100644
--- a/bigtable/bigtable.php
+++ b/bigtable/bigtable.php
@@ -125,10 +125,10 @@ class="search_bar"
echo "";
echo "";
foreach ($custom_headings as $heading) {
- echo "" . htmlspecialchars($heading, ENT_QUOTES) . " ";
+ echo "" . htmlspecialchars($heading, ENT_QUOTES) . " ";
}
- echo "Actions ";
- echo "Notes ";
+ echo "Actions ";
+ echo "Notes ";
echo " ";
foreach ($results as $row) {
From 339c0e1dc1a6291eef10dd608b0f2ed7296e2c11 Mon Sep 17 00:00:00 2001
From: James
Date: Wed, 22 Jan 2025 00:11:24 +0000
Subject: [PATCH 04/86] added: better notes
---
assets/style/style.css | 2 +-
bigtable/bigtable.php | 3 +-
bigtable/create_notes.php | 87 ++++++++++++++++++++++++++++
bigtable/view_notes.php | 116 +++++++++++++++-----------------------
4 files changed, 134 insertions(+), 74 deletions(-)
create mode 100644 bigtable/create_notes.php
diff --git a/assets/style/style.css b/assets/style/style.css
index 46d6c66..ff9a711 100644
--- a/assets/style/style.css
+++ b/assets/style/style.css
@@ -561,5 +561,5 @@ select option {
.table_button:hover {
text-decoration: none;
color: #003078;
- border-bottom: 2px solid #003078;
+ border-bottom: 4px solid #003078;
}
\ No newline at end of file
diff --git a/bigtable/bigtable.php b/bigtable/bigtable.php
index 7801a65..5e07ab6 100644
--- a/bigtable/bigtable.php
+++ b/bigtable/bigtable.php
@@ -154,18 +154,19 @@ class="search_bar"
+
Create Notes
+
View Notes
-
";
echo "";
}
diff --git a/bigtable/create_notes.php b/bigtable/create_notes.php
new file mode 100644
index 0000000..f967d5f
--- /dev/null
+++ b/bigtable/create_notes.php
@@ -0,0 +1,87 @@
+Staff code not found. Please log in again.");
+}
+
+$staff_code = $_SESSION['staff_code']; // Get the staff_code from session
+
+// Redirect back if the required data is missing
+if (!$student_id || !$takes_id) {
+ die("Invalid request. Missing student or medication data.
");
+}
+
+// Handle form submission
+if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['content'])) {
+ $content = trim($_POST['content']);
+ $note_date = $_POST['note_date']; // Get the date from the form input
+ $note_time = $_POST['note_time']; // Get the time from the form input
+
+ // Combine date and time into a single string
+ $full_note_datetime = $note_date . ' ' . $note_time;
+
+ // Validate that the user has entered a valid date and time
+ if (empty($content)) {
+ echo "Note content cannot be empty.
";
+ } elseif (empty($note_date) || empty($note_time)) {
+ echo "Please select both date and time for the note.
";
+ } else {
+ try {
+ // Insert the note with the user-selected date and time, and the staff_code
+ $sql = "INSERT INTO notes (takes_id, content, created_at, staff_code)
+ VALUES (:takes_id, :content, :created_at, :staff_code)";
+ $stmt = $conn->prepare($sql);
+ $stmt->bindParam(':takes_id', $takes_id, PDO::PARAM_INT);
+ $stmt->bindParam(':content', $content, PDO::PARAM_STR);
+ $stmt->bindParam(':created_at', $full_note_datetime, PDO::PARAM_STR);
+ $stmt->bindParam(':staff_code', $staff_code, PDO::PARAM_STR);
+ $stmt->execute();
+
+ echo "Note added successfully!
";
+ } catch (PDOException $e) {
+ die("Database error: " . htmlspecialchars($e->getMessage(), ENT_QUOTES) . "
");
+ }
+ }
+}
+?>
+
+
+
+
+ Create Notes
+
+
+
+
+
+
diff --git a/bigtable/view_notes.php b/bigtable/view_notes.php
index cd59d71..3c1373d 100644
--- a/bigtable/view_notes.php
+++ b/bigtable/view_notes.php
@@ -1,81 +1,53 @@
-
-
-Hours Tracking - View Notes
-
-
-
prepare($sql);
- $stmt->bindParam(':student_id', $student_id, PDO::PARAM_INT);
- $stmt->execute();
+// Get student_id and takes_id from the GET request
+$student_id = isset($_GET['student_id']) ? intval($_GET['student_id']) : null;
+$takes_id = isset($_GET['takes_id']) ? intval($_GET['takes_id']) : null;
- // Fetch results
- $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
-
- // Display the table
- echo "
Log Records for Student ID: " . htmlspecialchars($student_id) . " ";
- if ($results) {
- echo "
";
- echo "
- Log ID
- Date Logged
- Notes
- ";
-
- foreach ($results as $row) {
- echo "";
- echo "" . htmlspecialchars($row['log_id']) . " ";
- echo "" . htmlspecialchars(date('d/m/Y H:i', $row['date_time'])) . " ";
- echo "" . htmlspecialchars($row['notes']) . " ";
- echo " ";
- }
+// Validate the inputs
+if (!$student_id || !$takes_id) {
+ die("Invalid request. Missing student or medication data.
");
+}
- echo "
";
- } else {
- echo "
No records found for this student.
";
+try {
+ // Query to fetch notes along with staff_code for the specified student and takes_id
+ $sql = "SELECT notes.note_id, notes.content, notes.created_at,
+ students.first_name, students.last_name,
+ med.med_name, notes.staff_code
+ FROM notes
+ INNER JOIN takes ON notes.takes_id = takes.takes_id
+ INNER JOIN students ON takes.student_id = students.student_id
+ INNER JOIN med ON takes.med_id = med.med_id
+ WHERE takes.takes_id = :takes_id AND students.student_id = :student_id";
+
+ $stmt = $conn->prepare($sql);
+ $stmt->bindParam(':takes_id', $takes_id, PDO::PARAM_INT);
+ $stmt->bindParam(':student_id', $student_id, PDO::PARAM_INT);
+ $stmt->execute();
+
+ $notes = $stmt->fetchAll(PDO::FETCH_ASSOC);
+
+ echo "
Notes for " . htmlspecialchars($notes[0]['first_name'], ENT_QUOTES) . " " . htmlspecialchars($notes[0]['last_name'], ENT_QUOTES) . " ";
+ echo "
Medication: " . htmlspecialchars($notes[0]['med_name'], ENT_QUOTES) . " ";
+
+ if ($notes) {
+ echo "
";
+ echo "Staff Code Content Created At ";
+
+ foreach ($notes as $note) {
+ echo "";
+ echo "" . htmlspecialchars($note['staff_code'], ENT_QUOTES) . " "; // Display the staff_code from notes table
+ echo "" . htmlspecialchars($note['content'], ENT_QUOTES) . " ";
+ echo "" . htmlspecialchars(date('d/m/Y H:i', strtotime($note['created_at'])), ENT_QUOTES) . " ";
+ echo " ";
}
- } catch (PDOException $e) {
- echo "Database error: " . htmlspecialchars($e->getMessage()) . "
";
+
+ echo "
";
+ } else {
+ echo "
No notes found for this student and medication.
";
}
-} else {
- echo "
No student ID provided.
";
+} catch (PDOException $e) {
+ die("
Database error: " . htmlspecialchars($e->getMessage(), ENT_QUOTES) . "
");
}
?>
From 2894e482d1107cb01626a8fe9116fca66f2059cf Mon Sep 17 00:00:00 2001
From: James
Date: Wed, 22 Jan 2025 00:13:02 +0000
Subject: [PATCH 05/86] cookie update
---
login/login.php | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/login/login.php b/login/login.php
index feeeac5..29831cb 100644
--- a/login/login.php
+++ b/login/login.php
@@ -40,7 +40,7 @@ function logAction($conn, $staff_id, $action) {
$password = $_POST["password"];
// First check if the email exists and get the staff details
- $sql = "SELECT staff_id, `group`, password, email FROM staff WHERE email = :email";
+ $sql = "SELECT staff_id, `group`, password, email, staff_code FROM staff WHERE email = :email";
$stmt = $conn->prepare($sql);
$stmt->execute(['email' => $email]);
$user = $stmt->fetch(PDO::FETCH_ASSOC);
@@ -57,13 +57,14 @@ function logAction($conn, $staff_id, $action) {
$_SESSION['staff_id'] = $user['staff_id'];
$_SESSION["ssnlogin"] = true;
$_SESSION["email"] = $user["email"];
+ $_SESSION["staff_code"] = $user["staff_code"]; // Store staff_code in session
// Add cookie setting here
setcookie(
'cookies_and_cream',
'active',
[
- 'expires' => time() + (2 * 60), // 2 minutes
+ 'expires' => time() + (5 * 60), // 5 minutes
'path' => '/',
'secure' => true,
'httponly' => true,
@@ -94,4 +95,4 @@ function logAction($conn, $staff_id, $action) {
// Redirect to login page in case of an error
header("Location: ../index.html");
exit();
-}
\ No newline at end of file
+}
From 971c44aad936d1d144f01094ff5d785a34fbab00 Mon Sep 17 00:00:00 2001
From: James
Date: Wed, 22 Jan 2025 00:14:57 +0000
Subject: [PATCH 06/86] archive: code
---
administer/administer.php | 137 ---------------------------------
administer/administer_form.php | 59 --------------
administer/choose_med.php | 120 -----------------------------
administer/choose_stu.php | 85 --------------------
log/add_notes.php | 80 -------------------
log/choose_student.php | 92 ----------------------
log/log.php | 87 ---------------------
log/log_form.php | 54 -------------
8 files changed, 714 deletions(-)
delete mode 100644 administer/administer.php
delete mode 100644 administer/administer_form.php
delete mode 100644 administer/choose_med.php
delete mode 100644 administer/choose_stu.php
delete mode 100644 log/add_notes.php
delete mode 100644 log/choose_student.php
delete mode 100644 log/log.php
delete mode 100644 log/log_form.php
diff --git a/administer/administer.php b/administer/administer.php
deleted file mode 100644
index cf1817d..0000000
--- a/administer/administer.php
+++ /dev/null
@@ -1,137 +0,0 @@
-
-
-
-
-
-
-
- Hours Tracking - Administer
-
-
-
-
-
-
-
-
-
-
-
-prepare($sql);
-
- $stmt -> bindParam(1,$sid);
-
- $stmt->execute();
-
- $result = $stmt->fetch();
-
- $tid = $result['takes_id'];
-
- // Combine the date and time into a single string
- $date_time_str = $date . ' ' . $time;
-
- // Convert the combined date and time string to a Unix timestamp (epoch time)
- $date_time_epoch = strtotime($date_time_str);
-
- // Prepare SQL statement to insert information into the 'administer' table
- $sql = "INSERT INTO administer (staff_code, date_time, dose_given, takes_id) VALUES (?, ?, ?,?)";
- $stmt = $conn->prepare($sql);
-
- // Bind parameters to prevent SQL injection
- $stmt->bindParam(1, $staff_code);
- $stmt->bindParam(2, $date_time_epoch); // Use the Unix timestamp here
- $stmt->bindParam(3, $taken_dose);
- $stmt->bindParam(4, $tid);
-
- // Execute the statement
- if($stmt->execute()) {
- echo "Data successfully inserted!";
- echo "";
- } else {
- echo "Error inserting data.";
- echo "";
- }
-
- // Dose subtracted from takes table
-
- // Prepare sql statement
- $sql = "SELECT current_dose FROM takes WHERE takes_id = ?";
- $stmt = $conn->prepare($sql);
-
- // Bind parameters to prevent SQL injection
- $stmt->bindParam(1,$tid);
-
- $stmt->execute();
-
- $result = $stmt->fetch();
-
- $new_dose = $result['current_dose'] - $taken_dose;
-
- // Update sql table
- $sql = "UPDATE takes SET current_dose = ? WHERE takes_id = ?";
- $stmt = $conn->prepare($sql);
-
- // Bind parameters to prevent SQL injection
- $stmt->bindParam(1,$new_dose);
- $stmt->bindParam(2,$tid);
-
- // Execute the statement
- if($stmt->execute()){
- echo "Data successfully updated!";
- }else{
- echo "Error updating data.";
- };
-
-
- } catch (PDOException $e) {
- // Handle any errors
- echo "Error: " . $e->getMessage();
- }
-
-?>
\ No newline at end of file
diff --git a/administer/administer_form.php b/administer/administer_form.php
deleted file mode 100644
index bd6b080..0000000
--- a/administer/administer_form.php
+++ /dev/null
@@ -1,59 +0,0 @@
-
-
-
-
-
-
-
- Hours Tracking - Administer Form
-
-
-
-
-
-
-
-
Create a log
-
- Enter staff code
- Example: AWA
-
-
- Enter students first name
- Example: Joe
-
-
- Enter students year group
- Example: 12
-
-
- Submit
-
-
-
-
\ No newline at end of file
diff --git a/administer/choose_med.php b/administer/choose_med.php
deleted file mode 100644
index 25316dd..0000000
--- a/administer/choose_med.php
+++ /dev/null
@@ -1,120 +0,0 @@
-
-
-
-
-
-
-
- Hours Tracking - Choose Medication
-
-
-
-
-
-
-
-
-
-
-prepare($sql);
-
- // Bind parameter for student ID from POST data
- $stmt->bindParam(1, $_POST['sid']);
-
- // Execute the query
- $stmt->execute();
-
- // Fetch all results
- $result = $stmt->fetchAll();
-
- // Display the form and table for medication selection
- echo "";
-
- echo "";
-
- echo " ";
-
- echo " ";
-
-?>
\ No newline at end of file
diff --git a/administer/choose_stu.php b/administer/choose_stu.php
deleted file mode 100644
index a2408c9..0000000
--- a/administer/choose_stu.php
+++ /dev/null
@@ -1,85 +0,0 @@
-
-
-
-
-
-
-
- Hours Tracking - Choose Student
-
-
-
-
-
-
-
-
-
-prepare($sql);
-
- $stmt->bindParam(1, $_POST['student_fname']);
- $stmt->bindParam(2, $_POST['student_yeargroup']);
-
- $stmt->execute();
-
- $result = $stmt->fetchAll();
-
- // Display the table and form for student selection
- echo "";
- echo "";
- echo " ";
- echo " ";
- echo " ";
-
-?>
\ No newline at end of file
diff --git a/log/add_notes.php b/log/add_notes.php
deleted file mode 100644
index 549e83a..0000000
--- a/log/add_notes.php
+++ /dev/null
@@ -1,80 +0,0 @@
-
-
-
-
-
-
-
- Hours Tracking - Add Notes
-
-
-
-
-
-
-
-
-
-Add Notes";
- echo "";
- echo " ";
-
- ### TODO: Discuss using https://design-system.service.gov.uk/patterns/dates/ this date format instead and try and change the logic to still work with epoch -- James
- ### Still going to style it to match the style for the rest of the site but might be changed
- ### Working Example, https://github.com/SilentSmeary/hours-tracking/blob/main/student/insert_log.php
- echo "Enter date
- Example: 12/05/2025
";
- echo " ";
- echo " ";
- // Time input field of each medication
- echo "Enter time
- Example: 12/05/2025
";
- echo " ";
- echo " ";
- // Notes input for log
- echo "Enter notes
- Example: 2x Given
";
-// echo " ";
- echo " ";
- echo " ";
- // Submit button for the form
- echo "
";
-
- echo " ";
-
- echo "";
-
-?>
\ No newline at end of file
diff --git a/log/choose_student.php b/log/choose_student.php
deleted file mode 100644
index 374ed68..0000000
--- a/log/choose_student.php
+++ /dev/null
@@ -1,92 +0,0 @@
-
-
-
-
-
-
-
- Hours Tracking - Choose Student
-
-
-
-
-
- prepare($sql);
-
- $stmt->bindParam(1, $_POST['student_fname']);
- $stmt->bindParam(2, $_POST['student_yeargroup']);
-
- $stmt->execute();
-
- $result = $stmt->fetchAll();
-
- // Display the table and form for student selection
- echo "
";
-
- ?>
-
-
-
-
-
-
\ No newline at end of file
diff --git a/log/log.php b/log/log.php
deleted file mode 100644
index 3af42fb..0000000
--- a/log/log.php
+++ /dev/null
@@ -1,87 +0,0 @@
-
-
-
-
- Hours Tracking - Log
-
-
-
-
-
-
-prepare($sql);
-
- // Bind parameters to prevent SQL injection
- $stmt ->bindParam(1, $stu_id);
- $stmt ->bindParam(2, $staff_id);
- $stmt ->bindParam(3, $notes);
- $stmt ->bindParam(4, $date_time_epoch);
-
- // Execute the statement
- if($stmt->execute()) {
- echo "
Data successfully inserted!";
- echo "";
- } else {
- echo "Error inserting data.";
- echo "";
- }
-
- } catch (PDOException $e) {
- // Handle any errors
- echo "Error: " . $e->getMessage();
- }
-
-?>
\ No newline at end of file
diff --git a/log/log_form.php b/log/log_form.php
deleted file mode 100644
index 7e73f25..0000000
--- a/log/log_form.php
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
-
-
-
-
-
-
Hours Tracking - Log Form
-
-
-
-
-
Choose a Student
-
- Enter students first name
- Example: Joe
-
-
- Enter students year group
- Example: 12
-
-
- Submit
-
-
-
-
\ No newline at end of file
From 2d45ff09f7e76c7f1ba683fc7d9345d6fe03e295 Mon Sep 17 00:00:00 2001
From: James
Date: Wed, 22 Jan 2025 18:57:06 +0000
Subject: [PATCH 07/86] fixed: table readability
---
bigtable/bigtable.php | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/bigtable/bigtable.php b/bigtable/bigtable.php
index 5e07ab6..b322bc5 100644
--- a/bigtable/bigtable.php
+++ b/bigtable/bigtable.php
@@ -89,9 +89,8 @@ class="search_bar"
$total_pages = ceil($total_records / $results_per_page);
- $sql = "SELECT takes.takes_id, takes.exp_date, takes.current_dose, takes.min_dose,
- takes.strength, med.med_name, brand.brand_name,
- students.student_id, students.first_name, students.last_name, students.year
+ $sql = "SELECT takes.takes_id, students.student_id, students.first_name, students.last_name, students.year,
+ med.med_name, brand.brand_name, takes.exp_date, takes.current_dose, takes.min_dose
FROM takes
INNER JOIN med ON takes.med_id = med.med_id
INNER JOIN brand ON takes.brand_id = brand.brand_id
@@ -108,15 +107,14 @@ class="search_bar"
$custom_headings = [
'takes_id' => 'ID',
+ 'first_name' => 'First Name',
+ 'last_name' => 'Last Name',
+ 'year' => 'Year',
+ 'med_name' => 'Medication Name',
+ 'brand_name' => 'Brand Name',
'exp_date' => 'Expiry Date',
'current_dose' => 'Current Dose',
'min_dose' => 'Minimum Dose',
- 'strength' => 'Strength',
- 'med_name' => 'Medication Name',
- 'brand_name' => 'Brand Name',
- 'first_name' => 'First Name',
- 'last_name' => 'Last Name',
- 'year' => 'Year'
];
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
@@ -153,14 +151,14 @@ class="search_bar"
echo "
@@ -172,9 +184,8 @@
Archive
-
-
+
Log New Med
@@ -198,9 +209,8 @@
Archive
-
-
+
Log New Med
@@ -224,9 +234,8 @@
Archive
-
-
+
Log New Med
@@ -235,4 +244,4 @@
-
+
\ No newline at end of file
diff --git a/dashboard/doses.php b/dashboard/doses.php
new file mode 100644
index 0000000..c8c680f
--- /dev/null
+++ b/dashboard/doses.php
@@ -0,0 +1,40 @@
+prepare($check_sql);
+ $stmt->bindParam(':take_id', $take_id, PDO::PARAM_INT);
+ $stmt->execute();
+ $result = $stmt->fetch(PDO::FETCH_ASSOC);
+
+ if ($result && $result['doses'] > 0) {
+ // Decrement the dose count
+ $update_sql = "UPDATE takes SET doses = doses - 1 WHERE take_id = :take_id";
+ $update_stmt = $conn->prepare($update_sql);
+ $update_stmt->bindParam(':take_id', $take_id, PDO::PARAM_INT);
+ $update_stmt->execute();
+ header("Location: bigtable.php"); // Redirect back to the main page
+ exit;
+ } else {
+ echo "Cannot decrement: doses are already zero.";
+ }
+ } catch (PDOException $e) {
+ die("Database error: " . $e->getMessage());
+ }
+} else {
+ die("Invalid request.");
+}
+?>
diff --git a/dashboard/view_notes.php b/dashboard/view_notes.php
new file mode 100644
index 0000000..ec0efab
--- /dev/null
+++ b/dashboard/view_notes.php
@@ -0,0 +1,53 @@
+Invalid request. Missing student or medication data.
");
+}
+
+try {
+ // Query to fetch notes along with staff_code for the specified student and takes_id
+ $sql = "SELECT notes.note_id, notes.content, notes.created_at,
+ students.first_name, students.last_name,
+ med.med_name, notes.staff_code
+ FROM notes
+ INNER JOIN takes ON notes.takes_id = takes.takes_id
+ INNER JOIN students ON takes.student_id = students.student_id
+ INNER JOIN med ON takes.med_id = med.med_id
+ WHERE takes.takes_id = :takes_id AND students.student_id = :student_id";
+
+ $stmt = $conn->prepare($sql);
+ $stmt->bindParam(':takes_id', $takes_id, PDO::PARAM_INT);
+ $stmt->bindParam(':student_id', $student_id, PDO::PARAM_INT);
+ $stmt->execute();
+
+ $notes = $stmt->fetchAll(PDO::FETCH_ASSOC);
+
+ if (!$notes) {
+ echo "No notes found for this student and medication.
";
+ } else {
+ echo "Notes for " . htmlspecialchars($notes[0]['first_name'], ENT_QUOTES) . " " . htmlspecialchars($notes[0]['last_name'], ENT_QUOTES) . " ";
+ echo "Medication: " . htmlspecialchars($notes[0]['med_name'], ENT_QUOTES) . " ";
+
+ echo "";
+ echo "Staff Code Content Created At ";
+
+ foreach ($notes as $note) {
+ echo "";
+ echo "" . htmlspecialchars($note['staff_code'], ENT_QUOTES) . " "; // Display the staff_code from notes table
+ echo "" . htmlspecialchars($note['content'], ENT_QUOTES) . " ";
+ echo "" . htmlspecialchars(date('d/m/Y H:i', strtotime($note['created_at'])), ENT_QUOTES) . " ";
+ echo " ";
+ }
+
+ echo "
";
+ }
+} catch (PDOException $e) {
+ die("Database error: " . htmlspecialchars($e->getMessage(), ENT_QUOTES) . "
");
+}
+?>
From b91b9207373774223a1dc368f904fc6b455f5822 Mon Sep 17 00:00:00 2001
From: James
Date: Wed, 22 Jan 2025 22:44:01 +0000
Subject: [PATCH 13/86] added: button styling
---
assets/style/style.css | 18 +++++++++++++++
dashboard/dashboard.php | 50 ++++++++++++++++++++++++++++++++---------
2 files changed, 58 insertions(+), 10 deletions(-)
diff --git a/assets/style/style.css b/assets/style/style.css
index ff9a711..784fece 100644
--- a/assets/style/style.css
+++ b/assets/style/style.css
@@ -562,4 +562,22 @@ select option {
text-decoration: none;
color: #003078;
border-bottom: 4px solid #003078;
+}
+
+.home_page_button{
+ margin-top: 10px;
+ color: #0b0b0c;
+ font-family: roboto;
+ font-size: 20px;
+ font-weight: 500;
+ background-color: #f3f2f1;
+ border: none;
+ text-decoration: none;
+ cursor: pointer;
+ border-bottom: 1px solid #505a5f;
+ padding: 5px;
+}
+
+.home_page_button:hover {
+ background-color: #b1b4b6;
}
\ No newline at end of file
diff --git a/dashboard/dashboard.php b/dashboard/dashboard.php
index 3a6aee7..c50d13a 100644
--- a/dashboard/dashboard.php
+++ b/dashboard/dashboard.php
@@ -147,21 +147,21 @@
- Archive
+ Archive
- Log New Med
+ Log New Med
- Create Notes
+ Create Notes
- View Notes
+ View Notes
@@ -182,11 +182,21 @@
- Archive
+ Archive
- Log New Med
+ Log New Med
+
+
+
+
+ Create Notes
+
+
+
+
+ View Notes
@@ -207,11 +217,21 @@
- Archive
+ Archive
- Log New Med
+ Log New Med
+
+
+
+
+ Create Notes
+
+
+
+
+ View Notes
@@ -232,11 +252,21 @@
- Archive
+ Archive
- Log New Med
+ Log New Med
+
+
+
+
+ Create Notes
+
+
+
+
+ View Notes
From 91daf45c07b69380f18295676ac6ca7b85d8f31c Mon Sep 17 00:00:00 2001
From: James
Date: Wed, 22 Jan 2025 23:10:50 +0000
Subject: [PATCH 14/86] added: style for create notes
---
assets/style/style.css | 16 ++++++++++++++
dashboard/create_notes.php | 43 ++++++++++++++++++++++----------------
dashboard/view_notes.php | 35 +++++++++++++++++++++++--------
server/main_navbar.php | 34 +++++++++++++++---------------
4 files changed, 84 insertions(+), 44 deletions(-)
diff --git a/assets/style/style.css b/assets/style/style.css
index 784fece..cbf57d5 100644
--- a/assets/style/style.css
+++ b/assets/style/style.css
@@ -580,4 +580,20 @@ select option {
.home_page_button:hover {
background-color: #b1b4b6;
+}
+
+.big_table_td_custom_one {
+ width: 100px;
+ padding: 12px; /* Padding for table header cells */
+ text-align: left;
+ border-bottom: 1px solid #0b0b0c; /* Light gray border */
+ font-size: 20px;
+}
+
+.big_table_td_custom_two {
+ width: 200px;
+ padding: 12px; /* Padding for table header cells */
+ text-align: left;
+ border-bottom: 1px solid #0b0b0c; /* Light gray border */
+ font-size: 20px;
}
\ No newline at end of file
diff --git a/dashboard/create_notes.php b/dashboard/create_notes.php
index fae2454..3f1d5ca 100644
--- a/dashboard/create_notes.php
+++ b/dashboard/create_notes.php
@@ -51,6 +51,8 @@
}
}
}
+
+include "../server/main_navbar.php";
?>
@@ -59,29 +61,34 @@
Create Notes
-
-
-
Create Note
-
Adding a note for Student ID: and Takes ID:
+
+
diff --git a/dashboard/view_notes.php b/dashboard/view_notes.php
index ec0efab..35ff76a 100644
--- a/dashboard/view_notes.php
+++ b/dashboard/view_notes.php
@@ -1,5 +1,14 @@
+
+
+
+
Create Notes
+
+
+
+
execute();
$notes = $stmt->fetchAll(PDO::FETCH_ASSOC);
-
if (!$notes) {
+
echo "
No notes found for this student and medication.
";
+ echo "
> Go Back ";
} else {
- echo "
Notes for " . htmlspecialchars($notes[0]['first_name'], ENT_QUOTES) . " " . htmlspecialchars($notes[0]['last_name'], ENT_QUOTES) . " ";
- echo "
Medication: " . htmlspecialchars($notes[0]['med_name'], ENT_QUOTES) . " ";
+ echo "
View Notes ";
+ echo "
Notes for " . htmlspecialchars($notes[0]['first_name'], ENT_QUOTES) . " " . htmlspecialchars($notes[0]['last_name'], ENT_QUOTES) . "
";
+ echo "
Medication: " . htmlspecialchars($notes[0]['med_name'], ENT_QUOTES) . "
";
- echo "
";
- echo "Staff Code Content Created At ";
+ echo "";
+ echo "
+ Staff Code
+ Date and Time
+ Content
+ ";
foreach ($notes as $note) {
echo "";
- echo "" . htmlspecialchars($note['staff_code'], ENT_QUOTES) . " "; // Display the staff_code from notes table
- echo "" . htmlspecialchars($note['content'], ENT_QUOTES) . " ";
- echo "" . htmlspecialchars(date('d/m/Y H:i', strtotime($note['created_at'])), ENT_QUOTES) . " ";
+ echo "" . htmlspecialchars($note['staff_code'], ENT_QUOTES) . " "; // Display the staff_code from notes table
+ echo "" . htmlspecialchars(date('d/m/Y H:i', strtotime($note['created_at'])), ENT_QUOTES) . " ";
+ echo "" . htmlspecialchars($note['content'], ENT_QUOTES) . " ";
echo " ";
}
-
+
echo "
";
+ echo " ";
+ echo " > Go Back ";
}
} catch (PDOException $e) {
die("Database error: " . htmlspecialchars($e->getMessage(), ENT_QUOTES) . "
");
diff --git a/server/main_navbar.php b/server/main_navbar.php
index 7042666..d1a355d 100644
--- a/server/main_navbar.php
+++ b/server/main_navbar.php
@@ -1,18 +1,18 @@
\ No newline at end of file
+
+
\ No newline at end of file
From f8e4349b5433751ec7dff15f295a1741cfc651de Mon Sep 17 00:00:00 2001
From: James
Date: Wed, 22 Jan 2025 23:39:04 +0000
Subject: [PATCH 15/86] added: default date and time fields
---
assets/style/style.css | 4 ++--
dashboard/create_notes.php | 18 ++++++++++++++++--
dashboard/dashboard.php | 18 +++++++++---------
3 files changed, 27 insertions(+), 13 deletions(-)
diff --git a/assets/style/style.css b/assets/style/style.css
index cbf57d5..8d58c80 100644
--- a/assets/style/style.css
+++ b/assets/style/style.css
@@ -568,14 +568,14 @@ select option {
margin-top: 10px;
color: #0b0b0c;
font-family: roboto;
- font-size: 20px;
+ font-size: 18px;
font-weight: 500;
background-color: #f3f2f1;
border: none;
text-decoration: none;
cursor: pointer;
border-bottom: 1px solid #505a5f;
- padding: 5px;
+ padding: 10px;
}
.home_page_button:hover {
diff --git a/dashboard/create_notes.php b/dashboard/create_notes.php
index 3f1d5ca..8eb8660 100644
--- a/dashboard/create_notes.php
+++ b/dashboard/create_notes.php
@@ -69,12 +69,26 @@
Enter the note date:
Example: 22/01/2025
-
+
+
+
+
Enter the time:
Example: 22/01/2025
-
+
+
+
+
diff --git a/dashboard/dashboard.php b/dashboard/dashboard.php
index c50d13a..2fbaf7a 100644
--- a/dashboard/dashboard.php
+++ b/dashboard/dashboard.php
@@ -32,10 +32,10 @@
brand.brand_name,
takes.notes,
(SELECT CONCAT(notes.staff_code, ' logged ', notes.content)
- FROM notes
- WHERE notes.takes_id = takes.takes_id
- ORDER BY notes.created_at DESC
- LIMIT 1) AS recent_note
+ FROM notes
+ WHERE notes.takes_id = takes.takes_id
+ ORDER BY notes.created_at DESC
+ LIMIT 1) AS recent_note
FROM takes
JOIN students ON takes.student_id = students.student_id
JOIN med ON takes.med_id = med.med_id
@@ -90,10 +90,10 @@
takes.min_dose,
takes.notes,
(SELECT CONCAT(notes.staff_code, ' logged ', notes.content)
- FROM notes
- WHERE notes.takes_id = takes.takes_id
- ORDER BY notes.created_at DESC
- LIMIT 1) AS recent_note
+ FROM notes
+ WHERE notes.takes_id = takes.takes_id
+ ORDER BY notes.created_at DESC
+ LIMIT 1) AS recent_note
FROM takes
JOIN students ON takes.student_id = students.student_id
JOIN med ON takes.med_id = med.med_id
@@ -145,7 +145,7 @@
Recent Note:
-
+
Archive
From 3b7a645c7f3d269e0ac767feda6ea4a5ca0c80ed Mon Sep 17 00:00:00 2001
From: James
Date: Thu, 23 Jan 2025 00:11:46 +0000
Subject: [PATCH 16/86] added: delete verify for staff
---
admin/staff/staff_home.php | 11 ++++++++---
assets/style/style.css | 4 ++++
dashboard/dashboard.php | 6 +++---
3 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/admin/staff/staff_home.php b/admin/staff/staff_home.php
index 35dd1ad..60cae82 100644
--- a/admin/staff/staff_home.php
+++ b/admin/staff/staff_home.php
@@ -69,13 +69,18 @@
= htmlspecialchars($row['last_name']) ?>
= htmlspecialchars($row['email']) ?>
+
+
+ Edit Details
+
- Change Password
+ Change Password
-
+
+
- Delete
+ Delete
diff --git a/assets/style/style.css b/assets/style/style.css
index 8d58c80..01537d4 100644
--- a/assets/style/style.css
+++ b/assets/style/style.css
@@ -596,4 +596,8 @@ select option {
text-align: left;
border-bottom: 1px solid #0b0b0c; /* Light gray border */
font-size: 20px;
+}
+
+.action-buttons{
+ width: 500px;
}
\ No newline at end of file
diff --git a/dashboard/dashboard.php b/dashboard/dashboard.php
index 2fbaf7a..920fa14 100644
--- a/dashboard/dashboard.php
+++ b/dashboard/dashboard.php
@@ -180,7 +180,7 @@
Recent Note:
-
+
Archive
@@ -215,7 +215,7 @@
Recent Note:
-
+
Archive
@@ -250,7 +250,7 @@
Recent Note:
-
+
Archive
From fa0cb7112073dc73e710a48690533cb18728f458 Mon Sep 17 00:00:00 2001
From: James
Date: Thu, 23 Jan 2025 11:49:47 +0000
Subject: [PATCH 17/86] Update database.sql
---
database/database.sql | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/database/database.sql b/database/database.sql
index 04db9df..9c967e9 100644
--- a/database/database.sql
+++ b/database/database.sql
@@ -99,7 +99,7 @@ INSERT INTO `brand` (`brand_id`, `brand_name`) VALUES
(33, 'VIBRAMYCIN'),
(34, 'DELTASONE'),
(35, 'PLAVIX'),
-(36, 'PANADOL'),
+(36, 'PANADOL');
--
-- Triggers `brand`
@@ -162,10 +162,7 @@ INSERT INTO `med` (`med_id`, `med_name`) VALUES
(27, 'LEVOCETIRIZINE'),
(28, 'GABAPENTIN'),
(29, 'DOXYCYCLINE'),
-(30, 'CLOPIDOGREL'),
-(31, 'ASDASDASDASD'),
-(32, 'ASDASDASDASD'),
-(33, 'ASDASDASDASD');
+(30, 'CLOPIDOGREL');
--
-- Triggers `med`
@@ -281,7 +278,7 @@ INSERT INTO `students` (`student_id`, `first_name`, `last_name`, `year`) VALUES
(30, 'MARK', 'SLOAN', '11'),
(31, 'OWEN', 'HUNT', '13'),
(32, 'CRISTINA', 'YANG', '11'),
-(33, 'MIRANDA', 'BAILEY', '14'),
+(33, 'MIRANDA', 'BAILEY', '14');
--
-- Triggers `students`
From fea29215a29450ba5a1b687431ee10849d90faad Mon Sep 17 00:00:00 2001
From: James
Date: Thu, 23 Jan 2025 12:07:22 +0000
Subject: [PATCH 18/86] fix: style
---
dashboard/dashboard.php | 70 ++++++++++++++++++++++-------------------
1 file changed, 37 insertions(+), 33 deletions(-)
diff --git a/dashboard/dashboard.php b/dashboard/dashboard.php
index 920fa14..add8638 100644
--- a/dashboard/dashboard.php
+++ b/dashboard/dashboard.php
@@ -145,14 +145,6 @@
Recent Note:
-
-
- Archive
-
-
-
- Log New Med
-
@@ -163,6 +155,15 @@
View Notes
+
+
+
+ Archive
+
+
+
+ Log New Med
+
@@ -180,14 +181,6 @@
Recent Note:
-
-
- Archive
-
-
-
- Log New Med
-
@@ -198,6 +191,15 @@
View Notes
+
+
+
+ Archive
+
+
+
+ Log New Med
+
@@ -215,14 +217,6 @@
Recent Note:
-
-
- Archive
-
-
-
- Log New Med
-
@@ -233,6 +227,15 @@
View Notes
+
+
+
+ Archive
+
+
+
+ Log New Med
+
@@ -250,14 +253,6 @@
Recent Note:
-
-
- Archive
-
-
-
- Log New Med
-
@@ -268,10 +263,19 @@
View Notes
+
+
+
+ Archive
+
+
+
+ Log New Med
+
-
\ No newline at end of file
+
From d147f3475cd11e2bd8f198c4f6a8cc2adb3e7fdc Mon Sep 17 00:00:00 2001
From: James
Date: Thu, 23 Jan 2025 22:37:46 +0000
Subject: [PATCH 19/86] added: edit staff details
---
admin/staff/create_user_data.php | 10 ++-
admin/staff/create_user_form.php | 4 +
admin/staff/edit_user.php | 127 +++++++++++++++++++++++++++++++
admin/staff/staff_home.php | 6 +-
4 files changed, 141 insertions(+), 6 deletions(-)
create mode 100644 admin/staff/edit_user.php
diff --git a/admin/staff/create_user_data.php b/admin/staff/create_user_data.php
index 0aa1e07..22f587a 100644
--- a/admin/staff/create_user_data.php
+++ b/admin/staff/create_user_data.php
@@ -11,6 +11,7 @@
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
+$staff_code = $_POST['staff_code'];
$email = $_POST['email'];
$password = $_POST['password'];
$c_password = $_POST['c_password'];
@@ -37,13 +38,14 @@
} else {
try {
$hpswd = password_hash($password, PASSWORD_DEFAULT);
- $sql = "INSERT INTO staff (first_name, last_name, email, password, `group`) VALUES (?, ?, ?, ?, ?)";
+ $sql = "INSERT INTO staff (first_name, last_name, staff_code, email, password, `group`) VALUES (?, ?, ?, ?, ?, ?)";
$stmt = $conn->prepare($sql);
$stmt->bindParam(1,$first_name);
$stmt->bindParam(2,$last_name);
- $stmt->bindParam(3,$email);
- $stmt->bindParam(4,$hpswd);
- $stmt->bindParam(5,$group);
+ $stmt->bindParam(3,$staff_code);
+ $stmt->bindParam(4,$email);
+ $stmt->bindParam(5,$hpswd);
+ $stmt->bindParam(6,$group);
$stmt->execute();
header("refresh:5; url=staff_home.php");
diff --git a/admin/staff/create_user_form.php b/admin/staff/create_user_form.php
index 8d63948..07ff645 100644
--- a/admin/staff/create_user_form.php
+++ b/admin/staff/create_user_form.php
@@ -47,6 +47,10 @@
Example: Bloggs
+ Enter staff code
+ Example: JBL
+
+
Enter email:
Example: joe.bloggs@utcleeds.co.uk
diff --git a/admin/staff/edit_user.php b/admin/staff/edit_user.php
new file mode 100644
index 0000000..d9c4790
--- /dev/null
+++ b/admin/staff/edit_user.php
@@ -0,0 +1,127 @@
+prepare($query);
+ $stmt->bindParam(':staff_id', $staff_id, PDO::PARAM_INT);
+ $stmt->execute();
+ $user = $stmt->fetch(PDO::FETCH_ASSOC);
+
+ if (!$user) {
+ die("User not found.");
+ }
+ } elseif ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['staff_id'])) {
+ $staff_id = $_POST['staff_id'];
+ $first_name = $_POST['first_name'];
+ $last_name = $_POST['last_name'];
+ $email = $_POST['email'];
+ $staff_code = $_POST['staff_code'];
+
+ // Validate inputs
+ if (empty($first_name) || empty($last_name) || empty($email) || empty($staff_code)) {
+ $error = "All fields are required.";
+ } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
+ $error = "Invalid email format.";
+ } else {
+ // Update user details
+ $query = "UPDATE staff SET first_name = :first_name, last_name = :last_name, email = :email, staff_code = :staff_code WHERE staff_id = :staff_id";
+ $stmt = $conn->prepare($query);
+ $stmt->bindParam(':first_name', $first_name);
+ $stmt->bindParam(':last_name', $last_name);
+ $stmt->bindParam(':email', $email);
+ $stmt->bindParam(':staff_code', $staff_code);
+ $stmt->bindParam(':staff_id', $staff_id, PDO::PARAM_INT);
+
+ if ($stmt->execute()) {
+ $success = "Details updated successfully.";
+ } else {
+ $error = "Failed to update details.";
+ }
+ }
+ } else {
+ $error = "Invalid request.";
+ }
+} catch (PDOException $e) {
+ $error = "Database error: " . $e->getMessage();
+}
+?>
+
+
+
+Hours Tracking - Dashboard
+
+
+
Edit User Details
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Enter first name
+
Example: Joe
+
+
+
+
+
Enter last name
+
Example: Bloggs
+
+
+
+
+
Enter email
+
Example: joe.bloggs@utcleeds.co.uk
+
+
+
+
+
Enter staff code
+
Example: JBL
+
+
+
+ Update Details
+
+
+
+
< Go Back
+
+
+
diff --git a/admin/staff/staff_home.php b/admin/staff/staff_home.php
index 60cae82..4de3966 100644
--- a/admin/staff/staff_home.php
+++ b/admin/staff/staff_home.php
@@ -10,7 +10,7 @@
include "../../server/db_connect.php";
// Fetch staff data
-$query = "SELECT staff_id, first_name, last_name, email FROM staff WHERE staff_id != 1";
+$query = "SELECT staff_id, first_name, last_name, email, staff_code FROM staff WHERE staff_id != 1";
$stmt = $conn->prepare($query);
$stmt->execute();
$staffData = $stmt->fetchAll(PDO::FETCH_ASSOC);
@@ -57,6 +57,7 @@
First Name
Last Name
Email
+
Staff Code
Actions
@@ -68,8 +69,9 @@
= htmlspecialchars($row['first_name']) ?>
= htmlspecialchars($row['last_name']) ?>
= htmlspecialchars($row['email']) ?>
+
= htmlspecialchars($row['staff_code']) ?>
-
+
Edit Details
From 140e92a3efa0a90254c52f0ab6c798e5fea5c10b Mon Sep 17 00:00:00 2001
From: James
Date: Thu, 23 Jan 2025 23:55:27 +0000
Subject: [PATCH 20/86] added: search by year group
---
bigtable/bigtable.php | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/bigtable/bigtable.php b/bigtable/bigtable.php
index e2173ed..c957c20 100644
--- a/bigtable/bigtable.php
+++ b/bigtable/bigtable.php
@@ -32,7 +32,7 @@
type="text"
name="search"
class="search_bar"
- placeholder="Search by student name, medication, or brand"
+ placeholder="Search by student name, medication, brand, or year group"
value=""
>
Search
@@ -79,7 +79,7 @@ class="search_bar"
INNER JOIN brand ON takes.brand_id = brand.brand_id
INNER JOIN students ON takes.student_id = students.student_id
WHERE CONCAT(students.first_name, ' ', students.last_name) LIKE :search
- OR med.med_name LIKE :search OR brand.brand_name LIKE :search";
+ OR med.med_name LIKE :search OR brand.brand_name LIKE :search OR students.year LIKE :search";
$total_stmt = $conn->prepare($total_sql);
$search_param = '%' . $search_term . '%';
$total_stmt->bindParam(':search', $search_param, PDO::PARAM_STR);
@@ -95,7 +95,7 @@ class="search_bar"
INNER JOIN brand ON takes.brand_id = brand.brand_id
INNER JOIN students ON takes.student_id = students.student_id
WHERE CONCAT(students.first_name, ' ', students.last_name) LIKE :search
- OR med.med_name LIKE :search OR brand.brand_name LIKE :search
+ OR med.med_name LIKE :search OR brand.brand_name LIKE :search OR students.year LIKE :search
LIMIT :limit OFFSET :offset";
$stmt = $conn->prepare($sql);
@@ -133,10 +133,8 @@ class="search_bar"
foreach ($custom_headings as $column => $heading) {
$value = $row[$column] ?? '';
if ($column === 'takes_id') {
- // Make the ID bold
$value = "" . htmlspecialchars($value, ENT_QUOTES) . " ";
} elseif ($column === 'exp_date' && is_numeric($value)) {
- // Format expiry date
$value = date('d/m/y', $value);
}
echo "" . $value . " ";
@@ -171,7 +169,6 @@ class="search_bar"
";
echo "";
}
-
echo "";
} else {
From 25750cf52854c29426ca2d80ad2a80081d038624 Mon Sep 17 00:00:00 2001
From: James
Date: Sat, 25 Jan 2025 19:48:19 +0000
Subject: [PATCH 21/86] moved audit-log to the server folder with other
functions
---
insert_data/export_brands.php | 2 +-
insert_data/export_meds.php | 2 +-
insert_data/export_students.php | 2 +-
insert_data/process_csv.php | 2 +-
insert_data/upload_single.php | 2 +-
{audit-log => server}/audit-log.php | 0
6 files changed, 5 insertions(+), 5 deletions(-)
rename {audit-log => server}/audit-log.php (100%)
diff --git a/insert_data/export_brands.php b/insert_data/export_brands.php
index 1a74532..edf9673 100644
--- a/insert_data/export_brands.php
+++ b/insert_data/export_brands.php
@@ -1,7 +1,7 @@
setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
diff --git a/insert_data/export_meds.php b/insert_data/export_meds.php
index b4612a8..a2b9a5e 100644
--- a/insert_data/export_meds.php
+++ b/insert_data/export_meds.php
@@ -1,7 +1,7 @@
setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
diff --git a/insert_data/export_students.php b/insert_data/export_students.php
index d97f266..73c3dc2 100644
--- a/insert_data/export_students.php
+++ b/insert_data/export_students.php
@@ -1,7 +1,7 @@
setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
diff --git a/insert_data/process_csv.php b/insert_data/process_csv.php
index 60a74a4..46a5ed0 100644
--- a/insert_data/process_csv.php
+++ b/insert_data/process_csv.php
@@ -31,7 +31,7 @@
Date: Sat, 25 Jan 2025 20:03:45 +0000
Subject: [PATCH 22/86] Update database.sql
---
database/database.sql | 42 ++++++++++++++++++++++--------------------
1 file changed, 22 insertions(+), 20 deletions(-)
diff --git a/database/database.sql b/database/database.sql
index 9c967e9..18f466e 100644
--- a/database/database.sql
+++ b/database/database.sql
@@ -3,7 +3,7 @@
-- https://www.phpmyadmin.net/
--
-- Host: localhost:3306
--- Generation Time: Jan 22, 2025 at 07:25 PM
+-- Generation Time: Jan 25, 2025 at 08:03 PM
-- Server version: 8.0.30
-- PHP Version: 8.1.10
@@ -20,6 +20,8 @@ SET time_zone = "+00:00";
--
-- Database: `utcl-mts`
--
+CREATE DATABASE IF NOT EXISTS `utcl-mts` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
+USE `utcl-mts`;
-- --------------------------------------------------------
@@ -30,7 +32,7 @@ SET time_zone = "+00:00";
CREATE TABLE `administer` (
`adminster_id` int NOT NULL,
`takes_id` int NOT NULL,
- `staff_code` text COLLATE utf8mb4_general_ci NOT NULL,
+ `staff_code` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`date_time` int NOT NULL,
`dose_given` int NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
@@ -44,7 +46,7 @@ CREATE TABLE `administer` (
CREATE TABLE `audit_logs` (
`audit_id` int UNSIGNED NOT NULL,
`staff_id` int NOT NULL,
- `act` text COLLATE utf8mb4_general_ci NOT NULL,
+ `act` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`date_time` int NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
@@ -56,7 +58,7 @@ CREATE TABLE `audit_logs` (
CREATE TABLE `brand` (
`brand_id` int UNSIGNED NOT NULL,
- `brand_name` text COLLATE utf8mb4_general_ci NOT NULL
+ `brand_name` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
@@ -125,7 +127,7 @@ DELIMITER ;
CREATE TABLE `med` (
`med_id` int UNSIGNED NOT NULL,
- `med_name` text COLLATE utf8mb4_general_ci NOT NULL
+ `med_name` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
@@ -189,8 +191,8 @@ DELIMITER ;
CREATE TABLE `notes` (
`note_id` int NOT NULL,
`takes_id` int NOT NULL,
- `staff_code` text COLLATE utf8mb4_general_ci NOT NULL,
- `content` text COLLATE utf8mb4_general_ci NOT NULL,
+ `staff_code` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
+ `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`created_at` datetime DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
@@ -212,12 +214,12 @@ INSERT INTO `notes` (`note_id`, `takes_id`, `staff_code`, `content`, `created_at
CREATE TABLE `staff` (
`staff_id` int UNSIGNED NOT NULL,
- `first_name` text COLLATE utf8mb4_general_ci NOT NULL,
- `last_name` text COLLATE utf8mb4_general_ci NOT NULL,
- `email` text COLLATE utf8mb4_general_ci NOT NULL,
- `staff_code` text COLLATE utf8mb4_general_ci NOT NULL,
- `password` text COLLATE utf8mb4_general_ci NOT NULL,
- `group` text COLLATE utf8mb4_general_ci NOT NULL
+ `first_name` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
+ `last_name` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
+ `email` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
+ `staff_code` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
+ `password` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
+ `group` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
@@ -236,9 +238,9 @@ INSERT INTO `staff` (`staff_id`, `first_name`, `last_name`, `email`, `staff_code
CREATE TABLE `students` (
`student_id` int UNSIGNED NOT NULL,
- `first_name` text COLLATE utf8mb4_general_ci NOT NULL,
- `last_name` text COLLATE utf8mb4_general_ci NOT NULL,
- `year` text COLLATE utf8mb4_general_ci NOT NULL
+ `first_name` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
+ `last_name` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
+ `year` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
@@ -313,7 +315,7 @@ CREATE TABLE `takes` (
`current_dose` int NOT NULL,
`min_dose` int NOT NULL,
`max_dose` int NOT NULL,
- `strength` text COLLATE utf8mb4_general_ci NOT NULL,
+ `strength` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
`archived` tinyint(1) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
@@ -386,7 +388,7 @@ INSERT INTO `takes` (`takes_id`, `student_id`, `med_id`, `brand_id`, `exp_date`,
CREATE TABLE `whole_log` (
`whole_log_id` int NOT NULL,
`whole_school_id` int NOT NULL,
- `notes` text COLLATE utf8mb4_general_ci NOT NULL,
+ `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`date_time` int NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
@@ -398,10 +400,10 @@ CREATE TABLE `whole_log` (
CREATE TABLE `whole_school` (
`whole_school_id` int NOT NULL,
- `name` text COLLATE utf8mb4_general_ci NOT NULL,
+ `name` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`exp_date` int NOT NULL,
`amount_left` int NOT NULL,
- `notes` text COLLATE utf8mb4_general_ci NOT NULL,
+ `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`archived` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
From 5543976251fb7505caf516fa10b2e14a83614dd8 Mon Sep 17 00:00:00 2001
From: James
Date: Sat, 25 Jan 2025 22:02:01 +0000
Subject: [PATCH 23/86] added: decrement dose prompt to check amount
---
assets/style/style.css | 26 +++++++++++++
bigtable/bigtable.php | 87 ++++++++++++++++++++++++++----------------
bigtable/doses.php | 18 ++++++---
3 files changed, 93 insertions(+), 38 deletions(-)
diff --git a/assets/style/style.css b/assets/style/style.css
index 01537d4..9f18745 100644
--- a/assets/style/style.css
+++ b/assets/style/style.css
@@ -600,4 +600,30 @@ select option {
.action-buttons{
width: 500px;
+}
+
+.popup {
+ display: none;
+ position: fixed;
+ z-index: 1000;
+ left: 0;
+ top: 0;
+ width: 100%;
+ height: 100%;
+ overflow: auto;
+ background-color: rgba(0,0,0,0.4);
+}
+.popup-content {
+ background-color: #fefefe;
+ margin: 15% auto;
+ padding: 20px;
+ border: 1px solid #888;
+ width: 600px;
+}
+.popup-close {
+ color: #aaa;
+ float: right;
+ font-size: 28px;
+ font-weight: bold;
+ cursor: pointer;
}
\ No newline at end of file
diff --git a/bigtable/bigtable.php b/bigtable/bigtable.php
index c957c20..77b1e28 100644
--- a/bigtable/bigtable.php
+++ b/bigtable/bigtable.php
@@ -49,30 +49,6 @@ class="search_bar"
$start_from = ($page - 1) * $results_per_page;
$search_term = trim($_GET['search'] ?? '');
- if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['decrement'])) {
- $takes_id = intval($_POST['takes_id']);
-
- try {
- $check_sql = "SELECT current_dose FROM takes WHERE takes_id = :takes_id";
- $check_stmt = $conn->prepare($check_sql);
- $check_stmt->bindParam(':takes_id', $takes_id, PDO::PARAM_INT);
- $check_stmt->execute();
- $result = $check_stmt->fetch(PDO::FETCH_ASSOC);
-
- if ($result && $result['current_dose'] > 0) {
- $update_sql = "UPDATE takes SET current_dose = current_dose - 1 WHERE takes_id = :takes_id";
- $update_stmt = $conn->prepare($update_sql);
- $update_stmt->bindParam(':takes_id', $takes_id, PDO::PARAM_INT);
- $update_stmt->execute();
- echo "Dose decremented successfully.
";
- } else {
- echo "Cannot decrement. Dose is already at zero.
";
- }
- } catch (PDOException $e) {
- die("Database error: " . htmlspecialchars($e->getMessage(), ENT_QUOTES) . "
");
- }
- }
-
try {
$total_sql = "SELECT COUNT(*) AS total_records FROM takes
INNER JOIN med ON takes.med_id = med.med_id
@@ -117,7 +93,7 @@ class="search_bar"
];
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
- echo "";
+ echo "
";
if ($results) {
echo "
";
echo "";
@@ -141,12 +117,12 @@ class="search_bar"
}
echo "
-
-
-
- Decrement Dose
-
-
+
+ Decrement Dose
+
";
echo "
@@ -197,6 +173,53 @@ class="search_bar"
die("Database error: " . htmlspecialchars($e->getMessage(), ENT_QUOTES));
}
?>
+
+
+
+
+