<!-- Modal -->
<div class="modal" id="addRpModal" data-keyboard="false" data-backdrop="static">
    <div class="modal-dialog modal-lg" style="max-width: 500px">
        <div class="modal-content border-primary">
            <div class="modal-header bg-primary">
                <h5 class="modal-title text-white">Add Related Property</h5>
                <button type="button" class="close text-white" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <form method="post" action="{{route('updateContact', $contact->id)}}" data-toggle="validator"
                      autocomplete="off" class="form-styled">
                    @csrf
                    <input type="hidden" name="type" value="rp">
                    <div class="row">
                        <div class="col-xs-12 col-lg-12">
                            <div class="form-group has-feedback">
                                <label class="control-label">Property*</label>
                                <select required name="listing_id" class="form-control">
                                    <option value="">Select Property</option>
                                    @if(auth()->user()->type == 1)
                                        @foreach (\App\Models\Listing::whereType(1)->orderBy('title')->get() as $attr)
                                            <option value="{{ $attr->id }}">
                                                {{ $attr->title }} ({{ $attr->p_id }})
                                            </option>
                                        @endforeach
                                    @else
                                        @foreach (auth()->user()->simple_listings()->orderBy('title')->get() as $attr)
                                            <option value="{{ $attr->id }}">
                                                {{ $attr->title }} ({{ $attr->p_id }})
                                            </option>
                                        @endforeach
                                    @endif
                                </select>
                                <span class="help-block with-errors"></span>
                            </div>
                        </div>
                        @if(auth()->user()->type == 1 || auth()->user()->type == 2)
                            <div class="col-xs-12 col-lg-12">
                                <div class="form-group">
                                    <label class="control-label">Assign To</label>
                                    <select required name="assign_to" class="form-control">
                                        <option value="">Select User</option>
                                        @if(auth()->user()->type == 1)
                                            @foreach (App\Models\User::orderBy('name')->where('type', 3)->get() as $attr)
                                                <option value="{{ $attr->id }}">
                                                    {{ $attr->name }}
                                                </option>
                                            @endforeach
                                        @else
                                            @foreach (App\Models\User::orderBy('name')->where('parent_id', auth()->id())->get() as $attr)
                                                <option value="{{ $attr->id }}">
                                                    {{ $attr->name }}
                                                </option>
                                            @endforeach
                                        @endif
                                    </select>
                                    <span class="help-block with-errors"></span>
                                </div>
                            </div>
                        @endif
                        <div class="col-xs-12 col-lg-12">
                            <div class="form-group has-feedback">
                                <label class="control-label">Relationships to the Property*</label>
                                <select required name="relation" class="form-control">
                                    <option value="">Select Relation</option>
                                    <option value="Owner">Owner</option>
                                    <option value="Employee">Employee</option>
                                    <option value="Employer">Employer</option>
                                    <option value="Buyer">Buyer</option>
                                    <option value="Client">Client</option>
                                    <option value="Agent">Agent</option>
                                </select>
                                <span class="help-block with-errors"></span>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-xs-12 col-lg-12">
                            <div class="form-group">
                                <button type="submit" name="submit" class="btn btn-success"><i
                                        class="fa fa-check fa-lg"> </i>&nbsp;Submit
                                </button>
                                <button type="button" class="btn btn-secondary" data-dismiss="modal"><i
                                        class="fa fa-times fa-lg"></i> Close
                                </button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
