<div ng-controller="utilizadorController" ng-init="carregarUtilizadores()">

    <div class="modal-header">
        <h3>Utilizadores</h3>
        <p align="right">
            <div class="input-group">
                <input type="text" class="form-control" placeholder="Procurar..." ng-model="procurar_ut">
                <span class="input-group-addon">
                    <span class="glyphicon glyphicon-search"></span>
                </span>

            </div>
        </p>
    </div>

    <div class="modal-body" style="height:350px; overflow:auto">

        <table class="table table-hover table-striped">
            <tr>
                <th style="width:250px">Utilizador</th>
                <th>Perfis</th>
                <th style="text-align:right">
                    <button popover-placement="left"
                            popover-trigger="mouseenter"
                            data-popover="Remover"
                            ng-click="confirmarApagarUtilizador(selectedRow)"
                            ng-disabled="selected.item.perm.PApagar==false || selectedRow.PK_Utilizador==getSessionId() || selectedRow==null"
                            type="button" class="btn btn-warning btn-sm">
                        <span class="glyphicon glyphicon-remove"></span>
                    </button>
                    <button popover-placement="left"
                            popover-trigger="mouseenter"
                            data-popover="Adicionar"
                            ng-click="utilizadorEditRow()"
                            ng-disabled="selected.item.perm.PCriar==false"
                            type="button" class="btn btn-primary btn-sm">
                        <span class="glyphicon glyphicon-plus"></span>
                    </button>

                </th>
            </tr>
            <tr ng-repeat="utilizador in users | filter:procurar_ut" ng-click="selectItem(utilizador)" class="apontar" ng-class="{info:utilizador.PK_Utilizador==selectedRow.PK_Utilizador}">
                <td style="width:250px"><input type="text" onfocus="this.blur()" readonly="readonly" ng-model="utilizador.Nome" class="input_tab readonly" /></td>
                <td>
                    <input type="text" onfocus="this.blur()" readonly="readonly" ng-model="utilizador.NomesPerfisAssociados" class="input_tab readonly" />
                </td>
                <td style="text-align:right">
                    <button popover-placement="left"
                            popover-trigger="mouseenter"
                            data-popover="Editar"
                            ng-click="utilizadorEditRow(utilizador)"
                            ng-disabled="selected.item.perm.PEditar==false"
                            type="button" class="btn btn-default btn-sm">
                        <span class="glyphicon glyphicon-pencil"></span>
                    </button>
                </td>
            </tr>
        </table>

    </div>
    <div class="modal-footer">
        <button class="btn btn-primary" ng-click="fechaRetornaDados(selectedRow)">Aplicar</button>
        <button class="btn btn-warning" ng-click="cancel()">Cancelar</button>
    </div>
</div>
