@extends('layouts.layout-2')

@section('content')

    {!! Form::open(['url' => route('admin_settings_travel_country_update', [$id]), 'class' => 'form-horizontal']) !!}

    <h4 class="font-weight-bold py-3 mb-1">
        Reiseland Inhalte {{ $model->name }}
        <div class="float-right">
            <a href="{{route('admin_settings_travel_country')}}" class="btn btn-default btn-sm">{{ __('back') }}</a>
        </div>
    </h4>
    <div class="nav-tabs-top mb-4">
        <ul class="nav nav-tabs">
            <li class="nav-item">
                <a class="nav-link @if($step == false) active show @endif" data-toggle="tab" href="#navs-site">Seite</a>
            </li>
            <li class="nav-item">
                <a class="nav-link @if($step === 'form') active show @endif" data-toggle="tab" href="#navs-form">Formular</a>
            </li>
            <li class="nav-item">
                <a class="nav-link @if($step === 'contact') active show @endif" data-toggle="tab" href="#navs-contact">Kontaktdaten</a>
            </li>
            <li class="nav-item">
                <a class="nav-link @if($step === 'emails') active show @endif" data-toggle="tab" href="#navs-emails">E-Mails</a>
            </li>
            <li class="nav-item">
                <a class="nav-link @if($step === 'data') active show @endif" data-toggle="tab" href="#navs-data">PDF-Dateien</a>
            </li>
            <li class="nav-item">
                <a class="nav-link @if($step === 'services') active show @endif" data-toggle="tab" href="#navs-services">Leistungen</a>
            </li>
            <li class="nav-item">
                <a class="nav-link @if($step === 'travel') active show @endif" data-toggle="tab" href="#navs-travel">Einreisebestimmungen</a>
            </li>
        </ul>


        <div class="tab-content">
            <div class="tab-pane fade @if($step == false) active show @endif" id="navs-site">
                <div class="card">
                <div class="card-body">
                    <div class="form-row">
                        <div class="form-group col-sm-8">
                            <label class="form-label" for="name">{{ __('Name') }} *</label>
                            {{ Form::text('name', $model->name,  array('placeholder'=>__('Name'), 'class'=>'form-control', 'id'=>'name', 'required'=>true)) }}
                        </div>
                        <div class="form-group col-sm-4">
                            <label class="form-label" for="destco">{{ __('Code') }} *</label>
                            {{ Form::text('destco', $model->destco,  array('placeholder'=>__('Code'), 'class'=>'form-control', 'id'=>'destco', 'required'=>true)) }}
                        </div>
                    </div>
                    <br>
                    <h4>Inhalte für Seite</h4>
                    <div class="form-row">
                        <div class="form-group col-sm-12">
                            <label class="form-label" for="html_information">{{ __('Landinformationen (HTML)') }} </label>
                            {{ Form::textarea('html_information', $model->html_information, ['class' => 'form-control summernote']) }}
                        </div>
                    </div>


                    <div class="form-row">
                        <div class="col-12 py-2">
                            <label class="switcher switcher-on-off">
                                {{ Form::hidden('active_frontend', 0) }}
                                {{ Form::checkbox('active_frontend', 1, $model->active_frontend, array('class'=>'switcher-input')) }}
                                <span class="switcher-indicator">
                                    <span class="switcher-yes"></span>
                                    <span class="switcher-no"></span>
                                </span>
                                <span class="switcher-label">Sichtbar im Frontend (Suche)</span>
                            </label>
                        </div>
                        <div class="col-12 py-2">
                            <label class="switcher switcher-on-off">
                                {{ Form::hidden('active_backend', 0) }}
                                {{ Form::checkbox('active_backend', 1, $model->active_backend, array('class'=>'switcher-input')) }}
                                <span class="switcher-indicator">
                                    <span class="switcher-yes"></span>
                                    <span class="switcher-no"></span>
                                </span>
                                <span class="switcher-label">Sichtbar im Backend CRM</span>
                            </label>
                        </div>
                        <div class="col-12 py-2">
                            <label class="switcher switcher-on-off">
                                {{ Form::hidden('is_customer_country', 0) }}
                                {{ Form::checkbox('is_customer_country', 1, $model->is_customer_country, array('class'=>'switcher-input')) }}
                                <span class="switcher-indicator">
                                    <span class="switcher-yes"></span>
                                    <span class="switcher-no"></span>
                                </span>
                                <span class="switcher-label">Sichtbar bei Kunden</span>
                            </label>
                        </div>
                    </div>


                    <button type="submit" name="action" value="" class="btn btn-submit">{{ __('save changes') }}</button>&nbsp;

                </div>
                </div>
            </div>

            <div class="tab-pane fade @if($step === 'form') active show @endif" id="navs-form">
                <div class="card">
                <div class="card-body">
                    <br>
                    <h4>Inhalte für Formular</h4>
                    <div class="form-row">
                        <div class="form-group col-sm-12">
                            <label class="form-label" for="text_before">{{ __('Formular Text vor der Reise (max. 255 Zeichen)') }} </label>
                            {{ Form::text('text_before', $model->text_before, ['class' => 'form-control', 'maxlength'=>'255']) }}
                        </div>
                        <div class="form-group col-sm-12">
                            <label class="form-label" for="html_information">{{ __('Formular Text nach der Reise ( max. 255 Zeichen)') }} </label>
                            {{ Form::text('text_after', $model->text_after, ['class' => 'form-control', 'maxlength'=>'255']) }}
                        </div>
                    </div>
                    <button type="submit" name="action" value="form" class="btn btn-submit">{{ __('save changes') }}</button>&nbsp;
                </div>
                </div>
            </div>

            <div class="tab-pane fade @if($step === 'contact') active show @endif" id="navs-contact">
                <div class="card">
                <div class="card-body">
                    <h4>Land/Länder für Kontaktdaten definieren</h4>
                    <div class="form-row">
                        <div class="form-group col-sm-12">
                            <label class="form-label" for="contact_lands">Kontaktdaten aus folgenden Ländern nehmen</label>
                            <select class="selectpicker" data-style="btn-default" name="contact_lands[]" multiple>
                                {!!  HTMLHelper::getTravelCountriesOptions($model->contact_lands) !!}
                            </select>
                            <em>Das Land selbst muss auch hier selbst aufgeführt werden, wenn es angezeicht werden soll. Die Kontaktdaten der definierten Länder (Reiselandes) werden nacheinander am Ende des PDF's (RA, RB, Voucher) eingefügt.</em>
                        </div>
                    </div>
                    <hr>
                    <h4>Kontaktdaten im PDF</h4>
                    <div class="form-row">
                        <div class="form-group col-sm-12">
                            <label class="form-label" for="contact_headline">Überschrift</label>
                            {{ Form::text('contact_headline', $model->contact_headline, ['class' => 'form-control', 'maxlength'=>'255']) }}
                        </div>

                        <div class="form-group col-sm-6">
                            <label class="form-label" for="contact_text_1">Kontaktfeld 1 </label>
                            {{ Form::textarea('contact_text_1', $model->contact_text_1, ['class' => 'form-control', 'rows'=>4]) }}
                        </div>
                        <div class="form-group col-sm-6">
                            <label class="form-label" for="contact_text_2">Kontaktfeld 2 </label>
                            {{ Form::textarea('contact_text_2', $model->contact_text_2, ['class' => 'form-control', 'rows'=>4]) }}
                        </div>
                        <div class="form-group col-sm-6">
                            <label class="form-label" for="contact_text_3">Kontaktfeld 3 </label>
                            {{ Form::textarea('contact_text_3', $model->contact_text_3, ['class' => 'form-control', 'rows'=>4]) }}
                        </div>
                        <div class="form-group col-sm-6">
                            <label class="form-label" for="contact_text_4">Kontaktfeld 4</label>
                            {{ Form::textarea('contact_text_4', $model->contact_text_4, ['class' => 'form-control', 'rows'=>4]) }}
                        </div>
                    </div>
                    <hr>
                    <h4>Rückfragen im PDF</h4>
                    <p>Übergreifende Texte für jedes Land sind unter: <a href="{{route('cms_content_all')}}">Inhalte Allgemein</a><br>
                        - PDF Footer Hinweise Rückfragen<br>
                        - PDF Footer Hinweise Reisebedingungen<br>
                        - PDF Absender<br>
                    </p>
                    <div class="form-row">
                        <div class="form-group col-sm-12">
                            <label class="form-label" for="contact_text_4">Kontakt Footer</label>
                            {{ Form::textarea('contact_footer', $model->contact_footer, ['class' => 'form-control', 'rows'=>4]) }}
                        </div>
                    </div>
                    <button type="submit" name="action" value="contact" class="btn btn-submit">{{ __('save changes') }}</button>&nbsp;

                </div>
                </div>
            </div>

            <div class="tab-pane fade @if($step === 'emails') active show @endif" id="navs-emails">
                <div class="card">
                <div class="card-body">
                    <div class="form-row">
                        <div class="form-group col-sm-12">
                            <label class="form-label" for="mail_dir_name">Angezeigter Ordnername für dieses Land*</label>
                            {{ Form::text('mail_dir_name', $model->mail_dir_name,  array('placeholder'=>__('Name'), 'class'=>'form-control', 'id'=>'name')) }}
                        </div>
                    </div>
                    <hr>
                    <h4>Vordefinierte E-Mail-Adressen <span class="text-muted">für dieses Reiseland</span></h4>
                    <div class="form-row">
                        <div class="form-group col-sm-12">
                            <div class="form-group col-sm-">
                                <label class="form-label" for="contact_headline">der Agenturen für interene Mails <span class="text-muted">(jede E-Mail in eine extra Zeile)</span></label>
                                {{ Form::textarea('contact_emails', \App\Services\Util::_implodeLines($model->contact_emails), ['class' => 'form-control', 'rows'=>4]) }}
                            </div>
                        </div>
                    </div>
                    <hr>

                    <h4>Unterordner für die E-Mail Ablage für dieses Land</h4>
                    <p>Unterordner können unter <a href="{{route('admin_settings_emails', ['settings'])}}">Einstellungen -> E-Mails / Einstellungen</a> bearbeitet werden</p>
                    <hr>
                    @foreach(App\Services\Booking::getCustomerMailDirs() as $customer_mail_dir)
                        @if($customer_mail_dir->getArrayContent('model'))
                        <h5><i class="ion {{$customer_mail_dir->getArrayContent('icon')}}"></i> {{$customer_mail_dir->name}} <span class="text-muted">angezeigte E-Mail-Ordner</span></h5>
                        <div class="form-row">
                            <div class="form-group col-sm-12">
                                <label class="form-label" for="mail_dirs">Unterordner hinzufügen</label>
                                <select class="selectpicker" data-style="btn-default" name="mail_dirs[{{$customer_mail_dir->pos}}][]" multiple data-live-search="true">
                                    {!!  HTMLHelper::getCustomerMailDirsOptions($customer_mail_dir, $model->getMailDirs($customer_mail_dir->pos)) !!}
                                </select>
                                <em>Zum jeweiligen Reiseland können hier weitere Unterordner für die E-Mail-Ablage  ausgewählt werden.
                                    Die vordefinierten E-Mail-Adressen des Reiselandes werden bei einer neuen E-Mail entsprechend einsetzt.</em>
                            </div>
                        </div>
                        <hr>
                        @endif
                    @endforeach
                    <button type="submit" name="action" value="emails" class="btn btn-submit">{{ __('save changes') }}</button>&nbsp;
                </div>
                </div>
            </div>

            <div class="tab-pane fade @if($step === 'data') active show @endif" id="navs-data">
                <div class="card">
                <div class="card-body">
                    <br>
                    <h4>PDF-Dateien <span class="text-muted">für dieses Reiseland</span></h4>
                    <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($model->general_files)
                                @php($general_files_count = 1)
                                @foreach($model->general_files as $general_file)
                                    <tr>
                                        <th scope="row">{{$general_files_count++}}</th>
                                        <td>
                                            <a target="_blank" href="{{ $general_file->getURL() }}" class="badge badge-md badge-secondary">
                                                <i class="{{$general_file->getIconExt()}} mr-1"></i> {{$general_file->original_name}}
                                            </a>
                                        </td>
                                        <td>
                                            {{ $general_file->mine }} | {{ $general_file->formatBytes() }}
                                        </td>
                                        <td>{{\App\Services\Util::_format_date($general_file->created_at, 'date')}}</td>
                                        <td>
                                            <a href="{{ $general_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('admin_settings_travel_country_delete', [$general_file->id, 'general_file']) }}"  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">
                        <button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-load-content"
                                data-id="{{$model->id}}"
                                data-model="GeneralFile"
                                data-action="modal-upload-travel_country-file"
                                data-back="{{route('admin_settings_travel_country_detail', [$model->id, 'data'])}}"
                                data-url="{{ route('modal_load') }}"
                                data-route="{{ route('modal_load') }}"><i class="ion ion-md-cloud-upload"></i>&nbsp;Datei hinzufügen</button>
                    </div>
                </div>
                </div>
            </div>

            <div class="tab-pane fade @if($step === 'services') active show @endif" id="navs-services">
                <div class="card">
                <div class="card-body">
                    <br>
                    <h4>Länderleistungen/Agenturleistungen  <span class="text-muted">für dieses Reiseland</span></h4>
                    <div class="table-responsive" id="booking_files_table">
                        <table class="table table-striped table-sm">
                            <thead>
                            <tr>
                                <th style="width: 2%;">&nbsp;</th>
                                <th style="width: 6%;">{{__('POS')}}</th>
                                <th>Leistung</th>
                                <th>Beschreibung</th>
                                <th>&nbsp;</th>
                            </tr>
                            </thead>
                            <tbody>
                            @if($model->travel_country_services)
                                @foreach($model->travel_country_services as $travel_country_service)
                                    <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="{{$travel_country_service->id}}"
                                                    data-model="TravelCountryService"
                                                    data-action="modal-travel_country-services"
                                                    data-back="{{route('admin_settings_travel_country_detail', [$model->id, 'services'])}}"
                                                    data-url="{{ route('admin_settings_travel_country_update', [$model->id]) }}"
                                                    data-route="{{ route('modal_load') }}"><span class="fa fa-edit"></span></button>
                                        </td>
                                        <td>{{$travel_country_service->pos }}</td>
                                        <td>{{$travel_country_service->name}}</td>
                                        <td>{{$travel_country_service->description}}</td>
                                        <td>
                                            <a class="ml-2 btn btn-xs btn-danger" href="{{ route('admin_settings_travel_country_delete', [$travel_country_service->id, 'country_service']) }}"  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">
                        <button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-load-content"
                                data-id="new"
                                data-model="TravelCountryService"
                                data-action="modal-travel_country-services"
                                data-back="{{route('admin_settings_travel_country_detail', [$model->id, 'services'])}}"
                                data-url="{{ route('admin_settings_travel_country_update', [$model->id]) }}"
                                data-route="{{ route('modal_load') }}"><i class="ion ion-md-add-circle"></i>&nbsp;Leistung hinzufügen</button>
                    </div>
                </div>
                </div>
            </div>

            <div class="tab-pane fade @if($step === 'travel') active show @endif" id="navs-travel">
                <div class="card">
                <div class="card-body">
                    <br>
                    <h4>Einreisebestimmungen</h4>
                    @foreach($travel_nationalities as $travel_nationality)
                        <div class="form-row">
                            <div class="form-group col-sm-12">
                                <label class="form-label" for="travel_nationality_requirement_{{$travel_nationality->id}}">{{ $travel_nationality->name }}{{ __('(HTML)') }} </label>
                                {{ Form::textarea('travel_nationality_requirement['.$travel_nationality->id.']', $model->getNationalityRequirement($travel_nationality->id), ['class' => 'form-control summernote-small', 'id'=>'travel_nationality_requirement_'.$travel_nationality->id]) }}
                            </div>
                        </div>
                    @endforeach
                    <button type="submit" name="action" value="travel" class="btn btn-submit">{{ __('save changes') }}</button>&nbsp;
                </div>
                </div>
            </div>
        </div>
    </div>

    <div class="text-left mt-3">
        <a href="{{route('admin_settings_travel_country')}}" class="btn btn-default">{{ __('back') }}</a>
    </div>
    {!! Form::close() !!}

    <script>
        $( document ).ready(function() {
            $('input[name="active_frontend"]').on('change', function () {
                if($(this).prop( "checked")){
                    $('#show_active_frontend').show("slow");
                }else{
                    $('#show_active_frontend').hide("slow");
                }
            });
        });
        </script>



@endsection