<div ng-controller="localCadastroController" ng-init="listarEdificios(-1)">
    <div class="modal-header">
        <h4>Gestor por local</h4>
    </div>
    <div ng-controller="responsavelController" ng-init="carregarResponsaveis()">
        <div class="modal-body">
            <label>Origem</label>
            <div class="row">
                <div class="col-md-3">
                    <input type="text" placeholder="" class="form-control" style="cursor:default"
                           popover-placement="top"
                           popover-trigger="mouseenter"
                           data-popover="Nome da Entidade"
                           ng-click=""
                           readonly="readonly" ng-model="selectedEdificio.NomeEntidade" />
                </div>
                <div class="col-md-3">
                    <select class="form-control"
                            ng-model="selectedEdificio"
                            ng-change="selEdificio(selectedEdificio,-1)"
                            ng-options="e.EdificioEntidade for e in edificios">
                        <!--<option value="">Qualquer Edifício...</option>-->
                    </select>
                </div>
                <div class="col-md-3">
                    <select class="form-control"
                            ng-model="selectedPiso"
                            ng-change="selPiso(selectedPiso,-1)"
                            ng-options="p.Descricao for p in selectedEdificio.LstPiso">
                        <!--<option value="">Qualquer Piso...</option>-->
                    </select>
                </div>
                <div class="col-md-3">
                    <select class="form-control"
                            ng-model="selectedSala"
                            ng-change="selSala(selectedSala,-1)"
                            ng-options="s.Descricao for s in selectedPiso.LstSala">
                        <!--<option value="">Qualquer Sala...</option>-->
                    </select>
                </div>
            </div>
            <!--<br/>-->
            <div class="row" style="text-align:right; padding-right:20px">
                <label class="checkbox">
                    <input type="checkbox" ng-model="marcarDesmarcarMover"
                           ng-click="selecionarRegistosMoverLocal(items,marcarDesmarcarMover)" /> Marcar/desmarcar
                </label>
            </div>

            <div class="row" style="overflow: auto; height:290px; margin:0px">
                <table class="table table-bordered table-striped">
                    <tr ng-repeat="item in items"
                        class="apontar">
                        <td>{{item.NumInventario}}</td>
                        <td>{{item.Nome}}</td>
                        <!--<td>{{item.Localizacao}}</td>-->
                        <td style="width:44px">
                            <input type="checkbox" ng-model="item.selecionado" />
                        </td>
                    </tr>
                </table>
            </div>
            <br />
            <label>Gestor</label>
            <div class="row">
                <!--<div class="col-md-3">

                </div>-->
                <div class="col-md-3">
                    <select class="form-control"
                            ng-model="selectedResponsavel"
                            ng-change="selResponsavel(selectedResponsavel)"
                            ng-options="e.Nome for e in responsaveis"></select>
                </div>

            </div>
        </div>

        <div class="modal-footer">
            <button class="btn btn-primary"
                    ng-click="aplicarResponsavelAoLocal(items,selectedEdificio.PK_Edificio,
                        selectedPiso.PK_Piso,selectedSala.PK_Sala,selectedResponsavel.Pk_Responsavel);"
                    ng-disabled="selected.item.perm.PEditar==false || selected.item.perm.PCriar==false"
                    ng-show="responsaveis.length>0">
                Aplicar gestor
            </button>
            <button class="btn btn-warning" ng-click="ok()">Fechar</button>
        </div>
    </div>
</div>

