@extends('admin.layouts.app')

@section('contentSection')
    <div class="row">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-header">
                    <div class="pull-left"><i class="fa fa-table"></i> WIP Listings (<span
                            id="module_total_count"></span>)
                    </div>
                    <div class="pull-right">
                        <!-- <button type="button" id="trash-btn" data-toggle="modal" data-target="#trashedListingModal"
                                class="btn btn-danger"><i class="fa fa-trash"></i> View trashed
                            </button> -->
                        <button type="button" data-toggle="modal" data-target="#addListingModal"
                                class="btn btn-primary"><i
                                class="fa fa-plus"></i> Add Listing
                        </button>
                    </div>
                </div>
                <div class="card-header">
                    <div class="row">
                        <div class="col-md-3 form-group">
                            <i class="fa fa-filter"></i> Filters
                        </div>
                    </div>
                    <form id="listingSearchFrom">
                        <div class="row">
                            <div class="col-md-3 form-group">
                                <label class="control-label">Project</label>
                                <select data-live-search="true" name="project_search" id="project_search"
                                        class="form-control selectpicker show-tick">
                                    <option value="">Select Project</option>
                                </select>
                            </div>
                            <div class="col-md-3 form-group">
                                <label class="control-label">Purpose</label>
                                <select data-live-search="true" name="purpose_search" id="purpose_search"
                                        class="form-control selectpicker show-tick">
                                    <option value="">Select Purpose</option>
                                    @foreach (App\Models\Attribute::where('type', 'purpose')->get() as $attr)
                                        <option value="{{ $attr->id }}">{{ $attr->name }}</option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="col-md-3 form-group">
                                <label class="control-label">Contact</label>
                                <select data-live-search="true" name="contact_search" id="contact_search"
                                        class="form-control selectpicker show-tick">
                                    <option value="">Select Contact</option>
                                    @foreach (auth()->user()->contacts()->orderBy('name')->get() as $attr)
                                        <option value="{{ $attr->id }}">
                                            {{ $attr->name }}
                                        </option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="col-md-3 form-group">
                                <label class="control-label">Developer</label>
                                <select data-live-search="true" name="developer_search" id="developer_search"
                                        class="form-control selectpicker show-tick">
                                    <option value="">Select Developer</option>
                                    @foreach (App\Models\Attribute::where('type', 'developer')->get() as $attr)
                                        <option value="{{ $attr->id }}">{{ $attr->name }}</option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="col-md-3 form-group">
                                <label class="control-label">Property Type</label>
                                <select data-live-search="true" name="property_type_search" id="property_type_search"
                                        class="form-control selectpicker show-tick">
                                    <option value="">Select Property Type</option>
                                    @foreach (App\Models\Attribute::orderBy('name')->with('parent')->where('type', 'propertyType')->whereNotNull('parent_id')->get() as $attr)
                                        <option value="{{ $attr->id }}">
                                            {{ $attr->parent ? $attr->name . ' (' . $attr->parent->name . ')' : $attr->name }}
                                        </option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="col-md-3 form-group">
                                <label class="control-label">Unit Type</label>
                                <select data-live-search="true" name="unit_type_search" id="unit_type_search"
                                        class="form-control selectpicker show-tick">
                                    <option value="">Select Unit Type</option>
                                    @foreach (App\Models\Attribute::orderBy('name')->where('type', 'unitType')->get() as $attr)
                                        <option value="{{ $attr->id }}">{{ $attr->name }}</option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="col-md-3 form-group">
                                <label class="control-label">Completion Status</label>
                                <select data-live-search="true" name="cs_search" id="cs_search"
                                        class="form-control selectpicker show-tick">
                                    <option value="">Select Completion Status</option>
                                    @foreach (App\Models\Attribute::where('type', 'completionStatus')->get() as $attr)
                                        <option value="{{ $attr->id }}">{{ $attr->name }}</option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="col-md-3 form-group">
                                <label class="control-label">Ownership Status</label>
                                <select data-live-search="true" name="os_search" id="os_search"
                                        class="form-control selectpicker show-tick">
                                    <option value="">Select Ownership Status</option>
                                    @foreach (App\Models\Attribute::where('type', 'ownershipStatus')->get() as $attr)
                                        <option value="{{ $attr->id }}">{{ $attr->name }}</option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="col-md-3 form-group">
                                <label class="control-label">Development Status</label>
                                <select data-live-search="true" name="ds_search" id="ds_search"
                                        class="form-control selectpicker show-tick">
                                    <option value="">Select Development Status</option>
                                    @foreach (App\Models\Attribute::where('type', 'developmentStatus')->get() as $attr)
                                        <option value="{{ $attr->id }}">{{ $attr->name }}</option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="col-md-3 form-group">
                                <label class="control-label">Sale Status</label>
                                <select data-live-search="true" name="ss_search" id="ss_search"
                                        class="form-control selectpicker show-tick">
                                    <option value="">Select Sale Status</option>
                                    @foreach (App\Models\Attribute::where('type', 'saleStatus')->get() as $attr)
                                        <option value="{{ $attr->id }}">{{ $attr->name }}</option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="col-md-3 form-group">
                                <label class="control-label">Rent Frequency</label>
                                <select data-live-search="true" name="rf_search" id="rf_search"
                                        class="form-control selectpicker show-tick">
                                    <option value="">Select Rent Frequency</option>
                                    @foreach (App\Models\Attribute::where('type', 'rentFrequency')->get() as $attr)
                                        <option value="{{ $attr->id }}">{{ $attr->name }}</option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="col-md-3 form-group">
                                <label class="control-label">Beds</label>
                                <input name="bedSearch" type="text" maxlength="10" class="form-control">
                            </div>
                            <div class="col-md-3 form-group">
                                <label class="control-label">Baths</label>
                                <input name="bathSearch" type="text" maxlength="10" class="form-control">
                            </div>
                        </div>
                        <br>
                        <div class="row">
                            <div class="col-md-12 text-right">
                                <button class="btn btn-primary">Search</button>
                                <button type="reset" id="listingSearchFormReset" class="btn btn-primary">Reset</button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="card-body">
                    <div class="table-responsive">
                        <table id="listingsListTable" class="table table-bordered" style="width: 100%"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection
@section('pageSpecificScripts')
    @include('admin.wip.listingsListTemplate')
    @include('admin.wip.listingDetailsTemplate')
    @include('admin.wip.modals.addListingModal')
    @include('admin.wip.modals.editListingModal')
    @include('admin.wip.modals.viewListingModal')
    <script src="{{ asset('back_assets/assets/plugins/bootstrap-datatable/js/jquery.dataTables.min.js') }}"></script>
    <script
        src="{{ asset('back_assets/assets/plugins/bootstrap-datatable/js/dataTables.bootstrap4.min.js') }}"></script>
    <script src="{{ asset('back_assets/assets/plugins/dropzone/js/dropzone.js') }}"></script>
    <script src="{{ asset('back_assets/assets/plugins/bootstrap-select/js/bootstrap-select.min.js') }}"></script>
    <script type="text/javascript" src="{{ asset('assets/js/ajax-bs.js') }}"></script>
    <script src="{{ asset('back_assets/assets/plugins/summernote/dist/summernote-bs4.min.js') }}"></script>
    <script src="{{ asset('back_assets/assets/plugins/fancybox/js/jquery.fancybox.min.js') }}"></script>
    <script src="{{ asset('back_assets/assets/js/app/wipScript.js') }}"></script>
@endsection
