@extends('backend.admin.layouts.app')
@section('content')
    <div class="pagetitle">
        <h1>Dashboard</h1>
        <nav>
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="index.html">Home</a></li>
                <li class="breadcrumb-item">Dashboard</li>
                <li class="breadcrumb-item active">{{ $PageTitle }}</li>
            </ol>
        </nav>
    </div><!-- End Page Title -->

    <section class="section dashboard">

        <div class="row">
            <div class="col-lg-12">

                <div class="card">
                    <div class="card-body mt-3">
                        <!-- Table with stripped rows -->
                        <table class="table table-striped mt-4">
                            <thead>
                                <tr>
                                    <th scope="col">#</th>
                                    <th scope="col">Name</th>
                                    <th scope="col">Phone</th>
                                    <th scope="col">Address</th>
                                    <th scope="col">Price</th>
                                    <th scope="col">Status</th>
                                    <th scope="col">Action</th>
                                    <th scope="col"></th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach ($orders as $order)
                                    <tr>
                                        <th scope="row">{{ $loop->iteration }}</th>
                                        <td>{{ $order->name }}</td>
                                        <td>{{ $order->phone }}</td>
                                        <td>{{ $order->address }}</td>
                                        <td>{{ $order->total_price }}</td>
                                      
                                        <td>
                                            @if ($order->status === 'pending')
                                                <h6 class="badge bg-primary">{{ ucfirst($order->status) }}</h6>
                                            @elseif ($order->status === 'on-hold')
                                                <h6 class="badge bg-warning">{{ ucfirst($order->status) }}</h6>
                                            @elseif ($order->status === 'completed')
                                                <h6 class="badge bg-success">{{ ucfirst($order->status) }}</h6>
                                            @else
                                                <h6 class="badge bg-danger">{{ ucfirst($order->status) }}</h6>
                                            @endif
                                        </td>
                                        {{-- <td>{{ $order->status }}</td> --}}
                                        <td>
                                            <a href="{{ route('admin.order-details', $order->id) }}" class="mr-1"
                                                title="Edit">
                                                <img src="{{ asset('assets/img/shopping.png') }}" alt="">
                                            </a>

                                            <a href="#" class="ms-2 deleteItem"
                                                data-formid="delete_row_form_{{ $order->id }}">
                                                <img src="{{ asset('assets/img/trash.png') }}" alt="">
                                            </a>
                                            <form action="{{route('admin.order-delete', $order->id)}}" method="post" id="delete_row_form_{{ $order->id }}">
                                                @csrf
                                                {{ method_field('DELETE') }}
                                                <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                            </form>
                                        </td>
                                        <td>
                                            <form action="{{route('admin.order-update', $order->id)}}"
                                                method="POST">
                                                @csrf
                                                @method('put')
                                                <button type="submit" name="status" value="pending"
                                                    class="border border-0 badge bg-primary pending">Pending</button>
                                                <button type="submit" name="status" value="on-hold"
                                                    class="border border-0 badge bg-warning on-hold">On-hold</button><br/>
                                                <button type="submit" name="status" value="completed"
                                                    class="border border-0 badge bg-success completed">Completed</button>
                                                <button type="submit" name="status" value="cancelled"
                                                    class="border border-0 badge bg-danger cancelled">Cancelled</button>
                                            </form>
                                        </td>
                                    </tr>
                                @endforeach

                            </tbody>
                        </table>
                        <!-- End Table with stripped rows -->

                    </div>
                </div>
            </div>
        </div>

    </section>
@endsection
