feat: language switcher on portal + apply_margin re-added to Plată & total

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) <noreply@anthropic.com>
This commit is contained in:
2026-07-13 19:42:00 +00:00
parent 113610ea8f
commit 57bdc1b594
7 changed files with 60 additions and 1 deletions
@@ -21,6 +21,9 @@ input:focus { border-color: #3b82f6; }
</head>
<body>
<div class="card">
<div style="display:flex;justify-content:flex-end;margin-bottom:12px;">
@include('partials.lang-switcher', ['style' => 'light'])
</div>
<h1>{{ __('portal.invitation.welcome_name', ['name' => $name]) }}</h1>
<p class="sub">{!! __('portal.invitation.welcome_body', ['company' => '<strong>' . e($company) . '</strong>']) !!}</p>
@@ -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')
<div style="display:inline-flex;align-items:center;gap:2px;background:rgba(255,255,255,.15);border-radius:8px;padding:2px;font-size:12px;">
@foreach ($locales as $code => $meta)
<form method="POST" action="{{ url('/locale/' . $code) }}" style="margin:0;">
@csrf
<input type="hidden" name="_redirect_back" value="1">
<button type="submit" title="{{ $meta['full'] }}"
style="background:{{ $code === $current ? 'rgba(255,255,255,.95)' : 'transparent' }};
color:{{ $code === $current ? '#1f2937' : '#fff' }};
border:0;padding:5px 10px;border-radius:6px;cursor:pointer;font-size:12px;font-weight:600;
font-family:inherit;">
{{ $meta['label'] }}
</button>
</form>
@endforeach
</div>
@else
{{-- light style for pale backgrounds (invitations, auth pages) --}}
<div style="display:inline-flex;gap:4px;font-size:12px;">
@foreach ($locales as $code => $meta)
<form method="POST" action="{{ url('/locale/' . $code) }}" style="margin:0;">
@csrf
<button type="submit" title="{{ $meta['full'] }}"
style="background:{{ $code === $current ? '#3b82f6' : 'transparent' }};
color:{{ $code === $current ? '#fff' : '#4b5563' }};
border:1px solid {{ $code === $current ? '#3b82f6' : '#d1d5db' }};
padding:4px 10px;border-radius:6px;cursor:pointer;font-size:12px;font-weight:600;
font-family:inherit;">
{{ $meta['label'] }}
</button>
</form>
@endforeach
</div>
@endif
+1
View File
@@ -81,6 +81,7 @@
<a href="/shop/login">{{ __('portal.shop.login') }}</a>
<a href="/shop/register" style="background:rgba(255,255,255,.2);border-radius:6px;padding:4px 10px;">{{ __('portal.shop.register') }}</a>
@endauth
@include('partials.lang-switcher')
</nav>
</div>
</header>
+4 -1
View File
@@ -82,7 +82,10 @@
</style>
</head>
<body>
<header>
<header style="position:relative;">
<div style="position:absolute;top:14px;right:16px;">
@include('partials.lang-switcher')
</div>
@if ($logoUrl)<img src="{{ $logoUrl }}" alt="">@endif
<h1>{{ $tenant->display_name ?? $tenant->name }}</h1>
<div class="num">{{ __('portal.tracking.title_fisa', ['number' => $wo->number]) }}</div>