@extends('layouts.app')
@section('title', '領収書の発行 | So-Manager')
@section('content')
<main>
    <header class="title-header">領収書の発行</header>
    @if($errors->has('contract_id'))
    <div class="alert alert-danger text-center">
        {{ $errors->first('contract_id') }}
    </div>
    @endif
    <form method="POST" action="{{ route('receipt.issue', ['management_code' => $management_code, 'contract_id' => $contract_id]) }}" id="issueForm">
        @csrf
        <div class="col-12 col-md-5 offset-0 offset-md-1 mt10 mb50">
            <p class="text-left font-weight-bold">領収書内容の入力</p>
            <p class="text-left">領収書の宛名を入力してください。</p>
            <input type="text" class="form-control" id="receipt_name" name="receipt_name" value="{{ old('receipt_name') }}" required style="color: black;">
            <div class="mt-2">
                <div class="form-check">
                    <input class="form-check-input" type="radio" name="keisho" id="keisho_sama" value="様" {{ old('keisho') == '様' ? 'checked' : '' }}>
                    <label class="form-check-label" for="keisho_sama">様</label>
                </div>
                <div class="form-check">
                    <input class="form-check-input" type="radio" name="keisho" id="keisho_onchu" value="御中" {{ old('keisho') == '御中' ? 'checked' : '' }}>
                    <label class="form-check-label" for="keisho_onchu">御中</label>
                </div>
            </div>
            <div class="col-6 offset-3 text-left">
                <button type="submit" class="green-btn long-btn" id="submitBtn">発行する</button>
            </div>
        </div>
    </form>
</main>
<script>
    window.onload = function() {
        document.getElementById('submitBtn').disabled = false;
    };

    document.getElementById('issueForm').addEventListener('submit', function() {
        document.getElementById('submitBtn').disabled = true;
    });
</script>
@endsection