@section('title', 'إدارة الورديات') @section('page-title', 'الورديات') @section('page-description', 'عرض وإدارة الورديات في محطتك') {{-- Page content --}}
{{-- Success/Error Messages --}} @if (session('success'))

{{ session('success') }}

@endif @if (session('error'))

{{ session('error') }}

@endif {{-- Active Shift Alert --}} @if ($activeShift)

يوجد وردية نشطة حالياً

بدأ بواسطة: {{ $activeShift->user->name }}

@if($activeShift->workPeriod)

فترة العمل: {{ $activeShift->workPeriod->name }}

وقت الفترة: {{ $activeShift->workPeriod->formatted_time }}

@elseif($activeShift->pump)

المضخة: {{ $activeShift->pump->name }}

@endif

بدأت في: {{ $activeShift->start_datetime->format('Y-m-d H:i') }}

@endif {{-- Action Buttons - removed duplicate, kept the one in Actions Bar below --}} {{-- Stats --}}

إجمالي الورديات

{{ $stats['total_shifts'] }}

الورديات النشطة

{{ $stats['active_shifts'] }}

الورديات المكتملة

{{ $stats['completed_shifts'] }}

ورديات اليوم

{{ $stats['today_shifts'] }}

{{-- Actions Bar --}}

قائمة الورديات

{{-- Hidden when a shift is already open (Layer 1 — there's no longer a separate "closed/pending" state, shifts are auto-reconciled the moment they're closed). --}} @if(!$activeShift) @endif
{{-- Shifts List --}}
@if ($shifts->isEmpty())

لا توجد ورديات

ابدأ وردية جديدة لعرضها هنا.

@else
@foreach ($shifts as $shift) @endforeach
الوردية والتوقيت الموظف المضخة/فترة العمل المدة الحالة الإجراءات
#{{ $shift->id }}
{{ $shift->start_datetime->format('Y-m-d H:i') }}
@if ($shift->end_datetime)
{{ $shift->end_datetime->format('Y-m-d H:i') }}
@else
جارية...
@endif
{{ $shift->user->name }}
@if($shift->workPeriod)
{{ $shift->workPeriod->name }}
{{ $shift->workPeriod->formatted_time }}
@elseif($shift->pump) {{ $shift->pump->name }} @else غير محدد @endif
@if ($shift->end_datetime)
{{ $shift->duration_hours }}س {{ $shift->duration_minutes % 60 }}د
@php $totalMinutes = $shift->duration_minutes; $days = floor($totalMinutes / 1440); $hours = floor(($totalMinutes % 1440) / 60); $minutes = $totalMinutes % 60; @endphp @if ($days > 0) {{ $days }} يوم، {{ $hours }} ساعة، {{ $minutes }} دقيقة @elseif ($totalMinutes >= 60) {{ $hours }} ساعة، {{ $minutes }} دقيقة @else {{ $minutes }} دقيقة @endif
@else
نشطة
منذ {{ $shift->start_datetime->diffForHumans() }}
@endif
@php $statusClasses = [ 'open' => 'bg-blue-100 text-blue-800 dark:bg-blue-900/50 dark:text-blue-300', 'closed' => 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900/50 dark:text-yellow-300', 'reconciled' => 'bg-green-100 text-green-800 dark:bg-green-900/50 dark:text-green-300', 'discrepancy' => 'bg-red-100 text-red-800 dark:bg-red-900/50 dark:text-red-300', 'cancelled' => 'bg-gray-100 text-gray-800 dark:bg-gray-900/50 dark:text-gray-300', 'pending_approval' => 'bg-purple-100 text-purple-800 dark:bg-purple-900/50 dark:text-purple-300', ]; $statusTexts = [ 'open' => 'نشطة', 'closed' => 'مغلقة', 'reconciled' => 'موافق عليها', 'discrepancy' => 'تضارب', 'cancelled' => 'ملغية', 'pending_approval' => 'في انتظار الموافقة', ]; @endphp {{ $statusTexts[$shift->status] ?? $shift->status }}
@if ($shift->status === 'open') @endif @if ($shift->status === 'reconciled' && auth()->user()->user_type === 'station_manager') @endif
{{-- Pagination --}}
{{ $shifts->links() }}
@endif
@push('scripts') {{-- Modal Scripts --}} @endpush {{-- Modal بدء الوردية --}}