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:
@@ -114,6 +114,11 @@ class WorkOrderResource extends Resource
|
|||||||
->schema([
|
->schema([
|
||||||
Forms\Components\Select::make('pay_status')->options(WorkOrder::PAY_STATUSES)->default('unpaid')->required(),
|
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\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')
|
Forms\Components\TextInput::make('override_margin_pct')->label('Marjă internă (%) — override')
|
||||||
->numeric()->step(0.01)->minValue(0)->maxValue(90)
|
->numeric()->step(0.01)->minValue(0)->maxValue(90)
|
||||||
->placeholder('Ex: 25')
|
->placeholder('Ex: 25')
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ return [
|
|||||||
'required' => '*',
|
'required' => '*',
|
||||||
'currency_mdl' => 'MDL',
|
'currency_mdl' => 'MDL',
|
||||||
'powered_by' => 'Powered by AutoCRM',
|
'powered_by' => 'Powered by AutoCRM',
|
||||||
|
'language' => 'Limbă',
|
||||||
],
|
],
|
||||||
|
|
||||||
// ─── Invitation flow ───
|
// ─── Invitation flow ───
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ return [
|
|||||||
'required' => '*',
|
'required' => '*',
|
||||||
'currency_mdl' => 'MDL',
|
'currency_mdl' => 'MDL',
|
||||||
'powered_by' => 'Работает на AutoCRM',
|
'powered_by' => 'Работает на AutoCRM',
|
||||||
|
'language' => 'Язык',
|
||||||
],
|
],
|
||||||
|
|
||||||
// ─── Приглашение ───
|
// ─── Приглашение ───
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ input:focus { border-color: #3b82f6; }
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="card">
|
<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>
|
<h1>{{ __('portal.invitation.welcome_name', ['name' => $name]) }}</h1>
|
||||||
<p class="sub">{!! __('portal.invitation.welcome_body', ['company' => '<strong>' . e($company) . '</strong>']) !!}</p>
|
<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
|
||||||
@@ -81,6 +81,7 @@
|
|||||||
<a href="/shop/login">{{ __('portal.shop.login') }}</a>
|
<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>
|
<a href="/shop/register" style="background:rgba(255,255,255,.2);border-radius:6px;padding:4px 10px;">{{ __('portal.shop.register') }}</a>
|
||||||
@endauth
|
@endauth
|
||||||
|
@include('partials.lang-switcher')
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
@@ -82,7 +82,10 @@
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<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
|
@if ($logoUrl)<img src="{{ $logoUrl }}" alt="">@endif
|
||||||
<h1>{{ $tenant->display_name ?? $tenant->name }}</h1>
|
<h1>{{ $tenant->display_name ?? $tenant->name }}</h1>
|
||||||
<div class="num">{{ __('portal.tracking.title_fisa', ['number' => $wo->number]) }}</div>
|
<div class="num">{{ __('portal.tracking.title_fisa', ['number' => $wo->number]) }}</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user