Problem: When viewing orders page, console showed repeated "Failed to load resource: 400 (Bad Request)" errors for get_order_history.php?order_id=7
Root Cause:
- Authorization check in
get_order_history.phpwas too strict - Failed when
tailor_idwas NULL (unassigned orders) - Line 81:
if ($user_type === 'tailor' && $orderData['tailor_id'] != $user_id)
Solution:
- Updated authorization logic to allow tailors to view unassigned orders
- New logic: Tailors can view orders assigned to them OR unassigned orders (tailor_id = NULL)
- Only blocks if order is assigned to a different tailor
File Changed: api/orders/get_order_history.php (Lines 68-87)
Problem: User asked "how that measurements can be seen by tailor" - unclear how tailors access customer's saved measurements
Root Cause:
- API endpoint exists (
get_measurements.phpwithcustomer_idparameter) - But NO UI button/link in tailor order modal to access it
- Tailors could only see
measurements_snapshotembedded in order - No way to view customer's full measurement history
Solution:
- Added "View All Saved Measurements" button in tailor order modal
- Button appears:
- If measurements_snapshot exists: Below the snapshot display
- If no snapshot: Shows message with button to view saved measurements
- Clicking button opens new modal showing:
- All customer's saved measurements
- Default badges
- Garment context labels
- Formatted display with all measurement fields
- Creation timestamps
Files Changed:
assets/js/tailor-order-enhancements.js(Lines 123-135, added viewCustomerMeasurements() function)- Added new function:
viewCustomerMeasurements(customerId, customerName) - Added new function:
closeCustomerMeasurementsModal()
- Save measurements at
customer/measurements.php - Create order (measurements captured as snapshot)
- View order details → see measurements timeline
- Open order details
- See "Customer Measurements (Order Snapshot)" section
- Shows measurements as they were when order was placed
- Click "View All Saved Measurements" button
- New modal opens showing:
- All measurements customer has saved
- Which ones are default
- Comparison with order snapshot
- Full measurement history
- Captured when order is placed
- Immutable (won't change if customer updates measurements)
- Always available in order details
- Customer's measurement library
- Can be updated anytime
- Tailor can view via "View All Saved Measurements" button
- Useful for:
- Checking if customer has newer measurements
- Comparing different measurement sets
- Reference for alterations
Before: Failed if tailor_id was NULL
if ($user_type === 'tailor' && $orderData['tailor_id'] != $user_id)After: Allows unassigned orders
if ($user_type === 'tailor' && !empty($orderData['tailor_id']) && $orderData['tailor_id'] != $user_id)- Customers: See only their own measurements
- Tailors: Can query with
customer_idparameter (checks authorization)
-
api/orders/get_order_history.php
- Fixed authorization check for tailors
- Now allows viewing unassigned orders
-
assets/js/tailor-order-enhancements.js
- Added "View All Saved Measurements" button
- Added
viewCustomerMeasurements()function - Added
closeCustomerMeasurementsModal()function - Enhanced measurements display section
-
MEASUREMENTS_GUIDE.md (NEW)
- Complete documentation
- Usage guide for customers and tailors
- API reference
- Troubleshooting section
- Refresh the orders page - 400 errors should be gone
- Click "View Details" on any order - should load successfully
- As tailor, open order details - see "View All Saved Measurements" button
- Click the button - modal opens with customer's measurement history
- 400 Bad Request errors fixed
- Tailor measurement viewing implemented
- Authorization logic corrected
- Documentation created
- All PHP files syntax checked (0 errors)
Date: 2024 System: Smart Tailoring Management System