@extends('layouts.app')

@section('content')

    <div class="px-3">
        <div class="row">
            <div class="col-xl-6">
                <h4>МАФ на складе</h4>
            </div>
            <div class="col-xl-6 text-end">
                @if(isset($product_sku))
                    <button class="btn btn-sm text-success" onclick="$('#upl-pass').trigger('click');"><i class="bi bi-plus-circle-fill"></i> Загрузить паспорт</button>

                    <form action="{{ route('product-sku.upload-passport', $product_sku) }}" class="visually-hidden" method="POST" enctype="multipart/form-data">
                        @csrf
                        <input type="file" name="passport" onchange="$(this).parent().submit()" required id="upl-pass" />
                    </form>
                @endif
            </div>
        </div>
        <form class="row" action="{{ route('product_sku.update', $product_sku) }}" method="post">

            <div class="col-xxl-6">

                @csrf

                <input type="hidden" id="product_id" name="product_id" value="{{ $product_sku->product_id }}">

                @include('partials.input', ['name' => 'order_name', 'title' => 'Площадка', 'disabled' => true, 'value' => $product_sku->order->common_name])
                @include('partials.input', ['name' => 'product_name', 'title' => 'МАФ', 'disabled' => true, 'value' => $product_sku->product->common_name])
                @include('partials.input', ['name' => 'rfid', 'title' => 'RFID', 'required' => true, 'value' => $product_sku->rfid])
                @include('partials.input', ['name' => 'factory_number', 'title' => 'Номер фабрики', 'required' => true, 'value' => $product_sku->factory_number])
                @include('partials.input', ['name' => 'manufacture_date', 'title' => 'Дата производства', 'type' => 'date', 'required' => true, 'value' => $product_sku->manufacture_date])
                @include('partials.input', ['name' => 'service_life', 'title' => 'Срок службы', 'required' => true, 'type' => 'number', 'value' => $product_sku->service_life])
                @include('partials.input', ['name' => 'certificate_number', 'title' => 'Номер сертификата', 'required' => true, 'value' => $product_sku->certificate_number])
                @include('partials.input', ['name' => 'certificate_date', 'title' => 'Дата сертификата', 'type' => 'date', 'required' => true, 'value' => $product_sku->certificate_date])
                @include('partials.input', ['name' => 'certificate_issuer', 'title' => 'Орган сертификации', 'required' => true, 'value' => $product_sku->certificate_issuer])
                @include('partials.input', ['name' => 'certificate_type', 'title' => 'Вид сертификации', 'required' => true, 'value' => $product_sku->certificate_type])
                @include('partials.input', ['name' => 'statement_number', 'title' => 'Номер ведомости', 'value' => $product_sku->statement_number])
                @include('partials.input', ['name' => 'statement_date', 'title' => 'Дата ведомости', 'type' => 'date', 'value' => $product_sku->statement_date])
                @include('partials.input', ['name' => 'upd_number', 'title' => 'Номер УПД', 'value' => $product_sku->upd_number])
            </div>
            <div class="col-xxl-6">
                @if($product_sku->passport)
                    @include('partials.input', ['name' => 'cert', 'title' => 'Паспорт', 'value' => $product_sku->passport->original_name, 'disabled' => true])
                @endif
                <div class="row mb-2">
                    <label for="comment" class="col-form-label my-1">
                        Примечание
                    </label>
                    <div>
                        <textarea name="comment" id="comment" rows="15" class="form-control @error('comment') is-invalid @enderror">{{ old('note', $product_sku->comment ?? '') }}</textarea>
                        @error('comment')
                        <span class="invalid-feedback" role="alert"><strong>{{ $message }}</strong></span>
                        @enderror
                    </div>
                </div>


                <input type="hidden" name="redirect_url" value="{{ url()->previous() }}">
            </div>
            <div class="col-12">
                @include('partials.submit', ['name' => 'Сохранить', 'offset' => 5])
            </div>
        </form>
@endsection

