<div ng-controller="responsavelController">

    <div class="modal-header">
        <h3>Gestor Local</h3>
        <nav class="navbar navbar-default" role="navigation">
            <div class="container-fluid">
                <ul class="nav navbar-nav">
                    <!--<li ng-click="activarTabLocal(0)" ng-class="{active:showTabLocal[0]}"><a href="">Local</a></li>-->
                    <li ng-click="activarTabLocal(0)" ng-class="{active:showTabLocal[0]}"><a href="">Gestor</a></li>
                </ul>
                
                <form class="navbar-form navbar-right" role="navigation" ng-show="showTabLocal[0]">
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder="Procurar..." ng-model="procurar_resp" ng-change="selectedResponsavel=null">
                    </div>

                    <button popover-placement="top"
                            popover-trigger="mouseenter"
                            data-popover="Remover"
                            ng-click="confirmarApagarResponsavel(selectedResponsavel)"
                            type="button"
                            ng-show="responsaveis.length>0 && selectedResponsavel!=null"
                            ng-disabled="selected.item.perm.PApagar==false"
                            class="btn btn-warning">
                        <span class="glyphicon glyphicon-remove"></span>
                    </button>
                    <button popover-placement="top"
                            popover-trigger="mouseenter"
                            data-popover="Novo gestor"
                            ng-click="responsavelEditRow()"
                            type="button"
                            ng-disabled="selected.item.perm.PCriar==false"
                            class="btn btn-primary">
                        <span class="glyphicon glyphicon-plus"></span>
                    </button>
                    <button popover-placement="top"
                            popover-trigger="mouseenter"
                            data-popover="Editar"
                            ng-click="responsavelEditRow(selectedResponsavel)"
                            type="button"
                            ng-show="responsaveis.length>0 && selectedResponsavel!=null"
                            ng-disabled="selected.item.perm.PEditar==false"
                            class="btn btn-default">
                        <span class="glyphicon glyphicon-pencil"></span>
                    </button>
                </form>
            </div>
        </nav>

    </div>

    <div class="modal-body">

        <div style="height:270px; overflow:auto" ng-show="showTabLocal[0]" ng-init="carregarResponsaveis()">
            
            <div class="table-responsive">
                <table class="table table-hover table-striped">
                    <tr>                        
                        <th>Nome</th>
                        <!--<th>Utilizador</th>-->
                        <th style="width:50px"></th>
                    </tr>
                    <tr ng-click="atribuirResponsavelCadastro(item,selected.item)"
                        class="apontar"
                        ng-repeat="item in responsaveis | filter:procurar_resp"
                        ng-selected="ativarLinhaResLocal(item,selected.item)"
                        ng-class="{info:item.Pk_Responsavel==selectedResponsavel.Pk_Responsavel}">
                        
                        <td>{{item.Nome}}</td>
                        <th style="width:50px"><span class="glyphicon glyphicon-user" ng-show="item.IdUtilizador>0"></span></th>
                    </tr>
                </table>
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <!--<button class="btn btn-primary"
                ng-click="openModalAssociarResponsavelUtilizador(selectedResponsavel)"
                ng-disabled="selected.item.perm.PEditar==false || selected.item.perm.PCriar==false"
                ng-show="responsaveis.length>0 && selectedResponsavel!=null">
            Associar a utilizador
        </button>-->
        <button class="btn btn-primary"
                ng-click="selected.item.IdResponsavel=selectedResponsavel.Pk_Responsavel; ok();"
                ng-disabled="selected.item.perm.PEditar==false || selected.item.perm.PCriar==false"
                ng-show="responsaveis.length>0 && selectedResponsavel!=null">
            Aplicar gestor
        </button>
        <button class="btn btn-warning" ng-click="cancel()">Sair</button>
    </div>

</div>
