6e7c665433
Every card on the tenant main dashboard now links to a relevant page:
Operations widget (was 5 cards, now 7):
- Clienți → /app/clients
- Mașini → /app/vehicles
- Cereri noi → /app/leads pre-filtered by status=new
- Deal-uri active → /app/deals
- Programări azi → /app/calendar-board
- NEW: Fișe în lucru (in_work + awaiting_parts) → /app/work-orders filter
- NEW: Fișe gata predare (ready) → /app/work-orders filter
Finance widget (all 4 cards clickable now):
- Încasări → /app/payments
- Cheltuieli → /app/expenses
- Profit → /app/reports (with "Vezi raportul financiar" hint)
- Datorii → /app/work-orders pre-filtered by pay_status=unpaid
LowStockTable rows now navigate to /app/parts/{id}/edit on click and
have an explicit edit action for touch users.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
58 lines
2.2 KiB
PHP
58 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Tenant\Widgets;
|
|
|
|
use App\Models\Tenant\Expense;
|
|
use App\Models\Tenant\Payment;
|
|
use App\Models\Tenant\WorkOrder;
|
|
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
|
|
use Filament\Widgets\StatsOverviewWidget\Stat;
|
|
|
|
class FinanceOverview extends BaseWidget
|
|
{
|
|
protected static ?int $sort = 2;
|
|
|
|
protected function getStats(): array
|
|
{
|
|
$start = now()->startOfMonth();
|
|
$end = now()->endOfMonth();
|
|
|
|
$income = (float) Payment::whereBetween('paid_at', [$start, $end])->sum('amount');
|
|
$expenses = (float) Expense::whereBetween('paid_at', [$start, $end])->sum('amount');
|
|
$profit = $income - $expenses;
|
|
|
|
$debtTotal = (float) WorkOrder::where('pay_status', '!=', 'paid')
|
|
->whereNotIn('status', ['cancelled'])
|
|
->sum('total');
|
|
$paidOnDebt = (float) Payment::whereIn('work_order_id',
|
|
WorkOrder::where('pay_status', '!=', 'paid')->pluck('id')
|
|
)->sum('amount');
|
|
$debt = max(0, $debtTotal - $paidOnDebt);
|
|
|
|
return [
|
|
Stat::make(__('Încasări (luna)'), number_format($income, 2, '.', ' ') . ' MDL')
|
|
->icon('heroicon-o-arrow-trending-up')
|
|
->color('success')
|
|
->description(now()->translatedFormat('F Y'))
|
|
->url(url('/app/payments')),
|
|
|
|
Stat::make(__('Cheltuieli (luna)'), number_format($expenses, 2, '.', ' ') . ' MDL')
|
|
->icon('heroicon-o-arrow-trending-down')
|
|
->color('danger')
|
|
->url(url('/app/expenses')),
|
|
|
|
Stat::make(__('Profit (luna)'), number_format($profit, 2, '.', ' ') . ' MDL')
|
|
->icon('heroicon-o-banknotes')
|
|
->color($profit >= 0 ? 'success' : 'danger')
|
|
->description(__('Vezi raportul financiar'))
|
|
->url(url('/app/reports')),
|
|
|
|
Stat::make(__('Datorii clienți'), number_format($debt, 2, '.', ' ') . ' MDL')
|
|
->icon('heroicon-o-exclamation-circle')
|
|
->color($debt > 0 ? 'warning' : 'success')
|
|
->description(__('Fișe cu plată în așteptare'))
|
|
->url(url('/app/work-orders') . '?tableFilters[pay_status][value]=unpaid'),
|
|
];
|
|
}
|
|
}
|