@extends('layouts.app')

@section('content')
    <h3 class="page-title">@lang('quickadmin.residential-complex.title')</h3>

    <div class="panel panel-default">
        <div class="panel-heading">
            @lang('quickadmin.qa_view')
        </div>

        <div class="panel-body table-responsive">
            <div class="row">
                <div class="col-md-6">
                    <table class="table table-bordered table-striped">
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.name')</th>
                            <td field-key='name'>{{ $residential_complex->name }}</td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.code')</th>
                            <td field-key='code'>{{ $residential_complex->code }}</td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.enabled')</th>
                            <td field-key='enabled'>{{ Form::checkbox("enabled", 1, $residential_complex->enabled == 1 ? true : false, ["disabled"]) }}</td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.developer')</th>
                            <td field-key='developer'>{{ $residential_complex->developer->name ?? '' }}</td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.is-repair')</th>
                            <td field-key='is_repair'>{{ Form::checkbox("is_repair", 1, $residential_complex->is_repair == 1 ? true : false, ["disabled"]) }}</td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.is-credit')</th>
                            <td field-key='is_credit'>{{ Form::checkbox("is_credit", 1, $residential_complex->is_credit == 1 ? true : false, ["disabled"]) }}</td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.is-transport-hub')</th>
                            <td field-key='is_transport_hub'>{{ Form::checkbox("is_transport_hub", 1, $residential_complex->is_transport_hub == 1 ? true : false, ["disabled"]) }}</td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.site-link')</th>
                            <td field-key='site_link'>{{ $residential_complex->site_link }}</td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.phone')</th>
                            <td field-key='site_link'>{{ $residential_complex->phone }}</td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.meta-title')</th>
                            <td field-key='meta_title'>{{ $residential_complex->residential_complex_seos->first() ? $residential_complex->residential_complex_seos->first()->meta_title : "" }}</td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.meta-keywords')</th>
                            <td field-key='meta_keywords'>{{ $residential_complex->residential_complex_seos->first() ? $residential_complex->residential_complex_seos->first()->meta_keywords : "" }}</td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.meta-description')</th>
                            <td field-key='meta_description'>{{$residential_complex->residential_complex_seos->first() ? $residential_complex->residential_complex_seos->first()->meta_description : ""}}</td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.seo-text')</th>
                            <td field-key='seo_text'>{{$residential_complex->residential_complex_seos->first() ? $residential_complex->residential_complex_seos->first()->seo_text : "" }}</td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.main-page-priority')</th>
                            <td field-key='main_page_priority'>{{ $residential_complex->main_page_priority }}</td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.res-com-page-priority')</th>
                            <td field-key='res_com_page_priority'>{{ $residential_complex->res_com_page_priority }}</td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.min-price')</th>
                            <td field-key='min_price'>{{ $residential_complex->min_price }}</td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.date-putting-into-operation')</th>
                            <td field-key='date_putting_into_operation'>{{ $residential_complex->date_putting_into_operation }}</td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.date-putting-into-operation')</th>
                            <td field-key='date_putting_into_operation'>{{ $residential_complex->quarterly_putting_into_operation->name ?? '' }}</td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.building-count')</th>
                            <td field-key='building_count'>{{ $residential_complex->building_count }}</td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.room-count')</th>
                            <td field-key='room_count'>{{ $residential_complex->room_count }}</td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.room-count-date')</th>
                            <td field-key='room_count_date'>{{ $residential_complex->room_count_date }}</td>
                        </tr>
                        {{--<tr>--}}
                            {{--<th>@lang('quickadmin.residential-complex.fields.count-of-room-per-flat')</th>--}}
                            {{--<td field-key='count_of_room_per_flat'>--}}
                                {{--@foreach ($residential_complex->count_of_room_per_flat as $singleCountOfRoomPerFlat)--}}
                                    {{--<span class="label label-info label-many">{{ $singleCountOfRoomPerFlat->count }}</span>--}}
                                {{--@endforeach--}}
                            {{--</td>--}}
                        {{--</tr>--}}
                        {{--<tr>--}}
                            {{--<th>@lang('quickadmin.residential-complex.fields.room-type')</th>--}}
                            {{--<td field-key='room_type'>--}}
                                {{--@foreach ($residential_complex->room_type as $singleRoomType)--}}
                                    {{--<span class="label label-info label-many">{{ $singleRoomType->name }}</span>--}}
                                {{--@endforeach--}}
                            {{--</td>--}}
                        {{--</tr>--}}
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.city')</th>
                            <td field-key='city'>{{ $residential_complex->city->name ?? '' }}</td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.district')</th>
                            <td field-key='district'>{{ $residential_complex->district->name ?? '' }}</td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.street-name')</th>
                            <td field-key='street_name'>{{ $residential_complex->street_name->name ?? '' }}</td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.street-number')</th>
                            <td field-key='street_number'>{{ $residential_complex->street_number }}</td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.class')</th>
                            <td field-key='class'>
                                @foreach ($residential_complex->class as $singleClass)
                                    <span class="label label-info label-many">{{ $singleClass->name }}</span>
                                @endforeach
                            </td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.stage-of-construction')</th>
                            <td field-key='stage_of_construction'>
                                {{$residential_complex->stageOfConstruction->name}}
                            </td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.heating')</th>
                            <td field-key='heating'>
                                @foreach ($residential_complex->heating as $singleHeating)
                                    <span class="label label-info label-many">{{ $singleHeating->name }}</span>
                                @endforeach
                            </td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.technology-building')</th>
                            <td field-key='technology_building'>
                                @foreach ($residential_complex->technology_building as $singleTechnologyBuilding)
                                    <span class="label label-info label-many">{{ $singleTechnologyBuilding->name }}</span>
                                @endforeach
                            </td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.other-option')</th>
                            <td field-key='other_option'>
                                @foreach ($residential_complex->other_option as $singleOtherOption)
                                    <span class="label label-info label-many">{{ $singleOtherOption->name }}</span>
                                @endforeach
                            </td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.photo')</th>
                            <td field-key='photo'> @foreach($residential_complex->getMedia('photo') as $media)
                                    <p class="form-group">
                                        <a href="{{ $media->getUrl() }}" target="_blank">{{ $media->name }}
                                            ({{ $media->size }} bytes)</a>
                                    </p>
                                @endforeach</td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.landscape-photo')</th>
                            <td field-key='landscape_photo'> @foreach($residential_complex->getMedia('landscape_photo') as $media)
                                    <p class="form-group">
                                        <a href="{{ $media->getUrl() }}" target="_blank">{{ $media->name }} ({{ $media->size }} bytes)</a>
                                    </p>
                                @endforeach</td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.icon')</th>
                            <td field-key='icon'>
                                @foreach ($residential_complex->icon as $singleIcon)
                                    <span class="label label-info label-many">{{ $singleIcon->name }}</span>
                                @endforeach
                            </td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.recomended-residental-complex-id')</th>
                            <td field-key='recomended_residental_complex_id'>
                                @foreach ($residential_complex->recomended_residental_complex_id as $singleRecomendedResidentalComplexId)
                                    <span class="label label-info label-many">{{ $singleRecomendedResidentalComplexId->name }}</span>
                                @endforeach
                            </td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.bank')</th>
                            <td field-key='bank'>
                                @foreach ($residential_complex->bank as $singleBank)
                                    <span class="label label-info label-many">{{ $singleBank->name }}</span>
                                @endforeach
                            </td>
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.location')</th>
                            <td>
                                <strong>{{ $residential_complex->location_address }}</strong>
                                <div id='location-map' style='width: 600px;height: 300px;' class='map'
                                     data-key='location' data-latitude='{{$residential_complex->location_latitude}}'
                                     data-longitude='{{$residential_complex->location_longitude}}'></div>
                            </td>
                        </tr>
                    </table>
                </div>
            </div><!-- Nav tabs -->
            <ul class="nav nav-tabs" role="tablist">
                <li role="presentation" class=""><a href="#course_of_construction"
                                                    aria-controls="course_of_construction" role="tab" data-toggle="tab">Курс
                        будівництва ЖК</a></li>
                <li role="presentation" class=""><a href="#promotion" aria-controls="promotion" role="tab"
                                                    data-toggle="tab">Акції ЖК</a></li>
                <li role="presentation" class=""><a href="#customer_rating" aria-controls="customer_rating" role="tab"
                                                    data-toggle="tab">Відгуки клієнтів по ЖК</a></li>
                <li role="presentation" class=""><a href="#secret_buyer_rating" aria-controls="secret_buyer_rating"
                                                    role="tab" data-toggle="tab">Відгук таємного покупця</a></li>
                <li role="presentation" class=""><a href="#document" aria-controls="document" role="tab"
                                                    data-toggle="tab">Документ по ЖК</a></li>
                <li role="presentation" class=""><a href="#section" aria-controls="section" role="tab"
                                                    data-toggle="tab">Секції</a></li>
                <li role="presentation" class=""><a href="#residential_complex" aria-controls="residential_complex"
                                                    role="tab" data-toggle="tab">Рекомендовані ЖК</a></li>
            </ul>

            <!-- Tab panes -->
            <div class="tab-content">

                <div role="tabpanel" class="tab-pane course-of-construction" id="course_of_construction">
                    <table class="table table-bordered table-striped {{ count($course_of_constructions) > 0 ? 'datatable' : '' }}">
                        <thead>
                        <tr>
                            <th>@lang('quickadmin.course-of-construction.fields.images')</th>
                            <th>@lang('quickadmin.course-of-construction.fields.youtube-link')</th>
                            <th>@lang('quickadmin.course-of-construction.fields.report-date')</th>
                            {{--<th>@lang('quickadmin.course-of-construction.fields.description')</th>--}}
                            <th>@lang('quickadmin.course-of-construction.fields.residental-complex')</th>
                            @if( request('show_deleted') == 1 )
                                <th>@lang('quickadmin.qa_action')</th>
                            @else
                                <th>@lang('quickadmin.qa_action')</th>
                            @endif
                        </tr>
                        </thead>

                        <tbody>
                        @if (count($course_of_constructions) > 0)
                            @foreach ($course_of_constructions as $course_of_construction)
                                <tr data-entry-id="{{ $course_of_construction->id }}">
                                    <td field-key='images'>
                                        @foreach($course_of_construction->getMedia('images') as $media)
                                            <p class="form-group">
                                                <a href="{{ $media->getUrl() }}" target="_blank">{{ $media->name }}
                                                    ({{ $media->size }} bytes)</a>
                                            </p>
                                        @endforeach
                                    </td>
                                    <td field-key='youtube_link'>{{ $course_of_construction->youtube_link }}</td>
                                    <td field-key='report_date'>{{ $course_of_construction->report_date }}</td>
                                    {{--<td field-key='description'>{{ $course_of_construction->description }}</td>--}}
                                    <td field-key='residental_complex'>{{ $course_of_construction->residental_complex->name ?? '' }}</td>
                                    @if( request('show_deleted') == 1 )
                                        <td class="action">
                                            @can('course_of_construction_delete')
                                                {!! Form::open(array(
                'style' => 'display: inline-block;',
                'method' => 'POST',
                'onsubmit' => "return confirm('".trans("quickadmin.qa_are_you_sure")."');",
                'route' => ['admin.course_of_constructions.restore', $course_of_construction->id])) !!}
                                                {!! Form::submit(trans('quickadmin.qa_restore'), array('class' => 'btn btn-xs btn-success')) !!}
                                                {!! Form::close() !!}
                                            @endcan
                                            @can('course_of_construction_delete')
                                                {!! Form::open(array(
                'style' => 'display: inline-block;',
                'method' => 'DELETE',
                'onsubmit' => "return confirm('".trans("quickadmin.qa_are_you_sure")."');",
                'route' => ['admin.course_of_constructions.perma_del', $course_of_construction->id])) !!}
                                                {!! Form::submit(trans('quickadmin.qa_permadel'), array('class' => 'btn btn-xs btn-danger')) !!}
                                                {!! Form::close() !!}
                                            @endcan
                                        </td>
                                    @else
                                        <td td class="action">
                                            @can('course_of_construction_view')
                                                <a href="{{ route('admin.course_of_constructions.show',[$course_of_construction->id]) }}"
                                                   class="btn btn-xs btn-primary">@lang('quickadmin.qa_view')</a>
                                            @endcan
                                            @can('course_of_construction_edit')
                                                <a href="{{ route('admin.course_of_constructions.edit',[$course_of_construction->id]) }}"
                                                   class="btn btn-xs btn-info">@lang('quickadmin.qa_edit')</a>
                                            @endcan
                                            @can('course_of_construction_delete')
                                                {!! Form::open(array(
                                                                                        'style' => 'display: inline-block;',
                                                                                        'method' => 'DELETE',
                                                                                        'onsubmit' => "return confirm('".trans("quickadmin.qa_are_you_sure")."');",
                                                                                        'route' => ['admin.course_of_constructions.destroy', $course_of_construction->id])) !!}
                                                {!! Form::submit(trans('quickadmin.qa_delete'), array('class' => 'btn btn-xs btn-danger')) !!}
                                                {!! Form::close() !!}
                                            @endcan
                                        </td>
                                    @endif
                                </tr>
                            @endforeach
                        @else
                            <tr>
                                <td colspan="10">@lang('quickadmin.qa_no_entries_in_table')</td>
                            </tr>
                        @endif
                        </tbody>
                    </table>
                </div>
                <div role="tabpanel" class="tab-pane promotion" id="promotion">
                    <table class="table table-bordered table-striped {{ count($promotions) > 0 ? 'datatable' : '' }}">
                        <thead>
                        <tr>
                            <th>@lang('quickadmin.promotion.fields.plajka')</th>
                            <th>@lang('quickadmin.promotion.fields.color-picker')</th>
                            <th>@lang('quickadmin.promotion.fields.header')</th>
                            <th>@lang('quickadmin.promotion.fields.sub-header')</th>
                            {{--<th>@lang('quickadmin.promotion.fields.description')</th>--}}
                            <th>@lang('quickadmin.promotion.fields.image')</th>
                            <th>@lang('quickadmin.promotion.fields.residental-complex')</th>
                            @if( request('show_deleted') == 1 )
                                <th>@lang('quickadmin.qa_action')</th>
                            @else
                                <th>@lang('quickadmin.qa_action')</th>
                            @endif
                        </tr>
                        </thead>

                        <tbody>
                        @if (count($promotions) > 0)
                            @foreach ($promotions as $promotion)
                                <tr data-entry-id="{{ $promotion->id }}">
                                    <td field-key='plajka'>{{ $promotion->plajka }}</td>
                                    <td field-key='color_picker'>{{ $promotion->color_picker }}</td>
                                    <td field-key='header'>{{ $promotion->header }}</td>
                                    <td field-key='sub_header'>{{ $promotion->sub_header }}</td>
                                    {{--<td field-key='description'>{{ $promotion->description }}</td>--}}
                                    <td field-key='image'>@if($promotion->image)<a
                                                href="{{ asset(env('UPLOAD_PATH').'/' . $promotion->image) }}"
                                                target="_blank"><img
                                                    src="{{ asset(env('UPLOAD_PATH').'/thumb/' . $promotion->image) }}"/></a>@endif
                                    </td>
                                    <td field-key='residental_complex'>{{ $promotion->residental_complex->name ?? '' }}</td>
                                    @if( request('show_deleted') == 1 )
                                        <td class="action">
                                            @can('promotion_delete')
                                                {!! Form::open(array(
                'style' => 'display: inline-block;',
                'method' => 'POST',
                'onsubmit' => "return confirm('".trans("quickadmin.qa_are_you_sure")."');",
                'route' => ['admin.promotions.restore', $promotion->id])) !!}
                                                {!! Form::submit(trans('quickadmin.qa_restore'), array('class' => 'btn btn-xs btn-success')) !!}
                                                {!! Form::close() !!}
                                            @endcan
                                            @can('promotion_delete')
                                                {!! Form::open(array(
                'style' => 'display: inline-block;',
                'method' => 'DELETE',
                'onsubmit' => "return confirm('".trans("quickadmin.qa_are_you_sure")."');",
                'route' => ['admin.promotions.perma_del', $promotion->id])) !!}
                                                {!! Form::submit(trans('quickadmin.qa_permadel'), array('class' => 'btn btn-xs btn-danger')) !!}
                                                {!! Form::close() !!}
                                            @endcan
                                        </td>
                                    @else
                                        <td class="action">
                                            @can('promotion_view')
                                                <a href="{{ route('admin.promotions.show',[$promotion->id]) }}"
                                                   class="btn btn-xs btn-primary">@lang('quickadmin.qa_view')</a>
                                            @endcan
                                            @can('promotion_edit')
                                                <a href="{{ route('admin.promotions.edit',[$promotion->id]) }}"
                                                   class="btn btn-xs btn-info">@lang('quickadmin.qa_edit')</a>
                                            @endcan
                                            @can('promotion_delete')
                                                {!! Form::open(array(
                                                                                        'style' => 'display: inline-block;',
                                                                                        'method' => 'DELETE',
                                                                                        'onsubmit' => "return confirm('".trans("quickadmin.qa_are_you_sure")."');",
                                                                                        'route' => ['admin.promotions.destroy', $promotion->id])) !!}
                                                {!! Form::submit(trans('quickadmin.qa_delete'), array('class' => 'btn btn-xs btn-danger')) !!}
                                                {!! Form::close() !!}
                                            @endcan
                                        </td>
                                    @endif
                                </tr>
                            @endforeach
                        @else
                            <tr>
                                <td colspan="12">@lang('quickadmin.qa_no_entries_in_table')</td>
                            </tr>
                        @endif
                        </tbody>
                    </table>
                </div>
                <div role="tabpanel" class="tab-pane rating-table" id="customer_rating">
                    <table class="table table-bordered table-striped {{ count($customer_ratings) > 0 ? 'datatable' : '' }}">
                        <thead>
                        <tr>
                            <th>@lang('quickadmin.customer-rating.fields.position')</th>
                            <th>@lang('quickadmin.customer-rating.fields.infrastructure')</th>
                            <th>@lang('quickadmin.customer-rating.fields.transport-hub')</th>
                            <th>@lang('quickadmin.customer-rating.fields.planning')</th>
                            <th>@lang('quickadmin.customer-rating.fields.price-quality')</th>
                            <th>@lang('quickadmin.customer-rating.fields.enabled')</th>
                            <th>@lang('quickadmin.customer-rating.fields.residental-complex')</th>
                            @if( request('show_deleted') == 1 )
                                <th>@lang('quickadmin.qa_action')</th>
                            @else
                                <th>@lang('quickadmin.qa_action')</th>
                            @endif
                        </tr>
                        </thead>

                        <tbody>
                        @if (count($customer_ratings) > 0)
                            @foreach ($customer_ratings as $customer_rating)
                                <tr data-entry-id="{{ $customer_rating->id }}">
                                    <td field-key='position'>{{ $customer_rating->position }}</td>
                                    <td field-key='infrastructure'>{{ $customer_rating->infrastructure }}</td>
                                    <td field-key='transport_hub'>{{ $customer_rating->transport_hub }}</td>
                                    <td field-key='planning'>{{ $customer_rating->planning }}</td>
                                    <td field-key='price_quality'>{{ $customer_rating->price_quality }}</td>
                                    <td field-key='enabled'>{{ Form::checkbox("enabled", 1, $customer_rating->enabled == 1 ? true : false, ["disabled"]) }}</td>
                                    <td field-key='residental_complex'>{{ $customer_rating->residental_complex->name ?? '' }}</td>
                                    @if( request('show_deleted') == 1 )
                                        <td class="action">
                                            @can('customer_rating_delete')
                                                {!! Form::open(array(
                'style' => 'display: inline-block;',
                'method' => 'POST',
                'onsubmit' => "return confirm('".trans("quickadmin.qa_are_you_sure")."');",
                'route' => ['admin.customer_ratings.restore', $customer_rating->id])) !!}
                                                {!! Form::submit(trans('quickadmin.qa_restore'), array('class' => 'btn btn-xs btn-success')) !!}
                                                {!! Form::close() !!}
                                            @endcan
                                            @can('customer_rating_delete')
                                                {!! Form::open(array(
                'style' => 'display: inline-block;',
                'method' => 'DELETE',
                'onsubmit' => "return confirm('".trans("quickadmin.qa_are_you_sure")."');",
                'route' => ['admin.customer_ratings.perma_del', $customer_rating->id])) !!}
                                                {!! Form::submit(trans('quickadmin.qa_permadel'), array('class' => 'btn btn-xs btn-danger')) !!}
                                                {!! Form::close() !!}
                                            @endcan
                                        </td>
                                    @else
                                        <td class="action">
                                            @can('customer_rating_view')
                                                <a href="{{ route('admin.customer_ratings.show',[$customer_rating->id]) }}"
                                                   class="btn btn-xs btn-primary">@lang('quickadmin.qa_view')</a>
                                            @endcan
                                            @can('customer_rating_edit')
                                                <a href="{{ route('admin.customer_ratings.edit',[$customer_rating->id]) }}"
                                                   class="btn btn-xs btn-info">@lang('quickadmin.qa_edit')</a>
                                            @endcan
                                            @can('customer_rating_delete')
                                                {!! Form::open(array(
                                                                                        'style' => 'display: inline-block;',
                                                                                        'method' => 'DELETE',
                                                                                        'onsubmit' => "return confirm('".trans("quickadmin.qa_are_you_sure")."');",
                                                                                        'route' => ['admin.customer_ratings.destroy', $customer_rating->id])) !!}
                                                {!! Form::submit(trans('quickadmin.qa_delete'), array('class' => 'btn btn-xs btn-danger')) !!}
                                                {!! Form::close() !!}
                                            @endcan
                                        </td>
                                    @endif
                                </tr>
                            @endforeach
                        @else
                            <tr>
                                <td colspan="12">@lang('quickadmin.qa_no_entries_in_table')</td>
                            </tr>
                        @endif
                        </tbody>
                    </table>
                </div>
                <div role="tabpanel" class="tab-pane rating-table" id="secret_buyer_rating">
                    <table class="table table-bordered table-striped {{ count($secret_buyer_ratings) > 0 ? 'datatable' : '' }}">
                        <thead>
                        <tr>
                            <th>@lang('quickadmin.secret-buyer-rating.fields.position')</th>
                            <th>@lang('quickadmin.secret-buyer-rating.fields.infrastructure')</th>
                            <th>@lang('quickadmin.secret-buyer-rating.fields.transport-hub')</th>
                            <th>@lang('quickadmin.secret-buyer-rating.fields.planning')</th>
                            <th>@lang('quickadmin.secret-buyer-rating.fields.price-quality')</th>
                            <th>@lang('quickadmin.secret-buyer-rating.fields.enabled')</th>
                            <th>@lang('quickadmin.secret-buyer-rating.fields.residental-complex')</th>
                            <th>@lang('quickadmin.secret-buyer-rating.fields.youtube-link')</th>
                            @if( request('show_deleted') == 1 )
                                <th>@lang('quickadmin.qa_action')</th>
                            @else
                                <th>@lang('quickadmin.qa_action')</th>
                            @endif
                        </tr>
                        </thead>

                        <tbody>
                        @if (count($secret_buyer_ratings) > 0)
                            @foreach ($secret_buyer_ratings as $secret_buyer_rating)
                                <tr data-entry-id="{{ $secret_buyer_rating->id }}">
                                    <td field-key='position'>{{ $secret_buyer_rating->position }}</td>
                                    <td field-key='infrastructure'>{{ $secret_buyer_rating->infrastructure }}</td>
                                    <td field-key='transport_hub'>{{ $secret_buyer_rating->transport_hub }}</td>
                                    <td field-key='planning'>{{ $secret_buyer_rating->planning }}</td>
                                    <td field-key='price_quality'>{{ $secret_buyer_rating->price_quality }}</td>
                                    <td field-key='enabled'>{{ Form::checkbox("enabled", 1, $secret_buyer_rating->enabled == 1 ? true : false, ["disabled"]) }}</td>
                                    <td field-key='residental_complex'>{{ $secret_buyer_rating->residental_complex->name ?? '' }}</td>
                                    <td field-key='youtube_link'>{{ $secret_buyer_rating->youtube_link }}</td>
                                    @if( request('show_deleted') == 1 )
                                        <td class="action">
                                            @can('secret_buyer_rating_delete')
                                                {!! Form::open(array(
                'style' => 'display: inline-block;',
                'method' => 'POST',
                'onsubmit' => "return confirm('".trans("quickadmin.qa_are_you_sure")."');",
                'route' => ['admin.secret_buyer_ratings.restore', $secret_buyer_rating->id])) !!}
                                                {!! Form::submit(trans('quickadmin.qa_restore'), array('class' => 'btn btn-xs btn-success')) !!}
                                                {!! Form::close() !!}
                                            @endcan
                                            @can('secret_buyer_rating_delete')
                                                {!! Form::open(array(
                'style' => 'display: inline-block;',
                'method' => 'DELETE',
                'onsubmit' => "return confirm('".trans("quickadmin.qa_are_you_sure")."');",
                'route' => ['admin.secret_buyer_ratings.perma_del', $secret_buyer_rating->id])) !!}
                                                {!! Form::submit(trans('quickadmin.qa_permadel'), array('class' => 'btn btn-xs btn-danger')) !!}
                                                {!! Form::close() !!}
                                            @endcan
                                        </td>
                                    @else
                                        <td class="action">
                                            @can('secret_buyer_rating_view')
                                                <a href="{{ route('admin.secret_buyer_ratings.show',[$secret_buyer_rating->id]) }}"
                                                   class="btn btn-xs btn-primary">@lang('quickadmin.qa_view')</a>
                                            @endcan
                                            @can('secret_buyer_rating_edit')
                                                <a href="{{ route('admin.secret_buyer_ratings.edit',[$secret_buyer_rating->id]) }}"
                                                   class="btn btn-xs btn-info">@lang('quickadmin.qa_edit')</a>
                                            @endcan
                                            @can('secret_buyer_rating_delete')
                                                {!! Form::open(array(
                                                                                        'style' => 'display: inline-block;',
                                                                                        'method' => 'DELETE',
                                                                                        'onsubmit' => "return confirm('".trans("quickadmin.qa_are_you_sure")."');",
                                                                                        'route' => ['admin.secret_buyer_ratings.destroy', $secret_buyer_rating->id])) !!}
                                                {!! Form::submit(trans('quickadmin.qa_delete'), array('class' => 'btn btn-xs btn-danger')) !!}
                                                {!! Form::close() !!}
                                            @endcan
                                        </td>
                                    @endif
                                </tr>
                            @endforeach
                        @else
                            <tr>
                                <td colspan="14">@lang('quickadmin.qa_no_entries_in_table')</td>
                            </tr>
                        @endif
                        </tbody>
                    </table>
                </div>
                <div role="tabpanel" class="tab-pane documents" id="document">
                    <table class="table table-bordered table-striped {{ count($documents) > 0 ? 'datatable' : '' }}">
                        <thead>
                        <tr>
                            <th>@lang('quickadmin.document.fields.name')</th>
                            {{--<th>@lang('quickadmin.document.fields.description')</th>--}}
                            {{--<th>@lang('quickadmin.document.fields.icon')</th>--}}
                            <th>@lang('quickadmin.document.fields.file')</th>
                            <th>@lang('quickadmin.document.fields.link')</th>
                            <th>@lang('quickadmin.document.fields.document-type')</th>
                            <th>@lang('quickadmin.document.fields.residental-complex')</th>
                            @if( request('show_deleted') == 1 )
                                <th>@lang('quickadmin.qa_action')</th>
                            @else
                                <th>@lang('quickadmin.qa_action')</th>
                            @endif
                        </tr>
                        </thead>

                        <tbody>
                        @if (count($documents) > 0)
                            @foreach ($documents as $document)
                                <tr data-entry-id="{{ $document->id }}">
                                    <td field-key='name'>{{ $document->name }}</td>
                                    {{--<td field-key='description'>{{ $document->description }}</td>--}}
                                    <td field-key='icon'>@if($document->icon)<a
                                                href="{{ asset(env('UPLOAD_PATH').'/' . $document->icon) }}"
                                                target="_blank"><img
                                                    src="{{ asset(env('UPLOAD_PATH').'/thumb/' . $document->icon) }}"/></a>@endif
                                    </td>
                                    <td field-key='file'>@if($document->file)<a
                                                href="{{ asset(env('UPLOAD_PATH').'/' . $document->file) }}"
                                                target="_blank">Завантажити документ</a>@endif</td>
                                    <td field-key='link'>{{ $document->link }}</td>
                                    <td field-key='document_type'>{{ $document->document_type->name ?? '' }}</td>
                                    <td field-key='residental_complex'>{{ $document->residental_complex->name ?? '' }}</td>
                                    @if( request('show_deleted') == 1 )
                                        <td class="action">
                                            @can('document_delete')
                                                {!! Form::open(array(
                'style' => 'display: inline-block;',
                'method' => 'POST',
                'onsubmit' => "return confirm('".trans("quickadmin.qa_are_you_sure")."');",
                'route' => ['admin.documents.restore', $document->id])) !!}
                                                {!! Form::submit(trans('quickadmin.qa_restore'), array('class' => 'btn btn-xs btn-success')) !!}
                                                {!! Form::close() !!}
                                            @endcan
                                            @can('document_delete')
                                                {!! Form::open(array(
                'style' => 'display: inline-block;',
                'method' => 'DELETE',
                'onsubmit' => "return confirm('".trans("quickadmin.qa_are_you_sure")."');",
                'route' => ['admin.documents.perma_del', $document->id])) !!}
                                                {!! Form::submit(trans('quickadmin.qa_permadel'), array('class' => 'btn btn-xs btn-danger')) !!}
                                                {!! Form::close() !!}
                                            @endcan
                                        </td>
                                    @else
                                        <td class="action">
                                            @can('document_view')
                                                <a href="{{ route('admin.documents.show',[$document->id]) }}"
                                                   class="btn btn-xs btn-primary">@lang('quickadmin.qa_view')</a>
                                            @endcan
                                            @can('document_edit')
                                                <a href="{{ route('admin.documents.edit',[$document->id]) }}"
                                                   class="btn btn-xs btn-info">@lang('quickadmin.qa_edit')</a>
                                            @endcan
                                            @can('document_delete')
                                                {!! Form::open(array(
                                                                                        'style' => 'display: inline-block;',
                                                                                        'method' => 'DELETE',
                                                                                        'onsubmit' => "return confirm('".trans("quickadmin.qa_are_you_sure")."');",
                                                                                        'route' => ['admin.documents.destroy', $document->id])) !!}
                                                {!! Form::submit(trans('quickadmin.qa_delete'), array('class' => 'btn btn-xs btn-danger')) !!}
                                                {!! Form::close() !!}
                                            @endcan
                                        </td>
                                    @endif
                                </tr>
                            @endforeach
                        @else
                            <tr>
                                <td colspan="12">@lang('quickadmin.qa_no_entries_in_table')</td>
                            </tr>
                        @endif
                        </tbody>
                    </table>
                </div>
                <div role="tabpanel" class="tab-pane section" id="section">
                    <table class="table table-bordered table-striped {{ count($sections) > 0 ? 'datatable' : '' }}">
                        <thead>
                        <tr>
                            <th>@lang('quickadmin.section.fields.number')</th>
                            <th>@lang('quickadmin.section.fields.name')</th>
                            <th>@lang('quickadmin.section.fields.section-type')</th>
                            <th>@lang('quickadmin.section.fields.number-entrance-house')</th>
                            <th>@lang('quickadmin.section.fields.stage-of-construction')</th>
                            <th>@lang('quickadmin.section.fields.date-start-building')</th>
                            <th>@lang('quickadmin.section.fields.date-finish-buildiing')</th>
                            <th>@lang('quickadmin.section.fields.residental-complex')</th>
                            @if( request('show_deleted') == 1 )
                                <th>@lang('quickadmin.qa_action')</th>
                            @else
                                <th>@lang('quickadmin.qa_action')</th>
                            @endif
                        </tr>
                        </thead>

                        <tbody>
                        @if (count($sections) > 0)
                            @foreach ($sections as $section)
                                <tr data-entry-id="{{ $section->id }}">
                                    <td field-key='number'>{{ $section->number }}</td>
                                    <td field-key='name'>{{ $section->name }}</td>
                                    <td field-key='section_type'>{{ $section->section_type->type ?? '' }}</td>
                                    <td field-key='number_entrance_house'>{{ $section->number_entrance_house }}</td>
                                    <td field-key='stage_of_construction'>{{ $section->stage_of_construction->name ?? '' }}</td>
                                    <td field-key='date_start_building'>{{ $section->date_start_building }}</td>
                                    <td field-key='date_finish_buildiing'>{{ $section->date_finish_buildiing }}</td>
                                    <td field-key='residental_complex'>{{ $section->residental_complex->name ?? '' }}</td>
                                    @if( request('show_deleted') == 1 )
                                        <td class="action">
                                            @can('section_delete')
                                                {!! Form::open(array(
                'style' => 'display: inline-block;',
                'method' => 'POST',
                'onsubmit' => "return confirm('".trans("quickadmin.qa_are_you_sure")."');",
                'route' => ['admin.sections.restore', $section->id])) !!}
                                                {!! Form::submit(trans('quickadmin.qa_restore'), array('class' => 'btn btn-xs btn-success')) !!}
                                                {!! Form::close() !!}
                                            @endcan
                                            @can('section_delete')
                                                {!! Form::open(array(
                'style' => 'display: inline-block;',
                'method' => 'DELETE',
                'onsubmit' => "return confirm('".trans("quickadmin.qa_are_you_sure")."');",
                'route' => ['admin.sections.perma_del', $section->id])) !!}
                                                {!! Form::submit(trans('quickadmin.qa_permadel'), array('class' => 'btn btn-xs btn-danger')) !!}
                                                {!! Form::close() !!}
                                            @endcan
                                        </td>
                                    @else
                                        <td class="action">
                                            @can('section_view')
                                                <a href="{{ route('admin.sections.show',[$section->id]) }}"
                                                   class="btn btn-xs btn-primary">@lang('quickadmin.qa_view')</a>
                                            @endcan
                                            @can('section_edit')
                                                <a href="{{ route('admin.sections.edit',[$section->id]) }}"
                                                   class="btn btn-xs btn-info">@lang('quickadmin.qa_edit')</a>
                                            @endcan
                                            @can('section_delete')
                                                {!! Form::open(array(
                                                                                        'style' => 'display: inline-block;',
                                                                                        'method' => 'DELETE',
                                                                                        'onsubmit' => "return confirm('".trans("quickadmin.qa_are_you_sure")."');",
                                                                                        'route' => ['admin.sections.destroy', $section->id])) !!}
                                                {!! Form::submit(trans('quickadmin.qa_delete'), array('class' => 'btn btn-xs btn-danger')) !!}
                                                {!! Form::close() !!}
                                            @endcan
                                        </td>
                                    @endif
                                </tr>
                            @endforeach
                        @else
                            <tr>
                                <td colspan="13">@lang('quickadmin.qa_no_entries_in_table')</td>
                            </tr>
                        @endif
                        </tbody>
                    </table>
                </div>
                <div role="tabpanel" class="tab-pane " id="residential_complex">
                    <table class="table table-bordered table-striped {{ count($residential_complexes) > 0 ? 'datatable' : '' }}">
                        <thead>
                        <tr>
                            <th rowspan="2">@lang('quickadmin.residential-complex.fields.name')</th>
                            <th rowspan="2">@lang('quickadmin.residential-complex.fields.code')</th>
                            <th rowspan="2">@lang('quickadmin.residential-complex.fields.enabled')</th>
                            <th rowspan="2">@lang('quickadmin.residential-complex.fields.developer')</th>
                            <th colspan="2" id="priority-border">@lang('quickadmin.developer.fields.page-priority')</th>

                            {{--<th>@lang('quickadmin.residential-complex.fields.main-page-priority')</th>--}}
                            {{--<th>@lang('quickadmin.residential-complex.fields.res-com-page-priority')</th>--}}

                            <th rowspan="2">@lang('quickadmin.residential-complex.fields.min-price')</th>
                            <th rowspan="2">@lang('quickadmin.residential-complex.fields.city')</th>
                            <th rowspan="2">@lang('quickadmin.residential-complex.fields.district')</th>
                            <th rowspan="2">@lang('quickadmin.residential-complex.fields.street-name')</th>
                            {{--<th rowspan="2">@lang('quickadmin.residential-complex.fields.stage-of-construction')</th>--}}
                            @if( request('show_deleted') == 1 )
                                <th rowspan="2">@lang('quickadmin.qa_action')</th>
                            @else
                                <th rowspan="2">@lang('quickadmin.qa_action')</th>
                            @endif
                        </tr>
                        <tr>
                            <th>@lang('quickadmin.residential-complex.fields.main-page-priority_index')</th>
                            <th>@lang('quickadmin.residential-complex.fields.res-com-page-priority_index')</th>
                        </tr>
                        </thead>

                        <tbody>
                        @if (count($residential_complexes) > 0)
                            @foreach ($residential_complexes as $residential_complex)
                                <tr data-entry-id="{{ $residential_complex->id }}">
                                    <td field-key='name'>{{ $residential_complex->name }}</td>
                                    <td field-key='code'>{{ $residential_complex->code }}</td>
                                    <td field-key='enabled'>{{ Form::checkbox("enabled", 1, $residential_complex->enabled == 1 ? true : false, ["disabled"]) }}</td>
                                    <td field-key='developer'>{{ $residential_complex->developer->name ?? '' }}</td>
                                    <td field-key='main_page_priority'>{{ $residential_complex->main_page_priority }}</td>
                                    <td field-key='res_com_page_priority'>{{ $residential_complex->res_com_page_priority }}</td>
                                    <td field-key='min_price'>{{ $residential_complex->min_price }}</td>
                                    <td field-key='city'>{{ $residential_complex->city->name ?? '' }}</td>
                                    <td field-key='district'>{{ $residential_complex->district->name ?? '' }}</td>
                                    <td field-key='street_name'>{{ $residential_complex->street_name->name ?? '' }}</td>
                                    {{--<td field-key='stage_of_construction'>--}}
                                        {{--@foreach ($residential_complex->stage_of_construction as $singleStageOfConstruction)--}}
                                            {{--<span class="label label-info label-many">{{ $singleStageOfConstruction->name }}</span>--}}
                                        {{--@endforeach--}}
                                    {{--</td>--}}
                                    @if( request('show_deleted') == 1 )
                                        <td class="action">
                                            @can('residential_complex_delete')
                                                {!! Form::open(array(
                'style' => 'display: inline-block;',
                'method' => 'POST',
                'onsubmit' => "return confirm('".trans("quickadmin.qa_are_you_sure")."');",
                'route' => ['admin.residential_complexes.restore', $residential_complex->id])) !!}
                                                {!! Form::submit(trans('quickadmin.qa_restore'), array('class' => 'btn btn-xs btn-success')) !!}
                                                {!! Form::close() !!}
                                            @endcan
                                            @can('residential_complex_delete')
                                                {!! Form::open(array(
                'style' => 'display: inline-block;',
                'method' => 'DELETE',
                'onsubmit' => "return confirm('".trans("quickadmin.qa_are_you_sure")."');",
                'route' => ['admin.residential_complexes.perma_del', $residential_complex->id])) !!}
                                                {!! Form::submit(trans('quickadmin.qa_permadel'), array('class' => 'btn btn-xs btn-danger')) !!}
                                                {!! Form::close() !!}
                                            @endcan
                                        </td>
                                    @else
                                        <td class="action">
                                            @can('residential_complex_view')
                                                <a href="{{ route('admin.residential_complexes.show',[$residential_complex->id]) }}"
                                                   class="btn btn-xs btn-primary">@lang('quickadmin.qa_view')</a>
                                            @endcan
                                            @can('residential_complex_edit')
                                                <a href="{{ route('admin.residential_complexes.edit',[$residential_complex->id]) }}"
                                                   class="btn btn-xs btn-info">@lang('quickadmin.qa_edit')</a>
                                            @endcan
                                            @can('residential_complex_delete')
                                                {!! Form::open(array(
                                                                                        'style' => 'display: inline-block;',
                                                                                        'method' => 'DELETE',
                                                                                        'onsubmit' => "return confirm('".trans("quickadmin.qa_are_you_sure")."');",
                                                                                        'route' => ['admin.residential_complexes.destroy', $residential_complex->id])) !!}
                                                {!! Form::submit(trans('quickadmin.qa_delete'), array('class' => 'btn btn-xs btn-danger')) !!}
                                                {!! Form::close() !!}
                                            @endcan
                                        </td>
                                    @endif
                                </tr>
                            @endforeach
                        @else
                            <tr>
                                <td colspan="41">@lang('quickadmin.qa_no_entries_in_table')</td>
                            </tr>
                        @endif
                        </tbody>
                    </table>
                </div>
            </div>

            <p>&nbsp;</p>

            <a href="{{ route('admin.residential_complexes.index') }}"
               class="btn btn-default">@lang('quickadmin.qa_back_to_list')</a>
        </div>
    </div>
@stop

@section('javascript')
    @parent
    <script src="https://maps.googleapis.com/maps/api/js?key={{ env('GOOGLE_MAPS_API_KEY') }}&libraries=places&callback=initialize"
            async defer></script>

    <script>
        function initialize() {
            const maps = document.getElementsByClassName("map");
            for (let i = 0; i < maps.length; i++) {
                const field = maps[i]
                const fieldKey = field.dataset.key;
                const latitude = parseFloat(field.dataset.latitude) || -33.8688;
                const longitude = parseFloat(field.dataset.longitude) || 151.2195;

                const map = new google.maps.Map(document.getElementById(fieldKey + '-map'), {
                    center: {lat: latitude, lng: longitude},
                    zoom: 13
                });
                const marker = new google.maps.Marker({
                    map: map,
                    position: {lat: latitude, lng: longitude},
                });

                marker.setVisible(true);
            }

        }
    </script>
    <script src="{{ url('adminlte/plugins/datetimepicker/moment-with-locales.min.js') }}"></script>
    <script src="{{ url('adminlte/plugins/datetimepicker/bootstrap-datetimepicker.min.js') }}"></script>
    <script>
        $(function () {
            moment.updateLocale('{{ App::getLocale() }}', {
                week: {dow: 1} // Monday is the first day of the week
            });

            $('.date').datetimepicker({
                format: "{{ config('app.date_format_moment') }}",
                locale: "{{ App::getLocale() }}",
            });

        });
    </script>

@stop
