@extends('layouts.layout-2')

@section('content')

    <h4 class="font-weight-bold py-3 mb-1">
        {{ __('Einstellungen') }} {{ __('Reiseländer') }}
    </h4>

    @if ($errors->any())
        <div class="row">
            <div class="col-sm-12">
                <div class="alert alert-danger">
                    <ul>
                        @foreach ($errors->all() as $error)
                            <li>{{ $error }}</li>
                        @endforeach
                    </ul>
                </div>
            </div>
        </div>
    @endif

    <div class="card">
        <div class="card-datatable table-responsive">
            <table class="datatables-feedbacks table table-striped table-bordered">
                <thead>
                <tr>
                    <th style="max-width: 60px;">&nbsp;</th>
                    <th>{{__('Name')}}</th>
                    <th>{{__('Bezug')}}</th>
                    <th>{{__('Code')}}</th>
                    <th>{{__('E-Mail(s)')}}</th>
                    <th><i class="fa fa-eye"></i> {{__('Seite')}}</th>
                    <th><i class="fa fa-eye"></i> {{__('CRM')}}</th>
                    <th><i class="fa fa-eye"></i> {{__('Kunden')}}</th>
                </tr>
                </thead>
                <tbody>
                @foreach($travel_countries as $value)
                    <tr>
                        <td data-sort="{{ $value->id }}">
                            <a href="{{ route('admin_settings_travel_country_detail', [$value->id]) }}" class="btn icon-btn btn-sm btn-primary">
                                <span class="fa fa-edit"></span>
                            </a>
                        </td>
                        <td><a href="{{ route('admin_settings_travel_country_detail', [$value->id]) }}">{{ $value->name }}</a></td>
                        <td>
                            {!! implode("<br>", $value->getContactLandsArray()) !!}
                        </td>
                        <td>
                            {{ $value->destco }}
                        </td>
                        <td>
                            {!! \App\Services\Util::_implodeLines($value->contact_emails, "<br>") !!}
                        </td>
                        <td data-sort="{{ $value->active_frontend }}">
                            @if($value->active_frontend)
                                <span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>
                            @else
                                <span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>
                            @endif
                        </td>
                        <td data-sort="{{ $value->active_backend }}">
                            @if($value->active_backend)
                                <span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>
                            @else
                                <span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>
                            @endif
                        </td>
                        <td data-sort="{{ $value->is_customer_country }}">
                            @if($value->is_customer_country)
                                <span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>
                            @else
                                <span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>
                            @endif
                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>
        </div>
        <div class="ml-3 mb-2">
            <a href="{{ route('admin_settings_travel_country_detail', ['new']) }}" class="btn btn-sm btn-primary">Neues Reiseland anlegen</a>
        </div>
        <script>
            $( document ).ready(function() {
                $('.datatables-feedbacks').dataTable({
                    "bLengthChange": false,
                    "iDisplayLength": 50,
                    "language": {
                        "url": "/js/German.json"
                    },
                });


            });

        </script>
    </div>
@endsection