Autosave: 20260219-072319
This commit is contained in:
parent
a38832e8a0
commit
e2ac02cc7a
BIN
assets/pasted-20260219-071453-ee93359e.png
Normal file
BIN
assets/pasted-20260219-071453-ee93359e.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
229
index.php
229
index.php
@ -7096,73 +7096,96 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System';
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="d-flex justify-content-between mb-2">
|
||||
<span>Opening Balance:</span>
|
||||
<span>OMR <?= number_format((float)$s['opening_balance'], 3) ?></span>
|
||||
</div>
|
||||
<?php
|
||||
// Breakdown of sales by payment method
|
||||
$breakdown = db()->prepare("SELECT p.payment_method, SUM(p.amount) as total FROM pos_payments p JOIN pos_transactions t ON p.transaction_id = t.id WHERE t.register_session_id = ? AND t.status = 'completed' GROUP BY p.payment_method");
|
||||
$breakdown->execute([$s['id']]);
|
||||
$methods = $breakdown->fetchAll();
|
||||
$total_sales = 0;
|
||||
foreach ($methods as $m): $total_sales += $m['total']; ?>
|
||||
|
||||
$cash_sales = 0;
|
||||
$card_sales = 0;
|
||||
$credit_sales = 0;
|
||||
$bank_transfer_sales = 0;
|
||||
|
||||
foreach ($methods as $m) {
|
||||
$method = strtolower($m['payment_method']);
|
||||
if ($method === 'cash') $cash_sales = $m['total'];
|
||||
elseif ($method === 'card' || strpos($method, 'card') !== false) $card_sales = $m['total'];
|
||||
elseif ($method === 'credit') $credit_sales = $m['total'];
|
||||
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_all = (float)$s['opening_balance'] + $total_sales;
|
||||
?>
|
||||
|
||||
<div class="d-flex justify-content-between mb-2">
|
||||
<span class="text-uppercase">Sales (<?= htmlspecialchars($m['payment_method']) ?>):</span>
|
||||
<span>OMR <?= number_format((float)$m['total'], 3) ?></span>
|
||||
<span>Opening Balance:</span>
|
||||
<span class="fw-bold">OMR <?= number_format((float)$s['opening_balance'], 3) ?></span>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<div class="d-flex justify-content-between mb-2 fw-bold border-top pt-2">
|
||||
<span>Total Sales:</span>
|
||||
<span>OMR <?= number_format($total_sales, 3) ?></span>
|
||||
<div class="d-flex justify-content-between mb-2">
|
||||
<span>Cash Sales:</span>
|
||||
<span class="fw-bold">OMR <?= number_format($cash_sales, 3) ?></span>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="d-flex justify-content-between mb-2 h5 text-primary">
|
||||
<span>Expected Cash in Hand:</span>
|
||||
<span>OMR <?= number_format((float)($s['closing_balance'] ?? 0), 3) ?></span>
|
||||
<div class="d-flex justify-content-between mb-2">
|
||||
<span>Credit Card Sales:</span>
|
||||
<span class="fw-bold">OMR <?= number_format($card_sales, 3) ?></span>
|
||||
</div>
|
||||
<div class="d-flex justify-content-between mb-2 h5 text-success">
|
||||
<span>Actual Cash in Hand:</span>
|
||||
<span>OMR <?= number_format((float)($s['cash_in_hand'] ?? 0), 3) ?></span>
|
||||
<div class="d-flex justify-content-between mb-2">
|
||||
<span>Credit:</span>
|
||||
<span class="fw-bold">OMR <?= number_format($credit_sales, 3) ?></span>
|
||||
</div>
|
||||
<div class="d-flex justify-content-between mb-2 h5 <?= ($s['cash_in_hand'] - $s['closing_balance']) >= 0 ? 'text-info' : 'text-danger' ?>">
|
||||
<span>Difference:</span>
|
||||
<span>OMR <?= number_format((float)(($s['cash_in_hand'] ?? 0) - ($s['closing_balance'] ?? 0)), 3) ?></span>
|
||||
<div class="d-flex justify-content-between mb-2 border-bottom pb-2">
|
||||
<span>Bank Transfer:</span>
|
||||
<span class="fw-bold">OMR <?= number_format($bank_transfer_sales, 3) ?></span>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-between mb-2 h5 mt-3 text-primary">
|
||||
<span>Balance (Total):</span>
|
||||
<span>OMR <?= number_format($total_all, 3) ?></span>
|
||||
</div>
|
||||
|
||||
<div class="mt-4">
|
||||
<h6 class="fw-bold small text-uppercase mb-2">Transaction Details</h6>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-sm table-bordered small">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th>Time</th>
|
||||
<th>Order #</th>
|
||||
<th>Customer</th>
|
||||
<th>Method</th>
|
||||
<th class="text-end">Amount</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$txs_stmt = db()->prepare("SELECT t.*, c.name as customer_name, GROUP_CONCAT(p.payment_method SEPARATOR ', ') as methods FROM pos_transactions t LEFT JOIN pos_payments p ON t.id = p.transaction_id LEFT JOIN customers c ON t.customer_id = c.id WHERE t.register_session_id = ? AND t.status = 'completed' GROUP BY t.id ORDER BY t.created_at DESC");
|
||||
$txs_stmt->execute([$s['id']]);
|
||||
$txs = $txs_stmt->fetchAll();
|
||||
foreach ($txs as $tx):
|
||||
?>
|
||||
<tr>
|
||||
<td><?= date('H:i', strtotime($tx['created_at'])) ?></td>
|
||||
<td><?= htmlspecialchars($tx['transaction_no']) ?></td>
|
||||
<td><?= htmlspecialchars($tx['customer_name'] ?: 'Walk-in') ?></td>
|
||||
<td class="text-capitalize small"><?= htmlspecialchars($tx['methods'] ?: '---') ?></td>
|
||||
<td class="text-end"><?= number_format($tx['net_amount'], 3) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; if(empty($txs)): ?>
|
||||
<tr><td colspan="5" class="text-center text-muted">No transactions</td></tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<h6 class="fw-bold mb-3">Detailed Transactions by Method</h6>
|
||||
<?php
|
||||
foreach ($methods as $m):
|
||||
$details = db()->prepare("SELECT t.transaction_no, t.created_at, p.amount FROM pos_payments p JOIN pos_transactions t ON p.transaction_id = t.id WHERE t.register_session_id = ? AND t.status = 'completed' AND p.payment_method = ?");
|
||||
$details->execute([$s['id'], $m['payment_method']]);
|
||||
$trans = $details->fetchAll();
|
||||
?>
|
||||
<div class="mb-4">
|
||||
<div class="bg-light p-2 mb-2 d-flex justify-content-between align-items-center rounded border-start border-4 <?= strtolower($m['payment_method']) === 'cash' ? 'border-success' : 'border-primary' ?>">
|
||||
<span class="text-uppercase fw-bold small"><?= htmlspecialchars($m['payment_method']) ?></span>
|
||||
<span class="badge bg-white text-dark border rounded-pill">OMR <?= number_format((float)$m['total'], 3) ?></span>
|
||||
</div>
|
||||
<table class="table table-sm table-hover small mb-0">
|
||||
<thead>
|
||||
<tr class="text-muted border-bottom">
|
||||
<th>TX #</th>
|
||||
<th>Time</th>
|
||||
<th class="text-end">Amount</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($trans as $tr): ?>
|
||||
<tr>
|
||||
<td><?= htmlspecialchars($tr['transaction_no']) ?></td>
|
||||
<td><?= date('H:i', strtotime($tr['created_at'])) ?></td>
|
||||
<td class="text-end">OMR <?= number_format((float)$tr['amount'], 3) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="row g-2 small text-muted">
|
||||
<div class="col-6">Expected Cash: OMR <?= number_format($expected_balance, 3) ?></div>
|
||||
<div class="col-6 text-end">Actual Cash: OMR <?= number_format((float)($s['cash_in_hand'] ?? 0), 3) ?></div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if ($s['notes']): ?>
|
||||
<hr>
|
||||
@ -7238,34 +7261,94 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System';
|
||||
$curBreakdown = db()->prepare("SELECT p.payment_method, SUM(p.amount) as total FROM pos_payments p JOIN pos_transactions t ON p.transaction_id = t.id WHERE t.register_session_id = ? AND t.status = 'completed' GROUP BY p.payment_method");
|
||||
$curBreakdown->execute([$session['id']]);
|
||||
$curMethods = $curBreakdown->fetchAll();
|
||||
$curCashSales = 0;
|
||||
foreach($curMethods as $cm) if(strtolower($cm['payment_method']) === 'cash') $curCashSales = (float)$cm['total'];
|
||||
|
||||
$cash_sales = 0;
|
||||
$card_sales = 0;
|
||||
$credit_sales = 0;
|
||||
$bank_transfer_sales = 0;
|
||||
|
||||
foreach ($curMethods as $m) {
|
||||
$method = strtolower($m['payment_method']);
|
||||
if ($method === 'cash') $cash_sales = $m['total'];
|
||||
elseif ($method === 'card' || strpos($method, 'card') !== false) $card_sales = $m['total'];
|
||||
elseif ($method === 'credit') $credit_sales = $m['total'];
|
||||
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_cash = (float)$session['opening_balance'] + $cash_sales;
|
||||
$total_all = (float)$session['opening_balance'] + $total_sales;
|
||||
?>
|
||||
<div class="card bg-light border-0 mb-3 small">
|
||||
<div class="card-body">
|
||||
<h6 class="card-title fw-bold small text-uppercase mb-2">Session Summary</h6>
|
||||
<div class="d-flex justify-content-between mb-1">
|
||||
<span class="text-muted">Opening Cash:</span>
|
||||
<span class="text-muted">Opening Balance:</span>
|
||||
<span class="fw-bold">OMR <?= number_format((float)$session['opening_balance'], 3) ?></span>
|
||||
</div>
|
||||
<div class="d-flex justify-content-between mb-1">
|
||||
<span class="text-muted">Cash Sales:</span>
|
||||
<span class="fw-bold">OMR <?= number_format($curCashSales, 3) ?></span>
|
||||
<span class="fw-bold">OMR <?= number_format($cash_sales, 3) ?></span>
|
||||
</div>
|
||||
<div class="d-flex justify-content-between mb-1">
|
||||
<span class="text-muted">Credit Card Sales:</span>
|
||||
<span class="fw-bold">OMR <?= number_format($card_sales, 3) ?></span>
|
||||
</div>
|
||||
<div class="d-flex justify-content-between mb-1">
|
||||
<span class="text-muted">Credit:</span>
|
||||
<span class="fw-bold">OMR <?= number_format($credit_sales, 3) ?></span>
|
||||
</div>
|
||||
<div class="d-flex justify-content-between mb-1">
|
||||
<span class="text-muted">Bank Transfer:</span>
|
||||
<span class="fw-bold">OMR <?= number_format($bank_transfer_sales, 3) ?></span>
|
||||
</div>
|
||||
<hr class="my-2">
|
||||
<div class="d-flex justify-content-between fw-bold text-primary mb-2">
|
||||
<span>Expected Cash in Hand:</span>
|
||||
<span>OMR <?= number_format((float)$session['opening_balance'] + $curCashSales, 3) ?></span>
|
||||
<div class="d-flex justify-content-between fw-bold text-primary mb-1">
|
||||
<span>Balance (Total):</span>
|
||||
<span>OMR <?= number_format($total_all, 3) ?></span>
|
||||
</div>
|
||||
|
||||
<?php $hasOther = false; foreach($curMethods as $cm): if(strtolower($cm['payment_method']) !== 'cash'): $hasOther = true; ?>
|
||||
<div class="d-flex justify-content-between mt-1 text-muted border-top pt-1">
|
||||
<span><?= htmlspecialchars($cm['payment_method']) ?> Total:</span>
|
||||
<span>OMR <?= number_format((float)$cm['total'], 3) ?></span>
|
||||
<div class="d-flex justify-content-between fw-bold text-success">
|
||||
<span>Expected Cash:</span>
|
||||
<span>OMR <?= number_format($expected_cash, 3) ?></span>
|
||||
</div>
|
||||
<?php endif; endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<h6 class="fw-bold small text-uppercase mb-2">Transaction Details</h6>
|
||||
<div class="table-responsive" style="max-height: 200px; overflow-y: auto;">
|
||||
<table class="table table-sm table-bordered mb-0 small">
|
||||
<thead class="bg-light sticky-top">
|
||||
<tr>
|
||||
<th>Time</th>
|
||||
<th>Order #</th>
|
||||
<th>Customer</th>
|
||||
<th>Method</th>
|
||||
<th class="text-end">Amount</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$txs_stmt = db()->prepare("SELECT t.*, c.name as customer_name, GROUP_CONCAT(p.payment_method SEPARATOR ', ') as methods FROM pos_transactions t LEFT JOIN pos_payments p ON t.id = p.transaction_id LEFT JOIN customers c ON t.customer_id = c.id WHERE t.register_session_id = ? AND t.status = 'completed' GROUP BY t.id ORDER BY t.created_at DESC");
|
||||
$txs_stmt->execute([$session['id']]);
|
||||
$txs = $txs_stmt->fetchAll();
|
||||
foreach ($txs as $tx):
|
||||
?>
|
||||
<tr>
|
||||
<td><?= date('H:i', strtotime($tx['created_at'])) ?></td>
|
||||
<td><?= htmlspecialchars($tx['transaction_no']) ?></td>
|
||||
<td><?= htmlspecialchars($tx['customer_name'] ?: 'Walk-in') ?></td>
|
||||
<td class="text-capitalize small"><?= htmlspecialchars($tx['methods'] ?: '---') ?></td>
|
||||
<td class="text-end"><?= number_format($tx['net_amount'], 3) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; if(empty($txs)): ?>
|
||||
<tr><td colspan="5" class="text-center text-muted">No transactions</td></tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Total Cash in Hand (Actual Counted)</label>
|
||||
<input type="number" step="0.001" name="cash_in_hand" class="form-control" required placeholder="0.000">
|
||||
@ -9887,11 +9970,15 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
<i class="bi bi-credit-card"></i>
|
||||
<span class="small fw-bold">Card</span>
|
||||
</div>
|
||||
<div class="payment-method-btn" data-method="credit" onclick="cart.selectMethod('credit', this)">
|
||||
<i class="bi bi-person-badge"></i>
|
||||
<span class="small fw-bold">Credit</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="payment-method-btn" data-method="credit" onclick="cart.selectMethod('credit', this)">
|
||||
<i class="bi bi-person-badge"></i>
|
||||
<span class="small fw-bold">Credit</span>
|
||||
</div>
|
||||
<div class="payment-method-btn" data-method="transfer" onclick="cart.selectMethod('transfer', this)">
|
||||
<i class="bi bi-bank"></i>
|
||||
<span class="small fw-bold">Transfer</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row g-2 align-items-end">
|
||||
<div class="col">
|
||||
|
||||
@ -57,3 +57,6 @@
|
||||
2026-02-19 06:50:40 - 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":"5673086966938977","sale_price":"0.25","purchase_price":"0.2","stock_quantity":"0.000","min_stock_level":"0.000","vat_rate":"5","expiry_date":"","promotion_start":"","promotion_end":"","promotion_percent":"0.00","add_item":""}
|
||||
2026-02-19 06:53:36 - POST: {"action":"save_pos_transaction","customer_id":"","payments":"[{\"method\":\"cash\",\"amount\":0.978}]","total_amount":"0.9775","discount_code_id":"","discount_amount":"0","loyalty_redeemed":"0","items":"[{\"id\":1,\"qty\":2,\"price\":0.3825},{\"id\":2,\"qty\":1,\"price\":0.2125}]"}
|
||||
2026-02-19 07:01:43 - 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: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":""}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user