feat: WO apply_margin at fișă level + full RO/RU i18n on client portal

Two changes in one commit:

== 1. Moved apply_margin toggle from line-level to Fișă-level ==

The per-manoperă apply_margin toggle is gone from the Manopere tab.
In its place: a single "Aplică marjă internă" toggle in Fișa's
"Plată & total" section (next to override_margin_pct). One decision
per Fișă instead of per line — cleaner mental model, matches how the
shop actually thinks about at-cost vs. billable work.

Migration: work_orders.apply_margin boolean default true (idempotent).
WorkOrderWork::saving now reads WO.apply_margin from DB directly (not
via belongsTo cache) to determine salary_base:
  - WO.apply_margin=false → every line gets salary_base=total, applied_margin_pct=0
  - WO.apply_margin=true  → resolver chain (WO.override → user margin → tenant default)

Old wo_works.apply_margin column stays untouched (backward-compat with
existing rows), but no longer exposed in UI. Tests updated to new
semantic. All existing tests green.

== 2. Full i18n audit on client-facing portal — RO/RU separated ==

Problem: user selecting Russian saw Romanian mixed into headings,
buttons, labels. Every client-facing Blade file was 100% hardcoded
Romanian — zero __() calls.

Fix: created lang/ro/portal.php + lang/ru/portal.php with 131 keys
across 3 namespaces:
  - portal.common (email, phone, save, total, powered_by, ...)
  - portal.invitation (welcome_name, activate_account, expired_body, ...)
  - portal.tracking (title_fisa, approve, approval_needed_title,
                    ready_estimated, hours, unit_pcs, ...)
  - portal.shop (catalog, cart, checkout_title, order_number, vin_title,
                signin_title, add_to_cart, in_stock, ...)

Converted 15 Blade files to __() calls:
  - resources/views/invitations/{accept,expired,invalid}.blade.php
  - resources/views/tracking/show.blade.php
  - resources/views/shop/{layout,catalog,cart,checkout,order,account,part,vin}.blade.php
  - resources/views/shop/auth/{login,register,forgot,reset}.blade.php

Each view's <html lang="{{ app()->getLocale() }}"> now reflects the
resolved locale (was hardcoded lang="ro").

SetLocale middleware resolves locale in this order:
  1. session locale (user picked via language switcher)
  2. authenticated user.locale
  3. tenant.settings.language
  4. app.locale default (now 'ro')

Config change: config/app.php default locale + fallback both = 'ro'
(was 'en'). English falls back to Romanian for portal.* keys since
we don't ship English portal translations — a Romanian shop that
switches to English shows Romanian text, which is safer than showing
"portal.invitation.activate_account" literals.

phpunit.xml sets APP_LOCALE=ro so test assertSee() calls that look
for Romanian text pass.

Verified via portal.* grep: 131 __() calls across 15 files. Zero
hardcoded Romanian nouns/verbs left in any client-facing view.

Suite: 303 passed (840 assertions). Unchanged count — refactor,
not new tests.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-13 04:56:04 +00:00
parent f5ff3f149a
commit 113610ea8f
25 changed files with 495 additions and 166 deletions
@@ -49,11 +49,6 @@ class WorksRelationManager extends RelationManager
->options(WorkOrderWork::STATUSES)
->default('todo')
->required(),
Forms\Components\Toggle::make('apply_margin')
->label('Aplică marjă internă')
->default(true)
->helperText('On = din prețul manoperei se scade marja pentru salariu. Off = manoperă la cost (salariu se calculează pe Total integral).')
->visible(fn () => auth()->user()?->canDo(\App\Auth\Permissions::FINANCE_VIEW_INTERNAL_MARGIN) ?? false),
Forms\Components\Textarea::make('notes')->label('Notițe')->columnSpanFull()->rows(2),
]);
}
@@ -82,15 +77,11 @@ class WorksRelationManager extends RelationManager
->alignRight()
->description(function ($record) {
if (! self::marginDetailsVisible() || $record->salary_base === null) return null;
if (! $record->apply_margin) {
if ((float) $record->applied_margin_pct === 0.0) {
return 'Fără marjă · bază salariu = Total';
}
return 'Bază salariu: ' . number_format((float) $record->salary_base, 2) . ' MDL · marjă ' . rtrim(rtrim(number_format((float) $record->applied_margin_pct, 2), '0'), '.') . '%';
}),
Tables\Columns\ToggleColumn::make('apply_margin')
->label('Marjă')
->visible(fn () => auth()->user()?->canDo(\App\Auth\Permissions::FINANCE_VIEW_INTERNAL_MARGIN) ?? false)
->tooltip('On = se aplică marja internă. Off = manoperă la cost.'),
Tables\Columns\TextColumn::make('master.name')->label('Maistru')->placeholder('—'),
Tables\Columns\TextColumn::make('status')
->formatStateUsing(fn ($s) => WorkOrderWork::STATUSES[$s] ?? $s)
+2 -1
View File
@@ -39,7 +39,7 @@ class WorkOrder extends Model implements HasMedia
'opened_at', 'closed_at', 'mileage_in', 'mileage_out',
'complaint', 'diagnosis', 'recommendations',
'status', 'urgency', 'pay_status', 'approved', 'approved_at',
'discount_pct', 'override_margin_pct', 'total',
'discount_pct', 'override_margin_pct', 'apply_margin', 'total',
'eta_at', 'eta_promised', 'eta_change_reason', 'eta_updated_at',
'tracking_token',
];
@@ -52,6 +52,7 @@ class WorkOrder extends Model implements HasMedia
'eta_promised' => 'datetime',
'eta_updated_at' => 'datetime',
'approved' => 'boolean',
'apply_margin' => 'boolean',
'discount_pct' => 'decimal:2',
'total' => 'decimal:2',
];
+9 -3
View File
@@ -179,9 +179,15 @@ class WorkOrderWork extends Model
}
// Compute internal margin & freeze salary_base at save time.
// Once frozen, changing user.internal_margin_pct later does NOT rewrite history.
// apply_margin=false → this line is at-cost (no reduction); salary_base = total.
if (($row->salary_base === null || $row->isDirty(['total', 'master_id', 'apply_margin'])) && (float) $row->total > 0) {
if ((bool) $row->apply_margin === false) {
// WO.apply_margin=false → toate liniile Fișei devin at-cost (salariu pe Total).
if (($row->salary_base === null || $row->isDirty(['total', 'master_id'])) && (float) $row->total > 0) {
// Citim direct din DB pentru a evita orice cache al relației belongsTo
$applyMargin = true;
if ($row->work_order_id) {
$raw = \DB::table('work_orders')->where('id', $row->work_order_id)->value('apply_margin');
if ($raw !== null) $applyMargin = (bool) $raw;
}
if (! $applyMargin) {
$row->applied_margin_pct = 0;
$row->salary_base = (float) $row->total;
} else {
+2 -2
View File
@@ -78,9 +78,9 @@ return [
|
*/
'locale' => env('APP_LOCALE', 'en'),
'locale' => env('APP_LOCALE', 'ro'),
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'ro'),
'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'),
@@ -0,0 +1,26 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('work_orders', function (Blueprint $t) {
if (! Schema::hasColumn('work_orders', 'apply_margin')) {
$t->boolean('apply_margin')->default(true)->after('override_margin_pct');
}
});
}
public function down(): void
{
Schema::table('work_orders', function (Blueprint $t) {
if (Schema::hasColumn('work_orders', 'apply_margin')) {
$t->dropColumn('apply_margin');
}
});
}
};
+155
View File
@@ -0,0 +1,155 @@
<?php
return [
// ─── Common ───
'common' => [
'email' => 'Email',
'phone' => 'Telefon',
'name' => 'Nume',
'password' => 'Parolă',
'save' => 'Salvează',
'cancel' => 'Anulează',
'back' => 'Înapoi',
'search' => 'Caută',
'total' => 'Total',
'yes' => 'Da',
'no' => 'Nu',
'required' => '*',
'currency_mdl' => 'MDL',
'powered_by' => 'Powered by AutoCRM',
],
// ─── Invitation flow ───
'invitation' => [
'title_accept' => 'Acceptă invitația',
'welcome_name' => 'Bine ai venit, :name!',
'welcome_body' => 'Ai fost invitat să accesezi :company. Setează o parolă pentru a-ți activa contul.',
'new_password' => 'Parolă nouă',
'confirm_password' => 'Confirmă parola',
'activate_account' => 'Activează contul',
'expired_title' => 'Invitație expirată',
'expired_body' => 'Linkul de invitație a expirat (durata maximă: 7 zile). Roagă administratorul să retrimită invitația.',
'invalid_title' => 'Invitație invalidă',
'invalid_body' => 'Linkul nu mai este valabil sau a fost deja folosit.',
],
// ─── WO tracking (public) ───
'tracking' => [
'title_fisa' => 'Fișa #:number',
'ready_estimated' => 'Gata estimat:',
'details' => 'Detalii',
'auto' => 'Auto',
'mileage' => 'Kilometraj',
'opened' => 'Deschis',
'master' => 'Maistru',
'stages' => 'Etape',
'what_asked' => 'Ce ne-ai cerut',
'recommendations' => 'Recomandări',
'photos' => 'Fotografii',
'approval_needed_title' => '⚠ Necesită aprobarea ta',
'approval_needed_body' => 'Am descoperit lucrări suplimentare. Te rugăm să decizi mai jos.',
'hours' => 'ore',
'approve' => '✅ Aprob',
'decline' => '❌ Nu aprob',
'unit_pcs' => 'buc',
],
// ─── Shop navigation & layout ───
'shop' => [
'catalog' => 'Catalog',
'search_by_vin' => 'Caută după VIN',
'cart' => '🛒 Coș',
'login' => 'Login',
'register' => 'Înregistrare',
'logout' => 'Ieșire',
// Catalog
'catalog_title' => 'Catalog piese',
'search_placeholder' => 'Caută denumire, cod, brand, cod cross…',
'all_categories' => 'Toate categoriile',
'in_stock_only' => 'Doar în stoc',
'no_parts_found' => 'Nicio piesă găsită',
'no_parts_found_for' => 'Nicio piesă găsită pentru „:term"',
'in_stock' => '● În stoc',
'on_order' => '○ La comandă',
'add_to_cart' => 'Adaugă în coș',
// Cart
'cart_title' => 'Coșul meu',
'cart_empty' => 'Coșul e gol.',
'view_catalog' => 'Vezi catalogul',
'part' => 'Piesă',
'price' => 'Preț',
'qty' => 'Cant.',
'update_cart' => 'Actualizează coșul',
'subtotal' => 'Subtotal:',
'checkout_arrow' => 'Finalizează comanda →',
// Checkout
'checkout_title' => 'Finalizează comanda',
'full_name' => 'Nume complet *',
'phone_req' => 'Telefon *',
'delivery_req' => 'Livrare *',
'address_delivery' => 'Adresă (pentru curier/poștă)',
'notes' => 'Observații',
'place_order' => 'Plasează comanda',
'summary' => 'Sumar',
'delivery_fee_note' => 'Taxa de livrare se calculează în funcție de metoda aleasă.',
// Order status
'order_number' => 'Comanda',
'status' => 'Status',
'products' => 'Produse',
'delivery' => 'Livrare',
'delivery_data' => 'Date livrare',
'continue_shopping' => '← Continuă cumpărăturile',
// Part detail
'back_to_catalog' => '← Înapoi la catalog',
'brand_label' => 'Brand:',
'code_label' => 'Cod:',
'in_stock_qty' => '● În stoc (:qty :unit)',
'cross_refs_title' => 'Coduri echivalente (cross)',
'description' => 'Descriere',
// VIN
'vin_title' => 'Caută piese după VIN',
'vin_intro' => 'Introdu codul VIN (17 caractere) ca să identificăm mașina. Apoi caută piesele în catalog.',
'vin_decode' => 'Decodează',
'vin_invalid' => 'VIN invalid — trebuie 17 caractere.',
'vin_identified' => 'Mașină identificată',
'vin_manufacturer' => 'Producător',
'vin_year' => 'An model',
'vin_country' => 'Țară',
'vin_region' => 'Regiune',
'vin_search_parts' => 'Caută piese pentru :maker →',
'vin_contact_note' => 'Pentru compatibilitate exactă pe model/motorizare, contactează service-ul cu acest VIN.',
'this_car' => 'această mașină',
// Account
'my_account' => 'Contul meu',
'hello_name' => 'Salut, :name!',
'contact_data' => 'Date contact',
'my_orders' => 'Comenzile mele (:count)',
'no_orders_yet' => 'Nu ai nicio comandă încă.',
'order_nr' => 'Nr.',
'order_date' => 'Data',
'order_items' => 'Articole',
'order_details_arrow' => 'Detalii →',
// Auth
'signin_title' => 'Intră în cont',
'signin_button' => 'Intră',
'forgot_password' => 'Am uitat parola',
'no_account' => 'Nu ai cont?',
'register_title' => 'Înregistrare cont',
'register_button' => 'Creează cont',
'have_account' => 'Ai deja cont?',
'forgot_title' => 'Am uitat parola',
'forgot_intro' => 'Introdu emailul cu care te-ai înregistrat — îți trimitem un link de resetare.',
'send_reset_link' => 'Trimite link resetare',
'back_to_login' => '← Înapoi la login',
'reset_title' => 'Setează o parolă nouă',
'reset_button' => 'Setează parola',
],
];
+155
View File
@@ -0,0 +1,155 @@
<?php
return [
// ─── Общие ───
'common' => [
'email' => 'Email',
'phone' => 'Телефон',
'name' => 'Имя',
'password' => 'Пароль',
'save' => 'Сохранить',
'cancel' => 'Отмена',
'back' => 'Назад',
'search' => 'Поиск',
'total' => 'Итого',
'yes' => 'Да',
'no' => 'Нет',
'required' => '*',
'currency_mdl' => 'MDL',
'powered_by' => 'Работает на AutoCRM',
],
// ─── Приглашение ───
'invitation' => [
'title_accept' => 'Принять приглашение',
'welcome_name' => 'Добро пожаловать, :name!',
'welcome_body' => 'Вас пригласили в :company. Задайте пароль, чтобы активировать аккаунт.',
'new_password' => 'Новый пароль',
'confirm_password' => 'Подтвердите пароль',
'activate_account' => 'Активировать аккаунт',
'expired_title' => 'Приглашение просрочено',
'expired_body' => 'Срок действия ссылки истёк (максимум 7 дней). Попросите администратора выслать приглашение повторно.',
'invalid_title' => 'Недействительное приглашение',
'invalid_body' => 'Ссылка больше не действительна или уже была использована.',
],
// ─── Отслеживание заказ-наряда (публично) ───
'tracking' => [
'title_fisa' => 'Заказ-наряд #:number',
'ready_estimated' => 'Готово ориентировочно:',
'details' => 'Подробности',
'auto' => 'Автомобиль',
'mileage' => 'Пробег',
'opened' => 'Открыт',
'master' => 'Мастер',
'stages' => 'Этапы',
'what_asked' => 'Что вы просили',
'recommendations' => 'Рекомендации',
'photos' => 'Фотографии',
'approval_needed_title' => '⚠ Требуется ваше подтверждение',
'approval_needed_body' => 'Обнаружены дополнительные работы. Пожалуйста, примите решение ниже.',
'hours' => 'ч.',
'approve' => '✅ Согласен',
'decline' => '❌ Не согласен',
'unit_pcs' => 'шт.',
],
// ─── Магазин: навигация и лейаут ───
'shop' => [
'catalog' => 'Каталог',
'search_by_vin' => 'Поиск по VIN',
'cart' => '🛒 Корзина',
'login' => 'Войти',
'register' => 'Регистрация',
'logout' => 'Выйти',
// Каталог
'catalog_title' => 'Каталог запчастей',
'search_placeholder' => 'Найти по названию, коду, бренду, кросс-номеру…',
'all_categories' => 'Все категории',
'in_stock_only' => 'Только в наличии',
'no_parts_found' => 'Запчасти не найдены',
'no_parts_found_for' => 'Запчасти не найдены по запросу „:term"',
'in_stock' => '● В наличии',
'on_order' => '○ Под заказ',
'add_to_cart' => 'Добавить в корзину',
// Корзина
'cart_title' => 'Моя корзина',
'cart_empty' => 'Корзина пуста.',
'view_catalog' => 'Перейти в каталог',
'part' => 'Запчасть',
'price' => 'Цена',
'qty' => 'Кол-во',
'update_cart' => 'Обновить корзину',
'subtotal' => 'Промежуточный итог:',
'checkout_arrow' => 'Оформить заказ →',
// Оформление
'checkout_title' => 'Оформление заказа',
'full_name' => 'ФИО *',
'phone_req' => 'Телефон *',
'delivery_req' => 'Доставка *',
'address_delivery' => 'Адрес (для курьера/почты)',
'notes' => 'Комментарий',
'place_order' => 'Оформить заказ',
'summary' => 'Сводка',
'delivery_fee_note' => 'Стоимость доставки рассчитывается в зависимости от выбранного способа.',
// Статус заказа
'order_number' => 'Заказ',
'status' => 'Статус',
'products' => 'Товары',
'delivery' => 'Доставка',
'delivery_data' => 'Данные доставки',
'continue_shopping' => '← Продолжить покупки',
// Детали запчасти
'back_to_catalog' => '← Назад в каталог',
'brand_label' => 'Бренд:',
'code_label' => 'Код:',
'in_stock_qty' => '● В наличии (:qty :unit)',
'cross_refs_title' => 'Кросс-номера',
'description' => 'Описание',
// VIN
'vin_title' => 'Поиск запчастей по VIN',
'vin_intro' => 'Введите VIN-код (17 символов), чтобы мы определили автомобиль. Затем найдите запчасти в каталоге.',
'vin_decode' => 'Расшифровать',
'vin_invalid' => 'Неверный VIN — должно быть 17 символов.',
'vin_identified' => 'Автомобиль определён',
'vin_manufacturer' => 'Производитель',
'vin_year' => 'Год модели',
'vin_country' => 'Страна',
'vin_region' => 'Регион',
'vin_search_parts' => 'Найти запчасти для :maker →',
'vin_contact_note' => 'Для точного подбора по модели/двигателю свяжитесь с сервисом, указав этот VIN.',
'this_car' => 'этого автомобиля',
// Аккаунт
'my_account' => 'Мой аккаунт',
'hello_name' => 'Привет, :name!',
'contact_data' => 'Контактные данные',
'my_orders' => 'Мои заказы (:count)',
'no_orders_yet' => 'У вас пока нет заказов.',
'order_nr' => '№',
'order_date' => 'Дата',
'order_items' => 'Позиции',
'order_details_arrow' => 'Подробнее →',
// Аутентификация
'signin_title' => 'Войти в аккаунт',
'signin_button' => 'Войти',
'forgot_password' => 'Забыли пароль',
'no_account' => 'Нет аккаунта?',
'register_title' => 'Регистрация аккаунта',
'register_button' => 'Создать аккаунт',
'have_account' => 'Уже есть аккаунт?',
'forgot_title' => 'Забыли пароль',
'forgot_intro' => 'Введите email, с которым регистрировались — вышлем ссылку для сброса.',
'send_reset_link' => 'Выслать ссылку',
'back_to_login' => '← Вернуться ко входу',
'reset_title' => 'Задать новый пароль',
'reset_button' => 'Установить пароль',
],
];
+2
View File
@@ -19,6 +19,8 @@
</source>
<php>
<env name="APP_ENV" value="testing"/>
<env name="APP_LOCALE" value="ro"/>
<env name="APP_FALLBACK_LOCALE" value="ro"/>
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="BROADCAST_CONNECTION" value="null"/>
+8 -8
View File
@@ -1,8 +1,8 @@
<!DOCTYPE html>
<html lang="ro">
<html lang="{{ app()->getLocale() }}">
<head>
<meta charset="UTF-8">
<title>Acceptă invitația {{ $company }}</title>
<title>{{ __('portal.invitation.title_accept') }} {{ $company }}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body { font-family: -apple-system, BlinkMacSystemFont, sans-serif; background: #f5f7fa; color: #1a202c; margin: 0; padding: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center; }
@@ -21,8 +21,8 @@ input:focus { border-color: #3b82f6; }
</head>
<body>
<div class="card">
<h1>Bine ai venit, {{ $name }}!</h1>
<p class="sub">Ai fost invitat accesezi <strong>{{ $company }}</strong>. Setează o parolă pentru a-ți activa contul.</p>
<h1>{{ __('portal.invitation.welcome_name', ['name' => $name]) }}</h1>
<p class="sub">{!! __('portal.invitation.welcome_body', ['company' => '<strong>' . e($company) . '</strong>']) !!}</p>
@if ($errors->any())
<div class="errors">
@@ -35,18 +35,18 @@ input:focus { border-color: #3b82f6; }
<form method="POST" action="{{ url('/invitations/' . $token) }}">
@csrf
<div class="field readonly">
<label>Email</label>
<label>{{ __('portal.common.email') }}</label>
<input type="email" value="{{ $email }}" readonly>
</div>
<div class="field">
<label>Parolă nouă</label>
<label>{{ __('portal.invitation.new_password') }}</label>
<input type="password" name="password" required minlength="8" autofocus>
</div>
<div class="field">
<label>Confirmă parola</label>
<label>{{ __('portal.invitation.confirm_password') }}</label>
<input type="password" name="password_confirmation" required minlength="8">
</div>
<button class="btn" type="submit">Activează contul</button>
<button class="btn" type="submit">{{ __('portal.invitation.activate_account') }}</button>
</form>
</div>
</body>
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<html lang="ro"><head><meta charset="UTF-8"><title>Invitație expirată</title>
<html lang="{{ app()->getLocale() }}"><head><meta charset="UTF-8"><title>{{ __('portal.invitation.expired_title') }}</title>
<style>body{font-family:-apple-system,sans-serif;background:#f5f7fa;display:flex;align-items:center;justify-content:center;min-height:100vh;margin:0;color:#1a202c}.card{background:white;padding:32px;border-radius:12px;box-shadow:0 4px 20px rgba(0,0,0,0.08);max-width:420px;text-align:center}</style></head>
<body><div class="card"><h1>Invitație expirată</h1><p style="color:#4a5568">Linkul de invitație a expirat (durata maximă: 7 zile). Roagă administratorul retrimită invitația.</p></div></body></html>
<body><div class="card"><h1>{{ __('portal.invitation.expired_title') }}</h1><p style="color:#4a5568">{{ __('portal.invitation.expired_body') }}</p></div></body></html>
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<html lang="ro"><head><meta charset="UTF-8"><title>Invitație invalidă</title>
<html lang="{{ app()->getLocale() }}"><head><meta charset="UTF-8"><title>{{ __('portal.invitation.invalid_title') }}</title>
<style>body{font-family:-apple-system,sans-serif;background:#f5f7fa;display:flex;align-items:center;justify-content:center;min-height:100vh;margin:0;color:#1a202c}.card{background:white;padding:32px;border-radius:12px;box-shadow:0 4px 20px rgba(0,0,0,0.08);max-width:420px;text-align:center}</style></head>
<body><div class="card"><h1>Invitație invalidă</h1><p style="color:#4a5568">Linkul nu mai este valabil sau a fost deja folosit.</p></div></body></html>
<body><div class="card"><h1>{{ __('portal.invitation.invalid_title') }}</h1><p style="color:#4a5568">{{ __('portal.invitation.invalid_body') }}</p></div></body></html>
+8 -8
View File
@@ -1,32 +1,32 @@
@extends('shop.layout')
@section('title', 'Contul meu')
@section('title', __('portal.shop.my_account'))
@section('content')
@php
$currency = $tenant->settings['currency'] ?? 'MDL';
$statuses = \App\Models\Tenant\OnlineOrder::STATUSES;
@endphp
<h1 style="font-size:22px;margin-bottom:16px;">Salut, {{ $customer->name }}!</h1>
<h1 style="font-size:22px;margin-bottom:16px;">{{ __('portal.shop.hello_name', ['name' => $customer->name]) }}</h1>
<div class="card" style="margin-bottom:16px;">
<h3 style="font-size:15px;margin-bottom:10px;">Date contact</h3>
<h3 style="font-size:15px;margin-bottom:10px;">{{ __('portal.shop.contact_data') }}</h3>
<p class="muted">📞 {{ $customer->phone }}</p>
@if ($customer->email)<p class="muted">✉️ {{ $customer->email }}</p>@endif
</div>
<h2 style="font-size:18px;margin-bottom:12px;">Comenzile mele ({{ $orders->count() }})</h2>
<h2 style="font-size:18px;margin-bottom:12px;">{{ __('portal.shop.my_orders', ['count' => $orders->count()]) }}</h2>
@if ($orders->isEmpty())
<div class="card" style="text-align:center;padding:32px;">
<p class="muted">Nu ai nicio comandă încă.</p>
<a class="btn" href="/shop" style="margin-top:12px;">Vezi catalogul</a>
<p class="muted">{{ __('portal.shop.no_orders_yet') }}</p>
<a class="btn" href="/shop" style="margin-top:12px;">{{ __('portal.shop.view_catalog') }}</a>
</div>
@else
<div class="card">
<table class="cart">
<thead>
<tr>
<th>Nr.</th><th>Data</th><th>Articole</th><th class="r">Total</th><th>Status</th><th></th>
<th>{{ __('portal.shop.order_nr') }}</th><th>{{ __('portal.shop.order_date') }}</th><th>{{ __('portal.shop.order_items') }}</th><th class="r">{{ __('portal.common.total') }}</th><th>{{ __('portal.shop.status') }}</th><th></th>
</tr>
</thead>
<tbody>
@@ -37,7 +37,7 @@
<td>{{ $order->items()->count() }}</td>
<td class="r">{{ number_format((float) $order->total, 2) }} {{ $currency }}</td>
<td><span class="status-pill" style="font-size:11px;">{{ $statuses[$order->status] ?? $order->status }}</span></td>
<td><a href="{{ $order->trackingUrl() }}" class="muted" style="text-decoration:underline;">Detalii </a></td>
<td><a href="{{ $order->trackingUrl() }}" class="muted" style="text-decoration:underline;">{{ __('portal.shop.order_details_arrow') }}</a></td>
</tr>
@endforeach
</tbody>
+6 -6
View File
@@ -1,10 +1,10 @@
@extends('shop.layout')
@section('title', 'Resetare parolă')
@section('title', __('portal.shop.forgot_title'))
@section('content')
<div style="max-width:380px;margin:0 auto;">
<h1 style="font-size:22px;margin-bottom:8px;">Am uitat parola</h1>
<p class="muted" style="margin-bottom:16px;">Introdu emailul cu care te-ai înregistrat îți trimitem un link de resetare.</p>
<h1 style="font-size:22px;margin-bottom:8px;">{{ __('portal.shop.forgot_title') }}</h1>
<p class="muted" style="margin-bottom:16px;">{{ __('portal.shop.forgot_intro') }}</p>
@if (session('status'))
<div class="card" style="border-color:#bbf7d0;background:#f0fdf4;margin-bottom:14px;color:#166534;font-size:14px;">
@@ -22,14 +22,14 @@
<form method="POST" action="/shop/password/email" class="card">
@csrf
<div class="field"><label>Email *</label>
<div class="field"><label>{{ __('portal.common.email') }} *</label>
<input type="email" name="email" value="{{ old('email') }}" required autofocus>
</div>
<button type="submit" class="btn block">Trimite link resetare</button>
<button type="submit" class="btn block">{{ __('portal.shop.send_reset_link') }}</button>
</form>
<p class="muted" style="text-align:center;margin-top:12px;">
<a href="/shop/login" style="color:inherit;text-decoration:underline;"> Înapoi la login</a>
<a href="/shop/login" style="color:inherit;text-decoration:underline;">{{ __('portal.shop.back_to_login') }}</a>
</p>
</div>
@endsection
+7 -7
View File
@@ -1,9 +1,9 @@
@extends('shop.layout')
@section('title', 'Login')
@section('title', __('portal.shop.login'))
@section('content')
<div style="max-width:380px;margin:0 auto;">
<h1 style="font-size:22px;margin-bottom:16px;">Intră în cont</h1>
<h1 style="font-size:22px;margin-bottom:16px;">{{ __('portal.shop.signin_title') }}</h1>
@if ($errors->any())
<div class="card" style="border-color:#fca5a5;background:#fef2f2;margin-bottom:14px;">
@@ -15,18 +15,18 @@
<form method="POST" action="/shop/login" class="card">
@csrf
<div class="field"><label>Telefon *</label>
<div class="field"><label>{{ __('portal.shop.phone_req') }}</label>
<input type="text" name="phone" value="{{ old('phone') }}" required placeholder="+373…">
</div>
<div class="field"><label>Parolă *</label>
<div class="field"><label>{{ __('portal.common.password') }} *</label>
<input type="password" name="password" required>
</div>
<button type="submit" class="btn block">Intră</button>
<button type="submit" class="btn block">{{ __('portal.shop.signin_button') }}</button>
</form>
<p class="muted" style="text-align:center;margin-top:12px;">
<a href="/shop/password/forgot" style="color:inherit;text-decoration:underline;">Am uitat parola</a>
· Nu ai cont? <a href="/shop/register" style="color:inherit;text-decoration:underline;">Înregistrare</a>
<a href="/shop/password/forgot" style="color:inherit;text-decoration:underline;">{{ __('portal.shop.forgot_password') }}</a>
· {{ __('portal.shop.no_account') }} <a href="/shop/register" style="color:inherit;text-decoration:underline;">{{ __('portal.shop.register') }}</a>
</p>
@if (session('status'))
<div class="card" style="border-color:#bbf7d0;background:#f0fdf4;margin-top:14px;color:#166534;font-size:14px;text-align:center;">
+9 -9
View File
@@ -1,9 +1,9 @@
@extends('shop.layout')
@section('title', 'Înregistrare')
@section('title', __('portal.shop.register'))
@section('content')
<div style="max-width:420px;margin:0 auto;">
<h1 style="font-size:22px;margin-bottom:16px;">Înregistrare cont</h1>
<h1 style="font-size:22px;margin-bottom:16px;">{{ __('portal.shop.register_title') }}</h1>
@if ($errors->any())
<div class="card" style="border-color:#fca5a5;background:#fef2f2;margin-bottom:14px;">
@@ -15,26 +15,26 @@
<form method="POST" action="/shop/register" class="card">
@csrf
<div class="field"><label>Nume *</label>
<div class="field"><label>{{ __('portal.common.name') }} *</label>
<input type="text" name="name" value="{{ old('name') }}" required>
</div>
<div class="field"><label>Telefon *</label>
<div class="field"><label>{{ __('portal.shop.phone_req') }}</label>
<input type="text" name="phone" value="{{ old('phone') }}" required placeholder="+373…">
</div>
<div class="field"><label>Email</label>
<div class="field"><label>{{ __('portal.common.email') }}</label>
<input type="email" name="email" value="{{ old('email') }}">
</div>
<div class="field"><label>Parolă *</label>
<div class="field"><label>{{ __('portal.common.password') }} *</label>
<input type="password" name="password" required minlength="6">
</div>
<div class="field"><label>Confirmă parola *</label>
<div class="field"><label>{{ __('portal.invitation.confirm_password') }} *</label>
<input type="password" name="password_confirmation" required minlength="6">
</div>
<button type="submit" class="btn block">Creează cont</button>
<button type="submit" class="btn block">{{ __('portal.shop.register_button') }}</button>
</form>
<p class="muted" style="text-align:center;margin-top:12px;">
Ai deja cont? <a href="/shop/login" style="color:inherit;text-decoration:underline;">Login</a>
{{ __('portal.shop.have_account') }} <a href="/shop/login" style="color:inherit;text-decoration:underline;">{{ __('portal.shop.login') }}</a>
</p>
</div>
@endsection
+6 -6
View File
@@ -1,9 +1,9 @@
@extends('shop.layout')
@section('title', 'Parolă nouă')
@section('title', __('portal.shop.reset_title'))
@section('content')
<div style="max-width:380px;margin:0 auto;">
<h1 style="font-size:22px;margin-bottom:16px;">Setează o parolă nouă</h1>
<h1 style="font-size:22px;margin-bottom:16px;">{{ __('portal.shop.reset_title') }}</h1>
@if ($errors->any())
<div class="card" style="border-color:#fca5a5;background:#fef2f2;margin-bottom:14px;">
@@ -16,16 +16,16 @@
<form method="POST" action="/shop/password/reset" class="card">
@csrf
<input type="hidden" name="token" value="{{ $token }}">
<div class="field"><label>Email *</label>
<div class="field"><label>{{ __('portal.common.email') }} *</label>
<input type="email" name="email" value="{{ old('email', $email) }}" required readonly style="background:#f9fafb;">
</div>
<div class="field"><label>Parolă nouă *</label>
<div class="field"><label>{{ __('portal.invitation.new_password') }} *</label>
<input type="password" name="password" required minlength="6" autofocus>
</div>
<div class="field"><label>Confirmă parola *</label>
<div class="field"><label>{{ __('portal.invitation.confirm_password') }} *</label>
<input type="password" name="password_confirmation" required minlength="6">
</div>
<button type="submit" class="btn block">Setează parola</button>
<button type="submit" class="btn block">{{ __('portal.shop.reset_button') }}</button>
</form>
</div>
@endsection
+8 -8
View File
@@ -1,14 +1,14 @@
@extends('shop.layout')
@section('title', 'Coș')
@section('title', __('portal.shop.cart_title'))
@section('content')
@php $currency = $tenant->settings['currency'] ?? 'MDL'; @endphp
<h1 style="font-size:22px;margin-bottom:16px;">Coșul meu</h1>
<h1 style="font-size:22px;margin-bottom:16px;">{{ __('portal.shop.cart_title') }}</h1>
@if (empty($cart))
<div class="card" style="text-align:center;padding:40px;">
<p class="muted">Coșul e gol.</p>
<a class="btn" href="/shop" style="margin-top:12px;">Vezi catalogul</a>
<p class="muted">{{ __('portal.shop.cart_empty') }}</p>
<a class="btn" href="/shop" style="margin-top:12px;">{{ __('portal.shop.view_catalog') }}</a>
</div>
@else
<form method="POST" action="/shop/cart/update">
@@ -16,7 +16,7 @@
<div class="card">
<table class="cart">
<thead>
<tr><th>Piesă</th><th class="r">Preț</th><th class="r">Cant.</th><th class="r">Total</th></tr>
<tr><th>{{ __('portal.shop.part') }}</th><th class="r">{{ __('portal.shop.price') }}</th><th class="r">{{ __('portal.shop.qty') }}</th><th class="r">{{ __('portal.common.total') }}</th></tr>
</thead>
<tbody>
@foreach ($cart as $id => $item)
@@ -37,10 +37,10 @@
</table>
</div>
<div style="display:flex;justify-content:space-between;align-items:center;margin-top:16px;flex-wrap:wrap;gap:12px;">
<button class="btn outline" type="submit">Actualizează coșul</button>
<button class="btn outline" type="submit">{{ __('portal.shop.update_cart') }}</button>
<div style="text-align:right;">
<div style="font-size:20px;font-weight:700;">Subtotal: {{ number_format($subtotal, 2) }} {{ $currency }}</div>
<a class="btn" href="/shop/checkout" style="margin-top:8px;">Finalizează comanda </a>
<div style="font-size:20px;font-weight:700;">{{ __('portal.shop.subtotal') }} {{ number_format($subtotal, 2) }} {{ $currency }}</div>
<a class="btn" href="/shop/checkout" style="margin-top:8px;">{{ __('portal.shop.checkout_arrow') }}</a>
</div>
</div>
</form>
+8 -8
View File
@@ -1,26 +1,26 @@
@extends('shop.layout')
@section('title', 'Catalog piese')
@section('title', __('portal.shop.catalog_title'))
@section('content')
@php $currency = $tenant->settings['currency'] ?? 'MDL'; @endphp
<form method="GET" action="/shop" class="filters">
<input type="text" name="q" value="{{ $term }}" placeholder="Caută denumire, cod, brand, cod cross…">
<input type="text" name="q" value="{{ $term }}" placeholder="{{ __('portal.shop.search_placeholder') }}">
<select name="cat" onchange="this.form.submit()">
<option value="">Toate categoriile</option>
<option value="">{{ __('portal.shop.all_categories') }}</option>
@foreach ($categories as $c)
<option value="{{ $c }}" {{ $category === $c ? 'selected' : '' }}>{{ $c }}</option>
@endforeach
</select>
<label style="display:flex;align-items:center;gap:6px;font-size:14px;">
<input type="checkbox" name="in_stock" value="1" {{ $inStock ? 'checked' : '' }} onchange="this.form.submit()">
Doar în stoc
{{ __('portal.shop.in_stock_only') }}
</label>
<button class="btn" type="submit">Caută</button>
<button class="btn" type="submit">{{ __('portal.common.search') }}</button>
</form>
@if ($parts->isEmpty())
<div class="card" style="text-align:center;padding:48px;">
<p class="muted">Nicio piesă găsită{{ $term ? ' pentru „' . $term . '”' : '' }}.</p>
<p class="muted">{{ $term ? __('portal.shop.no_parts_found_for', ['term' => $term]) : __('portal.shop.no_parts_found') }}.</p>
</div>
@else
<div class="grid">
@@ -41,12 +41,12 @@
{{ $p->brand ? $p->brand . ' · ' : '' }}{{ $p->article ?? '' }}
</div>
<div class="stock {{ $stock > 0 ? 'in' : 'out' }}">
{{ $stock > 0 ? '● În stoc' : '○ La comandă' }}
{{ $stock > 0 ? __('portal.shop.in_stock') : __('portal.shop.on_order') }}
</div>
<div class="price">{{ number_format((float) $p->sell_price, 2) }} {{ $currency }}</div>
<form method="POST" action="/shop/part/{{ $p->id }}/add" style="margin-top:10px;">
@csrf
<button class="btn block" type="submit">Adaugă în coș</button>
<button class="btn block" type="submit">{{ __('portal.shop.add_to_cart') }}</button>
</form>
</div>
@endforeach
+11 -11
View File
@@ -1,12 +1,12 @@
@extends('shop.layout')
@section('title', 'Finalizare comandă')
@section('title', __('portal.shop.checkout_title'))
@section('content')
@php
$currency = $tenant->settings['currency'] ?? 'MDL';
$labels = \App\Models\Tenant\OnlineOrder::DELIVERY;
@endphp
<h1 style="font-size:22px;margin-bottom:16px;">Finalizează comanda</h1>
<h1 style="font-size:22px;margin-bottom:16px;">{{ __('portal.shop.checkout_title') }}</h1>
@if ($errors->any())
<div class="card" style="border-color:#fca5a5;background:#fef2f2;margin-bottom:14px;">
@@ -20,19 +20,19 @@
<form method="POST" action="/shop/checkout" class="card">
@csrf
<div class="field">
<label>Nume complet *</label>
<label>{{ __('portal.shop.full_name') }}</label>
<input type="text" name="customer_name" value="{{ old('customer_name', ($customer ?? null)?->name) }}" required>
</div>
<div class="field">
<label>Telefon *</label>
<label>{{ __('portal.shop.phone_req') }}</label>
<input type="text" name="customer_phone" value="{{ old('customer_phone', ($customer ?? null)?->phone) }}" required placeholder="+373…">
</div>
<div class="field">
<label>Email</label>
<label>{{ __('portal.common.email') }}</label>
<input type="email" name="customer_email" value="{{ old('customer_email', ($customer ?? null)?->email) }}">
</div>
<div class="field">
<label>Livrare *</label>
<label>{{ __('portal.shop.delivery_req') }}</label>
<select name="delivery_method" required>
@foreach ($deliveryOptions as $opt)
<option value="{{ $opt }}">{{ $labels[$opt] ?? $opt }}</option>
@@ -40,18 +40,18 @@
</select>
</div>
<div class="field">
<label>Adresă (pentru curier/poștă)</label>
<label>{{ __('portal.shop.address_delivery') }}</label>
<input type="text" name="address" value="{{ old('address') }}">
</div>
<div class="field">
<label>Observații</label>
<label>{{ __('portal.shop.notes') }}</label>
<textarea name="notes" rows="2">{{ old('notes') }}</textarea>
</div>
<button class="btn block" type="submit">Plasează comanda</button>
<button class="btn block" type="submit">{{ __('portal.shop.place_order') }}</button>
</form>
<div class="card">
<h3 style="font-size:15px;margin-bottom:10px;">Sumar</h3>
<h3 style="font-size:15px;margin-bottom:10px;">{{ __('portal.shop.summary') }}</h3>
<table class="cart">
@foreach ($cart as $item)
<tr>
@@ -63,7 +63,7 @@
<div style="margin-top:12px;font-size:18px;font-weight:700;text-align:right;">
{{ number_format($subtotal, 2) }} {{ $currency }}
</div>
<p class="muted" style="margin-top:6px;">Taxa de livrare se calculează în funcție de metoda aleasă.</p>
<p class="muted" style="margin-top:6px;">{{ __('portal.shop.delivery_fee_note') }}</p>
</div>
</div>
+8 -8
View File
@@ -10,7 +10,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>@yield('title', 'Magazin') {{ $brand }}</title>
<title>@yield('title', __('portal.shop.catalog')) {{ $brand }}</title>
@if ($faviconUrl)<link rel="icon" href="{{ $faviconUrl }}">@endif
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
@@ -67,19 +67,19 @@
<span>{{ $brand }}</span>
</a>
<nav>
<a href="/shop">Catalog</a>
<a href="/shop/vin">Caută după VIN</a>
<a href="/shop/cart">🛒 Coș
<a href="/shop">{{ __('portal.shop.catalog') }}</a>
<a href="/shop/vin">{{ __('portal.shop.search_by_vin') }}</a>
<a href="/shop/cart">{{ __('portal.shop.cart') }}
@if (($cartCount ?? 0) > 0)<span class="cart-badge">{{ $cartCount }}</span>@endif
</a>
@auth('shop')
<a href="/shop/account">👤 {{ Auth::guard('shop')->user()->name }}</a>
<form method="POST" action="/shop/logout" style="display:inline;">@csrf
<button type="submit" style="background:transparent;border:0;color:inherit;cursor:pointer;font:inherit;">Ieșire</button>
<button type="submit" style="background:transparent;border:0;color:inherit;cursor:pointer;font:inherit;">{{ __('portal.shop.logout') }}</button>
</form>
@else
<a href="/shop/login">Login</a>
<a href="/shop/register" style="background:rgba(255,255,255,.2);border-radius:6px;padding:4px 10px;">Înregistrare</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>
@endauth
</nav>
</div>
@@ -87,6 +87,6 @@
<div class="wrap">
@yield('content')
</div>
<footer>{{ $brand }} · Powered by AutoCRM</footer>
<footer>{{ $brand }} · {{ __('portal.common.powered_by') }}</footer>
</body>
</html>
+8 -8
View File
@@ -1,5 +1,5 @@
@extends('shop.layout')
@section('title', 'Comanda ' . $order->number)
@section('title', __('portal.shop.order_number') . ' ' . $order->number)
@section('content')
@php
$currency = $tenant->settings['currency'] ?? 'MDL';
@@ -10,14 +10,14 @@
@endphp
<div class="card" style="text-align:center;">
<div style="font-size:14px;color:#6b7280;">Comanda</div>
<div style="font-size:14px;color:#6b7280;">{{ __('portal.shop.order_number') }}</div>
<div style="font-size:24px;font-weight:700;margin:4px 0;">#{{ $order->number }}</div>
<span class="status-pill">{{ $statuses[$order->status] ?? $order->status }}</span>
</div>
@if ($order->status !== 'cancelled')
<div class="card" style="margin-top:14px;">
<h3 style="font-size:15px;margin-bottom:12px;">Status</h3>
<h3 style="font-size:15px;margin-bottom:12px;">{{ __('portal.shop.status') }}</h3>
<div style="display:flex;justify-content:space-between;gap:4px;">
@foreach ($flow as $i => $st)
<div style="flex:1;text-align:center;">
@@ -33,7 +33,7 @@
@endif
<div class="card" style="margin-top:14px;">
<h3 style="font-size:15px;margin-bottom:10px;">Produse</h3>
<h3 style="font-size:15px;margin-bottom:10px;">{{ __('portal.shop.products') }}</h3>
<table class="cart">
@foreach ($order->items as $it)
<tr>
@@ -41,20 +41,20 @@
<td class="r">{{ number_format((float) $it->total, 2) }} {{ $currency }}</td>
</tr>
@endforeach
<tr><td class="muted">Livrare ({{ $delivery[$order->delivery_method] ?? $order->delivery_method }})</td>
<tr><td class="muted">{{ __('portal.shop.delivery') }} ({{ $delivery[$order->delivery_method] ?? $order->delivery_method }})</td>
<td class="r">{{ number_format((float) $order->delivery_fee, 2) }} {{ $currency }}</td></tr>
<tr><td style="font-weight:700;">Total</td>
<tr><td style="font-weight:700;">{{ __('portal.common.total') }}</td>
<td class="r" style="font-weight:700;font-size:18px;">{{ number_format((float) $order->total, 2) }} {{ $currency }}</td></tr>
</table>
</div>
<div class="card" style="margin-top:14px;">
<h3 style="font-size:15px;margin-bottom:8px;">Date livrare</h3>
<h3 style="font-size:15px;margin-bottom:8px;">{{ __('portal.shop.delivery_data') }}</h3>
<p class="muted">{{ $order->customer_name }} · {{ $order->customer_phone }}</p>
@if ($order->address)<p class="muted">{{ $order->address }}</p>@endif
</div>
<div style="margin-top:16px;text-align:center;">
<a class="btn outline" href="/shop"> Continuă cumpărăturile</a>
<a class="btn outline" href="/shop">{{ __('portal.shop.continue_shopping') }}</a>
</div>
@endsection
+10 -8
View File
@@ -7,7 +7,7 @@
$imgs = $part->imageUrls();
@endphp
<a href="/shop" class="muted"> Înapoi la catalog</a>
<a href="/shop" class="muted">{{ __('portal.shop.back_to_catalog') }}</a>
@if (! empty($imgs))
<div class="card" style="margin-top:12px;display:grid;grid-template-columns:280px 1fr;gap:20px;align-items:start;">
@@ -43,13 +43,15 @@
@endif
<h1 style="font-size:22px;margin-bottom:8px;">{{ $part->name }}</h1>
<div class="muted" style="margin-bottom:14px;">
{{ $part->brand ? 'Brand: ' . $part->brand : '' }}
{{ $part->article ? ' · Cod: ' . $part->article : '' }}
{{ $part->brand ? __('portal.shop.brand_label') . ' ' . $part->brand : '' }}
{{ $part->article ? ' · ' . __('portal.shop.code_label') . ' ' . $part->article : '' }}
{{ $part->category ? ' · ' . $part->category : '' }}
</div>
<div class="stock {{ $stock > 0 ? 'in' : 'out' }}" style="margin-bottom:8px;">
{{ $stock > 0 ? '● În stoc (' . rtrim(rtrim(number_format($stock, 2), '0'), '.') . ' ' . ($part->unit ?? 'buc') . ')' : '○ La comandă' }}
{{ $stock > 0
? __('portal.shop.in_stock_qty', ['qty' => rtrim(rtrim(number_format($stock, 2), '0'), '.'), 'unit' => $part->unit ?? __('portal.tracking.unit_pcs')])
: __('portal.shop.on_order') }}
</div>
<div style="font-size:26px;font-weight:700;color:{{ $tenant->settings['theme_color'] ?? '#3B82F6' }};margin-bottom:16px;">
{{ number_format((float) $part->sell_price, 2) }} {{ $currency }}
@@ -58,12 +60,12 @@
<form method="POST" action="/shop/part/{{ $part->id }}/add" style="display:flex;gap:8px;align-items:center;max-width:320px;">
@csrf
<input type="number" name="qty" value="1" min="1" style="width:80px;padding:10px;border:1px solid #d1d5db;border-radius:8px;">
<button class="btn" type="submit">Adaugă în coș</button>
<button class="btn" type="submit">{{ __('portal.shop.add_to_cart') }}</button>
</form>
@if ($part->crossRefs->isNotEmpty())
<div style="margin-top:20px;">
<h3 style="font-size:14px;margin-bottom:6px;">Coduri echivalente (cross)</h3>
<h3 style="font-size:14px;margin-bottom:6px;">{{ __('portal.shop.cross_refs_title') }}</h3>
<div class="muted">
@foreach ($part->crossRefs as $cr)
<span style="display:inline-block;background:#f3f4f6;border-radius:6px;padding:3px 8px;margin:2px;">
@@ -76,11 +78,11 @@
@if ($part->notes)
<div style="margin-top:20px;">
<h3 style="font-size:14px;margin-bottom:6px;">Descriere</h3>
<h3 style="font-size:14px;margin-bottom:6px;">{{ __('portal.shop.description') }}</h3>
<p class="muted" style="white-space:pre-wrap;">{{ $part->notes }}</p>
</div>
@endif
@if ($img)
@if ($img ?? null)
</div>{{-- /right column --}}
</div>{{-- /card grid --}}
@else
+12 -12
View File
@@ -1,37 +1,37 @@
@extends('shop.layout')
@section('title', 'Căutare după VIN')
@section('title', __('portal.shop.vin_title'))
@section('content')
<div class="card">
<h1 style="font-size:20px;margin-bottom:6px;">Caută piese după VIN</h1>
<p class="muted" style="margin-bottom:16px;">Introdu codul VIN (17 caractere) ca identificăm mașina. Apoi caută piesele în catalog.</p>
<h1 style="font-size:20px;margin-bottom:6px;">{{ __('portal.shop.vin_title') }}</h1>
<p class="muted" style="margin-bottom:16px;">{{ __('portal.shop.vin_intro') }}</p>
<form method="GET" action="/shop/vin" style="display:flex;gap:8px;flex-wrap:wrap;">
<input type="text" name="vin" value="{{ $vin }}" maxlength="17" placeholder="ex: WVWZZZ1JZXW000001"
style="flex:1;min-width:240px;padding:10px 12px;border:1px solid #d1d5db;border-radius:8px;font-family:monospace;text-transform:uppercase;">
<button class="btn" type="submit">Decodează</button>
<button class="btn" type="submit">{{ __('portal.shop.vin_decode') }}</button>
</form>
</div>
@if ($decoded)
<div class="card" style="margin-top:14px;">
@if (! ($decoded['valid_length'] ?? false))
<p class="stock out">{{ $decoded['reason'] ?? 'VIN invalid — trebuie 17 caractere.' }}</p>
<p class="stock out">{{ $decoded['reason'] ?? __('portal.shop.vin_invalid') }}</p>
@else
<h3 style="font-size:16px;margin-bottom:10px;">Mașină identificată</h3>
<h3 style="font-size:16px;margin-bottom:10px;">{{ __('portal.shop.vin_identified') }}</h3>
<table class="cart">
<tr><td>Producător</td><td class="r"><strong>{{ $decoded['manufacturer'] ?? '—' }}</strong></td></tr>
<tr><td>An model</td><td class="r"><strong>{{ $decoded['year'] ?? '—' }}</strong></td></tr>
<tr><td>Țară</td><td class="r">{{ $decoded['country'] ?? '—' }}</td></tr>
<tr><td>Regiune</td><td class="r">{{ $decoded['region'] ?? '—' }}</td></tr>
<tr><td>{{ __('portal.shop.vin_manufacturer') }}</td><td class="r"><strong>{{ $decoded['manufacturer'] ?? '—' }}</strong></td></tr>
<tr><td>{{ __('portal.shop.vin_year') }}</td><td class="r"><strong>{{ $decoded['year'] ?? '—' }}</strong></td></tr>
<tr><td>{{ __('portal.shop.vin_country') }}</td><td class="r">{{ $decoded['country'] ?? '—' }}</td></tr>
<tr><td>{{ __('portal.shop.vin_region') }}</td><td class="r">{{ $decoded['region'] ?? '—' }}</td></tr>
</table>
<div style="margin-top:14px;">
<a class="btn outline" href="/shop?q={{ urlencode($decoded['manufacturer'] ?? '') }}">
Caută piese pentru {{ $decoded['manufacturer'] ?? 'această mașină' }}
{{ __('portal.shop.vin_search_parts', ['maker' => $decoded['manufacturer'] ?? __('portal.shop.this_car')]) }}
</a>
</div>
<p class="muted" style="margin-top:12px;">
Pentru compatibilitate exactă pe model/motorizare, contactează service-ul cu acest VIN.
{{ __('portal.shop.vin_contact_note') }}
</p>
@endif
</div>
+21 -21
View File
@@ -85,7 +85,7 @@
<header>
@if ($logoUrl)<img src="{{ $logoUrl }}" alt="">@endif
<h1>{{ $tenant->display_name ?? $tenant->name }}</h1>
<div class="num">Fișa #{{ $wo->number }}</div>
<div class="num">{{ __('portal.tracking.title_fisa', ['number' => $wo->number]) }}</div>
</header>
<style>
@@ -112,17 +112,17 @@
@if ($pendingWorks->isNotEmpty() || $pendingParts->isNotEmpty())
<div class="approval-banner">
<h3> Necesită aprobarea ta</h3>
<p style="font-size:13px;color:#92400e;margin-bottom:10px;">Am descoperit lucrări suplimentare. Te rugăm decizi mai jos.</p>
<h3>{{ __('portal.tracking.approval_needed_title') }}</h3>
<p style="font-size:13px;color:#92400e;margin-bottom:10px;">{{ __('portal.tracking.approval_needed_body') }}</p>
@foreach ($pendingWorks as $w)
<div class="approval-line">
<div class="approval-line-title">{{ $w->name }}</div>
<div class="approval-line-amount">{{ rtrim(rtrim(number_format($w->hours, 2), '0'), '.') }} ore · {{ number_format($w->total, 0, '.', ' ') }} MDL</div>
<div class="approval-line-amount">{{ rtrim(rtrim(number_format($w->hours, 2), '0'), '.') }} {{ __('portal.tracking.hours') }} · {{ number_format($w->total, 0, '.', ' ') }} {{ __('portal.common.currency_mdl') }}</div>
<div class="approval-line-actions">
<form method="POST" action="{{ route('tracking.approve', ['token' => $wo->tracking_token, 'kind' => 'work', 'lineToken' => $w->approval_token]) }}" style="flex:1;display:flex;gap:8px;">
@csrf
<button type="submit" name="decision" value="approve" class="btn-approve"> Aprob</button>
<button type="submit" name="decision" value="decline" class="btn-decline"> Nu aprob</button>
<button type="submit" name="decision" value="approve" class="btn-approve">{{ __('portal.tracking.approve') }}</button>
<button type="submit" name="decision" value="decline" class="btn-decline">{{ __('portal.tracking.decline') }}</button>
</form>
</div>
</div>
@@ -130,12 +130,12 @@
@foreach ($pendingParts as $p)
<div class="approval-line">
<div class="approval-line-title">{{ $p->name }} @if ($p->article) <span style="font-family:monospace;color:#6b7280;font-weight:400;">· {{ $p->article }}</span>@endif</div>
<div class="approval-line-amount">{{ rtrim(rtrim(number_format($p->qty, 2), '0'), '.') }} {{ $p->unit ?? 'buc' }} · {{ number_format($p->total, 0, '.', ' ') }} MDL</div>
<div class="approval-line-amount">{{ rtrim(rtrim(number_format($p->qty, 2), '0'), '.') }} {{ $p->unit ?? __('portal.tracking.unit_pcs') }} · {{ number_format($p->total, 0, '.', ' ') }} {{ __('portal.common.currency_mdl') }}</div>
<div class="approval-line-actions">
<form method="POST" action="{{ route('tracking.approve', ['token' => $wo->tracking_token, 'kind' => 'part', 'lineToken' => $p->approval_token]) }}" style="flex:1;display:flex;gap:8px;">
@csrf
<button type="submit" name="decision" value="approve" class="btn-approve"> Aprob</button>
<button type="submit" name="decision" value="decline" class="btn-decline"> Nu aprob</button>
<button type="submit" name="decision" value="approve" class="btn-approve">{{ __('portal.tracking.approve') }}</button>
<button type="submit" name="decision" value="decline" class="btn-decline">{{ __('portal.tracking.decline') }}</button>
</form>
</div>
</div>
@@ -147,32 +147,32 @@
<span class="status-badge">{{ $statuses[$wo->status] ?? $wo->status }}</span>
@if ($wo->eta_at && in_array($wo->status, ['in_work', 'awaiting_parts', 'approved', 'diagnosis'], true))
<p style="margin-top:10px;color:#6b7280;font-size:14px;">
Gata estimat: <strong style="color:#111827">{{ $wo->eta_at->isoFormat('D MMM YYYY, HH:mm') }}</strong>
{{ __('portal.tracking.ready_estimated') }} <strong style="color:#111827">{{ $wo->eta_at->isoFormat('D MMM YYYY, HH:mm') }}</strong>
</p>
@endif
</div>
<div class="card">
<h2>Detalii</h2>
<h2>{{ __('portal.tracking.details') }}</h2>
@if ($wo->vehicle)
<div class="row">
<span class="k">Auto</span>
<span class="k">{{ __('portal.tracking.auto') }}</span>
<span class="v">{{ trim($wo->vehicle->make . ' ' . $wo->vehicle->model) }}
@if ($wo->vehicle->plate) · {{ $wo->vehicle->plate }} @endif
</span>
</div>
@endif
@if ($wo->mileage_in)
<div class="row"><span class="k">Kilometraj</span><span class="v">{{ number_format($wo->mileage_in, 0, '.', ' ') }} km</span></div>
<div class="row"><span class="k">{{ __('portal.tracking.mileage') }}</span><span class="v">{{ number_format($wo->mileage_in, 0, '.', ' ') }} km</span></div>
@endif
<div class="row"><span class="k">Deschis</span><span class="v">{{ $wo->opened_at?->isoFormat('D MMM YYYY') }}</span></div>
<div class="row"><span class="k">{{ __('portal.tracking.opened') }}</span><span class="v">{{ $wo->opened_at?->isoFormat('D MMM YYYY') }}</span></div>
@if ($wo->master)
<div class="row"><span class="k">Maistru</span><span class="v">{{ $wo->master->name }}</span></div>
<div class="row"><span class="k">{{ __('portal.tracking.master') }}</span><span class="v">{{ $wo->master->name }}</span></div>
@endif
</div>
<div class="card">
<h2>Etape</h2>
<h2>{{ __('portal.tracking.stages') }}</h2>
<ul class="timeline">
@foreach ($flow as $i => $st)
@php
@@ -187,21 +187,21 @@
@if ($wo->complaint)
<div class="card">
<h2>Ce ne-ai cerut</h2>
<h2>{{ __('portal.tracking.what_asked') }}</h2>
<p style="font-size:14px;white-space:pre-wrap;">{{ $wo->complaint }}</p>
</div>
@endif
@if ($wo->recommendations)
<div class="card">
<h2>Recomandări</h2>
<h2>{{ __('portal.tracking.recommendations') }}</h2>
<div class="note" style="white-space:pre-wrap;">{{ $wo->recommendations }}</div>
</div>
@endif
@if ($photos->count())
<div class="card">
<h2>Fotografii</h2>
<h2>{{ __('portal.tracking.photos') }}</h2>
<div class="photos">
@foreach ($photos as $p)
<a href="{{ $p->getUrl() }}" target="_blank" rel="noopener">
@@ -215,14 +215,14 @@
@if ((float) $wo->total > 0)
<div class="card">
<div class="totals">
<span class="lbl">Total</span>
<span class="lbl">{{ __('portal.common.total') }}</span>
<span class="amt">{{ number_format((float) $wo->total, 2, '.', ' ') }} {{ $tenant->settings['currency'] ?? 'MDL' }}</span>
</div>
</div>
@endif
<footer>
Powered by AutoCRM
{{ __('portal.common.powered_by') }}
</footer>
</div>
</body>
+9 -18
View File
@@ -38,22 +38,24 @@ class InternalMarginToggleTest extends TestCase
]);
}
public function test_apply_margin_off_makes_salary_base_equal_to_total(): void
public function test_wo_apply_margin_off_forces_all_lines_at_cost(): void
{
// Toggle now lives on the WorkOrder, not per line
$this->wo->update(['apply_margin' => false]);
$work = WorkOrderWork::create([
'work_order_id' => $this->wo->id, 'master_id' => $this->mechanic->id,
'name' => 'Ulei la cost', 'hours' => 1, 'price_per_hour' => 250,
'apply_margin' => false,
]);
$this->assertEquals(250.00, (float) $work->total);
$this->assertEquals(250.00, (float) $work->salary_base);
$this->assertEquals(0.00, (float) $work->applied_margin_pct);
$this->assertFalse((bool) $work->apply_margin);
}
public function test_apply_margin_on_default_still_applies_margin(): void
public function test_wo_apply_margin_on_default_still_applies_margin(): void
{
// Default WO.apply_margin=true → margin applies
$work = WorkOrderWork::create([
'work_order_id' => $this->wo->id, 'master_id' => $this->mechanic->id,
'name' => 'Diagnoză cu marjă', 'hours' => 1, 'price_per_hour' => 250,
@@ -62,29 +64,18 @@ class InternalMarginToggleTest extends TestCase
$this->assertEquals(250.00, (float) $work->total);
$this->assertEquals(200.00, (float) $work->salary_base);
$this->assertEquals(20.00, (float) $work->applied_margin_pct);
$this->assertTrue((bool) $work->apply_margin);
}
public function test_toggling_apply_margin_recomputes_salary_base(): void
public function test_new_line_after_wo_toggle_off_is_at_cost(): void
{
// Start with margin ON
// WO turned off → subsequent line saves at-cost
$this->wo->update(['apply_margin' => false]);
$work = WorkOrderWork::create([
'work_order_id' => $this->wo->id, 'master_id' => $this->mechanic->id,
'name' => 'X', 'hours' => 1, 'price_per_hour' => 250,
]);
$this->assertEquals(200.00, (float) $work->salary_base);
// Toggle OFF
$work->update(['apply_margin' => false]);
$work->refresh();
$this->assertEquals(250.00, (float) $work->salary_base);
$this->assertEquals(0.00, (float) $work->applied_margin_pct);
// Toggle back ON
$work->update(['apply_margin' => true]);
$work->refresh();
$this->assertEquals(200.00, (float) $work->salary_base);
$this->assertEquals(20.00, (float) $work->applied_margin_pct);
}
public function test_company_default_margin_used_when_mechanic_has_none(): void