2a10f9af38
**Shiplogic API Integration:**
- Fixed API base URL configuration (removed /api suffix)
- Implemented comprehensive request/response logging for rates and shipments endpoints
- Fixed PDF fetching: API returns S3 URLs, now downloads actual PDFs from S3
- Added tests and mock API responses for local development (routes/shiplogic-mock.php)
**Courier Service Enhancements:**
- Added redownloadShipmentPdfs() public method for re-downloading corrupted PDFs
- Enhanced error logging with full request/response bodies for debugging
- Proper binary PDF storage using Laravel Storage facade
- URL and S3 download handling for Shiplogic API responses
**Workflow & Operations:**
- Changed to manual "Ready for Collection" button instead of automatic move
- Operators now: scan QR → apply labels → click "Ready for Collection" → moves to Awaiting Collection
- Removed duplicate PDF attachments to Trello (was adding twice from two listeners)
- Fixed NotifySlackOnShipmentCreated to only handle Slack notifications
**Mobile-Optimized Ops Page:**
- Removed QR code display from order detail page
- Implemented responsive single-column layout for mobile phones
- Large touch-friendly buttons (full width, increased padding)
- Bold typography for better readability on small screens
- Larger input fields and tracking number displays
- Clear step-by-step instructions for warehouse operators
- Re-download PDF button for damaged/corrupted labels
**New Features:**
- POST /ops/orders/{uuid}/ready-for-collection endpoint
- Re-download PDFs functionality accessible from awaiting_collection and in_transit states
- Full audit logging for all operations via ops interface
- Proper error handling and user feedback
**Testing:**
- Added ShipmentCreationTest with mock HTTP client
- Created comprehensive testing guide (SHIPLOGIC_TESTING.md)
- Mock API routes for local development without hitting live API
98 lines
3.1 KiB
PHP
98 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Events\OrderPacked;
|
|
use App\Models\Order;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class PackingController extends Controller
|
|
{
|
|
/**
|
|
* Confirm order packing with dimensions and weight
|
|
*
|
|
* POST /orders/{id}/pack
|
|
* POST /custom-orders/{id}/pack
|
|
*/
|
|
public function confirmPacked(Request $request, Order $order)
|
|
{
|
|
// Validate packing input
|
|
$validated = $request->validate([
|
|
'width' => 'required|numeric|min:0.01',
|
|
'length' => 'required|numeric|min:0.01',
|
|
'weight' => 'required|numeric|min:0.01',
|
|
]);
|
|
|
|
// Check: Order must exist and not already be packed
|
|
if (! $order) {
|
|
return response()->json(['error' => 'Order not found'], 404);
|
|
}
|
|
|
|
if ($order->packing_completed_at !== null) {
|
|
return response()->json(['error' => 'Order already packed'], 409);
|
|
}
|
|
|
|
// Check: Order must be in Inspection state
|
|
if ($order->status !== 'inspection') {
|
|
return response()->json([
|
|
'error' => 'Order must be in Inspection state before packing',
|
|
'current_status' => $order->status,
|
|
], 409);
|
|
}
|
|
|
|
try {
|
|
// Save packing data
|
|
$order->update([
|
|
'packing_width' => $validated['width'],
|
|
'packing_length' => $validated['length'],
|
|
'packing_height' => $validated['height'],
|
|
'packing_weight' => $validated['weight'],
|
|
'packing_completed_at' => now(),
|
|
'packed_by' => Auth::id(),
|
|
'status' => 'packing',
|
|
]);
|
|
|
|
Log::info('Order packed', [
|
|
'order_id' => $order->id,
|
|
'width' => $validated['width'],
|
|
'length' => $validated['length'],
|
|
'weight' => $validated['weight'],
|
|
'packed_by' => Auth::id(),
|
|
]);
|
|
|
|
// Emit event to trigger Trello update, Slack notification
|
|
OrderPacked::dispatch(
|
|
$order,
|
|
(float) $validated['width'],
|
|
(float) $validated['length'],
|
|
(float) $validated['weight'],
|
|
Auth::id(),
|
|
);
|
|
|
|
return response()->json([
|
|
'success' => true,
|
|
'message' => 'Order packed successfully',
|
|
'order_id' => $order->id,
|
|
'packing_completed_at' => $order->packing_completed_at,
|
|
'dimensions' => [
|
|
'width' => $validated['width'],
|
|
'length' => $validated['length'],
|
|
'weight' => $validated['weight'],
|
|
],
|
|
]);
|
|
} catch (\Exception $e) {
|
|
Log::error('Error packing order', [
|
|
'order_id' => $order->id,
|
|
'error' => $e->getMessage(),
|
|
]);
|
|
|
|
return response()->json([
|
|
'error' => 'Failed to pack order',
|
|
'message' => $e->getMessage(),
|
|
], 500);
|
|
}
|
|
}
|
|
}
|