<div ng-controller="ocorrenciasController">
    <div class="modal-header">
        <h3>Intervenção</h3>
    </div>
    <div class="modal-body">
        <div class="row">
            <div class="col-md-6">
                <label>Data</label>
                <br />
                <input type="text"
                       class="date form-control readonly simple-field-data-mask"
                       data-mask="0000-00-00"
                       ng-model="selected.item.DataStr"
                       placeholder="____-__-__" />
                <br />
                <label>Descrição</label>
                <br />
                <input type="text"
                       class="form-control"
                       ng-model="selected.item.Descricao" maxlength="255" />
                <br />
                <label>Observações</label>
                <br />
                <textarea class="form-control tarea" maxlength="2000"
                          ng-model="selected.item.Observacoes"
                          style="min-height:50px; height:80px"></textarea>

                <br />
            </div>
            <div class="col-md-6">
                <div ng-init="carregarAnexosIntervencao(selected.item.Pk_PlanoIntervencao)">
                    <input type="hidden" ng-model="myDocFile">
                    <input id="btUpload" type="file"
                           ng-file-select="onFileSelect($files,selected.item)" style="display:none">
                    <label>Anexos</label>
                    <br />
                    <div style="overflow: auto; height:150px; border:1px solid #EEE;">
                        <table class="table table-hover table-striped">
                            <tr>
                                <th>Nome</th>
                                <th style="width:80px; text-align:right">
                                    <button type="button"
                                            popover-placement="left"
                                            popover-trigger="mouseenter"
                                            data-popover="Adicionar anexo"
                                            class="btn btn-primary btn-sm"
                                            onclick="document.getElementById('btUpload').click()">
                                        <span class="glyphicon glyphicon-plus"></span>
                                    </button>
                                </th>
                            </tr>

                            <tr class="apontar" ng-click="selAnexoIntervencao(item)"
                                ng-repeat="item in lstAnexoIntervencao"
                                ng-class="{info:item.PkAnexo==selectedAnexoIntervencao.PkAnexo}">
                                <td>{{item.NomeFicheiro}}</td>
                                <td style="width:80px; text-align:right">
                                    <button popover-placement="left"
                                            popover-trigger="mouseenter"
                                            data-popover="Descarregar"
                                            ng-click="downloadAnexoIntervencao(item.PkAnexo)"
                                            type="button" class="btn btn-default btn-xs">
                                        <span class="glyphicon glyphicon-download-alt"></span>
                                    </button>
                                    <button popover-placement="left"
                                            popover-trigger="mouseenter"
                                            data-popover="Apagar"
                                            ng-click="removeAnexosIntervencao(item)"
                                            type="button" class="btn btn-warning btn-xs">
                                        <span class="glyphicon glyphicon-remove"></span>
                                    </button>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div ng-show="uploadprogress>=0 && uploadprogress<100">
                        <progressbar class="progress-striped active" max="100" value=uploadprogress><i>{{uploadprogress}}</i></progressbar>
                        <p align="right"><button class="btn btn-primary btn-xs" ng-click="upload.abort()">Cancelar</button></p>
                    </div>
                </div>
                <br/>
                <label class="checkbox" style="text-align: right" ng-show="selected.item.Pk_PlanoIntervencao>0">
                    <input type="checkbox"
                           ng-model="bensApenasAplicados"
                           ng-change="carregarBensAssociadosIntervencao(selected.item.FkPlano,selected.item,!bensApenasAplicados)" /> Apenas os Bens aplicados
                </label>
                <div class="table-responsive margem" ng-init="carregarBensAssociadosIntervencao(selected.item.FkPlano,selected.item,true)">
                    <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">
                                    <input type="checkbox" ng-disabled="mnuMANUTENCAO.PEditar==false"
                                           ng-model="selecionarTodosIntervencao" ng-click="selecionarBensListagemIntervencao(selecionarTodosIntervencao)" />
                                </th>
                            </tr>

                            <tr class="apontar"
                                ng-repeat="item in lstInvIntervencao">
                                <td>
                                    {{item.NumInventario}}
                                </td>
                                <td>{{item.Nome}}</td>
                                <td>
                                    <input type="checkbox" ng-disabled="mnuMANUTENCAO.PEditar==false" ng-model="item.Associado" />
                                </td>
                            </tr>
                        </table>
                    </div>
                </div> 
                
            </div>
        </div>

    </div>
    <div class="modal-footer">
        <button class="btn btn-primary"
                ng-click="validaDadosFecha(validaDadosPlanoIntervencao,[selected.item])"
                ng-disabled="selected.item.perm.PCriar==false">
            Guardar
        </button>
        <button class="btn btn-warning" ng-click="cancel()" id="btnModalFechar">Fechar</button>
    </div>

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

    });
</script>