<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 align-center">
          <div class=" btn-dismiss 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>
          <div class="middle d-flex align-center flex-grow-1">
            <ion-label class="title">{{ task.Folio}}</ion-label>
          </div>
          <div class="div-icon" (click)="openOptions()">
            <ion-icon *ngIf="ThemeService.currentTheme == 'default' " src="assets/images/icons-menu.svg"></ion-icon>
            <ion-icon *ngIf="ThemeService.currentTheme == 'gov' " src="assets/images/theme/gov/icons-menu.svg"></ion-icon>
          </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" style="margin-right: -20px; margin-right: -20px;">
        <div class="middle-content">
          <h5 *ngIf="intervenientes">Intervenientes</h5>
          <ion-item class="ion-no-margin ion-no-padding">
            <ion-label>
              <div *ngFor="let task of intervenientes">
                <p>{{task.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="fulltask.workflowInstanceDataFields.TaskMessage">
            <h5>Detalhes</h5>
            <ion-item class="ion-no-margin ion-no-padding">
                <p [innerHTML]="fulltask.workflowInstanceDataFields.TaskMessage"></p>
            </ion-item>
          </div>
        </div>
        <div class="bottom-content width-100">
          <ion-list>
            <h5>Documentos Anexados</h5>
            <ion-item class="ion-no-margin ion-no-padding cursor-pointer" *ngFor="let Document of fulltask.Documents">
              <ion-label class="d-block" (click)="viewDocument(Document.DocId, Document)">
                <p class="attach-title-item">{{ Document.Assunto }}<span class="span-right color-red btn-size"><ion-icon hidden name="close"></ion-icon></span></p>
                <p><span class="span-left">{{ Document.Sender}}</span><span class="span-right">{{ Document.DocDate | date: 'dd/MM/yyyy HH:mm' }}</span></p>
              </ion-label>
            </ion-item>
          </ion-list>
        </div>
      </div>

    </div>

    <!-- <app-task-details class="content d-flex flex-column"
      [task]="task"
      [intervenientes]="intervenientes"
      [cc]="cc"
      [customDate]="customDate"
      [fulltask]="fulltask"
      (openOptions)="openOptions($event)"
      (goBack)="goBack()"
      (viewDocument)="viewDocument($event)"
    > </app-task-details> -->



    <div *ngIf="task" class="aside-right flex-column height-100 overflow-y-auto">
      <div class="buttons" *ngIf="task.activityInstanceName == 'Tarefa de Despacho'">
        <div class="option-desc" *ngIf="task.WorkflowName == 'Despacho do Presidente da República' "> <div>Responder ao PR</div> </div>
        <button (click)="openAddNoteModal('Executado')" class="btn-cancel" shape="round" >Executado</button>
        <div class="option-desc" *ngIf="task.WorkflowName == 'Despacho do Presidente da República' ">Reencaminhar para Área jurídica</div>
        <button (click)="openAddNoteModal('Gerar Diploma')" *ngIf="task.WorkflowName == 'Despacho do Presidente da República'" class="btn-cancel" style="margin-bottom: 0px !important;" shape="round" >Gerar Diploma </button>
        <div class="option-desc" *ngIf="task.WorkflowName == 'Despacho do Presidente da República' " >Outras opções</div>
        <button (click)="openDelegarModal(task)" class="btn-cancel" shape="round" >Delegar</button>
        <div class="solid"></div>
        <button (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 (click)="openBookMeetingModal(task)" class="btn-cancel" shape="round" >Marcar Reunião</button>
        <div class="solid"></div>
        <button (click)="sendExpedienteToPending()" *ngIf="task.Status != 'Pending'" class="btn-cancel" shape="round" >Enviar para Pendentes</button>
      </div>
      <div class="buttons" *ngIf="task.activityInstanceName == 'Reexecutar Despacho'">
        <button (click)="openAddNoteModal('Executado')" class="btn-cancel" shape="round" >Executado</button>
        <button (click)="openDelegarModal(task)" class="btn-cancel" shape="round" >Delegar</button>
        <div class="solid"></div>
        <button (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 (click)="openBookMeetingModal(task)" class="btn-cancel" shape="round" >Marcar Reunião</button>
        <div class="solid"></div>
        <button (click)="sendExpedienteToPending()" *ngIf="task.Status != 'Pending'" class="btn-cancel" shape="round" >Enviar para Pendentes</button>
      </div>
      <div class="buttons" *ngIf="task.activityInstanceName == 'Concluir Despacho'">
        <button (click)="openAddNoteModal('Arquivar')" class="btn-cancel" shape="round" >Arquivar</button>
        <div class="solid"></div>
        <button (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 (click)="openBookMeetingModal(task)" class="btn-cancel" shape="round" >Marcar Reunião</button>
        <div class="solid"></div>
        <button (click)="sendExpedienteToPending()" *ngIf="task.Status != 'Pending'" class="btn-cancel" shape="round" >Enviar para Pendentes</button>
        <button (click)="openAddNoteModal('Reexecução')" class="btn-cancel" shape="round" >Enviar para Reexecução</button>
      </div>
    </div>
  </div>
</ion-content>

