WIP #102
This commit is contained in:
parent
779d46d708
commit
70b59e3cad
@ -51,6 +51,7 @@ enum IconEnum: string
|
|||||||
case APPROVED = 'lucide-check-check';
|
case APPROVED = 'lucide-check-check';
|
||||||
case PRODUCTION = 'lucide-refresh-cw';
|
case PRODUCTION = 'lucide-refresh-cw';
|
||||||
case SHIPPED = 'lucide-send';
|
case SHIPPED = 'lucide-send';
|
||||||
|
case INVOICING = 'lucide-calendar';
|
||||||
case INVOICED = 'lucide-credit-card';
|
case INVOICED = 'lucide-credit-card';
|
||||||
|
|
||||||
// Shipping Types (THEY_SHIP => SHIPPING_ENTRY)
|
// Shipping Types (THEY_SHIP => SHIPPING_ENTRY)
|
||||||
|
@ -12,6 +12,7 @@ enum OrderStatus: string implements HasColor, HasIcon, HasLabel
|
|||||||
case APPROVED = 'Approved';
|
case APPROVED = 'Approved';
|
||||||
case PRODUCTION = 'Production';
|
case PRODUCTION = 'Production';
|
||||||
case SHIPPED = 'Shipped';
|
case SHIPPED = 'Shipped';
|
||||||
|
case READY_FOR_INVOICE = 'Ready for Invoice';
|
||||||
case INVOICED = 'Invoiced';
|
case INVOICED = 'Invoiced';
|
||||||
|
|
||||||
public function getLabel(): ?string
|
public function getLabel(): ?string
|
||||||
@ -26,6 +27,7 @@ public function getColor(): string|array|null
|
|||||||
self::APPROVED => 'success',
|
self::APPROVED => 'success',
|
||||||
self::PRODUCTION => 'primary',
|
self::PRODUCTION => 'primary',
|
||||||
self::SHIPPED => 'warning',
|
self::SHIPPED => 'warning',
|
||||||
|
self::READY_FOR_INVOICE => 'invoicing',
|
||||||
self::INVOICED => 'invoiced',
|
self::INVOICED => 'invoiced',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -37,6 +39,7 @@ public function getIcon(): ?string
|
|||||||
self::APPROVED => IconEnum::APPROVED->value,
|
self::APPROVED => IconEnum::APPROVED->value,
|
||||||
self::PRODUCTION => IconEnum::PRODUCTION->value,
|
self::PRODUCTION => IconEnum::PRODUCTION->value,
|
||||||
self::SHIPPED => IconEnum::SHIPPED->value,
|
self::SHIPPED => IconEnum::SHIPPED->value,
|
||||||
|
self::READY_FOR_INVOICE => IconEnum::INVOICING->value,
|
||||||
self::INVOICED => IconEnum::INVOICED->value,
|
self::INVOICED => IconEnum::INVOICED->value,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,10 @@ public function getTabs(): array
|
|||||||
->query(fn ($query) => $query->where('status', InvoiceStatus::UNPAID))
|
->query(fn ($query) => $query->where('status', InvoiceStatus::UNPAID))
|
||||||
->icon(InvoiceStatus::UNPAID->getIcon()),
|
->icon(InvoiceStatus::UNPAID->getIcon()),
|
||||||
|
|
||||||
|
'partially_paid' => Tab::make('Partially Paid')
|
||||||
|
->query(fn ($query) => $query->where('status', InvoiceStatus::PARTIALLY_PAID))
|
||||||
|
->icon(InvoiceStatus::PARTIALLY_PAID->getIcon()),
|
||||||
|
|
||||||
'paid' => Tab::make('Paid')
|
'paid' => Tab::make('Paid')
|
||||||
->query(fn ($query) => $query->where('status', InvoiceStatus::PAID))
|
->query(fn ($query) => $query->where('status', InvoiceStatus::PAID))
|
||||||
->icon(InvoiceStatus::PAID->getIcon()),
|
->icon(InvoiceStatus::PAID->getIcon()),
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Support\Enums\MaxWidth;
|
use Filament\Support\Enums\MaxWidth;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Actions\BulkAction;
|
||||||
|
use Filament\Tables\Actions\BulkActionGroup;
|
||||||
use Filament\Tables\Columns\IconColumn\IconColumnSize;
|
use Filament\Tables\Columns\IconColumn\IconColumnSize;
|
||||||
use Filament\Tables\Columns\TextColumn;
|
use Filament\Tables\Columns\TextColumn;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
@ -202,13 +204,13 @@ public static function form(Form $form): Form
|
|||||||
->createOptionUsing(function (array $data): int {
|
->createOptionUsing(function (array $data): int {
|
||||||
return ServiceType::create($data)->getKey();
|
return ServiceType::create($data)->getKey();
|
||||||
}),
|
}),
|
||||||
TextInput::make('placement')
|
|
||||||
->datalist(ProductService::all()->unique('placement')->pluck('placement')->toArray())
|
|
||||||
->columnSpan(3),
|
|
||||||
TextInput::make('serviceFileName')
|
TextInput::make('serviceFileName')
|
||||||
->datalist(ServiceFile::all()->unique('name')->pluck('name')->toArray())
|
->datalist(ServiceFile::all()->unique('name')->pluck('name')->toArray())
|
||||||
->columnSpan(3)
|
->columnSpan(3)
|
||||||
->label('Logo Name'),
|
->label('Logo Name'),
|
||||||
|
TextInput::make('placement')
|
||||||
|
->datalist(ProductService::all()->unique('placement')->pluck('placement')->toArray())
|
||||||
|
->columnSpan(3),
|
||||||
TextInput::make('serviceFileSetupNumber')
|
TextInput::make('serviceFileSetupNumber')
|
||||||
->label('Setup')
|
->label('Setup')
|
||||||
->columnSpan(1)
|
->columnSpan(1)
|
||||||
@ -343,7 +345,6 @@ public static function table(Table $table): Table
|
|||||||
Tables\Actions\EditAction::make(),
|
Tables\Actions\EditAction::make(),
|
||||||
])
|
])
|
||||||
->bulkActions([
|
->bulkActions([
|
||||||
|
|
||||||
Tables\Actions\BulkAction::make('updateStatus')
|
Tables\Actions\BulkAction::make('updateStatus')
|
||||||
->form([
|
->form([
|
||||||
Select::make('status')
|
Select::make('status')
|
||||||
@ -366,9 +367,18 @@ public static function table(Table $table): Table
|
|||||||
->color('info')
|
->color('info')
|
||||||
->deselectRecordsAfterCompletion(),
|
->deselectRecordsAfterCompletion(),
|
||||||
|
|
||||||
Tables\Actions\BulkActionGroup::make([
|
BulkActionGroup::make([
|
||||||
|
BulkAction::make('Create individual invoices')
|
||||||
|
->icon(IconEnum::INVOICE->value),
|
||||||
|
BulkAction::make('Add all to new invoice')
|
||||||
|
->icon(IconEnum::REPEAT->value),
|
||||||
|
])
|
||||||
|
->label('Invoicing')
|
||||||
|
->hidden(fn () => ! auth()->user()->is_admin),
|
||||||
|
|
||||||
|
BulkActionGroup::make([
|
||||||
Tables\Actions\DeleteBulkAction::make(),
|
Tables\Actions\DeleteBulkAction::make(),
|
||||||
]),
|
])->label('Other actions'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,21 @@ class ListOrders extends ListRecords
|
|||||||
{
|
{
|
||||||
protected static string $resource = OrderResource::class;
|
protected static string $resource = OrderResource::class;
|
||||||
|
|
||||||
|
private function excludeStatuses($query): mixed
|
||||||
|
{
|
||||||
|
return $query
|
||||||
|
->whereNot('status', OrderStatus::READY_FOR_INVOICE)
|
||||||
|
->whereNot('status', OrderStatus::INVOICED)
|
||||||
|
->whereNot('status', OrderStatus::SHIPPED);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getBadgeCount(callable $queryCallback): ?int
|
||||||
|
{
|
||||||
|
$count = Order::query()->when(true, $queryCallback)->count();
|
||||||
|
|
||||||
|
return $count > 0 ? $count : null;
|
||||||
|
}
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@ -26,67 +41,37 @@ protected function getHeaderActions(): array
|
|||||||
public function getTabs(): array
|
public function getTabs(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
'all' => Tab::make('All')
|
||||||
|
->icon(IconEnum::TAB_ALL->value),
|
||||||
|
|
||||||
'active' => Tab::make()
|
'active' => Tab::make()
|
||||||
->query(function ($query) {
|
->query(fn ($query) => $this->excludeStatuses($query))
|
||||||
return $query
|
|
||||||
->whereNot('status', OrderStatus::INVOICED)
|
|
||||||
->whereNot('status', ORderStatus::SHIPPED);
|
|
||||||
})
|
|
||||||
->icon(OrderStatus::PRODUCTION->getIcon())
|
->icon(OrderStatus::PRODUCTION->getIcon())
|
||||||
->badge(function () {
|
->badge(fn () => $this->getBadgeCount(fn ($query) => $this->excludeStatuses($query))),
|
||||||
return Order::whereNot('status', OrderStatus::SHIPPED)
|
|
||||||
->whereNot('status', OrderStatus::INVOICED)
|
|
||||||
->count();
|
|
||||||
}),
|
|
||||||
|
|
||||||
'unprinted' => Tab::make()
|
'unprinted' => Tab::make()
|
||||||
->query(function ($query) {
|
->query(fn ($query) => $this->excludeStatuses($query)->where('printed', false))
|
||||||
return $query->where('printed', false);
|
|
||||||
})
|
|
||||||
->icon(IconEnum::PRINT->value)
|
->icon(IconEnum::PRINT->value)
|
||||||
->badge(function () {
|
->badge(fn () => $this->getBadgeCount(fn ($query) => $query->where('printed', false)))
|
||||||
$count = Order::where('printed', false)->count();
|
|
||||||
|
|
||||||
return $count > 0 ? $count : null;
|
|
||||||
})
|
|
||||||
->badgeColor('success'),
|
->badgeColor('success'),
|
||||||
|
|
||||||
'overdue' => Tab::make()
|
'overdue' => Tab::make()
|
||||||
->query(function ($query) {
|
->query(fn ($query) => $this->excludeStatuses($query)->whereDate('due_date', '<=', today()))
|
||||||
return $query->whereDate('due_date', '<=', today())
|
|
||||||
->whereNot('status', OrderStatus::INVOICED)
|
|
||||||
->whereNot('status', ORderStatus::SHIPPED);
|
|
||||||
})
|
|
||||||
->icon(IconEnum::TAB_OVERDUE->value)
|
->icon(IconEnum::TAB_OVERDUE->value)
|
||||||
->badge(function () {
|
->badge(fn () => $this->getBadgeCount(fn ($query) => $query->whereDate('due_date', '<=', today())))
|
||||||
$count = Order::whereDate('due_date', '<=', today())
|
|
||||||
->whereNot('status', OrderStatus::INVOICED)
|
|
||||||
->whereNot('status', ORderStatus::SHIPPED)
|
|
||||||
->count();
|
|
||||||
|
|
||||||
return $count > 0 ? $count : null;
|
|
||||||
})
|
|
||||||
->badgeColor('danger'),
|
->badgeColor('danger'),
|
||||||
|
|
||||||
'rush' => Tab::make()
|
'rush' => Tab::make()
|
||||||
->query(function ($query) {
|
->query(fn ($query) => $this->excludeStatuses($query)->where('rush', true))
|
||||||
return $query->where('rush', true)
|
|
||||||
->whereNot('status', OrderStatus::INVOICED)
|
|
||||||
->whereNot('status', OrderStatus::SHIPPED);
|
|
||||||
})
|
|
||||||
->icon(OrderAttributes::rush->getIcon())
|
->icon(OrderAttributes::rush->getIcon())
|
||||||
->badge(function () {
|
->badge(fn () => $this->getBadgeCount(fn ($query) => $query->where('rush', true)))
|
||||||
$count = Order::where('rush', true)
|
|
||||||
->whereNot('status', OrderStatus::INVOICED)
|
|
||||||
->whereNot('status', OrderStatus::SHIPPED)
|
|
||||||
->count();
|
|
||||||
|
|
||||||
return $count > 0 ? $count : null;
|
|
||||||
})
|
|
||||||
->badgeColor('warning'),
|
->badgeColor('warning'),
|
||||||
|
|
||||||
'all' => Tab::make('All')
|
'ready_for_invoice' => Tab::make()
|
||||||
->icon(IconEnum::TAB_ALL->value),
|
->query(fn ($query) => $query->where('status', OrderStatus::READY_FOR_INVOICE))
|
||||||
|
->icon(OrderStatus::READY_FOR_INVOICE->getIcon())
|
||||||
|
->badge(fn () => $this->getBadgeCount(fn ($query) => $query->where('status', OrderStatus::READY_FOR_INVOICE)))
|
||||||
|
->badgeColor(OrderStatus::READY_FOR_INVOICE->getColor()),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@ class ActiveOrdersTable extends BaseWidget
|
|||||||
{
|
{
|
||||||
protected static ?int $sort = 2;
|
protected static ?int $sort = 2;
|
||||||
|
|
||||||
|
protected string|int|array $columnSpan = 2;
|
||||||
|
|
||||||
public function table(Table $table): Table
|
public function table(Table $table): Table
|
||||||
{
|
{
|
||||||
return $table
|
return $table
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
class RushOrdersTable extends BaseWidget
|
class RushOrdersTable extends BaseWidget
|
||||||
{
|
{
|
||||||
|
protected string|int|array $columnSpan = 2;
|
||||||
|
|
||||||
public function table(Table $table): Table
|
public function table(Table $table): Table
|
||||||
{
|
{
|
||||||
return $table
|
return $table
|
||||||
|
@ -31,6 +31,7 @@ public function panel(Panel $panel): Panel
|
|||||||
->colors([
|
->colors([
|
||||||
'primary' => Color::Blue,
|
'primary' => Color::Blue,
|
||||||
'code' => Color::hex('#d63384'),
|
'code' => Color::hex('#d63384'),
|
||||||
|
'invoicing' => Color::hex('#DD00DD'),
|
||||||
'invoiced' => Color::hex('#900090'),
|
'invoiced' => Color::hex('#900090'),
|
||||||
])
|
])
|
||||||
->discoverResources(in: app_path('Filament/Admin/Resources/'), for: 'App\\Filament\\Admin\\Resources')
|
->discoverResources(in: app_path('Filament/Admin/Resources/'), for: 'App\\Filament\\Admin\\Resources')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user