bills update to outlets

This commit is contained in:
Flatlogic Bot 2026-02-26 05:15:35 +00:00
parent 0a530f6c7b
commit a7e405eadf
11 changed files with 244 additions and 7 deletions

View File

@ -1,7 +1 @@
Plan: Change the "Invite User" button text to "Add User" in the User Management page to make it more descriptive and match the modal's title.
Changed:
* `index.php`: Updated the button text and English localization attribute (`data-en`) from "Invite User" to "Add User".
Next:
Check out the User Management page to confirm the button now says "Add User". Let me know if you need anything else!
feat: use outlet information for printed bills and receipts

26
fix_showreceipt.php Normal file
View File

@ -0,0 +1,26 @@
<?php
$content = file_get_contents('index.php');
$search = <<<'JS'
const rcn = document.getElementById('receiptCompanyName');
if(rcn) rcn.textContent = data.outlet_name || "<?= htmlspecialchars($data['settings']['company_name'] ?? 'Accounting System') ?>";
const rca = document.getElementById('receiptCompanyAddress');
if(rca) rca.innerHTML = data.outlet_address ? data.outlet_address.replace(/\n/g, '<br>') : "<?= nl2br(htmlspecialchars($data['settings']['company_address'] ?? '')) ?>";
// Update labels for Purchase vs Sale
JS;
$replace = <<<'JS'
const rcn = document.getElementById('receiptCompanyName');
if(rcn) rcn.textContent = data.outlet_name || "<?= htmlspecialchars($data['settings']['company_name'] ?? 'Accounting System') ?>";
const rca = document.getElementById('receiptCompanyAddress');
if(rca) {
rca.textContent = data.outlet_address || "<?= nl2br(htmlspecialchars($data['settings']['company_address'] ?? '')) ?>".replace(/<br\s*[\/]?>/gi, '\n');
rca.style.whiteSpace = 'pre-line';
}
// Update labels for Purchase vs Sale
JS;
$content = str_replace($search, $replace, $content);
file_put_contents('index.php', $content);

23
patch_lpoprint.php Normal file
View File

@ -0,0 +1,23 @@
<?php
$content = file_get_contents('index.php');
$search = <<<'JS'
<h4 class="fw-bold mb-0">${companySettings.company_name || 'Your Company'}</h4>
<p class="text-muted mb-0 small">
${companySettings.company_address || ''}<br>
Phone: ${companySettings.company_phone || ''} | Email: ${companySettings.company_email || ''}
${companySettings.tax_number ? `<br>TRN: ${companySettings.tax_number}` : ''}
</p>
JS;
$replace = <<<'JS'
<h4 class="fw-bold mb-0">${data.outlet_name || companySettings.company_name || 'Your Company'}</h4>
<p class="text-muted mb-0 small">
${data.outlet_address ? data.outlet_address.replace(/\n/g, '<br>') : (companySettings.company_address || '').replace(/\n/g, '<br>')}<br>
Phone: ${data.outlet_phone || companySettings.company_phone || ''} | Email: ${companySettings.company_email || ''}
${companySettings.tax_number ? `<br>TRN: ${companySettings.tax_number}` : ''}
</p>
JS;
$content = str_replace($search, $replace, $content);
file_put_contents('index.php', $content);

23
patch_payment.php Normal file
View File

@ -0,0 +1,23 @@
<?php
$content = file_get_contents('index.php');
$search = <<<'SQL'
$stmt = db()->prepare("SELECT p.*, i.customer_id, c.name as customer_name,
o.name as outlet_name, o.address as outlet_address, o.phone as outlet_phone
FROM payments p
JOIN invoices i ON p.invoice_id = i.id
LEFT JOIN customers c ON i.customer_id = c.id
LEFT JOIN outlets o ON i.outlet_id = o.id
WHERE p.id = ?");
SQL;
$replace = <<<'SQL'
$stmt = db()->prepare("SELECT p.*, i.customer_id, i.id as inv_id, c.name as customer_name,
o.name as outlet_name, o.address as outlet_address, o.phone as outlet_phone
FROM payments p
JOIN invoices i ON p.invoice_id = i.id
LEFT JOIN customers c ON i.customer_id = c.id
LEFT JOIN outlets o ON i.outlet_id = o.id
WHERE p.id = ?");
SQL;
$content = str_replace($search, $replace, $content);
file_put_contents('index.php', $content);

37
patch_posreceipt.php Normal file
View File

@ -0,0 +1,37 @@
<?php
$content = file_get_contents('index.php');
$search = <<<'JS'
const companyName = "<?= htmlspecialchars($data['settings']['company_name'] ?? 'Accounting System') ?>";
const companyPhone = "<?= htmlspecialchars($data['settings']['company_phone'] ?? '') ?>";
const companyVat = "<?= htmlspecialchars($data['settings']['vat_number'] ?? '') ?>";
const companyLogo = "<?= htmlspecialchars($data['settings']['company_logo'] ?? '') ?>";
container.innerHTML = `
<div class="thermal-receipt <?= $lang === 'ar' ? 'rtl' : '' ?>">
<div class="center">
${companyLogo ? `<img src="${companyLogo}" alt="Logo" style="max-height: 60px; width: auto; margin-bottom: 10px; display: block; margin-left: auto; margin-right: auto;">` : ''}
<h5 class="mb-0 fw-bold">${companyName}</h5>
${companyPhone ? `<div>هاتف / Tel: ${companyPhone}</div>` : ''}
${companyVat ? `<div>الرقم الضريبي / VAT No: ${companyVat}</div>` : ''}
JS;
$replace = <<<'JS'
const companyName = outletName || "<?= htmlspecialchars($data['settings']['company_name'] ?? 'Accounting System') ?>";
const companyPhone = outletPhone || "<?= htmlspecialchars($data['settings']['company_phone'] ?? '') ?>";
const companyAddress = outletAddress ? outletAddress.replace(/\n/g, '<br>') : "<?= nl2br(htmlspecialchars($data['settings']['company_address'] ?? '')) ?>";
const companyVat = "<?= htmlspecialchars($data['settings']['vat_number'] ?? '') ?>";
const companyLogo = "<?= htmlspecialchars($data['settings']['company_logo'] ?? '') ?>";
container.innerHTML = `
<div class="thermal-receipt <?= $lang === 'ar' ? 'rtl' : '' ?>">
<div class="center">
${companyLogo ? `<img src="${companyLogo}" alt="Logo" style="max-height: 60px; width: auto; margin-bottom: 10px; display: block; margin-left: auto; margin-right: auto;">` : ''}
<h5 class="mb-0 fw-bold">${companyName}</h5>
${companyAddress ? `<div>${companyAddress}</div>` : ''}
${companyPhone ? `<div>هاتف / Tel: ${companyPhone}</div>` : ''}
${companyVat ? `<div>الرقم الضريبي / VAT No: ${companyVat}</div>` : ''}
JS;
$content = str_replace($search, $replace, $content);
file_put_contents('index.php', $content);

17
patch_qrcode.php Normal file
View File

@ -0,0 +1,17 @@
<?php
$content = file_get_contents('index.php');
$search = <<<'JS'
const companyName = <?= json_encode($data['settings']['company_name'] ?? 'Accounting System') ?>;
const vatNo = <?= json_encode($data['settings']['vat_number'] ?? '') ?>;
const qrData = `Seller: ${companyName}\nVAT: ${vatNo}\nInvoice: INV-${data.id.toString().padStart(5, '0')}\nDate: ${data.invoice_date}\nTotal: ${grandTotalValue.toFixed(3)}`;
JS;
$replace = <<<'JS'
const companyName = data.outlet_name || <?= json_encode($data['settings']['company_name'] ?? 'Accounting System') ?>;
const vatNo = <?= json_encode($data['settings']['vat_number'] ?? '') ?>;
const qrData = `Seller: ${companyName}\nVAT: ${vatNo}\nInvoice: INV-${data.id.toString().padStart(5, '0')}\nDate: ${data.invoice_date}\nTotal: ${grandTotalValue.toFixed(3)}`;
JS;
$content = str_replace($search, $replace, $content);
file_put_contents('index.php', $content);

40
patch_quotations.php Normal file
View File

@ -0,0 +1,40 @@
<?php
$content = file_get_contents('index.php');
// Quotations query update
$search_q = <<<'SQL'
$stmt = db()->prepare("SELECT q.*, c.name as customer_name
FROM quotations q
JOIN customers c ON q.customer_id = c.id
WHERE $whereSql
SQL;
$replace_q = <<<'SQL'
$stmt = db()->prepare("SELECT q.*, c.name as customer_name, o.name as outlet_name, o.address as outlet_address, o.phone as outlet_phone
FROM quotations q
JOIN customers c ON q.customer_id = c.id
LEFT JOIN outlets o ON q.outlet_id = o.id
WHERE $whereSql
SQL;
$content = str_replace($search_q, $replace_q, $content);
// LPOs query update
$search_l = <<<'SQL'
$stmt = db()->prepare("SELECT q.*, s.name as supplier_name
FROM lpos q
JOIN suppliers s ON q.supplier_id = s.id
WHERE $whereSql
SQL;
$replace_l = <<<'SQL'
$stmt = db()->prepare("SELECT q.*, s.name as supplier_name, o.name as outlet_name, o.address as outlet_address, o.phone as outlet_phone
FROM lpos q
JOIN suppliers s ON q.supplier_id = s.id
LEFT JOIN outlets o ON q.outlet_id = o.id
WHERE $whereSql
SQL;
$content = str_replace($search_l, $replace_l, $content);
file_put_contents('index.php', $content);

15
patch_receipt.php Normal file
View File

@ -0,0 +1,15 @@
<?php
$content = file_get_contents('index.php');
$search = <<<'HTML'
<h3 class="mb-1 fw-bold"><?= htmlspecialchars($data['settings']['company_name'] ?? 'Accounting System') ?></h3>
<p class="text-muted small mb-0"><?= nl2br(htmlspecialchars($data['settings']['company_address'] ?? '')) ?></p>
HTML;
$replace = <<<'HTML'
<h3 class="mb-1 fw-bold" id="receiptCompanyName"><?= htmlspecialchars($data['settings']['company_name'] ?? 'Accounting System') ?></h3>
<p class="text-muted small mb-0" id="receiptCompanyAddress"><?= nl2br(htmlspecialchars($data['settings']['company_address'] ?? '')) ?></p>
HTML;
$content = str_replace($search, $replace, $content);
file_put_contents('index.php', $content);

22
patch_showreceipt.php Normal file
View File

@ -0,0 +1,22 @@
<?php
$content = file_get_contents('index.php');
$search = <<<'JS'
document.getElementById('receiptAmountWords').textContent = data.amount_words;
// Update labels for Purchase vs Sale
JS;
$replace = <<<'JS'
document.getElementById('receiptAmountWords').textContent = data.amount_words;
const rcn = document.getElementById('receiptCompanyName');
if(rcn) rcn.textContent = data.outlet_name || "<?= htmlspecialchars($data['settings']['company_name'] ?? 'Accounting System') ?>";
const rca = document.getElementById('receiptCompanyAddress');
if(rca) rca.innerHTML = data.outlet_address ? data.outlet_address.replace(/\n/g, '<br>') : "<?= nl2br(htmlspecialchars($data['settings']['company_address'] ?? '')) ?>";
// Update labels for Purchase vs Sale
JS;
$content = str_replace($search, $replace, $content);
file_put_contents('index.php', $content);

19
patch_viewquot.php Normal file
View File

@ -0,0 +1,19 @@
<?php
$content = file_get_contents('index.php');
$search = <<<'JS'
const companyName = companySettings.company_name || 'Accounting System';
const companyAddress = (companySettings.company_address || '').replace(/\n/g, '<br>');
const companyVat = companySettings.vat_number ? `<p class="text-muted small mb-0">VAT: ${companySettings.vat_number}</p>` : '';
const companyPhone = companySettings.company_phone ? `<p class="text-muted small mb-0">Tel: ${companySettings.company_phone}</p>` : '';
JS;
$replace = <<<'JS'
const companyName = data.outlet_name || companySettings.company_name || 'Accounting System';
const companyAddress = data.outlet_address ? data.outlet_address.replace(/\n/g, '<br>') : (companySettings.company_address || '').replace(/\n/g, '<br>');
const companyVat = companySettings.vat_number ? `<p class="text-muted small mb-0">VAT: ${companySettings.vat_number}</p>` : '';
const companyPhone = data.outlet_phone ? `<p class="text-muted small mb-0">Tel: ${data.outlet_phone}</p>` : (companySettings.company_phone ? `<p class="text-muted small mb-0">Tel: ${companySettings.company_phone}</p>` : '');
JS;
$content = str_replace($search, $replace, $content);
file_put_contents('index.php', $content);

21
update_payment.php Normal file
View File

@ -0,0 +1,21 @@
<?php
$content = file_get_contents('index.php');
$search = <<<'SQL'
$stmt = db()->prepare("SELECT p.*, i.customer_id, c.name as customer_name
FROM payments p
JOIN invoices i ON p.invoice_id = i.id
JOIN customers c ON i.customer_id = c.id
WHERE p.id = ?");
SQL;
$replace = <<<'SQL'
$stmt = db()->prepare("SELECT p.*, i.customer_id, i.type as inv_type, i.id as inv_id, c.name as customer_name,
o.name as outlet_name, o.address as outlet_address, o.phone as outlet_phone
FROM payments p
JOIN invoices i ON p.invoice_id = i.id
LEFT JOIN customers c ON i.customer_id = c.id
LEFT JOIN outlets o ON i.outlet_id = o.id
WHERE p.id = ?");
SQL;
$content = str_replace($search, $replace, $content);
file_put_contents('index.php', $content); // oops wait, file_put_contents