<!-- Files -->
<div class="card mb-2">
    <h6 class="card-header  bg-primary text-white py-2" data-toggle="collapse" data-target="#collapseBookingFiles" aria-expanded="false" aria-controls="collapseBookingFiles">
        <strong style="line-height: 1.6em">PDF Dateien</strong>
    </h6>
    <div class="collapse" id="collapseBookingFiles">

        @php($booking_files_count = 1)
        <div class="card-body row">
            <div class="table-responsive" id="booking_files_table">
                <table class="table table-striped table-sm">
                    <thead>
                    <tr>
                        <th>#</th>
                        <th>Datei</th>
                        <th>Inhalt</th>
                        <th>Datum</th>
                        <th>&nbsp;</th>
                    </tr>
                    </thead>
                    <tbody>
                    @if($travel_user_booking_fewo->fewo_lodging)
                        <tr>
                            <th scope="row">{{$booking_files_count++}}</th>
                            <td>
                                <a target="_blank" href="{{ route('customer_file_show', ['fewo_instruction_pdf', $travel_user_booking_fewo->fewo_lodging->id, 'stream']) }}" class="badge badge-md badge-next">
                                    <i class="fa fa-file-pdf mr-1"></i> {{\App\Services\BookingFewo::getFeWoInstructionPDFName($travel_user_booking_fewo->fewo_lodging)}}
                                </a>
                            </td>
                            <td>
                                application/pdf
                            </td>
                            <td>-</td>
                            <td>
                                <a href="{{ route('customer_file_show', ['fewo_instruction_pdf', $travel_user_booking_fewo->fewo_lodging->id, 'download']) }}" class="btn btn-xs btn-default"
                                   title="Download" data-placement="left" rel="tooltip">
                                    <i class="fa fa-download"></i>
                                </a>
                            </td>
                        </tr>
                    @endif
                    @foreach(\App\Services\BookingFewo::contentFiles() as $content_file)
                        @if($file = \App\Models\CMSContent::getModelBySlug($content_file))
                            <tr>
                                <th scope="row">{{$booking_files_count++}}</th>
                                <td>
                                    <a target="_blank" href="{{ $file->getURL() }}" class="badge badge-md badge-next">
                                        <i class="fa fa-file-pdf mr-1"></i> {{$file->name}}
                                    </a>
                                </td>
                                <td>
                                    {{ $file->formatBytes() }}
                                </td>
                                <td>{{\App\Services\Util::_format_date($file->created_at, 'date')}}</td>
                                <td>
                                    <a href="{{ $file->getURL('download') }}" class="btn btn-xs btn-default"
                                       title="Download" data-placement="left" rel="tooltip">
                                        <i class="fa fa-download"></i>
                                    </a>
                                </td>
                            </tr>
                        @endif
                    @endforeach
                    @if($travel_user_booking_fewo->booking_files)
                        @foreach($travel_user_booking_fewo->booking_files as $booking_file)
                            <tr>
                                <th scope="row">{{$booking_files_count++}}</th>
                                <td>
                                    <a target="_blank" href="{{ $booking_file->getURL() }}" class="badge badge-md badge-secondary">
                                        <i class="{{$booking_file->getIconExt()}} mr-1"></i> {{$booking_file->original_name}}
                                    </a>
                                </td>
                                <td>
                                    {{ $booking_file->mine }} | {{ $booking_file->formatBytes() }}
                                </td>
                                <td>{{\App\Services\Util::_format_date($booking_file->created_at, 'date')}}</td>
                                <td>
                                    <a href="{{ $booking_file->getURL('download') }}" class="btn btn-xs btn-default"
                                       title="Download" data-placement="left" rel="tooltip">
                                        <i class="fa fa-download"></i>
                                    </a>
                                    <a class="ml-2 btn btn-xs btn-danger" href="{{ route('travel_user_booking_fewo_delete', [$booking_file->id, 'booking_fewo_files']) }}"  onclick="return confirm('{{__('Wirklich löschen?')}}');"><i class="fa fa-trash-alt"></i></a>

                                </td>
                            </tr>
                        @endforeach
                    @endif
                    </tbody>
                </table>

            </div>

            <div class="text-right d-block w-100">
                @if(Auth::user()->isPermission('sua-st-em'))
                    <div class="float-left small">Allgemeine Dateien unter: <a href="{{route('admin_settings_emails', ['settings'])}}">Einstellungen -> E-Mails / Einstellungen</a></div>
                @endif
            <button type="button" class="btn btn-sm btn-primary" data-toggle="modal"
                    data-target="#modals-load-content"
                    data-id="new-file"
                    data-model="TravelUserBookingFile"
                    data-action="modal-upload-booking-file"
                    data-url=""
                    data-redirect="back"
                    data-travel_user_booking_fewo_id="{{$travel_user_booking_fewo->id}}"
                    data-route="{{ route('customer_fewo_modal_load') }}"><i class="ion ion-md-cloud-upload"></i>&nbsp;Datei hinzufügen</button>
            </div>
        </div>
    </div>
</div>

