Commit graph

67 commits

Author SHA1 Message Date
John Mizerek
d73c4d60d3 Fix CFML iteration bugs and improve wizard functionality
- Fix for...in loops on query results in getForBuilder.cfm (only iterated once)
- Remove illegal var keyword from loop variables in saveWizard.cfm
- Only create food running tasks for dine-in orders (skip takeaway/delivery)
- Add image preview modal for modifier source images in wizard
- Add data clearing utilities (clearAllData, clearOrders)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 19:40:37 -08:00
John Mizerek
3384f128e1 Fix task acceptance incorrectly marking orders as delivered
When accepting a task, the order status was being set to 4 (Delivery in progress),
which caused the order to disappear from KDS and broke auto-complete functionality.

The correct flow is:
- Order at status 3 (Ready) → Worker accepts task → Order stays at 3
- Worker completes task → Order moves to status 5 (Delivered)

Removed the order status update from accept.cfm so orders remain visible in KDS
until the delivery task is actually completed.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-16 09:55:45 -08:00
John Mizerek
ef6efa0762 Filter default modifiers from KDS display
Only show customized modifiers on the Kitchen Display System,
hiding default/unaltered selections to reduce clutter.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-16 00:29:53 -08:00
John Mizerek
fe383f40d0 Fix wizard flow and add detailed modifier view
Major Changes:
1. Fixed infinite loop in wizard flow - uncertain modifiers step now correctly advances to final review instead of looping back to items
2. Moved uncertain modifier assignment to AFTER items review (makes more sense for user to see items first)
3. Added detailed modifier visualization on uncertain modifiers step showing:
   - Source image indicator (which image the modifier was extracted from)
   - Full list of all options with prices
   - Required/optional status
   - Option count summary

Technical Details:
- Backend: Added sourceImageIndex tracking in analyzeMenuImages.cfm to record which image each modifier came from
- Frontend: Enhanced uncertain modifiers step with inline detailed view showing complete modifier structure
- Flow correction: showUncertainModifiersStep() now calls showFinalStep() instead of showItemsStep() to prevent loop
- Improved error handling in API calls with detailed error messages from Claude API

Flow Changes:
- Old: Upload → Business → Categories → Modifiers → Uncertain Modifiers → Items → [LOOP]
- New: Upload → Business → Categories → Modifiers → Items → Uncertain Modifiers → Final Review

Model Configuration:
- Using claude-sonnet-4-20250514 for menu image analysis
- Added better error reporting to surface API issues (auth, credits, etc.)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-15 16:53:09 -08:00
John Mizerek
8999805ec6 Add detailed modifier view with source tracking
Backend (analyzeMenuImages.cfm):
- Track which image each modifier was found on via sourceImageIndex
- Changed loop to use index to capture image number

Frontend (setup-wizard.html):
- Show detailed modifier information in expandable cards
- Display source image number for each modifier
- Show appliesTo status (category/uncertain) with badges
- Display all modifier options with prices in detail view
- Click modifier header to expand/collapse full option list
- Added comprehensive CSS for new modifier display:
  * Expandable card design with hover effects
  * Color-coded badges for source image, category assignment
  * Detailed option list with prices
  * Visual distinction for uncertain modifiers

Users can now:
- See which image each modifier came from
- View complete option list before confirming
- Understand how each modifier will be applied
- Make informed decisions about which modifiers to keep

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-15 16:02:03 -08:00
John Mizerek
0f36874435 Move uncertain modifier assignment step after items review
Changed wizard flow so uncertain modifiers are presented AFTER user
has reviewed all items, not before. This makes more sense because:
- User can see what items exist before deciding modifier assignments
- User understands their menu structure before making decisions
- More informed decisions about which categories need which modifiers

New flow:
1. Business info
2. Categories
3. Modifiers (select which to keep)
4. Items (review and select)
5. Uncertain modifiers (assign to categories) <- moved here
6. Final review and save

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-15 15:31:09 -08:00
John Mizerek
9e195b79e0 Add conversational modifier assignment for uncertain modifiers
Backend (analyzeMenuImages.cfm):
- Updated AI prompts to classify modifiers by confidence level
- Added appliesTo field: 'category', 'item', or 'uncertain'
- Added categoryName field for category-level modifiers
- Auto-assign category-level modifiers to items in that category
- Only assign item-level modifiers when clearly in item description
- Mark uncertain modifiers for user confirmation

Frontend (setup-wizard.html):
- Added showUncertainModifiersStep() between modifier and item steps
- Shows conversational prompts for each uncertain modifier
- Users can select which categories each modifier applies to
- Users can skip modifiers that don't apply automatically
- Applies user selections to items before proceeding
- Added CSS styling for category selection checkboxes

Flow:
1. AI extracts modifiers with confidence classification
2. Category-level modifiers auto-assigned to items
3. Uncertain modifiers presented one-by-one for user decision
4. User confirms or skips each uncertain modifier
5. Assignments applied to items before save

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-15 15:29:15 -08:00
John Mizerek
0d2634e6c4 Update AI prompts to intelligently assign modifiers to items
- Instructs Claude to look for modifiers in specific menu locations:
  category headers, item descriptions, asterisk notes, headers/footers
- Assigns modifiers to items when confident about relationships
- Only links obvious modifier-to-item connections
- Leaves uncertain relationships unlinked for manual assignment

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-15 15:25:23 -08:00
John Mizerek
a4fb7e7503 Show all templates in menu builder regardless of links
- Changed template query to find ALL templates for business (ItemCategoryID=0, ItemParentItemID=0)
- Previously only showed templates that were in ItemTemplateLinks
- Now shows all templates so they can be viewed and manually assigned to items
- Template children query also updated to include children of all templates

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-15 15:17:08 -08:00
John Mizerek
d34d88e46a Fix wizard: remove CategoryID column ref, add analysis time message
- Fixed Items table INSERT to remove CategoryID column (only exists in Categories table)
- Templates now correctly use ItemCategoryID=0 instead of incorrect CategoryID
- Added user message that analysis may take several minutes
- Updated localStorage with new businessId after save to keep user logged in
- Redirect to visual menu builder with new businessId in URL

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-15 15:08:53 -08:00
John Mizerek
261bab2bb6 Improve address deduplication and delete matching duplicates
- list.cfm: Use GROUP BY to show unique addresses only, removed
  BusinessID filter, simplified aggregation for better MySQL compat
- delete.cfm: Delete ALL addresses matching the same address content
  (Line1, Line2, City, State, ZIP) to keep data clean when user
  deletes a deduplicated address

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 23:11:28 -08:00
John Mizerek
b069290862 Improve menu image analysis - fix JSON error handling
Replaced inline string concatenation with proper struct serialization
for error messages in Claude API calls to avoid JSON escaping issues.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 23:08:35 -08:00
John Mizerek
307c443f56 Add addresses debug endpoint 2026-01-14 22:28:16 -08:00
John Mizerek
f98eaa4ba1 Fix null date handling in order history API
Safely handle null/empty OrderAddedOn and OrderLastEditedOn fields
that were causing server errors when formatting dates.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 21:36:18 -08:00
John Mizerek
4c06040f41 Fix OrderLineItemIsDeleted BIT comparison, add debug info 2026-01-14 21:12:57 -08:00
John Mizerek
2dcafbbc59 Add setup wizard endpoints to public allowlist 2026-01-14 16:08:39 -08:00
John Mizerek
8d5c0cc6ac Add menu setup wizard with Claude Vision integration
- New setup-wizard.html: conversational wizard for uploading menu images
- analyzeMenuImages.cfm: sends images to Claude API, returns structured menu data
- saveWizard.cfm: saves extracted menu to database (categories, items, modifiers)
- Added Setup Wizard button to portal Menu page
- Added .gitignore for config files with secrets

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 16:02:21 -08:00
John Mizerek
3d61d883a2 Update cleanup script to handle children 2026-01-14 13:32:38 -08:00
John Mizerek
e628443c02 Add admin script to cleanup orphan items 2026-01-14 13:31:18 -08:00
John Mizerek
f40d5c1f93 Fix modifier move: use Shift key and dataTransfer data instead of effectAllowed 2026-01-14 12:57:34 -08:00
John Mizerek
ff6e4f2a36 Fix missing closing brace in item drag handler 2026-01-14 12:52:46 -08:00
John Mizerek
b6c1569add Fix syntax error in item card onclick handler 2026-01-14 12:39:30 -08:00
John Mizerek
85510a7647 Fix template loading state stuck on 'Loading templates...' 2026-01-14 12:27:40 -08:00
John Mizerek
fb329727d2 Add drag-and-drop for modifiers at all levels
- Modifiers can be dragged and dropped to reorder within same parent
- Modifiers can be dropped on other modifiers (same or different parent)
- Modifiers can be dropped on items to add as top-level modifier
- Default action is COPY (drag creates a copy)
- Hold Ctrl+Alt while dragging to MOVE instead of copy
- Deep cloning preserves nested options with new IDs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 12:15:44 -08:00
John Mizerek
12b47c3e41 Add accordion behavior to menu builder for all levels
- Categories: Only one category expanded at a time
- Items: Click item to expand/collapse modifiers
- Modifiers: Click modifier with sub-options to expand/collapse nested options
- Clicking a new parent auto-collapses siblings at that level

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 11:40:52 -08:00
John Mizerek
a6259bccb0 Revert deduplication hack - root cause fixed in app
The duplicate modifiers were caused by the app creating nested groups.
That's now fixed, so we can remove the deduplication workaround.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 22:52:12 -08:00
John Mizerek
f6c3729874 Deduplicate modifiers in KDS display
Prevents showing the same modifier twice when data has duplicates.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 22:45:55 -08:00
John Mizerek
70781ab75e Show Takeaway/Delivery instead of Table name in KDS
- Updated listForKDS.cfm to include OrderTypeName in response
- Added getLocationLabel/getLocationValue helpers in kds.js
- Takeaway orders now show "Type: Takeaway"
- Delivery orders now show "Type: Delivery"
- Dine-in orders continue to show "Table: [name]"

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 22:38:33 -08:00
John Mizerek
f919ef1cfe Add chat expiration and order management improvements
- Auto-expire stale chats older than 20 minutes in createChat.cfm
- Add expireStaleChats.cfm for scheduled cleanup
- Add abandonOrder.cfm for Start Fresh functionality
- Add closeAllChats action to debugTasks.cfm
- Fix setOrderType NULL value for non-delivery orders
- Add ForceNew parameter to setLineItem for customized items
- Add public endpoint allowlist entries for new endpoints

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 19:46:39 -08:00
John Mizerek
f7df6b614c Include delivery fee in payment calculation
createPaymentIntent.cfm now fetches the order's delivery fee
and includes it in the total amount charged to the customer.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 11:06:27 -08:00
John Mizerek
bd1e4110f6 Remove debug logging with Windows paths
The fileAppend calls were using Windows paths which fail on the
Linux production server.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 19:32:06 -08:00
John Mizerek
fc371dca3d Add item names to setLineItem response
loadCartPayload now includes ItemName, ItemParentName, and
ItemIsCheckedByDefault so the cart displays proper breadcrumbs
immediately after adding items.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 19:12:33 -08:00
John Mizerek
9136ef56a9 Add item names and parent names to cart API response
getCart.cfm now returns ItemName, ItemParentName, and
ItemIsCheckedByDefault for each line item, enabling the
Flutter app to display modifier breadcrumbs like
"Select Drink: Coke" without needing a separate menu lookup.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 19:06:39 -08:00
John Mizerek
0a10380639 Add template modifier support and fix KDS breadcrumbs
- setLineItem.cfm: Attach default children from ItemTemplateLinks
  (fixes drink choices not being saved for combos)
- listForKDS.cfm: Include ItemParentName for modifier categories
- kds.js: Display modifiers as "Category: Selection" format
- Various other accumulated fixes for menu builder, orders, and admin

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 18:45:06 -08:00
John Mizerek
e20aede25f Fix KDS to show all selected modifiers including defaults
Previously the KDS was skipping modifiers marked as "checked by default",
but for exclusive selection groups (like drink choices) the customer's
actual selection should always be visible to the kitchen.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 18:09:54 -08:00
John Mizerek
ccb27f679f Show EmployeeStatusID status instead of IsActive flag
- Display Pending/Invited/Active/Suspended from EmployeeStatusID
- Add CSS for pending and suspended status badges
- Update getStatusClass to handle employee status codes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 18:01:30 -08:00
John Mizerek
0b17d35b31 Add active/inactive status badge CSS styles
- Green background for active employees
- Red background for inactive employees

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 17:59:56 -08:00
John Mizerek
b8e85f3f11 Add debugEmployees to allowlist 2026-01-11 17:59:03 -08:00
John Mizerek
21dcb19ec4 Add debug endpoint for employee data 2026-01-11 17:58:31 -08:00
John Mizerek
245a37aeab Fix IsActive bit field comparison in team API
Cast BIT(1) to UNSIGNED INT in SQL and use val() for comparison
to correctly handle MySQL bit fields in ColdFusion/Lucee.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 17:39:48 -08:00
John Mizerek
e586a62a95 Add phone column to team table, add duplicate cleanup script
- Replace Role column with Phone column in team table
- Add formatPhone() helper to format phone numbers nicely
- Add cleanupDuplicateEmployees.cfm admin script to remove duplicates

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 17:32:07 -08:00
John Mizerek
b9f5eb834f Add hiring toggle functionality to portal Team page
- Add setHiring.cfm API endpoint to update BusinessIsHiring
- Add endpoint to Application.cfm allowlist
- Update portal.js to load and sync hiring toggle state
- Wire toggle to call API and show feedback toasts
- Bump portal.js version for cache busting

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 17:13:59 -08:00
John Mizerek
aa80dab890 Add IsHiring field to business get response
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 17:12:02 -08:00
John Mizerek
8de677ad9e Add debug logging to team loading 2026-01-11 17:08:58 -08:00
John Mizerek
4fdb7fca94 Implement team loading in portal
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 17:06:37 -08:00
John Mizerek
8092384702 Add team endpoint and chat features for portal
- Add /api/portal/team.cfm for employee listing
- Add chat endpoints (getMessages, sendMessage, markRead, getActiveChat)
- Add OTP authentication endpoints
- Add address management endpoints (delete, setDefault, states)
- Add task completion and chat task endpoints
- Update Application.cfm allowlist

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 17:03:55 -08:00
John Mizerek
d8d7efe056 Add user account APIs and fix Lucee header handling
- Add avatar.cfm: GET/POST for user profile photos with multi-extension support
- Add profile.cfm: GET/POST for user profile (name, email, phone)
- Add history.cfm: Order history endpoint with pagination
- Add addresses/list.cfm and add.cfm: Delivery address management
- Add setOrderType.cfm: Set delivery/takeaway type on orders
- Add checkToken.cfm: Debug endpoint for token validation
- Fix headerValue() in Application.cfm to use servlet request object
  (Lucee CGI scope doesn't expose custom HTTP headers like X-User-Token)
- Update public allowlist for new endpoints
- Add privacy.html page

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 20:01:07 -08:00
John Mizerek
e757a4140b Add drink modifiers, unified schema improvements, and portal fixes
Menu System:
- Unified schema with Categories table integration
- Virtual category headers with proper parent ID remapping
- Filter out legacy category headers when using new schema
- Add drink modifier endpoints for Fountain Soda (Size/Flavor)

Admin Tools:
- addDrinkModifiers.cfm - Add size/flavor modifiers to drinks
- copyDrinksToBigDeans.cfm - Copy drink items between businesses
- debugDrinkStructure.cfm - Debug drink item hierarchy

Portal:
- Station assignment improvements with better drag-drop
- Enhanced debug task viewer

API Fixes:
- Application.cfm updated with new admin endpoint allowlist
- setLineItem.cfm formatting cleanup
- listMine.cfm task query fixes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 20:30:58 -08:00
John Mizerek
634148f727 Add Categories table support, KDS station selection, and portal fixes
Categories Migration:
- Add ItemCategoryID column to Items table (api/admin/addItemCategoryColumn.cfm)
- Migration script to populate Categories from unified schema (api/admin/migrateToCategories.cfm)
- Updated items.cfm and getForBuilder.cfm to use Categories table with fallback

KDS Station Selection:
- KDS now prompts for station selection on load (Kitchen, Bar, or All Stations)
- Station filter persists in localStorage
- Updated listForKDS.cfm to filter orders by station
- Simplified KDS UI with station badge in header

Portal Improvements:
- Fixed drag-and-drop in station assignment (proper event propagation)
- Fixed Back button links to use BASE_PATH for local development
- Added console logging for debugging station assignment
- Order detail API now calculates Subtotal, Tax, Tip, Total properly

Admin Tools:
- setupBigDeansStations.cfm - Create Kitchen and Bar stations for Big Dean's

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 15:31:45 -08:00
John Mizerek
ec81af5cdd Add business info, order details, beacon management, and admin tools
API Improvements:
- api/businesses/get.cfm: Fetch address from Addresses table, hours from Hours table
- api/tasks/getDetails.cfm: Add CustomerPhone field from UserContactNumber
- api/orders/getDetail.cfm: New endpoint for order details with line items
- api/Application.cfm: Add new admin endpoints to public allowlist

Admin Tools:
- api/admin/beaconStatus.cfm: View all beacon-to-business mappings
- api/admin/updateBeaconMapping.cfm: Change beacon business assignment
- api/admin/setupBigDeansInfo.cfm: Set Big Dean's address and hours
- api/admin/listTables.cfm: List all database tables
- api/admin/describeTable.cfm: Get table structure and sample data
- api/admin/randomizePrices.cfm: Randomize item prices for testing
- Various Big Dean's debug/update scripts

Portal Enhancements:
- Enhanced CSS styling for portal pages
- Improved portal.js functionality

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 11:45:21 -08:00