From 13a3054fd1286503a4e52dbce39db58cc3581302 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Thu, 26 Feb 2026 15:17:34 +0000 Subject: [PATCH] adding fat --- admin/orders.php | 26 +++++--------- admin/products.php | 36 +++++++++++++------ admin/tables.php | 79 +++++++++++++++++++++++++++++++++++++++--- api/order.php | 46 +++++++++++++++---------- assets/js/main.js | 86 +++++++++++++++++++++++++++++++++------------- pos.php | 7 +++- qorder.php | 9 ++--- 7 files changed, 210 insertions(+), 79 deletions(-) diff --git a/admin/orders.php b/admin/orders.php index 3338a0c..218a88d 100644 --- a/admin/orders.php +++ b/admin/orders.php @@ -86,13 +86,14 @@ if (!empty($_GET['search'])) { $where_clause = !empty($where) ? 'WHERE ' . implode(' AND ', $where) : ''; -// Calculate Total Sum and Total Commission for filtered orders -$sum_query = "SELECT SUM(total_amount) as total_sum, SUM(commission_amount) as total_commission FROM orders o $where_clause"; +// Calculate Total Sum and Total Commission and Total VAT for filtered orders +$sum_query = "SELECT SUM(total_amount) as total_sum, SUM(commission_amount) as total_commission, SUM(vat) as total_vat FROM orders o $where_clause"; $stmt_sum = $pdo->prepare($sum_query); $stmt_sum->execute($params); $sum_data = $stmt_sum->fetch(PDO::FETCH_ASSOC); $total_sum = (float)($sum_data['total_sum'] ?? 0); $total_commission = (float)($sum_data['total_commission'] ?? 0); +$total_vat_sum = (float)($sum_data['total_vat'] ?? 0); // Main Query $query = "SELECT o.*, ot.name as outlet_name, pt.name as payment_type_name, u.username as cashier_name, @@ -107,9 +108,6 @@ $query = "SELECT o.*, ot.name as outlet_name, pt.name as payment_type_name, u.us $orders_pagination = paginate_query($pdo, $query, $params); $orders = $orders_pagination['data']; -// Add total sum to pagination object for rendering -$orders_pagination['total_amount_sum'] = $total_sum; - $settings = get_company_settings(); $commission_enabled = !empty($settings['commission_enabled']); @@ -170,7 +168,6 @@ include 'includes/header.php'; -
@@ -179,15 +176,14 @@ include 'includes/header.php';
-
Total Commission
-
+
Total VAT
+
- -
+
@@ -202,7 +198,7 @@ include 'includes/header.php';
-
+
@@ -279,7 +275,7 @@ include 'includes/header.php'; Cashier Customer Type - Source + VAT Total Commission @@ -326,11 +322,7 @@ include 'includes/header.php'; - - Table - - - + diff --git a/admin/products.php b/admin/products.php index 6a04893..e6fe17d 100644 --- a/admin/products.php +++ b/admin/products.php @@ -15,6 +15,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) { $name_ar = $_POST['name_ar'] ?? ''; $category_id = (int)$_POST['category_id']; $price = (float)$_POST['price']; + $vat_percent = (float)($_POST['vat_percent'] ?? 0); $cost_price = (float)($_POST['cost_price'] ?? 0); $stock_quantity = (int)($_POST['stock_quantity'] ?? 0); $description = $_POST['description'] ?? ''; @@ -48,16 +49,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) { if (!has_permission('products_edit')) { $message = '
Access Denied: You do not have permission to edit products.
'; } else { - $stmt = $pdo->prepare("UPDATE products SET name = ?, name_ar = ?, category_id = ?, price = ?, cost_price = ?, stock_quantity = ?, description = ?, image_url = ?, promo_discount_percent = ?, promo_date_from = ?, promo_date_to = ?, is_loyalty = ? WHERE id = ?"); - $stmt->execute([$name, $name_ar, $category_id, $price, $cost_price, $stock_quantity, $description, $image_url, $promo_discount_percent, $promo_date_from, $promo_date_to, $is_loyalty, $id]); + $stmt = $pdo->prepare("UPDATE products SET name = ?, name_ar = ?, category_id = ?, price = ?, vat_percent = ?, cost_price = ?, stock_quantity = ?, description = ?, image_url = ?, promo_discount_percent = ?, promo_date_from = ?, promo_date_to = ?, is_loyalty = ? WHERE id = ?"); + $stmt->execute([$name, $name_ar, $category_id, $price, $vat_percent, $cost_price, $stock_quantity, $description, $image_url, $promo_discount_percent, $promo_date_from, $promo_date_to, $is_loyalty, $id]); $message = '
Product updated successfully!
'; } } elseif ($action === 'add_product') { if (!has_permission('products_add')) { $message = '
Access Denied: You do not have permission to add products.
'; } else { - $stmt = $pdo->prepare("INSERT INTO products (name, name_ar, category_id, price, cost_price, stock_quantity, description, image_url, promo_discount_percent, promo_date_from, promo_date_to, is_loyalty) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); - $stmt->execute([$name, $name_ar, $category_id, $price, $cost_price, $stock_quantity, $description, $image_url, $promo_discount_percent, $promo_date_from, $promo_date_to, $is_loyalty]); + $stmt = $pdo->prepare("INSERT INTO products (name, name_ar, category_id, price, vat_percent, cost_price, stock_quantity, description, image_url, promo_discount_percent, promo_date_from, promo_date_to, is_loyalty) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + $stmt->execute([$name, $name_ar, $category_id, $price, $vat_percent, $cost_price, $stock_quantity, $description, $image_url, $promo_discount_percent, $promo_date_from, $promo_date_to, $is_loyalty]); $message = '
Product created successfully!
'; } } @@ -184,6 +185,7 @@ include 'includes/header.php'; + @@ -223,6 +225,9 @@ include 'includes/header.php'; : + + % + @@ -256,7 +261,7 @@ include 'includes/header.php'; - + @@ -306,7 +311,7 @@ include 'includes/header.php';
-
+
-
+
+ +
+ + +
-
+
-
+
-
+
@@ -400,6 +415,7 @@ function prepareEditForm(p) { document.getElementById('productNameAr').value = p.name_ar || ''; document.getElementById('productCategoryId').value = p.category_id; document.getElementById('productPrice').value = p.price; + document.getElementById('productVatPercent').value = parseFloat(p.vat_percent || 0); document.getElementById('productCostPrice').value = p.cost_price || ''; document.getElementById('productStockQuantity').value = p.stock_quantity || '0'; document.getElementById('productDescription').value = p.description || ''; diff --git a/admin/tables.php b/admin/tables.php index 63455eb..46489e7 100644 --- a/admin/tables.php +++ b/admin/tables.php @@ -74,6 +74,15 @@ $tables_pagination = paginate_query($pdo, $query); $tables = $tables_pagination['data']; include 'includes/header.php'; + +// Base URL for QR codes +$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || ($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '') === 'https') ? "https://" : "http://"; +$host = $_SERVER['HTTP_HOST']; +// Calculate project root +$current_dir = dirname($_SERVER['PHP_SELF']); // /admin +$project_root = dirname($current_dir); // / +if ($project_root === DIRECTORY_SEPARATOR) $project_root = ''; +$baseUrl = $protocol . $host . $project_root; ?>
@@ -102,6 +111,7 @@ include 'includes/header.php'; Area Capacity Status + QR Code Actions @@ -121,6 +131,12 @@ include 'includes/header.php'; + + +
+ + + + - - \ No newline at end of file +function showTableQR(id, number) { + const baseUrl = ''; + const qorderUrl = baseUrl + '/qorder.php?table_id=' + id; + const qrCodeUrl = "https://api.qrserver.com/v1/create-qr-code/?size=300x300&data=" + encodeURIComponent(qorderUrl); + + document.getElementById('qrTableNumber').innerText = 'Table ' + number; + document.getElementById('qrContainer').innerHTML = 'QR Code'; + document.getElementById('qrLink').innerText = qorderUrl; + + const modal = new bootstrap.Modal(document.getElementById('qrModal')); + modal.show(); +} + +function printQR() { + const content = document.getElementById('printableQR').innerHTML; + const printWindow = window.open('', '_blank'); + printWindow.document.write('Print Table QR'); + printWindow.document.write(''); + printWindow.document.write(''); + printWindow.document.write(''); + printWindow.document.write(content); + printWindow.document.write(''); + printWindow.document.close(); + setTimeout(() => { + printWindow.print(); + printWindow.close(); + }, 500); +} + + + diff --git a/api/order.php b/api/order.php index 21bfb8d..513e74e 100644 --- a/api/order.php +++ b/api/order.php @@ -29,11 +29,11 @@ try { $table_number = null; if ($order_type === 'dine-in') { - $tid = $data['table_number'] ?? null; // Front-end sends ID as table_number + $tid = $data['table_id'] ?? ($data['table_number'] ?? null); // Support both table_id and table_number as numeric ID if ($tid) { // Validate table exists AND belongs to the correct outlet $stmt = $pdo->prepare( - "SELECT t.id, t.name + "SELECT t.id, t.table_number FROM tables t JOIN areas a ON t.area_id = a.id WHERE t.id = ? AND a.outlet_id = ?" @@ -42,7 +42,7 @@ try { $table = $stmt->fetch(PDO::FETCH_ASSOC); if ($table) { $table_id = $table['id']; - $table_number = $table['name']; + $table_number = $table['table_number']; } } @@ -50,7 +50,7 @@ try { if (!$table_id) { // Optional: try to find the first available table for this outlet $stmt = $pdo->prepare( - "SELECT t.id, t.name + "SELECT t.id, t.table_number FROM tables t JOIN areas a ON t.area_id = a.id WHERE a.outlet_id = ? @@ -60,7 +60,7 @@ try { $table = $stmt->fetch(PDO::FETCH_ASSOC); if ($table) { $table_id = $table['id']; - $table_number = $table['name']; + $table_number = $table['table_number']; } } } @@ -105,7 +105,8 @@ try { } // Total amount will be recalculated on server to be safe - $calculated_total = 0; + $calculated_subtotal = 0; + $calculated_vat = 0; // First, process items to calculate real total and handle loyalty $processed_items = []; @@ -126,6 +127,7 @@ try { if (!$product) continue; $unit_price = get_product_price($product); + $vat_percent = floatval($product['vat_percent'] ?? 0); $variant_name = null; // Add variant adjustment @@ -150,6 +152,7 @@ try { 'variant_name' => $variant_name, 'quantity' => $qty, 'unit_price' => $unit_price, + 'vat_percent' => $vat_percent, 'is_loyalty' => (bool)$product['is_loyalty'] ]; } @@ -230,14 +233,22 @@ try { } } - // Recalculate Subtotal and Earned Points - foreach ($processed_items as $pi) { - $calculated_total += $pi['unit_price'] * $pi['quantity']; + // Recalculate Subtotal, VAT and Earned Points + foreach ($processed_items as &$pi) { + $item_subtotal = $pi['unit_price'] * $pi['quantity']; + $item_vat = $item_subtotal * ($pi['vat_percent'] / 100); + + $pi['vat_amount'] = $item_vat; + + $calculated_subtotal += $item_subtotal; + $calculated_vat += $item_vat; + // Award points for PAID loyalty items if ($pi['is_loyalty'] && $pi['unit_price'] > 0 && $pi['quantity'] > 0) { $points_awarded += $pi['quantity'] * $points_per_product; } } + unset($pi); // Award Points if ($customer_id && $loyalty_enabled && $points_awarded > 0) { @@ -250,8 +261,7 @@ try { $award_history_id = $pdo->lastInsertId(); } - $vat = isset($data['vat']) ? floatval($data['vat']) : 0.00; - $final_total = max(0, $calculated_total + $vat); + $final_total = max(0, $calculated_subtotal + $calculated_vat); // User/Payment info $user = get_logged_user(); @@ -266,7 +276,7 @@ try { $userStmt->execute([$user_id]); $commission_rate = (float)$userStmt->fetchColumn(); if ($commission_rate > 0) { - $commission_amount = $calculated_total * ($commission_rate / 100); + $commission_amount = $calculated_subtotal * ($commission_rate / 100); } } @@ -288,21 +298,21 @@ try { $stmt = $pdo->prepare("UPDATE orders SET outlet_id = ?, table_id = ?, table_number = ?, order_type = ?, customer_id = ?, customer_name = ?, customer_phone = ?, - payment_type_id = ?, total_amount = ?, discount = ?, user_id = ?, + 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, $customer_id, $customer_name, $customer_phone, - $payment_type_id, $final_total, $vat, $user_id, + $payment_type_id, $final_total, 0, $calculated_vat, $user_id, $commission_amount, $order_id ]); $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, payment_type_id, total_amount, discount, user_id, commission_amount, status) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'pending')"); - $stmt->execute([$outlet_id, $table_id, $table_number, $order_type, $customer_id, $customer_name, $customer_phone, $payment_type_id, $final_total, $vat, $user_id, $commission_amount]); + $stmt = $pdo->prepare("INSERT INTO orders (outlet_id, table_id, table_number, order_type, customer_id, customer_name, customer_phone, 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, $payment_type_id, $final_total, 0, $calculated_vat, $user_id, $commission_amount]); $order_id = $pdo->lastInsertId(); } @@ -317,13 +327,13 @@ 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) 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 = []; foreach ($processed_items as $pi) { - $item_stmt->execute([$order_id, $pi['product_id'], $pi['product_name'], $pi['variant_id'], $pi['variant_name'], $pi['quantity'], $pi['unit_price']]); + $item_stmt->execute([$order_id, $pi['product_id'], $pi['product_name'], $pi['variant_id'], $pi['variant_name'], $pi['quantity'], $pi['unit_price'], $pi['vat_percent'], $pi['vat_amount']]); // Decrement Stock $stock_stmt->execute([$pi['quantity'], $pi['product_id']]); diff --git a/assets/js/main.js b/assets/js/main.js index b9d949f..3d71c7b 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -40,6 +40,8 @@ document.addEventListener('DOMContentLoaded', () => { const cartItemsContainer = document.getElementById('cart-items'); const cartTotalPrice = document.getElementById('cart-total-price'); const cartSubtotal = document.getElementById('cart-subtotal'); + const cartVatAmount = document.getElementById('cart-vat-amount'); + const cartVatRow = document.getElementById('cart-vat-row'); const cartVatInput = document.getElementById('cart-vat-input'); const quickOrderBtn = document.getElementById('quick-order-btn'); @@ -504,7 +506,9 @@ document.addEventListener('DOMContentLoaded', () => { addToCart({ id: product.id, name: product.name, name_ar: product.name_ar || "", price: parseFloat(product.price), base_price: parseFloat(product.price), - hasVariants: false, quantity: 1, variant_id: null, variant_name: null, is_loyalty: parseInt(product.is_loyalty) === 1 + hasVariants: false, quantity: 1, variant_id: null, variant_name: null, + is_loyalty: parseInt(product.is_loyalty) === 1, + vat_percent: parseFloat(product.vat_percent || 0) }); } }; @@ -526,7 +530,9 @@ document.addEventListener('DOMContentLoaded', () => { addToCart({ id: product.id, name: product.name, name_ar: product.name_ar || "", price: finalPrice, base_price: parseFloat(product.price), - hasVariants: true, quantity: 1, variant_id: v.id, variant_name: v.name, is_loyalty: parseInt(product.is_loyalty) === 1 + hasVariants: true, quantity: 1, variant_id: v.id, variant_name: v.name, + is_loyalty: parseInt(product.is_loyalty) === 1, + vat_percent: parseFloat(product.vat_percent || 0) }); variantSelectionModal.hide(); }; @@ -572,6 +578,8 @@ document.addEventListener('DOMContentLoaded', () => { if (cart.length === 0) { cartItemsContainer.innerHTML = `

${_t('cart_empty')}

`; if (cartSubtotal) cartSubtotal.innerText = formatCurrency(0); + if (cartVatAmount) cartVatAmount.innerText = formatCurrency(0); + if (cartVatRow) cartVatRow.classList.add('d-none'); if (cartTotalPrice) cartTotalPrice.innerText = formatCurrency(0); if (quickOrderBtn) { quickOrderBtn.disabled = true; quickOrderBtn.innerText = _t('quick_pay'); } if (placeOrderBtn) { placeOrderBtn.disabled = true; placeOrderBtn.innerText = _t('save_bill'); } @@ -580,9 +588,13 @@ document.addEventListener('DOMContentLoaded', () => { cartItemsContainer.innerHTML = ''; let subtotal = 0; + let totalVat = 0; cart.forEach((item, index) => { const itemTotal = item.price * item.quantity; + const itemVat = itemTotal * (item.vat_percent / 100); subtotal += itemTotal; + totalVat += itemVat; + const row = document.createElement('div'); row.className = 'd-flex justify-content-between align-items-center mb-3 border-bottom pb-2'; const itemName = (LANG === 'ar' && item.name_ar) ? item.name_ar : item.name; @@ -592,7 +604,7 @@ document.addEventListener('DOMContentLoaded', () => {
${itemName}
${otherName ? `
${otherName}
` : ''} -
${formatCurrency(item.price)}
+
${formatCurrency(item.price)} ${item.vat_percent > 0 ? `${item.vat_percent}% VAT` : ''}
@@ -608,11 +620,16 @@ document.addEventListener('DOMContentLoaded', () => { }); if (cartSubtotal) cartSubtotal.innerText = formatCurrency(subtotal); - const vatRate = parseFloat(settings.vat_rate) || 0; - const vat = subtotal * (vatRate / 100); - if (cartVatInput) cartVatInput.value = vat.toFixed(2); - const total = subtotal + vat; + if (cartVatAmount) cartVatAmount.innerText = formatCurrency(totalVat); + if (cartVatRow) { + if (totalVat > 0) cartVatRow.classList.remove('d-none'); + else cartVatRow.classList.add('d-none'); + } + if (cartVatInput) cartVatInput.value = totalVat.toFixed(3); + + const total = subtotal + totalVat; if (cartTotalPrice) cartTotalPrice.innerText = formatCurrency(total); + if (quickOrderBtn) { quickOrderBtn.disabled = false; quickOrderBtn.innerText = _t('quick_pay'); } if (placeOrderBtn) { placeOrderBtn.disabled = false; placeOrderBtn.innerText = _t('save_bill'); } } @@ -648,9 +665,23 @@ document.addEventListener('DOMContentLoaded', () => { window.processOrder = function(paymentTypeId, paymentTypeName) { const orderTypeInput = document.querySelector('input[name="order_type"]:checked'); const orderType = orderTypeInput ? orderTypeInput.value : 'takeaway'; - const subtotal = cart.reduce((acc, item) => acc + (item.price * item.quantity), 0); - const vatRate = parseFloat(settings.vat_rate) || 0; - const vat = subtotal * (vatRate / 100); + + let subtotal = 0; + let totalVat = 0; + const itemsData = cart.map(item => { + const itemTotal = item.price * item.quantity; + const itemVat = itemTotal * (item.vat_percent / 100); + subtotal += itemTotal; + totalVat += itemVat; + return { + product_id: item.id, + quantity: item.quantity, + unit_price: item.price, + variant_id: item.variant_id, + vat_percent: item.vat_percent, + vat_amount: itemVat + }; + }); const orderData = { order_id: currentOrderId, @@ -659,9 +690,9 @@ document.addEventListener('DOMContentLoaded', () => { customer_id: selectedCustomerId ? selectedCustomerId.value : null, outlet_id: CURRENT_OUTLET ? CURRENT_OUTLET.id : 1, payment_type_id: paymentTypeId, - total_amount: subtotal + vat, - vat: vat, - items: cart.map(item => ({ product_id: item.id, quantity: item.quantity, unit_price: item.price, variant_id: item.variant_id })), + total_amount: subtotal + totalVat, + vat: totalVat, + items: itemsData, redeem_loyalty: isLoyaltyRedemption }; @@ -673,10 +704,13 @@ document.addEventListener('DOMContentLoaded', () => { name: item.name, variant_name: item.variant_name, quantity: item.quantity, - price: item.price + price: item.price, + vat_percent: item.vat_percent, + vat_amount: (item.price * item.quantity) * (item.vat_percent / 100) })), - total: subtotal + vat, - vat: vat, + subtotal: subtotal, + total: subtotal + totalVat, + vat: totalVat, orderType: orderType, tableNumber: (orderType === 'dine-in') ? currentTableName : null, date: new Date().toLocaleString('en-US', { year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' }), @@ -702,7 +736,7 @@ document.addEventListener('DOMContentLoaded', () => { }; window.printThermalReceipt = function(data) { - const width = 400; + const width = 450; const height = 800; const left = (screen.width - width) / 2; const top = (screen.height - height) / 2; @@ -717,7 +751,7 @@ document.addEventListener('DOMContentLoaded', () => { const tr = { 'Order': 'الطلب', 'Type': 'النوع', 'Date': 'التاريخ', 'Staff': 'الموظف', 'Table': 'طاولة', 'Payment': 'الدفع', 'ITEM': 'الصنف', 'TOTAL': 'المجموع', - 'Subtotal': 'المجموع الفرعي', 'VAT': 'ضريبة القيمة المضافة', 'Tax Included': 'شامل الضريبة', + 'Subtotal': 'المجموع الفرعي', 'VAT': 'الضريبة', 'Tax Included': 'شامل الضريبة', 'THANK YOU FOR YOUR VISIT!': 'شكراً لزيارتكم!', 'Please come again.': 'يرجى زيارتنا مرة أخرى.', 'Customer Details': 'تفاصيل العميل', 'Tel': 'هاتف', 'takeaway': 'سفري', 'dine-in': 'محلي', 'delivery': 'توصيل', 'VAT No': 'الرقم الضريبي', 'CTR No': 'رقم السجل التجاري' @@ -730,6 +764,7 @@ document.addEventListener('DOMContentLoaded', () => { ${item.variant_name ? `
(${item.variant_name})
` : ''}
${item.quantity} x ${formatCurrency(item.price)}
+ ${item.vat_percent > 0 ? item.vat_percent + '%' : '-'} ${formatCurrency(item.quantity * item.price)} `).join(''); @@ -761,7 +796,6 @@ document.addEventListener('DOMContentLoaded', () => { const loyaltyHtml = data.loyaltyRedeemed ? `
* Loyalty Reward Applied *
` : ''; - const subtotal = data.total - data.vat; const logoHtml = settings.logo_url ? `` : ''; const html = ` @@ -805,14 +839,20 @@ document.addEventListener('DOMContentLoaded', () => {
${customerHtml} - + + + + + + + ${itemsHtml}
ITEM / الصنفTOTAL / المجموع
ITEM / الصنفVAT / الضريبةTOTAL / المجموع
- - ${Math.abs(data.vat) > 0 ? `` : ''} + + ${Math.abs(data.vat) > 0 ? `` : ''}
Subtotal / ${tr['Subtotal']}${formatCurrency(subtotal)}
${data.vat < 0 ? 'Discount' : 'VAT'} / ${tr['VAT']}${data.vat < 0 ? '-' : '+'}${formatCurrency(Math.abs(data.vat))}
Subtotal / ${tr['Subtotal']}${formatCurrency(data.subtotal)}
VAT / ${tr['VAT']}${formatCurrency(Math.abs(data.vat))}
TOTAL / ${tr['TOTAL']}${formatCurrency(data.total)}
@@ -841,4 +881,4 @@ document.addEventListener('DOMContentLoaded', () => { const modal = new bootstrap.Modal(document.getElementById('qrRatingModal')); modal.show(); }; -}); \ No newline at end of file +}); diff --git a/pos.php b/pos.php index 11ef67f..63aaad3 100644 --- a/pos.php +++ b/pos.php @@ -326,6 +326,11 @@ if (!$loyalty_settings) { Subtotal
+
+ VAT + + +
Total @@ -478,4 +483,4 @@ if (!$loyalty_settings) { - + \ No newline at end of file diff --git a/qorder.php b/qorder.php index fc19add..0428e2e 100644 --- a/qorder.php +++ b/qorder.php @@ -14,7 +14,7 @@ if ($table_id <= 0) { // Fetch table and outlet info $stmt = $pdo->prepare(" - SELECT t.id, t.name as table_name, a.outlet_id, o.name as outlet_name + SELECT t.id, t.table_number as table_name, a.outlet_id, o.name as outlet_name FROM tables t JOIN areas a ON t.area_id = a.id JOIN outlets o ON a.outlet_id = o.id @@ -303,9 +303,6 @@ foreach ($variants_raw as $v) { document.getElementById('lang-btn').textContent = currentLang === 'en' ? 'AR' : 'EN'; if (currentLang === 'ar') { document.body.classList.add('lang-ar'); - document.body.classList.remove('both-names'); // Optional: hide EN when AR is active? - // User said "both", so maybe I should keep both-names active if I want to show both. - // But let's follow standard toggle behavior for UI. } else { document.body.classList.remove('lang-ar'); } @@ -458,7 +455,7 @@ foreach ($variants_raw as $v) { const payload = { outlet_id: OUTLET_ID, - table_number: TABLE_ID, + table_id: TABLE_ID, // Use table_id instead of table_number order_type: 'dine-in', customer_name: customerName, items: cart, @@ -513,4 +510,4 @@ foreach ($variants_raw as $v) { } - \ No newline at end of file +