
<div class="card mb-2">

    <h5 class="card-header">
        {{ __('Produkt') }}

    </h5>

    <div class="card-body">

        <div class="form-group">
            <label class="custom-control custom-checkbox float-right">
                {!! Form::checkbox('active', 1, $product->active, ['class'=>'custom-control-input']) !!}
                <span class="custom-control-label">{{__('aktiv')}}</span>
            </label>
            <label class="form-label" for="name">{{ __('Produktname / Titel') }}*</label>
            {{ Form::text('name', $product->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="title">{{ __('Title') }}</label>
                {{ Form::text('title', $product->title,  array('placeholder'=>__('Title'), 'class'=>'form-control', 'id'=>'title')) }}
            </div>
            --}}
        </div>

        <div class="form-row">
            <div class="form-group col-sm-5">
                <label class="form-label" for="title">{{ __('Kategorie (Mehrfachauswahl)') }}*</label>
                <select class="selectpicker" name="categories[]" id="categories"  data-style="btn-light" data-live-search="false" multiple required>
                    {!!  HTMLHelper::getCategoriesOptions($product->categories()->pluck('category_id')->toArray(), false) !!}
                </select>
            </div>
            <div class="form-group col-sm-5">
                <label class="form-label" for="show_at">{{ __('Produkt anzeigen') }}</label>
                {{ Form::select('show_at', $product->showATs, $product->show_at, array('data-live-search'=>'false', 'class'=>'selectpicker', 'id'=>'show_at') ) }}
            </div>

            <div class="form-group col-sm-2">
                <label class="form-label" for="pos">{{ __('Listenposition') }}</label>
                {{ Form::text('pos', $product->pos,  array('placeholder'=>__('1, 2, 3, etc'), 'class'=>'form-control', 'id'=>'pos')) }}
            </div>
        </div>
        <div class="form-group">
            <label class="form-label" for="copy">{{ __('Produktbeschreibung') }}</label>
            {{ Form::textarea('copy', $product->copy ,  array('placeholder'=>__('Produktbeschreibung'), 'class'=>'form-control summernote', 'id'=>'copy')) }}
        </div>

    </div>
</div>

<div class="card mb-2">
    <h5 class="card-header">
        {{ __('Preise in EUR') }}
    </h5>
    <div class="card-body">
        <div class="form-row">
            <div class="form-group col-sm-4">
                <label class="form-label" for="price">{{ __('Preis VK in EUR (Brutto)') }}</label>
                {{ Form::text('price', $product->getFormattedPrice(),  array('placeholder'=>__('Preis VK in EUR (Brutto)'), 'class'=>'form-control', 'id'=>'price')) }}

            </div>

            <div class="form-group col-sm-4">
                <label class="form-label" for="tax">{{ __('MwSt in %') }}</label>
                {{ Form::text('tax', $product->getFormattedTax(),  array('placeholder'=>__('MwSt in %'), 'class'=>'form-control', 'id'=>'tax')) }}

            </div>
            <div class="form-group col-sm-4">
                <label class="form-label" for="price_old">{{ __('Streichpreis in EUR (wenn > 0)') }}</label>
                {{ Form::text('price_old', $product->getFormattedPriceOld(),  array('placeholder'=>__('Streichpreis'), 'class'=>'form-control', 'id'=>'price_old')) }}

            </div>
        </div>
        <div class="form-row">

            <div class="form-group col-sm-4">
                <label class="form-label" for="weight">{{ __('Gewicht in g') }}</label>
                {{ Form::text('weight', $product->weight,  array('placeholder'=>__('Gewicht in g'), 'class'=>'form-control', 'id'=>'weight')) }}
            </div>
            {{-- <div class="form-group col-sm-4">
                <label class="form-label" for="points">{{ __('Points pro Produkt') }}</label>
                {{ Form::text('points', $product->points,  array('placeholder'=>__('Points pro Produkt'), 'class'=>'form-control', 'id'=>'points')) }}
            </div>
            --}}
            <div class="form-group col-sm-4">
                <label class="form-label" for="amount">{{ __('Anzahl/Verfügbarkeit') }}</label>
                {{ Form::text('amount', $product->amount,  array('placeholder'=>__('Anzahl/Verfügbarkeit'), 'class'=>'form-control', 'id'=>'amount')) }}
            </div>
            <div class="form-group col-sm-4">
                <label class="form-label" for="price_ek">{{ __('Preis EK in EUR') }}</label>
                {{ Form::text('price_ek', $product->getFormattedPriceEk(),  array('placeholder'=>__('Preis EK in EUR'), 'class'=>'form-control', 'id'=>'price_ek')) }}

            </div>
        </div>
        <div class="form-row">
            <div class="form-group col-sm-4">
                <label class="form-label" for="weight">{{ __('Keine Staffelprovision') }}</label>

                <label class="custom-control custom-checkbox mt-2">
                    {!! Form::checkbox('single_commission', 1, $product->single_commission, ['class'=>'custom-control-input']) !!}
                    <span class="custom-control-label">Einzelrabatt für dieses Produkt</span>
                </label>
                <label class="custom-control custom-checkbox mt-2">
                    {!! Form::checkbox('amount_commission', 1, $product->amount_commission, ['class'=>'custom-control-input']) !!}
                    <span class="custom-control-label">Betrag zum Staffelumsatz addieren</span>
                </label>


            </div>
            <div class="form-group col-sm-4">
                <label class="form-label" for="value_commission">{{ __('Einzelrabatt in %') }}</label>
                {{ Form::text('value_commission', $product->getFormattedValueCommission(),  array('placeholder'=>__('Einzelrabatt in %'), 'class'=>'form-control', 'id'=>'value_commission')) }}
            </div>
            <div class="form-group col-sm-4">
                <label class="form-label" for="partner_commission">{{ __('Vertriebspartner Einzelrabatt in %') }}</label>
                {{ Form::text('partner_commission', $product->getFormattedPartnerCommission(),  array('placeholder'=>__('Vertriebspartner Einzelrabatt in %'), 'class'=>'form-control', 'id'=>'partner_commission')) }}
            </div>
        </div>
    </div>
</div>

<div class="card mb-2">
    <h5 class="card-header">
       Landesspezifische Preise
    </h5>

    <div class="card-body pt-0">
        @foreach($country_for_prices as $country)

            {{ Form::hidden('country_prices[]', $country->id) }}
            <div class="card-header bg-light pb-0 mt-3">
                <h6>{{$country->de}}</h6>
            </div>
            <div class="bg-lighter p-2">
                @if($country->own_eur)
                    <div class="form-row">
                        <div class="form-group col-sm-4 col-md-3">
                            <label class="form-label">Land hat eigenen EURO Preis</label>
                            <p></p>
                        </div>
                        <div class="form-group col-sm-4 col-md-3">
                            <label class="form-label" for="price">{{ __('Preis VK in EUR Brutto') }}</label>
                            {{ Form::text('c_price['.$country->id.']', formatNumber($product->getCPrice($country->id)),  array('placeholder'=>__('Preis VK in EUR Brutto'), 'class'=>'form-control', 'id'=>'c_price_'.$country->id)) }}

                        </div>
                        <div class="form-group col-sm-4 col-md-3">
                            <label class="form-label" for="tax">{{ __('MwSt in %') }}</label>
                            {{ Form::text('c_tax['.$country->id.']', formatNumber($product->getCTax($country->id)),  array('placeholder'=>__('MwSt in %'), 'class'=>'form-control', 'id'=>'c_tax'.$country->id)) }}

                        </div>
                        <div class="form-group col-sm-4 col-md-3">
                            <label class="form-label" for="price_old">{{ __('Streichpreis (wenn > 0)') }}</label>
                            {{ Form::text('c_price_old['.$country->id.']', formatNumber($product->getCPriceOld($country->id)),  array('placeholder'=>__('Streichpreis'), 'class'=>'form-control', 'id'=>'c_price_old'.$country->id)) }}

                        </div>
                    </div>
                @endif
                @if($country->currency)
                    <div class="form-row">
                        <div class="form-group col-sm-4 col-md-3">
                            <label class="form-label">Land hat eigene Währung</label>
                            <p>@if($country->currency_calc) Preis Berechnung automatisch  @else Preis manuell
                                angegeben @endif</p>
                        </div>

                        @if($country->currency_calc)
                            {{--
                            NUR Anzeige vom automatisch berechneten Preis currency_faktor
                            Auf Basis vom price
                            Wenn  own_eur auf basis vom own_eur price
                            --}}
                            <div class="form-group col-sm-4 col-md-3">
                                <label class="form-label">Preis VK in {{ $country->currency_unit }}</label>
                                {{ Form::text('c_currency['.$country->id.']', formatNumber($product->getRealPrice($country) * $country->currency_faktor),  array('class'=>'form-control', 'readonly')) }}

                            </div>
                        @else
                            {{--
                                Eingabe
                                Währungs Namen aus currency_name
                                currency_faktor als Hinweis ausgeben
                                Auf Basis vom price
                                Wenn own_eur auf basis vom own_eur price
                            --}}
                            <div class="form-group col-sm-4 col-md-3">
                                <label class="form-label">{{__('Preis VK in ')}} {{ $country->currency_unit }} ({{formatNumber($product->getRealPrice($country) * $country->currency_faktor)}})</label>
                                {{ Form::text('c_currency['.$country->id.']', formatNumber($product->getCCurrency($country->id)),  array('placeholder'=>__('Preis VK in ').$country->currency_unit, 'class'=>'form-control')) }}
                            </div>
                        @endif

                        <div class="form-group col-sm-4 col-md-2">
                            <label class="form-label">{{ __('Währungs Faktor' ) }}</label>
                            {{ Form::text('currency_faktor['.$country->id.']', formatNumber($country->currency_faktor, 4),  array('class'=>'form-control', 'readonly')) }}
                        </div>
                        <div class="form-group col-sm-4 col-md-2">
                            <label class="form-label">{{ __('Preis VK in EUR ') }}</label>
                            {{ Form::text('preis_eur['.$country->id.']', formatNumber($product->getRealPrice($country)),  array('class'=>'form-control', 'readonly')) }}
                        </div>
                        <div class="form-group col-sm-4 col-md-2">
                            <label class="form-label">{{ __('Währung') }}</label>
                            {{ Form::text('currency_unit['.$country->id.']', $country->currency_unit,  array('class'=>'form-control', 'readonly')) }}
                        </div>

                    </div>
                @endif
            </div>
        @endforeach
        <em class="float-right text-muted small">für die Einstellung von landesspezifischen Preisen müssen diese unter
            <a href="{{route('admin_countries')}}">Länder</a> -> Land aktiviert werden.</em>
    </div>
</div>


<div class="card mb-2">
    <h5 class="card-header">
        {{ __('Inhalte') }}
    </h5>
    <div class="card-body">
        <div class="form-row">

            <div class="form-group col-sm-5">
                <label class="form-label" for="contents">{{ __('Menge Inhalt (ml / g) als Text') }}</label>
                {{ Form::text('contents', $product->contents,  array('placeholder'=>__('Bsp: 150 ml'), 'class'=>'form-control', 'id'=>'contents')) }}
            </div>
            <div class="form-group col-sm-3">
                <label class="form-label" for="contents_total">{{ __('Gesamter Inhalt (ml / g) als Zahl') }}</label>
                {{ Form::text('contents_total', $product->contents_total,  array('placeholder'=>__('Bsp: 150'), 'class'=>'form-control', 'id'=>'contents_total')) }}
            </div>
            <div class="form-group col-sm-2">
                <label class="form-label" for="contents">{{ __('Grundpreis Einheit') }}</label>
                {{ Form::select('unit', $product->unitTypes, $product->unit, array('data-live-search'=>'false', 'class'=>'selectpicker', 'id'=>'unit') ) }}
            </div>
            <div class="form-group col-sm-2">
                <label class="form-label" for="base_price">{{ __('Grundpreis') }}</label>
                {{ Form::text('base_price', $product->getBasePriceFormattedFull(),  array('placeholder'=>__(''), 'class'=>'form-control', 'id'=>'base_price', 'readonly')) }}

            </div>
            <div class="form-group col-sm-4">
                <label class="form-label" for="number">{{ __('Artikelnummer') }}</label>
                {{ Form::text('number', $product->number,  array('placeholder'=>__('number'), 'class'=>'form-control', 'id'=>'number')) }}

            </div>
            <div class="form-group col-sm-4">
                <label class="form-label" for="icons">{{ __('Icons') }}</label>
                {{ Form::text('icons', $product->icons,  array('placeholder'=>__('icons'), 'class'=>'form-control', 'id'=>'icons')) }}

            </div>
            <div class="form-group col-sm-4">
                <label class="form-label" for="title">{{ __('Attribute') }}</label>
                <select class="selectpicker" name="attributes[]" id="attributes" data-style="btn-light"
                        data-live-search="false" multiple>
                    {!!  HTMLHelper::getAttributesOptions($product->attributes()->pluck('attribute_id')->toArray()) !!}
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="form-label" for="description">{{ __('Beschreibung') }}</label>
            {{ Form::textarea('description', $product->description ,  array('placeholder'=>__('description'), 'class'=>'form-control summernote', 'id'=>'description')) }}
        </div>
        <div class="form-group">
            <label class="form-label" for="usage">{{ __('Anwendung') }}</label>
            {{ Form::textarea('usage', $product->usage ,  array('placeholder'=>__('usage'), 'class'=>'form-control summernote', 'id'=>'usage')) }}
        </div>
        <div class="form-group">
            <label class="form-label" for="ingredients">{{ __('Hinweise') }}</label>
            {{ Form::textarea('ingredients', $product->ingredients ,  array('placeholder'=>__('ingredients'), 'class'=>'form-control summernote', 'id'=>'ingredients')) }}
        </div>
    </div>
</div>

<div class="card mb-2">
    <h5 class="card-header">
        {{ __('Inhalte') }}
    </h5>
    <div class="card-body">
        <div class="card-datatable table-responsive pt-0">
            <table class="datatables-style table table-striped table-bordered">
                <thead>
                <tr>
                    <th>{{__('Name')}}</th>
                    <th>{{__('INCI')}}</th>
                    <th>{{__('Wirkung') }}</th>
                    <th></th>
                </tr>
                </thead>
                <tbody>
                @foreach($product->p_ingredients as $ingredient)
                    <tr>
                        <td>{{ $ingredient->name }}</td>
                        <td>{{ $ingredient->inci }}</td>
                        <td>{{ $ingredient->effect }}</td>
                        <td><a class="text-danger" href="{{ route('admin_product_delete', [$product->id, 'ingredient', $ingredient->id]) }}"  onclick="return confirm('{{__('Eintrag entfernen?')}}');"><i class="far fa-trash-alt"></i></a></td>
                    </tr>
                @endforeach
                </tbody>
            </table>
        </div>
        <div class="form-row">
            <div class="form-group col-sm-10">
                <label class="form-label" for="title">{{ __('Inhaltsstoffe hinzufügen (Mehrfachauswahl)') }}</label>
                <select class="selectpicker" name="product_ingredients[]" id="product_ingredients"  data-style="btn-light" data-live-search="false" multiple>
                    {!!  HTMLHelper::getProductIngredientsOptions($product->p_ingredients()->pluck('ingredient_id')->toArray()) !!}
                </select>
                <a class="btn btn-default btn-xs mt-2" href="{{route('admin_product_ingredients')}}">Inhaltsstoffe anlegen</a>
            </div>
            <div class="form-group col-sm-2">
                <button type="submit" class="btn btn-submit mt-0 mt-sm-4">{{ __('save') }}</button>&nbsp;
            </div>
        </div>
    </div>
</div>

@if(Auth::user()->isSySAdmin())
<div class="card mb-2">
    <h5 class="card-header">
        {{ __('SySAdmin Einstellungen') }}
    </h5>
    <div class="card-body">
        <div class="form-row">
            <div class="form-group col-sm-5">
                <label class="form-label" for="action">{{ __('Aktion beim Zahlungsprozess') }}</label>
                {{ Form::select('action[]', $product->actions, $product->action, array('data-live-search'=>'false', 'class'=>'selectpicker', 'id'=>'action', 'multiple') ) }}
            </div>
            <div class="form-group col-sm-5">
                <label class="form-label" for="identifier">{{ __('Anzeigeoptionen Zahlung Mitglieder-Accounts') }}</label>
                {{ Form::select('identifier', $product->identifiers_types, $product->identifier, array('data-live-search'=>'false', 'class'=>'selectpicker', 'id'=>'identifier') ) }}
            </div>
            <div class="form-group col-sm-2">
                <label class="form-label" for="upgrade_to_id">{{ __('Bei Upgrade auf Produkt-ID') }}</label>
                {{ Form::text('upgrade_to_id', $product->upgrade_to_id,  array('placeholder'=>__('Produkt-ID auf das geupdatet werden soll'), 'class'=>'form-control', 'id'=>'upgrade_to_id')) }}
            </div>
        </div>
        <div class="form-row">
        <div class="form-group col-sm-5">
            <label class="form-label" for="wp_number">WP Artikel Number (als Zahl ohne Leerzeichen für die WP-API)</label>
            {{ Form::text('wp_number', $product->wp_number,  array('placeholder'=>__('WP Number'), 'class'=>'form-control', 'id'=>'wp_number')) }}
        </div>
        </div>
    </div>
</div>
@endif