<div ng-controller="ocorrenciasController">
    <div class="modal-header">
        <h3>Plano de manutenção</h3>
    </div>
    <div class="modal-body">
        <div class="row" collapse="mostrarListagemBens">
            <div class="col-md-6">
                <label>Título</label>
                <br />
                <input class="form-control" ng-model="selected.item.Titulo" maxlength="255" />
                <br />
                <label>Descrição</label>
                <br />
                <input class="form-control" ng-model="selected.item.Descricao" maxlength="255" />
                <br />
                <label>Data de início</label>
                <br />
                <input type="text"
                       class="date form-control readonly simple-field-data-mask"
                       data-mask="0000-00-00"
                       ng-model="selected.item.DataInicioStr"
                       placeholder="____-__-__" />
                <br />
                <label>Periodicidade (dias)</label>
                <br />
                <input class="form-control" ng-model="selected.item.Periodicidade" number-input maxlength="5" />
                <br />
                <div class="row" style="text-align:right; padding-right:20px">
                    <!--<label class="checkbox">
                        <input type="checkbox" ng-model="selected.item.Finalizado" /> Encerrar
                    </label>-->
                </div>
                <br/>
            </div>
            <div class="col-md-6">
                <!--<label>Aplicar a</label>
                <br />-->
               
                <button ng-click="setMostraListagemBens(true); setUrlRefresParam()" type="button" ng-show="selected.item.PkPlano==0"
                        class="btn btn-primary btn-md">
                    Aplicar aos Bens <span class="glyphicon glyphicon-search"></span>
                </button>
                <button ng-click="setMostraListagemBens(true); setUrlRefresParam()" type="button" ng-show="selected.item.PkPlano>0"
                        class="btn btn-primary btn-md">
                    Acrescentar Bens <span class="glyphicon glyphicon-search"></span>
                </button>
                <br />
                <br/>
               
                <div class="table-responsive margem" ng-init="carregarBensAssociadosPlanoManutencao(selected.item.PkPlano,selected.item)">
                    <div class="sep1" style="border-top:1px solid #EEE; height:230px; overflow:auto">
                        <table class="table table-hover table-striped">
                            <tr>
                                <th>Nº Inv</th>
                                <th>Nome</th>
                                <th style="width:35px"></th>
                            </tr>

                            <tr class="apontar"
                                ng-repeat="item in lstInvPlano">
                                <td ng-style="verificaCorAbateBloqueio(item)">
                                    {{item.NumInventario}}
                                    <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true" ng-show="item.TemAbate" popover-placement="top" popover-trigger="mouseenter" data-popover="Abatido"></span>
                                </td>
                                <td>{{item.Nome}}</td>
                                <td>
                                    <button ng-disabled="mnuMANUTENCAO.PEditar==false" popover-placement="left"
                                            popover-trigger="mouseenter"
                                            data-popover="Remover"
                                            ng-click="retiraBemAssociadosPlanoManutencao(item,selected.item)"
                                            type="button" class="btn btn-warning btn-xs">
                                        <span class="glyphicon glyphicon-remove"></span>
                                    </button>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div> 
            </div>
        </div>
        <div class="row" collapse="!mostrarListagemBens">
            <div class="col-md-12" ng-controller="cadastroController" ng-init="listagemBensMostarColunaSelecao=true; removerIdsBens=selected.item.LstIdInventario">
                <div ng-include="'views/listagemBens.html'+currentUrlRefresParam">
                </div>
                <div style="text-align:right">
                    <button class="btn btn-primary"
                            ng-click="setMostraListagemBens(false); aplicaBensPlanoManutencao(selected.item,items,selected.item.PkPlano>0)">
                        Utilizar
                    </button>
                    <button class="btn btn-warning"
                            ng-click="setMostraListagemBens(false);">
                        Fechar
                    </button>
                </div>

            </div>
        </div>

    </div>
    <div class="modal-footer">
        <button class="btn btn-default"
                ng-click="selected.item.Finalizado=true; validaDadosFecha(validaDadosPlanoManutencaoGeral,[selected.item])"
                ng-show="selected.item.Finalizado===false"
                ng-disabled="selected.item.perm.PCriar==false">
            Encerrar
        </button>
        <button class="btn btn-default"
                ng-click="selected.item.Finalizado=false; validaDadosFecha(validaDadosPlanoManutencaoGeral,[selected.item])"
                ng-show="selected.item.Finalizado===true"
                ng-disabled="selected.item.perm.PCriar==false">
            Reabrir
        </button>
        <button class="btn btn-primary"
                ng-click="validaDadosFecha(validaDadosPlanoManutencaoGeral,[selected.item])"
                ng-disabled="selected.item.perm.PCriar==false">
            Guardar
        </button>
        <button class="btn btn-warning" ng-click="cancel()">Fechar</button>
    </div>

</div>
<script>
    $(document).ready(function () {
        $('.date').mask('0000-00-00');

    });
</script>
