@extends('layouts.app')

@section('page-title', __('Flight Bookings'))
@section('page-heading', __('Flight Bookings'))

@section('breadcrumbs')
    <li class="breadcrumb-item active">
        @lang('Flight Submissions')
    </li>
@stop

@section('content')

    @include('partials.messages')

    <div class="card">
        <div class="card-body">
            <div class="table-responsive" id="flights-table-wrapper">
                <table id="flights-table" class="table table-borderless table-striped">
                    <thead>
                        <tr>
                            <th>@lang('Personnel')</th>
                            <th>@lang('Itinerary')</th>
                            <th>@lang('Dates')</th>
                            <th>@lang('Pax')</th>
                            <th>@lang('Trip Type')</th>
                            <th>@lang('Mission')</th>
                            <th>@lang('Status')</th>
                            <th>@lang('Payment')</th>
                            <th class="text-center">@lang('Action')</th>
                        </tr>
                    </thead>
                    <tbody>
                        @if (count($flights))
                            @foreach ($flights as $flight)
                                <tr>
                                    <td class="align-middle">
                                        <strong>{{ $flight->fname }}</strong><br>
                                        <small class="text-muted">{{ $flight->email }}</small>
                                    </td>
                                    <td class="align-middle">
                                        <i class="fas fa-plane-departure text-success mr-1"></i> {{ $flight->departure_city }}<br>
                                        <i class="fas fa-plane-arrival text-primary mr-1"></i> {{ $flight->destination_city }}
                                    </td>
                                    <td class="align-middle">
                                        <small><strong>DEP:</strong> {{ $flight->departure_date }}</small><br>
                                        <small><strong>RET:</strong> {{ $flight->return_date ?? 'N/A' }}</small>
                                    </td>
                                    <td class="align-middle text-center">{{ $flight->passengers }}</td>
                                    <td class="align-middle">
                                        <span class="badge badge-secondary">{{ $flight->trip_type }}</span>
                                    </td>
                                    <td class="align-middle">{{ $flight->service_branch }}</td>
                                    <td class="align-middle">
                                        <span class="badge badge-info">{{ $flight->military_status }}</span>
                                    </td>
                                    <td class="align-middle">
                                        <small>{{ $flight->payment_preference }}</small>
                                    </td>
                                    <td class="text-center align-middle">
                                        <button class="btn btn-icon" title="@lang('View Details')" 
                                                onclick="alert('Request Note: {{ addslashes($flight->message) }}')">
                                            <i class="fas fa-info-circle text-info"></i>
                                        </button>
                                    </td>
                                </tr>
                            @endforeach
                        @else
                            <tr>
                                <td colspan="9" class="text-center"><em>@lang('No flight records found.')</em></td>
                            </tr>
                        @endif
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    {!! $flights->render() !!}

@stop

@section('scripts')
    <script type="text/javascript" src="https://cdn.datatables.net/v/bs4/dt-1.10.25/datatables.min.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/buttons/1.7.1/js/dataTables.buttons.min.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.bootstrap4.min.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.html5.min.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.print.min.js"></script>

    <script>
        $(document).ready(function() {
            $('#flights-table').DataTable({
                dom: 'Bfrtip',
                buttons: ['copy', 'csv', 'excel', 'pdf', 'print'],
                "columnDefs": [
                    { "orderable": false, "targets": 8 } 
                ]
            });
        });
    </script>
@stop