# Progress

✅ done · 🟡 part done · ⏳ pending

## Pages (from the prototype `southgate-timber-crm-v4.html`)

| Module | Page (prototype function) | Status | Notes |
|---|---|---|---|
| **Login** | Sign in (`pgLogin`) | ✅ | `/st_manager/auth/tl6hbosn4`, email or username |
| | Two-factor code (`pgLoginMfaForm`) | ✅ | 6-digit code emailed at sign-in (10 min, 5 tries, resend); shown on screen only when `APP_ENV=local` |
| | Forgot / reset / set password | ✅ | Emailed link (60 min); welcome emails use the same link |
| | Account lockout | ✅ | 5 wrong passwords lock the account; an admin unlocks it |
| **Dashboard** | Operational dashboard (`pgDash`) | ✅ | All 12 cards, real data. GA / social / integrations show "Not connected" until Config › Integrations |
| **Orders** | All orders list (`pgOrders`) | ✅ | 16-column grid, inline edits save, KPIs, periods, site filter, search, CSV export |
| | Samples / Abandoned carts (sidebar views) | ✅ | Filters of the list |
| | Unused carts | ✅ | `orders/unused-carts` |
| | Order page (`pgOrderDetail`) – Details tab | ✅ | Customer card (orders, lifetime spend, last order), addresses + map link, delivery costs, cart weight, pick progress, order lines, totals |
| | – Pick list tab (`odPickList`) | ✅ | Pick / undo per line, note per line, pick all, weights, "Mark ready for despatch" modal (service, date, tracking). Bays show "No bay set" until products are migrated |
| | – Payment tab (`odPayment`) | ✅ | Confirmed / pending box + full gateway history (Paysmart, Sage Pay) |
| | – Tasks tab (`odTasks`) | ✅ | Add task (assignee, priority, due), mark done / reopen, overdue flag. AI task generator ⏳ |
| | – Notes/Journal tab (`odNotes`) | ✅ | Internal / customer-facing / picking notes + activity log (saved actions and system events) |
| | – Delivery images tab (`odDeliveryImages`) | ✅ | Upload (after despatch), view, remove |
| | – AI order check panel (`aiPanel`) | ⏳ | Needs Config › Integrations (Anthropic key) |
| | Receipt (`pgOrderReceipt`) | ✅ | `orders/{order}/receipt`, print-friendly, real gateway response |
| | Order history (`pgOrderHistory`) | ✅ | History tab: the customer's orders (by email until customers are migrated) |
| | New order | ✅ | Phone / counter order builder (like the quote builder): customer search, product search with the customer's trade prices, bespoke lines, delivery or collection, **delivery charge worked out from Delivery Pricing** (postcode + cart weight from product / length weights + longest length; pick an option), payment state (pending, card by phone / card machine, bank transfer, cash, on account, free of charge — no card numbers in the CRM), discount %, website, notes; creates the next SGT number, staff initials, books counted stock out ("Order" movements). **Quote → order:** "Convert to order" on the quote page (choose the payment state): same customer, delivery, lines with products, discount and total; quote accepted and linked both ways; a second click goes to the existing order |
| | Collection reschedule modal | ✅ | Done as the collection booking page (change date / time, linked from the day view) |
| **Collections** | Month view (`pgCollMonth`) | ✅ | Calendar with free-slot badges (green / amber / full / closed), override tag, booked count, tick box to open / close a day, month navigation |
| | Day view (`pgCollDay`) | ✅ | Hourly grid with remaining / capacity, booking cards, "Open slot" placeholders, block / unblock an hour, close / open day, special hours for one day, booking modal (copies name / email / phone / value from the order, capacity check, overbook option) |
| | Booking edit (`pgCollBookingEdit`) | ✅ | Collection details, history, journal entry, email & calls log, Collected (marks the order collected), Cancel (frees the slot). Keeps the order's collection date / time in step |
| | Collection settings (`pgCollConfig`) | ✅ | Collection days, times, capacity per hour, lead time, minimum order value, closed days (add / reopen), upcoming day overrides |
| **Quotes** | Quotes list (`pgQuotes`) | ✅ | 6 KPI cards, All / Draft / Sent / Overdue / Accepted / Expired / Declined tabs with counts, owner filter, search, chase-date line under sent quotes, Email button, CSV export |
| | Quote page (`pgQuoteDetail`) | ✅ | Quote lines (edit qty / price / name, add from product search or bespoke, remove), sidebar (customer, delivery, discount & validity, owner, notes), Accepted / Declined / Reopen |
| | – PDF preview | ✅ | Printable quote (print / save as PDF from the browser) |
| | – Email (`pgQuoteEmailTab`) | ✅ | Compose + send; quote attached in the body; draft → Sent; logged in the Email trail |
| | – History & notes, Email trail | ✅ | Journal, follow-ups (moves the chase date), status changes; every email sent |
| | New quote (`pgQuoteNew`) | ✅ | Customer search, product search with lengths and prices, bespoke lines, delivery / collection, discount %, validity, notes, live totals. Delivery charge typed in until the Delivery Pricing calculator is built |
| **Categories / Products** | Category / product browser (`renderCatView`) | ✅ | Category tiles (suspend / reinstate, suspended banner), sub-category list, product table (thumbnail, SKU, live switch, websites, stock badge, price inc. VAT), "also shown here" products, sort mode (drag to reorder sub-categories / products), product search by name / SKU / code, new / edit / delete category (two levels; parent, address kept exactly, websites, tile image from the library, SEO, stock unit, category %). Product editor tabs: Details (name, SKU, code, address, display / mobile name, brand, main + extra categories, status flags, websites), Content & SEO (descriptions cleaned of scripts, meta, delivery / collection text, video, feature rows), Pricing (unit, web / trade / sale / cost / m² / sample prices ex VAT with inc-VAT shown, margin, weight, stock), Lengths & stock (per length: SKU, price, kg, stock, warn at, out-below level, bay, held; add / remove; logged stock adjustments), Images (from the image library, main photo), Cross-sell, History (price changes, stock movements, sales). Duplicate (copy switched off), delete. Quote builder search now reads the catalogue and quote lines keep the product / length picked |
| | Stock levels (`pgStock`), stock detail (`pgStockDetail`), stock order (`pgStockOrder`) | ✅ | Tabs Categories / Stock / Reorder / Purchase orders / Suppliers. **Stock:** KPIs (products counted, low, out of stock (selling lines), to order + open POs), needs attention (out / low lines that sell or have a reorder level, or need ordering) / out / low / all, per product a row of length chips. **Product stock page:** a card per length (stock, reorder at, sold / month, bay, bar, days left, on order, urgency, suggested qty, Adjust), open purchase orders, recent movements, Reorder low. **Reorder list:** urgency (critical / order now / watch) from stock + on order vs the reorder point ("reorder at" or worked out from sales over the lead time + a week), days left, 6-month sales sparkline + trend, lead time, editable order qty, est. cost; tick lines → one draft PO per supplier; CSV order sheet. Sales = paid orders, samples excluded, matched to a length by its name in the order line. **Purchase orders:** list by status, new / draft (add catalogue or other items, qty, unit cost), send (emails the supplier when an address is set), book goods in (part / full, adds stock with a "Delivery in" movement), cancel, delete draft. **Suppliers:** contact, order email, lead time, terms, account no., VAT no., link / unlink products. Stock value / order cost need cost prices (none in the old data). AI stock advice ⏳ (Config › Integrations). Dashboard low-stock card now reads the catalogue |
| **Reports** | Reports hub (`pgRptHub`) | ✅ | Date range (30 days / 90 days / 12 months / year to date / own dates), KPIs with change on the previous period of the same length (revenue, paid orders, quotes accepted + conversion, orders despatched), report cards, 12-month revenue chart. Stock ordering and AI trends shown as coming soon |
| | Sales, Orders, Quotes, Delivery, Marketing reports + drill-downs (`pgRpt*`, `pgRptDrill*`) | ✅ | Revenue = paid placed orders inc. VAT (`Services/Reports/Reports`). Sales: revenue / orders / AOV / refunds, monthly chart, by website (opens the order list for the same dates, `period=custom`), top products. Orders: fulfilment and payment status, customer type mix, samples, abandoned carts. Delivery: how orders went out, collection bookings, run stops. Quotes: pipeline and value by status (opens the quote tab), conversion, by owner (opens their quotes). Marketing: promo codes, discount given, SMS. CSV export per report (cells starting = + - @ are quoted). Links into other modules only show with access to them. Channel attribution needs website tracking (not in the old data) |
| | Trends (`pgTrends`) | ⏳ | Needs the Anthropic key in Config › Integrations; stock ordering needs the catalogue |
| **Accounts** | Accounts hub (`pgAcctsHub`) | ⏳ | New, no old data |
| | Nominal ledger, Sales ledger, Purchase ledger, VAT, P&L, Bank reconciliation | ⏳ | |
| **Delivery** | Delivery planner (`pgDelivery`), route plan (`pgRoutePlan`) | 🟡 | Planner by date: KPI strip with drill-downs (stops, completed, in transit, at risk), at-risk alert, despatch queue (paid delivery orders not despatched or on a run; weight / longest item, suggested service and price from Delivery Pricing, due-in days) with "assign to run", run cards (driver, vehicle, departs, capacity %, progress, stops). Route plan: stops in order with up / down and a Google Maps directions link (`YARD_POSTCODE` = start). AI optimise, live traffic and GPS tracking ⏳ (need Config › Integrations) |
| | Delivery record (`pgDeliveryRecord`), driver run (`pgDriverRun`) | ✅ | Driver run: KPIs (stops, delivered, in transit, at risk, value, load), progress, overweight / too-long warning, stops with reorder / remove, printable run sheet with signature column, Maps link, run details (driver, vehicle, date, departs, status, notes). Delivery record: details, status / ETA / arrival / signed-for name / notes; Delivered marks the order Despatched (lorry), Not delivered puts it back in the queue; email / call links and call log on the order timeline. SMS / Outlook sending ⏳ (SMS, Email modules) |
| | Delivery calculator (`pgCalc`) | ✅ | Under Delivery Pricing: postcode, weight, longest item → parcel / courier / lorry options with base, weight surcharge and length premium; flags unknown outcodes; also answers JSON (for the quote builder / new order later) |
| **Delivery Pricing** | Pricing zones (`pgPricingZones`) | ✅ | Rates list with All / Parcel / Courier / Lorry / Other tabs, postcode search ("rates covering CV32"), add / edit rate (price or P.O.A., service, method, regions, postcodes, weight and length conditions, surcharges, estimate), on / off, delete |
| **Fleet & Drivers** | Fleet (`pgFleet`), vehicle edit (`pgVehicleEdit`), driver edit (`pgDriverEdit`) | ✅ | Vehicles and Drivers tabs (with Couriers): vehicle cards with MOT / service / road tax due (amber within 30 days, red overdue), off-road flag, assigned driver; driver cards with licence / CPC expiry (CPC N/A for category B), "Action needed", vehicle; add / edit / remove; one driver per vehicle; a driver can be linked to a login for the driver run. New, no old data |
| **Couriers** | Couriers (`pgCouriers`), courier edit (`pgCourierEdit`), rate lookup (`pgCourierRateLookup`) | ✅ | Courier cards (account no., limits, lead time, regions, contact, tracking portal, orders sent), add / edit (tracking URL with `{code}` gives orders a direct tracking link), delete (set inactive if it has orders), rate lookup using the delivery pricing. Order despatch now records the courier. Starts empty: the old system had no couriers |
| **Users** | Users list (`pgUserList`) | ✅ | Cards, security alerts (locked, no MFA, old passwords, invited), online dot, search |
| | New user wizard (`pgUserNew`) | ✅ | Details → Role → Security (welcome email or password + strength meter, force change, MFA) → Confirm |
| | Edit user (`pgUserEdit`) | ✅ | Profile + photo, status, role, per-module permission overrides, MFA, reset link, revoke sessions, unlock, deactivate, activity |
| | My account (`pgMyAccount`) | ✅ | Profile + photo, change password, two-factor on/off, notification preferences, active sessions |
| **Roles** | Roles manager (`pgRolesManager`) | ✅ | Matrix (edit / view / none), inline editor, new / delete role, users by role. Super Admin is built in |
| **Customers** | Customers list (`pgCustomers`) | ✅ | All / Retail / Trade / Loyalty tabs with counts, search (name, company, email, phone, postcode), sort (last order, spend, orders, name, newest), guest checkouts hidden by default, Add customer modal |
| | Customer page (`pgCustomerDetail`) | ✅ | Company details form + saved addresses, summary sidebar, quick actions (email, call, log call, create quote) |
| | – Orders tab (`pgCustOrders`) | ✅ | Totals + order history with payment / fulfilment status, links to orders |
| | – Quotes tab (`pgCustQuotes`) | ✅ | The customer's quotes (by customer or email), open the quote page; New quote pre-fills the customer |
| | – Loyalty / Trade account tab | ✅ | Discount, credit limit, quantity discounts, welcome email date; editable (built with the Loyalty module) |
| | – Notes tab | ✅ | Notes + activity timeline (notes, logged calls) |
| | Welcome email (`pgWelcomeEmail`), AI account health panel | 🟡 | Welcome email ✅ (customer Loyalty tab: sends to the main contact, optional personal message, no password). AI account health ⏳ (Config › Integrations) |
| **SMS Marketing** | Campaigns (`pgSMS`), new (`pgSMSNew`), detail (`pgSMSDetail`), contacts (`pgSMSContacts`) | ✅ | KPIs, campaign list, new / edit campaign (bulk, personalised [NAME], single; character + text count + cost; audiences: opted-in loyalty / trade by trade type / all opted-in customers / uploaded lists with consent tick; send now, schedule, draft; send a test), detail (stats, recipients with status), contact lists (CSV upload, opt-out kept forever). Sends through Twilio from Config › Integrations — nothing goes out until it is switched on; scheduled campaigns go via `php artisan schedule:run` (cron). AI SMS copy ⏳ |
| **Image Library** | Folders / grid (`pgImageGrid`), image detail (`pgImageDetail`), picker (`pgImagePicker`) | ✅ | Folder cards with thumbnails, new / rename / delete-empty folder, grid with search and sort, select all and bulk move / tag / watermark on-off / delete, upload (optional watermark, original kept), image page (alt text, tags, folder, watermark toggle, copy URL, download, delete), picker used by the blog leader image and the gallery “Add from library”. New, no old data (old `z_system_images` are product swatches / banners / PDFs: catalogue) |
| **Email** | Inbox (`pgEmailList`), thread (`pgEmailThread`), compose (`pgEmailCompose`) | ✅ | Folders (inbox, starred, sent, archive) + website enquiries tab (old “Notify me” requests: reply, mark replied), search, unread, thread view (HTML cleaned, linked quote / order from the subject), reply, compose, star, archive, “check for new email”. Reads and sends through the Outlook mailbox (Microsoft Graph) when Microsoft 365 is connected in Config › Integrations, synced every 5 minutes; otherwise sends with the app mailer |
| **Tasks** | Board (`pgTaskBoard`), list (`pgTaskList`), task (`pgTaskDetail`), new (`pgTaskNew`), AI suggestions (`pgTaskAI`) | 🟡 | Board (Open / In progress / Waiting / Done columns, cards with type, priority, linked order, assignee, due, overdue flag, move buttons), list view, filters (all, mine, open, overdue, done, type, search), new task (title, type, priority, assignee, department, dates, linked order, description, watchers), task page (edit, mark done / reopen, notes & history, delete). Tasks made on orders show here too. AI task review ⏳ (Config › Integrations) |
| **Gallery** | Albums (`pgGalleryDirs`), grid (`pgGalleryGrid`), item (`pgGalleryDetail`) | ✅ | Album cards (cover, photo count, hidden flag), new album, album settings (name, live address, description, SEO, sites, order, show / hide, delete), photo grid with search, select all and bulk move / watermark on-off / hide / show / delete, upload (JPG / PNG / GIF up to 20 MB, optional “southgatetimber.co.uk” watermark drawn on the image, original kept), photo page (caption, description, album, order, show / hide, watermark toggle, download, delete). Old photos: set `LEGACY_GALLERY_IMAGE_URL`. “Add from library” waits for the Image library |
| **Blogs** | Posts (`pgBlogList`), editor (`pgBlogEditor`), preview (`pgBlogPreview`) | ✅ | List (All / Published / Drafts, site filter, search, thumbnail, site badges, quick publish), editor (title, live address kept exactly for old posts, intro, leader image upload or YouTube / Vimeo, meta, rich text with toolbar + HTML mode, teaser, sites, category from the old catalogue, linked products), Save draft / Publish / Unpublish / delete, preview with SEO snippet. Body HTML is cleaned (no scripts / handlers). Old images: set `LEGACY_BLOG_IMAGE_URL`. Category and "Products in this post" now from the catalogue (product chip picker: type a name / SKU) |
| **Buying Guides** | Guides (`pgGuideList`), generator (`pgGuideGenerator`), preview (`pgGuidePreview`) | 🟡 | KPIs (guides, published, avg SEO, words), site tabs, guide cards (status, intro, tags, words vs target, SEO score). “New guide” builds a draft from topic, title, focus keyword, sites, tone, word target and the chosen structure (overview, benefits, sizing, installation, maintenance, products, FAQ); editor (title, address, intro, sections add / move / delete, SEO checks, category, tags, sites, publish / unpublish, delete); preview with contents list and SEO snippet. AI writing ⏳ (needs an Anthropic key in Config › Integrations) |
| **Discounts** | Discounts (`pgDiscountList`), editor (`pgDiscountEditor`) | ✅ | KPIs (active, scheduled, all, inactive), list (type badge, sites, categories, period, min order, state), pause / activate, editor (name, % or £, min order, dates, active, categories picker from the old catalogue, sites), delete. Uses / revenue not shown: orders do not record which discount applied. Categories now from the catalogue (`discountables`; a top category covers its sub-categories) |
| **Promo Codes** | Promo codes (`pgPromoCodes`), editor (`pgPromoEditor`) | ✅ | List with uses (from orders.promo_code) vs max uses bar, paid revenue, expiry, sites, single / multi use, state, copy, pause; editor with Generate (8 chars, no 0/O/1/I), % / £ / free samples, min order, max uses, start / expiry, single use, min categories, categories / products, sites, notes; delete pauses a code that was used. Applies to: catalogue categories and a product picker (`discountables`) |
| **Website CMS** | Pages (`pgCMSList`), editor (`pgCMSEditor`) | ✅ | Site tabs, average SEO health, page cards (address, status, section icons, SEO score, edit / live), seasonal website theme (old sgt_banner_config), page editor (title, address kept exactly for live pages, site, rich text / HTML body, section builder: hero, text, image + text, products, CTA, testimonials, FAQ, gallery, video, banner, form — add / label / visible / move / delete, images from the library), SEO card with checks, publish / unpublish, delete. FAQs page (question, answer, show on About / How to / Delivery / Contact, order). Section rendering on the website is up to the website |
| **Config** | Config hub (`pgConfigHub`) | ✅ | Section cards (integrations show which are connected) |
| | Sections: collections, integrations, lead times, min order, notifications, order limits, quote validity, templates, watermark (`pgCfg*`) | ✅ | Lead times (days, amber / red per order type, override), order limit, minimum order, quote validity (now the New quote default), watermark (text, position, opacity, colour, shadow, live preview — used by gallery / library uploads), integrations (Anthropic, Microsoft 365, Twilio, Google Maps — stored encrypted, secrets never shown again, on / off, remove), notifications (email / SMS / staff per event), email / SMS templates with placeholders and reset (quote email now uses it), collections → Collections › Configuration |
| **Loyalty** | Trade applications / invitations / add tabs (`pgLoyalty*Tab`), application page (`pgLoyaltyDetail`) | ✅ | KPIs, applications (status filter, search, new flag, accept / decline), invitations (status, resend), individual invite + CSV upload (template download), application page (edit, history / notes, accept opens a loyalty account on the customer with that email or a new one). Customer Loyalty tab now editable: discount type / %, quantity discounts, credit limit (trade vs loyalty), terms, VAT, status, welcome email, account notes. **Trade prices:** per account on the customer's trade account tab: special price or % off per product, % off a whole category, add / update / remove, with the price the account pays worked out (special price → special % → product trade price → category % → account discount; lengths in proportion; suspended = web price). Product Pricing tab lists accounts with their own price. Quote builder search shows the chosen customer's trade prices |

**Pages: 25 done (+ quotes list, quote page with 5 tabs, new quote builder, customer quotes tab), 1 part done
(customer loyalty tab). Tests: 30. Earlier: 20 done (+ customers list, customer page). Before:
18 done (login + two-factor + password reset, dashboard, orders list, samples, abandoned, unused carts,
order page with 6 tabs + history, receipt, users list / new / edit, my account, roles), the rest pending.**

Automated tests: `docker exec st_manager_app php artisan test` (18 tests: sign-in, two-factor, lockout, password
reset, users, permission overrides, roles). They use a separate `st_manager_test` database.

## Database

| Migration file | Tables | Schema | Data import |
|---|---|---|---|
| `0001_01_01_000000_create_users_table` | roles, role_permissions, users, sessions, password_reset_tokens | ✅ | ✅ 13 staff (`legacy:import --only=staff`); local admin seeded |
| `2026_10_20_000001_add_security_and_profile_to_users` | users: photo, notes, sites, permission overrides, notification prefs, MFA, lockout, password age; login_codes | ✅ | n/a |
| `2026_10_16_100000_create_orders_tables` | orders, order_items, unused_carts | ✅ | ✅ 75,074 orders, 181,136 lines, 64,398 carts |
| `2026_10_17_000001_create_lookup_and_settings_tables` | countries, settings, integrations, message_templates | ✅ | ✅ settings: lead times, order limit, min order, quote validity (`--only=config`), seasonal theme (`--only=cms`). No credentials in the old database |
| `2026_10_17_000002_create_customers_tables` | customers, customer_addresses, customer_notes, mailing_list (+ `orders.customer_id`) | ✅ | ✅ 72,032 customers, 78,146 addresses, 2,440 mailing list, 245 countries; 73,898 orders linked (`--only=customers`, ≈35 s) |
| `2026_10_20_000002_add_profile_fields_to_customers` / `..._000003_add_order_stats_to_customers` | trade type, VAT, notes, welcome date, trade link; stored orders_count / total_spend / last_order_at | ✅ | filled by the import, kept current by `CustomerStats` when an order is saved |
| `2026_10_17_000003_create_catalogue_tables` | brands, categories, category_site, products, category_product, product_features, product_variants, product_colours, product_images, product_site, product_related, stock_movements, product_price_changes (+ `order_items.product_id`) + `2026_11_11_000015` (`weight_kg` names, category image, variant out-below level) | ✅ | ✅ `--only=catalogue` |
| `2026_10_17_000004_create_order_payments_and_activity_tables` | order_payments, activities (polymorphic timeline), pick fields on order_items | ✅ | ✅ 62,857 gateway records (634 Paysmart, 62,223 Sage Pay) |
| `2026_10_17_000005_create_quotes_tables` + `2026_10_21_000001_add_builder_fields_to_quotes` | quotes, quote_items, quote_emails (+ customer ref, PO, delivery / collection, postcode, discount %, notes on PDF, added_at) | ✅ | ✅ 21,853 quotes, 56,478 lines, 20,608 emails (`--only=quotes`, ≈12 s) |
| `2026_10_17_000006_create_collections_and_delivery_tables` | collection_slots, collection_bookings, collection_blocks, delivery_methods, delivery_zones, delivery_postcodes, couriers, vehicles, drivers, delivery_runs, delivery_run_stops (+ `orders.delivery_method_id`, `courier_id`) + `2026_10_21_000002_add_contact_fields_to_collection_bookings` | ✅ | Collections ✅ 10,045 bookings, 5 weekday slots, 21 day overrides, 825 blocks (`--only=collections`). Delivery pricing ✅ 5 methods, 69 rates, 2,872 outcodes (`--only=delivery`; `2026_11_11_000001` replaces delivery_zones with delivery_rates). Couriers ✅ (`2026_11_11_000002` adds account fields; nothing to import). Fleet ✅ (`2026_11_11_000003` adds vehicle / driver fields; new, no old data). Delivery planner ✅ (`2026_11_11_000004`; new, no old data) |
| `2026_10_17_000007_create_trade_tables` | trade_accounts, trade_contacts, trade_sites, trade_applications, trade_prices, trade_credit_entries (+ `orders.trade_account_id`) + `2026_11_11_000005` (trade_invites, review fields) | ✅ | ✅ 658 accounts + main contacts (passwords not imported), 627 account notes, 698 applications, 919 invitations, 1,731 orders linked (`--only=trade`). Sites / extra contacts / special prices ⏳ |
| `2026_10_17_000008_create_discounts_tables` | discounts, promo_codes, discountables + `2026_11_11_000006` (min order, single use, notes) + `2026_11_12_000002` (categories / products json → discountables) | ✅ | ✅ 4 discounts (2010, all off), 14 promo codes (`--only=discounts`) |
| `2026_10_17_000009_create_content_tables` | media_folders, media, pages, blog_posts, buying_guides, faqs, gallery_albums, gallery_items, banners + `2026_11_11_000007` (blog category) | ✅ | Blogs ✅ 134 posts (127 published) (`--only=blogs`). Gallery ✅ 22 albums, 536 album photos (`--only=gallery`; `2026_11_11_000008` upload fields). Image library ✅ (`2026_11_11_000009` watermark fields; new). CMS ✅ 8 pages, 25 FAQs, seasonal theme (`--only=cms`; `2026_11_11_000010` sections). Buying guides ✅ (`2026_11_11_000011`; new). Tasks ✅ 12 tasks + 40 notes (`--only=tasks`; `2026_11_11_000012` type). Pages, guides, FAQs, gallery, media ⏳ (+ copy image files from the live server) |
| `2026_10_17_000010_create_tasks_and_messages_tables` | tasks, task_user, task_comments, task_rules, documents, sms_messages, email_threads, email_messages, enquiries + `2026_11_11_000013` (SMS campaigns, recipients, contact lists) | ✅ | Tasks ✅ (`--only=tasks`). SMS: old message_sms was empty (new). Email ✅ (`2026_11_11_000014` sync fields); 80 website enquiries (`--only=enquiries`) |
| `2026_10_17_000011_create_accounts_tables` | nominal_accounts, suppliers, invoices, invoice_lines, journal_entries, journal_lines, bank_transactions, vat_returns | ✅ | n/a (new) |
| `2026_11_12_000001_create_stock_ordering_tables` | purchase_orders, purchase_order_lines; supplier ordering fields, products / variants reorder qty + supplier, stock_movements.purchase_order_id | ✅ | n/a (new) |

All migrations run on a fresh database and roll back cleanly. Each importer is added to
`legacy:import` when its module is built. Mapping old → new is in [DATABASE.md](DATABASE.md).

## Done (detail)

- Laravel 12 project with Docker (`app` on :8110, `mysql` 8.0 on :3320). OPcache is on for `artisan serve`
  (pages went from ~4 s to ~0.3 s on the Windows bind mount).
- Login at `/st_manager/auth/tl6hbosn4` (email **or** username + password, "keep me signed in",
  throttled to 10 attempts/minute, suspended users blocked). Logout from the user menu.
- Layout from the prototype: top bar (logo, avatar menu), sidebar with every module, role chip, prototype CSS.
  The prototype's role switcher is a demo tool, so the chip only shows the signed-in user's role.
- Roles and permissions: `roles` + `role_permissions` (role_id, module, level), `users.role_id`.
  Built-in Super Admin plus the prototype roles seeded by `RoleSeeder`. Middleware `module:<name>[,edit]`;
  sidebar hides modules a role cannot see.
- Structure matches `PROJECT_STRUCTURE.md`: `legacy:import` command + `Services/LegacyImport`
  (BaseImporter with cleaners, IdMap), `Support/Money`, `common/pagination`, shared `app.js`
  (toast, api, modals, dropdowns, tabs, confirm, inline edit, `data-save` fields, chips, row links,
  autosubmit), composer platform PHP 8.2, Pint.
- **Dashboard**: system status, today's collections, attention needed, email inbox, 8 KPI tiles, latest orders,
  quotes to chase, best sellers, Google Analytics, latest blog posts, SEO clusters, low stock, social posts,
  current offers. Reads `st_legacy` (`DashboardStats`, cached 5 min) until those modules are migrated.
- **Orders list**: Ref, Staff, Notes, Payment, Status and review ticks save on change (PATCH `orders/{order}`
  via `OrderFieldUpdater`; read-only without Orders edit permission). KPI cards, period tabs, website filter,
  search (order no, name, postcode, email, Encore ref, quote ref), CSV export, pagination, sidebar sub-items
  with counts.
- "Today" = `APP_TODAY` in `.env` (2026-07-20 while working on the backup; leave empty in production).
- Prototype copy for side-by-side checks: http://localhost:8110/prototype/index.html (local only, gitignored;
  run `AUTH_STATE.loggedIn=true;render()` in the console to skip its login).

## Next (suggested build order)

1. **Orders**: order page ✅, receipt ✅, new order ✅, quote → order ✅, collection book / reschedule from the order page ✅ (date + live free hours from the collections calendar, reason, overbook; moves the booking, keeps the order's collection date in step, logged on the order and the booking). Left: AI panels.
2. **Users & Roles** ✅. Before go-live: send each imported staff member their welcome email from their user page
   (they are "invited" until they set a password), and set real mail settings (`MAIL_*`) in production.
3. **Customers** ✅ (quotes / loyalty tabs finish with those modules).
   Dev environment: `vendor/` now lives in a Docker volume (was read through the slow Windows bind mount).
   Pages went from 1.5–4.5 s to 0.13–0.36 s. After changing composer.json run
   `docker compose run --rm --no-deps app composer install`.
4. **Categories / Products** ✅ (imported; 181,123 of 181,136 order lines linked to their product). **Stock control** ✅ (suppliers, reorder list, purchase orders). Discount targets and trade prices ✅.
5. **Quotes** ✅ incl. convert to order and the delivery calculator in the builder. Left: AI quote helpers.
   **Collections** ✅.
6. **Delivery pricing** ✅ (rates + calculator). **Couriers** ✅. **Fleet & Drivers** ✅. **Delivery planner** ✅ (no AI routing yet).
   **Loyalty** ✅. **Discounts / Promo codes** ✅. **Blogs** ✅. **Gallery** ✅. **Image library** ✅. **Website CMS** ✅. **Buying guides** ✅ (no AI yet). **Tasks** ✅. **Config** ✅. **SMS** ✅. **Email** ✅. **Reports** ✅ (no trends / stock yet). **Categories / Products** ✅. **Stock control** ✅. **Discount targets / trade prices** ✅. **New order / quote → order** ✅. **Blog / FAQ product pickers** ✅ (nothing reads the old catalogue any more). Next: **Accounts**, AI panels.
   The delivery calculator now fills the charge in the quote builder and new order.
7. **Loyalty (trade)** ✅ incl. trade prices. Left: the 10 site logins and 5 extra contacts per account.
8. **Discounts / Promo codes** ✅ (targets in `discountables`).
9. **Website CMS / Blogs / Buying guides / Gallery / Image library**: Blogs ✅, Gallery ✅, Image library ✅, Website CMS ✅, Buying guides ✅ (AI writing with Config › Integrations).
10. **Tasks** ✅ (no AI yet), **Config** ✅, **SMS** ✅ (needs Twilio + a cron for schedule:run), **Email** ✅ (needs Microsoft 365 for the Outlook inbox).
11. **Reports** ✅ (trends with AI, stock ordering with the catalogue), **Accounts**.

## Decisions

- **Order numbers:** orders made in the CRM continue the old numbering (`orders.id`, SGT 79556 onwards). At go-live, load the final copy of the old orders before anyone creates an order here, otherwise the old ids would clash.

- Admin URLs keep the live site's `/st_manager` prefix and login path, set in `config/st-manager.php`.
- The old database stays as a separate `st_legacy` database and is only read. Data is copied into the
  new schema by `legacy:import` importers, one per domain.
- Order numbers are kept: `orders.id` = old order id.
- Card numbers in the old `cards` / `orders` tables are **not** migrated (they are empty anyway).
- Old plain-text trade passwords and MD5 staff passwords are **not** imported; users set new ones.
- The dump files and the prototype are kept **outside** the repository (personal data).
