@extends('layouts.app')
@section('title')编辑-仓库@endsection

@section('content')
    <div id="nav2">
        @component('maintenance.menu')
        @endcomponent
        @component('maintenance.warehouse.menu')
                <li class="nav-item">
                    <a class="nav-link" href="{{URL::current()}}" :class="{active:isActive('edit',4)}">修改</a>
                </li>
        @endcomponent
    </div>
    <div class="container-fluid">
        <div class="card">
            <div class="card-body">
                @if(Session::has('successTip'))
                    <div class="alert alert-success h1">{{Session::get('successTip')}}！</div>
                @endif
                <form method="POST" action='{{url("maintenance/warehouse/{$warehouse->id}")}}'>
                    @csrf
                    @method('PUT')
                    <div class="form-group row">
                        <label for="name" class="col-2 col-form-label text-right">仓库名称</label>
                        <div class="col-8">
                            <input type="text" class="form-control @error('name') is-invalid @enderror"
                                   name="name" autocomplete="off" value="@if(old('name')){{old('name')}}@else{{$warehouse->name}}@endif" required>
                            @error('name')
                            <span class="invalid-feedback" role="alert">
                                <strong>{{ $message }}</strong>
                            </span>
                            @enderror
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="code" class="col-2 col-form-label text-right">仓库代码</label>
                        <div class="col-8">
                            <input type="text" class="form-control @error('code') is-invalid @enderror"
                                   name="code" autocomplete="off" value="@if(old('code')){{old('code')}}@else{{$warehouse->code}}@endif" required>
                            @error('code')
                            <span class="invalid-feedback" role="alert">
                                <strong>{{ $message }}</strong>
                            </span>
                            @enderror
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="production_capacity" class="col-2 col-form-label text-right">产能</label>
                        <div class="col-8">
                            <input id="production_capacity" type="number" step="0.01" min="0" class="form-control @error('production_capacity') is-invalid @enderror"
                                   name="production_capacity" autocomplete="off" value="{{ old('production_capacity') ?? $warehouse->production_capacity }}" required>
                            <span class="text-muted">每立方需要1产能，每吨需要3产能</span>
                            @error('production_capacity')
                            <span class="invalid-feedback" role="alert">
                                <strong>{{ $message }}</strong>
                            </span>
                            @enderror
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="reduced_production_capacity_coefficient" class="col-2 col-form-label text-right">SKU减产系数</label>
                        <div class="col-8 input-group">
                            <input id="reduced_production_capacity_coefficient" type="number" class="form-control @error('reduced_production_capacity_coefficient') is-invalid @enderror"
                                   step="1" min="0" max="100" autocomplete="off"
                                   name="reduced_production_capacity_coefficient"  value="{{ old('reduced_production_capacity_coefficient') ?? $warehouse->reduced_production_capacity_coefficient }}" required>
                            <span class="d-block input-group-append">
                                <span class="input-group-text font-weight-bold">%</span>
                            </span>
                            @error('reduced_production_capacity_coefficient')
                            <span class="invalid-feedback" role="alert">
                                <strong>{{ $message }}</strong>
                            </span>
                            @enderror
                            <div class="text-muted">当SKU的数量多到可以影响产能时，每个SKU增加百分之几的产能需求（如填5，那每个原来1产能完成的，需要105%完成）</div>
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="principal" class="col-2 col-form-label text-right">联系人</label>
                        <div class="col-8">
                            <input id="principal" type="text" class="form-control @error('principal') is-invalid @enderror"
                                   name="principal" autocomplete="off" value="{{ old('principal') ?? $warehouse->principal }}">
                            @error('principal')
                            <span class="invalid-feedback" role="alert">
                                <strong>{{ $message }}</strong>
                            </span>
                            @enderror
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="phone" class="col-2 col-form-label text-right">联系电话</label>
                        <div class="col-8">
                            <input id="phone" type="text" class="form-control @error('phone') is-invalid @enderror"
                                   name="phone" autocomplete="off" value="{{ old('phone') ?? $warehouse->phone }}">
                            @error('phone')
                            <span class="invalid-feedback" role="alert">
                                <strong>{{ $message }}</strong>
                            </span>
                            @enderror
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="address" class="col-2 col-form-label text-right">地址</label>
                        <div class="col-8">
                            <input id="address" type="text" class="form-control @error('address') is-invalid @enderror"
                                   name="address" autocomplete="off" value="{{ old('address') ?? $warehouse->address }}">
                            @error('address')
                            <span class="invalid-feedback" role="alert">
                                <strong>{{ $message }}</strong>
                            </span>
                            @enderror
                        </div>
                    </div>
                    <div class="form-group row">
                        <div class="col-8 offset-2">
                            <input type="submit" class="btn btn-outline-dark form-control">
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
@endsection
