<div class="col-md-12" ng-controller="perfilAcessoController" ng-init="carregarAcessos()" style="padding:3px;">
    
    <div class="col-md-4" style="padding:3px">
        <div class="table-responsive margem">
            <table class="table" style="margin:0">
                <tr>
                    <th>Perfil</th>
                    <th style="text-align:right">
                        <button popover-placement="top"
                                popover-trigger="mouseenter"
                                data-popover="Remover"
                                ng-click="confirmarRemoverPerfil(selectedPerfil)"
                                ng-disabled="mnuUtilizadores.PApagar==false"
                                type="button"
                                class="btn btn-warning btn-sm">
                            <span class="glyphicon glyphicon-remove"></span>
                        </button>
                        <button popover-placement="top"
                                popover-trigger="mouseenter"
                                data-popover="Adicionar"
                                ng-click="perfilEditRow()"
                                ng-disabled="mnuUtilizadores.PCriar==false"
                                type="button"
                                class="btn btn-primary btn-sm">
                            <span class="glyphicon glyphicon-plus"></span>
                        </button>

                    </th>
                </tr>
            </table>
            <div style="border:1px solid #EEE; overflow:auto; height:392px">
                <table class="table table-hover table-striped">
                    
                    <tr ng-repeat="perfil in perfis" class="apontar" ng-class="{info:perfil.IdPerfil==selectedPerfil.IdPerfil}">
                        <td class="apontar" ng-click="selPerfil(perfil)">{{perfil.NomePerfil}}</td>
                        <td style="text-align:right;width:100px">
                            <button popover-placement="top"
                                    popover-trigger="mouseenter"
                                    data-popover="Editar"
                                    ng-click="selPerfil(perfil); perfilEditRow(perfil)"
                                    ng-disabled="mnuUtilizadores.PEditar==false"
                                    type="button" class="btn btn-default btn-sm">
                                <span class="glyphicon glyphicon-pencil"></span>
                            </button>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        
    </div>

    <div class="col-md-8" style="padding:3px">
        <div class="table-responsive margem">
            
            <table class="table" style="margin-bottom:2px">
                <tr>
                    <th>Menu</th>
                    <th style="width:70px">Criar</th>
                    <th style="width:70px">Editar</th>
                    <th style="width:70px">Apagar</th>
                    <th style="width:70px">Leitura</th>
                </tr>
            </table>
            <div style="border:1px solid #EEE; overflow:auto; height:400px">
                <table class="table table-hover">
                    <tr ng-repeat="lst in selectedPerfil.Acessos">
                        <td>{{lst.DescSubMenu}}</td>
                        <td style="width:70px">
                            <input type="checkbox"
                                   ng-model="lst.PCriar"
                                   ng-change="verificaSoLeitura(); dadosModificados(true)"
                                   ng-disabled="mnuAcessoMenus.PEditar==false || bloqueia()" />
                        </td>
                        <td style="width:70px">
                            <input type="checkbox"
                                   ng-model="lst.PEditar"
                                   ng-change="verificaSoLeitura(); dadosModificados(true)"
                                   ng-disabled="mnuAcessoMenus.PEditar==false || bloqueia()" />
                        </td>
                        <td style="width:70px">
                            <input type="checkbox"
                                   ng-model="lst.PApagar"
                                   ng-change="verificaSoLeitura(); dadosModificados(true)"
                                   ng-disabled="mnuAcessoMenus.PEditar==false || bloqueia()" />
                        </td>
                        <td style="width:70px">
                            <input type="checkbox"
                                   ng-model="lst.SoLeitura"
                                   ng-change="verificaSoLeitura(); dadosModificados(true)"
                                   ng-disabled="mnuAcessoMenus.PEditar==false || bloqueia()" />
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        
    </div>
    <div class="col-md-12" style="text-align:right; padding-bottom:5px">
        <button type="button" class="btn btn-success btn-md"
                ng-click="guardarAcessos(); dadosModificados(false)"
                ng-disabled="mnuUtilizadores.PEditar==false">
            <span class="glyphicon glyphicon-ok"></span> Guardar Todos
        </button>
    </div>
</div>