@extends('backEnd.layouts.master') @section('title',$order_status->name.' Order') @section('content')

{{ $order_status->name }} Order ({{ $order_status->orders_count }})

@foreach($show_data as $key => $value) {{-- Order Note (client) --}} {{-- Admin Note --}} {{-- Amount (show remaining if partial paid) --}} {{-- Courier Information --}} @endforeach
SL Action Invoice Date Name Type Vendor Reseller IP Order Note Admin Note Amount Status Courier Track Fraud Check
{{ $loop->iteration }}
@csrf
{{ $value->invoice_id }} {{ date('d-m-Y', strtotime($value->updated_at)) }}
{{ date('h:i:s a', strtotime($value->updated_at)) }}
{{ $value->shipping ? $value->shipping->name : '' }}

{{ $value->shipping ? $value->shipping->phone : '' }}

@php $items = $value->orderDetails; $types = []; foreach ($items as $item) { if ($item->product && $item->product->is_digital == 1) { $types[] = 'Digital'; } else { $types[] = 'Physical'; } } $types = array_unique($types); if (count($types) === 1) { echo $types[0]; } else { echo "Mixed"; } @endphp @php $vendors = []; if ($value->orderDetails) { foreach ($value->orderDetails as $item) { if ($item->vendor && $item->vendor->shop_name) { $vendors[$item->vendor->id] = $item->vendor->shop_name; } } } $uniqueVendors = array_unique($vendors); @endphp @if(count($uniqueVendors) > 0) @foreach($uniqueVendors as $vendorName) {{ $vendorName }} @endforeach @else - @endif @if($value->reseller_profit) @if($value->user) {{ Str::limit($value->user->name, 15) }}
Profit: ৳{{ number_format($value->reseller_profit, 0) }} @else Reseller Order
Profit: ৳{{ number_format($value->reseller_profit, 0) }} @endif @else - @endif
{{ $value->ip_address }} @if($value->ip_address) @php $isBlocked = in_array($value->ip_address, isset($blockedIps) ? $blockedIps : []); @endphp @if($isBlocked) Blocked @else @endif @endif
@php $orderNote = isset($value->order_note) ? $value->order_note : (isset($value->note) ? $value->note : ''); @endphp @php $payment = \App\Models\Payment::where('order_id', $value->id)->first(); $paid = $payment ? floatval($payment->amount) : 0; $total = floatval($value->amount); $showAmount = $total; if ($paid > 0 && $paid < $total) { $showAmount = $total - $paid; } @endphp ৳{{ number_format($showAmount, 2) }} {{ $value->status ? $value->status->name : '' }} @php // Priority: courier_tracking_id > consignment_id $trackingId = isset($value->courier_tracking_id) ? $value->courier_tracking_id : $value->consignment_id; $courierType = $value->courier_type; // If no courier_type but has consignment_id, assume it's steadfast (backward compatibility) // This handles old orders that were sent via Steadfast but don't have courier_type if (!$courierType && $value->consignment_id) { $courierType = 'steadfast'; } // If still no courier_type but has tracking_id, assume steadfast if (!$courierType && $trackingId) { $courierType = 'steadfast'; } @endphp @if($trackingId) @php $courierName = ucfirst(isset($courierType) ? $courierType : 'Steadfast'); $ct = isset($courierType) ? strtolower($courierType) : 'steadfast'; if ($ct === 'pathao') { $courierColor = 'info'; } elseif ($ct === 'steadfast') { $courierColor = 'primary'; } elseif ($ct === 'redx') { $courierColor = 'warning'; } else { $courierColor = 'primary'; } @endphp
{{ $courierName }}
ID: {{ Str::limit($trackingId, 15) }} @if($value->courier_sent_at)
{{ date('d-m-Y', strtotime($value->courier_sent_at)) }} @endif
@else - @endif
@php // Get tracking ID (new field or fallback to old consignment_id) $trackingId = isset($value->courier_tracking_id) ? $value->courier_tracking_id : $value->consignment_id; $courierType = $value->courier_type; // If no courier_type but has consignment_id, assume it's steadfast if (!$courierType && $value->consignment_id) { $courierType = 'steadfast'; } @endphp @if(!empty($trackingId)) @if($courierType == 'pathao') Track @elseif($courierType == 'steadfast' || (!$courierType && $trackingId)) Track @elseif($courierType == 'redx') Track @else {{ $trackingId }} @endif @else কোন রেকর্ড নেই @endif {{-- LOGIC: - is_null() ব্যবহার করা হয়েছে কারণ 0 একটি ভ্যালিড রেট হতে পারে (ফ্রড)। - NULL হলে "যাচাই করুন" (হলুদ)। - অন্যথায় রেট দেখাবে (সবুজ/লাল)। --}} @if(is_null($value->fraud_rate)) চেকিং @else {{ $value->fraud_rate }}% {{ $value->fraud_rate >= 80 ? 'নিরাপদ' : 'ঝুঁকি' }} @endif
{{ $show_data->links('pagination::bootstrap-4') }}
@endsection