diff --git a/.gitignore b/.gitignore index 9436d97..136a47f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /.idea /.vscode +/vendor diff --git a/README.md b/README.md new file mode 100755 index 0000000..4d870e0 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +## UTC Medical Tracker + +### Requirements +- Composer (Latest Version) +- PHP (Latest Version) +- MySQL (Latest Version) + +#### Composer Libraries +``` +composer install +``` + +### Linux Only +``` +sudo chmod 777 /opt/lampp/htdocs/website/* +``` diff --git a/admin/add/add_new_brand.php b/admin/add/add_new_brand.php deleted file mode 100644 index 37a0e52..0000000 --- a/admin/add/add_new_brand.php +++ /dev/null @@ -1,82 +0,0 @@ - - -
-| Staff ID | +First Name | +Last Name | +Staff Code | +|
|---|---|---|---|---|
| = htmlspecialchars($row['staff_id']) ?> | += htmlspecialchars($row['first_name']) ?> | += htmlspecialchars($row['last_name']) ?> | += htmlspecialchars($row['email']) ?> | += htmlspecialchars($row['staff_code']) ?> | +
| No staff members found. | +||||
| = htmlspecialchars($row['brand_id']) ?> | += htmlspecialchars($row['brand_name']) ?> | +
| No data found. | +|
Password sucessfully changed
'; + echo '| = htmlspecialchars($row['med_id']) ?> | += htmlspecialchars($row['med_name']) ?> | +
| No data found. | +|
| " . htmlspecialchars($cell) . " | "; + echo "" . htmlspecialchars($cell) . " | "; } else { - echo "" . htmlspecialchars($cell) . " | "; + echo "" . htmlspecialchars($cell) . " | "; } } echo "|||
|---|---|---|---|---|---|---|
| Staff ID | -First Name | -Last Name | -Actions | -|
|---|---|---|---|---|
| = htmlspecialchars($row['staff_id']) ?> | -= htmlspecialchars($row['first_name']) ?> | -= htmlspecialchars($row['last_name']) ?> | -= htmlspecialchars($row['email']) ?> | -- - - | -
| No staff members found. | -||||
| Staff ID | +First Name | +Last Name | +Staff Code | +Group | +Actions | +|
|---|---|---|---|---|---|---|
| = htmlspecialchars($row['staff_id']) ?> | += htmlspecialchars($row['first_name']) ?> | += htmlspecialchars($row['last_name']) ?> | += htmlspecialchars($row['email']) ?> | += htmlspecialchars($row['staff_code']) ?> | += htmlspecialchars($row['group']) ?> | ++ + + + + | +
| No staff members found. | +||||||
| Student ID | +First Name | +Last Name | +Year | +Action | +
|---|---|---|---|---|
| + | + | + | + |
+
+
+
+ |
+
| No records found. | +||||
| " . htmlspecialchars($heading, ENT_QUOTES) . " | "; + } + echo "
|---|
| " . htmlspecialchars($value, ENT_QUOTES) . " | "; + } + echo "
Dose decremented successfully.
"; - } else { - echo "Cannot decrement. Dose is already at zero.
"; - } - } catch (PDOException $e) { - die("Database error: " . htmlspecialchars($e->getMessage(), ENT_QUOTES) . "
"); - } + if (!empty($search_term)) { + $source = "Student Medication"; + $staff_id = $_SESSION['staff_id']; // Fetch from POST, not SESSION + $staff_code = $_SESSION['staff_code']; // Staff code is correctly from SESSION + $action = "$staff_code searched $search_term"; + + logAction($conn, $staff_id, $action, $source); } + try { + // Total records query $total_sql = "SELECT COUNT(*) AS total_records FROM takes INNER JOIN med ON takes.med_id = med.med_id 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); @@ -89,15 +77,16 @@ 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 + // Main query with sorting by last_name + $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 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 + ORDER BY students.last_name ASC LIMIT :limit OFFSET :offset"; $stmt = $conn->prepare($sql); @@ -108,54 +97,67 @@ 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); - echo "| " . htmlspecialchars($heading, ENT_QUOTES) . " | "; + echo "" . htmlspecialchars($heading, ENT_QUOTES) . " | "; } - echo "Actions | "; - echo "Notes | "; + echo "Actions | "; + echo "Notes | "; echo "
|---|---|---|---|---|---|
| " . htmlspecialchars($value, ENT_QUOTES) . " | "; + echo "" . $value . " | "; } echo "- | "; + echo "
+
+
- | ";
- echo "- | "; + + "; echo "
| "; // Checkbox for select all + foreach ($custom_headings as $heading) { + echo " | " . htmlspecialchars($heading, ENT_QUOTES) . " | "; + } + echo "
|---|---|
| + + | "; + foreach ($custom_headings as $column => $heading) { + $value = $row[$column] ?? ''; + if ($column === 'exp_date' && is_numeric($value)) { + $value = date('d/m/y', $value); + } + echo "" . htmlspecialchars($value, ENT_QUOTES) . " | "; + } + echo "
| Log ID | -Date Logged | -Notes | -
|---|---|---|
| " . htmlspecialchars($row['log_id']) . " | "; - echo "" . htmlspecialchars(date('d/m/Y H:i', $row['date_time'])) . " | "; - echo "" . htmlspecialchars($row['notes']) . " | "; - echo "
No records found for this student.
"; - } - } catch (PDOException $e) { - echo "Database error: " . htmlspecialchars($e->getMessage()) . "
"; - } -} else { - echo "No student ID provided.
"; -} -?> diff --git a/bigtable/view_notes.php b/bigtable/view_notes.php new file mode 100644 index 0000000..a26955a --- /dev/null +++ b/bigtable/view_notes.php @@ -0,0 +1,72 @@ + + + +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 "| Staff Code | +Date and Time | +Content | +
|---|---|---|
| " . 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 "
Database error: " . htmlspecialchars($e->getMessage(), ENT_QUOTES) . "
"); +} +?> diff --git a/composer.json b/composer.json new file mode 100755 index 0000000..9ba9d6b --- /dev/null +++ b/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "phpoffice/phpspreadsheet": "^3.9" + } +} diff --git a/composer.lock b/composer.lock new file mode 100755 index 0000000..a54fb31 --- /dev/null +++ b/composer.lock @@ -0,0 +1,598 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "6ca0e11e13366565618a058133359df4", + "packages": [ + { + "name": "composer/pcre", + "version": "3.3.2", + "source": { + "type": "git", + "url": "https://github.com/composer/pcre.git", + "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e", + "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "conflict": { + "phpstan/phpstan": "<1.11.10" + }, + "require-dev": { + "phpstan/phpstan": "^1.12 || ^2", + "phpstan/phpstan-strict-rules": "^1 || ^2", + "phpunit/phpunit": "^8 || ^9" + }, + "type": "library", + "extra": { + "phpstan": { + "includes": [ + "extension.neon" + ] + }, + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Pcre\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "PCRE wrapping library that offers type-safe preg_* replacements.", + "keywords": [ + "PCRE", + "preg", + "regex", + "regular expression" + ], + "support": { + "issues": "https://github.com/composer/pcre/issues", + "source": "https://github.com/composer/pcre/tree/3.3.2" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2024-11-12T16:29:46+00:00" + }, + { + "name": "maennchen/zipstream-php", + "version": "3.1.1", + "source": { + "type": "git", + "url": "https://github.com/maennchen/ZipStream-PHP.git", + "reference": "6187e9cc4493da94b9b63eb2315821552015fca9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/6187e9cc4493da94b9b63eb2315821552015fca9", + "reference": "6187e9cc4493da94b9b63eb2315821552015fca9", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "ext-zlib": "*", + "php-64bit": "^8.1" + }, + "require-dev": { + "ext-zip": "*", + "friendsofphp/php-cs-fixer": "^3.16", + "guzzlehttp/guzzle": "^7.5", + "mikey179/vfsstream": "^1.6", + "php-coveralls/php-coveralls": "^2.5", + "phpunit/phpunit": "^10.0", + "vimeo/psalm": "^5.0" + }, + "suggest": { + "guzzlehttp/psr7": "^2.4", + "psr/http-message": "^2.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "ZipStream\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paul Duncan", + "email": "pabs@pablotron.org" + }, + { + "name": "Jonatan Männchen", + "email": "jonatan@maennchen.ch" + }, + { + "name": "Jesse Donat", + "email": "donatj@gmail.com" + }, + { + "name": "András Kolesár", + "email": "kolesar@kolesar.hu" + } + ], + "description": "ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.", + "keywords": [ + "stream", + "zip" + ], + "support": { + "issues": "https://github.com/maennchen/ZipStream-PHP/issues", + "source": "https://github.com/maennchen/ZipStream-PHP/tree/3.1.1" + }, + "funding": [ + { + "url": "https://github.com/maennchen", + "type": "github" + } + ], + "time": "2024-10-10T12:33:01+00:00" + }, + { + "name": "markbaker/complex", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/MarkBaker/PHPComplex.git", + "reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/95c56caa1cf5c766ad6d65b6344b807c1e8405b9", + "reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "dev-master", + "phpcompatibility/php-compatibility": "^9.3", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0", + "squizlabs/php_codesniffer": "^3.7" + }, + "type": "library", + "autoload": { + "psr-4": { + "Complex\\": "classes/src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Baker", + "email": "mark@lange.demon.co.uk" + } + ], + "description": "PHP Class for working with complex numbers", + "homepage": "https://github.com/MarkBaker/PHPComplex", + "keywords": [ + "complex", + "mathematics" + ], + "support": { + "issues": "https://github.com/MarkBaker/PHPComplex/issues", + "source": "https://github.com/MarkBaker/PHPComplex/tree/3.0.2" + }, + "time": "2022-12-06T16:21:08+00:00" + }, + { + "name": "markbaker/matrix", + "version": "3.0.1", + "source": { + "type": "git", + "url": "https://github.com/MarkBaker/PHPMatrix.git", + "reference": "728434227fe21be27ff6d86621a1b13107a2562c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/728434227fe21be27ff6d86621a1b13107a2562c", + "reference": "728434227fe21be27ff6d86621a1b13107a2562c", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "dev-master", + "phpcompatibility/php-compatibility": "^9.3", + "phpdocumentor/phpdocumentor": "2.*", + "phploc/phploc": "^4.0", + "phpmd/phpmd": "2.*", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0", + "sebastian/phpcpd": "^4.0", + "squizlabs/php_codesniffer": "^3.7" + }, + "type": "library", + "autoload": { + "psr-4": { + "Matrix\\": "classes/src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Baker", + "email": "mark@demon-angel.eu" + } + ], + "description": "PHP Class for working with matrices", + "homepage": "https://github.com/MarkBaker/PHPMatrix", + "keywords": [ + "mathematics", + "matrix", + "vector" + ], + "support": { + "issues": "https://github.com/MarkBaker/PHPMatrix/issues", + "source": "https://github.com/MarkBaker/PHPMatrix/tree/3.0.1" + }, + "time": "2022-12-02T22:17:43+00:00" + }, + { + "name": "phpoffice/phpspreadsheet", + "version": "3.9.0", + "source": { + "type": "git", + "url": "https://github.com/PHPOffice/PhpSpreadsheet.git", + "reference": "414f8a2aa1d8b974b39f577c0677d5ebc96fab36" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/414f8a2aa1d8b974b39f577c0677d5ebc96fab36", + "reference": "414f8a2aa1d8b974b39f577c0677d5ebc96fab36", + "shasum": "" + }, + "require": { + "composer/pcre": "^3.3", + "ext-ctype": "*", + "ext-dom": "*", + "ext-fileinfo": "*", + "ext-gd": "*", + "ext-iconv": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-simplexml": "*", + "ext-xml": "*", + "ext-xmlreader": "*", + "ext-xmlwriter": "*", + "ext-zip": "*", + "ext-zlib": "*", + "maennchen/zipstream-php": "^2.1 || ^3.0", + "markbaker/complex": "^3.0", + "markbaker/matrix": "^3.0", + "php": "^8.1", + "psr/http-client": "^1.0", + "psr/http-factory": "^1.0", + "psr/simple-cache": "^1.0 || ^2.0 || ^3.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "dev-main", + "dompdf/dompdf": "^2.0 || ^3.0", + "friendsofphp/php-cs-fixer": "^3.2", + "mitoteam/jpgraph": "^10.3", + "mpdf/mpdf": "^8.1.1", + "phpcompatibility/php-compatibility": "^9.3", + "phpstan/phpstan": "^1.1", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^10.5", + "squizlabs/php_codesniffer": "^3.7", + "tecnickcom/tcpdf": "^6.5" + }, + "suggest": { + "dompdf/dompdf": "Option for rendering PDF with PDF Writer", + "ext-intl": "PHP Internationalization Functions", + "mitoteam/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers", + "mpdf/mpdf": "Option for rendering PDF with PDF Writer", + "tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer" + }, + "type": "library", + "autoload": { + "psr-4": { + "PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Maarten Balliauw", + "homepage": "https://blog.maartenballiauw.be" + }, + { + "name": "Mark Baker", + "homepage": "https://markbakeruk.net" + }, + { + "name": "Franck Lefevre", + "homepage": "https://rootslabs.net" + }, + { + "name": "Erik Tilt" + }, + { + "name": "Adrien Crivelli" + } + ], + "description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine", + "homepage": "https://github.com/PHPOffice/PhpSpreadsheet", + "keywords": [ + "OpenXML", + "excel", + "gnumeric", + "ods", + "php", + "spreadsheet", + "xls", + "xlsx" + ], + "support": { + "issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues", + "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/3.9.0" + }, + "time": "2025-01-26T05:10:24+00:00" + }, + { + "name": "psr/http-client", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-client.git", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP clients", + "homepage": "https://github.com/php-fig/http-client", + "keywords": [ + "http", + "http-client", + "psr", + "psr-18" + ], + "support": { + "source": "https://github.com/php-fig/http-client" + }, + "time": "2023-09-23T14:17:50+00:00" + }, + { + "name": "psr/http-factory", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a", + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a", + "shasum": "" + }, + "require": { + "php": ">=7.1", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "PSR-17: Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-factory" + }, + "time": "2024-04-15T12:06:14+00:00" + }, + { + "name": "psr/http-message", + "version": "2.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/2.0" + }, + "time": "2023-04-04T09:54:51+00:00" + }, + { + "name": "psr/simple-cache", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/simple-cache.git", + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/764e0b3939f5ca87cb904f570ef9be2d78a07865", + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\SimpleCache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interfaces for simple caching", + "keywords": [ + "cache", + "caching", + "psr", + "psr-16", + "simple-cache" + ], + "support": { + "source": "https://github.com/php-fig/simple-cache/tree/3.0.0" + }, + "time": "2021-10-29T13:26:27+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": {}, + "prefer-stable": false, + "prefer-lowest": false, + "platform": {}, + "platform-dev": {}, + "plugin-api-version": "2.6.0" +} diff --git a/create_super_user.php b/create_super_user.php new file mode 100644 index 0000000..f02501b --- /dev/null +++ b/create_super_user.php @@ -0,0 +1,64 @@ +prepare($sql); + $stmt->bindParam(1,$_POST['first_name']); + $stmt->bindParam(2,$_POST['last_name']); + $stmt->bindParam(3,$_POST['email']); + $hash_password = password_hash($password = $_POST['password'], PASSWORD_DEFAULT); + $stmt->bindParam(4,$hash_password); + $group = "ROOT"; + $stmt->bindParam(5,$group); + $stmt->bindParam(6,$_POST['staff_code']); + + $stmt->execute(); + header("refresh:0; url=index.php"); +} +?> + + + + + + + + +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(); + + $staff_id = $_SESSION['staff_id']; + $staff_code = $_SESSION['staff_code']; + $action = "$staff_code Logged $content"; + $source = "Create Notes"; + + logAction($conn, $staff_id, $action, $source); + + header("location:dashboard.php"); + echo "Note added successfully!
"; + } catch (PDOException $e) { + die("Database error: " . htmlspecialchars($e->getMessage(), ENT_QUOTES) . "
"); + } + } +} + + +?> + + + + +You are adding a note for Student ID: with Takes ID:
+ +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 "| Staff Code | +Date and Time | +Content | +
|---|---|---|
| " . 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 "
Database error: " . htmlspecialchars($e->getMessage(), ENT_QUOTES) . "
"); +} +?> diff --git a/database/database.sql b/database/database.sql index e41186b..4f00eb0 100644 --- a/database/database.sql +++ b/database/database.sql @@ -1,11 +1,11 @@ -- phpMyAdmin SQL Dump --- version 5.2.1 +-- version 5.2.0 -- https://www.phpmyadmin.net/ -- -- Host: localhost:3306 --- Generation Time: Jan 20, 2025 at 01:04 AM --- Server version: 8.0.40-cll-lve --- PHP Version: 8.3.14 +-- Generation Time: Jan 30, 2025 at 12:47 AM +-- Server version: 8.0.30 +-- PHP Version: 8.1.10 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; START TRANSACTION; @@ -18,9 +18,9 @@ SET time_zone = "+00:00"; /*!40101 SET NAMES utf8mb4 */; -- --- Database: `barowika_utcl-mts` +-- Database: `utcl-mts` -- -CREATE DATABASE IF NOT EXISTS `utcl-mts` DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci; +CREATE DATABASE IF NOT EXISTS `utcl-mts` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci; USE `utcl-mts`; -- -------------------------------------------------------- @@ -47,9 +47,131 @@ CREATE TABLE `audit_logs` ( `audit_id` int UNSIGNED NOT NULL, `staff_id` int NOT NULL, `act` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `source` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `date_time` int NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +-- +-- Dumping data for table `audit_logs` +-- + +INSERT INTO `audit_logs` (`audit_id`, `staff_id`, `act`, `date_time`) VALUES +(114, 5, 'User successfully logged in, IP: ::1', 1737835629), +(115, 5, 'User successfully logged in, IP: ::1', 1737840646), +(116, 5, 'User successfully logged in, IP: ::1', 1737842079), +(117, 5, 'User successfully logged in, IP: ::1', 1737842228), +(118, 5, 'User successfully logged in, IP: ::1', 1737842905), +(119, 5, 'User successfully logged in, IP: ::1', 1737843990), +(120, 5, 'User successfully logged in, IP: ::1', 1737844669), +(121, 5, 'User successfully logged in, IP: ::1', 1737844998), +(122, 5, 'User successfully logged in, IP: ::1', 1737845432), +(123, 5, 'User successfully logged in, IP: ::1', 1737845912), +(124, 5, 'User successfully logged in, IP: ::1', 1737846394), +(125, 5, 'User successfully logged in, IP: ::1', 1737847069), +(126, 5, 'User successfully logged in, IP: ::1', 1737847524), +(127, 5, 'User successfully logged in, IP: ::1', 1737849240), +(128, 5, 'User successfully logged in, IP: ::1', 1737849610), +(129, 5, 'User successfully logged in, IP: ::1', 1737849987), +(130, 5, 'User successfully logged in, IP: ::1', 1737851000), +(131, 5, 'User successfully logged in, IP: ::1', 1737851610), +(132, 5, 'User successfully logged in, IP: ::1', 1737852072), +(133, 5, 'User successfully logged in, IP: ::1', 1737852410), +(134, 5, 'User successfully logged in, IP: ::1', 1737894096), +(135, 5, 'User successfully logged in, IP: ::1', 1737899697), +(136, 5, 'User successfully logged in, IP: ::1', 1737900468), +(137, 5, 'User successfully logged in, IP: ::1', 1737901333), +(138, 5, 'User successfully logged in, IP: ::1', 1737902083), +(139, 5, 'User successfully logged in, IP: ::1', 1737902397), +(140, 5, 'User successfully logged in, IP: ::1', 1737902718), +(141, 5, 'User successfully logged in, IP: ::1', 1737903024), +(142, 5, 'User successfully logged in, IP: ::1', 1737903037), +(143, 5, 'User successfully logged in, IP: ::1', 1737903374), +(144, 5, 'User successfully logged in, IP: ::1', 1737903676), +(145, 5, 'User successfully logged in, IP: ::1', 1737911633), +(146, 5, 'User successfully logged in, IP: ::1', 1737911993), +(147, 5, 'User successfully logged in, IP: ::1', 1737912326), +(148, 5, 'User successfully logged in, IP: ::1', 1737912665), +(149, 5, 'User successfully logged in, IP: ::1', 1737913009), +(150, 5, 'User successfully logged in, IP: ::1', 1737913447), +(151, 5, 'User successfully logged in, IP: ::1', 1737915287), +(152, 5, 'User successfully logged in, IP: ::1', 1737915778), +(153, 5, 'User successfully logged in, IP: ::1', 1737916160), +(154, 5, 'User successfully logged in, IP: ::1', 1737916463), +(155, 5, 'User successfully logged in, IP: ::1', 1737932770), +(156, 5, 'User successfully logged in, IP: ::1', 1738089436), +(157, 5, 'User successfully logged in, IP: ::1', 1738089938), +(158, 5, 'Failed login attempt with valid email, IP: ::1', 1738089942), +(159, 5, 'Failed login attempt with valid email, IP: ::1', 1738089960), +(160, 0, 'Failed login attempt with invalid email, IP: ::1', 1738089964), +(161, 5, 'Failed login attempt with valid email, IP: ::1', 1738090020), +(162, 5, 'User successfully logged in, IP: ::1', 1738090027), +(163, 8, 'User successfully logged in, IP: ::1', 1738090191), +(164, 8, 'Attempted login to archived account, IP: ::1', 1738090326), +(165, 5, 'User successfully logged in, IP: ::1', 1738090468), +(166, 5, 'Failed login attempt with valid email, IP: ::1', 1738090477), +(167, 5, 'User successfully logged in, IP: ::1', 1738090623), +(168, 5, 'User successfully logged in, IP: ::1', 1738090671), +(169, 5, 'User successfully logged in, IP: ::1', 1738090684), +(170, 5, 'User successfully logged in, IP: ::1', 1738090689), +(171, 5, 'User successfully logged in, IP: ::1', 1738091047), +(172, 5, 'User successfully logged in, IP: ::1', 1738091794), +(173, 5, 'User successfully logged in, IP: ::1', 1738092207), +(174, 5, 'User successfully logged in, IP: ::1', 1738092510), +(175, 5, 'User successfully logged in, IP: ::1', 1738097910), +(176, 5, 'User successfully logged in, IP: ::1', 1738098220), +(177, 5, 'Failed login attempt with valid email, IP: ::1', 1738098406), +(178, 8, 'Attempted login to archived account, IP: ::1', 1738098431), +(179, 5, 'User successfully logged in, IP: ::1', 1738098499), +(180, 5, 'User successfully logged in, IP: ::1', 1738103980), +(181, 5, 'User successfully logged in, IP: ::1', 1738106592), +(182, 5, 'User successfully logged in, IP: ::1', 1738180296), +(183, 5, 'User successfully logged in, IP: ::1', 1738180741), +(184, 9, 'User successfully logged in, IP: ::1', 1738181019), +(185, 5, 'User successfully logged in, IP: ::1', 1738181024), +(186, 5, 'User successfully logged in, IP: ::1', 1738181285), +(187, 5, 'User successfully logged in, IP: ::1', 1738181393), +(188, 5, 'Failed login attempt with valid email, IP: ::1', 1738181397), +(189, 5, 'User successfully logged in, IP: ::1', 1738181400), +(190, 5, 'User successfully logged in, IP: ::1', 1738181757), +(191, 9, 'User successfully logged in, IP: ::1', 1738181787), +(192, 9, 'User successfully logged in, IP: ::1', 1738181970), +(193, 5, 'User successfully logged in, IP: ::1', 1738181999), +(194, 5, 'User successfully logged in, IP: ::1', 1738182310), +(195, 5, 'User successfully logged in, IP: ::1', 1738183071), +(196, 5, 'User successfully logged in, IP: ::1', 1738183724), +(197, 5, 'User successfully logged in, IP: ::1', 1738184719), +(198, 5, 'User successfully logged in, IP: ::1', 1738185385), +(199, 5, 'User successfully logged in, IP: ::1', 1738187460), +(200, 5, 'User successfully logged in, IP: ::1', 1738187464), +(201, 5, 'User successfully logged in, IP: ::1', 1738188127), +(202, 5, 'User successfully logged in, IP: ::1', 1738190079), +(203, 5, 'User successfully logged in, IP: ::1', 1738191866), +(204, 5, 'User successfully logged in, IP: ::1', 1738192194), +(205, 5, 'Failed login attempt with valid email, IP: ::1', 1738192240), +(206, 5, 'User successfully logged in, IP: ::1', 1738192288), +(207, 5, 'User successfully logged in, IP: 127.0.0.1', 1738192315), +(208, 5, 'User successfully logged in, IP: ::1', 1738193732), +(209, 5, 'User successfully logged in, IP: ::1', 1738195884), +(210, 9, 'Failed login attempt with valid email, IP: ::1', 1738195895), +(211, 9, 'Failed login attempt with valid email, IP: ::1', 1738195903), +(212, 9, 'Failed login attempt with valid email, IP: ::1', 1738195914), +(213, 5, 'User successfully logged in, IP: ::1', 1738195916), +(214, 10, 'User successfully logged in, IP: ::1', 1738195962), +(215, 10, 'User successfully logged in, IP: ::1', 1738196266), +(216, 10, 'User successfully logged in, IP: ::1', 1738196268), +(217, 10, 'User successfully logged in, IP: ::1', 1738196321), +(218, 10, 'User successfully logged in, IP: ::1', 1738197460), +(219, 10, 'User successfully logged in, IP: ::1', 1738197464), +(220, 10, 'User successfully logged in, IP: ::1', 1738197483), +(221, 10, 'User successfully logged in, IP: ::1', 1738197487), +(222, 10, 'User successfully logged in, IP: ::1', 1738197490), +(223, 5, 'User successfully logged in, IP: ::1', 1738197542), +(224, 5, 'User successfully logged in, IP: ::1', 1738197549), +(225, 5, 'User successfully logged in, IP: ::1', 1738197588), +(226, 5, 'User successfully logged in, IP: ::1', 1738197608), +(227, 5, 'User successfully logged in, IP: ::1', 1738197947), +(228, 10, 'User successfully logged in, IP: ::1', 1738198033); + -- -------------------------------------------------------- -- @@ -101,7 +223,8 @@ INSERT INTO `brand` (`brand_id`, `brand_name`) VALUES (33, 'VIBRAMYCIN'), (34, 'DELTASONE'), (35, 'PLAVIX'), -(36, 'PANADOL'); +(36, 'PANADOL'), +(58, 'TESC'); -- -- Triggers `brand` @@ -121,20 +244,6 @@ DELIMITER ; -- -------------------------------------------------------- --- --- Table structure for table `log` --- - -CREATE TABLE `log` ( - `log_id` int NOT NULL, - `student_id` int NOT NULL, - `staff_id` int 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; - --- -------------------------------------------------------- - -- -- Table structure for table `med` -- @@ -179,9 +288,7 @@ INSERT INTO `med` (`med_id`, `med_name`) VALUES (28, 'GABAPENTIN'), (29, 'DOXYCYCLINE'), (30, 'CLOPIDOGREL'), -(31, 'ASDASDASDASD'), -(32, 'ASDASDASDASD'), -(33, 'ASDASDASDASD'); +(34, 'TEST'); -- -- Triggers `med` @@ -201,6 +308,24 @@ DELIMITER ; -- -------------------------------------------------------- +-- +-- Table structure for table `notes` +-- + +CREATE TABLE `notes` ( + `note_id` int NOT NULL, + `takes_id` int 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; + +-- +-- Dumping data for table `notes` +-- + +-- -------------------------------------------------------- + -- -- Table structure for table `staff` -- @@ -210,17 +335,21 @@ CREATE TABLE `staff` ( `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 + `group` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `archived` tinyint(1) NOT NULL DEFAULT '0' ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -- -- Dumping data for table `staff` -- -INSERT INTO `staff` (`staff_id`, `first_name`, `last_name`, `email`, `password`, `group`) VALUES -(1, 'Failed', 'Events', 'failed.events@utcleeds.co.uk', 'failed.events', 'system'), -(5, 'user', 'user', 'user.user@utcleeds.co.uk', '$2y$10$vF4bf/M/qEBKJXKLCwI/AeJPjw7ELS8MyQ9zu3cHRTno55kWX7PeK', 'admin'); +INSERT INTO `staff` (`staff_id`, `first_name`, `last_name`, `email`, `staff_code`, `password`, `group`, `archived`) VALUES +(1, 'Failed', 'Events', 'failed.events@utcleeds.co.uk', '', 'failed.events', 'system', 0), +(5, 'admin', 'user', 'admin.user@utcleeds.co.uk', 'AUS', '$2y$10$m8jI0VvPXXgfQpp6R05ssuoQOfeEtMGoWdh3LibJ0aMG8jJD9Ryz6', 'admin', 0), +(8, 'Joe', 'Bloggs', 'joe.bloggs@utcleeds.co.uk', 'JBL ', '$2y$10$7Pw7G2Tnj.eNkjbZHfcmreLvVumcPwTMEW1kD7uw6HZIRDQ.OsUWC', 'user', 1), +(10, 'basic ', 'user', 'basic.user@utcleeds.co.uk', 'bus', '$2y$10$UKe4cHuSkLWRhBn19oRJauHHUPY4ZdDWW4FLQgZmucS5.7e76iJre', 'user', 0); -- -------------------------------------------------------- @@ -232,47 +361,48 @@ CREATE TABLE `students` ( `student_id` int UNSIGNED 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 + `year` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `archived` int DEFAULT '0' ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -- -- Dumping data for table `students` -- -INSERT INTO `students` (`student_id`, `first_name`, `last_name`, `year`) VALUES -(1, 'JAKE', 'PERALTA', '13'), -(2, 'AMY', 'SANTIAGO', '11'), -(3, 'CHARLES', 'BOYLE', '10'), -(4, 'ROSA', 'DIAZ', '12'), -(5, 'GINA', 'LINETTI', '13'), -(6, 'RAYMOND', 'HOLT', '13'), -(7, 'LUCY', 'CHEN', '12'), -(8, 'TIM', 'BRADFORD', '11'), -(9, 'JOHN', 'NOLAN', '13'), -(10, 'JACKSON', 'WEST', '12'), -(11, 'BAILEY', 'NUNE', '10'), -(12, 'WESLEY', 'EVENS', '10'), -(13, 'ANGELA', 'LOPEZ', '11'), -(14, 'ROSALIND', 'DYER', '12'), -(15, 'NYLA', 'HARPER', '13'), -(16, 'AARON', 'THORSEN', '11'), -(17, 'TAILIA', 'BISHOP', '11'), -(18, 'ZOE', 'ANDERSON', '12'), -(19, 'TAMARA', 'COLLINS', '10'), -(20, 'CELINA', 'JUAREZ', '10'), -(21, 'ELIJA', 'STONE', '12'), -(22, 'MONICA', 'STEVENS', '13'), -(23, 'OSCAR', 'HUTCHINSON', '12'), -(24, 'WADE', 'GREY', '12'), -(25, 'EMMET', 'LANG', '13'), -(26, 'JAMES', 'MURRAY', '13'), -(27, 'MEREDITH', 'GREY', '11'), -(28, 'DEREK', 'SHEPARD', '12'), -(29, 'ALEX', 'KEREV', '10'), -(30, 'MARK', 'SLOAN', '11'), -(31, 'OWEN', 'HUNT', '13'), -(32, 'CRISTINA', 'YANG', '11'), -(33, 'MIRANDA', 'BAILEY', '12'); +INSERT INTO `students` (`student_id`, `first_name`, `last_name`, `year`, `archived`) VALUES +(1, 'JAKE', 'PERALTA', '13', 1), +(2, 'TEST', 'CHANGES', '11', 0), +(3, 'CHARLES', 'BOYLE', '10', 0), +(4, 'ROSA', 'DIAZ', '14', 0), +(5, 'GINA', 'LINETTI', '13', 0), +(6, 'RAYMOND', 'HOLT', '13', 0), +(7, 'LUCY', 'CHEN', '14', 0), +(8, 'TIM', 'BRADFORD', '11', 0), +(9, 'JOHN', 'NOLAN', '13', 0), +(10, 'JACKSON', 'WEST', '14', 0), +(11, 'BAILEY', 'NUNE', '10', 0), +(12, 'WESLEY', 'EVENS', '10', 0), +(13, 'ANGELA', 'LOPEZ', '11', 0), +(14, 'ROSALIND', 'DYER', '14', 0), +(15, 'NYLA', 'HARPER', '13', 0), +(16, 'AARON', 'THORSEN', '11', 0), +(17, 'TAILIA', 'BISHOP', '11', 0), +(18, 'ZOE', 'ANDERSON', '14', 0), +(19, 'TAMARA', 'COLLINS', '10', 0), +(20, 'CELINA', 'JUAREZ', '10', 0), +(21, 'ELIJA', 'STONE', '14', 0), +(22, 'MONICA', 'STEVENS', '13', 0), +(23, 'OSCAR', 'HUTCHINSON', '14', 0), +(24, 'WADE', 'GREY', '14', 0), +(25, 'EMMET', 'LANG', '13', 0), +(26, 'JAMES', 'MURRAY', '13', 0), +(27, 'MEREDITH', 'GREY', '11', 0), +(28, 'DEREK', 'SHEPARD', '14', 0), +(29, 'ALEX', 'KEREV', '10', 0), +(30, 'MARK', 'SLOAN', '11', 0), +(31, 'OWEN', 'HUNT', '13', 0), +(32, 'CRISTINA', 'YANG', '11', 0), +(33, 'MIRANDA', 'BAILEY', '14', 0); -- -- Triggers `students` @@ -317,10 +447,10 @@ CREATE TABLE `takes` ( -- INSERT INTO `takes` (`takes_id`, `student_id`, `med_id`, `brand_id`, `exp_date`, `current_dose`, `min_dose`, `max_dose`, `strength`, `notes`, `archived`) VALUES -(103, 1, 1, 1, 1735862400, 2, 4, 8, '100mg', '', 1), -(104, 2, 2, 2, 1707004800, 4, 1, 30, '50mg', '', 1), -(105, 2, 3, 2, 1733702400, 32, 6, 32, '200mg', '', 0), -(106, 3, 3, 4, 1760659200, 6, 6, 49, '200 mg', '', 0), +(103, 1, 1, 1, 1735862400, 0, 4, 8, '100mg', '', 1), +(104, 2, 2, 2, 1707004800, 1, 1, 30, '50mg', '', 1), +(105, 2, 3, 2, 1733702400, 20, 6, 32, '200mg', '', 0), +(106, 3, 3, 4, 1760659200, 3, 6, 49, '200 mg', '', 0), (107, 3, 4, 5, 1747008000, 30, 6, 31, '500 mg', '', 0), (108, 3, 5, 5, 1745366400, 26, 2, 50, '850 mg', '', 0), (109, 3, 6, 6, 1738713600, 9, 5, 46, '5 mg', '', 0), @@ -333,7 +463,7 @@ INSERT INTO `takes` (`takes_id`, `student_id`, `med_id`, `brand_id`, `exp_date`, (116, 6, 13, 13, 1693526400, 21, 3, 60, '200mg', '', 1), (117, 7, 14, 14, 1751328000, 1, 2, 1, '0.3mg', '', 0), (118, 7, 14, 14, 1751328000, 1, 8, 1, '0.3mg', '', 0), -(119, 8, 15, 15, 1734134400, 5, 9, 7, '30g', 'Stored in a fridge', 0), +(119, 8, 15, 15, 1734134400, 5, 9, 7, '30g', '', 0), (120, 8, 20, 16, 1769904000, 40, 10, 60, '125mg', '', 0), (121, 9, 1, 17, 1759276800, 4, 6, 8, '500mg', '', 0), (122, 9, 18, 18, 1732838400, 6, 2, 7, '30mg', '', 1), @@ -347,7 +477,7 @@ INSERT INTO `takes` (`takes_id`, `student_id`, `med_id`, `brand_id`, `exp_date`, (130, 15, 10, 22, 1652054400, 27, 1, 24, '500 mg', '', 1), (131, 16, 11, 23, 1690329600, 26, 4, 42, '40 mg', '', 1), (132, 17, 14, 14, 1760140800, 1, 6, 1, '0.3mg', '', 0), -(133, 17, 14, 14, 1775001600, 1, 8, 1, '0.3mg', '', 0), +(133, 17, 14, 14, 1775001600, 0, 8, 1, '0.3mg', '', 0), (134, 18, 2, 2, 1716249600, 4, 3, 30, '50mg', '', 1), (135, 19, 3, 2, 1693353600, 32, 4, 32, '200mg', '', 1), (136, 20, 1, 1, 1799884800, 2, 3, 8, '100mg', '', 0), @@ -359,13 +489,17 @@ INSERT INTO `takes` (`takes_id`, `student_id`, `med_id`, `brand_id`, `exp_date`, (142, 26, 24, 28, 1696550400, 10, 6, 30, '40 mg', '', 1), (143, 27, 25, 29, 1821312000, 60, 9, 100, '81 mg', '', 0), (144, 27, 26, 30, 1775952000, 15, 3, 20, '1 mg', '', 0), -(145, 28, 27, 31, 1669507200, 35, 3, 50, '5 mg', 'uasihdajsdkjasdasdjasojasd', 0), +(145, 28, 27, 31, 1669507200, 35, 3, 50, '5 mg', '', 0), (146, 28, 28, 32, 1707091200, 12, 2, 30, '300 mg', '', 0), -(147, 29, 29, 33, 1732406400, 20, 7, 30, '100 mg', 'asdfg', 0), +(147, 29, 29, 33, 1732406400, 20, 7, 30, '100 mg', '', 0), (148, 29, 12, 20, 1696723200, 40, 10, 50, '10 mg', '', 0), (149, 30, 7, 34, 1800835200, 10, 4, 20, '5 mg', '', 0), (150, 31, 30, 35, 1710374400, 60, 10, 90, '75 mg', '', 0), -(151, 31, 1, 36, 1755734400, 20, 2, 30, '500 mg', '', 0); +(151, 31, 1, 36, 1755734400, 20, 2, 30, '500 mg', '', 0), +(152, 20, 5, 4, 1747267200, 69, 69, 420, '69', NULL, 0), +(153, 20, 5, 4, 1747267200, 69, 69, 420, '69', NULL, 0), +(154, 1, 1, 2, 1737504000, 12, 12, 12, '50', NULL, 0), +(155, 1, 2, 2, 1747958400, 12, 12, 12, '12', NULL, 0); -- -------------------------------------------------------- @@ -394,14 +528,6 @@ CREATE TABLE `whole_school` ( `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; - --- --- Dumping data for table `whole_school` --- - -INSERT INTO `whole_school` (`whole_school_id`, `name`, `exp_date`, `amount_left`, `notes`, `archived`) VALUES -(1, 'Defib Pads', 1735776000, 12, '12123123', 0); - -- -- Indexes for dumped tables -- @@ -424,18 +550,18 @@ ALTER TABLE `audit_logs` ALTER TABLE `brand` ADD PRIMARY KEY (`brand_id`); --- --- Indexes for table `log` --- -ALTER TABLE `log` - ADD PRIMARY KEY (`log_id`); - -- -- Indexes for table `med` -- ALTER TABLE `med` ADD PRIMARY KEY (`med_id`); +-- +-- Indexes for table `notes` +-- +ALTER TABLE `notes` + ADD PRIMARY KEY (`note_id`); + -- -- Indexes for table `staff` -- @@ -480,43 +606,43 @@ ALTER TABLE `administer` -- AUTO_INCREMENT for table `audit_logs` -- ALTER TABLE `audit_logs` - MODIFY `audit_id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=83; + MODIFY `audit_id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=229; -- -- AUTO_INCREMENT for table `brand` -- ALTER TABLE `brand` - MODIFY `brand_id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=58; + MODIFY `brand_id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=59; -- --- AUTO_INCREMENT for table `log` +-- AUTO_INCREMENT for table `med` -- -ALTER TABLE `log` - MODIFY `log_id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; +ALTER TABLE `med` + MODIFY `med_id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=35; -- --- AUTO_INCREMENT for table `med` +-- AUTO_INCREMENT for table `notes` -- -ALTER TABLE `med` - MODIFY `med_id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=34; +ALTER TABLE `notes` + MODIFY `note_id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8; -- -- AUTO_INCREMENT for table `staff` -- ALTER TABLE `staff` - MODIFY `staff_id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8; + MODIFY `staff_id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11; -- -- AUTO_INCREMENT for table `students` -- ALTER TABLE `students` - MODIFY `student_id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=877; + MODIFY `student_id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=917; -- -- AUTO_INCREMENT for table `takes` -- ALTER TABLE `takes` - MODIFY `takes_id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=154; + MODIFY `takes_id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=156; -- -- AUTO_INCREMENT for table `whole_log` @@ -528,7 +654,7 @@ ALTER TABLE `whole_log` -- AUTO_INCREMENT for table `whole_school` -- ALTER TABLE `whole_school` - MODIFY `whole_school_id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; + MODIFY `whole_school_id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6; COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; diff --git a/database/empty-database.sql b/database/empty-database.sql new file mode 100644 index 0000000..cc724fe --- /dev/null +++ b/database/empty-database.sql @@ -0,0 +1,347 @@ +-- phpMyAdmin SQL Dump +-- version 5.2.0 +-- https://www.phpmyadmin.net/ +-- +-- Host: localhost:3306 +-- Generation Time: Jan 22, 2025 at 07:08 PM +-- Server version: 8.0.30 +-- PHP Version: 8.1.10 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!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 */; + +-- +-- Database: `utcl-mts` +-- +CREATE DATABASE IF NOT EXISTS `utcl-mts` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; +USE `utcl-mts`; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `administer` +-- + +CREATE TABLE `administer` ( + `adminster_id` int NOT NULL, + `takes_id` int NOT NULL, + `staff_code` text 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; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `audit_logs` +-- + +CREATE TABLE `audit_logs` ( + `audit_id` int UNSIGNED NOT NULL, + `staff_id` int NOT NULL, + `act` text COLLATE utf8mb4_general_ci NOT NULL, + `date_time` int NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `brand` +-- + +CREATE TABLE `brand` ( + `brand_id` int UNSIGNED NOT NULL, + `brand_name` text COLLATE utf8mb4_general_ci NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- +-- Triggers `brand` +-- +DELIMITER $$ +CREATE TRIGGER `before_insert_brand` BEFORE INSERT ON `brand` FOR EACH ROW BEGIN + SET NEW.brand_name = UPPER(NEW.brand_name); +END +$$ +DELIMITER ; +DELIMITER $$ +CREATE TRIGGER `before_update_brand` BEFORE UPDATE ON `brand` FOR EACH ROW BEGIN + SET NEW.brand_name = UPPER(NEW.brand_name); +END +$$ +DELIMITER ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `med` +-- + +CREATE TABLE `med` ( + `med_id` int UNSIGNED NOT NULL, + `med_name` text COLLATE utf8mb4_general_ci NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- +-- Triggers `med` +-- +DELIMITER $$ +CREATE TRIGGER `before_insert_med` BEFORE INSERT ON `med` FOR EACH ROW BEGIN + SET NEW.med_name = UPPER(NEW.med_name); +END +$$ +DELIMITER ; +DELIMITER $$ +CREATE TRIGGER `before_update_med` BEFORE UPDATE ON `med` FOR EACH ROW BEGIN + SET NEW.med_name = UPPER(NEW.med_name); +END +$$ +DELIMITER ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `notes` +-- + +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, + `created_at` datetime DEFAULT CURRENT_TIMESTAMP +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `staff` +-- + +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 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `students` +-- + +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 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- +-- Triggers `students` +-- +DELIMITER $$ +CREATE TRIGGER `before_insert_students` BEFORE INSERT ON `students` FOR EACH ROW BEGIN + SET NEW.first_name = UPPER(NEW.first_name); + SET NEW.last_name = UPPER(NEW.last_name); +END +$$ +DELIMITER ; +DELIMITER $$ +CREATE TRIGGER `before_update_students` BEFORE UPDATE ON `students` FOR EACH ROW BEGIN + SET NEW.first_name = UPPER(NEW.first_name); + SET NEW.last_name = UPPER(NEW.last_name); +END +$$ +DELIMITER ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `takes` +-- + +CREATE TABLE `takes` ( + `takes_id` int UNSIGNED NOT NULL, + `student_id` int NOT NULL, + `med_id` int NOT NULL, + `brand_id` int NOT NULL, + `exp_date` int NOT NULL, + `current_dose` int NOT NULL, + `min_dose` int NOT NULL, + `max_dose` int NOT NULL, + `strength` text 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; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `whole_log` +-- + +CREATE TABLE `whole_log` ( + `whole_log_id` int NOT NULL, + `whole_school_id` int NOT NULL, + `notes` text COLLATE utf8mb4_general_ci NOT NULL, + `date_time` int NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `whole_school` +-- + +CREATE TABLE `whole_school` ( + `whole_school_id` int NOT NULL, + `name` text COLLATE utf8mb4_general_ci NOT NULL, + `exp_date` int NOT NULL, + `amount_left` int NOT NULL, + `notes` text COLLATE utf8mb4_general_ci NOT NULL, + `archived` tinyint(1) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `administer` +-- +ALTER TABLE `administer` + ADD PRIMARY KEY (`adminster_id`); + +-- +-- Indexes for table `audit_logs` +-- +ALTER TABLE `audit_logs` + ADD PRIMARY KEY (`audit_id`); + +-- +-- Indexes for table `brand` +-- +ALTER TABLE `brand` + ADD PRIMARY KEY (`brand_id`); + +-- +-- Indexes for table `med` +-- +ALTER TABLE `med` + ADD PRIMARY KEY (`med_id`); + +-- +-- Indexes for table `notes` +-- +ALTER TABLE `notes` + ADD PRIMARY KEY (`note_id`); + +-- +-- Indexes for table `staff` +-- +ALTER TABLE `staff` + ADD PRIMARY KEY (`staff_id`); + +-- +-- Indexes for table `students` +-- +ALTER TABLE `students` + ADD PRIMARY KEY (`student_id`); + +-- +-- Indexes for table `takes` +-- +ALTER TABLE `takes` + ADD PRIMARY KEY (`takes_id`); + +-- +-- Indexes for table `whole_log` +-- +ALTER TABLE `whole_log` + ADD PRIMARY KEY (`whole_log_id`); + +-- +-- Indexes for table `whole_school` +-- +ALTER TABLE `whole_school` + ADD PRIMARY KEY (`whole_school_id`); + +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- +-- AUTO_INCREMENT for table `administer` +-- +ALTER TABLE `administer` + MODIFY `adminster_id` int NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `audit_logs` +-- +ALTER TABLE `audit_logs` + MODIFY `audit_id` int UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `brand` +-- +ALTER TABLE `brand` + MODIFY `brand_id` int UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `med` +-- +ALTER TABLE `med` + MODIFY `med_id` int UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `notes` +-- +ALTER TABLE `notes` + MODIFY `note_id` int NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `staff` +-- +ALTER TABLE `staff` + MODIFY `staff_id` int UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `students` +-- +ALTER TABLE `students` + MODIFY `student_id` int UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `takes` +-- +ALTER TABLE `takes` + MODIFY `takes_id` int UNSIGNED NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `whole_log` +-- +ALTER TABLE `whole_log` + MODIFY `whole_log_id` int NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `whole_school` +-- +ALTER TABLE `whole_school` + MODIFY `whole_school_id` int NOT NULL AUTO_INCREMENT; +COMMIT; + +/*!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 */; diff --git a/edit_details/student_table.php b/edit_details/student_table.php deleted file mode 100644 index 96dedab..0000000 --- a/edit_details/student_table.php +++ /dev/null @@ -1,197 +0,0 @@ - - -| " . htmlspecialchars($header) . " | "; - } - echo "Progress | "; - echo "
|---|---|
| " . htmlspecialchars($value) . " | "; - } - echo "
-
-
-
- | ";
- echo "
No students found in Year $selected_year.
"; - } - } catch (PDOException $e) { - die("Database error: " . htmlspecialchars($e->getMessage()) . "
"); - } - } - - // Handle the final progress submission - if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['finalize_progress']) && isset($_POST['progress_ids'])) { - $progress_ids = $_POST['progress_ids']; - - try { - // Update the year group for selected students - $update_sql = "UPDATE students SET year = year + 1 WHERE student_id = :student_id"; - $update_stmt = $conn->prepare($update_sql); - - foreach ($progress_ids as $id) { - $update_stmt->bindParam(':student_id', $id, PDO::PARAM_INT); - $update_stmt->execute(); - } - - echo "Year group progression completed successfully.
"; - } catch (PDOException $e) { - die("Database error: " . htmlspecialchars($e->getMessage()) . "
"); - } - } - - // Default student table display logic - $results_per_page = 10; - $page = isset($_GET['page']) ? intval($_GET['page']) : 1; - $start_from = ($page - 1) * $results_per_page; - $search_term = isset($_GET['search']) ? trim($_GET['search']) : ''; - - try { - $total_sql = "SELECT COUNT(*) AS total_records FROM students WHERE CONCAT(first_name, ' ', last_name) LIKE :search OR year LIKE :search"; - $total_stmt = $conn->prepare($total_sql); - $search_param = '%' . $search_term . '%'; - $total_stmt->bindParam(':search', $search_param, PDO::PARAM_STR); - $total_stmt->execute(); - $total_records = $total_stmt->fetch(PDO::FETCH_ASSOC)['total_records']; - $total_pages = ceil($total_records / $results_per_page); - - $sql = "SELECT * FROM students WHERE CONCAT(first_name, ' ', last_name) LIKE :search OR year LIKE :search LIMIT :limit OFFSET :offset"; - $stmt = $conn->prepare($sql); - $stmt->bindParam(':search', $search_param, PDO::PARAM_STR); - $stmt->bindParam(':limit', $results_per_page, PDO::PARAM_INT); - $stmt->bindParam(':offset', $start_from, PDO::PARAM_INT); - $stmt->execute(); - $results = $stmt->fetchAll(PDO::FETCH_ASSOC); - - if ($results) { - echo "| " . htmlspecialchars($header) . " | "; - } - echo "Actions | "; - echo "
|---|---|
| " . htmlspecialchars($value) . " | "; - } - echo "
-
-
- | ";
- echo "
Database error: " . htmlspecialchars($e->getMessage()) . "
"); - } - - ?> -| Brand ID | Brand Name |
|---|---|
| " . htmlspecialchars($cell) . " | "; - } - echo "
| Med ID | Med Name |
|---|---|
| " . htmlspecialchars($cell) . " | "; - } - echo "
| Student ID | First Name | Last Name | Year |
|---|---|---|---|
| " . htmlspecialchars($cell) . " | "; - } - echo "
| "; - echo " | "; - echo " | First name: " . htmlspecialchars($row['first_name']) . " | Last name: " . htmlspecialchars($row['last_name']) . " | "; - } - - // Submit button for the form - echo "
No records found for the given student name.
"; } echo "Database error: " . htmlspecialchars($e->getMessage()) . "
"); } - } else { - echo "Please enter a student name to search.
"; } // Display selected student's data and medication records @@ -113,23 +100,31 @@ class="text_input" $student_data = $stmt->fetchAll(PDO::FETCH_ASSOC); + $staff_id = $_SESSION['staff_id']; + $staff_code = $_SESSION['staff_code']; + $concat_string = htmlspecialchars($student_data[0]['first_name'] . ' ' . $student_data[0]['last_name'] . ' Year '. $student_data[0]['year']); + $action = "$staff_code searched and viewed $concat_string, ID $student_id"; + $source = "Student Profile"; + + logAction($conn, $staff_id, $action, $source); + if (!empty($student_data)) { $full_name = htmlspecialchars($student_data[0]['first_name'] . ' ' . $student_data[0]['last_name']); $year = htmlspecialchars($student_data[0]['year']); echo "| Medication | -Brand | -Current Dose | -Expiry Date | +Medication | +Brand | +Current Dose | +Expiry Date |
|---|---|---|---|---|---|---|---|
| " . htmlspecialchars($row['med_name'] ?? 'N/A') . " | "; - echo "" . htmlspecialchars($row['brand_name'] ?? 'N/A') . " | "; - echo "" . htmlspecialchars($row['current_dose'] ?? 'N/A') . " | "; - echo "" . + echo " | " . htmlspecialchars($row['med_name'] ?? 'N/A') . " | "; + echo "" . htmlspecialchars($row['brand_name'] ?? 'N/A') . " | "; + echo "" . htmlspecialchars($row['current_dose'] ?? 'N/A') . " | "; + echo "" . (isset($row['exp_date']) ? date('Y-m-d', htmlspecialchars($row['exp_date'])) : 'N/A') . " | "; echo "
Selected Student IDs:
+ + +Currently selected student IDs:
+ + + +| "; + foreach ($custom_headings as $heading) { + echo " | " . htmlspecialchars($heading, ENT_QUOTES) . " | "; + } + echo "
|---|---|
| + + | "; + foreach ($custom_headings as $column => $heading) { + $value = $row[$column] ?? ''; + if ($column === 'exp_date' && is_numeric($value)) { + $value = date('d/m/Y', $value); + } + echo "" . htmlspecialchars($value, ENT_QUOTES) . " | "; + } + echo "
+ Trip Dates: + +
+No medication records found for this trip.
"; + } + ?> + +| Trip ID | "; + echo "Trip Name | "; + echo "Start Date | "; + echo "End Date | "; + echo "Number of Students | "; + echo "Actions | "; + echo "
|---|---|---|---|---|---|
| " . htmlspecialchars($trip['trip_id'], ENT_QUOTES) . " | "; + echo "" . htmlspecialchars($trip['trip_name'], ENT_QUOTES) . " | "; + echo "" . htmlspecialchars($startDate, ENT_QUOTES) . " | "; + echo "" . htmlspecialchars($endDate, ENT_QUOTES) . " | "; + echo "" . htmlspecialchars($studentCount, ENT_QUOTES) . " | "; + // The "Check Expirations" action sends you to trip_expiration.php with the trip id + echo " ++ Check Expirations + Export Excel + | "; + echo "
No trips found.
"; + } + } catch (PDOException $e) { + echo "Error fetching trips: " . htmlspecialchars($e->getMessage(), ENT_QUOTES) . "
"; + } + ?> +| " . htmlspecialchars($customHeadings[$header] ?? $header) . " | "; + } + echo "Actions | "; + echo "
|---|---|
| " . htmlspecialchars($value) . " | "; + } + echo "
+ | ";
+ echo "
No records found.
"; + } + } catch (PDOException $e) { + echo "Database error: " . htmlspecialchars($e->getMessage()) . "
"; + } + ?> +| " . htmlspecialchars($customHeadings[$header] ?? $header) . " | "; + } + echo "
|---|
| " . htmlspecialchars($value) . " | "; + } + echo "
No archived records found.
"; + } + } catch (PDOException $e) { + echo "Database error: " . htmlspecialchars($e->getMessage()) . "
"; + } + ?> \ No newline at end of file diff --git a/whole_school/edit_school_record.php b/whole_school/edit_school_record.php index 3c5e419..381e7e1 100644 --- a/whole_school/edit_school_record.php +++ b/whole_school/edit_school_record.php @@ -1,6 +1,10 @@ bindParam(':whole_school_id', $whole_school_id, PDO::PARAM_INT); $update_stmt->execute(); + $staff_id = $_SESSION['staff_id']; + $staff_code = $_SESSION['staff_code']; + $action = "$staff_code updated $whole_school_id , $name , $exp_date, $amount_left, $notes"; + $source = "Whole School Medication"; + + logAction($conn, $staff_id, $action, $source); + + $success_message = "Record updated successfully."; + header("location: active_records.php"); } catch (PDOException $e) { $error_message = "Database error: " . htmlspecialchars($e->getMessage()); } } else { $error_message = "All fields are required, and amount left must be a non-negative integer."; + $staff_id = $_SESSION['staff_id']; + $staff_code = $_SESSION['staff_code']; + $action = "$staff_code failed to edit record mutliple invalid inputs"; + $source = "Whole School Medication"; + + logAction($conn, $staff_id, $action, $source); } } ?> @@ -65,26 +84,6 @@| " . htmlspecialchars($header) . " | "; - } - echo "Actions | "; - echo "
|---|---|
| " . htmlspecialchars($value) . " | "; - } - echo "
- | ";
- echo "
No records found.
"; - } - } catch (PDOException $e) { - echo "Database error: " . htmlspecialchars($e->getMessage()) . "
"; - } - ?> - - - - -| " . htmlspecialchars($header) . " | "; - } - echo "
|---|
| " . htmlspecialchars($value) . " | "; - } - echo "
No archived records found.
"; - } - } catch (PDOException $e) { - echo "Database error: " . htmlspecialchars($e->getMessage()) . "
"; - } - ?> -