@extends('frontend.layout.dashboard-master') @section('site_title', __('Order Details')) @section('style') @endsection @section('content') @php $od = $order_details; $mile_stones = \App\Models\OrderMilestone::where('order_id', $od->id)->get(); $payable_amount = \App\Models\OrderMilestone::where('order_id', $od->id)->where('status', '!=', 3)->sum('price'); $earnings = \App\Models\OrderMilestone::where('order_id', $od->id)->where('status', 2)->sum('price'); $complete_orders = \App\Models\Order::where('freelancer_id', $od->freelancer_id)->where('status', 3)->count(); $active_orders = \App\Models\Order::where('freelancer_id', $od->freelancer_id)->where('status', 1)->count(); $check_order_has_report_by_client = \App\Models\Report::where('client_id', $od->user_id) ->where('order_id', $od->id)->where('reporter', 'client')->first(); $clientRating = \App\Models\Rating::where('order_id', $od->id) ->where('sender_type', 1) ->where('sender_id', auth()->id()) ->first(); $isHourly = $od->is_fixed_hourly === 'hourly'; $notSuspended = $od?->freelancer?->is_suspend != 1; $hourlyLoggedSeconds = 0; $hourlyLoggedHours = 0; $hourlyPayAmount = 0; $hourlyRefund = 0; if ($isHourly && $od->status !== 3) { $hourlyLoggedSeconds = \App\Models\OrderWorkHistory::where('order_id', $od->id)->sum('seconds'); $hourlyLoggedHours = $hourlyLoggedSeconds / 3600; $hourlyRate = $od->hourly_rate ?? $od->job?->hourly_rate ?? 0; $hourlyActual = ($hourlyLoggedSeconds / 3600) * $hourlyRate; $hourlyPayAmount = min($hourlyActual, (float) $od->price); $hourlyRefund = max(0, (float) $od->price - $hourlyPayAmount); } $orderTitle = match($od->is_project_job) { 'project' => $od->project?->title ?? __('N/A'), 'job' => $od->job?->title ?? __('N/A'), default => __('Custom Order'), }; $budget = $isHourly ? float_amount_with_currency_symbol($od->job?->hourly_rate ?? 0) : float_amount_with_currency_symbol($od->price); if ($od->freelancer?->image) { if (cloudStorageExist() && in_array(\Illuminate\Support\Facades\Storage::getDefaultDriver(), ['s3','cloudFlareR2','wasabi'])) { $freelancerImage = render_frontend_cloud_image_if_module_exists('profile/'.$od->freelancer->image, load_from: $od->freelancer->load_from ?? ''); } else { $freelancerImage = asset('assets/uploads/profile/'.$od->freelancer->image); } } else { $freelancerImage = asset('assets/static/img/author/author.jpg'); } $isOnline = \Illuminate\Support\Facades\Cache::has('user_is_online_' . $od->freelancer?->id); @endphp {{-- Back link --}}
{{ __('Back to Orders') }}
{{-- ===== LEFT COLUMN ===== --}}
{{-- Card 1: Summary --}}

{{ $orderTitle }}

@if($od->status === 0) {{ __('Queue') }} @elseif($od->status === 1) {{ __('Active') }} @elseif($od->status === 2) {{ __('Deliver') }} @elseif($od->status === 3) {{ __('Complete') }} @elseif($od->status === 4) {{ __('Cancelled') }} @elseif($od->status === 5) {{ __('Declined') }} @elseif($od->status === 6) {{ __('Suspended') }} @elseif($od->status === 7) {{ __('On Hold') }} @endif

{{ __('Order ID') }}: #{{ str_pad($od->id, 6, '0', STR_PAD_LEFT) }}


{{ $isHourly ? __('Hourly Rate') : __('Budget') }}

{{ $budget }} @if(!$isHourly) ({{ $od->payment_status === 'complete' ? __('Funded') : ucfirst($od->payment_status) }}) @endif

{{ __('Delivery Time') }}

{{ $od->delivery_time ?? __('N/A') }}

{{ __('Completed') }}

{{ $complete_orders }}

{{ __('Active') }}

{{ $active_orders }}

@if($notSuspended)
@csrf
@if($od->status === 3) {{ __('Invoice') }} @if(!$clientRating) {{ __('Submit Review') }} @endif @endif @endif @if($isHourly && $od->status !== 0) {{ __('Work History') }} @endif
{{-- Card 2: Balance stats --}} @if(get_static_option('commission_disable_client_panel') != 'disable')
{{-- Card 1 --}}
@if($isHourly && $od->status !== 3)

{{ __('Hours Logged') }}

{{ number_format($hourlyLoggedHours, 2) }} / {{ $od->job?->estimated_hours ?? '—' }} {{ __('hrs') }}

@else

{{ __('Earned Balance') }}

{{ float_amount_with_currency_symbol($od->status === 3 ? $od->payable_amount : $earnings) }}

@endif
{{-- Card 2 --}}
@if($isHourly && $od->status !== 3)

{{ __('Hourly Rate') }}

{{ float_amount_with_currency_symbol($od->job?->hourly_rate) }}

@else

{{ __('Pending Balance') }}

@if($mile_stones->count() > 0) {{ float_amount_with_currency_symbol($od->status != 3 ? $payable_amount - $earnings : 0) }} @else {{ ($od->status != 3 && $od->status != 4 && $od->payment_status != '') ? float_amount_with_currency_symbol($od->payable_amount) : site_currency_symbol().'0' }} @endif

@endif
{{-- Card 3 --}}
@if($isHourly && $od->status !== 3)

{{ __('Amount to Pay') }}

{{ float_amount_with_currency_symbol($hourlyPayAmount) }}

@if($hourlyLoggedSeconds === 0)

{{ __('No hours logged yet') }}

@elseif($hourlyRefund > 0)

{{ float_amount_with_currency_symbol($hourlyRefund) }} {{ __('will be refunded to you') }}

@endif @else

{{ __('Commission Amount') }}

{{ float_amount_with_currency_symbol($od->commission_amount) }}

@endif
{{-- Card 4 --}}

{{ $isHourly ? __('Locked Budget') : __('Total Budget') }}

{{ float_amount_with_currency_symbol($od->price) }}

@endif {{-- Card 3: Tabs --}}
@if($mile_stones->count() > 0) @endif
{{-- Milestones tab --}} @if($mile_stones->count() > 0)
@foreach($mile_stones as $ms)

#{{ $ms->id }} — {{ $ms->title }}

@if($ms->status === 0) {{ __('Pending') }} @elseif($ms->status === 1) {{ __('Active') }} @elseif($ms->status === 2) {{ __('Complete') }} @elseif($ms->status === 3) {{ __('Cancel') }} @elseif($ms->status === 4) {{ __('Deliver') }} @endif {{ float_amount_with_currency_symbol($ms->price) }} @if($ms->revision) {{ __('Rev') }}: {{ $ms->revision }} ({{ __('Left') }}: {{ $ms->revision_left }}) @endif

{{ __('Delivery') }}: {{ $ms->deadline }}

{{ $ms->description }}

@endforeach
@endif {{-- Description tab --}}

{{ $od->description ?? __('No description provided.') }}

{{-- Works Submitted tab --}}
@if(empty($check_order_has_report_by_client)) @if(in_array($od->status, [3, 4]) && $notSuspended) @endif @else {{ __('Reported') }} @endif
@if($mile_stones->isEmpty())
{{ __('Revisions') }}: {{ $od->revision }} {{ __('Left') }}: {{ $od->revision_left }}
@endif
{{-- end left --}} {{-- ===== RIGHT COLUMN: Freelancer sidebar ===== --}}
{{ $od->freelancer?->first_name }}

{{ $od->freelancer?->first_name }} {{ $od->freelancer?->last_name }}

@if($od->freelancer?->user_verified_status) @endif
{{ $isOnline ? __('Active') : __('Inactive') }}

@if($od->freelancer?->user_state?->state){{ $od->freelancer->user_state->state }}, @endif {{ $od->freelancer?->user_country?->country }}


{!! freelancer_rating($od->freelancer?->id) !!}
{{ __('Member Since') }}
{{ $od->freelancer?->created_at?->format('M d, Y') }}
{{ __('Complete Orders') }}
{{ $complete_orders }}
{{ __('Active Orders') }}
{{ $active_orders }}
{{-- end grid --}} {{-- ===== MODALS ===== --}} {{-- Revision Request Modal --}} {{-- Revision Details Modal --}} {{-- Submission Description Modal --}} {{-- Report Order Modal --}} @endsection @section('script') @endsection