@extends('layouts.admin.app') @section('content') {{-- --}}

Order Detail

{{-- --}}
No record found. @if($disable >= 1) @else

Assign Agent

@csrf
@endif @if($disable == 0) @else {{--

Processed Order Detail

--}} {{-- --}} @php $mailDisable = 0; $groupedData = []; //dd($assinged); foreach ($assinged as $assignedItem) { foreach ($assigned_agent_product_map as $assigned_agent_product_maps) { if ($assignedItem->id == $assigned_agent_product_maps->agent_assinged_id) { $agent = $agents->firstWhere('id', $assignedItem->agent_id); $productItem = $product->firstWhere('id', $assigned_agent_product_maps->product_id); $productMapedItem = $agent_product_list->firstWhere('id', $assigned_agent_product_maps->product_id); $productQty = $assigned_agent_product_map ->where('product_id', $assigned_agent_product_maps->product_id) ->where('agent_assinged_id', $assigned_agent_product_maps->agent_assinged_id) ->first(); if ($productItem && $agent) { // ✅ Use agent_order_id as the grouping key $orderKey = $assignedItem->agent_order_id; if (!isset($groupedData[$orderKey])) { $groupedData[$orderKey] = [ 'products' => [], 'mapped_details' => [], 'qty' => [], 'OrderID' => $assignedItem->id, 'agent_order_id' => $assignedItem->agent_order_id, 'delivery_date' => $assignedItem->delivery_date, 'agent_id' => $assignedItem->agent_id, 'totalPrice' => $assignedItem->totalPrice, 'status' => $assignedItem->status, 'agent_name' => $agent->name, 'extra' => $assignedItem->extra, 'Deliver_charge' => $assignedItem->Deliver_charge, 'reason' => $assignedItem->reason, 'track_no' => $assignedItem->track_no, 'isConfirmCl' => $assignedItem->isConfirmCl ]; } $groupedData[$orderKey]['products'][] = $productItem->product_name; $groupedData[$orderKey]['mapped_details'][] = $productMapedItem->fnid; $groupedData[$orderKey]['qty'][] = $productQty->qty; } } } } @endphp @php @endphp {{----}} @php $i = 1; @endphp @php $Delivery_Price = 0; $Extra = 0; $Delivery = 0; $total = 0; @endphp @foreach($groupedData as $data) {{----}} @endforeach
Sl No Order Id Product Name & QtyQtyAssigned Agent Price Delivery Charge Extra Reason Track No Status
{{ $i++ }} {{ $data['agent_order_id'] }}
{{ date('jS M, Y' , strtotime($data['delivery_date'])) }}
{!! implode('
', $data['mapped_details']) !!}
{!! implode('
', $data['qty']) !!}
@foreach($data['mapped_details'] as $index => $detail) {{ $detail }} [Qty:{{ $data['qty'][$index] ?? 0 }}] @if (!$loop->last)
@endif @endforeach
{{ ucwords($data['agent_name']) }} {{ $data['totalPrice'] }} {{ $data['Deliver_charge'] }} {{ $data['extra'] }} {{ $data['reason'] }} {{ $data['track_no'] }} @if($data['status'] == 'P')
PENDING
@elseif($data['status'] == 'PC') @php $mailDisable++; @endphp
PROGRESS
@elseif($data['status'] == 'CL')
CANCEL
@elseif($data['status'] == 'H')
HOLD
@elseif($data['status'] == 'S') @php $mailDisable++; @endphp
SHIPPED
@elseif($data['status'] == 'D') @php $mailDisable++; @endphp
DELIVERED
@endif @if($data['isConfirmCl'] == 0 && $data['status'] == "CL") Confirm Cancel @endif
@foreach($groupedData as $amount) @if($amount['isConfirmCl'] != 1 && $amount['status'] != "CL") @php $total +=$amount['totalPrice'] + $amount['extra'] + $amount['Deliver_charge']; @endphp @endif @endforeach
@if($order->order_delivery_status == "CL") @if($assingedCancelCount > 0) @endif
@endif @if($order->order_delivery_status != 'CL') @if($order->order_delivery_status != 'D') @if($disable == $mailDisable)

Customer Email

@php $count = 0; $buttonEnable = count($agentasGroupBy) + 1; $buttonCount = 1; @endphp @foreach($agentasGroupBy as $assign) @if($assign->status != 'P') @php $count++; $buttonCount++; @endphp @endif @endforeach {{-- @if($count > 0) @endif @if($buttonCount == $buttonEnable) @endif
--}} @endif @endif @endif @php $grandTotal = 0; @endphp @if($order->order_delivery_status == 'D') @php $grandTotal = $Delivery_Price+$Extra+$Delivery+$total; @endphp

Paid To Agent : {{$total}}

@endif @if($order->order_delivery_status == 'PC') @foreach($agentasGroupBy as $assignItems) @if($assignItems->status == "CL") @else @endif @endforeach @endif @endif
@endsection @section('script') @endsection