@extends('layouts.layout-2')

@section('content')

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

    <h4 class="font-weight-bold py-3 mb-1">
        Reiseveranstalter Inhalte {{ $model->name }}
        <div class="float-right">
            <a href="{{route('admin_settings_travel_company')}}" 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">Allgemein</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>

        </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">
                    <h4>Allgemein</h4>
                    <div class="form-row">
                        <div class="form-group col-sm-12">
                            <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>
                    <div class="form-row">
                        <div class="form-group col-sm-12">
                            <label for="percentage" class="form-label">Prozentsatz für Provision*</label>
                            {{ Form::text('percentage', $model->percentage,  array('placeholder'=>__('%'), 'class'=>'form-control', 'required'=>true)) }}
                        </div>
                    </div>

                    <div class="form-row">
                        <div class="form-group col-sm-12">
                            <label class="form-label" for="contact_emails">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),  array('class'=>'form-control', 'rows'=>4)) }}
                        </div>
                    </div>

                    <div class="form-row">
                        <div class="col-12 py-2">
                            <label class="switcher switcher-on-off">
                                {{ Form::hidden('is_allowed_edit_commission', 0) }}
                                {{ Form::checkbox('is_allowed_edit_commission', 1, $model->is_allowed_edit_commission, array('class'=>'switcher-input')) }}
                                <span class="switcher-indicator">
                                    <span class="switcher-yes"></span>
                                    <span class="switcher-no"></span>
                                </span>
                                <span class="switcher-label">Provision änderbar</span>
                            </label>
                        </div>
                        <div class="col-12 py-2">
                            <label class="switcher switcher-on-off">
                                {{ Form::hidden('is_inhouse', 0) }}
                                {{ Form::checkbox('is_inhouse', 1, $model->is_inhouse, array('class'=>'switcher-input')) }}
                                <span class="switcher-indicator">
                                    <span class="switcher-yes"></span>
                                    <span class="switcher-no"></span>
                                </span>
                                <span class="switcher-label">In-House</span>
                            </label>
                        </div>
                        <div class="col-12 py-2">
                            <label class="switcher switcher-on-off">
                                {{ Form::hidden('active', 0) }}
                                {{ Form::checkbox('active', 1, $model->active, array('class'=>'switcher-input')) }}
                                <span class="switcher-indicator">
                                    <span class="switcher-yes"></span>
                                    <span class="switcher-no"></span>
                                </span>
                                <span class="switcher-label">sichtbar</span>
                            </label>
                        </div>
                    </div>
                    <br>
                    <button type="submit" name="action" value="" class="btn btn-submit">{{ __('save changes') }}</button>&nbsp;
                </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>Leistungen <span class="text-muted">für dieses Reiseveranstalter</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_company_services)
                                @foreach($model->travel_company_services as $travel_company_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_company_service->id}}"
                                                    data-model="TravelCompanyService"
                                                    data-action="modal-travel_company-services"
                                                    data-back="{{route('admin_settings_travel_company_detail', [$model->id, 'services'])}}"
                                                    data-url="{{ route('admin_settings_travel_company_update', [$model->id]) }}"
                                                    data-route="{{ route('modal_load') }}"><span class="fa fa-edit"></span></button>
                                        </td>
                                        <td>{{$travel_company_service->pos }}</td>
                                        <td>{{$travel_company_service->name}}</td>
                                        <td>{{$travel_company_service->description}}</td>
                                        <td>
                                            <a class="ml-2 btn btn-xs btn-danger" href="{{ route('admin_settings_travel_company_delete', [$travel_company_service->id, 'company_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="TravelCompanyService"
                                data-action="modal-travel_company-services"
                                data-back="{{route('admin_settings_travel_company_detail', [$model->id, 'services'])}}"
                                data-url="{{ route('admin_settings_travel_company_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>
    </div>

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




@endsection