Suvodip 2025-03-19 11:03:38 +05:30
parent 93859cf971
commit e5a54e6c5d
1 changed files with 2 additions and 4 deletions

View File

@ -102,13 +102,11 @@
if ($stmt->execute()) {
$customerAddress = $stmt->fetch(PDO::FETCH_ASSOC);
}
// Generate new Invoice Id
$stmt = $db->query("SELECT id FROM invoice WHERE DATE(invoiceDate) = CURDATE() ORDER BY id DESC LIMIT 1");
$lastInvoice = $stmt->fetch(PDO::FETCH_ASSOC);
$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");