Files
autocrm/resources/views/filament/tenant/pages/reports.blade.php
T
Vasyka 5e6472948f fix(reports): repair blade @foreach corrupted by aggressive i18n wrap
The mega-i18n script mis-wrapped a PHP fragment inside the array
literal of a Blade @foreach on reports.blade.php (line 91). It
matched the '>' from '>= 0' as an HTML tag boundary and turned the
rest of the array into a broken __() string, which caused
'unexpected endforeach' compile error.

Rewrote the array with proper __() calls on each label.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-07-18 10:22:36 +00:00

282 lines
14 KiB
PHP

<x-filament-panels::page>
@php
$data = $this->data();
$tabs = $this->tabs();
$periods = $this->periods();
@endphp
<style>
.rp-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.rp-label { font-size: 13px; font-weight: 500; }
.rp-pill {
padding: 6px 12px; border-radius: 6px; font-size: 13px;
background: #fff; border: 1px solid #e5e7eb; cursor: pointer; color: #374151;
transition: all .15s;
}
.dark .rp-pill { background: #1f2937; border-color: #374151; color: #d1d5db; }
.rp-pill:hover { background: #f9fafb; }
.dark .rp-pill:hover { background: #374151; }
.rp-pill.active { background: #3b82f6; color: #fff; border-color: #3b82f6; }
.rp-tabs {
display: flex; flex-wrap: wrap; gap: 4px;
border-bottom: 1px solid #e5e7eb; margin-bottom: 16px;
}
.dark .rp-tabs { border-color: #374151; }
.rp-tab {
padding: 10px 16px; font-size: 14px; font-weight: 500;
border: none; background: transparent; cursor: pointer;
border-bottom: 2px solid transparent; margin-bottom: -1px;
color: #6b7280;
}
.rp-tab:hover { color: #1f2937; }
.dark .rp-tab:hover { color: #f9fafb; }
.rp-tab.active { color: #3b82f6; border-bottom-color: #3b82f6; }
.rp-grid { display: grid; gap: 16px; }
.rp-grid-4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.rp-grid-2 { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.rp-card {
background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
padding: 16px;
}
.dark .rp-card { background: #1f2937; border-color: #374151; }
.rp-stat-label { font-size: 11px; color: #6b7280; text-transform: uppercase; letter-spacing: .5px; }
.rp-stat-value { font-size: 28px; font-weight: 700; margin-top: 6px; }
.rp-h3 { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.rp-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.rp-tbl thead th {
text-align: left; padding: 8px 4px; border-bottom: 1px solid #e5e7eb;
font-weight: 600; color: #6b7280;
}
.dark .rp-tbl thead th { border-color: #374151; }
.rp-tbl tbody td { padding: 8px 4px; border-bottom: 1px solid #f3f4f6; }
.dark .rp-tbl tbody td { border-color: #374151; }
.rp-tbl tbody tr:last-child td { border-bottom: none; }
.rp-right { text-align: right; }
.rp-bold { font-weight: 600; }
.rp-success { color: #059669; }
.rp-danger { color: #dc2626; }
.rp-warning { color: #d97706; }
.rp-muted { color: #9ca3af; text-align: center; padding: 16px 0; }
.rp-stack { display: flex; flex-direction: column; gap: 16px; }
</style>
<div class="rp-stack">
<div class="rp-bar">
<span class="rp-label">{{ __('Perioadă:') }}</span>
@foreach ($periods as $key => $label)
<button type="button" wire:click="setPeriod('{{ $key }}')"
class="rp-pill {{ $period === $key ? 'active' : '' }}">{{ $label }}</button>
@endforeach
</div>
<div class="rp-tabs">
@foreach ($tabs as $key => $label)
<button type="button" wire:click="setTab('{{ $key }}')"
class="rp-tab {{ $tab === $key ? 'active' : '' }}">{{ $label }}</button>
@endforeach
</div>
@if ($tab === 'finance')
<div class="rp-grid rp-grid-4">
@foreach ([
[__('Încasări'), $data['income'], 'success'],
[__('Cheltuieli'), $data['expenses'], 'danger'],
[__('Profit'), $data['profit'], $data['profit'] >= 0 ? 'success' : 'danger'],
[__('Datorii clienți'), $data['debt'], 'warning'],
] as [$label, $value, $color])
<div class="rp-card">
<div class="rp-stat-label">{{ $label }}</div>
<div class="rp-stat-value rp-{{ $color }}">
{{ number_format((float)$value, 2, '.', ' ') }} MDL
</div>
</div>
@endforeach
</div>
<div class="rp-grid rp-grid-2">
<div class="rp-card">
<div class="rp-h3">{{ __('Încasări pe metodă') }}</div>
<table class="rp-tbl">
<thead><tr><th>{{ __('Metodă') }}</th><th class="rp-right">{{ __('Tranz.') }}</th><th class="rp-right">{{ __('Total') }}</th></tr></thead>
<tbody>
@forelse ($data['by_method'] as $row)
<tr>
<td>{{ \App\Models\Tenant\Payment::METHODS[$row->method] ?? $row->method }}</td>
<td class="rp-right">{{ $row->cnt }}</td>
<td class="rp-right rp-bold">{{ number_format((float)$row->total, 2, '.', ' ') }}</td>
</tr>
@empty
<tr><td colspan="3" class="rp-muted">{{ __('Nicio plată în perioada selectată.') }}</td></tr>
@endforelse
</tbody>
</table>
</div>
<div class="rp-card">
<div class="rp-h3">{{ __('Cheltuieli pe categorie') }}</div>
<table class="rp-tbl">
<thead><tr><th>{{ __('Categorie') }}</th><th class="rp-right">{{ __('Nr.') }}</th><th class="rp-right">{{ __('Total') }}</th></tr></thead>
<tbody>
@forelse ($data['by_category'] as $row)
<tr>
<td>{{ \App\Models\Tenant\Expense::CATEGORIES[$row->category] ?? $row->category }}</td>
<td class="rp-right">{{ $row->cnt }}</td>
<td class="rp-right rp-bold rp-danger">{{ number_format((float)$row->total, 2, '.', ' ') }}</td>
</tr>
@empty
<tr><td colspan="3" class="rp-muted">{{ __('Nicio cheltuială.') }}</td></tr>
@endforelse
</tbody>
</table>
</div>
</div>
<div style="font-size: 13px; color: #6b7280;">{{ __('Marjă profit:') }} <b>{{ $data['margin_pct'] }}%</b></div>
@elseif ($tab === 'workload')
<div class="rp-grid rp-grid-2">
<div class="rp-card">
<div class="rp-stat-label">{{ __('Fișe deschise') }}</div>
<div class="rp-stat-value">{{ $data['opened'] }}</div>
</div>
<div class="rp-card">
<div class="rp-stat-label">{{ __('Fișe închise') }}</div>
<div class="rp-stat-value rp-success">{{ $data['closed'] }}</div>
</div>
</div>
<div class="rp-card">
<div class="rp-h3">{{ __('Pe status') }}</div>
<table class="rp-tbl">
<tbody>
@forelse ($data['by_status'] as $row)
<tr>
<td>{{ \App\Models\Tenant\WorkOrder::STATUSES[$row->status] ?? $row->status }}</td>
<td class="rp-right rp-bold">{{ $row->cnt }}</td>
</tr>
@empty
<tr><td colspan="2" class="rp-muted">{{ __('Nicio fișă în perioada selectată.') }}</td></tr>
@endforelse
</tbody>
</table>
</div>
@elseif ($tab === 'masters')
<div class="rp-card" style="overflow-x: auto;">
<table class="rp-tbl">
<thead><tr>
<th>{{ __('Mecanic') }}</th>
<th>{{ __('Specializare') }}</th>
<th class="rp-right">{{ __('Manopere') }}</th>
<th class="rp-right">{{ __('Ore') }}</th>
<th class="rp-right">{{ __('Venit') }}</th>
</tr></thead>
<tbody>
@forelse ($data['rows'] as $r)
<tr>
<td class="rp-bold">{{ $r['name'] }}</td>
<td style="color:#6b7280">{{ $r['specialization'] ?? '—' }}</td>
<td class="rp-right">{{ $r['works'] }}</td>
<td class="rp-right">{{ number_format($r['hours'], 1) }}</td>
<td class="rp-right rp-bold rp-success">{{ number_format($r['revenue'], 2, '.', ' ') }}</td>
</tr>
@empty
<tr><td colspan="5" class="rp-muted">{{ __('Niciun mecanic activ.') }}</td></tr>
@endforelse
</tbody>
</table>
</div>
@elseif ($tab === 'works')
<div class="rp-card" style="overflow-x: auto;">
<table class="rp-tbl">
<thead><tr>
<th>{{ __('Manoperă') }}</th>
<th class="rp-right">{{ __('Nr.') }}</th>
<th class="rp-right">{{ __('Ore total') }}</th>
<th class="rp-right">{{ __('Venit') }}</th>
</tr></thead>
<tbody>
@forelse ($data['rows'] as $r)
<tr>
<td>{{ $r->name }}</td>
<td class="rp-right rp-bold">{{ $r->cnt }}</td>
<td class="rp-right">{{ number_format((float)$r->hours, 1) }}</td>
<td class="rp-right rp-success">{{ number_format((float)$r->revenue, 2, '.', ' ') }}</td>
</tr>
@empty
<tr><td colspan="4" class="rp-muted">{{ __('Nicio manoperă efectuată.') }}</td></tr>
@endforelse
</tbody>
</table>
</div>
@elseif ($tab === 'parts')
<div class="rp-grid rp-grid-2">
<div class="rp-card" style="overflow-x: auto;">
<div class="rp-h3">{{ __('Top piese vândute') }}</div>
<table class="rp-tbl">
<thead><tr><th>{{ __('Piesă') }}</th><th class="rp-right">{{ __('Cant.') }}</th><th class="rp-right">{{ __('Venit') }}</th><th class="rp-right">{{ __('Marjă') }}</th></tr></thead>
<tbody>
@forelse ($data['sold'] as $r)
<tr>
<td>{{ $r->name }} <span style="color:#9ca3af">{{ $r->brand }}</span></td>
<td class="rp-right">{{ number_format((float)$r->qty, 2) }}</td>
<td class="rp-right">{{ number_format((float)$r->revenue, 2, '.', ' ') }}</td>
<td class="rp-right rp-success">{{ number_format((float)$r->margin, 2, '.', ' ') }}</td>
</tr>
@empty
<tr><td colspan="4" class="rp-muted">{{ __('Nicio piesă montată.') }}</td></tr>
@endforelse
</tbody>
</table>
</div>
<div class="rp-card">
<div class="rp-h3">{{ __('⚠️ Stoc minim atins') }}</div>
<table class="rp-tbl">
<thead><tr><th>{{ __('Piesă') }}</th><th class="rp-right">{{ __('Stoc') }}</th><th class="rp-right">{{ __('Min.') }}</th></tr></thead>
<tbody>
@forelse ($data['low'] as $p)
<tr>
<td>{{ $p->name }}</td>
<td class="rp-right rp-bold {{ $p->qty <= 0 ? 'rp-danger' : 'rp-warning' }}">{{ $p->qty }}</td>
<td class="rp-right">{{ $p->min_qty }}</td>
</tr>
@empty
<tr><td colspan="3" class="rp-muted">{{ __('Toate piesele sunt în stoc.') }}</td></tr>
@endforelse
</tbody>
</table>
</div>
</div>
@elseif ($tab === 'clients')
<div class="rp-grid rp-grid-2">
<div class="rp-card">
<div class="rp-stat-label">{{ __('Clienți noi în perioadă') }}</div>
<div class="rp-stat-value">{{ $data['new_count'] }}</div>
</div>
<div class="rp-card">
<div class="rp-h3">{{ __('Lead-uri pe sursă') }}</div>
<table class="rp-tbl">
<tbody>
@forelse ($data['by_source'] as $row)
<tr>
<td>{{ \App\Models\Tenant\Lead::SOURCES[$row->source] ?? ($row->source ?? '—') }}</td>
<td class="rp-right rp-bold">{{ $row->cnt }}</td>
</tr>
@empty
<tr><td colspan="2" class="rp-muted">{{ __('Niciun lead.') }}</td></tr>
@endforelse
</tbody>
</table>
</div>
</div>
@endif
</div>
</x-filament-panels::page>