From 57bdc1b59431ec9942229865824216f9a8d1517c Mon Sep 17 00:00:00 2001 From: Vasyka Date: Mon, 13 Jul 2026 19:42:00 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20language=20switcher=20on=20portal=20+?= =?UTF-8?q?=20apply=5Fmargin=20re-added=20to=20Plat=C4=83=20&=20total?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two fixes: == 1. Language switcher (RO/RU/EN) in portal headers == New partial resources/views/partials/lang-switcher.blade.php with two visual styles: - style='chip' (default) — white-tinted glass for colored headers (shop nav bar, tracking page hero) - style='light' — outlined buttons for pale backgrounds (invitation accept card) Each button is a POST form to the existing /locale/{lang} route which: - puts locale in session - persists to user.locale if authenticated - redirects back to the same page Included in: - resources/views/shop/layout.blade.php (right side of top nav, after login/register) - resources/views/tracking/show.blade.php (top-right of hero header, absolutely positioned) - resources/views/invitations/accept.blade.php (top-right of card, above welcome heading, light style) Current locale button is highlighted (opaque white on colored bg / blue on pale bg). Others are muted until hovered. Two new translation keys: - portal.common.language (RO: Limbă / RU: Язык) == 2. apply_margin toggle back in "Plată & total" == Previous session's edit didn't persist to the file. Now confirmed in place: WorkOrderResource form's "Plată & total" section shows a "Aplică marjă internă" toggle between discount_pct and override_margin_pct. Gated by FINANCE_VIEW_INTERNAL_MARGIN so only owner / admin / manager / accountant see it. Default = true. When toggled off on a Fișă, WorkOrderWork::saving hook writes salary_base = total for every line on that WO (no reduction). Backend logic already in place — this commit fixes the missing UI control. Suite: 303 passed (840 assertions). Unchanged — refactor + view only. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../Tenant/Resources/WorkOrderResource.php | 5 +++ lang/ro/portal.php | 1 + lang/ru/portal.php | 1 + resources/views/invitations/accept.blade.php | 3 ++ .../views/partials/lang-switcher.blade.php | 45 +++++++++++++++++++ resources/views/shop/layout.blade.php | 1 + resources/views/tracking/show.blade.php | 5 ++- 7 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 resources/views/partials/lang-switcher.blade.php diff --git a/app/Filament/Tenant/Resources/WorkOrderResource.php b/app/Filament/Tenant/Resources/WorkOrderResource.php index 36faa46..8941e8e 100644 --- a/app/Filament/Tenant/Resources/WorkOrderResource.php +++ b/app/Filament/Tenant/Resources/WorkOrderResource.php @@ -114,6 +114,11 @@ class WorkOrderResource extends Resource ->schema([ Forms\Components\Select::make('pay_status')->options(WorkOrder::PAY_STATUSES)->default('unpaid')->required(), Forms\Components\TextInput::make('discount_pct')->label('Discount %')->numeric()->default(0), + Forms\Components\Toggle::make('apply_margin') + ->label('Aplică marjă internă') + ->default(true) + ->helperText('On = din prețul manoperelor se scade marja pentru salariu. Off = manopere la cost (salariu pe Total integral).') + ->visible(fn () => auth()->user()?->canDo(\App\Auth\Permissions::FINANCE_VIEW_INTERNAL_MARGIN) ?? false), Forms\Components\TextInput::make('override_margin_pct')->label('Marjă internă (%) — override') ->numeric()->step(0.01)->minValue(0)->maxValue(90) ->placeholder('Ex: 25') diff --git a/lang/ro/portal.php b/lang/ro/portal.php index 98d2f95..85478ef 100644 --- a/lang/ro/portal.php +++ b/lang/ro/portal.php @@ -17,6 +17,7 @@ return [ 'required' => '*', 'currency_mdl' => 'MDL', 'powered_by' => 'Powered by AutoCRM', + 'language' => 'Limbă', ], // ─── Invitation flow ─── diff --git a/lang/ru/portal.php b/lang/ru/portal.php index 4269099..b4cc6e9 100644 --- a/lang/ru/portal.php +++ b/lang/ru/portal.php @@ -17,6 +17,7 @@ return [ 'required' => '*', 'currency_mdl' => 'MDL', 'powered_by' => 'Работает на AutoCRM', + 'language' => 'Язык', ], // ─── Приглашение ─── diff --git a/resources/views/invitations/accept.blade.php b/resources/views/invitations/accept.blade.php index 3674e6c..339ac66 100644 --- a/resources/views/invitations/accept.blade.php +++ b/resources/views/invitations/accept.blade.php @@ -21,6 +21,9 @@ input:focus { border-color: #3b82f6; }
+
+ @include('partials.lang-switcher', ['style' => 'light']) +

{{ __('portal.invitation.welcome_name', ['name' => $name]) }}

{!! __('portal.invitation.welcome_body', ['company' => '' . e($company) . '']) !!}

diff --git a/resources/views/partials/lang-switcher.blade.php b/resources/views/partials/lang-switcher.blade.php new file mode 100644 index 0000000..8b7880c --- /dev/null +++ b/resources/views/partials/lang-switcher.blade.php @@ -0,0 +1,45 @@ +@php + $locales = [ + 'ro' => ['label' => 'RO', 'full' => 'Română', 'flag' => '🇷🇴'], + 'ru' => ['label' => 'RU', 'full' => 'Русский', 'flag' => '🇷🇺'], + 'en' => ['label' => 'EN', 'full' => 'English', 'flag' => '🇬🇧'], + ]; + $current = app()->getLocale(); + // Default: dark-glass style suits colored header (shop, tracking). Override via $style param. + $style = $style ?? 'chip'; +@endphp + +@if ($style === 'chip') +
+ @foreach ($locales as $code => $meta) +
+ @csrf + + +
+ @endforeach +
+@else + {{-- light style for pale backgrounds (invitations, auth pages) --}} +
+ @foreach ($locales as $code => $meta) +
+ @csrf + +
+ @endforeach +
+@endif diff --git a/resources/views/shop/layout.blade.php b/resources/views/shop/layout.blade.php index c25242e..96efa5d 100644 --- a/resources/views/shop/layout.blade.php +++ b/resources/views/shop/layout.blade.php @@ -81,6 +81,7 @@ {{ __('portal.shop.login') }} {{ __('portal.shop.register') }} @endauth + @include('partials.lang-switcher')
diff --git a/resources/views/tracking/show.blade.php b/resources/views/tracking/show.blade.php index cf152ca..aaeab97 100644 --- a/resources/views/tracking/show.blade.php +++ b/resources/views/tracking/show.blade.php @@ -82,7 +82,10 @@ -
+
+
+ @include('partials.lang-switcher') +
@if ($logoUrl)@endif

{{ $tenant->display_name ?? $tenant->name }}

{{ __('portal.tracking.title_fisa', ['number' => $wo->number]) }}