diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..ab01c12a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Ignore +src/includes/error-logs.txt \ No newline at end of file diff --git a/src/accounts.php b/src/accounts.php index 2e04a40e..385178dd 100644 --- a/src/accounts.php +++ b/src/accounts.php @@ -1,9 +1,15 @@ query($sql); + $row = $result->fetch_assoc(); + ?> @@ -28,7 +34,8 @@ @@ -73,21 +80,21 @@ query($sql); - - while($row = $result->fetch_assoc()) { - echo ' - - - '.$row['last_name'].' - '.$row["first_name"].' - '.$row['middle_name'].' - '.$row['email'].' - - '; - } - ?> + $sql = "SELECT * FROM user"; + $result = $db->query($sql); + while($row = $result->fetch_assoc()) { + echo ' + + + '.$row['last_name'].' + '.$row["first_name"].' + '.$row['middle_name'].' + '.$row['email'].' + + '; + } + $db->close(); + ?> @@ -204,6 +211,7 @@ class="btn fw-medium btn-medium-brown text-capitalize py-2 px-4">add account + + diff --git a/src/delete-account.php b/src/delete-account.php index 12107279..9597073b 100644 --- a/src/delete-account.php +++ b/src/delete-account.php @@ -1,6 +1,8 @@ prepare("SELECT id, username, password FROM user WHERE BINARY username = ?"); + $stmt->bind_param('s', $username); + $stmt->execute(); + $result = $stmt->get_result(); + + // Check if a user of this username exists + if($result->num_rows > 0) { + $row = $result->fetch_assoc(); + + // Verify if password match the entered username + if (password_verify($password, $row['password'])) { + $_SESSION['id'] = $row['id']; + session_regenerate_id(true); + header("location: ../index.php"); + exit(); + } + // If username and password mismatched, display this + else { + $_SESSION['error_message'] = 'Username and password mismatched.'; + header("Location: ../login.php"); + exit(); + } + } + // If there is no user with the username, display this + else { + $_SESSION['error_message'] = 'User is not found.'; + header("Location: ../login.php"); + exit(); + } +} \ No newline at end of file diff --git a/src/includes/logout.php b/src/includes/logout.php new file mode 100644 index 00000000..719907ad --- /dev/null +++ b/src/includes/logout.php @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/src/includes/mailer.php b/src/includes/mailer.php index 53986f83..0bb4387d 100644 --- a/src/includes/mailer.php +++ b/src/includes/mailer.php @@ -4,7 +4,9 @@ use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; -require __DIR__ . "/../../vendor/autoload.php"; +include_once str_replace('/', DIRECTORY_SEPARATOR, 'file-utilities.php'); +require FileUtils::normalizeFilePath(__DIR__ . "/../../vendor/autoload.php"); +include_once FileUtils::normalizeFilePath('error-reporting.php'); // CONFIGURATION diff --git a/src/includes/navbar.php b/src/includes/navbar.php index fd5c8adc..f803a864 100644 --- a/src/includes/navbar.php +++ b/src/includes/navbar.php @@ -1,5 +1,7 @@ prepare("SELECT id, first_name FROM user WHERE id = ?"); @@ -73,7 +75,7 @@ Accounts -
  • +
  • diff --git a/src/includes/preloader.html b/src/includes/preloader.html new file mode 100644 index 00000000..fc185a37 --- /dev/null +++ b/src/includes/preloader.html @@ -0,0 +1,5 @@ +
    +
    + +
    +
    \ No newline at end of file diff --git a/src/includes/process-reset-password.php b/src/includes/process-reset-password.php index 781a41ac..7f444fa0 100644 --- a/src/includes/process-reset-password.php +++ b/src/includes/process-reset-password.php @@ -1,6 +1,7 @@ fetch(); $stmt->close(); -$sql = "SELECT SUM(total_amount) AS monthly_sale - FROM transaction - WHERE YEAR(timestamp) = YEAR(CURRENT_DATE()) - AND MONTH(timestamp) = MONTH(CURRENT_DATE()) - AND DAY(timestamp) <= DAY(CURRENT_DATE())"; +$sql = "SELECT SUM(total_amount) AS monthly_sale FROM transaction WHERE YEAR(timestamp) = YEAR(CURRENT_DATE()) AND MONTH(timestamp) = MONTH(CURRENT_DATE()) AND DAY(timestamp) <= DAY(CURRENT_DATE())"; $stmt = $db->prepare($sql); $stmt->execute(); $stmt->bind_result($monthly_sale); @@ -69,7 +66,7 @@ @@ -78,13 +75,14 @@ @@ -252,6 +250,7 @@ + \ No newline at end of file diff --git a/src/javascript/preloader.js b/src/javascript/preloader.js new file mode 100644 index 00000000..4146f362 --- /dev/null +++ b/src/javascript/preloader.js @@ -0,0 +1,9 @@ +const spinnerWrapper = document.querySelector(".spinner-wrapper"); + +window.addEventListener("load", () => { + spinnerWrapper.style.opacity = "0"; + + setTimeout(() => { + spinnerWrapper.style.display = "none"; + }, 200); +}); diff --git a/src/login.php b/src/login.php index f996857e..c5a38bbc 100644 --- a/src/login.php +++ b/src/login.php @@ -1,7 +1,7 @@ prepare("SELECT id, username, password FROM user WHERE BINARY username = ?"); - $stmt->bind_param('s', $username); - $stmt->execute(); - $result = $stmt->get_result(); - - // Check if a user of this username exists - if($result->num_rows > 0) { - $row = $result->fetch_assoc(); - - // Verify if password match the entered username - if (password_verify($password, $row['password'])) { - $_SESSION['id'] = $row['id']; - session_regenerate_id(true); - header("location: index.php"); - exit(); - } - // If username and password mismatched, display this - else { - $_SESSION['error_message'] = 'Username and password mismatched.'; - header("Location: login.php"); - exit(); - } - } - // If there is no user with the username, display this - else { - $_SESSION['error_message'] = 'User is not found.'; - header("Location: login.php"); - exit(); - } -} - if (isset($_SESSION['error_message'])) { $errorMessage = $_SESSION['error_message']; unset($_SESSION['error_message']); @@ -93,6 +50,8 @@ + + - - - - - - + diff --git a/src/logout.php b/src/logout.php deleted file mode 100644 index 36966d9c..00000000 --- a/src/logout.php +++ /dev/null @@ -1,6 +0,0 @@ - \ No newline at end of file diff --git a/src/product.php b/src/product.php index bd0233a4..bd037f3a 100644 --- a/src/product.php +++ b/src/product.php @@ -1,6 +1,8 @@ @@ -317,6 +320,7 @@ + + \ No newline at end of file diff --git a/src/sales.php b/src/sales.php index 313b8682..45bdec6d 100644 --- a/src/sales.php +++ b/src/sales.php @@ -1,6 +1,8 @@ @@ -181,6 +184,7 @@ +