
PK 
@extends('user.layouts.master')
@section('title','Order Detail')
@section('main-content')
<div class="card">
<h5 class="card-header">Order <a href="{{route('order.pdf',$order->id)}}" class=" btn btn-sm btn-primary shadow-sm float-right"><i class="fas fa-download fa-sm text-white-50"></i> Generate PDF</a>
</h5>
<div class="card-body">
@if($order)
@php
$sn = 1;
@endphp
<table class="table table-striped table-hover">
<thead>
<tr>
<th>S.N.</th>
<th>Order No.</th>
<th>Name</th>
<th>Email</th>
<th>Quantity</th>
<th>Charge</th>
<th>Total Amount</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ $sn++ }}</td>
<td>{{$order->order_number}}</td>
<td>{{$order->first_name}}</td>
<td>{{$order->email}}</td>
<td>{{$order->quantity}}</td>
<td>₹{{$order->shipping_charge}}</td>
<td>₹{{number_format($order->total_amount,2)}}</td>
<td>
@if($order->status=='new')
<span class="badge badge-primary">{{$order->status}}</span>
@elseif($order->status=='process')
<span class="badge badge-warning">{{$order->status}}</span>
@elseif($order->status=='delivered')
<span class="badge badge-success">{{$order->status}}</span>
@else
<span class="badge badge-danger">{{$order->status}}</span>
@endif
</td>
<td>
<form method="POST" action="{{route('order.destroy',[$order->id])}}">
@csrf
@method('delete')
<button class="btn btn-danger btn-sm dltBtn" data-id={{$order->id}} style="height:30px; width:30px;border-radius:50%" data-toggle="tooltip" data-placement="bottom" title="Delete"><i class="fas fa-trash-alt"></i></button>
</form>
</td>
</tr>
</tbody>
</table>
<!-- Product Details Section -->
@if(count($order->cart_info) > 1)
<div class="product-details mt-4">
<h4 class="text-center pb-4">PRODUCT DETAILS</h4>
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th>Product</th>
<th>Quantity</th>
<th>Price</th>
<th>Subtotal</th>
<th>GST (18%)</th>
<th>Total</th>
</tr>
</thead>
<tbody>
@php
$totalTaxableValue = 0;
$totalGST = 0;
$isIntraState = ($order->country === 'Delhi');
@endphp
@foreach($order->cart_info as $cart)
@php
$product = DB::table('products')->select('title')->where('id',$cart->product_id)->first();
$totalWithGST = $cart->price * $cart->quantity;
// Calculate GST components (price includes 18% GST)
$taxableValue = $totalWithGST / (1 + 0.18); // Reverse calculate base price
$gstAmount = $totalWithGST - $taxableValue;
$totalTaxableValue += $taxableValue;
$totalGST += $gstAmount;
@endphp
<tr>
<td>{{ $product->title ?? '' }}</td>
<td>{{ $cart->quantity }}</td>
<td>₹{{ number_format($cart->price, 2) }}</td>
<td>₹{{ number_format($taxableValue, 2) }}</td>
<td>₹{{ number_format($gstAmount, 2) }}</td>
<td>₹{{ number_format($totalWithGST, 2) }}</td>
</tr>
@endforeach
<tr>
<td colspan="3" class="text-right"><strong>Subtotal:</strong></td>
<td>₹{{ number_format($totalTaxableValue, 2) }}</td>
<td>₹{{ number_format($totalGST, 2) }}</td>
<td>₹{{ number_format($order->sub_total, 2) }}</td>
</tr>
@if($isIntraState)
<tr>
<td colspan="4" class="text-right"><strong>CGST (9%):</strong></td>
<td>₹{{ number_format($totalGST / 2, 2) }}</td>
<td></td>
</tr>
<tr>
<td colspan="4" class="text-right"><strong>SGST (9%):</strong></td>
<td>₹{{ number_format($totalGST / 2, 2) }}</td>
<td></td>
</tr>
@else
<tr>
<td colspan="4" class="text-right"><strong>IGST (18%):</strong></td>
<td>₹{{ number_format($totalGST, 2) }}</td>
<td></td>
</tr>
@endif
<tr>
<td colspan="5" class="text-right"><strong>Shipping Charge:</strong></td>
<td>₹{{ number_format($order->shipping_charge, 2) }}</td>
</tr>
<tr>
<td colspan="5" class="text-right"><strong>Grand Total:</strong></td>
<td>₹{{ number_format($order->total_amount, 2) }}</td>
</tr>
</tbody>
</table>
</div>
</div>
@endif
<section class="confirmation_part section_padding">
<div class="order_boxes">
<div class="row">
<div class="col-lg-6 col-lx-4">
<div class="order-info">
<h4 class="text-center pb-4">ORDER INFORMATION</h4>
<table class="table">
<tr class="">
<td>Order Number</td>
<td> : {{$order->order_number}}</td>
</tr>
<tr>
<td>Order Date</td>
<td> : {{$order->created_at->format('D d M, Y')}} at {{$order->created_at->format('g : i a')}} </td>
</tr>
<tr>
<td>Quantity</td>
<td> : {{$order->quantity}}</td>
</tr>
<tr>
<td>Order Status</td>
<td> : {{$order->status}}</td>
</tr>
<tr>
<td>Shipping Charge</td>
<td> :₹ {{$order->shipping_charge}}</td>
</tr>
<tr>
<td>Total Amount</td>
<td> : ₹ {{number_format($order->total_amount,2)}}</td>
</tr>
<tr>
<td>Payment Method</td>
<td> : @if($order->payment_method=='cod') Cash on Delivery @else Paypal @endif</td>
</tr>
<tr>
<td>Payment Status</td>
<td> : {{$order->payment_status}}</td>
</tr>
</table>
</div>
</div>
<div class="col-lg-6 col-lx-4">
<div class="shipping-info">
<h4 class="text-center pb-4">SHIPPING INFORMATION</h4>
<table class="table">
<tr class="">
<td>Full Name</td>
<td> : {{$order->first_name}}</td>
</tr>
<tr>
<td>Email</td>
<td> : {{$order->email}}</td>
</tr>
<tr>
<td>Phone No.</td>
<td> : {{$order->phone}}</td>
</tr>
<tr>
<td>Address</td>
<td> : {{$order->address1}}, {{$order->address2}}</td>
</tr>
<tr>
<td>State</td>
<td> : {{$order->country}}</td>
</tr>
<tr>
<td>Post Code</td>
<td> : {{$order->post_code}}</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</section>
@endif
</div>
</div>
@endsection
@push('styles')
<style>
.order-info,.shipping-info{
background:#ECECEC;
padding:20px;
}
.order-info h4,.shipping-info h4{
text-decoration: underline;
}
.product-details {
margin-bottom: 30px;
}
.product-details table {
background: #fff;
}
.product-details th {
background: #f8f9fa;
}
</style>
@endpush


PK 99