diff --git a/app/Filament/Tenant/Resources/LaborResource/Pages/ListLabors.php b/app/Filament/Tenant/Resources/LaborResource/Pages/ListLabors.php index 649ab9f..4554550 100644 --- a/app/Filament/Tenant/Resources/LaborResource/Pages/ListLabors.php +++ b/app/Filament/Tenant/Resources/LaborResource/Pages/ListLabors.php @@ -3,6 +3,8 @@ namespace App\Filament\Tenant\Resources\LaborResource\Pages; use App\Filament\Tenant\Resources\LaborResource; +use App\Models\Tenant\Labor; +use App\Models\Tenant\LaborCategory; use Filament\Actions; use Filament\Resources\Pages\ListRecords; @@ -10,5 +12,23 @@ class ListLabors extends ListRecords { protected static string $resource = LaborResource::class; - protected function getHeaderActions(): array { return [Actions\CreateAction::make()]; } + protected string $view = 'filament.tenant.resources.labor.list-labors'; + + protected function getHeaderActions(): array + { + return [Actions\CreateAction::make()]; + } + + public function getLaborTree(): \Illuminate\Support\Collection + { + $cats = LaborCategory::orderBy('sort_order')->get(); + $labors = Labor::orderBy('name_ro')->get()->groupBy('category'); + + return $cats->map(fn ($cat) => (object) [ + 'id' => $cat->id, + 'label' => $cat->label(), + 'name' => $cat->name, + 'items' => $labors->get($cat->name, collect()), + ])->filter(fn ($c) => $c->items->isNotEmpty()); + } } diff --git a/resources/views/filament/tenant/resources/labor/list-labors.blade.php b/resources/views/filament/tenant/resources/labor/list-labors.blade.php new file mode 100644 index 0000000..5889697 --- /dev/null +++ b/resources/views/filament/tenant/resources/labor/list-labors.blade.php @@ -0,0 +1,149 @@ + + +
+ + {{-- ── View toggle bar ── --}} +
+ + {{-- Expand / Collapse all (only in tree mode) --}} + + + + + + {{-- Toggle buttons --}} +
+ + +
+
+ + {{-- ── LIST mode: standard Filament table ── --}} +
+ {{ $this->table }} +
+ + {{-- ── TREE mode: category accordion ── --}} +
+ + @php $tree = $this->getLaborTree(); @endphp + + @forelse ($tree as $cat) +
+ + {{-- Category header --}} + + + {{-- Labor items --}} +
+ + + + + + + + + + + + + @foreach ($cat->items as $labor) + + + + + + + + + @endforeach + +
{{ __('Manoperă') }}{{ __('Mod') }}{{ __('Ore') }}{{ __('Preț') }}{{ __('Cost') }}
+ {{ $labor->label() }} + @if ($labor->code) + {{ $labor->code }} + @endif + @if (! $labor->is_active) + {{ __('Inactiv') }} + @endif + + + {{ $labor->pricing_mode === 'fixed' ? __('Fix') : __('Pe oră') }} + + + {{ $labor->pricing_mode === 'hourly' ? rtrim(rtrim(number_format((float)$labor->hours, 2), '0'), '.') : '—' }} + + {{ number_format((float)($labor->pricing_mode === 'fixed' ? $labor->fixed_price : $labor->price), 2, '.', ' ') }} MDL + + {{ $labor->cost_price > 0 ? number_format((float)$labor->cost_price, 2, '.', ' ') . ' MDL' : '—' }} + + + {{ __('Editează') }} + +
+
+
+ @empty +
{{ __('Nicio manoperă găsită.') }}
+ @endforelse +
+ +
+ +