@extends('layouts.layout-2')

@section('content')

    <style>
        .switcher-input:checked ~ .switcher-label .switcher-label-yes {
            display: inline-block;

        }
        .switcher-input:checked ~ .switcher-label .switcher-label-no {
            display: none;
        }
        .switcher-input:not(:checked) ~ .switcher-label .switcher-label-yes {
            display: none;
        }
        .switcher-input:not(:checked) ~ .switcher-label .switcher-label-no {
            display: inline-block;

        }
    </style>

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

    <h4 class="font-weight-bold py-3 mb-1">
        Inhalte Infos verwalten
        <div class="float-right">
            <button type="submit" name="action" value="saveAll" class="btn btn-submit btn-sm">{{ __('save changes') }}</button>&nbsp;
        </div>
    </h4>
    <div class="clearfix"></div>


    <!--  -->
    <div class="card mb-4">
        <div class="card-body">
            <h4>Lokale Öffnungszeiten</h4>
            <p>Die Öffnungszeiten können eine Woche im Voraus geplant werden und wird live im Frontend angezeigt.</p>
            @foreach($days as $wday => $values)
                @php($available = \App\Models\CMSInfoAvailable::getContentBySlug('local', $wday))
                <div class="form-row">
                    {{ Form::hidden('info_availables[local]['.$wday.'][wday]', $wday) }}
                    <div class="col-sm-2 col-6 py-2"><strong>{{ $values['name'] }} <span class="text-muted">({{ $values['date'] }})</span></strong></div>
                    <div class="col-sm-3 col-6 py-2">
                        <label class="switcher">
                            {{ Form::hidden('info_availables[local]['.$wday.'][active]', 0) }}
                            {{ Form::checkbox('info_availables[local]['.$wday.'][active]', 1, $available->active, array('class'=>'switcher-input')) }}
                            <span class="switcher-indicator">
                                <span class="switcher-yes"></span>
                                <span class="switcher-no"></span>
                            </span>
                            <span class="switcher-label"><span class="switcher-label-yes">geöffnet</span> <span class="switcher-label-no">geschlossen</span></span>
                        </label>
                    </div>
                    <div class="form-group col-sm-2 col-6">
                        <select class="selectpicker" data-style="btn-default" name="info_availables[local][{{$wday}}][from]" data-live-search="true">
                            {!! \App\Services\HTMLHelper::getTimeInSteps($available->from) !!}
                        </select>
                    </div>
                    <div class="form-group col-sm-2 col-6">
                        <select class="selectpicker" data-style="btn-default" name="info_availables[local][{{$wday}}][to]" data-live-search="true">
                            {!! \App\Services\HTMLHelper::getTimeInSteps($available->to) !!}
                        </select>
                    </div>
                </div>
            @endforeach
        </div>
    </div>

    <div class="card mb-4">
        <div class="card-body">
            <button type="submit" name="action" value="add_special_available_local" class="btn btn-primary btn-sm float-right mb-2"><i class="ion ion-ios-add-circle"></i> Eintrag</button>

            <h4>Spezielle Öffnungszeiten Lokal</h4>
            <p>Überschreibt bei dem speziellen Datum Erreichbarkeit und fügt das Datum den Öffnungszeiten hinzu.</p>

            @foreach($specials_local as $special_local)
                <div class="form-row">
                    {{ Form::hidden('special_availables['.$special_local->id.'][wday]', $special_local->wday) }}
                    <div class="col-sm-2 col-6">
                        {{ Form::text('special_availables['.$special_local->id.'][date]', $special_local->date,  array('placeholder'=>__('Datum'), 'class'=>'form-control datepicker-base')) }}
                    </div>
                    <div class="col-sm-2 col-6 py-2"><strong>{!! \App\Services\HTMLHelper::getDeDay($special_local->wday) !!}</strong></div>

                    <div class="col-sm-2 col-12 py-2">
                        <label class="switcher">
                            {{ Form::hidden('special_availables['.$special_local->id.'][active]', 0) }}
                            {{ Form::checkbox('special_availables['.$special_local->id.'][active]', 1, $special_local->active, array('class'=>'switcher-input')) }}
                            <span class="switcher-indicator">
                                <span class="switcher-yes"></span>
                                <span class="switcher-no"></span>
                            </span>
                            <span class="switcher-label"><span class="switcher-label-yes">geöffnet</span> <span class="switcher-label-no">geschlossen</span></span>
                        </label>
                    </div>
                    <div class="form-group col-sm-2 col-6">
                        <select class="selectpicker" data-style="btn-default" name="special_availables[{{$special_local->id}}][from]" data-live-search="true">
                            {!! \App\Services\HTMLHelper::getTimeInSteps($special_local->from) !!}
                        </select>
                    </div>
                    <div class="form-group col-sm-2 col-6">
                        <select class="selectpicker" data-style="btn-default" name="special_availables[{{$special_local->id}}][to]" data-live-search="true">
                            {!! \App\Services\HTMLHelper::getTimeInSteps($special_local->to) !!}
                        </select>
                    </div>
                    <div class="col-sm-1 col-2 p-1">
                        <a href="{{route('cms_content_infos_delete', ['special_available', $special_local->id])}}" class="btn btn-danger btn-sm" onclick="return confirm('Wirklich löschen?');"><i class="fa fa-trash-alt"></i></a>
                    </div>
                </div>
                <hr>
            @endforeach
        </div>
    </div>


    <div class="card mb-4">
        <div class="card-body">
            <h4>Telefon Erreichbarkeit</h4>
            <p>Die Erreichbarkeit per Telefon kann eine Woche im Voraus geplant werden und wird live im Frontend angezeigt.</p>
            @foreach($days as $wday => $values)
                @php($available = \App\Models\CMSInfoAvailable::getContentBySlug('phone', $wday))
                <div class="form-row">
                    {{ Form::hidden('info_availables[phone]['.$wday.'][wday]', $wday) }}
                    <div class="col-sm-2 col-6 py-2"><strong>{{ $values['name'] }} <span class="text-muted">({{ $values['date'] }})</span></strong></div>
                    <div class="col-sm-3 col-6 py-2">
                        <label class="switcher">
                            {{ Form::hidden('info_availables[phone]['.$wday.'][active]', 0) }}
                            {{ Form::checkbox('info_availables[phone]['.$wday.'][active]', 1, $available->active, array('class'=>'switcher-input')) }}
                            <span class="switcher-indicator">
                                <span class="switcher-yes"></span>
                                <span class="switcher-no"></span>
                            </span>
                            <span class="switcher-label"><span class="switcher-label-yes">erreichbar</span> <span class="switcher-label-no">nicht erreichbar</span></span>
                        </label>
                    </div>
                    <div class="form-group col-sm-2 col-6">
                        <select class="selectpicker" data-style="btn-default" name="info_availables[phone][{{$wday}}][from]" data-live-search="true">
                            {!! \App\Services\HTMLHelper::getTimeInSteps($available->from) !!}
                        </select>
                    </div>
                    <div class="form-group col-sm-2 col-6">
                        <select class="selectpicker" data-style="btn-default" name="info_availables[phone][{{$wday}}][to]" data-live-search="true">
                            {!! \App\Services\HTMLHelper::getTimeInSteps($available->to) !!}
                        </select>
                    </div>
                </div>
            @endforeach
        </div>
    </div>

    <div class="card mb-4">
        <div class="card-body">
            <button type="submit" name="action" value="add_special_available_phone" class="btn btn-primary btn-sm float-right mb-2"><i class="ion ion-ios-add-circle"></i> Eintrag</button>

            <h4>Spezielle Erreichbarkeit Telefon</h4>
            <p>Überschreibt bei dem speziellen Datum Erreichbarkeit und fügt das Datum der Erreichbarkeit hinzu.</p>

            @foreach($specials_phone as $special_phone)
                <div class="form-row">
                    {{ Form::hidden('special_availables['.$special_phone->id.'][wday]', $special_phone->wday) }}
                    <div class="col-sm-2 col-6">
                        {{ Form::text('special_availables['.$special_phone->id.'][date]', $special_phone->date,  array('placeholder'=>__('Datum'), 'class'=>'form-control datepicker-base')) }}
                    </div>
                    <div class="col-sm-2 col-6 py-2"><strong>{!! \App\Services\HTMLHelper::getDeDay($special_phone->wday) !!}</strong></div>

                    <div class="col-sm-2 col-12 py-2">
                        <label class="switcher">
                            {{ Form::hidden('special_availables['.$special_phone->id.'][active]', 0) }}
                            {{ Form::checkbox('special_availables['.$special_phone->id.'][active]', 1, $special_phone->active, array('class'=>'switcher-input')) }}
                            <span class="switcher-indicator">
                                <span class="switcher-yes"></span>
                                <span class="switcher-no"></span>
                            </span>
                            <span class="switcher-label"><span class="switcher-label-yes">geöffnet</span> <span class="switcher-label-no">geschlossen</span></span>
                        </label>
                    </div>
                    <div class="form-group col-sm-2 col-6">
                        <select class="selectpicker" data-style="btn-default" name="special_availables[{{$special_phone->id}}][from]" data-live-search="true">
                            {!! \App\Services\HTMLHelper::getTimeInSteps($special_phone->from) !!}
                        </select>
                    </div>
                    <div class="form-group col-sm-2 col-6">
                        <select class="selectpicker" data-style="btn-default" name="special_availables[{{$special_phone->id}}][to]" data-live-search="true">
                            {!! \App\Services\HTMLHelper::getTimeInSteps($special_phone->to) !!}
                        </select>
                    </div>
                    <div class="col-sm-1 col-2 p-1">
                        <a href="{{route('cms_content_infos_delete', ['special_available', $special_phone->id])}}" class="btn btn-danger btn-sm" onclick="return confirm('Wirklich löschen?');"><i class="fa fa-trash-alt"></i></a>
                    </div>
                </div>
                <hr>
            @endforeach
        </div>
    </div>

    <div class="card mb-4">
        <div class="card-body">
            <button type="submit" name="action" value="add_holiday" class="btn btn-primary btn-sm float-right mb-2"><i class="ion ion-ios-add-circle"></i> Eintrag</button>

            <h4>Geschlossen Tage (nicht erreichbar)</h4>
            <p>Überschreibt bei dem Datum von - bis die Erreichbarkeit, wenn lokal und/oder telefon aktiviert (rot) ist. </p>

            @foreach($cms_holidays as $cms_holiday)
            <div class="form-row">
                <div class="col-sm-2 col-6 py-2">
                    <label class="switcher switcher-danger">
                        {{ Form::hidden('info_holidays['.$cms_holiday->id.'][local]', 0) }}
                        {{ Form::checkbox('info_holidays['.$cms_holiday->id.'][local]', 1, $cms_holiday->local, array('class'=>'switcher-input')) }}
                        <span class="switcher-indicator">
                                    <span class="switcher-yes"></span>
                                    <span class="switcher-no"></span>
                                </span>
                        <span class="switcher-label">Lokal</span>
                    </label>
                </div>
                <div class="col-sm-3 col-6 py-2">
                    <label class="switcher switcher-danger">
                        {{ Form::hidden('info_holidays['.$cms_holiday->id.'][phone]', 0) }}
                        {{ Form::checkbox('info_holidays['.$cms_holiday->id.'][phone]', 1, $cms_holiday->phone, array('class'=>'switcher-input')) }}
                        <span class="switcher-indicator">
                                    <span class="switcher-yes"></span>
                                    <span class="switcher-no"></span>
                                </span>
                        <span class="switcher-label">Telefon</span>
                    </label>
                </div>
                <div class="col-sm-6 col-10">
                    <div class="input-daterange input-group datepicker-range">
                        {{ Form::text('info_holidays['.$cms_holiday->id.'][from]', $cms_holiday->from,  array('placeholder'=>__('Datum von'), 'class'=>'form-control')) }}
                        <div class="input-group-prepend">
                            <span class="input-group-text">bis</span>
                        </div>
                        {{ Form::text('info_holidays['.$cms_holiday->id.'][to]', $cms_holiday->to,  array('placeholder'=>__('Datum von'), 'class'=>'form-control')) }}
                    </div>
                </div>
                <div class="col-sm-1 col-2 p-1">
                    <a href="{{route('cms_content_infos_delete', ['holiday', $cms_holiday->id])}}" class="btn btn-danger btn-sm" onclick="return confirm('Wirklich löschen?');"><i class="fa fa-trash-alt"></i></a>
                </div>
            </div>
                <hr>
            @endforeach
        </div>
    </div>

    <div class="card mb-2">
        <div class="card-body">
            <h4>Kontaktinfos</h4>
            <div class="form-row">
                <div class="form-group col-12">
                    <label class="switcher">
                        {{ Form::hidden('infos[office-important-note-active][val]', 0) }}
                        {{ Form::checkbox('infos[office-important-note-active][val]', 1, \App\Models\CMSInfo::getContentBySlug('office-important-note-active'), array('class'=>'switcher-input')) }}
                        <span class="switcher-indicator">
                                    <span class="switcher-yes"></span>
                                    <span class="switcher-no"></span>
                                </span>
                        <span class="switcher-label"></span>
                    </label>
                    {{ Form::hidden('infos[office-important-note-active][type]', 'bool') }}

                    <label class="form-label" for="office_important_note">{{ __('Wichtiger Hinweis') }} <span class="text-muted">(wird zusätzlich angezeigt, wenn aktiv)</span></label>
                    {{ Form::text('infos[office-important-note][val]', \App\Models\CMSInfo::getContentBySlug('office-important-note'),  array('placeholder'=>__('Weihnachtsferien! Vom 23.12.2019 bis zum 28.12.2019 sind wir nur zu den genannten Zeiten telefonisch zu erreichen.'), 'class'=>'form-control', 'id'=>'office_important_note')) }}
                    {{ Form::hidden('infos[office-important-note][type]', 'full_text') }}
                </div>
            </div>
            <div class="form-row">
                <div class="form-group col-sm-12">
                    <label class="form-label" for="office_appointment">{{ __('Termin Text') }}*</label>
                    {{ Form::textarea('infos[office-appointment][val]', \App\Models\CMSInfo::getContentBySlug('office-appointment'),  array('placeholder'=>__('Text zur Terminvereinbarung'), 'class'=>'form-control', 'id'=>'office_appointment', 'rows'=>4)) }}
                    {{ Form::hidden('infos[office-appointment][type]', 'full_text') }}
                </div>
            </div>
            <div class="form-row">
                <div class="form-group col-sm-12">
                    <label class="form-label" for="office_phone">{{ __('Telefonnummer') }}*</label>
                    {{ Form::text('infos[office-phone][val]', \App\Models\CMSInfo::getContentBySlug('office-phone'),  array('placeholder'=>__('Telefonnummer'), 'class'=>'form-control', 'id'=>'office_phone', 'required'=>true)) }}
                    {{ Form::hidden('infos[office-phone][type]', 'text') }}

                </div>
            </div>
            <div class="form-row">
                <div class="form-group col-sm-12">
                    <label class="form-label" for="office_email">{{ __('E-Mail') }}*</label>
                    {{ Form::email('infos[office-email][val]', \App\Models\CMSInfo::getContentBySlug('office-email'),  array('placeholder'=>__('E-Mail'), 'class'=>'form-control', 'id'=>'office_email', 'required'=>true)) }}
                    {{ Form::hidden('infos[office-email][type]', 'text') }}
                </div>
            </div>
        </div>
    </div>


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

    {!! Form::close() !!}

@endsection