Suvodip 2025-03-19 10:56:58 +05:30
parent 9f69cd9b9f
commit 93859cf971
1 changed files with 5 additions and 1 deletions

View File

@ -105,7 +105,11 @@
$stmt = $db->query("SELECT id FROM invoice WHERE DATE(invoiceDate) = CURDATE() ORDER BY id DESC LIMIT 1");
$lastInvoice = $stmt->fetch(PDO::FETCH_ASSOC);
$invoiceId = "CB" . date('my') . ($lastInvoice ? ($lastInvoice['id'] + 1) : '1');
$nextId = $lastInvoice ? ($lastInvoice['id'] + 1) : 1;
// Ensure the ID is always three digits (e.g., 001, 010, 100)
$invoiceId = "CB" . date('my') . str_pad($nextId, 3, '0', STR_PAD_LEFT);
$stmt = $db->query("SELECT invoiceId FROM invoice ORDER BY id DESC LIMIT 1");
$lastInvoicePrint = $stmt->fetch(PDO::FETCH_ASSOC);