<div ng-controller="auxiliosController" ng-init="getAmortizacoesErros();">
    <div class="modal-header">
        <h4>Amortizações</h4>
    </div>
    <div class="modal-body">

        <div style="overflow: auto; height:380px;">
            <div class="list-group" ng-repeat="item in lstAmortizacoesErros">
                <div class="list-group-item apontar" ng-click="selErroAmortizacao(item)" ng-class="{active:item.IdInv==selectedErroAmortizacao.IdInv}">
                    {{item.Erros}}
                    <span class="glyphicon glyphicon-arrow-down" style="float:right" aria-hidden="true"></span>
                </div>
                <div class="list-group-item" ng-show="item.IdInv==selectedErroAmortizacao.IdInv">
                    <table class="table table-bordered table-striped">
                        <tr>
                            <th>Data</th>
                            <th>Tipo</th>
                            <th>Cód.</th>
                            <th>V.Bruto</th>
                            <th>Vida</th>
                            <th>Taxa</th>
                            <th>V.Amortiz.</th>
                            <th>V.Liquido</th>
                            <th></th>
                        </tr>
                        <tr ng-repeat="am in item.LstAm" ng-click="selLinhaAmortizacao(am)" ng-class="{info:am.Pk_Amortizacao==selectedLinhaAmortizacao.Pk_Amortizacao}">
                            <td><input type="text" ng-model="am.Data" 
                                       class="date simple-field-data-mask input_tab" 
                                       style="width:80px"
                                       data-mask="0000-00-00"
                                       datepicker-popup="yyyy-MM-dd" 
                                       placeholder="____-__-__" ng-change="am.Gravar=true" /></td>
                            <td>{{am.Tipo}}</td>
                            <td>{{am.DescricaoCodigo}}</td>
                            <td><input type="text" ng-model="am.ValorBruto" class="input_tab" style="width:60px" number-input maxlength="20" ng-change="am.Gravar=true" /></td>
                            <td><input type="text" ng-model="am.VidaUtil" class="input_tab" style="width:60px" numbers-only maxlength="3" ng-change="am.Gravar=true" /></td>
                            <td><input type="text" ng-model="am.Taxa" class="input_tab" style="width:60px" number-input maxlength="5" ng-change="am.Gravar=true" /></td>
                            <td><input type="text" ng-model="am.ValorAmortizacao" class="input_tab" style="width:60px" number-input maxlength="20" ng-change="am.Gravar=true" /></td>
                            <td><input type="text" ng-model="am.ValorLiquido" class="input_tab" style="width:60px"  number-input maxlength="20"  ng-change="am.Gravar=true"/></td>
                            <td>
                                <button popover-placement="top"
                                        popover-trigger="mouseenter"
                                        data-popover="Apagar"
                                        ng-click="confirmaApagarAmortizacao(am.Pk_Amortizacao, item.LstAm, am)"
                                        type="button" class="btn btn-warning btn-xs">
                                    <span class="glyphicon glyphicon-remove"></span>
                                </button>
                            </td>
                        </tr>
                    </table>
                    <div>
                        <!--<button ng-click="atualizaAmortizacaoLista(item.LstAm)"
                                type="button" class="btn btn-success btn-md">
                            Gravar
                        </button>-->
                        <button popover-placement="top"
                                popover-trigger="mouseenter"
                                data-popover="Adicionar"
                                ng-click="linhaAmortizacaoAdiciona(item)"
                                type="button" class="btn btn-primary btn-md">
                            <span class="glyphicon glyphicon-plus"></span>
                        </button>
                        <button ng-click="sugereValorLiquidoLinhaAbate(item.LstAm)"
                                type="button" class="btn btn-success btn-md">
                            Sugere correção  linha abate
                        </button>
                    </div>
                </div>
                
            </div>
            
        </div>

    </div>

    <div class="modal-footer">
        <button ng-click="sugereValorLiquidoLinhaAbateTodos(lstAmortizacoesErros)"
                type="button" class="btn btn-success btn-md">
            Sugere correção linha abate
        </button>
        <button ng-click="atualizaAmortizacaoLista(lstAmortizacoesErros)"
                type="button" class="btn btn-primary btn-md">
            Gravar
        </button>
        <button class="btn btn-warning" ng-click="ok()">Fechar</button>
        
    </div>
</div>
<script>
    $(document).ready(function () {
        $('.date').mask('0000-00-00');

    });
</script>