@php

$disp = [
    ['code' => 0, 'name' => '表示'],
    ['code' => 1, 'name' => '非表示'],
];

$list = [
    ['code' => 1, 'name' => '一覧用'],
];


$image_kind = [
    ['code' => 1, 'name' => 'BEFORE'],
    ['code' => 2, 'name' => 'AFTER'],
];


@endphp
@extends('admin.layouts.base')

@section('contents')
<div class="mt5">
    @include('admin.objects.components.hp-tab', ['title' => 'HP管理ーリフォーム情報', 'type' => 'reform'])
@if($reform->disp == 1)
    @php $url = ""; if($reform->id != null && $reform->id != ""){ $url = '/reform/works/'.$reform->code.'.html'; } @endphp
    @include('admin.objects.components.regist-band', ['title' => 'リフォーム情報一覧', 'conf_url' => $url])
@else
    @include('admin.objects.components.regist-band', ['title' => 'リフォーム情報一覧'])
@endif
    <div class="news_regist">
        @if($errors->any())
        <div class="error">
        <ul>
            @foreach($errors->all() as $message)
            <li>{{ $message }}</li>
            @endforeach
        </ul>
        </div>
        @endif
        <form method="POST" action="{{ route('reform-edit', ['id' => $reform->code]) }}" enctype="multipart/form-data">
        {{ csrf_field() }}
            <div>
                <table>
                    <tr>
                        <th class="w200">リフォーム番号</th>
                        <td>
                            {{$reform->code}}
                        </td>
                    </tr>
                    <tr>
                        <th>登録日</th>
                        <td>
                            <div class="d-flex">
                                @include('admin.objects.components.input', ['name' => 'regist_date', 'class' => 'w250 cal_picker', 'value' => $reform->regist_date, 'showBtnToday' => true])
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th>カテゴリ</th>
                        <td>
                        @include('admin.objects.components.radio', ['name' => 'category', 'radio' => $category, 'default' => 1, 'checked' => $reform->category])
                        </td>
                    </tr>
                    <tr>
                        <th>タイトル</th>
                        <td>
                        @include('admin.objects.components.textarea_reform', ['name' => 'title', 'class' => 'ta500', 'count' => 50, 'placeholder' => '５０文字以内で入力してください', 'value' => $reform->title])
                        </td>
                    </tr>
                    <tr>
                        <th>エリア</th>
                        <td>
                        @include('admin.objects.components.input', ['name' => 'area', 'class' => 'w500', 'value' => $reform->area])
                        </td>
                    </tr>
                    <tr>
                        <th>築年</th>
                        <td>
                            @include('admin.objects.components.selectbox', ['name' => 'from_year', 'options' => Config::get('const.OLD_YEAR'), 'selected' => $reform->from_year])年
                            @include('admin.objects.components.selectbox', ['name' => 'from_month', 'options' => Config::get('const.MONTH'), 'selected' => $reform->from_month])月
                        </td>
                    </tr>
                    <tr>
                        <th>リフォーム費用</th>
                        <td>
                        @include('admin.objects.components.input', ['name' => 'cost', 'class' => 'w250', 'value' => $reform->cost])万円
                        </td>
                    </tr>
                    <tr>
                        <th>施工箇所</th>
                        <td>
                        @include('admin.objects.components.textarea_reform', ['name' => 'target', 'class' => 'ta500', 'count' => 50, 'placeholder' => '５０文字以内で入力してください', 'value' => $reform->target])
                        </td>
                    </tr>
                    <tr>
                        <th>プランの特徴</th>
                        <td>
                        @include('admin.objects.components.textarea_reform', ['name' => 'plan', 'class' => 'ta500', 'count' => 500, 'placeholder' => '５００文字以内で入力してください', 'value' => $reform->plan])
                        </td>
                    </tr>
                    <tr>
                        <th>施工のポイント</th>
                        <td>
                        @include('admin.objects.components.textarea_reform', ['name' => 'point', 'class' => 'ta500', 'count' => 500, 'placeholder' => '５００文字以内で入力してください', 'value' => $reform->point])
                        </td>
                    </tr>
                </table>
            </div>
            <div class="search_vendor__btn">
                @include('admin.objects.components.regist-btn', ['class' => '', 'title' => '登録・保存'])
            </div>
            <table class="p-regist__table mt10">
                <tbody>
                @include('admin.objects.projects.image-upload-large-reform', ['id' => 'iamgeAreaMulti', 'cid' => 'iamgeAreaMultiChild'])
                <tr>
                    <td colspan="8">
                        <table id="sortable_reform_image">
                            <tbody id="image_list">
                        @include('admin.objects.components.add-reform-template')
                        @foreach($photos as $photo)
                            @include('admin.objects.components.add-reform-template-edit', ['num' => $loop->iteration+1])
                        @endforeach
                            </tbody>
                        </table>
                    </td>
                </tr>
                </tbody>
            </table>
            <div class="regist__div">
                @include('admin.objects.components.regist-btn', ['class' => '', 'title' => '登録・保存'])
            </div>

            <table class="p-regist__table mt10">
                <tbody>
                    <tr>
                        <th rowspan="2" class="w200i">間取り</th>
                        <td>
                            <div class="d-flex">
                                <div>
                                    @include('admin.objects.components.add-reform-before', ['id' => 'imageArea2'])
                                </div>
                                <div class="ml10">
                                    <span>BEFORE図面</span>
                                </div>
                            </div>
                        </td>
                        <td class="w200i">
                        @include('admin.objects.components.hidden', ['name' => 'del_before_flag'])
                        @include('admin.objects.components.btn', ['name' => 'del_before_img', 'class' => '', 'title' => '削除', 'type' => 'button'])
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="d-flex">
                                <div>
                                    @include('admin.objects.components.add-reform-after', ['id' => 'imageArea3'])
                                </div>
                                <div class="ml10">
                                    <span>AFTER図面</span>
                                </div>
                            </div>
                        </td>
                        <td class="w200i">
                        @include('admin.objects.components.hidden', ['name' => 'del_after_flag'])
                        @include('admin.objects.components.btn', ['name' => 'del_after_img', 'class' => '', 'title' => '削除', 'type' => 'button'])
                        </td>
                    </tr>
                </tbody>
            </table>
            <div class="regist__div">
                @include('admin.objects.components.regist-btn', ['class' => '', 'title' => '登録・保存'])
            </div>
        </form>
            @if (session('message_modal'))
                <input type="hidden" name="" id="message" value="{{ session('message_modal') }}">
                @include('admin.objects.projects.modal-message', ['ok' => "OK"])
                <script type="text/javascript">
                    window.onload = function(){
                        var message = $("#message").val();
                        $('#saved_message').text(message);
                        openMessageModal();
                        $(".btn-close-modal").click(function () {
                            $("#modal-overlay").remove();
                            $("#modal-message-content").remove();
                        });
                    };
                </script>
            @endif
    </div>
</div>
@if (session('message'))
    @include('admin.objects.projects.modal-message')
    <script type="text/javascript">
        window.onload = function(){
            var message = '登録・保存しました';
            $('#saved_message').text(message);
            openMessageModal();
        };
    </script>
@endif
@endsection
