@extends('layouts.app')

@section('content')
    <div class="px-3">
        <div class="col-xxl-6 offset-xxl-2">
            <form action="{{ ($contract) ? route('contract.update', $contract) : route('contract.store') }}" method="post">

                @csrf
                @include('partials.input', ['name' => 'year',
                                            'type' => 'number',
                                            'title' => 'Год',
                                            'required' => true,
                                            'value' => $contract->year ?? date('Y'),
                                            ])
                @include('partials.input', ['name' => 'contract_number', 'title' => 'Номер договора', 'required' => true, 'value' => $contract->contract_number ?? ''])
                @include('partials.input', ['name' => 'contract_date', 'type' => 'date','title' => 'Дата договора', 'value' => $contract->contract_date ?? date('Y-m-d'), 'required' => true])

                @include('partials.submit', ['deleteDisabled' => (!isset($contract)), 'delete' => ['form_id' => 'deleteContract']])
            </form>
            @if($contract)
                <div class="visually-hidden">
                    <form action="{{ route('contract.delete', $contract) }}" method="POST" id="deleteContract">
                        @csrf
                        @method('DELETE')
                    </form>
                </div>
            @endif
        </div>
    </div>
@endsection
