@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">
        {{ __('Erinnerung') }} {{ $reminder->id > 0 ? 'bearbeiten' : 'erstellen' }}
    </h4>

    <div class="text-left mt-0 mb-2">
        <a href="{{ route('admin_payments_reminder') }}" class="btn btn-default">{{ __('back') }}</a>
    </div>

    <div class="card mb-2">
        {!! Form::open(['action' => route('admin_payments_reminder_store',), 'class' => 'form-horizontal', 'id'=>'']) !!}
        <input type="hidden" name="id" value="@if($reminder->id>0){{$reminder->id}}@else new @endif">
        <div class="card-body">

            <div class="form-row">
                <div class="form-group col">
                    <label for="title" class="form-label">{{__('Titel')}}*</label>
                    {{ Form::text('title', $reminder->title,  array('placeholder'=>__('Titel'), 'class'=>'form-control', 'required')) }}
                </div>
            </div>

            <div class="form-row">
                <div class="form-group col">
                    <label for="subject" class="form-label">{{__('Betreff')}}*</label>
                    {{ Form::text('subject', $reminder->subject,  array('placeholder'=>__('Betreff'), 'class'=>'form-control', 'required')) }}
                </div>
            </div>

            <div class="form-row">
                <div class="form-group col">
                    <label for="message" class="form-label">{{__('Nachricht')}}</label>
                    {{ Form::textarea('message', $reminder->message,  array('placeholder'=>__('Nachricht'), 'class'=>'form-control summernote-small')) }}
                    <p> <i>Platzhalter: {billing_first_name}, {billing_last_name}, {order_number}, {order_date}, {order_total}</i></p>
                </div>
            </div>

            <div class="form-row">
                <div class="form-group col">
                    <label for="interval" class="form-label">{{__('Interval (in Tagen nach der Bestellung)')}}*</label>
                    {{ Form::number('interval', $reminder->interval,  array('placeholder'=>__('Interval'), 'class'=>'form-control', 'required')) }}
                </div>
            </div>

            <div class="form-row">
                <div class="form-group col">
                    <label for="clearingtype" class="form-label">{{__('Typ')}}*</label>
                    {{ Form::select('clearingtype', \App\Models\PaymentReminder::returnClearingtypes(), $reminder->clearingtype,  array('placeholder'=>__('Typ'), 'class'=>'form-control custom-select', 'required')) }}
                </div>
            </div>


            <div class="form-row">
                <div class="form-group col-12">
                    <label class="custom-control custom-checkbox m-2">
                        {!! Form::checkbox('action', 'set_order_status_cancelled', $reminder->action == 'set_order_status_cancelled', ['class'=>'custom-control-input']) !!}
                        <span class="custom-control-label">Action: Bestellung auf "storniert" setzen</span>
                    </label>
                </div>

                <div class="form-group col-12">
                    <label class="custom-control custom-checkbox m-2">
                        {!! Form::checkbox('active', 1, $reminder->active, ['class'=>'custom-control-input']) !!}
                        <span class="custom-control-label">{{__('active')}}</span>
                    </label>
                </div>

            </div>
            @if($reminder->id > 0)
                <div class="float-right">
                    <a href="{{ route('admin_payments_reminder_delete', $reminder->id) }}" class="btn btn-danger btn-sm" onclick="return confirm('{{ __('Are you sure you want to delete this reminder?') }}')"><i class="fa fa-trash"></i> {{ __('delete') }}</a>
                </div>
            @endif
            <div class="text-left mt-0 mb-2">
                <button type="submit" class="btn btn-secondary">{{ __('save') }}</button>&nbsp;
            </div>
         
        
        </div>
        {!! Form::close() !!}
    </div>

    
    <div class="text-left mt-2 mb-2">
        <a href="{{ route('admin_payments_reminder') }}" class="btn btn-default">{{ __('back') }}</a>
    </div>
    



@endsection
