<div>
    <div class="table-responsive" style="border:1px solid #DDD; height:400px; overflow:auto" ng-show="mostrar">
        <table class="table table-hover 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 style="text-align:right">
                    <button popover-placement="top"
                            popover-trigger="mouseenter"
                            data-popover="Adicionar"
                            ng-click="linhaAmortizacaoEditRowV2(null)"
                            ng-show="tipout=='Inovar'"
                            type="button" class="btn btn-primary btn-xs">
                        <span class="glyphicon glyphicon-plus" ng-show="tipout=='Inovar'"></span>
                    </button>
                </th>

                <!--<th>Ficheiro</th>-->
            </tr>
            <tr ng-repeat="am in selectedCadastro.LstAmortizacao" ng-click="selLinhaAmort(am)" ng-class="{info:am==selectedLinhaAmort}" ng-style="getCorLinhaAmortAlterada(am)"
                class="apontar">
                <td>{{am.Data | date:'yyyy-MM-dd'}}</td>
                <td>{{am.Tipo}}</td>
                <td>{{am.DescricaoCodigo}}</td>
                <td>{{formata2casas(am.ValorBruto)}}</td>
                <td>{{am.VidaUtil}}</td>
                <td>{{formata2casas(am.Taxa)}}</td>
                <td>{{formata2casas(am.ValorAmortizacao)}}</td>
                <td>{{formata2casas(am.ValorLiquido)}}</td>
                <td style="text-align:right">
                    <button popover-placement="top"
                            popover-trigger="mouseenter"
                            data-popover="Editar"
                            ng-click="linhaAmortizacaoEditRowV2(am)"
                            ng-show="tipout=='Inovar'"
                            type="button" class="btn btn-default btn-xs">
                        <span class="glyphicon glyphicon-pencil" ng-show="tipout=='Inovar'"></span>
                    </button>
                    <div ng-show="tipout!='Inovar'">
                        <button popover-placement="top"
                                popover-trigger="mouseenter"
                                data-popover="Editar"
                                ng-click="linhaAmortizacaoEditRow(am)"
                                ng-disabled="mnuValorizacao.PEditar==false || selectedCadastro.Bloqueado==true"
                                type="button" class="btn btn-default btn-xs">
                            <span class="glyphicon glyphicon-pencil" ng-show="selectedCadastro.Bloqueado==false"></span>
                            <span class="glyphicon glyphicon-lock" ng-show="selectedCadastro.Bloqueado==true"></span>
                        </button>
                    </div>
                    
                    <button popover-placement="top"
                            popover-trigger="mouseenter"
                            data-popover="Apagar"
                            ng-click="confirmaApagarAmortizacao(am.Pk_Amortizacao)"
                            ng-show="tipout=='Inovar'"
                            type="button" class="btn btn-warning btn-xs">
                        <span class="glyphicon glyphicon-remove" ng-show="tipout=='Inovar'"></span>
                    </button>

                </td>
                <td></td>
            </tr>

        </table>
    </div>
    <!--<h5>Alteração</h5>-->

    <div class="table-responsive" style="border:1px solid #DDD; height:400px; overflow:auto" ng-show="!mostrar">
        <table class="table table-hover table-striped">
            <tr>
                <th>Tipo</th>
                <th>Data</th>
                <th>Valor Alteração</th>
                <th>Vida</th>
                <th>Taxa Amort.</th>
                <th style="text-align:right">

                    <button popover-placement="top"
                            popover-trigger="mouseenter"
                            data-popover="Apagar Alteração da Valorização"
                            ng-click="confirmarApagarAlteracao(selectedLinhaAlteracao)"
                            type="button" class="btn btn-warning btn-xs"
                            ng-disabled="existeAbate() || mnuValorizacao.PApagar==false || selectedLinhaAlteracao.Bloqueado==true">
                        <span class="glyphicon glyphicon-remove"></span>
                    </button>
                    <button popover-placement="top"
                            popover-trigger="mouseenter"
                            data-popover="Nova Alteração"
                            ng-click="linhaAlteracaoAddRow(selectedCadastro.Pk_Inventario)"
                            type="button"
                            class="btn btn-primary btn-xs"
                            ng-disabled="existeAbate() || mnuValorizacao.PCriar==false">
                        <span class="glyphicon glyphicon-plus"></span>
                    </button>
                </th>
            </tr>
            <tr ng-repeat="itemalt in selectedCadastro.LstAlteracao" ng-click="selLinhaAlteracao(itemalt)" class="apontar" ng-class="{info:itemalt==selectedLinhaAlteracao}">

                <td>{{itemalt.CodigoAlteracao}}</td>
                <td>{{itemalt.Data | date:'yyyy-MM-dd'}}</td>
                <td>{{itemalt.ValorAlteracao.toFixed(2)}}</td>
                <td>{{itemalt.VidaUtil}}</td>
                <td>{{itemalt.TaxaAmortisacao.toFixed(2)}}</td>
                <td style="text-align:right">
                    <button popover-placement="top"
                            popover-trigger="mouseenter"
                            data-popover="Documentos"
                            ng-click="openModalDocumentos(itemalt,'Alteracao')"
                            type="button"
                            ng-disabled="mnuValorizacao.PEditar==false || itemalt.Bloqueado==true"
                            class="btn btn-warning btn-xs">
                        <span class="glyphicon glyphicon-file" ng-show="itemalt.Bloqueado==false"></span>
                        <span class="glyphicon glyphicon-lock" ng-show="itemalt.Bloqueado==true"></span>
                    </button>
                    <button popover-placement="top"
                            popover-trigger="mouseenter"
                            data-popover="Editar"
                            ng-click="linhaAlteracaoEditRow(itemalt)"
                            ng-disabled="mnuValorizacao.PEditar==false || itemalt.Bloqueado==true"
                            type="button" class="btn btn-default btn-xs">
                        <span class="glyphicon glyphicon-pencil" ng-show="itemalt.Bloqueado==false"></span>
                        <span class="glyphicon glyphicon-lock" ng-show="itemalt.Bloqueado==true"></span>
                    </button>
                </td>


            </tr>
        </table>
        <br />

    </div>
    <p align="right" style="margin-top:10px">
        
        <button class="btn btn-default" ng-disabled="root_podeMexerDadosDoBem===false"
                ng-click="confirmaRecalcularAmortizacoesDoBem(selectedCadastro)">
            Recalcular
        </button>
        <button class="btn btn-primary" ng-disabled="root_podeMexerDadosDoBem===false"
                ng-click="openOpcaoAmortizarValorTotal(selectedCadastro)">
            Amortizar valor total
        </button>
        <button class="btn btn-primary" style="min-width:150px" ng-disabled="root_podeMexerDadosDoBem===false"
                ng-click="mostrar=!mostrar">
            Alteração <i class="pull-right glyphicon" ng-class="{'glyphicon-chevron-down': mostrar, 'glyphicon-chevron-up': !mostrar}"></i>
        </button>
    </p>
    <label>Última gravação em: {{selectedCadastro.DataGravAmortiz}}</label>


</div>

