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';
| ID | Register | Cashier | Opened At | Closed At | Opening Bal. | -Expected Bal. | -Cash in Hand | -Difference | +Cash Sales | +Card Sales | +Transfer | +Credit | +Total Sales | +Expected Cash | +Actual Cash | +Shortage | Status | Report |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| = htmlspecialchars($s['register_name']) ?> | -= htmlspecialchars($s['username']) ?> | +#= $s['id'] ?> | += htmlspecialchars($s['register_name'] ?? 'N/A') ?> | += htmlspecialchars($s['username'] ?? 'N/A') ?> | = $s['opened_at'] ?> | = $s['closed_at'] ?? '---' ?> | OMR = number_format((float)$s['opening_balance'], 3) ?> | -OMR = number_format((float)($s['closing_balance'] ?? 0), 3) ?> | + 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; + ?> +OMR = number_format($c_total, 3) ?> | +OMR = number_format($cd_total, 3) ?> | +OMR = number_format($tr_total, 3) ?> | +OMR = number_format($cr_total, 3) ?> | +OMR = number_format($t_sales, 3) ?> | +OMR = number_format($row_expected_cash, 3) ?> | OMR = number_format((float)($s['cash_in_hand'] ?? 0), 3) ?> |
0 ? 'text-info' : 'text-danger');
?>
OMR = number_format($diff, 3) ?>
@@ -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 = number_format((float)$s['opening_balance'], 3) ?>
-
-
- Cash Sales:
- OMR = number_format($cash_sales, 3) ?>
-
-
- Credit Card Sales:
- OMR = number_format($card_sales, 3) ?>
-
-
- Credit:
- OMR = number_format($credit_sales, 3) ?>
-
-
- Bank Transfer:
- OMR = number_format($bank_transfer_sales, 3) ?>
-
-
- Balance (Total):
- OMR = number_format($total_all, 3) ?>
+
+
+
+
+
+ Sales Summary+
+ Opening Balance:
+ OMR = number_format((float)$s['opening_balance'], 3) ?>
+
+
+ Cash Sales:
+ OMR = number_format($cash_sales, 3) ?>
+
+
+ Credit Card Sales:
+ OMR = number_format($card_sales, 3) ?>
+
+
+ Credit:
+ OMR = number_format($credit_sales, 3) ?>
+
+
+ Bank Transfer:
+ OMR = number_format($bank_transfer_sales, 3) ?>
+
+
+ Total Sales:
+ OMR = number_format($total_sales, 3) ?>
+
+
+
+
Cash Reconciliation+
+ Opening Balance:
+ OMR = number_format((float)$s['opening_balance'], 3) ?>
+
+
+ (+) Cash Sales:
+ OMR = number_format($cash_sales, 3) ?>
+
+
+ Expected Cash:
+ OMR = number_format($expected_cash_total, 3) ?>
+
+
+
+ Actual Cash:
+ OMR = number_format((float)$s['cash_in_hand'], 3) ?>
+
+ 0 ? 'text-info' : 'text-success');
+ ?>
+
+ Shortage / Overage:
+ OMR = number_format($shortage, 3) ?>
+
+
+
+
Transaction Details |