add customer note
This commit is contained in:
@@ -22,6 +22,12 @@ if (isNewDb) {
|
||||
db.exec(schema);
|
||||
}
|
||||
|
||||
// Lightweight migration for DBs created before internal_note existed on customers.
|
||||
const customerColumns = db.prepare(`PRAGMA table_info(customers)`).all() as { name: string }[];
|
||||
if (!customerColumns.some((c) => c.name === 'internal_note')) {
|
||||
db.exec(`ALTER TABLE customers ADD COLUMN internal_note TEXT`);
|
||||
}
|
||||
|
||||
const FIRST_ORDER_NUMBER = 8246;
|
||||
|
||||
/** Allocates the next order number inside the caller's transaction. */
|
||||
|
||||
@@ -36,7 +36,7 @@ router.post('/:id/edit', (req, res) => {
|
||||
.prepare(
|
||||
`UPDATE customers SET
|
||||
name = ?, phone = ?, alt_phone = ?, email = ?,
|
||||
address_line1 = ?, address_line2 = ?, city = ?, state = ?, zip = ?
|
||||
address_line1 = ?, address_line2 = ?, city = ?, state = ?, zip = ?, internal_note = ?
|
||||
WHERE id = ?`
|
||||
)
|
||||
.run(
|
||||
@@ -49,6 +49,7 @@ router.post('/:id/edit', (req, res) => {
|
||||
b.city || null,
|
||||
b.state || null,
|
||||
b.zip || null,
|
||||
b.internal_note || null,
|
||||
req.params.id
|
||||
);
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ CREATE TABLE customers (
|
||||
phone TEXT,
|
||||
alt_phone TEXT,
|
||||
email TEXT,
|
||||
internal_note TEXT, -- staff-only; never printed on the invoice
|
||||
created_at TEXT DEFAULT (datetime('now'))
|
||||
);
|
||||
|
||||
|
||||
@@ -19,6 +19,11 @@
|
||||
<label>State <input type="text" name="state" value="{{ customer.state or '' }}"></label>
|
||||
<label>Zip <input type="text" name="zip" value="{{ customer.zip or '' }}"></label>
|
||||
</div>
|
||||
|
||||
<label>
|
||||
Note <span class="hint">(internal only — never printed on the invoice)</span>
|
||||
<textarea name="internal_note" rows="3">{{ customer.internal_note or '' }}</textarea>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<button type="submit">Save</button>
|
||||
|
||||
Reference in New Issue
Block a user