<ion-header class="ion-no-border">
  <app-header></app-header>
</ion-header>

<ion-content class="container-wrapper">
  <div class="main-content d-flex height-100 overflow-hidden">
    <div class="content d-flex flex-column" *ngIf="task">
      <div class="main-header ">
        <div class="title-content width-100 d-flex justify-space-between ">
          <div class="font-30 cursor-pointer" (click)="goBack()" defaultHref="#">
            <ion-icon *ngIf="ThemeService.currentTheme == 'default' " slot="end" src='assets/images/icons-arrow-arrow-left.svg'></ion-icon>
            <ion-icon *ngIf="ThemeService.currentTheme == 'gov' " slot="end" src='assets/images/theme/gov/icons-calendar-arrow-left.svg'></ion-icon>
          </div>
          <!-- <app-btn-modal-dismiss></app-btn-modal-dismiss> -->
          <div class="middle flex-grow-1">
            <ion-label class="title">{{ task.Folio}}</ion-label>
          </div>
          <div class="div-icon">
            <div autoHide="false" class="d-flex" (click)="openOptions()">
              <ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="font-30 cursor-pointer" src="assets/images/icons-menu.svg"></ion-icon>
              <ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="font-30 cursor-pointer" src="assets/images/theme/gov/icons-menu.svg"></ion-icon>
            </div>
          </div>
        </div>
      </div>
      <div class="upper-content">
        <div class="content-details">
          <ion-label>
            <p><span class="date">{{customDate}}</span><span class="label">{{ task.activityInstanceName }}</span></p>
            <p><span class="color-red">{{ task.DeadlineType }}</span></p>
          </ion-label>
        </div>
      </div>
      <div class="line"></div>

      <div class="overflow-y-auto">
        <div class="middle-content">
          <h5 *ngIf="intervenientes">Intervenientes</h5>
          <ion-item class="ion-no-margin ion-no-padding">
            <ion-label>
              <div *ngFor="let interveniente of intervenientes">
                <p>{{interveniente.Name}}</p>
              </div>
            </ion-label>
          </ion-item>
          <div *ngIf="cc.length > 0">
            <h5>Com conhecimento</h5>
            <ion-item class="ion-no-margin ion-no-padding">
              <ion-label>
                <div *ngFor="let c of cc">
                  <p>{{c.Name}}</p>
                </div>
              </ion-label>
            </ion-item>
          </div>
          <div *ngIf="task.Note">
            <h5>Detalhes</h5>
            <ion-item class="ion-no-margin ion-no-padding">
                <p [innerHTML]="task.Note"></p>
            </ion-item>
          </div>
        </div>
        <div class="bottom-content width-100">
          <ion-list>
            <h5>Documentos Anexados</h5>
            <ion-item *ngFor="let attachment of attachments"
              class="ion-no-margin ion-no-padding cursor-pointer"
            >
              <ion-label
                (click)="viewDocument(attachment.DocId, attachment)"
              >
                <p *ngIf="attachment.Assunto" class="attach-title-item">{{ attachment.Assunto }}<span class="span-right color-red btn-size"><ion-icon hidden name="close"></ion-icon></span></p>
                <p *ngIf="!attachment.Assunto" class="attach-title-item">{{ attachment.DocNumber }}<span class="span-right color-red btn-size"><ion-icon hidden name="close"></ion-icon></span></p>
                <p><span class="span-left">{{attachment.Sender}}</span><span class="span-right">{{ attachment.DocDate | date: 'dd/MM/yy' }}</span></p>
              </ion-label>
          </ion-item>
          </ion-list>
        </div>
      </div>

    </div>

    <div *ngIf="task" class="aside-right flex-column height-100 overflow-y-auto">
      <div *ngIf="task.WorkflowName == 'Pedido de Deferimento'">
        <div class="buttons" *ngIf="task.activityInstanceName == 'Tarefa de Deferimento'">
          <button (click)="openAddNoteModal('Arquivar')" class="btn-cancel" shape="round" >Arquivar</button>
          <button (click)="openDelegarModal(task)" class="btn-cancel" shape="round" >Delegar</button>
          <div class="solid"></div>
          <button *ngIf="p.userRole(['MDGPR'])" (click)="openExpedientActionsModal('0',fulltask)" class="btn-cancel" shape="round" >Efetuar Despacho</button>
          <button *ngIf="p.userRole(['PR'])" (click)="openExpedientActionsModal('0',fulltask)" class="btn-cancel" shape="round" >Efetuar Despacho</button>
          <button *ngIf="loggeduser.Profile == 'MDGPR'" (click)="openExpedientActionsModal('2',fulltask)" class="btn-cancel" shape="round" >Pedido de Deferimento</button>
          <button (click)="openBookMeetingModal(task)" class="btn-cancel" shape="round" >Marcar Reunião</button>
          <button (click)="sendExpedienteToPending()" *ngIf="task.Status != 'Pending'" class="btn-cancel" shape="round" >Enviar para Pendentes</button>
        </div>
        <div class="buttons" *ngIf="task.activityInstanceName == 'Reapreciar Deferimento'">
          <button (click)="openAddNoteModal('Arquivar')" class="btn-cancel" shape="round" >Arquivar</button>
          <button (click)="openDelegarModal(task)" class="btn-cancel" shape="round" >Delegar</button>
          <div class="solid"></div>
          <button *ngIf="p.userRole(['MDGPR'])" (click)="openExpedientActionsModal('0',fulltask)" class="btn-cancel" shape="round" >Efetuar Despacho</button>
          <button *ngIf="p.userRole(['PR'])" (click)="openExpedientActionsModal('0',fulltask)" class="btn-cancel" shape="round" >Efetuar Despacho</button>
          <button *ngIf="loggeduser.Profile == 'MDGPR'" (click)="openExpedientActionsModal('2',fulltask)" class="btn-cancel" shape="round" >Pedido de Deferimento</button>
          <button (click)="openBookMeetingModal(task)" class="btn-cancel" shape="round" >Marcar Reunião</button>
          <button (click)="sendExpedienteToPending()" *ngIf="task.Status != 'Pending'" class="btn-cancel" shape="round" >Enviar para Pendentes</button>
        </div>
        <div class="buttons" *ngIf="task.activityInstanceName == 'Concluir Deferimento'">
          <button (click)="openAddNoteModal('Arquivar')" class="btn-cancel" shape="round" >Arquivar</button>
          <button (click)="openDelegarModal(task)" class="btn-cancel" shape="round" >Delegar</button>
          <div class="solid"></div>
          <button *ngIf="p.userRole(['MDGPR'])" (click)="openExpedientActionsModal('0',fulltask)" class="btn-cancel" shape="round" >Efetuar Despacho</button>
          <button *ngIf="p.userRole(['PR'])" (click)="openExpedientActionsModal('0',fulltask)" class="btn-cancel" shape="round" >Efetuar Despacho</button>
          <button hidden (click)="openExpedientActionsModal('1',fulltask)" class="btn-cancel" shape="round" >Solicitar Parecer</button>
          <button (click)="openAddNoteModal('Solicitar Reapreciação')" class="btn-cancel" shape="round" >Solicitar Reapreciação</button>
          <button (click)="openBookMeetingModal(task)" class="btn-cancel" shape="round" >Marcar Reunião</button>
          <button (click)="sendExpedienteToPending()" *ngIf="task.Status != 'Pending'" class="btn-cancel" shape="round" >Enviar para Pendentes</button>
        </div>
      </div>
      <div *ngIf="task.WorkflowName == 'Pedido de Parecer' || task.WorkflowName == 'Pedido de Parecer do Presidente'">
        <div class="buttons" *ngIf="task.activityInstanceName == 'Tarefa de Parecer'">
          <button (click)="openDarParecer(task)" class="btn-cancel" shape="round" >Dar o meu Parecer</button>
          <button (click)="openBookMeetingModal(task)" class="btn-cancel" shape="round" >Marcar Reunião</button>
          <button *ngIf="task.WorkflowName == 'Pedido de Parecer do Presidente'" (click)="openForwardModal(task)" class="btn-cancel" shape="round" >Reencaminhar</button>
          <button (click)="sendExpedienteToPending()" *ngIf="task.Status != 'Pending'" class="btn-cancel" shape="round" >Enviar para Pendentes</button>
        </div>
        <div class="buttons" *ngIf="task.activityInstanceName == 'Concluir Parecer'">
          <button (click)="openAddNoteModal('Arquivar')" class="btn-cancel" shape="round" >Arquivar</button>
          <button *ngIf="p.userRole(['MDGPR'])" (click)="openExpedientActionsModal('0',fulltask)" class="btn-cancel" shape="round" >Efetuar Despacho</button>
          <button *ngIf="p.userRole(['PR'])" (click)="openExpedientActionsModal('0',fulltask)" class="btn-cancel" shape="round" >Efetuar Despacho</button>
          <button (click)="openExpedientActionsModal('1',fulltask)" class="btn-cancel" shape="round" >Solicitar Parecer</button>
          <button *ngIf="loggeduser.Profile == 'MDGPR'" (click)="openExpedientActionsModal('2',fulltask)" class="btn-cancel" shape="round" >Pedido de Deferimento</button>
          <button (click)="openBookMeetingModal(task)" class="btn-cancel" shape="round" >Marcar Reunião</button>
          <button (click)="sendExpedienteToPending()" *ngIf="task.Status != 'Pending'" class="btn-cancel" shape="round" >Enviar para Pendentes</button>
        </div>
        <div *ngIf="task.WorkflowName == 'Pedido de Parecer do Presidente'" class="buttons">
          <button (click)="openNewGroupPage()" class="btn-cancel" shape="round" >Iniciar Conversa</button>
        </div>
      </div>
    </div>
  </div>
</ion-content>

