@extends('layouts.admin.home') @section('title') {{ __('admin.pages.users.title') }} - {{ $user->name }} @endsection @section('css') @endsection @section('content') @php $statusClasses = [ 'pending' => 'chip-pending', 'confirmed' => 'chip-confirmed', 'under review' => 'chip-under-review', 'under_review' => 'chip-under-review', 'processing' => 'chip-processing', 'shipped' => 'chip-shipped', 'delivered' => 'chip-delivered', 'completed' => 'chip-completed', 'cancelled' => 'chip-cancelled', 'canceled' => 'chip-cancelled', 'rejected' => 'chip-rejected', 'upcoming' => 'chip-upcoming', 'active' => 'chip-active', 'paused' => 'chip-paused', 'converted to order' => 'chip-converted', 'offers received' => 'chip-offers-received', 'supplier selected' => 'chip-supplier-selected', 'assigned to supplier' => 'chip-assigned', 'assigned' => 'chip-assigned', 'on hold' => 'chip-on-hold', ]; $resolveStatus = function ($order, $providerId = null) use ($statusClasses) { $lastTimelineNo = optional($order->timeline->sortByDesc('timeline_no')->first())->timeline_no; $lastTimelineLabel = strtolower(trim((string) timelineName((int) $lastTimelineNo))); if ((int) $order->request_type === 2) { $statusText = ucfirst((string) $order->scheduled_status); $statusKey = strtolower((string) $order->scheduled_status); } else { $myOffer = null; if (!is_null($providerId)) { $myOffer = $order->offers->where('provider_id', (int) $providerId)->first(); } if ($myOffer) { $offerStatus = strtolower((string) $myOffer->status); if ($offerStatus === '2' || $offerStatus === 'accepted') { $statusText = 'Confirmed'; $statusKey = 'confirmed'; } elseif ($offerStatus === '3' || $offerStatus === 'rejected') { $statusText = 'Rejected'; $statusKey = 'rejected'; } else { $statusText = ucwords($lastTimelineLabel !== '---' ? $lastTimelineLabel : 'Pending'); $statusKey = $lastTimelineLabel !== '---' ? $lastTimelineLabel : 'pending'; } } else { $acceptedOffer = $order->offers->first(function ($offer) { $status = strtolower((string) $offer->status); return $status === '2' || $status === 'accepted'; }); $rejectedOffer = $order->offers->first(function ($offer) { $status = strtolower((string) $offer->status); return $status === '3' || $status === 'rejected'; }); if ($acceptedOffer) { $statusText = 'Confirmed'; $statusKey = 'confirmed'; } elseif ($rejectedOffer && $order->offers->count() > 0) { $statusText = 'Rejected'; $statusKey = 'rejected'; } else { $statusText = ucwords($lastTimelineLabel !== '---' ? $lastTimelineLabel : 'Pending'); $statusKey = $lastTimelineLabel !== '---' ? $lastTimelineLabel : 'pending'; } } } return [ 'text' => $statusText, 'class' => $statusClasses[$statusKey] ?? 'chip-pending', ]; }; @endphp
{{ __('admin.pages.users.back_to_users') }} {{ __('admin.pages.common.edit') }} @if($activeTab === 'account')
@if($user->img) {{ $user->name }} @else
@endif

{{ $user->name }}

@if((int) $user->user_type === 2) {{ __('admin.pages.common.provider') }} @elseif((int) $user->user_type === 1) {{ __('admin.pages.common.client') }} @else {{ __('admin.pages.common.undefined') }} @endif @if((int) $user->is_activate === 1) {{ __('admin.pages.common.active') }} @else {{ __('admin.pages.common.inactive') }} @endif
{{ __('admin.pages.common.email') }}: {{ $user->email ?? '-' }}
{{ __('admin.pages.common.mobile') }}: {{ $user->mobile ?? '-' }}
{{ __('admin.pages.common.location') }}: {{ $user->location ?? '-' }}
{{ __('admin.pages.common.branch') }}: {{ $user->branch ?? '-' }}
{{ __('admin.pages.common.tax_number') }}: {{ $user->tax_number ?? '-' }}
{{ __('admin.pages.common.cr_number') }}: {{ $user->cr_number ?? '-' }}
@endif @if($activeTab === 'customer-orders')
{{ __('admin.pages.users.customer_orders') }}
{{ __('admin.pages.common.total') }}: {{ $customerOrders->total() }}
@forelse($customerOrders as $order) @php $status = $resolveStatus($order, (int) ($order->provider_id ?? 0) ?: null); @endphp @empty @endforelse
{{ __('admin.pages.common.id') }} {{ __('admin.pages.common.provider') }} {{ __('admin.pages.common.total_cost') }} {{ __('admin.pages.common.status') }} {{ __('admin.pages.common.created_at') }} {{ __('admin.pages.common.actions') }}
#{{ $order->id }} {{ optional($order->provider)->name ?? '-' }} {{ $order->total_cost ?? 0 }} {{ $status['text'] }} {{ optional($order->created_at)->format('Y-m-d H:i') }}
{{ __('admin.pages.common.no_data') }}
{{ $customerOrders->appends(['tab' => 'customer-orders'])->links() }}
@endif @if($activeTab === 'vendor-orders')
{{ __('admin.pages.users.vendor_orders') }}
{{ __('admin.pages.common.total') }}: {{ $vendorOrders->total() }}
@forelse($vendorOrders as $order) @php $status = $resolveStatus($order, $user->id); @endphp @empty @endforelse
{{ __('admin.pages.common.id') }} {{ __('admin.pages.common.customer') }} {{ __('admin.pages.common.total_cost') }} {{ __('admin.pages.common.status') }} {{ __('admin.pages.common.created_at') }} {{ __('admin.pages.common.actions') }}
#{{ $order->id }} {{ optional($order->user)->name ?? '-' }} {{ $order->total_cost ?? 0 }} {{ $status['text'] }} {{ optional($order->created_at)->format('Y-m-d H:i') }}
{{ __('admin.pages.common.no_data') }}
{{ $vendorOrders->appends(['tab' => 'vendor-orders'])->links() }}
@endif @if($activeTab === 'products')
{{ __('admin.pages.users.vendor_products') }}
{{ __('admin.pages.common.total') }}: {{ $products->total() }}
@forelse($products as $product) @empty @endforelse
{{ __('admin.pages.common.id') }} {{ __('admin.pages.common.name') }} {{ __('admin.pages.common.category') }} {{ __('admin.pages.common.price') }} {{ __('admin.pages.common.stock_quantity') }} {{ __('admin.pages.common.actions') }}
#{{ $product->id }} {{ $product->name }} {{ optional($product->category)->name ?? '-' }} {{ $product->price ?? 0 }} {{ $product->stock_quantity ?? 0 }}
{{ __('admin.pages.common.no_data') }}
{{ $products->appends(['tab' => 'products'])->links() }}
@endif
@endsection