@if(Session::has('success'))
    <div class="alert alert-success alert-dismissible" role="alert">
        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
        {{ Session::get('success') }}
    </div>
@elseif(Session::has('error'))
    <div class="alert alert-danger alert-dismissible">
        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
        <h4><i class="icon fa fa-ban"></i> エラー:</h4>
        {!! Session::get('error') !!}
    </div>
@endif


<div class="card-body">
    <div class="row">
        {{-- 編集・詳細時のみテンプレートID表示 --}}
        @if($isEdit || $isInfo)
            <div class="form-group col-3">
                <label>テンプレートID</label>
            </div>
            <div class="form-group col-9">
                <input type="text" value="{{ $mailTemplate->mail_template_id ?? '' }}" class="form-control form-control-lg" readonly />
            </div>
        @endif

        <!-- 使用プログラムID -->
        <div class="form-group col-3">
            <label class="required">使用プログラムID</label>
        </div>
        <div class="form-group col-9">
            <input type="number" name="pg_id" value="{{ old('pg_id', $mailTemplate->pg_id ?? '') }}"
                   class="form-control form-control-lg" @if($isInfo) readonly @endif required />
        </div>

        <!-- 内部ID -->
        <div class="form-group col-3">
            <label>内部ID</label>
        </div>
        <div class="form-group col-9">
            <input type="number" name="internal_id" value="{{ old('internal_id', $mailTemplate->internal_id ?? '') }}"
                   class="form-control form-control-lg" @if($isInfo) readonly @endif />
        </div>

        <!-- エリアマネージャー同報 -->
        <div class="form-group col-3">
            <label>エリアマネージャー同報</label>
        </div>
        <div class="form-group col-9 mt-2">
            <div class="form-check form-check-inline">
                <input class="form-check-input" type="radio" name="mgr_cc_flag" value="1"
                       @if(old('mgr_cc_flag', $mailTemplate->mgr_cc_flag ?? '') == 1) checked @endif
                       @if($isInfo) disabled @endif>
                <label class="form-check-label">同報する</label>
            </div>
            <div class="form-check form-check-inline">
                <input class="form-check-input" type="radio" name="mgr_cc_flag" value="0"
                       @if(old('mgr_cc_flag', $mailTemplate->mgr_cc_flag ?? '') == 0) checked @endif
                       @if($isInfo) disabled @endif>
                <label class="form-check-label">同報しない</label>
            </div>
        </div>

        <!-- BCCアドレス -->
        <div class="form-group col-3">
            <label>BCCアドレス</label>
        </div>
        <div class="form-group col-9">
            <input type="text" name="bcc_adrs" value="{{ old('bcc_adrs', $mailTemplate->bcc_adrs ?? '') }}"
                   class="form-control form-control-lg" @if($isInfo) readonly @endif />
        </div>

        <!-- 使用フラグ -->
        <div class="form-group col-3">
            <label>使用フラグ</label>
        </div>
        <div class="form-group col-9 mt-2">
            <div class="form-check form-check-inline">
                <input class="form-check-input" type="radio" name="use_flag" value="1"
                       @if(old('use_flag', $mailTemplate->use_flag ?? '') == 1) checked @endif
                       @if($isInfo) disabled @endif>
                <label class="form-check-label">使用する</label>
            </div>
            <div class="form-check form-check-inline">
                <input class="form-check-input" type="radio" name="use_flag" value="0"
                       @if(old('use_flag', $mailTemplate->use_flag ?? '') == 0) checked @endif
                       @if($isInfo) disabled @endif>
                <label class="form-check-label">使用しない</label>
            </div>
        </div>

        <!-- メモ -->
        <div class="form-group col-3">
            <label>メモ</label>
        </div>
        <div class="form-group col-9">
            <input type="text" name="memo" value="{{ old('memo', $mailTemplate->memo ?? '') }}"
                   class="form-control form-control-lg" @if($isInfo) readonly @endif />
        </div>

        <!-- 件名 -->
        <div class="form-group col-3">
            <label class="required">件名</label>
        </div>
        <div class="form-group col-9">
            <input type="text" name="subject" value="{{ old('subject', $mailTemplate->subject ?? '') }}"
                   class="form-control form-control-lg" @if($isInfo) readonly @endif required />
        </div>

        <!-- 本文 -->
        <div class="form-group col-3">
            <label class="required">本文</label>
        </div>
        <div class="form-group col-9">
            <textarea name="text" class="form-control form-control-lg" rows="8"
                      @if($isInfo) readonly @endif required>{{ old('text', $mailTemplate->text ?? '') }}</textarea>
        </div>

        <!-- オペレータID -->
        <div class="form-group col-3">
            <label>オペレータID</label>
        </div>
        <div class="form-group col-9">
            <input type="number" name="operator_id" value="{{ old('operator_id', $mailTemplate->operator_id ?? '') }}"
                   class="form-control form-control-lg" @if($isInfo) readonly @endif />
        </div>
    </div>

    {{-- ===== 下部ボタン領域 ===== --}}

        {{-- 下部ボタン --}}
        @if($isEdit)
            <button type="submit" class="btn btn-lg btn-success register">{{ __('保存') }}</button>
            <button type="submit" class="btn btn-lg btn-secondary register">{{ __('戻る') }}</button>
        @else
            <button type="submit" class="btn btn-lg btn-success register">{{ __('登録') }}</button>
            <button type="submit" class="btn btn-lg btn-danger register">{{ __('削除') }}</button>
        @endif

</div>
