@extends('layouts.layout-2')

@section('content')
    <h4 class="font-weight-bold py-3 mb-1">
        E-Mail Vorlagen
    </h4>

    <div class="nav-tabs-top mb-4">
        <ul class="nav nav-tabs">
            <li class="nav-item">
                <a class="nav-link @if(!$step) active show @endif" data-toggle="tab" href="#navs-top-drafts">Vorlagen</a>
            </li>
            <li class="nav-item">
                <a class="nav-link @if($step === 'directories') active show @endif" data-toggle="tab" href="#navs-top-directories">Verzeichnisse</a>
            </li>
            <li class="nav-item">
                <a class="nav-link @if($step === 'settings') active show @endif" data-toggle="tab" href="#navs-top-settings">Einstellungen</a>
            </li>
        </ul>


        <div class="tab-content">

            <div class="tab-pane fade @if(!$step) active show @endif" id="navs-top-drafts">
                <div class="card">
                    <div class="card-datatable table-responsive">
                        <table class="datatables-default table table-striped table-bordered">
                            <thead>
                            <tr>
                                <th style="max-width: 60px;">&nbsp;</th>
                                <th>{{__('Vorlage Bezeichnung')}}</th>
                                <th>{{__('Verzeichniss')}}</th>
                                <th>{{__('sichtbar')}}</th>
                                <th></th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($email_template as $value)
                                <tr>
                                    <td data-sort="{{ $value->id }}">
                                        <button type="button" class="btn icon-btn btn-sm btn-primary" data-toggle="modal"
                                            data-target="#modals-load-content"
                                            data-id="{{ $value->id }}"
                                            data-model="emailTemplate"
                                            data-action="modal-email-template"
                                            data-url=""
                                            data-redirect="back"
                                            data-route="{{ route('admin_settings_emails_load') }}"><span class="fa fa-edit"></span></button>
                                    </td>
                                    <td>{{ $value->name }}</td>
                                    <td>@if($value->email_template_dir)
                                           <span class="badge badge-default" style="background-color: {{$value->email_template_dir->color}}">{{ $value->email_template_dir->name }}</span>
                                        @else
                                            &nbsp;
                                        @endif
                                    </td>
                                    <td data-sort="{{ $value->active }}">{!! \App\Services\HTMLHelper::getActiveIcon($value->active) !!}</td>
                                    <td><a class="text-danger" href="{{ route('admin_settings_emails_delete', [$value->id]) }}"  onclick="return confirm('{{__('Wirklich löschen?')}}');"><i class="fa fa-trash-alt"></i></a></td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                        <div class="mt-4 col">
                            <button type="button" class="btn btn-sm btn-primary" data-toggle="modal"
                                data-target="#modals-load-content"
                                data-id="new"
                                data-model="emailTemplate"
                                data-action="modal-email-template"
                                data-url=""
                                data-redirect="back"
                                data-route="{{ route('admin_settings_emails_load') }}">&nbsp;Neue E-Mail Vorlage anlegen</button>
                        </div>
                    </div>
                    <script>
                        $( document ).ready(function() {
                            $('.datatables-default').dataTable({
                                "bLengthChange": false,
                                "iDisplayLength": 50,
                                "order": [[ 0, "desc" ]],
                                "language": {
                                    "url": "/js/German.json"
                                }
                            });
                        });
                    </script>
                </div>
            </div>

            <div class="tab-pane fade @if($step === 'directories') active show @endif" id="navs-top-directories">
                <div class="card">
                    <div class="card-datatable table-responsive">
                        <table class="datatables-types table table-striped table-bordered">
                            <thead>
                            <tr>
                                <th style="max-width: 60px;">&nbsp;</th>
                                <th style="width: 2%;">{{__('POS')}}</th>
                                <th>{{__('Name')}}</th>
                                <th>{{__('Farbe')}}</th>
                                <th>{{__('sichtbar')}}</th>
                                <th></th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($email_template_dirs as $value)
                                <tr>
                                    <td>
                                        <button type="button" class="btn icon-btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-type"
                                                data-id="{{ $value->id }}"
                                                data-name="{{ $value->name }}"
                                                data-color="{{ $value->color }}"
                                                data-active="{{ $value->active }}"
                                                data-pos="{{ $value->pos }}">
                                            <span class="fa fa-edit"></span>
                                        </button>
                                    </td>
                                    <td>{{ $value->pos  }}</td>
                                    <td>{{ $value->name  }}</td>
                                    <td>@if($value->color)
                                            <div style="display:inline-block; width: 20px; height: 20px; border: 1px solid #888a85; background-color: {{$value->color}}"></div>
                                            {{ $value->color }}
                                        @else
                                            <div style="display:inline-block; width: 20px; height: 20px; border: 1px solid #888a85; background-color: #fff"></div>
                                        @endif
                                    </td>
                                    <td data-sort="{{ $value->active }}">
                                        @if($value->active)
                                            <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><a class="text-danger" href="{{ route('draft_type_delete', [$value->id]) }}"  onclick="return confirm('{{__('Wirklich löschen?')}}');"><i class="fa fa-trash-alt"></i></a></td>

                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                        <div class="mt-4 ml-3 text-left">
                            <button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-type"
                                    data-id="new"
                                    data-name=""
                                    data-active="1"
                                    data-pos="0"
                            >Neues Verzeichniss anlegen</button>
                        </div>
                    </div>

                    <!-- Modal template -->
                    <div class="modal fade" id="modals-type">
                        <div class="modal-dialog">
                            <form class="modal-content" action="{{ route('admin_settings_emails_update') }}" method="post">
                                @csrf
                                <input type="hidden" class="form-control" name="id">
                                <input type="hidden" class="form-control" name="action" value="email_template_dir">
                                <input type="hidden" class="form-control" name="step" value="directories">


                                <div class="modal-header">
                                    <h5 class="modal-title">Verzeichniss <span class="font-weight-light">anlegen/bearbeiten</span></h5>
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>
                                </div>
                                <div class="modal-body">
                                    <div class="form-row">
                                        <div class="form-group col">
                                            <label for="name" class="form-label">Name*</label>
                                            <input type="text" class="form-control" name="name" placeholder="{{__('Description')}}" required>
                                        </div>
                                    </div>
                                    <div class="form-row">
                                        <div class="form-group col">
                                            <label for="pos" class="form-label">POS*</label>
                                            <input type="text" class="form-control" name="pos" placeholder="{{__('Position')}}" required>
                                        </div>
                                    </div>

                                    <div class="form-row">
                                        <div class="form-group col">
                                            <label for="name" class="form-label">Farbe*</label>
                                            <input type="text" name="color" id="minicolors-hue" class="form-control" value="#fff">
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="custom-control custom-checkbox m-0">
                                            <input type="checkbox" class="custom-control-input" name="active" checked>
                                            <span class="custom-control-label">{{__('sichtbar')}}</span>
                                        </label>
                                    </div>
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-default" data-dismiss="modal">{{__('close')}}</button>
                                    <button type="submit" class="btn btn-primary">{{__('save')}}</button>
                                </div>
                            </form>

                        </div>
                    </div>
                    <script>
                        $( document ).ready(function() {

                            $('#minicolors-hue').minicolors({
                                control:  'hue',
                                position: 'bottom ' + 'left',
                            });

                            $('#modals-type').on('show.bs.modal', function (event) {
                                var button = $(event.relatedTarget);
                                $(this).find(".modal-content input[name='id']").val(button.data('id'));
                                $(this).find(".modal-body input[name='name']").val(button.data('name'));
                                $(this).find(".modal-body input[name='pos']").val(button.data('pos'));
                                color = '#fff';
                                if(button.data('color') != ""){
                                    color = button.data('color');
                                }
                                $('#minicolors-hue').minicolors('value', color);

                                // $('.selectpicker').selectpicker('refresh');
                                $(this).find(".modal-body input[name='active']").prop( "checked", button.data('active'));
                            });

                            $('.datatables-types').dataTable({
                                "bLengthChange": false,
                                "iDisplayLength": 50,
                                "order": [[ 1, "desc" ]],
                                "language": {
                                    "url": "/js/German.json"
                                }
                            });
                        });
                    </script>
                </div>
            </div>

            <div class="tab-pane fade @if($step === 'settings') active show @endif" id="navs-top-settings">
                <div class="card">
                        <h4 class="mt-4 mb-2 ml-4">Ordner für Buchungen/E-Mail Ablage</h4>
                        <p class="ml-4">Unterordner werden für das jeweilige Reiseland der Buchung unter <a href="{{route('admin_settings_travel_country')}}">Reiseländer</a>  -> Land / E-Mails zugewiesen  </p>
                        <div class="card-datatable table-responsive pt-0">
                            <table class="datatables-customer-mail-dirs table table-striped table-bordered">
                                <thead>
                                <tr>
                                    <th style="max-width: 60px;">&nbsp;</th>
                                    <th style="width: 2%;">{{__('ID')}}</th>
                                    <th>{{__('Name')}}</th>
                                    <th>{{__('Icon')}}</th>
                                    <th>{{__('Model')}}</th>
                                    <th>{{__('E-Mails')}}</th>
                                </tr>
                                </thead>
                                <tbody>
                                @php($next_customer_mail_dir_id = 0)
                                @foreach($customer_mail_dirs as $customer_mail_dir)
                                    <tr>
                                        <td class="not">
                                            <button type="button" class="btn icon-btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-customer-mail-dirs"
                                                    data-id="{{$customer_mail_dir->id}}"
                                                    data-icon="{{$customer_mail_dir->getArrayContent('icon')}}"
                                                    data-model="{{$customer_mail_dir->getArrayContent('model')}}"
                                                    data-emails="{{\App\Services\Util::_implodeLines($customer_mail_dir->getArrayContent('emails'))}}"
                                                    data-name="{{$customer_mail_dir->name}}"
                                                    data-pos="{{$customer_mail_dir->pos}}">
                                                <span class="fa fa-edit"></span>
                                            </button>
                                        </td>
                                        <td>{{ $customer_mail_dir->pos }}</td>
                                        <td>{{ $customer_mail_dir->name }}</td>
                                        <td>{{ $customer_mail_dir->getArrayContent('icon') }}</td>
                                        <td>{{ $customer_mail_dir->getArrayContent('model') }}</td>
                                        <td>
                                            {!! \App\Services\Util::_implodeLines( $customer_mail_dir->getArrayContent('emails'), "<br>") !!}
                                        </td>
                                        {{--  <td><a class="text-danger" href=""  onclick="return confirm('{{__('Wirklich löschen?')}}');"><i class="fa fa-trash-alt"></i></a></td> --}}
                                    </tr>
                                    @php($next_customer_mail_dir_id = $customer_mail_dir->pos+1)
                                @endforeach
                                </tbody>
                            </table>
                            <div class="mt-4 ml-3 text-left">
                                <button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-customer-mail-dirs"
                                        data-id="new"
                                        data-icon=""
                                        data-model=""
                                        data-emails=""
                                        data-name=""
                                        data-pos="{{$next_customer_mail_dir_id}}"
                                >Neuen Ordner anlegen</button>
                            </div>
                        </div>

                    <!-- Modal template -->
                    <div class="modal fade" id="modals-customer-mail-dirs">
                        <div class="modal-dialog">
                            <form class="modal-content" action="{{ route('admin_settings_emails_update') }}" method="post">
                                @csrf
                                <input type="hidden" class="form-control" name="id">
                                <input type="hidden" class="form-control" name="action" value="customer_mail_dirs">
                                <input type="hidden" class="form-control" name="step" value="settings">
                                <input type="hidden" class="form-control" name="identifier" value="customer-mail-dirs">
                                <input type="hidden" class="form-control" name="field" value="array">
                                <div class="modal-header">
                                    <h5 class="modal-title">E-Mail Ordner <span class="font-weight-light">anlegen/bearbeiten</span></h5>
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>
                                </div>
                                <div class="modal-body">
                                    <div class="form-row">
                                        <div class="form-group col">
                                            <label for="pos" class="form-label">ID*</label>
                                            <input type="text" class="form-control" name="pos" placeholder="{{__('ID')}}" required>
                                            <em>Die ID definiert die Zuweisung der E-Mails in die jeweiligen Ordner, bei Änderungen der ID können schon zugeordnete E-Mails nicht mehr angezeigt werden.</em>
                                        </div>
                                    </div>
                                    <div class="form-row">
                                        <div class="form-group col">
                                            <label for="name" class="form-label">Name*</label>
                                            <input type="text" class="form-control" name="name" placeholder="{{__('Description')}}" required>
                                        </div>
                                    </div>
                                    <div class="form-row">
                                        <div class="form-group col">
                                            <label for="icon" class="form-label">Icon*</label>
                                            <input type="text" class="form-control" name="icon" placeholder="{{__('Icon')}}" required>
                                        </div>
                                    </div>
                                    <div class="form-row">
                                        <div class="form-group col">
                                            <label for="model" class="form-label">Model <span class="text-muted">(wird benötigt um Unterordner unter Reiseländer zuzuweisen)</span></label>
                                            <input type="text" class="form-control" name="model" placeholder="{{__('Model')}}">
                                            <em>Das Model das muss vorab in der Programmierung erfasst werden.</em>
                                        </div>
                                    </div>
                                    <div class="form-row">
                                        <div class="form-group col">
                                            <label class="form-label" for="emails">Für interene Mails <span class="text-muted">(jede E-Mail in eine extra Zeile)</span></label>
                                            <textarea class="form-control" rows="4" name="emails" cols="50"></textarea>
                                        </div>
                                    </div>
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-default" data-dismiss="modal">{{__('close')}}</button>
                                    <button type="submit" class="btn btn-primary">{{__('save')}}</button>
                                </div>
                            </form>

                        </div>
                    </div>
                    <hr>
                    <h4 class="mt-2 mb-0 ml-4">Allgemeine PDF Dateien für Buchungen/E-Mail-Anhänge</h4>
                    <div class="card-datatable table-responsive pt-0">
                        <table class="datatables-booking-email-files table table-striped table-bordered">
                            <thead>
                            <tr>
                                <th style="max-width: 60px;">&nbsp;</th>
                                <th style="width: 2%;">{{__('POS')}}</th>
                                <th>{{__('Name')}}</th>
                                <th>{{__('Slug')}}</th>
                                <th>{{__('Inhalt')}}</th>
                                <th>{{__('Type')}}</th>
                                <th></th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($booking_email_files as $value)
                                <tr>
                                    <td class="not">
                                        <button type="button" class="btn icon-btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-load-content"
                                                data-id="{{ $value->id }}"
                                                data-pos="{{ $value->pos }}"
                                                data-identifier="{{$identifier_booking_file}}"
                                                data-model="content"
                                                data-back="{{route('admin_settings_emails', ['settings'])}}"
                                                data-route="{{ route('cms_content_all_load_modal') }}">
                                            <span class="fa fa-edit"></span>
                                        </button>
                                    </td>
                                    <td>{{ $value->pos   }}</td>
                                    <td>{{ $value->name }}</td>
                                    <td>{{ $value->slug }}</td>
                                    <td>@if($value->isFile()) {!! $value->getPreviewContent() !!} @else {{ $value->getPreviewContent() }} @endif</td>
                                    <td>{{ $value->getFieldName() }}</td>
                                    <td><a class="text-danger" href="{{ route('cms_content_all_delete', [$value->id]) }}"  onclick="return confirm('{{__('Wirklich löschen?')}}');"><i class="fa fa-trash-alt"></i></a></td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                        <div class="mt-4 ml-3 text-left">
                            <button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-load-content"
                                    data-id="new"
                                    data-identifier="{{$identifier_booking_file}}"
                                    data-field="file"
                                    data-model="content"
                                    data-back="{{route('admin_settings_emails', ['settings'])}}"
                                    data-route="{{ route('cms_content_all_load_modal') }}"
                            >Neue Datei anlegen</button>
                        </div>
                    </div>
                    <hr><hr>

                    <!--  FEWO -->
                    <h4 class="mt-4 mb-2 ml-4">Ordner für FeWo/E-Mail Ablage</h4>
                    <div class="card-datatable table-responsive pt-0">
                        <table class="datatables-customer-fewo-mail-dirs table table-striped table-bordered">
                            <thead>
                            <tr>
                                <th style="max-width: 60px;">&nbsp;</th>
                                <th style="width: 2%;">{{__('ID')}}</th>
                                <th>{{__('Name')}}</th>
                                <th>{{__('Icon')}}</th>
                                <th>{{__('Model')}}</th>
                                <th>{{__('E-Mails')}}</th>
                            </tr>
                            </thead>
                            <tbody>
                            @php($next_customer_fewo_mail_dir_id = 0)
                            @foreach($customer_fewo_mail_dirs as $customer_fewo_mail_dir)
                                <tr>
                                    <td class="not">
                                        <button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-customer-fewo-mail-dirs"
                                                data-id="{{$customer_fewo_mail_dir->id}}"
                                                data-icon="{{$customer_fewo_mail_dir->getArrayContent('icon')}}"
                                                data-model="{{$customer_fewo_mail_dir->getArrayContent('model')}}"
                                                data-emails="{{\App\Services\Util::_implodeLines($customer_fewo_mail_dir->getArrayContent('emails'))}}"
                                                data-name="{{$customer_fewo_mail_dir->name}}"
                                                data-pos="{{$customer_fewo_mail_dir->pos}}">
                                            <span class="fa fa-edit"></span>
                                        </button>
                                    </td>
                                    <td>{{ $customer_fewo_mail_dir->pos }}</td>
                                    <td>{{ $customer_fewo_mail_dir->name }}</td>
                                    <td>{{ $customer_fewo_mail_dir->getArrayContent('icon') }}</td>
                                    <td>{{ $customer_fewo_mail_dir->getArrayContent('model') }}</td>
                                    <td>
                                        {!! \App\Services\Util::_implodeLines( $customer_fewo_mail_dir->getArrayContent('emails'), "<br>") !!}
                                    </td>
                                    {{--  <td><a class="text-danger" href=""  onclick="return confirm('{{__('Wirklich löschen?')}}');"><i class="fa fa-trash-alt"></i></a></td> --}}
                                </tr>
                                @php($next_customer_fewo_mail_dir_id = $customer_fewo_mail_dir->pos+1)
                            @endforeach
                            </tbody>
                        </table>
                        <div class="mt-4 ml-3 text-left">
                            <button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-customer-fewo-mail-dirs"
                                    data-id="new"
                                    data-icon=""
                                    data-model=""
                                    data-emails=""
                                    data-name=""
                                    data-pos="{{$next_customer_fewo_mail_dir_id}}"
                            >Neuen Ordner anlegen</button>
                        </div>
                    </div>

                    <!-- Modal template -->
                    <div class="modal fade" id="modals-customer-fewo-mail-dirs">
                        <div class="modal-dialog">
                            <form class="modal-content" action="{{ route('admin_settings_emails_update') }}" method="post">
                                @csrf
                                <input type="hidden" class="form-control" name="id">
                                <input type="hidden" class="form-control" name="action" value="customer_mail_dirs">
                                <input type="hidden" class="form-control" name="step" value="settings">
                                <input type="hidden" class="form-control" name="identifier" value="customer-fewo-mail-dirs">
                                <input type="hidden" class="form-control" name="field" value="array">
                                <div class="modal-header">
                                    <h5 class="modal-title">E-Mail Ordner <span class="font-weight-light">anlegen/bearbeiten</span></h5>
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>
                                </div>
                                <div class="modal-body">
                                    <div class="form-row">
                                        <div class="form-group col">
                                            <label for="pos" class="form-label">ID*</label>
                                            <input type="text" class="form-control" name="pos" placeholder="{{__('ID')}}" required>
                                            <em>Die ID definiert die Zuweisung der E-Mails in die jeweiligen Ordner, bei Änderungen der ID können schon zugeordnete E-Mails nicht mehr angezeigt werden.</em>
                                        </div>
                                    </div>
                                    <div class="form-row">
                                        <div class="form-group col">
                                            <label for="name" class="form-label">Name*</label>
                                            <input type="text" class="form-control" name="name" placeholder="{{__('Description')}}" required>
                                        </div>
                                    </div>
                                    <div class="form-row">
                                        <div class="form-group col">
                                            <label for="icon" class="form-label">Icon*</label>
                                            <input type="text" class="form-control" name="icon" placeholder="{{__('Icon')}}" required>
                                        </div>
                                    </div>
                                    <div class="form-row">
                                        <div class="form-group col">
                                            <label for="model" class="form-label">Model <span class="text-muted">(wird benötigt um Unterordner unter Reiseländer zuzuweisen)</span></label>
                                            <input type="text" class="form-control" name="model" placeholder="{{__('Model')}}">
                                            <em>Das Model das muss vorab in der Programmierung erfasst werden.</em>
                                        </div>
                                    </div>
                                    <div class="form-row">
                                        <div class="form-group col">
                                            <label class="form-label" for="emails">Für interene Mails <span class="text-muted">(jede E-Mail in eine extra Zeile)</span></label>
                                            <textarea class="form-control" rows="4" name="emails" cols="50"></textarea>
                                        </div>
                                    </div>
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-default" data-dismiss="modal">{{__('close')}}</button>
                                    <button type="submit" class="btn btn-primary">{{__('save')}}</button>
                                </div>
                            </form>

                        </div>
                    </div>

                    <hr>
                    <h4 class="mt-2 mb-0 ml-4">Allgemeine PDF Dateien für FeWo/E-Mail-Anhänge</h4>
                    <div class="card-datatable table-responsive pt-0">
                        <table class="datatables-fewo-email-files table table-striped table-bordered">
                            <thead>
                            <tr>
                                <th style="max-width: 60px;">&nbsp;</th>
                                <th style="width: 2%;">{{__('POS')}}</th>
                                <th>{{__('Name')}}</th>
                                <th>{{__('Slug')}}</th>
                                <th>{{__('Inhalt')}}</th>
                                <th>{{__('Type')}}</th>
                                <th></th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($fewo_email_files as $value)
                                <tr>
                                    <td class="not">
                                        <button type="button" class="btn icon-btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-load-content"
                                                data-id="{{ $value->id }}"
                                                data-pos="{{ $value->pos }}"
                                                data-identifier="{{$identifier_fewo_file}}"
                                                data-model="content"
                                                data-back="{{route('admin_settings_emails', ['settings'])}}"
                                                data-route="{{ route('cms_content_all_load_modal') }}">
                                            <span class="fa fa-edit"></span>
                                        </button>
                                    </td>
                                    <td>{{ $value->pos   }}</td>
                                    <td>{{ $value->name }}</td>
                                    <td>{{ $value->slug }}</td>
                                    <td>@if($value->isFile()) {!! $value->getPreviewContent() !!} @else {{ $value->getPreviewContent() }} @endif</td>
                                    <td>{{ $value->getFieldName() }}</td>
                                    <td><a class="text-danger" href="{{ route('cms_content_all_delete', [$value->id]) }}"  onclick="return confirm('{{__('Wirklich löschen?')}}');"><i class="fa fa-trash-alt"></i></a></td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                        <div class="mt-4 ml-3 text-left">
                            <button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-load-content"
                                    data-id="new"
                                    data-identifier="{{$identifier_fewo_file}}"
                                    data-field="file"
                                    data-model="content"
                                    data-back="{{route('admin_settings_emails', ['settings'])}}"
                                    data-route="{{ route('cms_content_all_load_modal') }}"
                            >Neue Datei anlegen</button>
                        </div>
                    </div>
                    <script>
                        $( document ).ready(function() {
                            $('.datatables-booking-email-files').dataTable({
                                "bLengthChange": false,
                                "iDisplayLength": 50,
                                "order": [[ 1, "desc" ]],
                                "language": {
                                    "url": "/js/German.json"
                                }
                            });
                            $('.datatables-customer-mail-dirs').dataTable({
                                "bLengthChange": false,
                                "iDisplayLength": 50,
                                "order": [[ 1, "asc" ]],
                                "language": {
                                    "url": "/js/German.json"
                                }
                            });
                            $('.datatables-customer-fewo-mail-dirs').dataTable({
                                "bLengthChange": false,
                                "iDisplayLength": 50,
                                "order": [[ 1, "asc" ]],
                                "language": {
                                    "url": "/js/German.json"
                                }
                            });
                            $('.datatables-fewo-email-files').dataTable({
                                "bLengthChange": false,
                                "iDisplayLength": 50,
                                "order": [[ 1, "desc" ]],
                                "language": {
                                    "url": "/js/German.json"
                                }
                            });

                            $('#modals-customer-mail-dirs').on('show.bs.modal', function (event) {
                                var button = $(event.relatedTarget);
                                $(this).find(".modal-content input[name='id']").val(button.data('id'));
                                $(this).find(".modal-body input[name='name']").val(button.data('name'));
                                $(this).find(".modal-body input[name='pos']").val(button.data('pos'));
                                $(this).find(".modal-body input[name='icon']").val(button.data('icon'));
                                $(this).find(".modal-body input[name='model']").val(button.data('model'));
                                $(this).find(".modal-body textarea[name='emails']").val(button.data('emails'));
                            });

                            $('#modals-customer-fewo-mail-dirs').on('show.bs.modal', function (event) {
                                var button = $(event.relatedTarget);
                                $(this).find(".modal-content input[name='id']").val(button.data('id'));
                                $(this).find(".modal-body input[name='name']").val(button.data('name'));
                                $(this).find(".modal-body input[name='pos']").val(button.data('pos'));
                                $(this).find(".modal-body input[name='icon']").val(button.data('icon'));
                                $(this).find(".modal-body input[name='model']").val(button.data('model'));
                                $(this).find(".modal-body textarea[name='emails']").val(button.data('emails'));
                            });
                        });
                    </script>
                </div>
            </div>

        </div>
@endsection