@extends('layouts.layout-2')

@section('content')
    <h4 class="font-weight-bold py-2 mb-2">
        {{ __('navigation.my_orders') }} / {{ __('navigation.do_order') }}
    </h4>



    <div class="card">
        <div class="card-body p-2 p-md-4">

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

        <h4>Lieferdaten</h4>
        <div class="switchers-stacked">
            <label class="switcher switcher-secondary">
                <input type="radio" class="switcher-input" name="switchers-radio-is-for" value="me" @if(!$shopping_user) checked="checked" @endif >
                <span class="switcher-indicator">
                      <span class="switcher-yes"></span>
                      <span class="switcher-no"></span>
                    </span>
                <span class="switcher-label">Ware ist für mich und wird an meine Adresse versandt</span>
            </label>

            <label class="switcher switcher-secondary">
                <input type="radio" class="switcher-input" name="switchers-radio-is-for" value="ot" @if($shopping_user) checked="checked" @endif>
                <span class="switcher-indicator">
                      <span class="switcher-yes"></span>
                      <span class="switcher-no"></span>
                    </span>
                <span class="switcher-label">Ware ist für einen Kunden und wird an den Kunden versandt</span>
            </label>
        </div>
            <hr>

        <div id="show-is-for-customer" @if(!$shopping_user) style="display: none" @endif >
            <div class="form-row">
                <div class="form-group col-sm-6">
                    <button type="button" class="btn btn-sm btn-secondary" data-toggle="modal" data-target="#modals-load-content"
                            data-id="show"
                            data-action="user-order-my-delivery-show"
                            data-back="{{route('user_order_my_delivery', [$for])}}"
                            data-modal="modal-xl"
                            data-route="{{route('modal_load')}}"><span class="fa fa-shopping-cart"></span> An bestehenden Kunden versenden | Kunden auswählen</button>
                </div>
                <div class="form-group col-sm-6">
                    <a href="{{route('user_customer_add', ['new'])}}" class="btn btn-sm btn-primary">An neuen Kunden versenden | <i class="ion ion-md-person-add"></i> Kunden hinzufügen</a>
                </div>
            </div>
            <hr>
            @if($shopping_user)
                @if(Session::has('custom-error'))
                    <div class="alert alert-dark-warning alert-dismissible fade show">
                        <button type="button" class="close" data-dismiss="alert">×</button>
                        <strong>{{ Session::get('custom-error') }}</strong>
                    </div>
                @endif
                <div class="show-is-for-customer">
                    <h4>An diesen Kunde versenden</h4>
                    <p>Sollten unten stehende Angaben nicht korrekt sein oder aktualisiert werden müssen, ändere diese bitte vorerst unter:
                        <a href="{{route('user_customers')}}">Meine Kunden -> Übersicht</a> -> <a href="{{route('user_customer_detail', $shopping_user->id)}}"><i class="fa fa-edit"></i> Kunde</a></a></p>
                    @include('admin.customer._customer_detail')
                </div>
            @endif

        </div>
            @if($shopping_user)
            <div class="" id="hide_for_me">
                <hr>
            <div class="form-group">
                <label class="custom-control custom-checkbox m-2 ">
                    <input type="checkbox" class="custom-control-input" name="check_for_ot" id="checkbox_for_me" required>
                    <span class="custom-control-label secondary">{{__('Mir ist bekannt, dass dieser Bestellvorgang nur für Kundenbestellungen ist und nicht für meine eigenen Bestellungen')}}</span>
                </label>
            </div>
            </div>

            <div class="float-rights">
                <button type="submit" class="btn btn-secondary" name="action" value="next">bestätigen und weiter zur Bestellung</button>
            </div>
            @else
            <div class="float-rights" id="hide_for_ot">
                <button type="submit" class="btn btn-secondary" name="action" value="next">bestätigen und weiter zur Bestellung</button>
            </div>
            @endif
        </div>
        {!! Form::close() !!}

    </div>

    <script>
        $( document ).ready(function() {

            $('input[name="switchers-radio-is-for"]').on('change', function (){
               if($(this).val() === 'ot'){
                   $('#show-is-for-customer').show('slow');
                   $('#hide_for_ot').hide('slow');
                   $('#hide_for_me').show('slow');
                   $('#checkbox_for_me').attr('required', true);

               }else{
                   $('#show-is-for-customer').hide('slow');
                   $('#hide_for_ot').show('slow');
                   $('#hide_for_me').hide('slow');
                   $('#checkbox_for_me').attr('required', false);


               }
            });
        });
    </script>
@endsection

