-
\ No newline at end of file
+
diff --git a/admin/orders.php b/admin/orders.php
index ec07f67..fa9ad9f 100644
--- a/admin/orders.php
+++ b/admin/orders.php
@@ -56,7 +56,7 @@ if (isset($_GET['delete'])) {
}
// Fetch Outlets for Filter
-$outlets = $pdo->query("SELECT id, name FROM outlets ORDER BY name")->fetchAll(PDO::FETCH_ASSOC);
+$outlets = $pdo->query("SELECT id, name FROM outlets WHERE is_deleted = 0 ORDER BY name")->fetchAll(PDO::FETCH_ASSOC);
// Build Query with Filters
$params = [];
@@ -78,11 +78,16 @@ if (!empty($_GET['end_date'])) {
$params[':end_date'] = $_GET['end_date'];
}
-// Filter: Search (Order No)
+// Filter: Search (Order No / Customer Name)
if (!empty($_GET['search'])) {
- if (is_numeric($_GET['search'])) {
- $where[] = "o.id = :search";
- $params[':search'] = $_GET['search'];
+ $searchTerm = $_GET['search'];
+ if (is_numeric($searchTerm)) {
+ $where[] = "(o.id = :search_exact OR o.customer_name LIKE :search_like)";
+ $params[':search_exact'] = $searchTerm;
+ $params[':search_like'] = "%$searchTerm%";
+ } else {
+ $where[] = "o.customer_name LIKE :search";
+ $params[':search'] = "%$searchTerm%";
}
}
@@ -246,7 +251,7 @@ include 'includes/header.php';
-
+
diff --git a/db/migrations/041_fix_tables_naming.sql b/db/migrations/041_fix_tables_naming.sql
index 32a00bb..86f02fb 100644
--- a/db/migrations/041_fix_tables_naming.sql
+++ b/db/migrations/041_fix_tables_naming.sql
@@ -16,7 +16,7 @@ ALTER TABLE `tables` ADD COLUMN IF NOT EXISTS `is_deleted` TINYINT(1) DEFAULT 0;
-- But usually, if they have 'name', they need to move it to 'table_number'.
-- If name exists, this will work. If not, it will fail, which is okay for this specific fix.
-UPDATE `tables` SET `table_number` = `name` WHERE `table_number` IS NULL OR `table_number` = '';
+-- UPDATE `tables` SET `table_number` = `name` WHERE `table_number` IS NULL OR `table_number` = '';
-- Fix areas foreign key if it was wrong in their initial setup
ALTER TABLE `areas` DROP FOREIGN KEY IF EXISTS `areas_ibfk_1`;
diff --git a/db/migrations/042_add_reset_token_to_users.sql b/db/migrations/042_add_reset_token_to_users.sql
new file mode 100644
index 0000000..e3840c9
--- /dev/null
+++ b/db/migrations/042_add_reset_token_to_users.sql
@@ -0,0 +1,2 @@
+ALTER TABLE users ADD COLUMN reset_token VARCHAR(255) DEFAULT NULL;
+ALTER TABLE users ADD COLUMN reset_token_expiry DATETIME DEFAULT NULL;
diff --git a/forgot_password.php b/forgot_password.php
new file mode 100644
index 0000000..07ed5ef
--- /dev/null
+++ b/forgot_password.php
@@ -0,0 +1,122 @@
+prepare("SELECT id, username, full_name FROM users WHERE email = ? AND is_deleted = 0 LIMIT 1");
+ $stmt->execute([$email]);
+ $user = $stmt->fetch(PDO::FETCH_ASSOC);
+
+ if ($user) {
+ $token = bin2hex(random_bytes(32));
+ $expiry = date('Y-m-d H:i:s', strtotime('+1 hour'));
+
+ $stmt = $pdo->prepare("UPDATE users SET reset_token = ?, reset_token_expiry = ? WHERE id = ?");
+ $stmt->execute([$token, $expiry, $user['id']]);
+
+ $resetLink = $baseUrl . "reset_password.php?token=" . $token;
+
+ $subject = "Password Reset Request - " . $settings['company_name'];
+ $messageHtml = "
+