<div class="container containerProduct" >

<form class="productForm">
    <div class="form-group row">
        <label for="productSupplierName" class="col-sm-2 col-form-label">Beszálllító néve:</label>
        <div class="col-sm-10">
            <span class="font-weight-bold">{{$Product->supplier->name}}</span>
            <input type="hidden" name="supplierId" value="12">
        </div>
    </div>

    <div class="form-group row">
        <label for="productName" class="col-sm-2 col-form-label">Termék név:</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" id="productName" placeholder="Írja be a nevét" name="name" value="{{$Product->name}}">
        </div>
    </div>

    <div class="form-group row">
        <label for="productProducer" class="col-sm-2 col-form-label">Gyártó:</label>
        <div class="col-sm-10">
            <select class="productProducerSelect" name="producer[]"  multiple="multiple" style="width: 100%">
                @foreach($producer as $item)
                        <option value="{{$item['id']}}"
                                @if ($item['id']==$Product->producer_id)
                                    selected
                            @endif
                        >
                            {{$item['name']}}
                        </option>
                @endforeach
            </select>
        </div>
    </div>

    <div class="form-group row">
        <label for="" class="col-sm-2 col-form-label">Adatok:</label>
        <div class="col-sm-10">
            <div class="input-group mb-3">
                <div class="input-group-prepend">
                    <span class="input-group-text" >Kiszerelés:</span>
                </div>
                <input type="text" class="form-control" placeholder="" name="packaging" value="{{$Product->packing}}" >
                <div class="input-group-prepend">
                    <span class="input-group-text" >Ürtart.</span>
                </div>
                <input type="text" class="form-control" placeholder="" name="unitValue" value="{{$Product->unitValue}}">
                <div class="input-group-prepend">
                    <span class="input-group-text" >Mértékegység.</span>
                </div>
                <select class="productUnit" style="width: 5em; height: 2em;" name="productUnit" >
                    @foreach($productUnit as $unitName)
                        <option value="{{$unitName}}"
                            @if ($unitName==$Product->productUnit)
                                    selected
                            @endif
                        >{{$unitName}}</option>
                    @endforeach


                </select>

            </div>

        </div>
    </div>

    <div class="form-group row">
        <label for="" class="col-sm-2 col-form-label"></label>
        <div class="col-sm-10">
            <div class="input-group mb-3">
                <div class="input-group-prepend">
                    <span class="input-group-text" >Eladási Egység:</span>
                </div>
                <select class="productUnit" style="width: 5em; height: 2em;" name="sellerUnit">
                    @foreach($sellerUnit as $unitName)
                        <option value="{{$unitName}}"
                            @if ($unitName==$Product->sellerUnit)
                                selected
                           @endif
                        >{{$unitName}}</option>
                    @endforeach

                </select>
                <div class="input-group-prepend">
                    <span class="input-group-text" >Egységszorzó.</span>
                </div>
                <input type="text" class="form-control" placeholder="" name="unitMultiplier" value="{{$Product->unitMultiplier}}">
                <div class="input-group-prepend">
                    <span class="input-group-text" >MennyiségiEgység.</span>
                </div>
                <input type="text" class="form-control" placeholder="" name="amountUnit" value="{{$Product->amountUnit}}">

            </div>

        </div>
    </div>

    <div class="form-group row">
        <label for="" class="col-sm-2 col-form-label"></label>
        <div class="col-sm-10">
            <div class="input-group mb-3">
                <div class="input-group-prepend">
                    <span class="input-group-text" >Aktuális számlázási nettó ár</span>
                </div>
                <input type="text" class="form-control" placeholder="" name="price" value="{{$Product->price}}">
                <div class="input-group-prepend">
                    <span class="input-group-text" >ÁFA %</span>
                </div>
                <input type="text" class="form-control" placeholder="" name="vat" value="{{$Product->vat}}">
                <div class="input-group-prepend">
                    <span class="input-group-text" >Szállítói cikkszám</span>
                </div>
                <input type="text" class="form-control" placeholder="" name="supplierProductNumber" value="{{$Product->supplierProductNumber}}">
              {{--  <div class="input-group-prepend">
                    <span class="input-group-text" >Áfa%</span>
                </div>
                <input type="text" class="form-control" placeholder="" name="vat">
--}}
            </div>

        </div>
    </div>



{{--
    **************************************
    Vevői adatok
    **************************************
    --}}

    <div class="form-group row">
        <label for="productBuyerName" class="col-sm-2 col-form-label">Vevői megnevezés:</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" id="productBuyerName" placeholder="Írja be a nevét" name="buyerProductName" value="{{$Product->buyerProductName}}">
        </div>
    </div>

    <div class="form-group row">
        <label for="productProductGroups" class="col-sm-2 col-form-label">Termék kategória:</label>
        <div class="col-sm-10">
            <select class="productCategorySelect" name="productGroup[]"  multiple="multiple" style="width: 100%">
                <optgroup label="Food">
{{--
                    @foreach($productGroup as $groupData) @if($groupData['type']=='F' && $groupData['depth']>1)<option value="{{$groupData['id']}}">{{$groupData['name']}}</option>@endif @endforeach
--}}
                @foreach($productGroup as $groupData) @if($groupData['type']=='F' && $groupData['depth']>1)<option value="{{$groupData['id']}}" @if ($groupData['id']==$Product->product_group_id) selected @endif>{{$groupData['name']}}</option>
                    @endif @endforeach

                </optgroup>
                <optgroup label="Non Food">
                @foreach($productGroup as $groupData)
                    @if($groupData['type']=='N' && $groupData['depth']==2)
                    <option value="{{$groupData['id']}}" @if ($groupData['id']==$Product->product_group_id) selected @endif>{{$groupData['name']}}</option>
                    @endif
                @endforeach
                </optgroup>

            </select>
        </div>
    </div>

    <div class="form-group row">
        <label for="" class="col-sm-2 col-form-label">Vevői adatok:</label>
        <div class="col-sm-10">
            <div class="input-group mb-3">
                <div class="input-group-prepend">
                    <span class="input-group-text" >Hooreyca ID:</span>
                </div>
                <input type="text" class="form-control" placeholder="" name="hooreycaId" value="{{$Product->hooreycaId}}" >
                <div class="input-group-prepend">
                    <span class="input-group-text" >H. mértékegység:</span>
                </div>
                <input type="text" class="form-control" placeholder="" name="HooreycaUnit" value="{{$Product->HooreycaUnit}}" >
                <div class="input-group-prepend">
                    <span class="input-group-text" >H. mennyiségi szorzó:</span>
                </div>
                <input type="text" class="form-control" placeholder="" name="HooreycaMultiplier" value="{{$Product->HooreycaMultiplier}}" >
{{--
                <div class="input-group-prepend">
                    <span class="input-group-text" >Vevői cikkszám</span>
                </div>
                <input type="text" class="form-control" placeholder="" name="buyerProductNumber" value="{{$Product->buyerProductNumber}}">
--}}

            </div>
        </div>
    </div>


























    <div class="form-group row">
        <label for="note" class="col-sm-2 col-form-label">Megjegyzés:</label>
        <div class="col-sm-10">
            <textarea class="form-control" rows="3" placeholder="Ha kiván itt tud megjegyzést írni" name="note">{{$Product->note}}</textarea>
        </div>
    </div>

   <div class="form-group row">
        <label for="" class="col-sm-2 col-form-label">Kapcsolók:</label>
        <div class="col-sm-10">
            <div class="input-group mb-3">
                <div class="input-group-prepend">
                    <span class="input-group-text text-black" >Látható:</span>
                </div>
                <div  class="btn-group customRadioBtnGroup " >
                    <a class="btn btn-primary btn-sm
                        @if($Product->canSee==1) active @else notActive @endif " data-toggle="canSee" data-title="1">Igen</a>
                    <a class="btn btn-primary btn-sm
                        @if($Product->canSee==0) active @else notActive @endif" data-toggle="canSee" data-title="0">Nem</a>
                </div>
                <input type="hidden" name="canSee" value="{{$Product->canSee}}">

                <div class="input-group-prepend" style="margin-left: 5px;">
                    <span class="input-group-text text-black" >Krel:</span>
                </div>
                <div  class="btn-group customRadioBtnGroup">
                    <a class="btn btn-primary btn-sm
                        @if($Product->krel==1) active @else notActive @endif" data-toggle="krel" data-title="1">Igen</a>
                    <a class="btn btn-primary btn-sm
                        @if($Product->krel==0) active @else notActive @endif" data-toggle="krel" data-title="0">Nem</a>
                </div>
                <input type="hidden" name="krel" value="{{$Product->krel}}">

                <div class="input-group-prepend" style="margin-left: 5px;">
                    <span class="input-group-text text-black" >Akciós:</span>
                </div>
                <div  class="btn-group customRadioBtnGroup">
                    <a class="btn btn-primary btn-sm
                        @if($Product->specialOffer==1) active @else notActive @endif" data-toggle="specialOffer" data-title="1">Igen</a>
                    <a class="btn btn-primary btn-sm
                        @if($Product->specialOffer==0) active @else notActive @endif" data-toggle="specialOffer" data-title="0">Nem</a>
                </div>
                <input type="xhidden" name="specialOffer" value="{{$Product->specialOffer}}">

{{--
                <div class="input-group-prepend" style="margin-left: 5px;">
                    <span class="input-group-text text-black" >Súlymérős:</span>
                </div>
                <div  class="btn-group customRadioBtnGroup">
                    <a class="btn btn-primary btn-sm
                        @if($Product->weightScale==1) active @else notActive @endif" data-toggle="weightScale" data-title="1">Igen</a>
                    <a class="btn btn-primary btn-sm
                        @if($Product->weightScale==0) active @else notActive @endif" data-toggle="weightScale" data-title="0">Nem</a>
                </div>
                <input type="hidden" name="weightScale" value="{{$Product->weightScale}}">
--}}


            </div>
        </div>
    </div>

    {{--    <div class="form-group row">
            <label for="note" class="col-sm-2 col-form-label">Látható:</label>
            <div class="col-sm-10">
                <div class="input-group">
                    <div  class="btn-group customRadioBtnGroup">
                        <a class="btn btn-primary btn-sm
                        @if($Product->canSee==1) active @else notActive @endif
                        @end
                        " data-toggle="canSee" data-title="1">Igen</a>
                        <a class="btn btn-primary btn-sm
                        @if($Product->canSee==0) active @else notActive @endif" data-toggle="canSee" data-title="0">Nem</a>
                    </div>
                    <input type="hidden" name="canSee" value="{{$Product->canSee}}">
                </div>

            </div>
        </div>--}}
{{--

    <div class="form-group row">
        <label for="logoFile" class="col-sm-2 col-form-label">Kép:</label>
        <div class="col-sm-10">
            <div class="input-group mb-3">
                <div class="custom-file">
                    <input type="file" class="custom-file-input" id="" name="logoFile" accept="image/*">
                    <label class="custom-file-label" for="">Válasszon fájlt</label>
                </div>
            </div>
        </div>
        <label for="logoFileFile" class="col-sm-2 col-form-label"></label>
        <div class="col-sm-8 containerFileUploadStarted ">
            <div class="input-group mb-3 ">
                <img class="imageProduct" src="{{url('images/icons/no-photo256.png')}}">
            </div>
        </div>
    </div>
    <div class="form-group row">
        <label for="attacheFile" class="col-sm-2 col-form-label">Specifikáció:</label>
        <div class="col-sm-10">
            <div class="form-group row">
                <div class="input-group mb-3">
                    <div class="custom-file">
                        <input type="file" class="custom-file-input" id="" name="specificationFile"
                               accept="application/msword, application/vnd.ms-excel, text/plain, application/pdf, image/*, application/vnd.oasis.opendocument.spreadsheet, application/vnd.oasis.opendocument.text">
                        <label class="custom-file-label" for="">Válasszon fájlt</label>
                    </div>
                </div>

            </div>


            <div class="form-group row">

                <div class="col">
                    <table class="table table-striped table-hover table-sm attachmentTable">
                        <thead>
                        <tr>
                            <th scope="col">#</th>
                            <th scope="col">Név</th>
                            <th scope="col">Dátum</th>
                            <th scope="col">Fájl</th>
                            <th scope="col">Akció</th>
                        </tr>
                        </thead>
                        <tbody>

                        <template data-name="productAttachmentTableRow">
                            <tr>
                                <th scope="row">[[rowNum]]
                                    <input type="hidden" name="attachmentId" value="[[id]]" style="width: 3em;"/>
                                </th>
                                <td>[[original_filename]]</td>
                                <td>[[date]]</td>
                                <td><a href="[[link]]" download="[[original_filename]]">Letöltés</a>

                                </td>
                                <td>
                                    <button type="button" class="btn btn-danger buttonDelete"  data-toggle="tooltip" data-placement="bottom" title="Törlés">
                                        <span class="fas fa-trash"></span>
                                    </button>
                                </td>
                            </tr>
                        </template>
                        </tbody>
                    </table>
                </div>

            </div>
        </div>
    </div>

--}}
    <div class="form-group row">
        <div class="col-sm-10">
            <button type="button" class="btn btn-success FormSaveButton">Mentés</button>
        </div>
    </div>
    {{--
    --}}

</form>
</div>

<style>
    .contactTable .btn{
        padding: 1px 6px;
    }
    .select2-selection__rendered {
        vertical-align: center;
/*
        line-height: calc(2em + 0.75rem + 2px); !important;
        height:calc(2em + 0.75rem + 2px); !important;
*/

    }
    .select2-container .select2-selection--single {
        height: calc(1.5em + 0.75rem + 2px); !important;
    }
    .select2-selection__arrow {
        height:calc(2em + 0.75rem + 2px); !important;
    }

</style>
<script>


    $(document).ready(function() {

        $(".productUnit").select2({
            dropdownCssClass: "bigdrop",
        });
        $(".productCategorySelect").select2({
            maximumSelectionLength: 1,
        });
        $(".productProducerSelect").select2({
            maximumSelectionLength: 1,
        });
        APP.ProductAdmin = new window.ProductAdmin();
        APP.ProductAdmin.init({
            token:'{{csrf_token()}}',
            URL: {
                getDataTableContent:'{{route('admin.product.getDataTableContent')}}',
                getProductSearch:'{{route('admin.statistics.getProductSearch')}}',
                index:'{{route('admin.product.index')}}',
                show:'{{route('admin.product.show',"%id%")}}',
                create:'{{route('admin.product.create')}}',
                edit:'{{route('admin.product.edit',"%id%")}}',
                store:'{{route('admin.product.store')}}',
                update:'{{route('admin.product.update',"%id%")}}',
                destroy:'{{route('admin.product.destroy',"%id%")}}',
                attachFile:'{{route('admin.product.attachFile',"%id%")}}',
                detachFile:'{{route('admin.product.detachFile',"%id%")}}',
            },
        },APP.Product);

        initRadioButtons();
        APP.Product=new Product({!! json_encode($Product) !!});
        APP.ProductAdmin.Product=APP.Product;
        APP.ProductAdmin.initViewDetails();
    })
</script>
