@extends('layouts.app')
@section('title', 'インボイス設定')

@section('content')
<div class="content-header">
  <div class="container-fluid">
    <div class="row mb-2">
      <div class="col-lg-6"><h1 class="m-0 text-dark">インボイス設定</h1></div>
    </div>
  </div>
</div>

<section class="content">
  <div class="container-fluid">
    @if(session('success'))
      <div class="alert alert-success">{{ session('success') }}</div>
    @endif

    @if ($errors->any())
      <div class="alert alert-danger">
        <ul>
          @foreach ($errors->all() as $e)<li>{{ $e }}</li>@endforeach
        </ul>
      </div>
    @endif

    <form method="post" action="{{ route('inv_settings_save') }}" enctype="multipart/form-data">
    @csrf

      {{-- 適格請求書発行事業者番号 --}}
      <div class="form-group row">
          <label class="col-sm-3 col-form-label">適格請求書発行事業者番号<span class="text-danger">*</span></label>
          <div class="form-group col-4">
              <input type="text" name="t_number" class="form-control"
                  value="{{ old('t_number', $row->t_number ?? '') }}">
          </div>
      </div>

      {{-- 適格事業者名 --}}
      <div class="form-group row">
          <label class="col-sm-3 col-form-label">適格事業者名<span class="text-danger">*</span></label>
          <div class="form-group col-4">
              <input type="text" name="t_name" class="form-control"
                  value="{{ old('t_name', $row->t_name ?? '') }}">
          </div>
      </div>

      {{-- 郵便番号 --}}
      <div class="form-group row">
          <label class="col-sm-3 col-form-label">郵便番号</label>
          <div class="col-sm-9 d-flex">
              <input type="text" name="zip1" class="form-control" style="max-width:120px;"
                  value="{{ old('zip1', $zip1) }}">
              <span class="mx-2">-</span>
              <input type="text" name="zip2" class="form-control" style="max-width:140px;"
                  value="{{ old('zip2', $zip2) }}">
          </div>
      </div>

      {{-- 表示住所 --}}
      <div class="form-group row">
          <label class="col-sm-3 col-form-label">表示住所<span class="text-danger">*</span></label>
          <div class="form-group col-4">
              <input type="text" name="adrs" class="form-control"
                  value="{{ old('adrs', $row->adrs ?? '') }}">
          </div>
      </div>

      {{-- 建物名 --}}
      <div class="form-group row">
          <label class="col-sm-3 col-form-label">建物名</label>
          <div class="form-group col-4">
              <input type="text" name="bldg" class="form-control"
                  value="{{ old('bldg', $row->bldg ?? '') }}">
          </div>
      </div>

      {{-- 表示電話番号 --}}
      <div class="form-group row">
          <label class="col-sm-3 col-form-label">表示電話番号</label>
          <div class="col-sm-9 d-flex">
              <input name="tel1" class="form-control" style="max-width:100px;" value="{{ old('tel1', $tel1) }}">
              <span class="mx-2">-</span>
              <input name="tel2" class="form-control" style="max-width:100px;" value="{{ old('tel2', $tel2) }}">
              <span class="mx-2">-</span>
              <input name="tel3" class="form-control" style="max-width:100px;" value="{{ old('tel3', $tel3) }}">
          </div>
      </div>

      {{-- 表示FAX番号 --}}
      <div class="form-group row">
          <label class="col-sm-3 col-form-label">表示FAX番号</label>
          <div class="col-sm-9 d-flex">
              <input name="fax1" class="form-control" style="max-width:100px;" value="{{ old('fax1', $fax1) }}">
              <span class="mx-2">-</span>
              <input name="fax2" class="form-control" style="max-width:100px;" value="{{ old('fax2', $fax2) }}">
              <span class="mx-2">-</span>
              <input name="fax3" class="form-control" style="max-width:100px;" value="{{ old('fax3', $fax3) }}">
          </div>
      </div>

      {{-- 社判画像 --}}
      <div class="form-group row">
          <label class="col-sm-3 col-form-label">社判画像</label>
          <div class="col-sm-9">
              <input type="file" name="company_image" class="form-control-file">
              @if(!empty($row->company_image_path))
                  <div class="mt-2">
                      <a href="{{ asset('storage/'.$row->company_image_path) }}" target="_blank">現在の画像を表示</a>
                  </div>
              @endif
          </div>
      </div>

      {{-- 登録ボタン --}}
      <div class="form-group row">
          <div class="col-sm-3">
              <button type="submit" class="btn btn-success px-3">登録</button>
          </div>
      </div>
  </form>
  </div>
</section>
@endsection
