<!-- Modal -->
<div class="modal" id="editContactModal" 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">Edit</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 data-toggle="validator" autocomplete="off" class="form-styled" id="edit_contact_form">
                    @csrf
                    <input type="hidden" id="contact_id">
                    <div class="row">
                        <div class="col-xs-12 col-lg-12">
                            <div class="form-group has-feedback">
                                <label class="control-label">Type of contact*</label>
                                <select id="edit_contact_type" required class="form-control">
                                    <option value="1">Individual</option>
                                    <option value="2">Company</option>
                                </select>
                                <span class="help-block with-errors"></span>
                            </div>
                        </div>
                        <div class="col-xs-12 col-lg-12" id="ecSalutation">
                            <div class="form-group has-feedback">
                                <label class="control-label">Title</label>
                                <select id="edit_contact_salutation" class="form-control">
                                    <option value="">Select an option</option>
                                    <option value="Mr">Mr</option>
                                    <option value="Ms">Ms</option>
                                    <option value="M/S">M/S</option>
                                </select>
                            </div>
                        </div>
                        <div class="col-xs-12 col-lg-12">
                            <div class="form-group has-feedback">
                                <label class="control-label" id="ecName">Name*</label>
                                <input type="text" id="edit_contact_name" maxlength="50" required data-minlength="1"
                                       data-error="Must be at least 3 character" class="form-control"><span
                                    class="help-block with-errors"></span>
                            </div>
                        </div>
                        <div class="col-xs-12 col-lg-12">
                            <div class="form-group has-feedback">
                                <label class="control-label" id="ecPhone">Phone</label>
                                <input type="text" id="edit_contact_phone" maxlength="20" class="form-control">
                            </div>
                        </div>
                        <div class="col-xs-12 col-lg-12">
                            <div class="form-group has-feedback">
                                <label class="control-label" id="ecAltPhone">Alternate Phone</label>
                                <input type="text" id="edit_contact_alt_phone" maxlength="20" class="form-control">
                            </div>
                        </div>
                        <div class="col-xs-12 col-lg-12">
                            <div class="form-group has-feedback">
                                <label class="control-label" id="ecEmail">Email</label>
                                <input type="text" id="edit_contact_email" maxlength="50" class="form-control">
                            </div>
                        </div>
                        <div class="col-xs-12 col-lg-12" id="ecBrn">
                            <div class="form-group has-feedback">
                                <label class="control-label">BRN</label>
                                <input type="text" id="edit_contact_brn" maxlength="20" class="form-control">
                            </div>
                        </div>
                        <div class="col-xs-12 col-lg-12" style="display: none" id="ecOrn">
                            <div class="form-group has-feedback">
                                <label class="control-label">RERA ORN</label>
                                <input type="text" id="edit_contact_orn" maxlength="20" class="form-control">
                            </div>
                        </div>
                        <div class="col-xs-12 col-lg-12" style="display: none" id="ecTln">
                            <div class="form-group has-feedback">
                                <label class="control-label">Trade Licence</label>
                                <input type="text" id="edit_contact_tln" maxlength="20" class="form-control">
                            </div>
                        </div>
                        <div class="col-xs-12 col-lg-12" style="display: none" id="ecAddress">
                            <div class="form-group has-feedback">
                                <label class="control-label">Address</label>
                                <input type="text" id="edit_contact_address" maxlength="200" class="form-control">
                            </div>
                        </div>
                        <div class="col-xs-12 col-lg-12" id="ecUrl" style="display: none">
                            <div class="form-group has-feedback">
                                <label class="control-label">Company Url</label>
                                <input type="text" id="edit_contact_website" maxlength="100" class="form-control">
                            </div>
                        </div>
                        <div class="col-xs-12 col-lg-12">
                            <div class="form-group">
                                <label class="control-label">Lead Source</label>
                                <select data-live-search="true" id="edit_contact_source"
                                        class="form-control selectpicker show-tick">
                                    <option value="">Select Lead Source</option>
                                    @foreach (App\Models\Attribute::orderBy('name')->where('type', 'leadSource')->whereNull('is_primary')->get() as $attr)
                                        <option value="{{ $attr->id }}">
                                            {{ $attr->name }}
                                        </option>
                                    @endforeach
                                </select>
                            </div>
                        </div>
                        <div class="col-xs-12 col-lg-12" id="ecContactRole">
                            <div class="form-group">
                                <label class="control-label">Contact Role</label>
                                <select data-live-search="true" id="edit_contact_role"
                                        class="form-control selectpicker show-tick">
                                    <option value="">Select Contact Role</option>
                                    @foreach (App\Models\Attribute::orderBy('name')->where('type', 'contactRole')->get() as $attr)
                                        <option value="{{ $attr->id }}">
                                            {{ $attr->name }}
                                        </option>
                                    @endforeach
                                </select>
                            </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 data-live-search="true" id="edit_contact_assign_to"
                                            class="form-control selectpicker show-tick">
                                        <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>
                                </div>
                            </div>
                        @endif
                    </div>
                    <div class="row">
                        <div class="col-xs-12 col-lg-12">
                            <div class="form-group">
                                <button type="submit" id="edit_submit_btn" 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 class="alert alert-danger edit_errors" style="display: none">
                                    <ul></ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
