78ff8d4b43
User screenshots showed the tenant admin panel (Filament) had sidebar
labels stuck in Romanian even when switching to Russian: 'Cereri',
'Calendar vizual', 'Atelierul meu', 'KPI mecanici', 'Fișe lucru',
'Norme-ore', 'Tehnicieni', 'Șabloane servicii', 'Depozite', 'Scaner',
'Depozit', 'VIN-căutare', 'Furnizori', 'Achiziții', 'Procentaj',
'Coeficienți preț', plus all group headers.
Root cause: every Filament Resource and Page had static properties
'protected static ?string $navigationLabel = "Fișe lucru"' — string
literals baked into class definitions. Static properties don't run
through the translation layer.
Fix in two parts:
1. New translation files with 52 label keys + 12 group keys:
- lang/ro/nav.php — Romanian (identity)
- lang/ru/nav.php — full Russian translations (Заказ-наряды,
Автомобили, Клиенты, Календарь, Моя мастерская, Механики KPI,
Настройки, etc.)
- lang/en/nav.php — English translations (Work orders, Vehicles,
Clients, Calendar, My workshop, Mechanic KPI, Settings, etc.)
Keyed by the Romanian original so lookups map 1:1 —
'nav.label.Fișe lucru' returns 'Заказ-наряды' in RU, 'Work orders'
in EN, 'Fișe lucru' in RO.
2. Python transformer converted 54 files:
- 33 Filament Tenant Resources
- 15 Filament Tenant Pages
- 4 Filament Central Resources
- 1 Filament Central Page
- 1 Widget
Each 'protected static ?string $navigationLabel = "X";' became
'public static function getNavigationLabel(): string { return
__("nav.label.X"); }'. Same treatment for $navigationGroup.
Cleanup: 6 resources already had manually-added getNavigationLabel
methods from an earlier partial effort — those used flat JSON keys
(__("Cereri")) that never resolved. Deduped so only the nav.label.*
version remains.
Untouched (intentional):
- $modelLabel / $pluralModelLabel (used in breadcrumbs and headings —
still hardcoded, next tier of work)
- Section titles, column headers, form field labels (medium priority)
- $navigationSort (numeric, no translation needed)
- $navigationIcon (icon reference)
Suite: 306 passed (853 assertions). Unchanged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
162 lines
7.3 KiB
PHP
162 lines
7.3 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Tenant\Resources;
|
|
|
|
use App\Filament\Tenant\Resources\BodyshopJobResource\Pages;
|
|
use App\Filament\Tenant\Resources\BodyshopJobResource\RelationManagers;
|
|
use App\Models\Tenant\BodyshopJob;
|
|
use App\Models\Tenant\Client;
|
|
use App\Models\Tenant\Vehicle;
|
|
use Filament\Actions;
|
|
use Filament\Forms;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Schemas;
|
|
use Filament\Schemas\Components\Utilities\Get;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Table;
|
|
|
|
class BodyshopJobResource extends Resource
|
|
{
|
|
protected static ?string $model = BodyshopJob::class;
|
|
|
|
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-paint-brush';
|
|
|
|
public static function getNavigationLabel(): string
|
|
{
|
|
return __('nav.label.Tinichigerie / Detailing');
|
|
}
|
|
|
|
public static function getNavigationGroup(): ?string
|
|
{
|
|
return __('nav.group.Tinichigerie');
|
|
}
|
|
|
|
protected static ?string $modelLabel = 'lucrare caroserie';
|
|
|
|
protected static ?string $pluralModelLabel = 'lucrări caroserie';
|
|
|
|
protected static ?int $navigationSort = 80;
|
|
|
|
public static function getNavigationBadge(): ?string
|
|
{
|
|
$open = static::getModel()::query()
|
|
->whereNotIn('status', ['delivered', 'cancelled'])->count();
|
|
return $open > 0 ? (string) $open : null;
|
|
}
|
|
|
|
public static function form(Schema $schema): Schema
|
|
{
|
|
return $schema->components([
|
|
Schemas\Components\Section::make('Lucrare')
|
|
->columns(3)
|
|
->schema([
|
|
Forms\Components\TextInput::make('number')->label('Nr.')->disabled()->dehydrated(false)->placeholder('Generat automat'),
|
|
Forms\Components\Select::make('type')->label('Tip')->options(BodyshopJob::TYPES)->default('body_repair')->required(),
|
|
Forms\Components\Select::make('status')->label('Status')->options(BodyshopJob::STATUSES)->default('estimate')->required(),
|
|
Forms\Components\Select::make('client_id')
|
|
->label('Client')
|
|
->options(fn () => Client::pluck('name', 'id'))
|
|
->searchable()->live(),
|
|
Forms\Components\Select::make('vehicle_id')
|
|
->label('Auto')
|
|
->options(fn (Get $get) => $get('client_id')
|
|
? Vehicle::where('client_id', $get('client_id'))->get()
|
|
->mapWithKeys(fn ($v) => [$v->id => "{$v->make} {$v->model} {$v->plate}"])->toArray()
|
|
: [])
|
|
->searchable(),
|
|
Forms\Components\TextInput::make('estimate_amount')->label('Deviz')->numeric()->default(0),
|
|
Forms\Components\TextInput::make('approved_amount')->label('Aprobat')->numeric()->default(0),
|
|
]),
|
|
Schemas\Components\Section::make('Asigurare')
|
|
->collapsible()
|
|
->columns(3)
|
|
->schema([
|
|
Forms\Components\Toggle::make('is_insurance')->label('Caz de asigurare')->live()->columnSpanFull(),
|
|
Forms\Components\TextInput::make('insurer')->label('Asigurător')
|
|
->visible(fn (Get $get) => $get('is_insurance')),
|
|
Forms\Components\TextInput::make('policy_no')->label('Nr. poliță')
|
|
->visible(fn (Get $get) => $get('is_insurance')),
|
|
Forms\Components\TextInput::make('claim_no')->label('Nr. dosar daună')
|
|
->visible(fn (Get $get) => $get('is_insurance')),
|
|
Forms\Components\Select::make('insurance_status')->label('Status dosar')
|
|
->options(BodyshopJob::INSURANCE_STATUSES)
|
|
->visible(fn (Get $get) => $get('is_insurance')),
|
|
]),
|
|
Schemas\Components\Section::make('Foto înainte / după')
|
|
->columns(2)
|
|
->schema([
|
|
\Filament\Forms\Components\SpatieMediaLibraryFileUpload::make('photos_before')
|
|
->label('Înainte')->collection('photos_before')->multiple()->image()->reorderable()->maxFiles(20),
|
|
\Filament\Forms\Components\SpatieMediaLibraryFileUpload::make('photos_after')
|
|
->label('După')->collection('photos_after')->multiple()->image()->reorderable()->maxFiles(20),
|
|
]),
|
|
Forms\Components\Textarea::make('notes')->label('Observații')->columnSpanFull()->rows(2),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
Tables\Columns\TextColumn::make('number')->label('Nr.')->searchable()->sortable(),
|
|
Tables\Columns\TextColumn::make('client.name')->label('Client')->searchable()->placeholder('—'),
|
|
Tables\Columns\TextColumn::make('vehicle.plate')->label('Auto')->placeholder('—'),
|
|
Tables\Columns\TextColumn::make('type')
|
|
->formatStateUsing(fn ($s) => BodyshopJob::TYPES[$s] ?? $s)
|
|
->badge()->color('info'),
|
|
Tables\Columns\IconColumn::make('is_insurance')->label('Asig.')->boolean()->toggleable(),
|
|
Tables\Columns\TextColumn::make('damage_points_count')->counts('damagePoints')->label('Daune')->alignRight(),
|
|
Tables\Columns\TextColumn::make('approved_amount')->label('Aprobat')->money('MDL')->alignRight(),
|
|
Tables\Columns\TextColumn::make('status')
|
|
->formatStateUsing(fn ($s) => BodyshopJob::STATUSES[$s] ?? $s)
|
|
->badge()
|
|
->colors([
|
|
'gray' => ['estimate'],
|
|
'info' => ['approved', 'in_progress'],
|
|
'success' => ['done', 'delivered'],
|
|
'danger' => ['cancelled'],
|
|
]),
|
|
])
|
|
->filters([
|
|
Tables\Filters\SelectFilter::make('type')->options(BodyshopJob::TYPES),
|
|
Tables\Filters\SelectFilter::make('status')->options(BodyshopJob::STATUSES),
|
|
Tables\Filters\TernaryFilter::make('is_insurance')->label('Caz asigurare'),
|
|
])
|
|
->actions([
|
|
Actions\EditAction::make(),
|
|
Actions\DeleteAction::make(),
|
|
])
|
|
->emptyStateHeading('Nicio lucrare de caroserie')
|
|
->emptyStateDescription('Înregistrează lucrări de tinichigerie, vopsitorie, PDR, detailing, ceramică, PPF sau polish. Hartă daune, dosar asigurare și arhivă foto înainte/după.')
|
|
->emptyStateIcon('heroicon-o-paint-brush')
|
|
->defaultSort('created_at', 'desc');
|
|
}
|
|
|
|
public static function getRelations(): array
|
|
{
|
|
return [
|
|
RelationManagers\DamagePointsRelationManager::class,
|
|
];
|
|
}
|
|
|
|
public static function getModelLabel(): string
|
|
{
|
|
return __('lucrare caroserie');
|
|
}
|
|
|
|
public static function getPluralModelLabel(): string
|
|
{
|
|
return __('lucrări caroserie');
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => Pages\ListBodyshopJobs::route('/'),
|
|
'create' => Pages\CreateBodyshopJob::route('/create'),
|
|
'edit' => Pages\EditBodyshopJob::route('/{record}/edit'),
|
|
];
|
|
}
|
|
}
|