|
|
@ -2,8 +2,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
namespace App\Filament\Resources\OrderResource\Pages;
|
|
|
|
namespace App\Filament\Resources\OrderResource\Pages;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use App\Enums\OrderAttributes;
|
|
|
|
|
|
|
|
use App\Enums\OrderStatus;
|
|
|
|
use App\Filament\Resources\OrderResource;
|
|
|
|
use App\Filament\Resources\OrderResource;
|
|
|
|
|
|
|
|
use App\Models\Order;
|
|
|
|
use Filament\Actions;
|
|
|
|
use Filament\Actions;
|
|
|
|
|
|
|
|
use Filament\Resources\Components\Tab;
|
|
|
|
use Filament\Resources\Pages\ListRecords;
|
|
|
|
use Filament\Resources\Pages\ListRecords;
|
|
|
|
|
|
|
|
|
|
|
|
class ListOrders extends ListRecords
|
|
|
|
class ListOrders extends ListRecords
|
|
|
@ -16,4 +20,66 @@ class ListOrders extends ListRecords
|
|
|
|
Actions\CreateAction::make(),
|
|
|
|
Actions\CreateAction::make(),
|
|
|
|
];
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getTabs(): array
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
|
|
|
null => Tab::make('All')
|
|
|
|
|
|
|
|
->icon('lucide-layout-grid'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'overdue' => Tab::make()
|
|
|
|
|
|
|
|
->query(function ($query) {
|
|
|
|
|
|
|
|
return $query->whereDate('due_date', '<=', today())
|
|
|
|
|
|
|
|
->whereNot('status', OrderStatus::INVOICED)
|
|
|
|
|
|
|
|
->whereNot('status', ORderStatus::SHIPPED);
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
->icon('lucide-calendar-clock')
|
|
|
|
|
|
|
|
->badge(function () {
|
|
|
|
|
|
|
|
$count = Order::whereDate('due_date', '<=', today())
|
|
|
|
|
|
|
|
->whereNot('status', OrderStatus::INVOICED)
|
|
|
|
|
|
|
|
->whereNot('status', ORderStatus::SHIPPED)
|
|
|
|
|
|
|
|
->count();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $count > 0 ? $count : null;
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
->badgeColor('danger'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'rush' => Tab::make()
|
|
|
|
|
|
|
|
->query(function ($query) {
|
|
|
|
|
|
|
|
return $query->where('rush', true)
|
|
|
|
|
|
|
|
->whereNot('status', OrderStatus::INVOICED)
|
|
|
|
|
|
|
|
->whereNot('status', OrderStatus::SHIPPED);
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
->icon(OrderAttributes::rush->getIcon())
|
|
|
|
|
|
|
|
->badge(function () {
|
|
|
|
|
|
|
|
$count = Order::where('rush', true)
|
|
|
|
|
|
|
|
->whereNot('status', OrderStatus::INVOICED)
|
|
|
|
|
|
|
|
->whereNot('status', OrderStatus::SHIPPED)
|
|
|
|
|
|
|
|
->count();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $count > 0 ? $count : null;
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
->badgeColor('warning'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'draft' => Tab::make()
|
|
|
|
|
|
|
|
->query(fn ($query) => $query->where('status', OrderStatus::DRAFT->value))
|
|
|
|
|
|
|
|
->icon(OrderStatus::DRAFT->getIcon()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'approved' => Tab::make()
|
|
|
|
|
|
|
|
->query(fn ($query) => $query->where('status', OrderStatus::APPROVED->value))
|
|
|
|
|
|
|
|
->icon(OrderStatus::APPROVED->getIcon()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'production' => Tab::make()
|
|
|
|
|
|
|
|
->query(fn ($query) => $query->where('status', OrderStatus::PRODUCTION->value))
|
|
|
|
|
|
|
|
->icon(OrderStatus::PRODUCTION->getIcon()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'shipped' => Tab::make()
|
|
|
|
|
|
|
|
->query(fn ($query) => $query->where('status', OrderStatus::SHIPPED->value))
|
|
|
|
|
|
|
|
->icon(OrderStatus::SHIPPED->getIcon()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'invoiced' => Tab::make()
|
|
|
|
|
|
|
|
->query(fn ($query) => $query->where('status', OrderStatus::INVOICED->value))
|
|
|
|
|
|
|
|
->icon(OrderStatus::INVOICED->getIcon()),
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|