
<div class="card mb-2">

    <h5 class="card-header">
        {{ __('Promotion') }}
    </h5>
    <div class="card-body">

        <div class="form-group ">
            <label class="custom-control custom-checkbox float-right">
                {!! Form::checkbox('active', 1, $promotion->active, ['class'=>'custom-control-input']) !!}
                <span class="custom-control-label">{{__('Berater können diese Promotion sehen')}}</span>
            </label>
            <label class="form-label" for="name">{{ __('Promotionname / Titel') }}*</label>
            {{ Form::text('name', $promotion->name,  array('placeholder'=>__('Name'), 'class'=>'form-control', 'id'=>'name', 'required')) }}
        </div>

        <div class="form-row">

            <div class="form-group col-sm-6">
                <label class="form-label" for="type">{{ __('Promotiontyp') }}*</label>
                {{ Form::select('type', $promotion->promotionType, $promotion->type, array('data-live-search'=>'false', 'class'=>'selectpicker', 'id'=>'type') ) }}
            </div>
        </div>
        <div class="form-row">
            <div class="form-group col-sm-6">
                <label class="form-label" for="">Zusätzliches einkaufen</label>
                <label class="custom-control custom-checkbox mt-2">
                    {!! Form::checkbox('shop', 1, $promotion->shop, ['class'=>'custom-control-input']) !!}
                    <span class="custom-control-label">Shop bei Promotion anzeigen</span>
                </label>
            </div>
        </div>
        <div class="form-row">
            <div class="form-group col-12">
                <label class="form-label" for="description">{{ __('Promotioninfo') }}</label>
                {{ Form::textarea('description', $promotion->description ,  array('placeholder'=>__('Interne Notiz'), 'class' => 'form-control text-autosize', 'rows' => 1, 'id'=>'description')) }}
            </div>
        </div>

        <div class="form-row">
            <div class="form-group col-12">
                <label class="form-label" for="user_description">{{ __('Vertriebspartner - Kurzbeschreibung Deiner Promotion') }}</label>
                {{ Form::textarea('user_description', $promotion->user_description ,  array('placeholder'=>__('Kurzbeschreibung'), 'class' => 'form-control bootstrap-maxlength text-autosize', 'maxlength'=>600, 'rows' => 1, 'id'=>'description')) }}
            </div>
        </div>

        <div class="form-row">
            <div class="form-group col-12">
                <label class="form-label" for="user_about">{{ __('Vertriebspartner - Kurzer Text über Dich') }}</label>
                {{ Form::textarea('user_about', $promotion->user_about ,  array('placeholder'=>__('Text über Dich'), 'class' => 'form-control bootstrap-maxlength text-autosize', 'maxlength'=>600, 'rows' => 1, 'id'=>'description')) }}
            </div>
        </div>
        <div class="form-row">
            <div class="form-group col-sm-3">
                <label class="form-label" for="max_bugdet">{{ __('Max. gesamtes Budget für diese Promotion') }}</label>
                {{ Form::text('max_bugdet', $promotion->getFormattedMaxBugdet(),  array('placeholder'=>__('Budget in Euro / Brutto'), 'class'=>'form-control', 'id'=>'max_bugdet')) }}
            </div>
            <div class="form-group col-sm-3">
                <label class="form-label" for="max_items">{{ __('Max. gesamte Produkte für diese Promotion') }}</label>
                {{ Form::text('max_items', $promotion->max_items,  array('placeholder'=>__('Einheiten in Stück'), 'class'=>'form-control', 'id'=>'max_items')) }}
            </div>
            <div class="form-group col-sm-6">
                <label class="form-label">&nbsp;</label><br>
                <i>Ist das Budget oder Einheiten erreicht, wird auf der Microseite keine Promotion mehr angezeigt.</i>
            </div>
        </div>
         <div class="form-row">
           <div class="form-group col-sm-3">
                <label class="form-label" for="from">{{ __('Promotion Datum ab') }}</label>
                {!! Form::text('from', $promotion->from, ['class'=>'form-control datepicker-base']) !!}
            </div>

            <div class="form-group col-sm-3">
                <label class="form-label" for="to">{{ __('Promotion Datum bis') }}</label>
                {!! Form::text('to', $promotion->to, ['class'=>'form-control datepicker-base']) !!}
            </div>
            
          
            <div class="form-group col-sm-6">
                <label class="form-label">&nbsp;</label><br>
                <i>Ist das ab oder bis Datum gesetzt wird die Promotion nur innerhalb dieses Zeitraumns angezeigt.</i>
            </div>
            
          
        </div>
    </div>
</div>


<div class="card mb-2">
    <h5 class="card-header">
        {{ __('Produkte') }}
    </h5>
    @if($promotion->id > 0)

    <div class="mt-3 ml-3">
        <button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-load-content"
            data-id="new"
            data-promotion_id="{{ $promotion->id }}"
            data-action="save-promotion_product"
            data-back="{{url()->current()}}"
            data-route="{{ route('modal_load') }}"><span class="far fa-plus-circle"></span> Produkt hinzufügen
        </button>

    </div>
    <div class="card-body px-0">
        <div class="card-datatable table-responsive pt-0">
            <table class="datatables-style table table-striped table-bordered">
                <thead>
                <tr>
                    <th style="max-width: 60px;">&nbsp;</th>
                    <th>{{__('Bild')}}</th>

                    <th>{{__('Produkt')}}</th>
                    <th>{{__('Versandkosten') }}</th>
                    <th>{{__('Provision') }}</th>
                    <th>{{__('Neuer Preis')}}</th>
                    <th>{{__('Preis B.') }}</th>
                    <th>{{__('max. P.') }}</th>
                    <th>{{__('verkauft P.') }}</th>
                    <th>{{__('active') }}</th>
                    <th></th>
                </tr>
                </thead>
                <tbody>
                @foreach($promotion->promotion_admin_products as $promotion_admin_products)
                    <tr>
                        <td>
                            <button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-load-content"
                            data-id="{{ $promotion_admin_products->id }}"
                            data-promotion_id="{{ $promotion->id }}"
                            data-action="save-promotion_product"
                            data-back="{{url()->current()}}"
                            data-route="{{ route('modal_load') }}"><span class="fa fa-edit"></span></button>
                        </td>
                        <td>
                            @if(count($promotion_admin_products->product->images))
                            <img class="img-fluid" alt="" style="max-height: 80px" src="{{ route('product_image', [$promotion_admin_products->product->images->first()->slug]) }}">
                            @endif
                        </td>
                        <td><a href="{{ route('admin_product_edit', [$promotion_admin_products->product->id]) }}">{{ $promotion_admin_products->product->name }}</a></td>
                        <td>{!! get_active_badge($promotion_admin_products->calcu_commission) !!}</td>
                        <td>{!! get_active_badge($promotion_admin_products->shipping) !!}</td>
                        <td>{!! get_active_badge($promotion_admin_products->own_price) !!}</td>
                        <td>{{ $promotion_admin_products->getFormattedRealPrice() }}  €</td>
                        <td>{{ $promotion_admin_products->max_items }}</td>
                        <td>{{ $promotion_admin_products->used_items }}</td>
                        <td>{!! get_active_badge($promotion_admin_products->active) !!}</td>
                        <td><a class="text-danger" href="{{ route('admin_promotion_delete', [$promotion_admin_products->id, 'promotion_admin_product']) }}"  onclick="return confirm('{{__('Produkt entfernen?')}}');"><i class="far fa-trash-alt"></i></a></td>
                    </tr>
                @endforeach
                </tbody>
            </table>
        </div>
    </div>
    @endif
</div>



