# Repair Order Status Workflow (6-Status System) Introduced June 2026. Replaced the original 4-status system (in-progress, waiting-for-parts, completed, waiting-for-pickup). ## Statuses and Display Colors | Status | Label | Color | Badge Class | |--------|-------|-------|-------------| | `diagnosing` | DIAGNOSING | amber-100/800 | `bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200` | | `in-progress` | IN PROGRESS | green | `bg-green-100 text-green-800` | | `waiting-for-approval` | WAITING APPROVAL | rose | `bg-rose-100 text-rose-800` | | `waiting-for-parts` | WAITING FOR PARTS | orange | `bg-orange-100 text-orange-800` | | `waiting-for-pickup` | WAITING FOR PICK-UP | blue | `bg-blue-100 text-blue-800` | | `completed` | COMPLETED | purple | `bg-purple-100 text-purple-800` | ## Sorting Priority (renderRepairOrders) ``` diagnosing: 0, in-progress: 1, waiting-for-approval: 2, waiting-for-pickup: 3, waiting-for-parts: 4, completed: 5 ``` New ROs default to `diagnosing`. ## Segmented Control Status Modal `openWorkStatusModal()` in `repair-orders.js` renders a 2-column × 3-row grid of pill buttons (replacing the old vertical list). - Active status is highlighted with ring-2 + colored border - Hover shows subtle bg-gray-50 - **Parts Info Section**: when `waiting-for-parts` is the active or selected status, an inline form appears showing vendor/ETA fields. Pre-populated from `ro.partsInfo`. - **Completed → Financial**: clicking "Completed" closes the status modal and opens `openFinancialSummaryModal(roId, 'completed')` directly — no intermediate confirmation dialog. - **Parts-Leaving Warning**: changing FROM `waiting-for-parts` to any other status shows a "Parts Received?" confirmation before proceeding. ## Status History Tracking Every status change pushes an entry to `ro.statusHistory[]`: ```js { from: oldWorkStatus || 'none', to: newWorkStatus, timestamp: new Date().toISOString() } ``` Synced to PocketBase as part of `updateData` / `createData` in `updateRepairOrderWorkStatus()`. A collapsible "Status History" section in the edit modal (`openEditModal()`) displays the timeline: ``` ● Completed — Jun 23 14:32 ● Waiting Pick-Up — Jun 22 09:15 ● In Progress — Jun 22 08:00 ● Diagnosing — Jun 21 16:45 ``` ## Parts Info (waiting-for-parts) Stored as `ro.partsInfo = { vendor: string, eta: string }`. - Captured from the inline form in the work status modal - Displayed in the RO card when status is `waiting-for-parts` - Synced to Firebase with every status update ## Pickup Tracking (waiting-for-pickup) - `ro.pickupSetAt` timestamp saved when status changes to `waiting-for-pickup` - RO card shows elapsed waiting time with color coding: - < 1 day: green "Just ready" - 1-3 days: yellow "2d waiting" - 3+ days: red "3d waiting" (semibold) - Time-until-due field shows blue **"READY FOR PICKUP"** text instead of "OVERDUE" — regardless of whether the promised time has passed - Copy Pickup SMS button was REMOVED (June 2026) ## Financial Modal on Completion When completing from the status modal, `openFinancialSummaryModal(roId, 'completed')` shows: - A purple notice: "Marking RO #XXX as completed. Enter financial details below and click 'Save & Complete'." - Pre-populated CP fields parsed from services string (extracts dollar amounts, estimates from service line count) - LocalStorage saves/loads last-used labor rate (`shopProQuote_financialRates` key) - On save, status history is updated with the completed transition - Works as both completion AND editing flow (the `context` parameter controls appearance only) ## Dashboard Widget Counts `dashboard.js` → `updateDashboardStats()` now counts: - `parts-on-order-count`: ROs with `workStatus === 'waiting-for-parts'` - `ready-for-pickup-count`: ROs with `workStatus === 'waiting-for-pickup'` - Breakdown text updated dynamically ## Edit Modal Updates The `#edit-work-status` dropdown in `repair-orders.html` includes all 6 statuses. The `#status-history-section` collapsible timeline is rendered when `openEditModal()` finds `ro.statusHistory` entries. ## Customer Notes (per-customer, across ROs) Introduced June 2026. Notes are tied to the customer (by phone number), not the RO — they persist across different repair orders for the same customer. **Storage**: `localStorage` keyed by `cust_notes_{phone}` (phone digits only). Full text string. **UI**: - "Customer Notes" button in each RO card's three-dot dropdown menu (teal icon, between Invoice Lines and Delete) - Opens a modal showing customer name/phone, a textarea with existing notes, Cancel/Save - If notes exist for that customer, a small teal checkmark badge appears next to the customer name on EVERY RO card for that customer **Key code**: `openCustomerNotesModal(roId)` in `repair-orders.js`. Triggered by `.customer-notes-btn` in `handleROMenuClicks`. ## Due Time Modal Clicking the due date/time on any RO card opens `openDueTimeModal(roId)` with two options: 1. **Set exact date/time**: `datetime-local` input pre-filled with current due, "Set Due Time" button 2. **Add hours**: number input (default 1, min 1, max 168) + "Add Hours" button — pushes the due out by that many hours from current Both options call `updateDueTime(roId, newISO)` which: - Updates `repairOrders[].promisedTime` locally - Syncs to PocketBase via `updateDoc()` - Re-renders the active orders list - Shows success notification **Due date format** (`formatDueDate`) now includes clock time: "Today 3:15 PM", "Tomorrow 10:30 AM", "Wed 2:00 PM", "Jun 28 11:00 AM". The "Due: " prefix was removed. | Feature | File | Function | |---------|------|----------| | Status modal + segmented control | `repair-orders.js` | `openWorkStatusModal()` | | Status update + history tracking | `repair-orders.js` | `updateRepairOrderWorkStatus()` | | RO card rendering | `repair-orders.js` | `createROHTML()` | | Edit modal status history | `repair-orders.js` | `openEditModal()` | | Financial modal (completion) | `repair-orders.js` | `openFinancialSummaryModal()`, `handleFinancialCompletion()` | | Dashboard widget counts | `dashboard.js` | `updateDashboardStats()` | | Due time modal | `repair-orders.js` | `openDueTimeModal()`, `updateDueTime()` | | Customer notes modal | `repair-orders.js` | `openCustomerNotesModal()` | | Due date formatting (with time) | `repair-orders.js` | `formatDueDate()` | | Status modal HTML (segments, parts) | `repair-orders.js` | Generated in `openWorkStatusModal()` | | Status history list HTML | `repair-orders.html` | `#status-history-section` |