@extends('layouts.layout-2')

@section('content')

   {{--
   @if ($errors->any())
        <div class="row">
            <div class="col-sm-12">
                <div class="alert alert-danger">
                    <ul>
                        @foreach ($errors->all() as $error)
                            <li>{{ $error }}</li>
                        @endforeach
                    </ul>
                </div>
            </div>
        </div>
    @endif
    --}}
    <h4 class="font-weight-bold py-2 mb-2">
        {{ __('Kunden hinzufügen') }}
    </h4>

    <div id="smartwizard-3" class="smartwizard-add-client">
        <ul class="card px-4 pt-3 mb-3">
            <li>
                <a href="#smartwizard-3-step-1" class="mb-3">
                    <span class="sw-done-icon ion ion-md-checkmark"></span>
                    <span class="sw-number">1</span>
                    E-Mail Adresse
                    <div class="text-muted small">prüfen</div>

                </a>
            </li>
            <li>
                <a href="#smartwizard-3-step-2" class="mb-3">
                    <span class="sw-done-icon ion ion-md-checkmark"></span>
                    <span class="sw-number">2</span>
                    Daten
                    <div class="text-muted small">eingeben</div>
                </a>
            </li>
        </ul>

        <div class="mb-3">
            <div id="smartwizard-3-step-1" class="card animated fadeIn">
                <div class="card-body">
                    {!! Form::open(['url' => route('user_customer_edit', ['new']), 'class' => 'form-horizontal']) !!}
                    <div class="form-row">
                        <div class="form-group col-md-12 {{ $errors->has('email') ? 'has-error' : '' }}">
                            <label class="form-label" for="email">{{ __('E-Mail Address') }}*</label>
                            {{ Form::text('email', '',  array('placeholder'=>'E-Mail Adresse', 'class'=>'form-control', 'id'=>'email', 'required'=>true ,'tabindex' => 1)) }}
                            @if ($errors->has('email'))
                                <span class="help-block">
                                    <strong>{{ $errors->first('email') }}</strong>
                                </span>
                            @endif
                            <p class="mt-2">Kundenhoheit: Es können nur Kunden hinzugefügt werden, die noch nicht im Salescenter vorhanden sind. </p>
                        </div>
                    </div>
                    <div class="text-left mt-2">
                        <button type="submit" class="btn btn-secondary" name="action" value="add_customer_with_email">{{ __('prüfen und weiter') }}</button>&nbsp;
                    </div>

                    <hr>
                    {!! Form::close() !!}
                    {!! Form::open(['url' => route('user_customer_edit', ['new']), 'class' => 'form-horizontal']) !!}
                    <div class="form-row">
                        <div class="form-group col-md-12 mt-2">
                            <label class="switcher switcher-secondary">
                                <input type="checkbox" class="switcher-input" name="switcher-without-email" value="true">
                                <span class="switcher-indicator">
                                    <span class="switcher-yes"></span>
                                    <span class="switcher-no"></span>
                                  </span>
                                <span class="switcher-label">Kunde ohne E-Mail hinzufügen</span>
                            </label>
                        </div>
                    </div>
                    <div class="text-left" style="display: none" id="show-button-without-email">
                        <p class="mt-2">Hinweis: Du kannst Deine Kunden auch ohne Email-Adresse anlegen. Das System gleicht dann Nachname und Postleitzahl ab. Sollte es hier mal Übereinstimmungen geben, gleicht der Support von gruene-seele.bio die Kundensätze ab und ordnet sie den Vertriebspartner entsprechend zu. Daher empfehlen wir im besten Fall immer die Angabe einer Email-Adresse. Diese ist einzigartig und damit eindeutig einem Kunden zuzuordnen.</p>
                        <button type="submit" class="btn btn-secondary" name="action" value="add_customer_without_email">{{ __('weiter ohne E-Mail') }}</button>&nbsp;
                    </div>
                    {!! Form::close() !!}

                </div>
            </div>
            <div id="smartwizard-3-step-2" class="card animated fadeIn">
                <div class="card-body">
                    @if($step == 1)
                    {!! Form::open(['url' => route('user_customer_edit', ['new']), 'class' => 'form-horizontal', 'id'=>'lead-form-validation']) !!}
                    @include('admin.customer._edit')

                    <div class="text-left mt-3">
                        <button type="submit" class="btn btn-secondary" name="action" value="shopping-user-store-new">{{ __('save changes') }}</button>&nbsp;
                    </div>
                    {!! Form::close() !!}
                </div>
                @endif
            </div>

        </div>
    </div>

    <link rel="stylesheet" href="{{ mix('/vendor/libs/smartwizard/smartwizard.css') }}">
    <script src="{{ mix('/vendor/libs/smartwizard/smartwizard.js') }}"></script>
    <script type="text/javascript">
        $(document).ready(function() {

            $('.smartwizard-add-client').smartWizard({
                autoAdjustHeight: true,
                backButtonSupport: true,
                useURLhash: false,
                showStepURLhash: false,
                selected: '{{$step}}',
                toolbarSettings: {
                    showNextButton: false,
                    showPreviousButton: false,
                }
            });

            $('input[name="switcher-without-email"]').on('change', function (){

                if($(this).prop('checked') === true){
                    $('#show-button-without-email').show();
                }else{
                    $('#show-button-without-email').hide();
                }
            });
        });
    </script>

@endsection
