Current File : //home/tradevaly/public_html/resources/views/user/pages/order/buying_view.blade.php
@extends('user.ayaan.master')
@push('title','Order')
@push('style')
    
@endpush

@section('content')
    <div class="container">
        <div class="row">
            <div class="col-md-8">
                <div class="card">
                    <div class="card-header d-flex justify-content-between">
                        <h3>Order Details</h3>
                        <button class="btn btn-success" onclick="window.print()"><i class="fas fa-print"></i> Print</button>
                    </div>
                    <div class="card-body">
                <div class="d-flex justify-content-between ">
                    <div class="text-left">
                        <h3>Order Number</h3>
                        <p>{{$order->order_id}}</p>
                        <p><strong>Date : </strong>{{$order->created_at->format('d/m/Y')}}</p>
                    </div>
                    <div class="text-end">
                        
                        <p class="mt-4">Payment Method :{{$order->payment_type}}</p>
                        <p>Payment Status:{{$order->payment_status}}</p>
                    </div>
                </div>
                <table class="table">
                      <thead>
                        <tr>
                          <th scope="col">#</th>
                          <th scope="col">Product image</th>
                          <th scope="col">Product Title</th>
                          <th scope="col">Product Price</th>
                          <th scope="col">Quantity </th>
                          <th scope="col" style="text-align: center;">Status</th>
                          <th scope="col">Total</th>
                        </tr>
                      </thead>
                      <tbody>
                          @php
                          $total = 0;
                          $discount = 0;
                          @endphp
                          @foreach($items as $item)
                        <tr>
                          <th scope="row">{{$loop->iteration}}</th>
                          <td><img src="{{asset('storage/images/admin/product/'.(isset($item->product->image) ?$item->product->image:""))}}" height="50" alt=""></td>
                          <td>{{isset($item->product->title)?$item->product->title:$item->product_title}}</td>
                          <td>{{$item->product_price}}</td>
                          <td>{{$item->quantity}}</td>
                          <td>
                              @if($item->status == "new")
                            <p class="bg-primary rounded-pill text-center text-white" style="width: 100px;" >{{$item->status}}</p>
                            @elseif($item->status == "pending")
                            <p class="bg-warning rounded-pill text-center text-white" style="width: 100px;" >{{$item->status}}</p>
                            @elseif($item->status == "cancel")
                            <p class="bg-danger rounded-pill text-center text-white" style="width: 100px;" >{{$item->status}}</p>
                            @elseif($item->status == "delevered")
                            <p class="bg-success rounded-pill text-center text-white" style="width: 100px;" >{{$item->status}}</p>
                            @endif
                          </td>
                          <td>{{$item->quantity * $item->product_price}}</td>

                          @php
                          $total= $total + ($item->quantity * $item->product_price);
                          $discount = $discount + ($item->discount_price * $item->quantity );
                          @endphp
                        </tr>
                        @endforeach
                        <tr>
                            <td colspan="6" class="text-end"><strong>Total : </strong></td>
                            <td>{{$total}}</td>
                        </tr>
                        <tr>
                            <td colspan="6" class="text-end"><strong>Discount : </strong></td>
                            <td>{{$discount}}</td>
                        </tr>
                        <tr>
                            <td colspan="6" class="text-end"><strong>SubTotal : </strong></td>
                            <td>{{$total -  $discount}}</td>
                        </tr>
                      </tbody>
                    </table>
            </div>
            </div>
            </div>
            <div class="col-md-4">
                <div class="card">
                    <div class="card-header">
                        <h2>Customer Details</h2>
                    </div>
                    <div class="card-body">
                        <ul class="list-group list-group-flush">
                          <li class="list-group-item"><strong>Name:</strong> {{$order->name}}</li>
                          <li class="list-group-item"><strong>Email:</strong> {{$order->email}}</li>
                          <li class="list-group-item"><strong>Phone:</strong> {{$order->phone}}</li>
                          <li class="list-group-item"><strong>Address:</strong> {{$order->address_1}}</li>
                          <li class="list-group-item"><strong>Company:</strong> {{$order->user->company->name}}</li>
                          
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
@stop

@push('script')
   
@endpush