@extends('layouts.app')
@section('title', __('dashboard.sidebar_product_tracking'))
@section('page_heading', __('dashboard.sidebar_product_tracking'))
@section('content')
@php
$availablePercent = $totalProductsCount > 0 ? round(($availableProductsCount / $totalProductsCount) * 100) : 0;
$withCustomerPercent = $totalProductsCount > 0 ? round(($productsWithCustomerCount / $totalProductsCount) * 100) : 0;
$atLaundryPercent = $totalProductsCount > 0 ? round(($productsAtLaundryCount / $totalProductsCount) * 100) : 0;
$maintenancePercent = $totalProductsCount > 0 ? round(($productsInMaintenanceCount / $totalProductsCount) * 100) : 0;
$scrappedPercent = ($totalProductsCount + $scrappedProductsCount) > 0 ? round(($scrappedProductsCount / ($totalProductsCount + $scrappedProductsCount)) * 100) : 0;
@endphp
{{-- KPIs --}}
@foreach([
['متاح',$availableProductsCount,$availablePercent,'fa-solid fa-circle-check','#f0fdf4','#16a34a'],
['مع العميل',$productsWithCustomerCount,$withCustomerPercent,'fa-solid fa-user-check','#fffbeb','#d97706'],
['في المغسلة',$productsAtLaundryCount,$atLaundryPercent,'fa-solid fa-droplet','#eff6ff','#2563eb'],
['في الصيانة',$productsInMaintenanceCount,$maintenancePercent,'fa-solid fa-screwdriver-wrench','#fef2f2','#dc2626'],
['هالك',$scrappedProductsCount,$scrappedPercent,'fa-solid fa-trash','#f8fafc','#64748b'],
] as [$lbl,$val,$pct,$icon,$bg,$color])
@endforeach
{{-- مع العميل --}}
المنتجات مع العملاء
{{ $reservationsWithCustomers->count() }}
@if($reservationsWithCustomers->isEmpty())
@include('layouts.partials.index-empty-state', ['icon'=>'fa-solid fa-user-check','title'=>'لا توجد منتجات مع العملاء','message'=>''])
@else
@foreach(['SKU','المنتج','العميل','الهاتف','موعد الاستلام','#الحجز'] as $h)
| {{ $h }} |
@endforeach
@foreach($reservationsWithCustomers as $r)
| {{ $r->product->sku }} |
{{ $r->product->name }} |
{{ $r->customer->name }} |
{{ $r->customer->phone }} |
@if($r->customer_return_date)
{{ $r->customer_return_date->format('Y-m-d') }}
@else
—
@endif
|
#{{ $r->id }}
|
@endforeach
@endif
{{-- في المغسلة --}}
المنتجات في المغسلة
{{ $productsAtLaundry->count() }}
@if($productsAtLaundry->isEmpty())
@include('layouts.partials.index-empty-state', ['icon'=>'fa-solid fa-droplet','title'=>'لا توجد منتجات في المغسلة','message'=>''])
@else
@foreach(['SKU','المنتج','المغسلة','تاريخ الإرسال','#العملية'] as $h)
| {{ $h }} |
@endforeach
@foreach($productsAtLaundry as $p)
| {{ $p->product->sku }} |
{{ $p->product->name }} |
{{ $p->laundry_name }} |
@if($p->sent_date)
{{ optional($p->sent_date)->format('Y-m-d') }}
@else
—
@endif
|
#{{ $p->operation_id }}
|
@endforeach
@endif
{{-- في الصيانة --}}
المنتجات في الصيانة
{{ $productsInMaintenance->count() }}
@if($productsInMaintenance->isEmpty())
@include('layouts.partials.index-empty-state', ['icon'=>'fa-solid fa-screwdriver-wrench','title'=>'لا توجد منتجات في الصيانة','message'=>''])
@else
@foreach(['SKU','المنتج','السبب','العميل','التكلفة','تحميل العميل'] as $h)
| {{ $h }} |
@endforeach
@foreach($productsInMaintenance as $m)
| {{ $m->product?->sku ?? '—' }} |
{{ $m->product?->name ?? '—' }}
{{ optional($m->started_at)->format('Y-m-d') }}
|
{{ $m->title }} |
{{ $m->customer?->name ?? '—' }} |
{{ number_format((float)$m->maintenance_cost, 2) }} |
{{ number_format((float)$m->customer_charge_amount, 2) }} |
@endforeach
@endif
{{-- الهالك --}}
قائمة الهالك
{{ $scrappedProductsCount }}
@if($scrappedProducts->isEmpty())
@include('layouts.partials.index-empty-state', ['icon'=>'fa-solid fa-trash','title'=>'لا توجد منتجات هالك','message'=>''])
@else
@foreach(['SKU','المنتج','تاريخ التحويل','بواسطة','السبب'] as $h)
| {{ $h }} |
@endforeach
@foreach($scrappedProducts as $product)
| {{ $product->sku }} |
{{ $product->name }} |
{{ optional($product->scrapped_at)->format('Y-m-d') ?? '—' }} |
{{ $product->scrapper?->name ?? '—' }} |
{{ $product->scrap_reason ?: '—' }} |
@endforeach
@endif
@endsection