@extends('layouts.layout-2')

@section('content')



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

    <h4 class="font-weight-bold py-3 mb-1">
        Sidebar Widget @if($id == "new") <span class="text-primary">anlegen</span> @else {{"(ID: ".$id.")"}} verwalten @endif
        <div class="float-right">
            <button type="submit" name="action" value="saveAll" class="btn btn-submit btn-sm">{{ __('save changes') }}</button>&nbsp;
            <a href="{{route('cms_sidebar')}}" class="btn btn-default btn-sm">{{ __('back') }}</a>
        </div>
    </h4>
    <div class="clearfix"></div>

    <input type="hidden" name="id" id="id" value="{{$id}}">


    <!-- draft -->
    <div class="card mb-2">
        <div class="card-body">
            <div class="form-row">
                <div class="form-group col-sm-8">
                    <label class="form-label" for="widget_title">{{ __('Name') }}*</label>
                    {{ Form::text('name', $widget->name,  array('placeholder'=>__('Name'), 'class'=>'form-control', 'id'=>'widget_name', 'required'=>true)) }}
                </div>
                <div class="form-group col-sm-4">
                        <label class="custom-control custom-checkbox float-right">
                            {!! Form::checkbox('active', 1, $widget->active, ['class'=>'custom-control-input']) !!}
                            <span class="custom-control-label">{{__('aktiv')}}</span>
                        </label>
                    <label for="widget_pos" class="form-label">{{__('Position')}}</label>
                    {{ Form::text('pos', $widget->pos,  array('placeholder'=>__('pos'), 'class'=>'form-control', 'id'=>'widget_pos')) }}
                </div>
            </div>
            <div class="form-row">
                <div class="form-group col-sm-12">
                <label class="form-label" for="component">{{ __('Komponente') }}</label>
                <select class="selectpicker" data-style="btn-default" name="component">
                    {!! \App\Models\SidebarWidget::getComponentsOptions($widget->component) !!}
                </select>
                </div>
            </div>
            <div class="form-row">
                <div class="form-group col-sm-12">
                    <label class="form-label" for="html">{{ __('HTML') }}</label>
                    {{ Form::textarea('html', $widget->html, ['class' => 'form-control']) }}
                </div>
            </div>
            <div class="form-row">
                <div class="form-group col-sm-12">
                    <label class="form-label" for="show_at">{{ __('Sichtbar') }}</label>
                    <select class="selectpicker" data-style="btn-default" name="show_at[]" multiple>
                        {!! \App\Models\SidebarWidget::getShowsOptions($widget->show_at) !!}
                    </select>
                </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;
        <a href="{{route('cms_sidebar')}}" class="btn btn-default">{{ __('back') }}</a>
    </div>

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

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


                <div class="modal-header">
                    <h5 class="modal-title">Programm Katagorie/Klassen <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 class="custom-control custom-checkbox float-right">
                                <input type="checkbox" class="custom-control-input" name="standard" checked>
                                <span class="custom-control-label">{{__('Standard')}}</span>
                            </label>
                            <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="description" class="form-label">Beschreibung</label>
                            <input type="text" class="form-control" name="description" placeholder="{{__('Description')}}">
                        </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>


    <!-- Modal template -->
    <div class="modal fade" id="modals-draft">
        <div class="modal-dialog">
            <form class="modal-content" action="{{ route('travel_program_draft_update') }}" method="post">
                @csrf
                <input type="hidden" class="form-control" name="id">
                <input type="hidden" class="form-control" name="travel_program_id" value="{{$widget->id}}">

                <div class="modal-header">
                    <h5 class="modal-title">Vorlage Reiseprogramm <span class="font-weight-light">zuordnen</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="draft_id" class="form-label">{{__('Vorlage')}}</label>
                            <select class="selectpicker" data-style="btn-default" name="draft_id" data-live-search="true" required>
                                {!!  HTMLHelper::getDraftOptions() !!}
                            </select>
                        </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>

    <script>
        $( document ).ready(function() {
            $('#modals-class').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='description']").val(button.data('description'));
                $(this).find(".modal-body input[name='standard']").prop( "checked", button.data('standard'));
            });

            $('#modals-draft').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 select[name='draft_id']").val(button.data('draft_id'));
                $(this).find(".modal-body select[name='travel_class_id']").val(button.data('travel_class_id'));
                $(this).find(".modal-body select[name='weekdays[]']").val(button.data('weekdays'));

                $('.selectpicker').selectpicker('refresh');
            });
        });
    </script>
    --}}


@endsection