@extends('layouts.app')
@section('title', '[東京都|〇〇駐輪場]  駐輪場マスタ')
@section('content')
    <div class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-lg-6">
                    <h1 class="m-0 text-dark">{{__('駐輪場マスタ')}}</h1>
                </div><!-- /.col -->
                <div class="col-lg-6">
                    <ol class="breadcrumb float-sm-right text-sm">
                        <li class="breadcrumb-item"><a href="{{route('home')}}">XX様info(ホーム)</a></li>
                        <li class="breadcrumb-item"><a href="javascript: void(0);">[東京都|〇〇駐輪場]</a></li>
                        <li class="breadcrumb-item active">{{__('駐輪場マスタ')}}</li>
                    </ol>
                </div><!-- /.col -->
            </div><!-- /.row -->
        </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->

    <!-- Main content -->
    <section class="content">
        <div class="container-fluid">
            <!-- SELECT2 EXAMPLE -->
            <div class="row">
                <form action="{{route('parks')}}" method='post' id='list-form'>
                    <input type="hidden" name="_token" value="{{ csrf_token() }}">
                    <input type="hidden" value="{{$sort}}" name="sort" id="sort">
                    <input type="hidden" value="{{$sort_type}}" name="sort_type" id="sort_type">
                </form>


                <div class="container-fluid mb20">
                    <button type="submit" class="btn btn-sm btn-default mr10" name="delete"
                            id="delete">{{__('削除')}}</button>
                    <button type="submit" class="btn btn-sm btn-default mr10" name="import_csv" id="import_csv" action="{{route('parks_import')}}">{{__('インポート')}}</button>
                    <button type="submit" class="btn btn-sm btn-default mr10" name="export_csv" id="export_csv" action="{{route('parks_export')}}">{{__('CSV出力')}}</button>
                    {{ $list->links('pagination') }}
                </div>
                <div class="form col-lg-12">
                    @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>
                    @elseif(isset($errorMsg))
                        <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>
                            {!! $errorMsg !!}
                        </div>
                    @endif
                </div>
                <div class="col-lg-12 row sample03-wrapper no_padding_right mb20">
                    <div class="col-xl-2 col-lg-2 col-md-2 col-sm-3 col-xs-3 table_left">
                        <form action="{{route('parks_delete')}}" method="post" id="form_delete">
                            <input type="hidden" name="_token" value="{{ csrf_token() }}">
                            <table class="table dataTable">
                                <thead>
                                <tr>
                                    <th>
                                        <input type="checkbox" class="minimal m-0" id="checkbox_all">
                                    </th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($list as $item)
                                    <tr role="row">
                                        <td>
                                            <input type="checkbox" class="minimal m-0 checkbox"
                                                   value="{{$item->park_id}}" name="pk[]">
                                            <div class="btn_action">
                                                {{--<a href="{{route('park_add')}}" class="btn btn-sm btn-default">詳細</a>--}}
                                                <a href="{{route('park_info',['pk'=>$item->park_id])}}"
                                                   class="btn btn-sm btn-default ml10">{{__('編集')}}</a>
                                            </div>
                                        </td>

                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                        </form>
                    </div>
                    <div class="col-lg-10 col-xl-10 col-md-10 col-sm-9 col-xs-9 table_right no_padding_right">
                        <div class="scroll">
                            <table class="table dataTable">
                                <thead>
                                <tr>
                                    <!-- 駐輪場ID　 -->
                                    <th class="sorting @if($sort=="park_id"){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif"
                                        sort="park_id"><span>{{__('validation.attributes.park_id')}}</span>
                                    </th>
                                    <!-- 市区 -->
                                    <th class="sorting @if($sort=="city_id"){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif"
                                        sort="city_id"><span>{{__('validation.attributes.city_id')}}</span>
                                    </th>
                                    <!-- 駐輪場名 -->
                                    <th class="sorting @if($sort=="park_name"){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif"
                                        sort="park_name"><span>{{__('validation.attributes.park_name')}}</span>
                                    </th>
                                    <!-- 駐輪場ふりがな -->
                                    <th class="sorting @if($sort=="park_ruby"){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif"
                                        sort="park_ruby"><span>{{__('validation.attributes.park_ruby')}}</span>
                                    </th>
                                    <!-- 駐輪場五十音 -->
                                    <th class="sorting @if($sort=="park_syllabary"){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif"
                                        sort="park_syllabary">
                                        <span>{{__('validation.attributes.park_syllabary')}}</span>
                                    </th>
                                    <!-- 住所 -->
                                    <th><span>{{__('validation.attributes.park_adrs')}}</span>
                                    </th>
                                    <!-- 閉設フラグ -->
                                    <th>
                                        <span>{{__('validation.attributes.park_close_flag')}}</span>
                                    </th>
                                    <!-- 閉設日 -->
                                    <th><span>{{__('validation.attributes.park_day')}}</span>
                                    </th>
                                    <th><span>{{__('validation.attributes.alert_flag')}}</span>
                                    </th>
                                    <!-- 印字数 -->
                                    <th><span>{{__('validation.attributes.print_number')}}</span>
                                    </th>
                                    <!-- 最新キープアライブ -->
                                    <th><span>{{__('validation.attributes.keep_alive')}}</span>
                                    </th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($list as $item)
                                    <tr>
                                        <!-- 駐輪場ID　 -->
                                        <td class='sm-item text-left'><span>{{mb_substr($item->park_id, 0, 20)}}</span>
                                        </td>
                                        <!--  市区 -->
                                        <td class='sm-item text-right'>
                                            <span>{{mb_substr(!empty($item->getCity())? $item->getCity()->city_name:"", 0, 20)}}</span>
                                        </td>
                                        <!-- 駐輪場名 -->
                                        <td class='sm-item text-right'>
                                            <span>{{mb_substr($item->park_name, 0, 20)}}</span></td>
                                        <!-- 駐輪場ふりがな -->
                                        <td class='sm-item text-right'>
                                            <span>{{mb_substr($item->park_ruby, 0, 20)}}</span></td>
                                        <!-- 駐輪場五十音 -->
                                        <td class='sm-item text-left'>
                                            <span>{{mb_substr($item->park_syllabary, 0, 1)}}</span></td>
                                        <!-- 住所 -->
                                        <td class='sm-item text-right'>
                                            <span>{{mb_substr($item->park_adrs, 0, 60)}}</span></td>
                                        <!-- 閉設フラグ -->
                                        <td class='sm-item text-right'><span>{{$item->getParkCloseFlagDisplay()}}</span>
                                        </td>
                                        <!-- 閉設日 -->
                                        <td class='sm-item text-right'>
                                            <span>{{mb_substr($item->park_day, 0, 10)}}</span></td>
                                        <!-- 残警告チェックフラグ -->
                                        <td class='sm-item text-left'>
                                            <span>{{mb_substr($item->alert_flag, 0, 6)}}</span></td>
                                        <!-- 印字数 -->
                                        <td class='sm-item text-left'>
                                            <span>{{mb_substr($item->print_number, 0, 6)}}</span></td>
                                        <!-- 最新キープアライブ -->
                                        <td class='sm-item text-left'>
                                            <span>{{mb_substr($item->keep_alive, 0, 6)}}</span></td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <!-- /.row -->
            </div><!-- /.container-fluid -->
        </div>
    </section>
    <!-- /.content -->

@endsection