<script type="text/x-template" id="exsettings-template">

    <!-- full template HTML here -->

    <div class="col-xs-12">

        <div class="card">
            <div class="header">
                <h3> {{getLabelText("DefaultOrganizationsSettings")}}</h3>
            </div>
            <div class="body">
                <div class="row">
                    <div class="col-xs-12 row-label">
                        <div class="form-group">
                            <input type="checkbox" v-model="globalSettings.DLRequireAuth" id="enableRequiredAuthDL" />
                            <label for="enableRequiredAuthDL">{{getLabelText("EnableRequiredAuthDL")}}</label>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12 row-label">
                        <div class="form-group">
                            <input type="checkbox" v-model="globalSettings.DLRequireAuthUpdateEnabled" id="allowAdminToChangeReqAuthDL" />
                            <label for="allowAdminToChangeReqAuthDL">{{getLabelText("AllowAdminToChangeReqAuthDL")}}</label>
                        </div>
                    </div>
                </div>
                <div class="row" id="Div_AllowResellerToChangeReAuthDL" v-if="!isLoggedInAsReseller">
                    <div class="col-xs-12 row-label">
                        <div class="form-group">
                            <input type="checkbox" v-model="globalSettings.DLRequireAuthResellerUpdateEnabled" id="allowResellerToChangeReAuthDL" />
                            <label for="allowResellerToChangeReAuthDL">{{getLabelText("AllowResellerToChangeReAuthDL")}}</label>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12 row-label">
                        <div class="form-group">
                            <input type="checkbox" v-model="globalSettings.AllowLinkedMailbox" id="allowToAddLinkedMailbox" />
                            <label for="allowToAddLinkedMailbox">{{getLabelText("ACL212")}}</label>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12 row-label">
                        <div class="form-group">
                            <input type="checkbox" v-model="globalSettings.FirstNameLastNameRequired" id="strFirstLastNameRequired" />
                            <label for="strFirstLastNameRequired">{{getLabelText("strFirstLastNameRequired")}}</label>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12 row-label">
                        <div class="form-group">
                            <input type="checkbox" v-model="globalSettings.HideExternalForwardingEmail" id="strHideExternalForwardingEmailInput" />
                            <label for="strHideExternalForwardingEmailInput">{{getLabelText("strHideExternalForwardingEmailInput")}}</label>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12 row-label">
                        <div class="form-group">
                            <input type="checkbox" v-model="globalSettings.LoadTemplatesBasedOnAddons" id="strLoadTemplatesBasedOnAddons" />
                            <label for="strLoadTemplatesBasedOnAddons">{{getLabelText("strLoadTemplatesBasedOnAddons")}}</label>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12 row-label">
                        <div class="form-group">
                            <input type="checkbox" v-model="globalSettings.AllowToUpdateSignature" id="strAllowToUpdateSignature" />
                            <label for="strAllowToUpdateSignature">{{getLabelText("strAllowToUpdateSignature")}}</label>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12 row-label">
                        <div class="form-group">
                            <input type="checkbox" v-model="globalSettings.AutoDisableEnableMailboxwithADUser" id="strAutoDisableEnableMailboxwithADUser" />
                            <label for="strAutoDisableEnableMailboxwithADUser">{{getLabelText("DisableEnableMailboxwithADUser")}}</label>
                        </div>
                    </div>
                </div>

                <div class="row" v-if="!readOnly">
                    <div class="col-xs-12">
                        <button id="Btn_AddUpdateAllOrgSetting" class="btn btn-primary waves-effect btnAction" v-on:click.prevent="SaveGlobalOrgSettings">{{getLabelText("GN0000281")}}</button>
                    </div>
                </div>
            </div>
        </div>
        <br />

        <div class="card">
            <div class="header">
                <h3>{{ getLabelText('OrganizationSettings') }}</h3>
            </div>

            <div class="body" v-if="!isUpdateOrgSettingsMode">
                <div class="row">

                    <OperationsPanel>
                        <button id="Btn_AddUpdateOrgSetting" v-if="!readOnly" class="btn btn-primary waves-effect btnAction" v-on:click.prevent="updateOrgsSettings">{{getLabelText("AddUpdateOrgSetting")}}</button>
                        <button id="Btn_RemoveSettings" class="btn btn-primary waves-effect btnAction" v-if="!readOnly" v-show="showActionButton()" v-on:click.prevent="DeleteSelectedSettings();">{{getLabelText("DeleteSelected")}}</button>
                    </OperationsPanel>

                    <SearchPanel id='setting-list' :showClearButton="showClearButton" @onSearch='doSearch' @onClear='doClearSearch'>
                        <div :class="searchContainerDivClass" v-if="orgs.show">
                            <div class="form-group form-float">
                                <VueSelect :options="orgs.items" :selectedValue="this.search.selectedorg" @selectchange="orgChangeHandler" />
                            </div>
                        </div>

                        <InputSearch :searchValue="search.primaryDomainName" fieldName="primaryDomainName" :fieldLabel="getLabelText('strPrimaryDomainName')" :containerDivClass="searchContainerDivClass" @inputSearchChange="inputSearchChangeHandler" />
                        <InputSearch :searchValue="search.customerName" fieldName="customerName" :fieldLabel="getLabelText('GN0000268')" :containerDivClass="searchContainerDivClass" @inputSearchChange="inputSearchChangeHandler" />

                    </SearchPanel>

                    <div class="col-xs-12" v-if="isLoading">
                        <Loading />
                    </div>
                    <div class="col-xs-12" v-else>
                        <table class="table table-bordered table-striped table-hover" v-if="settings.length > 0">
                            <tbody>
                                <tr>
                                    <th class="col-xs-1 align-center" v-if="!(readOnly || isSubReseller)">
                                        <input type="checkbox" id="CheckAll" :checked="checkAllChecked()" @change="checkAll($event.target.checked);" />
                                        <label for="CheckAll"></label>
                                    </th>
                                    <th class="col-xs-1"><a href="#" @click.prevent="sortBy('OrganizationName')">{{getLabelText("DGN1110608")}}</a></th>
                                    <th class="col-xs-2"><a href="#" @click.prevent="sortBy('DomainName')">{{getLabelText("strPrimaryDomainName")}}</a></th>
                                    <th class="col-xs-2"><a href="#" @click.prevent="sortBy('FirstName')">{{getLabelText("GN0000268")}}</a></th>

                                    <th class="col-xs-4 align-center">{{getLabelText("M0027")}}</th>
                                </tr>
                                <tr v-for="setting in settings">

                                    <td class="align-center" v-if="!(readOnly || isSubReseller)">
                                        <input type="checkbox" v-bind:id="setting.RecordId" v-model="setting.IsItemSelected" />
                                        <label v-bind:for="setting.RecordId"></label>
                                    </td>
                                    <td>
                                        <a v-bind:href="'/RCC/Exchange/ExAccountDetail.aspx?oID='+setting.OrganizationId+'&MBManage=1'">
                                            {{setting.OrganizationName}}
                                        </a>
                                    </td>
                                    <td>{{setting.DomainName}}</td>
                                    <td><a v-bind:href="'/RCC/Clients/ClientDetail.aspx?CID='+setting.CustomerId+'&Src=C'">{{setting.CustomerId}}-{{setting.FirstName}} {{setting.LastName}}</a></td>

                                    <td>
                                        <table class="table small">
                                            <tbody>
                                                <tr>
                                                    <td class="col-xs-9 row-label">
                                                        {{getLabelText("EnableRequiredAuthDL")}}:
                                                    </td>
                                                    <td class="col-xs-3" v-if="setting.DLRequireAuth">
                                                        {{getLabelText("GN00001024")}}
                                                    </td>
                                                    <td v-else>{{getLabelText("GN00001025")}}</td>
                                                </tr>
                                                <tr>
                                                    <td class="col-xs-9 row-label">
                                                        {{getLabelText("AllowAdminToChangeReqAuthDL")}}:
                                                    </td>
                                                    <td class="col-xs-3" v-if="setting.DLRequireAuthUpdateEnabled">
                                                        {{getLabelText("GN00001024")}}
                                                    </td>
                                                    <td v-else>{{getLabelText("GN00001025")}}</td>
                                                </tr>
                                                <tr>
                                                    <td class="col-xs-9 row-label">
                                                        {{getLabelText("ACL212") + ':'}}
                                                    </td>
                                                    <td class="col-xs-3" v-if="setting.AllowLinkedMailbox">
                                                        {{getLabelText("GN00001024")}}
                                                    </td>
                                                    <td v-else>{{getLabelText("GN00001025")}}</td>
                                                </tr>
                                                <tr>
                                                    <td class="col-xs-9 row-label">
                                                        {{getLabelText("strFirstLastNameRequired")}}:
                                                    </td>
                                                    <td class="col-xs-3" v-if="setting.FirstNameLastNameRequired">
                                                        {{getLabelText("GN00001024")}}
                                                    </td>
                                                    <td v-else>{{getLabelText("GN00001025")}}</td>
                                                </tr>
                                                <tr>
                                                    <td class="col-xs-9 row-label">
                                                        {{getLabelText("strAllowToUpdateSignature") + ':'}}
                                                    </td>
                                                    <td class="col-xs-3" v-if="setting.AllowToUpdateSignature">
                                                        {{getLabelText("GN00001024")}}
                                                    </td>
                                                    <td v-else>{{getLabelText("GN00001025")}}</td>
                                                </tr>
                                                <tr>
                                                    <td class="col-xs-9 row-label">
                                                        {{getLabelText("DisableEnableMailboxwithADUser") + ':'}}
                                                    </td>
                                                    <td class="col-xs-3" v-if="setting.AutoDisableEnableMailboxwithADUser">
                                                        {{getLabelText("GN00001024")}}
                                                    </td>
                                                    <td v-else>{{getLabelText("GN00001025")}}</td>
                                                </tr>
                                            </tbody>
                                        </table>

                                    </td>
                                </tr>

                                <Pager :totalRecords="totalRecords" :pageSize="this.search.pageSize" :currentPage="this.search.pageIndex" @pagerChange="pagerChangeHandler" />
                            </tbody>
                        </table>
                        <NoRecords v-else />
                    </div>
                </div>
            </div>

            <div class="body" v-else>
                <div class="row">
                    <div class="col-xs-12 row-label">
                        <label>{{getLabelText("SelectOrganizations") }}</label>
                    </div>
                    <div class="col-xs-12">
                        <VueMultiSelectableSelected :useTranslation="true" :items="ucOrgs" id="ucOrgsSettings" @selectionInfo="OrgsSelectionInfoHandler" />
                    </div>
                </div>
                <div class="row">
                    <div class="row-label col-xs-12">
                        <div class="form-group">
                            <input type="checkbox" v-model="orgsEnableRequiredAuthDL" id="orgsEnableRequiredAuthDL" />
                            <label for="orgsEnableRequiredAuthDL">{{getLabelText("EnableRequiredAuthDL")}}</label>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="row-label col-xs-12">
                        <div class="form-group">
                            <input type="checkbox" v-model="orgsAllowAdminToChangeReqAuthDL" id="orgsAllowAdminToChangeReqAuthDL" />
                            <label for="orgsAllowAdminToChangeReqAuthDL">{{getLabelText("AllowAdminToChangeReqAuthDL")}}</label>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12 row-label">
                        <div class="form-group">
                            <input type="checkbox" v-model="orgAllowLinkedMailbox" id="orgAllowLinkedMailbox" />
                            <label for="orgAllowLinkedMailbox">{{getLabelText("ACL212")}}</label>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12 row-label">
                        <div class="form-group">
                            <input type="checkbox" v-model="orgFirstLastNameRequired" id="orgFirstLastNameRequired" />
                            <label for="orgFirstLastNameRequired">{{getLabelText("strFirstLastNameRequired")}}</label>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12 row-label">
                        <div class="form-group">
                            <input type="checkbox" v-model="orgAllowToUpdateSignature" id="orgAllowToUpdateSignature" />
                            <label for="orgAllowToUpdateSignature">{{getLabelText("strAllowToUpdateSignature")}}</label>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12 row-label">
                        <div class="form-group">
                            <input type="checkbox" v-model="autoDisableEnableMailboxwithADUser" id="autoDisableEnableMailboxwithADUser" />
                            <label for="autoDisableEnableMailboxwithADUser">{{getLabelText("DisableEnableMailboxwithADUser")}}</label>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="col-xs-12">
                        <a v-on:click.prevent="saveOrgsSettings" class="btn btn-primary waves-effect btnAction">{{getLabelText("GN0000281") }}</a>
                        <a v-on:click.prevent="resetOrgsSettings" class="btn btn-primary waves-effect">{{getLabelText("Cancel") }}</a>
                    </div>
                </div>
            </div>

        </div>
    </div>

</script>

