diff --git a/app/Classes/General/Eloquent/Filters/Delivered.php b/app/Classes/General/Eloquent/Filters/Delivered.php new file mode 100644 index 00000000..f6c09b98 --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/Delivered.php @@ -0,0 +1,32 @@ +whereHas('packingList', function($packingList){ + return $packingList->where('type', PackingListType::SHIPPING_PACKING_LIST)->where('status', ApprovalStatus::APPROVED); + })->whereHas('container', + function($container) { + return $container->where('containers.status', ApprovalStatus::COMPLETED); + } + )->whereHas('deliverySchedules', + function($schedule) { + return $schedule->where('eta', '<', Carbon::now())->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); + } + ); + } +} \ No newline at end of file diff --git a/app/Classes/General/Eloquent/Filters/InDestinationWarehouse.php b/app/Classes/General/Eloquent/Filters/InDestinationWarehouse.php new file mode 100644 index 00000000..b4a56b23 --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/InDestinationWarehouse.php @@ -0,0 +1,32 @@ +whereHas('packingList', function($packingList){ + return $packingList->where('type', PackingListType::SHIPPING_PACKING_LIST)->where('status', ApprovalStatus::APPROVED); + })->whereHas('container', + function($container) { + return $container->where('containers.status', ApprovalStatus::COMPLETED); + } + )->whereDoesntHave('deliverySchedules', + function($schedule) { + return $schedule->where('etd', '<', Carbon::now())->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); + } + ); + } +} \ No newline at end of file diff --git a/app/Classes/General/Eloquent/Filters/InTransit.php b/app/Classes/General/Eloquent/Filters/InTransit.php index e7ce4fea..db453486 100644 --- a/app/Classes/General/Eloquent/Filters/InTransit.php +++ b/app/Classes/General/Eloquent/Filters/InTransit.php @@ -19,9 +19,13 @@ class InTransit implements Filter { return $builder->whereHas('packingList', function($packingList){ return $packingList->where('type', PackingListType::SHIPPING_PACKING_LIST)->where('status', ApprovalStatus::APPROVED); - })->whereHas('shippingSchedules', + })->whereHas('container', + function($container) { + return $container->where('containers.status', ApprovalStatus::PENDING_VERIFICATION); + } + )->whereHas('shippingSchedules', function($schedule) { - return $schedule->where('etd', '<', Carbon::now())->where('eta', '>', Carbon::now()) + return $schedule->where('etd', '<', Carbon::now()) ->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); } ); diff --git a/app/Models/Package.php b/app/Models/Package.php index cfc50f2f..89ef8328 100644 --- a/app/Models/Package.php +++ b/app/Models/Package.php @@ -143,7 +143,7 @@ class Package extends AbstractModel protected static function booted() { if (auth()->user()->type === RoleTypes::USER) { - static::addGlobalScope(new CustomerPackagesScope()); +// static::addGlobalScope(new CustomerPackagesScope()); } } diff --git a/resources/views/pages/orders/packages.blade.php b/resources/views/pages/orders/packages.blade.php index 2d3e3cb9..2629c58b 100644 --- a/resources/views/pages/orders/packages.blade.php +++ b/resources/views/pages/orders/packages.blade.php @@ -160,19 +160,27 @@
- + + +
- + + +