@php use App\Enums\Order\OrderReturnActorEnum; use App\Enums\Order\OrderItemReturnStatusEnum; /** @var \App\Models\OrderItemReturn $return */ /** @var string $panel */ /** @var array{items:array,total:float} $refundBreakdown */ $isAdminPanel = ($panel ?? 'seller') === 'admin'; // Comment: Finalized or rejected statuses where neither confirmation nor rejection buttons should appear $orderItemStatus = (string) ($return->orderItem?->status ?? ''); $isFinalizedStatus = !empty($return->store_rejection_reason) || !empty($return->action_on_rejection) || !empty($return->refund_processed_at) || in_array((string) $return->return_status, [ (string) OrderItemReturnStatusEnum::COMPLETED(), (string) OrderItemReturnStatusEnum::REJECTED_AT_STORE(), (string) OrderItemReturnStatusEnum::SELLER_REJECTED(), (string) OrderItemReturnStatusEnum::CANCELLED(), (string) OrderItemReturnStatusEnum::REFUND_PROCESSED(), 'rejected', 'completed', ], true) || in_array($orderItemStatus, [ (string) \App\Enums\Order\OrderItemStatusEnum::REJECTED(), (string) \App\Enums\Order\OrderItemStatusEnum::REFUNDED(), (string) \App\Enums\Order\OrderItemStatusEnum::CANCELLED(), 'rejected', 'refunded', 'cancelled', ], true) || in_array((string) $return->pickup_status, [ (string) \App\Enums\Order\OrderItemReturnPickupStatusEnum::CANCELLED(), 'rejected', 'cancelled', ], true); $isPending = ! $isFinalizedStatus && (string) $return->return_status === (string) OrderItemReturnStatusEnum::REQUESTED(); // ========================================================== // Return Dispute System // Phase 3 // Seller Inspection Pending Status Evaluation // ========================================================== $isPendingStoreReceipt = !$isAdminPanel && (string) $return->return_status === (string) OrderItemReturnStatusEnum::RECEIVED_BY_SELLER(); $product = $return->orderItem?->product; $variant = $return->orderItem?->variant; $addons = $return->orderItem?->addons ?? collect(); $customer = $return->user; $order = $return->order; $store = $return->store; $sellerUser = $return->seller?->user; $decidedBy = $return->decidedBy; $decidedAt = $return->admin_decided_at ?? $return->seller_approved_at; $decidedByValue = $return->decided_by_type instanceof OrderReturnActorEnum ? $return->decided_by_type->value : (string) $return->decided_by_type; $isAdminDecided = $decidedByValue === (string) OrderReturnActorEnum::ADMIN(); @endphp @if ($isPendingStoreReceipt && !$isAdminPanel) @php $slaHours = (int) (app(\App\Services\SettingService::class)->getSettingValues('seller')['return_seller_inspection_sla_hours'] ?? 48); $receivedAt = $return->received_at; $deadline = $receivedAt ? $receivedAt->copy()->addHours($slaHours) : null; $now = \Carbon\Carbon::now(); $slaExpired = $deadline ? $now->greaterThanOrEqualTo($deadline) : false; $remainingText = ''; $warningClass = 'bg-info-lt text-info border-info'; $borderClass = 'border-info'; $btnClass = 'btn-info'; if ($deadline && !$slaExpired) { $diffInMinutes = $now->diffInMinutes($deadline); $diffInHours = $now->diffInHours($deadline); $diffInDays = $now->diffInDays($deadline); if ($diffInDays >= 1) { $remHours = $diffInHours % 24; $remainingText = "{$diffInDays} " . \Illuminate\Support\Str::plural('Day', $diffInDays) . " {$remHours} " . \Illuminate\Support\Str::plural('Hour', $remHours) . " Remaining"; } elseif ($diffInHours >= 1) { $remainingText = "{$diffInHours} " . \Illuminate\Support\Str::plural('Hour', $diffInHours) . " Remaining"; } else { $remainingText = "{$diffInMinutes} " . \Illuminate\Support\Str::plural('Minute', $diffInMinutes) . " Remaining"; } if ($diffInHours < 12) { $warningClass = 'bg-warning-lt text-warning-dark border-warning'; $borderClass = 'border-warning'; $btnClass = 'btn-warning'; } } else { $warningClass = 'bg-danger-lt text-danger border-danger'; $borderClass = 'border-danger'; $btnClass = 'btn-danger'; } @endphp
Awaiting Seller Inspection @if ($deadline) Received at: {{ $receivedAt?->format('Y-m-d H:i') }} @endif

Inspection Deadline

@if ($slaExpired)
Inspection deadline has expired. This return will be processed automatically during the next scheduled system check.
@else
{{ $remainingText }}
Must act before: {{ $deadline?->format('Y-m-d H:i') }}
@endif

Guidance: Inspect the returned item carefully. If the returned product is correct, accept the return. If there is any issue with the returned product, escalate the dispute to the administrator with supporting evidence before the inspection deadline expires.

@endif

{{ __('labels.return_request') }} #{{ $return->id }}

{{ __('labels.submitted') }} {{ $return->created_at?->format('Y-m-d H:i') }} @if ($return->created_at) ({{ $return->created_at->diffForHumans() }}) @endif
@include('returns._pipeline-status', ['return' => $return])
@php $acceptTarget = $isAdminPanel ? '#adminAcceptModel' : '#acceptModel'; $rejectTarget = $isAdminPanel ? '#adminRejectModel' : '#rejectModel'; @endphp @if ($isPending) @elseif ($isPendingStoreReceipt && !$isAdminPanel) @else {{-- Comment: Display clear status badge when actions are finalized or rejected --}} @php $isRejectedOrCancelled = !empty($return->store_rejection_reason) || $return->action_on_rejection === 'no_refund_customer' || in_array((string) $return->return_status, [ (string) OrderItemReturnStatusEnum::SELLER_REJECTED(), (string) OrderItemReturnStatusEnum::REJECTED_AT_STORE(), (string) OrderItemReturnStatusEnum::CANCELLED(), (string) OrderItemReturnStatusEnum::REJECTED(), 'rejected', ], true) || in_array((string) ($return->orderItem?->status ?? ''), [ (string) \App\Enums\Order\OrderItemStatusEnum::REJECTED(), (string) \App\Enums\Order\OrderItemStatusEnum::CANCELLED(), 'rejected', 'cancelled', ], true) || in_array((string) $return->pickup_status, [ (string) \App\Enums\Order\OrderItemReturnPickupStatusEnum::CANCELLED(), 'rejected', 'cancelled', ], true); $statusBadgeText = \Illuminate\Support\Str::headline((string) $return->return_status); if (in_array((string) $return->pickup_status, ['cancelled', 'rejected'], true) && !in_array((string) $return->return_status, ['cancelled', 'rejected_at_store', 'seller_rejected'], true)) { $statusBadgeText = \Illuminate\Support\Str::headline((string) $return->pickup_status); } if (!empty($return->store_rejection_reason) || $return->action_on_rejection === 'no_refund_customer' || (string) $return->return_status === (string) OrderItemReturnStatusEnum::REJECTED_AT_STORE()) { $statusBadgeText = __('labels.rejected_at_store') ?? 'Rejected At Store'; } elseif ((string) $return->return_status === (string) OrderItemReturnStatusEnum::SELLER_REJECTED() || (string) ($return->orderItem?->status ?? '') === 'rejected') { $statusBadgeText = __('labels.rejected') ?? 'Seller Rejected'; } elseif ((string) $return->return_status === (string) OrderItemReturnStatusEnum::REFUND_PROCESSED()) { $statusBadgeText = __('labels.refund_processed'); } elseif ((string) $return->return_status === (string) OrderItemReturnStatusEnum::COMPLETED()) { $statusBadgeText = __('labels.completed') ?? 'Completed'; } @endphp @if ($isRejectedOrCancelled) {{ $statusBadgeText }} @if ((float) $return->refund_amount <= 0 && !str_contains(strtolower($statusBadgeText), 'no refund')) ({{ __('labels.no_refund_customer') ?? 'No Refund' }}) @endif @else {{ $statusBadgeText }} @endif @endif
{{-- LEFT column --}}
{{-- Product --}}

{{ __('labels.product') }}

@if ($product?->main_image) @endif
{{ $return->orderItem?->title ?? __('labels.n_a') }}
@if ($variant?->title)
{{ $variant->title }}
@endif
{{ __('labels.qty') }}: {{ $return->orderItem?->quantity ?? 1 }}
@if ($addons->isNotEmpty())
{{ __('labels.addons') }}:
    @foreach ($addons as $addon)
  • @if ($addon->addonGroup?->title) {{ $addon->addonGroup->title }} — @endif {{ $addon->addonItem?->title ?? '—' }} · {{ number_format((float) $addon->price, 2) }}
  • @endforeach
@endif
{{-- Customer reason + photos --}} @if (!($hideEvidenceCards ?? false))

{{ __('labels.customer_reason') }}

@if ($return->reason)

{{ $return->reason }}

@else

{{ __('labels.no_reason_provided') }}

@endif @if (! empty($return->images))
@foreach ($return->images as $imageUrl) @endforeach
@endif
@endif {{-- Refund breakdown --}}

{{ __('labels.refund_breakdown') }}

{{-- Comment: If return request is rejected and customer receives no refund, display clear rejection message --}} @if (in_array((string) $return->return_status, [(string) OrderItemReturnStatusEnum::SELLER_REJECTED(), (string) OrderItemReturnStatusEnum::REJECTED_AT_STORE()], true) && (float) $return->refund_amount <= 0)
{{ __('labels.no_refund_customer') ?? 'No Refund to Customer' }} — {{ __('labels.return_request_rejected') ?? 'This return request was rejected and no customer refund will be processed.' }}
@else @foreach ($refundBreakdown['items'] as $row) @endforeach
{{ $row['label'] }} {{ number_format($row['amount'], 2) }}
{{ __('labels.refund_total') }} {{ number_format($refundBreakdown['total'], 2) }}
@endif
{{-- Seller / Admin notes --}} @if ($return->seller_comment || $return->admin_comment)

{{ __('labels.notes') }}

@if ($return->seller_comment)
{{ __('labels.seller_note') }}
{{ $return->seller_comment }}
@endif @if ($return->admin_comment)
{{ __('labels.admin_note') }}
{{ $return->admin_comment }}
@endif
@endif {{-- Timeline --}}

{{ __('labels.timeline') }}

@include('returns._timeline', ['timelineSteps' => $timelineSteps])
{{-- RIGHT column --}}
{{-- Customer --}}

{{ __('labels.customer') }}

{{ $customer?->name ?? __('labels.n_a') }}
@if ($customer?->email)
{{ $customer->email }}
@endif @if ($isAdminPanel && $customer?->mobile)
{{ $customer->mobile }}
@endif
{{-- Order --}}

{{ __('labels.order') }}

#{{ $order?->order_id ?? $return->order_id }}
@if ($order?->created_at)
{{ $order->created_at->format('Y-m-d H:i') }}
@endif @if ($order)
{{ __('labels.order_item_id') }} #{{ $return->order_item_id }}
@endif
{{-- Store / Seller (admin-only) --}} @if ($isAdminPanel)

{{ __('labels.store_seller') }}

{{ $store?->name ?? __('labels.n_a') }}
@if ($sellerUser?->name)
{{ $sellerUser->name }}
@endif
@endif {{-- Pickup --}} @php use App\Enums\Order\OrderItemReturnPickupStatusEnum; $pickupStatus = (string) $return->pickup_status; $isApproved = (string) $return->return_status === (string) OrderItemReturnStatusEnum::SELLER_APPROVED(); $isAssignable = $isApproved && in_array($pickupStatus, [ (string) OrderItemReturnPickupStatusEnum::PENDING(), (string) OrderItemReturnPickupStatusEnum::ASSIGNED(), ], true); $rider = $return->deliveryBoy; $canAssign = ($isAdminPanel ?? false) && ($canAssignRider ?? false); @endphp @if (!($hideEvidenceCards ?? false))

{{ __('labels.pickup') }}

{{ __('labels.status') }}: {{ \Illuminate\Support\Str::headline($pickupStatus) }}
@if ($rider) @php $riderName = $rider->full_name ?? $rider->user?->name ?? '—'; $riderPhone = $rider->user?->mobile ?? $rider->user?->phone ?? null; @endphp
{{ __('labels.rider') }}: {{ $riderName }} @if ($riderPhone) · {{ $riderPhone }} @endif
@endif @if ($return->pickup_otp || ($return->snapshot_otp_required ?? false))
{{ __('labels.return_otp') ?? 'Pickup OTP' }}: {{ $return->pickup_otp ?? '—' }} @if ($return->pickup_otp_verified) {{ __('labels.verified') ?? 'Verified' }} @else {{ __('labels.pending') ?? 'Pending' }} @endif
@endif @if (! empty($return->pickup_images))
{{ __('labels.pickup_images') ?? 'Rider Proof Images' }}:
@foreach ($return->pickup_images as $imageUrl) @endforeach
@endif @if ($canAssign && $isAssignable) @endif
@endif @if (!($hideEvidenceCards ?? false)) @if ($return->store_rejection_reason || (string) $return->return_status === (string) OrderItemReturnStatusEnum::REJECTED_AT_STORE())

{{ __('labels.store_rejection_details') ?? 'Store Rejection Details' }}

{{ __('labels.rejection_reason') }}:
{{ $return->store_rejection_reason ?? '—' }}
{{ __('labels.action_taken') ?? 'Action Taken' }}:
@php $respParty = $return->responsible_party instanceof \BackedEnum ? $return->responsible_party->value : (string) $return->responsible_party; $deductionType = $return->rider_deduction_type; @endphp @if ($respParty === 'rider' || $return->deduct_from_rider || $return->action_on_rejection === 'deduct_from_delivery_boy') @if ($deductionType === 'delivery_earning') {{ \Illuminate\Support\Facades\Lang::has('labels.customer_refunded_deducted_delivery_earning') ? __('labels.customer_refunded_deducted_delivery_earning') : 'Customer Refunded · Deducted Delivery Earning' }} @elseif ($deductionType === 'product_cost' || $return->deduct_from_rider || $return->action_on_rejection === 'deduct_from_delivery_boy') {{ \Illuminate\Support\Facades\Lang::has('labels.customer_refunded_deducted_product_cost') ? __('labels.customer_refunded_deducted_product_cost') : 'Customer Refunded · Deducted Product Cost from Rider' }} @else {{ \Illuminate\Support\Facades\Lang::has('labels.customer_refunded_seller_loss') ? __('labels.customer_refunded_seller_loss') : 'Customer Refunded · Seller Absorbed Loss' }} @endif @else {{ \Illuminate\Support\Facades\Lang::has('labels.no_refund_customer') ? __('labels.no_refund_customer') : 'No Refund to Customer' }} @endif
@if (($respParty === 'rider' || $return->deduct_from_rider || $return->action_on_rejection === 'deduct_from_delivery_boy') && (float) ($return->deduction_amount ?? 0) > 0)
{{ __('labels.deducted_amount') ?? 'Deducted Amount' }}:
{{ isset($return->order) && $return->order->currency_code ? $return->order->currency_code : '$' }} {{ number_format($return->deduction_amount, 2) }}
@endif
@endif @endif {{-- Decision metadata --}} @if (!($hideEvidenceCards ?? false)) @if ($decidedBy)

{{ __('labels.decision') }}

{{ $isAdminDecided ? __('labels.by_support') : __('labels.by_seller') }}
{{ $decidedBy->name }}
@if ($decidedAt)
{{ $decidedAt->format('Y-m-d H:i') }}
@endif
@endif @endif