<div ng-controller="CollapseGeralCtrl" >
    <div ng-controller="ocorrenciasController" ng-init="carregarPlanosManutencao(selectedCadastro.Pk_Inventario)">
       
        <div style="" collapse="isCollapsed">
            <div class="table-responsive">
                <table class="table table-hover table-striped">
                    <tr>
                        <th style="min-width:90px">Data início</th>
                        <th>Period.</th>
                        <th>Gestor</th>
                        <th>Titulo</th>
                        <th>Descrição</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="openModalPlanoManInventario(null,selectedCadastro.Pk_Inventario)"
                                    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 style="min-width:80px">
                            <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 style="width:90px">{{item.DataExecutadaStr}}</td>
                        <td style="width:90px">{{item.DataAvisoStr}}</td>
                        <td style="width:100px; text-align:right">
                            <button popover-placement="left"
                                    popover-trigger="mouseenter"
                                    data-popover="Detalhes"
                                    ng-click="selPlanoMan(item); carregarIntervencoes(item.PkPlano,selectedCadastro.Pk_Inventario); 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="openModalPlanoManInventario(item,selectedCadastro.Pk_Inventario)"
                                    type="button" class="btn btn-default btn-xs">
                                <span class="glyphicon glyphicon-pencil"></span>
                            </button>
                            <button ng-disabled="mnuMANUTENCAO.PEditar==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>
        <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:80px; 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="openModalPlanoIntervencaoInventario(null,selectedPlanoMan.PkPlano,selectedCadastro.Pk_Inventario)"
                                    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:80px; text-align:right">
                            <span class="glyphicon glyphicon-paperclip" ng-show="item.TemAnexo==true"></span>
                            <button ng-disabled="mnuMANUTENCAO.PEditar==false" popover-placement="top"
                                    popover-trigger="mouseenter"
                                    data-popover="Editar"
                                    ng-click="openModalPlanoIntervencaoInventario(item,selectedPlanoMan.PkPlano,selectedCadastro.Pk_Inventario)"
                                    type="button" class="btn btn-default btn-xs">
                                <span class="glyphicon glyphicon-pencil"></span>
                            </button>
                        </td>
                    </tr>
                </table>
            </div>
        </div>

    </div>
</div>