Files
autocrm/app/Filament/Tenant/Widgets/LowStockTable.php
T
Vasyka 6e7c665433 feat(dashboard): clickable stat cards + 2 new WO counters + parts row link
Every card on the tenant main dashboard now links to a relevant page:

Operations widget (was 5 cards, now 7):
- Clienți → /app/clients
- Mașini → /app/vehicles
- Cereri noi → /app/leads pre-filtered by status=new
- Deal-uri active → /app/deals
- Programări azi → /app/calendar-board
- NEW: Fișe în lucru (in_work + awaiting_parts) → /app/work-orders filter
- NEW: Fișe gata predare (ready) → /app/work-orders filter

Finance widget (all 4 cards clickable now):
- Încasări → /app/payments
- Cheltuieli → /app/expenses
- Profit → /app/reports (with "Vezi raportul financiar" hint)
- Datorii → /app/work-orders pre-filtered by pay_status=unpaid

LowStockTable rows now navigate to /app/parts/{id}/edit on click and
have an explicit edit action for touch users.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-08-06 05:55:39 +00:00

53 lines
1.8 KiB
PHP

<?php
namespace App\Filament\Tenant\Widgets;
use App\Models\Tenant\Part;
use Filament\Actions\Action;
use Filament\Tables;
use Filament\Tables\Table;
use Filament\Widgets\TableWidget as BaseWidget;
class LowStockTable extends BaseWidget
{
protected static ?int $sort = 5;
protected int|string|array $columnSpan = 'full';
protected static ?string $heading = null;
protected function getTableHeading(): string
{
return '⚠️ ' . __('Stoc minim atins');
}
public function table(Table $table): Table
{
return $table
->query(
Part::query()
->where('is_active', true)
->whereColumn('qty', '<=', 'min_qty')
->orderBy('qty')
)
->columns([
Tables\Columns\TextColumn::make('name')->label(__('Piesă'))->wrap()->searchable(),
Tables\Columns\TextColumn::make('article')->label(__('Cod'))->placeholder('—'),
Tables\Columns\TextColumn::make('qty')->label(__('Stoc'))->alignRight()
->color(fn ($state) => $state <= 0 ? 'danger' : 'warning')
->weight('bold'),
Tables\Columns\TextColumn::make('min_qty')->label(__('Min.'))->alignRight(),
Tables\Columns\TextColumn::make('preferredSupplier.name')->label(__('Furnizor'))->placeholder('—'),
])
->recordUrl(fn (Part $r) => url('/app/parts/' . $r->id . '/edit'))
->actions([
Action::make('edit')
->label(__('Editează'))
->icon('heroicon-m-pencil-square')
->url(fn (Part $r) => url('/app/parts/' . $r->id . '/edit')),
])
->paginated(false)
->defaultSort('qty');
}
}