items back

This commit is contained in:
Flatlogic Bot 2026-02-21 18:11:55 +00:00
parent 259f6c425e
commit 8a346582bb
7 changed files with 72 additions and 15 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -0,0 +1,4 @@
-- Fix missing columns in invoice_items table
-- Date: 2026-02-21
ALTER TABLE invoice_items ADD COLUMN IF NOT EXISTS vat_amount DECIMAL(15,3) DEFAULT 0.000 AFTER unit_price;

View File

@ -0,0 +1,14 @@
-- Fix missing columns in invoices table for POS transactions
-- Date: 2026-02-21
ALTER TABLE invoices ADD COLUMN IF NOT EXISTS transaction_no VARCHAR(50) DEFAULT NULL AFTER id;
ALTER TABLE invoices ADD COLUMN IF NOT EXISTS register_session_id INT(11) DEFAULT NULL;
ALTER TABLE invoices ADD COLUMN IF NOT EXISTS is_pos TINYINT(1) DEFAULT 0;
ALTER TABLE invoices ADD COLUMN IF NOT EXISTS discount_amount DECIMAL(15,3) DEFAULT 0.000;
ALTER TABLE invoices ADD COLUMN IF NOT EXISTS loyalty_points_earned DECIMAL(15,3) DEFAULT 0.000;
ALTER TABLE invoices ADD COLUMN IF NOT EXISTS loyalty_points_redeemed DECIMAL(15,3) DEFAULT 0.000;
ALTER TABLE invoices ADD COLUMN IF NOT EXISTS created_by INT(11) DEFAULT NULL;
-- Ensure indexes for better performance
ALTER TABLE invoices ADD INDEX IF NOT EXISTS idx_transaction_no (transaction_no);
ALTER TABLE invoices ADD INDEX IF NOT EXISTS idx_register_session (register_session_id);

4
debug.log Normal file
View File

@ -0,0 +1,4 @@
2026-02-21 17:52:10 - Items case hit
2026-02-21 17:52:37 - Items case hit
2026-02-21 17:53:18 - Items case hit
2026-02-21 18:10:28 - Items case hit

17
debug_items.php Normal file
View File

@ -0,0 +1,17 @@
<?php
require_once 'db/config.php';
$whereSql = "1=1";
$params = [];
$stmt = db()->prepare("SELECT i.*, c.name_en as cat_en, c.name_ar as cat_ar, u.short_name_en as unit_en, u.short_name_ar as unit_ar, s.name as supplier_name
FROM stock_items i
LEFT JOIN stock_categories c ON i.category_id = c.id
LEFT JOIN stock_units u ON i.unit_id = u.id
LEFT JOIN suppliers s ON i.supplier_id = s.id
WHERE $whereSql
ORDER BY i.id DESC");
$stmt->execute($params);
$items = $stmt->fetchAll();
echo "Count: " . count($items) . "\n";
foreach ($items as $item) {
echo "ID: {$item['id']}, Name: {$item['name_en']}\n";
}

View File

@ -2468,6 +2468,7 @@ switch ($page) {
// Already fetched globally
break;
case 'items':
file_put_contents('debug.log', date('Y-m-d H:i:s') . " - Items case hit\n", FILE_APPEND);
$where = ["1=1"];
$params = [];
if (!empty($_GET['search'])) {
@ -3795,8 +3796,8 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System';
<tbody>
<?php foreach ($data['customers'] as $c): ?>
<tr>
<td><?= htmlspecialchars($c['name']) ?></td>
<td><?= htmlspecialchars($c['phone']) ?></td>
<td><?= htmlspecialchars((string)($c['name'] ?? '')) ?></td>
<td><?= htmlspecialchars((string)($c['phone'] ?? '')) ?></td>
<td class="text-end" data-en="OMR <?= number_format((float)$c['balance'], 3) ?>" data-ar="<?= number_format((float)$c['balance'], 3) ?> ر.ع."><?= $lang === 'ar' ? number_format((float)$c['balance'], 3) . ' ر.ع.' : 'OMR ' . number_format((float)$c['balance'], 3) ?></td>
</tr>
<?php endforeach; ?>
@ -3900,10 +3901,10 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System';
<tbody>
<?php foreach ($data['customers'] as $c): ?>
<tr>
<td><?= htmlspecialchars($c['name']) ?></td>
<td><?= htmlspecialchars($c['tax_id'] ?? '---') ?></td>
<td><?= htmlspecialchars($c['email']) ?></td>
<td><?= htmlspecialchars($c['phone']) ?></td>
<td><?= htmlspecialchars((string)($c['name'] ?? '')) ?></td>
<td><?= htmlspecialchars((string)($c['tax_id'] ?? '---')) ?></td>
<td><?= htmlspecialchars((string)($c['email'] ?? '')) ?></td>
<td><?= htmlspecialchars((string)($c['phone'] ?? '')) ?></td>
<td class="text-end" data-en="OMR <?= number_format((float)$c['balance'], 3) ?>" data-ar="<?= number_format((float)$c['balance'], 3) ?> ر.ع."><?= $lang === 'ar' ? number_format((float)$c['balance'], 3) . ' ر.ع.' : 'OMR ' . number_format((float)$c['balance'], 3) ?></td>
<td class="text-end">
<div class="btn-group btn-group-sm">
@ -4166,7 +4167,7 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System';
<?php elseif ($page === 'items'): ?>
<div class="card p-4">
<div class="d-flex justify-content-between align-items-center mb-4">
<h5 class="m-0" data-en="Stock Items" data-ar="أصناف المخزون">Stock Items</h5>
<h5 class="m-0" data-en="Stock Items" data-ar="أصناف المخزون">Stock Items (<?= count($data['items'] ?? []) ?>)</h5>
<div class="d-flex align-items-center">
<button class="btn btn-dark me-2" id="bulkBarcodeBtn" style="display:none;" onclick="openAveryModal()">
<i class="bi bi-printer"></i> <span data-en="Avery Labels" data-ar="ملصقات إيفري">Avery Labels</span>
@ -4252,15 +4253,15 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System';
<td><?= htmlspecialchars($item['sku']) ?></td>
<td>
<div class="fw-bold">
<?= htmlspecialchars($item['name_en']) ?>
<?= htmlspecialchars((string)($item['name_en'] ?? '')) ?>
<?php if (isset($item['is_promotion']) && $item['is_promotion']): ?>
<span class="badge bg-success ms-1" style="font-size: 0.65rem;" data-en="Promo" data-ar="عرض">Promo</span>
<?php endif; ?>
</div>
<div class="small text-muted"><?= htmlspecialchars($item['name_ar']) ?></div>
<div class="small text-muted"><?= htmlspecialchars((string)($item['name_ar'] ?? '')) ?></div>
</td>
<td><span data-en="<?= htmlspecialchars($item['cat_en']) ?>" data-ar="<?= htmlspecialchars($item['cat_ar']) ?>"><?= htmlspecialchars($item['cat_en']) ?></span></td>
<td><?= htmlspecialchars($item['supplier_name'] ?? '---') ?></td>
<td><span data-en="<?= htmlspecialchars((string)($item['cat_en'] ?? '')) ?>" data-ar="<?= htmlspecialchars((string)($item['cat_ar'] ?? '')) ?>"><?= htmlspecialchars((string)($item['cat_en'] ?? '')) ?></span></td>
<td><?= htmlspecialchars((string)($item['supplier_name'] ?? '---')) ?></td>
<td>
<div class="text-end">
<strong><?= number_format((float)$item['stock_quantity'], 3) ?></strong>
@ -4288,13 +4289,13 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System';
<div class="modal-dialog">
<div class="modal-content border-0 shadow">
<div class="modal-header">
<h5 class="modal-title"><?= htmlspecialchars($item['name_en']) ?></h5>
<h5 class="modal-title"><?= htmlspecialchars((string)($item['name_en'] ?? '')) ?></h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<div class="text-center mb-3">
<?php if ($item['image_path']): ?>
<img src="<?= htmlspecialchars($item['image_path']) ?>" class="img-fluid rounded shadow-sm" style="max-height: 200px;">
<img src="<?= htmlspecialchars((string)$item['image_path']) ?>" class="img-fluid rounded shadow-sm" style="max-height: 200px;">
<?php else: ?>
<div class="bg-light rounded d-flex align-items-center justify-content-center mx-auto" style="width: 150px; height: 150px;">
<i class="bi bi-image text-muted" style="font-size: 3rem;"></i>
@ -4302,7 +4303,7 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System';
<?php endif; ?>
</div>
<table class="table table-sm">
<tr><th class="text-muted">SKU</th><td><?= htmlspecialchars($item['sku']) ?></td></tr>
<tr><th class="text-muted">SKU</th><td><?= htmlspecialchars((string)($item['sku'] ?? '')) ?></td></tr>
<tr><th class="text-muted">Category</th><td><?= htmlspecialchars($item['cat_en'] ?? '---') ?></td></tr>
<tr><th class="text-muted">Supplier</th><td><?= htmlspecialchars($item['supplier_name'] ?? '---') ?></td></tr>
<tr><th class="text-muted">Sale Price</th><td>OMR <?= number_format((float)$item['sale_price'], 3) ?></td></tr>
@ -4333,12 +4334,27 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System';
<div class="col-md-6">
<label class="form-label">Name (EN)</label>
<div class="input-group">
<input type="text" name="name_en" id="editItemNameEn<?= $item['id'] ?>" class="form-control" value="<?= htmlspecialchars($item['name_en']) ?>" required>
<input type="text" name="name_en" id="editItemNameEn<?= $item['id'] ?>" class="form-control" value="<?= htmlspecialchars((string)($item['name_en'] ?? '')) ?>" required>
<button class="btn btn-outline-secondary btn-translate" type="button" data-source="editItemNameAr<?= $item['id'] ?>" data-target="editItemNameEn<?= $item['id'] ?>" data-to="en">
<i class="bi bi-translate"></i> EN
</button>
</div>
</div>
<div class="col-md-6">
<label class="form-label">Name (AR)</label>
<div class="input-group">
<input type="text" name="name_ar" id="editItemNameAr<?= $item['id'] ?>" class="form-control" value="<?= htmlspecialchars((string)($item['name_ar'] ?? '')) ?>" required>
<button class="btn btn-outline-secondary btn-translate" type="button" data-source="editItemNameEn<?= $item['id'] ?>" data-target="editItemNameAr<?= $item['id'] ?>" data-to="ar">
<i class="bi bi-translate"></i> AR
</button>
</div>
</div>
...
<div class="col-md-6">
<label class="form-label">SKU</label>
<input type="text" name="sku" class="form-control" value="<?= htmlspecialchars((string)($item['sku'] ?? '')) ?>">
</div>
</div>
<div class="col-md-6">
<label class="form-label">Name (AR)</label>
<div class="input-group">

View File

@ -3,3 +3,5 @@
2026-02-21 17:33:52 - POST: {"open_register":"1","register_id":"3","opening_balance":"2"}
2026-02-21 17:34:02 - POST: {"action":"save_pos_transaction","customer_id":"","payments":"[{\"method\":\"cash\",\"amount\":15.45}]","total_amount":"15.45","tax_amount":"0","discount_code_id":"","discount_amount":"0","loyalty_redeemed":"0","items":"[{\"id\":1,\"qty\":1,\"price\":0.45,\"vat_rate\":0,\"vat_amount\":0},{\"id\":8,\"qty\":1,\"price\":15,\"vat_rate\":0,\"vat_amount\":0}]"}
2026-02-21 17:34:26 - POST: {"action":"save_pos_transaction","customer_id":"","payments":"[{\"method\":\"cash\",\"amount\":15.45}]","total_amount":"15.45","tax_amount":"0","discount_code_id":"","discount_amount":"0","loyalty_redeemed":"0","items":"[{\"id\":1,\"qty\":1,\"price\":0.45,\"vat_rate\":0,\"vat_amount\":0},{\"id\":8,\"qty\":1,\"price\":15,\"vat_rate\":0,\"vat_amount\":0}]"}
2026-02-21 17:37:40 - POST: {"action":"save_pos_transaction","customer_id":"","payments":"[{\"method\":\"cash\",\"amount\":15.45}]","total_amount":"15.45","tax_amount":"0","discount_code_id":"","discount_amount":"0","loyalty_redeemed":"0","items":"[{\"id\":1,\"qty\":1,\"price\":0.45,\"vat_rate\":0,\"vat_amount\":0},{\"id\":8,\"qty\":1,\"price\":15,\"vat_rate\":0,\"vat_amount\":0}]"}
2026-02-21 18:11:19 - POST: {"action":"translate","text":"Tomato","target":"ar"}