@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">

                <div class="card-header">{{ __('Created requests for virtual') }}</div>
                <div class="card-body">
                    <table class="table">
                        <thead>
                          <tr>
                            <th scope="col">Creator</th>
                            <th scope="col">System</th>
                            <th scope="col">Actions</th>
                          </tr>
                        </thead>
                        <tbody>
                        @forelse ($virtualszero as $virtual)
                            @if ($virtual->ready == '0')                           
                                <tr>
                                    <td>{{ $virtual->user_name }}</td>
                                    <td>{{ $virtual->system }}</td>
                                    <td>
                                        <a href="{{ route('virtuals.edit', $virtual->id) }}"><button type="button" class="btn btn-primary float-left">Edit</button></a>
                                        <form action="{{ route('virtuals.destroy', $virtual) }}" method="POST" class="float-left">
                                            @csrf
                                            {{ method_field('DELETE') }}
                                            <button type="submit" class="btn btn-warning">Delete</button>
                                        </form>                                    
                                    </td>
                                </tr>
                            @endif
                        @empty
                        <tr>
                            <td>No Virtuals</td>                                
                        </tr>
                        @endforelse
                        </tbody>
                    </table>
                </div>

                @if (count($virtualsone)>0 )
                <div class="card-header">{{ __('Waiting virtuals') }}</div>
                <div class="card-body">
                    <table class="table">
                        <thead>
                          <tr>
                            <th scope="col">Creator</th>
                            <th scope="col">System</th>
                            <th scope="col">Actions</th>
                          </tr>
                        </thead>
                        <tbody>
                        @forelse ($virtualsone as $virtual)
                            @if ($virtual->ready == '1')    
                                <tr>
                                    <td>{{ $virtual->user_name }}</td>
                                    <td>{{ $virtual->system }}</td>
                                    <td>
                                        <form action="{{ route('virtuals.destroy', $virtual) }}" method="POST" class="float-left">
                                            @csrf
                                            {{ method_field('DELETE') }}
                                            <button type="submit" class="btn btn-warning">Delete</button>
                                        </form>                                    
                                    </td>
                                </tr>
                            @endif
                        @empty
                            <tr>
                                <td>No Virtuals</td>                                
                            </tr>
                        @endforelse
                        </tbody>
                    </table>                    
                </div>
                @endif    

                @if (count($virtualstwo)>0 )
                <div class="card-header">{{ __('Ready virtuals') }}</div>
                <div class="card-body">
                    <table class="table">
                        <thead>
                          <tr>
                            <th scope="col">Creator</th>
                            <th scope="col">System</th>
                            <th scope="col">Actions</th>
                          </tr>
                        </thead>
                        <tbody>
                        @forelse ($virtualstwo as $virtual)
                            @if ($virtual->ready == '2')    
                                <tr>
                                    <td>{{ $virtual->user_name }}</td>
                                    <td>{{ $virtual->system }}</td>
                                    <td>
                                        <form action="/virtuals/{{ $virtual->id }}/requestdelete" method="GET">
                                            @csrf
                                            <button type="submit" class="btn btn-warning float-left">Request delete</button>
                                        </form>                                
                                    </td>
                                </tr>
                            @endif
                        @empty
                            <tr>
                                <td>No Virtuals</td>                                
                            </tr>
                        @endforelse
                        </tbody>
                    </table>                    
                </div>
                @endif    

                @if (count($virtualsthree)>0 )
                <div class="card-header">{{ __('Virtuals waiting for delete') }}</div>
                <div class="card-body">
                    <table class="table">
                        <thead>
                          <tr>
                            <th scope="col">Creator</th>
                            <th scope="col">System</th>
                            <th scope="col">Actions</th>
                          </tr>
                        </thead>
                        <tbody>
                        @forelse ($virtualsthree as $virtual)
                            @if ($virtual->ready == '3')    
                                <tr>
                                    <td>{{ $virtual->user_name }}</td>
                                    <td>{{ $virtual->system }}</td>
                                    <td>
                                        <form action="/virtuals/{{ $virtual->id }}/canceldelete" method="GET">
                                            @csrf
                                            <button type="submit" class="btn btn-secondary float-left">Cancel delete</button>
                                        </form>                                
                                    </td>
                                </tr>
                            @endif
                        @empty
                            <tr>
                                <td>No Virtuals</td>                                
                            </tr>
                        @endforelse
                        </tbody>
                    </table>                    
                </div>
                @endif    
            </div>
        </div>
    </div>
</div>
@endsection
