diff --git a/debts.php b/debts.php
index f9d3a3b..2ef3292 100644
--- a/debts.php
+++ b/debts.php
@@ -367,7 +367,7 @@ require_once 'includes/header.php';
= h(payment_status_label($paymentSummary['payment_status'])) ?>
- |
@@ -383,30 +383,80 @@ require_once 'includes/header.php';
diff --git a/includes/sale_form.php b/includes/sale_form.php
index cb4210d..333df6b 100644
--- a/includes/sale_form.php
+++ b/includes/sale_form.php
@@ -30,6 +30,12 @@ $notesPlaceholder = $isEidOrder
$notesHelper = $isEidOrder
? tr('هذه الملاحظة داخلية وتبقى في النظام فقط، ولن تظهر في الإيصال المطبوع.', 'This note is internal, stays in the system only, and will not appear on the printed receipt.')
: tr('سيتم حفظ هذه الملاحظات مع الفاتورة داخل النظام.', 'These notes will be saved with the invoice inside the system.');
+$itemNotePlaceholder = $isEidOrder
+ ? tr('مثال: بدون سكر، تغليف هدية، لون معين، كتابة اسم...', 'Example: no sugar, gift wrap, specific color, write a name...')
+ : tr('ملاحظة داخلية لهذا الصنف...', 'Internal note for this item...');
+$itemNoteHelper = $isEidOrder
+ ? tr('ملاحظة داخلية لهذا الصنف فقط — لا تُطبع في الإيصال.', 'Internal for this item only — not printed on the receipt.')
+ : tr('ملاحظة محفوظة لهذا الصنف داخل النظام.', 'This note is saved for this item inside the system.');
try {
$customers = db()->query('SELECT id, name, phone FROM customers ORDER BY name ASC')->fetchAll();
@@ -97,6 +103,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$finalName = $sku;
}
+$itemNote = trim((string) ($item['item_note'] ?? ''));
+
$price = isset($item['price']) && is_numeric($item['price'])
? max(0, (float) $item['price'])
: (float) $product['price'];
@@ -113,6 +121,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
'name_en' => $finalName,
'qty' => $qty,
'price' => $price,
+ 'item_note' => $itemNote,
'line_total' => $lineTotal,
'vat_percent' => $vatPercent,
'vat_amount' => $itemVat
@@ -604,6 +613,9 @@ require __DIR__ . '/header.php';
const catalogData = = json_encode($catalog, JSON_UNESCAPED_UNICODE) ?>;
const catalogArray = Object.values(catalogData);
const partialPaymentText = '= h(tr('متبقٍ بعد الحفظ:', 'Due after save:')) ?>';
+const showItemNotes = = $isEidOrder ? 'true' : 'false' ?>;
+const itemNotePlaceholder = = json_encode($itemNotePlaceholder, JSON_UNESCAPED_UNICODE) ?>;
+const itemNoteHelper = = json_encode($itemNoteHelper, JSON_UNESCAPED_UNICODE) ?>;
let invoiceItems = {};
let currentInvoiceTotal = 0;
@@ -780,7 +792,8 @@ function addItemToInvoice(sku) {
sku: sku,
name: '= current_lang() ?>' === 'ar' ? item.name_ar : item.name_en,
price: parseFloat(item.price),
- qty: 1
+ qty: 1,
+ item_note: ''
};
}
renderInvoice();
@@ -809,6 +822,23 @@ function changeItemPrice(sku, newPrice) {
renderInvoice();
}
+function changeItemNoteValue(sku, newNote) {
+ if (!invoiceItems[sku]) {
+ return;
+ }
+ invoiceItems[sku].item_note = String(newNote ?? '');
+ cartJson.value = JSON.stringify(Object.keys(invoiceItems).map(currentSku => {
+ const currentItem = invoiceItems[currentSku];
+ return {
+ sku: currentItem.sku,
+ name: currentItem.name,
+ price: currentItem.price,
+ qty: currentItem.qty,
+ item_note: String(currentItem.item_note ?? '')
+ };
+ }));
+}
+
function changeQty(sku, newQty) {
const qty = parseInt(newQty);
if (isNaN(qty) || qty < 1) {
@@ -854,16 +884,22 @@ function renderInvoice() {
totalVat += itemVat;
totalAmount += lineTotal;
- cartData.push({ sku: item.sku, name: item.name, price: item.price, qty: item.qty });
+ cartData.push({ sku: item.sku, name: item.name, price: item.price, qty: item.qty, item_note: String(item.item_note || '') });
const safeSku = escapeHtml(item.sku);
const safeName = escapeHtml(item.name);
+ const safeItemNote = escapeHtml(item.item_note || '');
+ const itemNoteHtml = showItemNotes ? `
+
+ ${escapeHtml(itemNoteHelper)}
+ ` : '';
const tr = document.createElement('tr');
tr.innerHTML = `
- SKU: ${safeSku}
+ ${itemNoteHtml}
+ SKU: ${safeSku}
|
diff --git a/sales.php b/sales.php
index c07c81d..16aaaf9 100644
--- a/sales.php
+++ b/sales.php
@@ -330,7 +330,7 @@ require __DIR__ . '/includes/header.php';
| = h(date('Y-m-d H:i', strtotime((string) $sale['sale_date']))) ?> |
0.0005): ?>
-
+
@@ -365,30 +365,80 @@ require __DIR__ . '/includes/header.php';
|