diff --git a/commit_message.txt b/commit_message.txt index bd60dfc..ceeae73 100644 --- a/commit_message.txt +++ b/commit_message.txt @@ -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 diff --git a/fix_showreceipt.php b/fix_showreceipt.php new file mode 100644 index 0000000..2b239cf --- /dev/null +++ b/fix_showreceipt.php @@ -0,0 +1,26 @@ +"; + const rca = document.getElementById('receiptCompanyAddress'); + if(rca) rca.innerHTML = data.outlet_address ? data.outlet_address.replace(/\n/g, '
') : ""; + + // Update labels for Purchase vs Sale +JS; + +$replace = <<<'JS' + const rcn = document.getElementById('receiptCompanyName'); + if(rcn) rcn.textContent = data.outlet_name || ""; + const rca = document.getElementById('receiptCompanyAddress'); + if(rca) { + rca.textContent = data.outlet_address || "".replace(//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); diff --git a/patch_lpoprint.php b/patch_lpoprint.php new file mode 100644 index 0000000..7b6b910 --- /dev/null +++ b/patch_lpoprint.php @@ -0,0 +1,23 @@ +${companySettings.company_name || 'Your Company'} +

+ ${companySettings.company_address || ''}
+ Phone: ${companySettings.company_phone || ''} | Email: ${companySettings.company_email || ''} + ${companySettings.tax_number ? `
TRN: ${companySettings.tax_number}` : ''} +

+JS; + +$replace = <<<'JS' +

${data.outlet_name || companySettings.company_name || 'Your Company'}

+

+ ${data.outlet_address ? data.outlet_address.replace(/\n/g, '
') : (companySettings.company_address || '').replace(/\n/g, '
')}
+ Phone: ${data.outlet_phone || companySettings.company_phone || ''} | Email: ${companySettings.company_email || ''} + ${companySettings.tax_number ? `
TRN: ${companySettings.tax_number}` : ''} +

+JS; + +$content = str_replace($search, $replace, $content); +file_put_contents('index.php', $content); diff --git a/patch_payment.php b/patch_payment.php new file mode 100644 index 0000000..5fb2a7a --- /dev/null +++ b/patch_payment.php @@ -0,0 +1,23 @@ +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); diff --git a/patch_posreceipt.php b/patch_posreceipt.php new file mode 100644 index 0000000..1dcd85b --- /dev/null +++ b/patch_posreceipt.php @@ -0,0 +1,37 @@ +"; + const companyPhone = ""; + const companyVat = ""; + const companyLogo = ""; + + container.innerHTML = ` +
+
+ ${companyLogo ? `Logo` : ''} +
${companyName}
+ ${companyPhone ? `
هاتف / Tel: ${companyPhone}
` : ''} + ${companyVat ? `
الرقم الضريبي / VAT No: ${companyVat}
` : ''} +JS; + +$replace = <<<'JS' + const companyName = outletName || ""; + const companyPhone = outletPhone || ""; + const companyAddress = outletAddress ? outletAddress.replace(/\n/g, '
') : ""; + const companyVat = ""; + const companyLogo = ""; + + container.innerHTML = ` +
+
+ ${companyLogo ? `Logo` : ''} +
${companyName}
+ ${companyAddress ? `
${companyAddress}
` : ''} + ${companyPhone ? `
هاتف / Tel: ${companyPhone}
` : ''} + ${companyVat ? `
الرقم الضريبي / VAT No: ${companyVat}
` : ''} +JS; + +$content = str_replace($search, $replace, $content); +file_put_contents('index.php', $content); diff --git a/patch_qrcode.php b/patch_qrcode.php new file mode 100644 index 0000000..64cc16c --- /dev/null +++ b/patch_qrcode.php @@ -0,0 +1,17 @@ +; + const vatNo = ; + 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 || ; + const vatNo = ; + 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); diff --git a/patch_quotations.php b/patch_quotations.php new file mode 100644 index 0000000..07f2c40 --- /dev/null +++ b/patch_quotations.php @@ -0,0 +1,40 @@ +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); diff --git a/patch_receipt.php b/patch_receipt.php new file mode 100644 index 0000000..034d128 --- /dev/null +++ b/patch_receipt.php @@ -0,0 +1,15 @@ + +

+HTML; + +$replace = <<<'HTML' +

+

+HTML; + +$content = str_replace($search, $replace, $content); +file_put_contents('index.php', $content); diff --git a/patch_showreceipt.php b/patch_showreceipt.php new file mode 100644 index 0000000..ab79f6c --- /dev/null +++ b/patch_showreceipt.php @@ -0,0 +1,22 @@ +"; + const rca = document.getElementById('receiptCompanyAddress'); + if(rca) rca.innerHTML = data.outlet_address ? data.outlet_address.replace(/\n/g, '
') : ""; + + // Update labels for Purchase vs Sale +JS; + +$content = str_replace($search, $replace, $content); +file_put_contents('index.php', $content); diff --git a/patch_viewquot.php b/patch_viewquot.php new file mode 100644 index 0000000..0d5801a --- /dev/null +++ b/patch_viewquot.php @@ -0,0 +1,19 @@ +'); + const companyVat = companySettings.vat_number ? `

VAT: ${companySettings.vat_number}

` : ''; + const companyPhone = companySettings.company_phone ? `

Tel: ${companySettings.company_phone}

` : ''; +JS; + +$replace = <<<'JS' + const companyName = data.outlet_name || companySettings.company_name || 'Accounting System'; + const companyAddress = data.outlet_address ? data.outlet_address.replace(/\n/g, '
') : (companySettings.company_address || '').replace(/\n/g, '
'); + const companyVat = companySettings.vat_number ? `

VAT: ${companySettings.vat_number}

` : ''; + const companyPhone = data.outlet_phone ? `

Tel: ${data.outlet_phone}

` : (companySettings.company_phone ? `

Tel: ${companySettings.company_phone}

` : ''); +JS; + +$content = str_replace($search, $replace, $content); +file_put_contents('index.php', $content); diff --git a/update_payment.php b/update_payment.php new file mode 100644 index 0000000..ea1de35 --- /dev/null +++ b/update_payment.php @@ -0,0 +1,21 @@ +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