@php
$stationsCount = \App\Models\Station::where(
'company_id',
auth()->user()->company_id,
)->count();
$employeesCount = \App\Models\User::where(
'company_id',
auth()->user()->company_id,
)->count();
// حساب مبيعات اليوم من جميع المحطات
$companyStations = \App\Models\Station::where('company_id', auth()->user()->company_id)->pluck('id');
$today = \Carbon\Carbon::today();
$todayShifts = \App\Models\Shift::whereIn('station_id', $companyStations)
->whereDate('start_datetime', $today)
->where('status', '!=', 'open')
->with('nozzleReadings')
->get();
$dailySales = 0;
foreach ($todayShifts as $shift) {
foreach ($shift->nozzleReadings as $reading) {
if ($reading->closing_reading && $reading->opening_reading && $reading->price_per_liter) {
$quantity = $reading->closing_reading - $reading->opening_reading;
$amount = $quantity * $reading->price_per_liter;
$dailySales += $amount;
}
}
}
@endphp
المحطات
{{ $stationsCount }}
الموظفين
{{ $employeesCount }}
المبيعات اليوم
{{ number_format($dailySales, 2) }} ر.س
المحطات النشطة
{{ \App\Models\Station::where('company_id', auth()->user()->company_id)->where('status', 'active')->count() }}/{{ $stationsCount }}
ورديات اليوم
{{ $todayShifts->count() }}