<div ng-include="'views/pageHeader.html'"></div>
<div class="container" style="" ng-controller="CollapseGeralCtrl">
    <div ng-controller="ocorrenciasController" ng-init="carregarLstPlanosManutencao(procurar_dados,false)">
        <div class="">
            <div class="col-xs-6 col-md-6" style="padding:0">
                <label style="color:#333366; font-size:14pt; margin-right:10pt">PLANO DE MANUTENÇÃO</label>
            </div>
            <div class="col-xs-6 col-md-6" style="text-align:right; padding:0px">

            </div>
            <br />
            <br />
        </div>

        <div style="" collapse="isCollapsed">
            <div class="col-md-4" style="margin-bottom:5px">
                <div class="input-group">
                    <input type="text"
                           class="form-control"
                           placeholder="Procurar..."
                           ng-model="procurar_dados"
                           ng-change="carregarLstPlanosManutencao(procurar_dados,false)"
                           ng-debounce
                           style="">
                    <span class="input-group-addon apontar"
                          popover-placement="bottom"
                          popover-trigger="mouseenter"
                          data-popover="Pesquisa avançada"
                          ng-click="openModalPesquisaAvancadaManutencao()">
                        Pesquisa avançada <span class="glyphicon glyphicon-search"></span>
                    </span>

                </div>
            </div>

            <div class="col-md-12 table-responsive margem">
                <div class="sep1" id="tabCadastro" style="border-top:1px solid #EEE; height:468px; overflow-x:hidden">
                    <table class="table table-hover table-striped">
                        <tr>
                            <th>Data início</th>
                            <th>Periodicidade</th>
                            
                            <th>Gestor</th>
                            <th>Titulo</th>
                            <th>Descrição</th>
                            <th>Nº Inv</th>
                            <th>Executada</th>
                            <th>Aviso</th>
                            <th style="width:80px; text-align:right">
                                <button type="button" popover-placement="left"
                                        popover-trigger="mouseenter"
                                        data-popover="Adicionar"
                                        class="btn btn-primary btn-sm"
                                        ng-click="openModalManutencaoGeral(null)"
                                        ng-disabled="mnuMANUTENCAO.PCriar==false">
                                    <span class="glyphicon glyphicon-plus"></span>
                                </button>
                            </th>
                        </tr>

                        <tr class="apontar" ng-click="selPlanoMan(item)"
                            ng-repeat="item in lstPlanosManutencao"
                            ng-class="{info:item.PkPlano==selectedPlanoMan.PkPlano}" ng-style="getCorLinhaPlanoEncerrado(item)">
                            <td>
                                <span popover-placement="right" popover-trigger="{{showTooltip(item.Finalizado)}}" data-popover="Encerrado">{{item.DataInicioStr}}</span>
                            </td>
                            <td>{{item.Periodicidade}}</td>
                            <td>{{item.Responsavel}}</td>
                            <td>
                                <span popover-placement="left" popover-trigger="{{showTooltip(item.Finalizado)}}" data-popover="Encerrado">{{item.Titulo}}</span>
                            </td>
                            <td>
                                <span popover-placement="left" popover-trigger="{{showTooltip(item.Finalizado)}}" data-popover="Encerrado">{{item.Descricao}}</span>
                            </td>
                            <td>{{item.NumInventario}}</td>
                            <td>{{item.DataExecutadaStr}}</td>
                            <td>{{item.DataAvisoStr}}</td>
                            <td style="width:120px; text-align:right">
                                <button popover-placement="left"
                                        popover-trigger="mouseenter"
                                        data-popover="Detalhes"
                                        ng-click="selPlanoMan(item); carregarIntervencoes(item.PkPlano); setCollapse(true)"
                                        type="button" class="btn btn-default btn-xs">
                                    <span class="glyphicon glyphicon-list"></span>
                                </button>
                                <button ng-disabled="mnuMANUTENCAO.PEditar==false" popover-placement="left"
                                        popover-trigger="mouseenter"
                                        data-popover="Editar"
                                        ng-click="openModalManutencaoGeral(item)"
                                        type="button" class="btn btn-default btn-xs">
                                    <span class="glyphicon glyphicon-pencil"></span>
                                </button>
                                <button ng-disabled="mnuMANUTENCAO.PApagar==false" popover-placement="left"
                                        popover-trigger="mouseenter"
                                        data-popover="Remover"
                                        ng-click="confirmarApagarPlanoManutencao(item)"
                                        type="button" class="btn btn-warning btn-xs">
                                    <span class="glyphicon glyphicon-remove"></span>
                                </button>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
            <br />

            <button ng-click="carregarLstPlanosManutencao(procurar_dados,true)" type="button"
                    ng-disabled="itemsLoaded==false || totalLoaded==0"
                    class="btn btn-primary btn-md">
                <span class="glyphicon glyphicon-forward"></span> Ver mais
            </button>
            <img src="images/preloader.gif" width="32" ng-hide="itemsLoaded==true || items.length==0" style="margin-left:10px; margin-right:10px" />
        </div>
        <div collapse="!isCollapsed">
            <button type="button" class="btn btn-primary btn-sm" ng-click="setCollapse(false)">
                <span class="glyphicon glyphicon-arrow-left"></span>
            </button>
            <label class="text-primary" style="margin-left:10px">{{selectedPlanoMan.Titulo}}</label>
            <div class="table-responsive">
                <table class="table table-hover table-striped">
                    <tr>
                        <th>Data</th>
                        <th>Descrição</th>
                        <th style="width:100px; text-align:right">
                            <button type="button"
                                    popover-placement="left"
                                    popover-trigger="mouseenter"
                                    data-popover="Nova intervenção"
                                    class="btn btn-primary btn-sm"
                                    ng-click="openModalPlanoIntervencao(null,selectedPlanoMan.PkPlano)"
                                    ng-disabled="mnuMANUTENCAO.PCriar==false">
                                <span class="glyphicon glyphicon-plus"></span>
                            </button>
                        </th>
                    </tr>

                    <tr class="apontar" ng-click="selIntervencao(item)"
                        ng-repeat="item in lstIntervencoes"
                        ng-class="{info:item.Pk_PlanoIntervencao==selectedIntervencao.Pk_PlanoIntervencao}">
                        <td>{{item.DataStr}}</td>
                        <td>{{item.Descricao}}</td>
                        <td style="width:100px; text-align:right">
                            <span class="glyphicon glyphicon-paperclip" ng-show="item.TemAnexo==true"></span>
                            <button popover-placement="left" ng-disabled="mnuMANUTENCAO.PEditar==false"
                                    popover-trigger="mouseenter"
                                    data-popover="Editar"
                                    ng-click="openModalPlanoIntervencao(item,selectedPlanoMan.PkPlano)"
                                    type="button" class="btn btn-default btn-xs">
                                <span class="glyphicon glyphicon-pencil"></span>
                            </button>
                            <button ng-disabled="mnuMANUTENCAO.PApagar==false" popover-placement="left"
                                    popover-trigger="mouseenter"
                                    data-popover="Remover"
                                    ng-click="confirmarApagarIntervencaoPlanoManutencao(item)"
                                    type="button" class="btn btn-warning btn-xs">
                                <span class="glyphicon glyphicon-remove"></span>
                            </button>
                        </td>
                    </tr>
                </table>
            </div>
        </div>

    </div>
</div>