Files
Additional/app/Providers/EventServiceProvider.php
T
twotalesanimation 2a10f9af38 feat: Complete Shiplogic integration with mobile-optimized ops workflow
**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
2026-01-03 16:13:20 +02:00

157 lines
4.8 KiB
PHP

<?php
namespace App\Providers;
use App\Events\BalancePaid;
use App\Events\DepositPaid;
use App\Events\InspectionPassed;
use App\Events\InspectionFailed;
use App\Events\OrderCreated;
use App\Events\OrderMovedToPrep;
use App\Events\OrderMovedToAwaitingApproval;
use App\Events\OrderMovedToReadyForPrint;
use App\Events\OrderMovedToPrinting;
use App\Events\OrderMovedToInspection;
use App\Events\OrderPacked;
use App\Events\ParcelCollected;
use App\Events\ParcelDelivered;
use App\Events\ParcelFailedDelivery;
use App\Events\ParcelInTransit;
use App\Events\ProofApproved;
use App\Events\ProofRevisionRequested;
use App\Events\ProofUploaded;
use App\Events\ReadyToShipIntent;
use App\Events\ShipmentCreated;
use App\Events\ShipmentCreationFailed;
use App\Listeners\CreateShipmentOnReadyToShip;
use App\Listeners\GenerateQrCodeOnOrderCreated;
use App\Listeners\MoveCardToPackingOnInspectionPassed;
use App\Listeners\NotifySlackOnOrderCreated;
use App\Listeners\NotifySlackOnOrderMovedToPrep;
use App\Listeners\NotifySlackOnOrderMovedToAwaitingApproval;
use App\Listeners\NotifySlackOnOrderMovedToReadyForPrint;
use App\Listeners\NotifySlackOnOrderMovedToPrinting;
use App\Listeners\NotifySlackOnOrderPacked;
use App\Listeners\NotifySlackOnParcelCollected;
use App\Listeners\NotifySlackOnParcelDelivered;
use App\Listeners\NotifySlackOnParcelFailedDelivery;
use App\Listeners\NotifySlackOnShipmentCreated;
use App\Listeners\NotifySlackOnShipmentCreationFailed;
use App\Listeners\NotifySlackOnInspectionPassed;
use App\Listeners\NotifySlackOnInspectionFailed;
use App\Listeners\NotifySlackOnCardMovedToInspection;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
* The event to listener mappings for the application.
*
* @var array<class-string, array<int, class-string>>
*/
protected $listen = [
// Order events
OrderCreated::class => [
NotifySlackOnOrderCreated::class,
GenerateQrCodeOnOrderCreated::class,
],
// Trello card move events
OrderMovedToPrep::class => [
NotifySlackOnOrderMovedToPrep::class,
],
OrderMovedToAwaitingApproval::class => [
NotifySlackOnOrderMovedToAwaitingApproval::class,
],
OrderMovedToReadyForPrint::class => [
NotifySlackOnOrderMovedToReadyForPrint::class,
],
OrderMovedToPrinting::class => [
NotifySlackOnOrderMovedToPrinting::class,
],
// Packing events
OrderPacked::class => [
NotifySlackOnOrderPacked::class,
],
// Inspection events
InspectionPassed::class => [
MoveCardToPackingOnInspectionPassed::class,
NotifySlackOnInspectionPassed::class,
],
InspectionFailed::class => [
NotifySlackOnInspectionFailed::class,
],
OrderMovedToInspection::class => [
NotifySlackOnCardMovedToInspection::class,
],
// Ready to Ship intent (from Trello webhook)
ReadyToShipIntent::class => [
CreateShipmentOnReadyToShip::class,
],
// Shipment events
ShipmentCreated::class => [
NotifySlackOnShipmentCreated::class,
],
ShipmentCreationFailed::class => [
NotifySlackOnShipmentCreationFailed::class,
],
// Courier events
ParcelCollected::class => [
NotifySlackOnParcelCollected::class,
],
ParcelInTransit::class => [
// TODO: Add listener
],
ParcelDelivered::class => [
NotifySlackOnParcelDelivered::class,
],
ParcelFailedDelivery::class => [
NotifySlackOnParcelFailedDelivery::class,
],
// Custom order events (listeners TODO)
DepositPaid::class => [
// TODO: NotifySlackOnDepositPaid
],
ProofUploaded::class => [
// TODO: NotifySlackOnProofUploaded
],
ProofApproved::class => [
// TODO: NotifySlackOnProofApproved
],
ProofRevisionRequested::class => [
// TODO: NotifySlackOnProofRevisionRequested
],
BalancePaid::class => [
// TODO: NotifySlackOnBalancePaid
],
Registered::class => [
SendEmailVerificationNotification::class,
],
];
/**
* Disable automatic event discovery to avoid permission issues
*/
public function shouldDiscoverEvents(): bool
{
return false;
}
/**
* Register any events for your application.
*/
public function boot(): void
{
//
}
}