From e3240af16d4d61df0462edbf0b974300801d486c Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Thu, 19 Feb 2026 08:20:05 +0000 Subject: [PATCH] modifying register --- index.php | 150 +++++++++++++++++++++++++++++++++++++------------ post_debug.log | 14 +++++ 2 files changed, 127 insertions(+), 37 deletions(-) diff --git a/index.php b/index.php index 25eb6bc..9b14ede 100644 --- a/index.php +++ b/index.php @@ -1278,6 +1278,8 @@ if (isset($_POST['add_hr_department'])) { $stmt->execute([$register_id, $user_id, $opening_balance]); $_SESSION['register_session_id'] = db()->lastInsertId(); $message = "Register opened successfully!"; + header("Location: index.php?page=pos"); + exit; } } @@ -1303,6 +1305,8 @@ if (isset($_POST['add_hr_department'])) { unset($_SESSION['register_session_id']); $message = "Register closed successfully!"; + header("Location: index.php?page=dashboard"); + exit; } @@ -1914,8 +1918,8 @@ switch ($page) { $whereSql = implode(" AND ", $where); $stmt = db()->prepare("SELECT s.*, r.name as register_name, u.username FROM register_sessions s - JOIN cash_registers r ON s.register_id = r.id - JOIN users u ON s.user_id = u.id + LEFT JOIN cash_registers r ON s.register_id = r.id + LEFT JOIN users u ON s.user_id = u.id WHERE $whereSql ORDER BY s.id DESC"); $stmt->execute($params); @@ -7030,14 +7034,20 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System'; + - - - + + + + + + + + @@ -7045,16 +7055,41 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System'; - - + + + - + prepare("SELECT + SUM(CASE WHEN LOWER(p.payment_method) = 'cash' THEN p.amount ELSE 0 END) as cash_total, + SUM(CASE WHEN LOWER(p.payment_method) IN ('card', 'credit card', 'visa', 'mastercard') THEN p.amount ELSE 0 END) as card_total, + SUM(CASE WHEN LOWER(p.payment_method) = 'credit' THEN p.amount ELSE 0 END) as credit_total, + SUM(CASE WHEN LOWER(p.payment_method) LIKE '%transfer%' OR LOWER(p.payment_method) LIKE '%bank%' THEN p.amount ELSE 0 END) as transfer_total, + SUM(p.amount) as total_sales + FROM pos_payments p + JOIN pos_transactions t ON p.transaction_id = t.id + WHERE t.register_session_id = ? AND t.status = 'completed'"); + $stats_stmt->execute([$s['id']]); + $st = $stats_stmt->fetch(); + $c_total = (float)($st['cash_total'] ?? 0); + $cd_total = (float)($st['card_total'] ?? 0); + $cr_total = (float)($st['credit_total'] ?? 0); + $tr_total = (float)($st['transfer_total'] ?? 0); + $t_sales = (float)($st['total_sales'] ?? 0); + $row_expected_cash = (float)$s['opening_balance'] + $c_total; + ?> + + + + + +
ID Register Cashier Opened At Closed At Opening Bal.Expected Bal.Cash in HandDifferenceCash SalesCard SalesTransferCreditTotal SalesExpected CashActual CashShortage Status Report
# OMR OMR OMR OMR OMR OMR OMR OMR OMR 0 ? 'text-info' : 'text-danger'); ?> OMR @@ -7115,38 +7150,75 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System'; elseif (strpos($method, 'transfer') !== false || strpos($method, 'bank') !== false) $bank_transfer_sales = $m['total']; else $cash_sales += $m['total']; } - $total_sales = $cash_sales + $card_sales + $credit_sales + $bank_transfer_sales; - $expected_balance = (float)$s['opening_balance'] + $cash_sales; // Usually balance in hand is opening + cash sales + $total_sales = $cash_sales + $card_sales + $credit_sales + $bank_transfer_sales; + $expected_cash_total = (float)$s['opening_balance'] + $cash_sales; $total_all = (float)$s['opening_balance'] + $total_sales; ?> - -
- Opening Balance: - OMR -
-
- Cash Sales: - OMR -
-
- Credit Card Sales: - OMR -
-
- Credit: - OMR -
-
- Bank Transfer: - OMR -
-
- Balance (Total): - OMR +
+
+
Sales Summary
+
+ Opening Balance: + OMR +
+
+ Cash Sales: + OMR +
+
+ Credit Card Sales: + OMR +
+
+ Credit: + OMR +
+
+ Bank Transfer: + OMR +
+
+ Total Sales: + OMR +
+
+
+ +
+
+
Cash Reconciliation
+
+ Opening Balance: + OMR +
+
+ (+) Cash Sales: + OMR +
+
+ Expected Cash: + OMR +
+ +
+ Actual Cash: + OMR +
+ 0 ? 'text-info' : 'text-success'); + ?> +
+ Shortage / Overage: + OMR +
+ +
+
Transaction Details
@@ -7183,7 +7255,7 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System';
-
Expected Cash: OMR
+
Expected Cash: OMR
Actual Cash: OMR
@@ -7302,8 +7374,12 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System'; Bank Transfer:OMR +
+ Total Sales: + OMR +

-
+
Balance (Total): OMR
diff --git a/post_debug.log b/post_debug.log index 2e823a8..0281ed3 100644 --- a/post_debug.log +++ b/post_debug.log @@ -60,3 +60,17 @@ 2026-02-19 07:02:59 - POST: {"name_en":"Tissue","name_ar":"\u0645\u062d\u0627\u0631\u0645 \u0648\u0631\u0642\u064a\u0629","category_id":"2","unit_id":"2","supplier_id":"6","sku":"760115926272","sale_price":"0.25","purchase_price":"0.2","stock_quantity":"5","min_stock_level":"0.000","vat_rate":"5","expiry_date":"","promotion_start":"","promotion_end":"","promotion_percent":"0.00","add_item":""} 2026-02-19 07:12:25 - POST: {"action":"save_pos_transaction","customer_id":"","payments":"[{\"method\":\"cash\",\"amount\":0.883}]","total_amount":"0.8825000000000001","discount_code_id":"","discount_amount":"0","loyalty_redeemed":"0","items":"[{\"id\":1,\"qty\":1,\"price\":0.3825},{\"id\":3,\"qty\":2,\"price\":0.25}]"} 2026-02-19 07:12:39 - POST: {"close_register":"1","session_id":"3","cash_in_hand":"5","notes":""} +2026-02-19 07:30:27 - POST: {"open_register":"1","register_id":"1","opening_balance":"6"} +2026-02-19 07:30:51 - POST: {"action":"save_pos_transaction","customer_id":"","payments":"[{\"method\":\"cash\",\"amount\":0.845}]","total_amount":"0.8450000000000001","discount_code_id":"","discount_amount":"0","loyalty_redeemed":"0","items":"[{\"id\":1,\"qty\":1,\"price\":0.3825},{\"id\":3,\"qty\":1,\"price\":0.25},{\"id\":2,\"qty\":1,\"price\":0.2125}]"} +2026-02-19 07:30:56 - POST: {"open_register":"1","register_id":"1","opening_balance":"6"} +2026-02-19 07:31:28 - POST: {"close_register":"1","session_id":"4","cash_in_hand":"55","notes":""} +2026-02-19 07:33:04 - POST: {"open_register":"1","register_id":"1","opening_balance":"10"} +2026-02-19 07:33:19 - POST: {"action":"save_pos_transaction","customer_id":"","payments":"[{\"method\":\"cash\",\"amount\":0.845}]","total_amount":"0.845","discount_code_id":"","discount_amount":"0","loyalty_redeemed":"0","items":"[{\"id\":3,\"qty\":1,\"price\":0.25},{\"id\":2,\"qty\":1,\"price\":0.2125},{\"id\":1,\"qty\":1,\"price\":0.3825}]"} +2026-02-19 07:33:23 - POST: {"open_register":"1","register_id":"1","opening_balance":"10"} +2026-02-19 07:33:39 - POST: {"close_register":"1","session_id":"5","cash_in_hand":"10","notes":""} +2026-02-19 07:57:20 - POST: {"open_register":"1","register_id":"1","opening_balance":"44"} +2026-02-19 07:57:30 - POST: {"action":"save_pos_transaction","customer_id":"","payments":"[{\"method\":\"cash\",\"amount\":0.845}]","total_amount":"0.8450000000000001","discount_code_id":"","discount_amount":"0","loyalty_redeemed":"0","items":"[{\"id\":1,\"qty\":1,\"price\":0.3825},{\"id\":3,\"qty\":1,\"price\":0.25},{\"id\":2,\"qty\":1,\"price\":0.2125}]"} +2026-02-19 07:57:44 - POST: {"close_register":"1","session_id":"6","cash_in_hand":"9","notes":""} +2026-02-19 07:58:34 - POST: {"open_register":"1","register_id":"1","opening_balance":"11"} +2026-02-19 07:58:46 - POST: {"action":"save_pos_transaction","customer_id":"","payments":"[{\"method\":\"cash\",\"amount\":0.845}]","total_amount":"0.8450000000000001","discount_code_id":"","discount_amount":"0","loyalty_redeemed":"0","items":"[{\"id\":1,\"qty\":1,\"price\":0.3825},{\"id\":3,\"qty\":1,\"price\":0.25},{\"id\":2,\"qty\":1,\"price\":0.2125}]"} +2026-02-19 07:59:08 - POST: {"close_register":"1","session_id":"7","cash_in_hand":"13","notes":""}