<div ng-controller="centroCustosController" ng-init="setLocal(selected.item.idEdificio,selected.item.idPiso,selected.item.idSala); carregarGuardados();">
    <div class="modal-header">
        <h4>Centro de Custos</h4>
        <h5>Tipo Custo - Amortizações</h5>
    </div>
    <div class="modal-body">
        <div class="row">
            <div class="col-md-4">
                <div class="input-group">
                    <span class="input-group-addon">Ano Letivo</span>
                    <select class="form-control"
                            ng-change="selAnoLetivo(selectedAnoLetivo); carregarGuardados();"
                            ng-model="selectedAnoLetivo"
                            ng-options="e.descricao for e in lstAnosLetivos"></select>
                </div>
            </div>
            
        </div>

        <div class="row">
            <br />
        </div>        
        
        <ul class="nav nav-tabs">
            <li role="presentation" ng-class="{active:separador[0]}" ng-click="mostraSeparador(0);"><a href="">Aplicados</a></li>
            <li role="presentation" ng-class="{active:separador[1]}" ng-click="mostraSeparador(1)"><a href="">Filtrar</a></li>
            <li role="presentation" ng-class="{active:separador[2]}" ng-click="mostraSeparador(2); filtraDados()"><a href="">Contas</a></li>
            <li role="presentation" ng-class="{active:separador[3]}" ng-click="mostraSeparador(3); filtraSelecionados()"><a href="">Selecionados</a></li>
        </ul>

        <div style="min-height:200px">
            <div ng-show="separador[0]">
                <br />
                <div style="overflow: auto; height:250px;">
                    <table class="table table-bordered table-striped">
                        <tr ng-repeat="item in lstExistentes" ng-click="selRow(item)" ng-class="{info:item==selectedRow}">
                            <td>{{item.CodNivel5}}</td>
                            <td>{{item.Nivel2}}</td>
                            <td>{{item.Nivel3}}</td>
                            <td>{{item.Nivel4}}</td>
                            <td style="width:84px"><input type="text" class="form-control" ng-model="item.Percent" number-input /></td>
                            <td style="width:44px">
                                <button popover-placement="top"
                                        popover-trigger="mouseenter"
                                        data-popover="Excluir" ng-click="excluir(item)" type="button"
                                        class="btn btn-warning btn-sm">
                                    <span class="glyphicon glyphicon-remove"></span>
                                </button>
                            </td>
                        </tr>
                    </table>
                </div>

            </div>
            
            <div ng-show="separador[1]" style="overflow: auto; height:290px">
                <br />
                <div class="panel panel-default">
                    <div class="panel-heading">1º Nivel</div>
                    <table class="table table-condensed">
                        <tr ng-repeat="item in lstNivel1">
                            <td style="width:32px"><input ng-model="item.Escolhido" type="checkbox" ng-click="ativaItem(item)" /></td>
                            <td>{{item.Descricao}}</td>
                        </tr>
                    </table>
                </div>

                <!--<div class="panel panel-default">
                    <div class="panel-heading">Nivel Ensino</div>
                    <table class="table table-condensed">
                        <tr ng-repeat="item in lstNivelEnsino">
                            <td style="width:32px"><input ng-model="item.Escolhido" type="checkbox" ng-click="ativaItem(item)" /></td>
                            <td>{{item.Descricao}}</td>

                        </tr>

                    </table>
                </div>
                <br />
                <div class="panel panel-default">
                    <div class="panel-heading">Escolas</div>
                    <table class="table table-condensed">
                        <tr ng-repeat="item in lstEscolas">
                            <td style="width:32px"><input ng-model="item.Escolhido" type="checkbox" ng-click="ativaItem(item)" /></td>
                            <td>{{item.NomeEscola}}</td>

                        </tr>

                    </table>
                </div>
                <br />
                <div class="panel panel-default">
                    <div class="panel-heading">TipoEnsino</div>
                    <table class="table table-condensed">
                        <tr ng-repeat="item in lstTipoEnsino">
                            <td style="width:32px"><input ng-model="item.Escolhido" type="checkbox" ng-click="ativaItem(item)" /></td>
                            <td>{{item.TipoEnsino}}</td>

                        </tr>

                    </table>
                </div>-->
            </div>

            <div ng-show="separador[2]">
                <br />
                <div class="input-group">
                    <input type="text" class="form-control" placeholder="Procurar..." aria-describedby="basic-addon2" ng-model="procurar">
                    <span class="input-group-addon" id="basic-addon2">
                        <span class="glyphicon glyphicon-search" aria-hidden="true"></span>
                    </span>
                </div>
                <br />
                <div style="overflow: auto; height:200px;">
                    <table class="table table-bordered table-striped">
                        <tr ng-repeat="item in (lstFinal = (lAnalitica | filter:procurar | filter:showNiveis ) )">
                            <td><input type="checkbox" ng-model="item.Escolhido" ng-click="ativaItem(item)" /></td>
                            <td>{{item.CodNivel5}}</td>
                            <td>{{item.Nivel2}}</td>
                            <td>{{item.Nivel3}}</td>
                            <td>{{item.Nivel4}}</td>
                        </tr>
                        
                    </table>
                </div>
                <div style="margin-top:10px; border-top:1px solid #DDD">
                    <label class="checkbox" style="margin-left:20px">
                        <input type="checkbox" ng-click="seleccionarTodos(selTodos)"
                               ng-model="selTodos" /> Seleccionar Todos
                    </label>
                </div>

            </div>
            <div ng-show="separador[3]">
                <br />
                <div style="overflow: auto; height:250px;">
                    <table class="table table-bordered table-striped">
                        <tr ng-repeat="item in lstSelecionados">
                            <td>{{item.CodNivel5}}</td>
                            <td>{{item.Nivel2}}</td>
                            <td>{{item.Nivel3}}</td>
                            <td>{{item.Nivel4}}</td>
                            <td style="width:84px"><input type="text" class="form-control" ng-model="item.Percent" number-input  /></td>
                        </tr>
                    </table>
                </div>

            </div>
            
        </div>
        <br />
        <div ng-show="false">
            <div class="row">
                <div class="col-md-4">
                    <div class="input-group">
                        <span class="input-group-addon">Ano Económico</span>
                        <input type="text" class="form-control" placeholder="" aria-describedby="basic-addon2" ng-model="anoEconomico">
                    </div>
                </div>
            </div>
            <br />
            
        </div>
        
        <br />
        <div class="alert alert-warning" role="alert">
            <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
            <!--<span class="sr-only">Error:</span>-->
            As alterações serão aplicadas a todos os bens neste local
        </div>
        <div ng-show="emExecucao==true">
            <label style="font-size:8pt">Por Favor Aguarde... </label><img src="images/preloader.gif" width="32" style="margin-left:30px; margin-right:30px" />
        </div>
        
    </div>
    
    <div class="modal-footer">
        <button class="btn btn-primary" ng-click="guardaDados()" ng-disabled="emExecucao==true">Gravar</button>
        <button class="btn btn-warning" ng-click="ok()" ng-disabled="emExecucao==true">Fechar</button>
    </div>
</div>
