Date: ${data.date}
${tr['Date']}: ${data.date}
diff --git a/admin/orders.php b/admin/orders.php
index 9422f25..3929f05 100644
--- a/admin/orders.php
+++ b/admin/orders.php
@@ -321,16 +321,27 @@ include 'includes/header.php';
- 'bg-info',
- 'takeaway' => 'bg-success',
- 'delivery' => 'bg-warning',
- 'drive-thru' => 'bg-primary',
- default => 'bg-secondary'
+ "bg-info",
+ "takeaway" => "bg-success",
+ "delivery" => "bg-warning",
+ "drive-thru" => "bg-primary",
+ default => "bg-secondary"
+ };
+ $source_name = match($order["source"] ?? "pos") {
+ "online" => "Online",
+ "qr" => "QR Order",
+ default => "POS"
+ };
+ $source_badge = match($order["source"] ?? "pos") {
+ "online" => "bg-success",
+ "qr" => "bg-info",
+ default => "bg-secondary"
};
?>
- = ucfirst($order['order_type']) ?>
+ mb-1">= ucfirst($order["order_type"]) ?>
+ = $source_name ?>
|
= format_currency($order['vat']) ?>
diff --git a/api/kitchen.php b/api/kitchen.php
index 19a2acb..617693b 100644
--- a/api/kitchen.php
+++ b/api/kitchen.php
@@ -14,7 +14,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
// Kitchen sees: pending, preparing, ready
$stmt = $pdo->prepare("
SELECT
- o.id, o.table_number, o.order_type, o.status, o.created_at, o.ready_time, o.customer_name, o.car_plate, o.user_id,
+ o.id, o.table_number, o.order_type, o.source, o.status, o.created_at, o.ready_time, o.customer_name, o.car_plate, o.user_id,
oi.quantity, COALESCE(p.name, oi.product_name) as product_name, COALESCE(v.name, oi.variant_name) as variant_name
FROM orders o
JOIN order_items oi ON o.id = oi.order_id
diff --git a/api/order.php b/api/order.php
index 7f47608..94f22e6 100644
--- a/api/order.php
+++ b/api/order.php
@@ -26,6 +26,9 @@ try {
: 'dine-in';
// Get outlet_id from input, default to 1 if missing
+ $allowed_sources = ['pos', 'online', 'qr'];
+ $source = isset($data['source']) && in_array($data['source'], $allowed_sources) ? $data['source'] : 'pos';
+
$outlet_id = !empty($data['outlet_id']) ? intval($data['outlet_id']) : 1;
$table_id = null;
@@ -89,7 +92,7 @@ try {
if ($existing) {
$customer_id = $existing['id'];
} else {
- $stmt = $pdo->prepare("INSERT INTO customers (name, phone) VALUES (?, ?)");
+ $stmt = $pdo->prepare("INSERT INTO customers (name, phone) VALUES (?, ?, ?)");
$stmt->execute([$customer_name, $customer_phone]);
$customer_id = $pdo->lastInsertId();
}
@@ -251,7 +254,7 @@ try {
->execute([$redemptions_done, $customer_id]);
// Record Loyalty History (Deduction)
- $historyStmt = $pdo->prepare("INSERT INTO loyalty_points_history (customer_id, points_change, reason) VALUES (?, ?, 'Redeemed Free Product(s)')");
+ $historyStmt = $pdo->prepare("INSERT INTO loyalty_points_history (customer_id, points_change, reason) VALUES (?, ?, ?, 'Redeemed Free Product(s)')");
$historyStmt->execute([$customer_id, -$points_deducted]);
$redeem_history_id = $pdo->lastInsertId();
@@ -290,7 +293,7 @@ try {
$awardStmt->execute([$points_awarded, $customer_id]);
// Record Loyalty History (Award)
- $historyStmt = $pdo->prepare("INSERT INTO loyalty_points_history (customer_id, points_change, reason) VALUES (?, ?, 'Earned from Products')");
+ $historyStmt = $pdo->prepare("INSERT INTO loyalty_points_history (customer_id, points_change, reason) VALUES (?, ?, ?, 'Earned from Products')");
$historyStmt->execute([$customer_id, $points_awarded]);
$award_history_id = $pdo->lastInsertId();
}
@@ -335,14 +338,15 @@ try {
}
if ($is_update) {
- $stmt = $pdo->prepare("UPDATE orders SET
+ $stmt = $pdo->prepare("UPDATE orders SET
+ source = ?,
outlet_id = ?, table_id = ?, table_number = ?, order_type = ?,
customer_id = ?, customer_name = ?, customer_phone = ?, car_plate = ?, ready_time = ?,
payment_type_id = ?, total_amount = ?, discount = ?, vat = ?, user_id = ?,
commission_amount = ?, status = 'pending'
WHERE id = ?");
$stmt->execute([
- $outlet_id, $table_id, $table_number, $order_type,
+ $source, $outlet_id, $table_id, $table_number, $order_type,
$customer_id, $customer_name, $customer_phone, $car_plate, $ready_time,
$payment_type_id, $final_total, 0, $calculated_vat, $user_id,
$commission_amount, $order_id
@@ -351,8 +355,8 @@ try {
$delStmt = $pdo->prepare("DELETE FROM order_items WHERE order_id = ?");
$delStmt->execute([$order_id]);
} else {
- $stmt = $pdo->prepare("INSERT INTO orders (outlet_id, table_id, table_number, order_type, customer_id, customer_name, customer_phone, car_plate, ready_time, payment_type_id, total_amount, discount, vat, user_id, commission_amount, status) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'pending')");
- $stmt->execute([$outlet_id, $table_id, $table_number, $order_type, $customer_id, $customer_name, $customer_phone, $car_plate, $ready_time, $payment_type_id, $final_total, 0, $calculated_vat, $user_id, $commission_amount]);
+ $stmt = $pdo->prepare("INSERT INTO orders (source, outlet_id, table_id, table_number, order_type, customer_id, customer_name, customer_phone, car_plate, ready_time, payment_type_id, total_amount, discount, vat, user_id, commission_amount, status) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'pending')");
+ $stmt->execute([$source, $outlet_id, $table_id, $table_number, $order_type, $customer_id, $customer_name, $customer_phone, $car_plate, $ready_time, $payment_type_id, $final_total, 0, $calculated_vat, $user_id, $commission_amount]);
$order_id = $pdo->lastInsertId();
}
@@ -367,7 +371,7 @@ try {
}
// Insert Items and Update Stock
- $item_stmt = $pdo->prepare("INSERT INTO order_items (order_id, product_id, product_name, variant_id, variant_name, quantity, unit_price, vat_percent, vat_amount) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
+ $item_stmt = $pdo->prepare("INSERT INTO order_items (order_id, product_id, product_name, variant_id, variant_name, quantity, unit_price, vat_percent, vat_amount) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
$stock_stmt = $pdo->prepare("UPDATE products SET stock_quantity = stock_quantity - ? WHERE id = ?");
$order_items_list = [];
diff --git a/assets/js/main.js b/assets/js/main.js
index 5f0b592..b4aae23 100644
--- a/assets/js/main.js
+++ b/assets/js/main.js
@@ -769,6 +769,7 @@ document.addEventListener('DOMContentLoaded', () => {
total: isLoyaltyRedemption ? 0 : (subtotal + totalVat),
vat: isLoyaltyRedemption ? 0 : totalVat,
orderType: orderType,
+ source: 'pos',
tableNumber: (orderType === 'dine-in') ? currentTableName : null,
date: new Date().toLocaleString('en-US', { year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' }),
paymentMethod: paymentTypeName || (isLoyaltyRedemption ? 'Loyalty Redeem' : 'Unpaid'),
@@ -939,7 +940,8 @@ document.addEventListener('DOMContentLoaded', () => {
Order: #${data.orderId}${tr['Order']}: #${data.orderId}
- Type: ${data.orderType.toUpperCase()}${tr['Type']}: ${tr[data.orderType] || data.orderType}
+ Type: ${data.orderType.toUpperCase()}${tr['Type']}: ${tr[data.orderType] || data.orderType}
+ ${data.source ? \` Source: ${data.source.toUpperCase()}${tr['Source'] || "Source"}: ${data.source.toUpperCase()} \` : ""}
Date: ${data.date}${tr['Date']}: ${data.date}
Staff: ${CURRENT_USER.name}${tr['Staff']}: ${CURRENT_USER.name}
diff --git a/db/migrations/050_add_source_to_orders.sql b/db/migrations/050_add_source_to_orders.sql
new file mode 100644
index 0000000..ba34ae0
--- /dev/null
+++ b/db/migrations/050_add_source_to_orders.sql
@@ -0,0 +1 @@
+ALTER TABLE orders ADD COLUMN source VARCHAR(50) DEFAULT 'pos';
diff --git a/includes/PrinterService.php b/includes/PrinterService.php
index 9707195..63a0d2f 100644
--- a/includes/PrinterService.php
+++ b/includes/PrinterService.php
@@ -58,6 +58,11 @@ class PrinterService {
$out .= $esc . "a" . "\x00"; // Left align
$out .= "Order ID: #" . $order['id'] . "\n";
+ $out .= "Type: " . strtoupper($order['order_type'] ?? '') . "\n";
+ if (!empty($order['table_number'])) {
+ $out .= "Table: " . $order['table_number'] . "\n";
+ }
+ $out .= "Source: " . strtoupper($order['source'] ?? 'POS') . "\n";
$out .= "Date: " . ($order['created_at'] ?? date('Y-m-d H:i:s')) . "\n";
if (!empty($order['customer_name'])) {
$out .= "Customer: " . $order['customer_name'] . "\n";
diff --git a/kitchen.php b/kitchen.php
index fa2ed5c..77d83cb 100644
--- a/kitchen.php
+++ b/kitchen.php
@@ -282,7 +282,8 @@ function renderOrders(orders) {
- ${order.order_type === 'dine-in' ? `Table ${order.table_number}` : order.order_type.toUpperCase()}
+ ${order.order_type === 'dine-in' ? \`Table ${order.table_number}\` : order.order_type.toUpperCase()}
+ ${order.source ? order.source.toUpperCase() : "POS"}
${order.customer_name ? ` ${order.customer_name}` : ''}
${order.car_plate ? ` ${order.car_plate}` : ''}
${order.ready_time ? ` ` : ''}
@@ -348,7 +349,8 @@ function printKitchenTicket(orderId) {
#${order.id}
- Type: ${order.order_type.toUpperCase()}
+ Type: ${order.order_type.toUpperCase()}
+ Source: ${order.source ? order.source.toUpperCase() : "POS"}
${order.order_type === 'dine-in' ? ` Table: ${order.table_number} ` : ''}
Time: ${new Date(order.created_at).toLocaleString()}
${order.customer_name ? ` Cust: ${order.customer_name} ` : ''}
diff --git a/online_order.php b/online_order.php
index 174d6d6..6c746da 100644
--- a/online_order.php
+++ b/online_order.php
@@ -871,6 +871,7 @@ foreach ($variants_by_product as $pid => $vars) {
}
const orderData = {
+ source: 'online',
table_id: = $table_id ?>,
outlet_id: = $outlet_id ?>,
items: cart.map(item => ({
diff --git a/qorder.php b/qorder.php
index 3911a9a..56f35ea 100644
--- a/qorder.php
+++ b/qorder.php
@@ -698,6 +698,7 @@ foreach ($variants_raw as $v) {
if (cart.length === 0) return;
const orderData = {
+ source: 'qr',
table_id: = $table_id ?>,
outlet_id: = $outlet_id ?>,
items: cart.map(item => ({
|