Files
autocrm/app/Filament/Central/Widgets/PlatformStats.php
T
Vasyka 2d447e6294 feat(i18n): fix widgets, pipeline & mechanic boards + missing translations
Follow-up to previous i18n pass — user reported many visible RO strings on
EN/RU locales because auto-wrap missed:
  - Stat::make() first-arg labels in StatsOverview, FinanceOverview, PlatformStats
  - $heading static in LowStockTable (converted to getHeading() method)
  - Pipeline board Blade view: 40+ literal strings wrapped with {{ __() }}
  - Mechanic board Blade view: statuses, buttons, block modal
  - PipelineBoard.php hardcoded tag labels, stage labels, notify strings
  - MechanicBoard.php confirmBlock notification

Added human RU + EN translations for the visible strings shown in the
screenshots (dashboard widgets, Client/Vehicle list breadcrumbs & columns,
pipeline board topbar/stats/filters/cards/detail panel/quick actions,
mechanic board stats/statuses/block modal). All 306 tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-07-15 05:31:26 +00:00

65 lines
2.7 KiB
PHP

<?php
namespace App\Filament\Central\Widgets;
use App\Models\Central\Company;
use App\Models\Central\Subscription;
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;
class PlatformStats extends BaseWidget
{
protected static ?int $sort = 1;
protected function getStats(): array
{
$total = Company::count();
$active = Company::where('status', 'active')->count();
$trial = Company::where('status', 'trial')->count();
$expiring = Company::where('status', 'active')
->whereNotNull('active_until')
->whereDate('active_until', '<=', now()->addDays(7))
->count();
$mrr = (float) Subscription::where('status', 'paid')
->whereYear('paid_at', date('Y'))
->whereMonth('paid_at', date('m'))
->sum('amount');
$overdue = Subscription::where('status', 'overdue')->count()
+ Subscription::where('status', 'pending')
->whereNotNull('due_at')
->where('due_at', '<', now())
->count();
return [
Stat::make(__('Tenants total'), $total)
->description(__('Toate companiile'))
->descriptionIcon('heroicon-m-building-office-2')
->color('primary')
->url(\App\Filament\Central\Resources\CompanyResource::getUrl('index')),
Stat::make(__('Active'), $active)
->description(__("✓ Pe abonament plătit"))
->descriptionIcon('heroicon-m-check-circle')
->color('success'),
Stat::make(__('În trial'), $trial)
->description($trial > 0 ? __('Posibili clienți noi') : '—')
->descriptionIcon('heroicon-m-clock')
->color('warning'),
Stat::make(__('Expiră < 7 zile'), $expiring)
->description($expiring > 0 ? __('⚠ Acțiune necesară') : __('Toate ok'))
->descriptionIcon('heroicon-m-exclamation-triangle')
->color($expiring > 0 ? 'danger' : 'success'),
Stat::make(__('Venit luna curentă'), number_format($mrr, 0, ',', ' ') . ' MDL')
->description(__('MRR realizat'))
->descriptionIcon('heroicon-m-banknotes')
->color('success'),
Stat::make(__('Facturi neplătite'), $overdue)
->description($overdue > 0 ? __('Verifică și amintește') : __('Toate plătite'))
->descriptionIcon('heroicon-m-exclamation-circle')
->color($overdue > 0 ? 'danger' : 'gray')
->url(\App\Filament\Central\Resources\SubscriptionResource::getUrl('index') . '?activeTab=overdue'),
];
}
}