@extends('layouts.app')
@section('content')
<main>
    <header class="alert alert-success">
        <h4 class="container">契約更新 > 定期契約を更新する</h4>
    </header>
    <section id="" class="container mt30 mb50">
        @if ($errors->has('month'))
        <div class="alert alert-danger text-center">
            {{ $errors->first('month') }}
        </div>
        @endif
        <form class="row form" action="{{ url('regular_contract/update_period') }}" method="post">
            @csrf
            <input type="hidden" name="contract_id" value="{{ $contract_id }}">
            <div class="col-12 col-md-8 offset-0 offset-md-2 mb30">
                <h3 class="alert-success">契約期間を選択してください。</h3>
                <div class="hcenter">
                    @if ($regular_type->regular_class_1 == 1)
                    <div class="text-center">
                        <input type="radio" name="month" id="m1" value="1">
                        <input type="hidden" name="price_1" value="{{ optional($prices->where('price_month', 1)->first())->price }}">
                        <label for="m1" class="radio mr20 font-weight-bold">1ヶ月</label>
                        <span class="d-block mt-0">
                            {{ optional($prices->where('price_month', 1)->first())->price ? number_format(optional($prices->where('price_month', 1)->first())->price) . '円' : '価格未設定' }}
                        </span>
                    </div>
                    @endif
                    @if ($regular_type->regular_class_2 == 1)
                    <div class="text-center">
                        <input type="radio" name="month" id="m2" value="2">
                        <input type="hidden" name="price_2" value="{{ optional($prices->where('price_month', 2)->first())->price }}">
                        <label for="m2" class="radio mr20 font-weight-bold">2ヶ月</label>
                        <span class="d-block mt-0">
                            {{ optional($prices->where('price_month', 2)->first())->price ? number_format(optional($prices->where('price_month', 2)->first())->price) . '円' : '価格未設定' }}
                        </span>
                    </div>
                    @endif
                    @if ($regular_type->regular_class_3 == 1)
                    <div class="text-center">
                        <input type="radio" name="month" id="m3" value="3">
                        <input type="hidden" name="price_3" value="{{ optional($prices->where('price_month', 3)->first())->price }}">
                        <label for="m3" class="radio mr20 font-weight-bold">3ヶ月</label>
                        <span class="d-block mt-0">
                            {{ optional($prices->where('price_month', 3)->first())->price ? number_format(optional($prices->where('price_month', 3)->first())->price) . '円' : '価格未設定' }}
                        </span>
                    </div>
                    @endif
                    @if ($regular_type->regular_class_6 == 1)
                    <div class="text-center">
                        <input type="radio" name="month" id="m6" value="6">
                        <input type="hidden" name="price_6" value="{{ optional($prices->where('price_month', 6)->first())->price }}">
                        <label for="m6" class="radio mr20 font-weight-bold">6ヶ月</label>
                        <span class="d-block mt-0">
                            {{ optional($prices->where('price_month', 6)->first())->price ? number_format(optional($prices->where('price_month', 6)->first())->price) . '円' : '価格未設定' }}
                        </span>
                    </div>
                    @endif
                    @if ($regular_type->regular_class_12 == 1)
                    <div class="text-center">
                        <input type="radio" name="month" id="m12" value="12">
                        <input type="hidden" name="price_12" value="{{ optional($prices->where('price_month', 12)->first())->price }}">
                        <label for="m12" class="radio mr20 font-weight-bold">12ヶ月</label>
                        <span class="d-block mt-0">
                            {{ optional($prices->where('price_month', 12)->first())->price ? number_format(optional($prices->where('price_month', 12)->first())->price) . '円' : '価格未設定' }}
                        </span>
                    </div>
                    @endif
                </div>
            </div>
            <div class="col-12 col-md-6 offset-0 offset-md-3">
                <input type="submit" class="btn btn-lg btn-block btn-success" value="決定" />
            </div>
            <div class="col-12 col-md-5 offset-0 offset-md-1 mt50 mb50"> <a href="{{ url('regular_contract/info') }}"
                    class="btn btn-lg btn-block btn-outline-success">契約一覧へ戻る</a> </div>
            <div class="col-12 col-md-5 mt50 mb50"> <a class="btn btn-lg btn-block btn-outline-success"
                    href="{{ url('/mypage') }}">マイページへ戻る</a> </div>
        </form>
    </section>
</main>
@endsection