main
parent
93859cf971
commit
e5a54e6c5d
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue