@extends('admin.layouts') @section('title', 'Recent Orders') @section('header') @endsection @section('content')

Recent Orders

@if ($order->status == 'accepted') Accepted Download Invoice Print Invoice @elseif($order->status == 'rejected') Rejected @else Accept Reject @endif
@foreach ($recent_orders as $recent_order)

Order ID: #{{ $recent_order->order_random_id }}

Placed on: {{ $recent_order->created_at->format('d-m-Y h:i A') }}
@if ($recent_order->status == 'pending') Payment Status: Paid @endif
@endforeach

Customer Information

@foreach ($recent_orders as $recent_order)

Name: {{ $recent_order->user_name ?? 'N/A' }}

Email: {{ $order->user->email ?? 'N/A' }}

Phone: {{ $order->user->phone_number ?? 'N/A' }}

@endforeach

Shipping Address

@foreach ($recent_orders as $recent_order)

{{ $recent_order->delivery_address }}

@endforeach

Order Details

@php function decodeData($data) { if (is_string($data)) { $decoded = json_decode($data, true); return is_array($decoded) ? $decoded : explode('~', $data); } return []; } $global_item_sn = 0; @endphp @foreach ($recent_orders as $order_key => $recent_order) {{-- Changed index to order_key --}} @php // Decode order details $product_names = decodeData($recent_order->product_details_name); $images = json_decode($recent_order->image, true); $images = is_array($images) ? $images : []; // Ensure it's an array $quantities = decodeData($recent_order->quantity); $gst_prices = decodeData($recent_order->gst_price); $price_details = decodeData($recent_order->price_details); $variant_ids = decodeData($recent_order->variant_id); $hsn_codes = decodeData($recent_order->hsn_code); $product_ids = decodeData($recent_order->product_details_id); $imei_serial_numbers = json_decode($recent_order->imei_serial_numbers, true) ?? []; @endphp @for ($i = 0; $i < count($product_names); $i++) @php $global_item_sn++; // Increment for each item row @endphp @endfor @endforeach
S/N ITEM IMAGE QUANTITY PRODUCT ID HSN CODE PRICE TOTAL
{{ $global_item_sn }} {{ $product_names[$i] ?? 'N/A' }} @if (isset($variant_ids[$i]) && $variant_ids[$i] != 'N/A' && $variant_ids[$i] != '')
Variant: {{ $variant_ids[$i] }} @endif
IMEI/Serial
Product Image {{ $quantities[$i] ?? 0 }} {{ $product_ids[$i] ?? 'N/A' }} {{ $hsn_codes[$i] ?? 'N/A' }} {{ $price_details[$i] ?? 'N/A' }} {{ number_format(($price_details[$i] ?? 0.0) * ($quantities[$i] ?? 0), 2) }}

Order Summary

@foreach ($recent_orders as $recent_order) @php // Decode and multiply price by quantity $price_details = decodeData($recent_order->price_details); $quantities = decodeData($recent_order->quantity); $sub_total = 0; foreach ($price_details as $key => $price) { $sub_total += $price * ($quantities[$key] ?? 1); } @endphp

Sub Total: ₹{{ number_format($sub_total, 2) }}

Cash Wallet: -₹{{ number_format($recent_order->cash_wallet, 2) }}

Shopping Wallet: -₹{{ number_format($recent_order->shopp_wallet, 2) }}

Delivery Fee: +₹{{ number_format($recent_order->delivery_fee, 2) }}


Total: ₹{{ number_format($recent_order->amount, 2) }}
@endforeach

Tax Calculation

@foreach ($recent_orders as $recent_order) @php $beforeGstValue = 0; $cgst = 0; $sgst = 0; $totalAmount = 0; $is_gst = true; $gst_rate = 18; if ($is_gst && $recent_order->amount > 0 && $gst_rate > 0) { $beforeGstValue = round($recent_order->amount / (1 + $gst_rate / 100), 2); $totalGst = round($recent_order->amount - $beforeGstValue, 2); $cgst = round($totalGst / 2, 2); $sgst = round($totalGst / 2, 2); $totalAmount = $recent_order->amount; } else { $beforeGstValue = $recent_order->amount; $cgst = 0; $sgst = 0; $totalAmount = $recent_order->amount; } @endphp

Before GST Value: ₹{{ number_format($beforeGstValue, 2) }}

SGST: +₹{{ number_format($sgst, 2) }}

CGST: +₹{{ number_format($cgst, 2) }}


Total (incl. GST): ₹{{ number_format($totalAmount, 2) }}
@endforeach
{{-- Modals remain unchanged as their styling is handled by Bootstrap --}}
@endsection @section('footer') @endsection