@extends('layouts.app')
@section('title')编辑-客户@endsection

@section('content')
    <div id="nav2">
        @component('customer.menu')@endcomponent
        @component('customer.customer.menu')
                @if(isset($customer))@can('客户-编辑')
                <li class="nav-item">
                    <a class="nav-link" href="{{URL::current()}}" :class="{active:isActive('edit',4)}">编辑</a>
                </li> @endcan @endif
        @endcomponent
    </div>
    <div class="container-fluid card">
        <div class="card-body offset-3 mt-2">
            <form method="post" action="{{isset($customer) ? url('customer/customer').'/'.$customer->id : url('customer/customer')}}">
                @csrf
                @if(isset($customer)) @method('PUT') @endif
                <div class="row">
                    <label class="col-2 text-info" for="code">客户代码</label>
                    <input class="form-control col-6 @error("code") is-invalid @enderror" id="code" name="code"
                    value="{{old("code") ?? (isset($customer) ? $customer->code : '')}}">
                    @error("code")<span class="offset-2 mt-0 invalid-feedback">
                        <strong>{{$message}}</strong>
                    </span>@enderror
                </div>
                <div class="row mt-3">
                    <label class="col-2" for="name">客户名称</label>
                    <input class="form-control col-6 @error("name") is-invalid @enderror" id="name" name="name"
                    value="{{old("name") ?? (isset($customer) ? $customer->name : '')}}">
                    @error("name")<span class="offset-2 mt-0 invalid-feedback">
                        <strong>{{$message}}</strong>
                    </span>@enderror
                </div>
                <div class="row mt-3">
                    <label class="col-2" for="company_name">公司名称</label>
                    <input class="form-control col-6" id="company_name" name="company_name"
                    value="{{old("company_name") ?? (isset($customer) ? $customer->company_name : '')}}">
                </div>

                <div class="row mt-3">
                    <label class="col-2" for="invoice_address">发票地址</label>
                    <input class="form-control col-6" id="invoice_address" name="invoice_address"
                           value="{{old("invoice_address") ?? (isset($customer) ? $customer->invoice_address : '')}}">
                </div>

                <div class="row mt-3">
                    <label class="col-2" for="contact_man">联系人</label>
                    <input class="form-control col-6" id="contact_man" name="contact_man"
                           value="{{old("contact_man") ?? (isset($customer) ? $customer->contact_man : '')}}">
                </div>

                <div class="row mt-3">
                    <label class="col-2" for="phone">联系电话</label>
                    <input class="form-control col-6" id="phone" name="phone"
                           value="{{old("phone") ?? (isset($customer) ? $customer->phone : '')}}">
                </div>

                <div class="row mt-3">
                    <label class="col-2" for="remark">公司备注</label>
                    <input class="form-control col-6" id="remark" name="remark"
                           value="{{old("remark") ?? (isset($customer) ? $customer->remark : '')}}">
                </div>

                <div class="row mt-3 offset-1">
                    <button class="btn btn-success col-7">提交</button>
                </div>
            </form>
        </div>
    </div>
@stop

